debugging
parent
fe55f588bd
commit
4e28fa5069
|
@ -7,18 +7,18 @@
|
|||
enum CommandCodeEnum
|
||||
{
|
||||
CODE_UNDEFINED = -1,
|
||||
G00 = 0,
|
||||
G01,
|
||||
G28,
|
||||
F01,
|
||||
F02,
|
||||
F03,
|
||||
F11,
|
||||
F12,
|
||||
F13,
|
||||
F81,
|
||||
F82,
|
||||
F83
|
||||
G00 = 0,
|
||||
G01 = 1,
|
||||
G28 = 28,
|
||||
F01 = 101,
|
||||
F02 = 102,
|
||||
F03 = 103,
|
||||
F11 = 111,
|
||||
F12 = 112,
|
||||
F13 = 113,
|
||||
F81 = 181,
|
||||
F82 = 182,
|
||||
F83 = 183
|
||||
};
|
||||
|
||||
#define NULL 0
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#ifndef CONFIG_H_
|
||||
#define CONFIG_H_
|
||||
|
||||
const int LOGGING = 1;
|
||||
const int LOGGING = 0;
|
||||
|
||||
const unsigned int MAX_STEPS_PER_SECOND = 100;
|
||||
const unsigned int MAX_ACCELERATION_STEPS_PER_SECOND = 2;
|
||||
|
|
|
@ -28,32 +28,32 @@ CurrentState::CurrentState() {
|
|||
speed = 0;
|
||||
}
|
||||
|
||||
unsigned int CurrentState::getX() {
|
||||
long CurrentState::getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
unsigned int CurrentState::getY() {
|
||||
long CurrentState::getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
unsigned int CurrentState::getZ() {
|
||||
long CurrentState::getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
unsigned int* CurrentState::getPoint() {
|
||||
unsigned int currentPoint[3] = {x, y, z};
|
||||
long* CurrentState::getPoint() {
|
||||
long currentPoint[3] = {x, y, z};
|
||||
return currentPoint;
|
||||
}
|
||||
|
||||
void CurrentState::setX(unsigned int newX) {
|
||||
void CurrentState::setX(long newX) {
|
||||
x = newX;
|
||||
}
|
||||
|
||||
void CurrentState::setY(unsigned int newY) {
|
||||
void CurrentState::setY(long newY) {
|
||||
y = newY;
|
||||
}
|
||||
|
||||
void CurrentState::setZ(unsigned int newZ) {
|
||||
void CurrentState::setZ(long newZ) {
|
||||
z = newZ;
|
||||
}
|
||||
|
||||
|
@ -61,6 +61,15 @@ void CurrentState::setEndStopState(unsigned int axis, unsigned int position, boo
|
|||
endStopState[axis][position] = state;
|
||||
}
|
||||
|
||||
void CurrentState::storeEndStops() {
|
||||
CurrentState::getInstance()->setEndStopState(0,0,digitalRead(X_MIN_PIN));
|
||||
CurrentState::getInstance()->setEndStopState(0,1,digitalRead(X_MAX_PIN));
|
||||
CurrentState::getInstance()->setEndStopState(1,0,digitalRead(Y_MIN_PIN));
|
||||
CurrentState::getInstance()->setEndStopState(1,1,digitalRead(Y_MAX_PIN));
|
||||
CurrentState::getInstance()->setEndStopState(2,0,digitalRead(Z_MIN_PIN));
|
||||
CurrentState::getInstance()->setEndStopState(3,1,digitalRead(Z_MAX_PIN));
|
||||
}
|
||||
|
||||
void CurrentState::printPosition() {
|
||||
Serial.print("R82");
|
||||
Serial.print(" X");
|
||||
|
|
|
@ -8,19 +8,21 @@
|
|||
#ifndef CURRENTSTATE_H_
|
||||
#define CURRENTSTATE_H_
|
||||
#include "Arduino.h"
|
||||
#include "pins.h"
|
||||
|
||||
class CurrentState {
|
||||
public:
|
||||
static CurrentState* getInstance();
|
||||
unsigned int getX();
|
||||
unsigned int getY();
|
||||
unsigned int getZ();
|
||||
unsigned int* getPoint();
|
||||
void setX(unsigned int);
|
||||
void setY(unsigned int);
|
||||
void setZ(unsigned int);
|
||||
long getX();
|
||||
long getY();
|
||||
long getZ();
|
||||
long* getPoint();
|
||||
void setX(long);
|
||||
void setY(long);
|
||||
void setZ(long);
|
||||
void setEndStopState(unsigned int, unsigned int, bool);
|
||||
void printPosition();
|
||||
void storeEndStops();
|
||||
void printEndStops();
|
||||
void print();
|
||||
void printBool(bool);
|
||||
|
|
|
@ -31,6 +31,7 @@ Serial.print("home\n");
|
|||
Serial.print("R99 Report end stops\n");
|
||||
}
|
||||
|
||||
CurrentState::getInstance()->storeEndStops();
|
||||
CurrentState::getInstance()->printEndStops();
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -25,8 +25,6 @@ F83Handler::F83Handler() {
|
|||
|
||||
int F83Handler::execute(Command* command) {
|
||||
|
||||
Serial.print("home\n");
|
||||
|
||||
if (LOGGING) {
|
||||
Serial.print("R99 Report server version\n");
|
||||
}
|
||||
|
@ -35,10 +33,6 @@ Serial.print("home\n");
|
|||
Serial.print(SOFTWARE_VERSION);
|
||||
Serial.print("\n");
|
||||
|
||||
StepperControl::getInstance()->moveAbsoluteConstant(0,0,0,0, false, false, true);
|
||||
if (LOGGING) {
|
||||
CurrentState::getInstance()->print();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,6 +37,8 @@ int GCodeProcessor::execute(Command* command) {
|
|||
int execution = handler->execute(command);
|
||||
if(execution == 0) {
|
||||
Serial.println("R02");
|
||||
} else {
|
||||
Serial.println("R03");
|
||||
}
|
||||
return execution;
|
||||
};
|
||||
|
|
|
@ -242,18 +242,6 @@ int endStopsReached() {
|
|||
bool z_min_endstop=(digitalRead(Z_MIN_PIN) == INVERT_ENDSTOPS);
|
||||
bool z_max_endstop=(digitalRead(Z_MAX_PIN) == INVERT_ENDSTOPS);
|
||||
if(x_min_endstop || x_max_endstop || y_min_endstop || y_max_endstop || z_min_endstop || z_max_endstop) {
|
||||
Serial.print("R03 ");
|
||||
Serial.print(x_min_endstop);
|
||||
Serial.print(" ");
|
||||
Serial.print(x_max_endstop);
|
||||
Serial.print(" ");
|
||||
Serial.print(y_min_endstop);
|
||||
Serial.print(" ");
|
||||
Serial.print(y_max_endstop);
|
||||
Serial.print(" ");
|
||||
Serial.print(z_min_endstop);
|
||||
Serial.print(" ");
|
||||
Serial.println(z_max_endstop);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -293,42 +281,12 @@ int endStopAxisReached(int axis_nr, bool movement_forward) {
|
|||
void reportEndStops() {
|
||||
|
||||
CurrentState::getInstance()->printEndStops();
|
||||
|
||||
/*
|
||||
bool x_min_endstop=(digitalRead(X_MIN_PIN) == INVERT_ENDSTOPS);
|
||||
bool x_max_endstop=(digitalRead(X_MAX_PIN) == INVERT_ENDSTOPS);
|
||||
bool y_min_endstop=(digitalRead(Y_MIN_PIN) == INVERT_ENDSTOPS);
|
||||
bool y_max_endstop=(digitalRead(Y_MAX_PIN) == INVERT_ENDSTOPS);
|
||||
bool z_min_endstop=(digitalRead(Z_MIN_PIN) == INVERT_ENDSTOPS);
|
||||
bool z_max_endstop=(digitalRead(Z_MAX_PIN) == INVERT_ENDSTOPS);
|
||||
if(x_min_endstop || x_max_endstop || y_min_endstop || y_max_endstop || z_min_endstop || z_max_endstop) {
|
||||
Serial.print("R03 ");
|
||||
Serial.print(x_min_endstop);
|
||||
Serial.print(" ");
|
||||
Serial.print(x_max_endstop);
|
||||
Serial.print(" ");
|
||||
Serial.print(y_min_endstop);
|
||||
Serial.print(" ");
|
||||
Serial.print(y_max_endstop);
|
||||
Serial.print(" ");
|
||||
Serial.print(z_min_endstop);
|
||||
Serial.print(" ");
|
||||
Serial.println(z_max_endstop);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
*/
|
||||
}
|
||||
|
||||
void storeEndStops() {
|
||||
CurrentState::getInstance()->setEndStopState(0,0,digitalRead(X_MIN_PIN));
|
||||
CurrentState::getInstance()->setEndStopState(0,1,digitalRead(X_MAX_PIN));
|
||||
CurrentState::getInstance()->setEndStopState(1,0,digitalRead(Y_MIN_PIN));
|
||||
CurrentState::getInstance()->setEndStopState(1,1,digitalRead(Y_MAX_PIN));
|
||||
CurrentState::getInstance()->setEndStopState(2,0,digitalRead(Z_MIN_PIN));
|
||||
CurrentState::getInstance()->setEndStopState(3,1,digitalRead(Z_MAX_PIN));
|
||||
}
|
||||
|
||||
CurrentState::getInstance()->storeEndStops();
|
||||
}
|
||||
|
||||
/**
|
||||
* xDest - destination X in steps
|
||||
|
|
Loading…
Reference in New Issue