Removed unused variables.
This commit is contained in:
@@ -65,28 +65,22 @@ extern FastAccelStepperEngine g_stepEngine;
|
|||||||
extern FastAccelStepper *g_pStepperRotate;
|
extern FastAccelStepper *g_pStepperRotate;
|
||||||
extern FastAccelStepper *g_pStepperPen;
|
extern FastAccelStepper *g_pStepperPen;
|
||||||
|
|
||||||
// extern FastAccelStepper rotMotor;
|
|
||||||
// extern FastAccelStepper penMotor;
|
|
||||||
extern Servo penServo;
|
extern Servo penServo;
|
||||||
extern SerialCommand SCmd;
|
extern SerialCommand SCmd;
|
||||||
|
|
||||||
extern int penMin;
|
extern int g_iPenUpPos;
|
||||||
extern int penMax;
|
extern int g_iPenDownPos;
|
||||||
extern int g_iPEN_UP_POS;
|
extern int g_iServoRateUp;
|
||||||
extern int g_iPEN_DOWN_POS;
|
extern int g_iServoRateDown;
|
||||||
extern int servoRateUp;
|
extern long g_iRotStepError;
|
||||||
extern int servoRateDown;
|
extern long g_iPenStepError;
|
||||||
extern long rotStepError;
|
extern int g_iPenState;
|
||||||
extern long penStepError;
|
extern uint32_t g_uiNodeCount;
|
||||||
extern int penState;
|
extern unsigned int g_uiLayer;
|
||||||
extern uint32_t nodeCount;
|
extern boolean g_bPrgButtonState;
|
||||||
extern unsigned int layer;
|
extern float fROT_STEP_CORRECTION;
|
||||||
extern boolean prgButtonState;
|
extern float fPEN_STEP_CORRECTION;
|
||||||
extern uint8_t rotStepCorrection;
|
extern boolean g_bMotorsEnabled;
|
||||||
extern uint8_t penStepCorrection;
|
|
||||||
extern float rotSpeed;
|
|
||||||
extern float penSpeed;
|
|
||||||
extern boolean motorsEnabled;
|
|
||||||
|
|
||||||
extern ConfigParameter configParameters[];
|
extern ConfigParameter configParameters[];
|
||||||
extern const size_t configParameterCount;
|
extern const size_t configParameterCount;
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ async function pollLogs() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log(String("Config gespeichert: penUpPos=") + g_iPEN_UP_POS + ", penDownPos=" + g_iPEN_DOWN_POS);
|
Log(String("Config gespeichert: penUpPos=") + g_iPenUpPos + ", penDownPos=" + g_iPenDownPos);
|
||||||
server.send(200, "application/json", buildConfigJson());
|
server.send(200, "application/json", buildConfigJson());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -273,7 +273,7 @@ bool loadConfigFromFile()
|
|||||||
param->description = item["description"].as<String>();
|
param->description = item["description"].as<String>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Log(String("Config geladen: penUpPos=") + g_iPEN_UP_POS + ", penDownPos=" + g_iPEN_DOWN_POS);
|
Log(String("Config geladen: penUpPos=") + g_iPenUpPos + ", penDownPos=" + g_iPenDownPos);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,9 @@
|
|||||||
|
|
||||||
void queryPen()
|
void queryPen()
|
||||||
{
|
{
|
||||||
|
Log(__FUNCTION__);
|
||||||
char state;
|
char state;
|
||||||
if (penState == g_iPEN_UP_POS)
|
if (g_iPenState == g_iPenUpPos)
|
||||||
state = '1';
|
state = '1';
|
||||||
else
|
else
|
||||||
state = '0';
|
state = '0';
|
||||||
@@ -13,26 +14,28 @@ void queryPen()
|
|||||||
|
|
||||||
void queryButton()
|
void queryButton()
|
||||||
{
|
{
|
||||||
Serial.print(String(prgButtonState) + "\r\n");
|
Serial.print(String(g_bPrgButtonState) + "\r\n");
|
||||||
sendAck();
|
sendAck();
|
||||||
prgButtonState = 0;
|
g_bPrgButtonState = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void queryLayer()
|
void queryLayer()
|
||||||
{
|
{
|
||||||
Serial.print(String(layer) + "\r\n");
|
Log(__FUNCTION__);
|
||||||
|
Serial.print(String(g_uiLayer) + "\r\n");
|
||||||
sendAck();
|
sendAck();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setLayer()
|
void setLayer()
|
||||||
{
|
{
|
||||||
|
Log(__FUNCTION__);
|
||||||
uint32_t value = 0;
|
uint32_t value = 0;
|
||||||
char *arg1;
|
char *arg1;
|
||||||
arg1 = SCmd.next();
|
arg1 = SCmd.next();
|
||||||
if (arg1 != NULL)
|
if (arg1 != NULL)
|
||||||
{
|
{
|
||||||
value = atoi(arg1);
|
value = atoi(arg1);
|
||||||
layer = value;
|
g_uiLayer = value;
|
||||||
sendAck();
|
sendAck();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -41,19 +44,20 @@ void setLayer()
|
|||||||
|
|
||||||
void queryNodeCount()
|
void queryNodeCount()
|
||||||
{
|
{
|
||||||
Serial.print(String(nodeCount) + "\r\n");
|
Serial.print(String(g_uiNodeCount) + "\r\n");
|
||||||
sendAck();
|
sendAck();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setNodeCount()
|
void setNodeCount()
|
||||||
{
|
{
|
||||||
|
Log(__FUNCTION__);
|
||||||
uint32_t value = 0;
|
uint32_t value = 0;
|
||||||
char *arg1;
|
char *arg1;
|
||||||
arg1 = SCmd.next();
|
arg1 = SCmd.next();
|
||||||
if (arg1 != NULL)
|
if (arg1 != NULL)
|
||||||
{
|
{
|
||||||
value = atoi(arg1);
|
value = atoi(arg1);
|
||||||
nodeCount = value;
|
g_uiNodeCount = value;
|
||||||
sendAck();
|
sendAck();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -62,18 +66,19 @@ void setNodeCount()
|
|||||||
|
|
||||||
void nodeCountIncrement()
|
void nodeCountIncrement()
|
||||||
{
|
{
|
||||||
nodeCount = nodeCount++;
|
g_uiNodeCount = g_uiNodeCount++;
|
||||||
sendAck();
|
sendAck();
|
||||||
}
|
}
|
||||||
|
|
||||||
void nodeCountDecrement()
|
void nodeCountDecrement()
|
||||||
{
|
{
|
||||||
nodeCount = nodeCount--;
|
g_uiNodeCount = g_uiNodeCount--;
|
||||||
sendAck();
|
sendAck();
|
||||||
}
|
}
|
||||||
|
|
||||||
void stepperMove()
|
void stepperMove()
|
||||||
{
|
{
|
||||||
|
Log(__FUNCTION__);
|
||||||
uint16_t duration = 0; // in ms
|
uint16_t duration = 0; // in ms
|
||||||
int penStepsEBB = 0; // Pen
|
int penStepsEBB = 0; // Pen
|
||||||
int rotStepsEBB = 0; // Rot
|
int rotStepsEBB = 0; // Rot
|
||||||
@@ -99,6 +104,7 @@ void stepperMove()
|
|||||||
|
|
||||||
void setPen()
|
void setPen()
|
||||||
{
|
{
|
||||||
|
Log(__FUNCTION__);
|
||||||
int cmd;
|
int cmd;
|
||||||
int value;
|
int value;
|
||||||
char *arg;
|
char *arg;
|
||||||
@@ -113,17 +119,11 @@ void setPen()
|
|||||||
switch (cmd)
|
switch (cmd)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
penServo.write(g_iPEN_UP_POS);
|
penServo.write(g_iPenUpPos);
|
||||||
penState = g_iPEN_UP_POS;
|
|
||||||
sprintf(cstrMsg, "PEN down: %d", g_iPEN_UP_POS);
|
|
||||||
Log(cstrMsg);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
penServo.write(g_iPEN_DOWN_POS);
|
penServo.write(g_iPenDownPos);
|
||||||
penState = g_iPEN_DOWN_POS;
|
|
||||||
sprintf(cstrMsg, "PEN up: %d", g_iPEN_DOWN_POS);
|
|
||||||
Log(cstrMsg);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -150,6 +150,7 @@ void setPen()
|
|||||||
|
|
||||||
void togglePen()
|
void togglePen()
|
||||||
{
|
{
|
||||||
|
Log(__FUNCTION__);
|
||||||
int value;
|
int value;
|
||||||
char *arg;
|
char *arg;
|
||||||
|
|
||||||
@@ -168,20 +169,22 @@ void togglePen()
|
|||||||
|
|
||||||
void doTogglePen()
|
void doTogglePen()
|
||||||
{
|
{
|
||||||
if (penState == g_iPEN_UP_POS)
|
Log(__FUNCTION__);
|
||||||
|
if (g_iPenState == g_iPenUpPos)
|
||||||
{
|
{
|
||||||
penServo.write(g_iPEN_DOWN_POS);
|
penServo.write(g_iPenDownPos);
|
||||||
penState = g_iPEN_DOWN_POS;
|
g_iPenState = g_iPenDownPos;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
penServo.write(g_iPEN_UP_POS);
|
penServo.write(g_iPenUpPos);
|
||||||
penState = g_iPEN_UP_POS;
|
g_iPenState = g_iPenUpPos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void enableMotors()
|
void enableMotors()
|
||||||
{
|
{
|
||||||
|
Log(__FUNCTION__);
|
||||||
int cmd;
|
int cmd;
|
||||||
int value;
|
int value;
|
||||||
char *arg;
|
char *arg;
|
||||||
@@ -230,6 +233,7 @@ void enableMotors()
|
|||||||
|
|
||||||
void stepperModeConfigure()
|
void stepperModeConfigure()
|
||||||
{
|
{
|
||||||
|
Log(__FUNCTION__);
|
||||||
int cmd;
|
int cmd;
|
||||||
int value;
|
int value;
|
||||||
char *arg;
|
char *arg;
|
||||||
@@ -245,14 +249,12 @@ void stepperModeConfigure()
|
|||||||
switch (cmd)
|
switch (cmd)
|
||||||
{
|
{
|
||||||
case 4:
|
case 4:
|
||||||
g_iPEN_DOWN_POS = (int)((float)(value - 6000) / (float)133.3); // transformation from EBB to PWM-Servo
|
g_iPenDownPos = (int)((float)(value - 6000) / (float)133.3); // transformation from EBB to PWM-Servo
|
||||||
Log(String("SC set PEN_DOWN_POS -> ") + g_iPEN_DOWN_POS + " (raw " + value + ")");
|
|
||||||
storePenDownPosInEE();
|
storePenDownPosInEE();
|
||||||
sendAck();
|
sendAck();
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
g_iPEN_UP_POS = (int)((float)(value - 6000) / (float)133.3); // transformation from EBB to PWM-Servo
|
g_iPenUpPos = (int)((float)(value - 6000) / (float)133.3); // transformation from EBB to PWM-Servo
|
||||||
Log(String("SC set PEN_UP_POS -> ") + g_iPEN_UP_POS + " (raw " + value + ")");
|
|
||||||
storePenUpPosInEE();
|
storePenUpPosInEE();
|
||||||
sendAck();
|
sendAck();
|
||||||
break;
|
break;
|
||||||
@@ -263,11 +265,11 @@ void stepperModeConfigure()
|
|||||||
sendAck();
|
sendAck();
|
||||||
break;
|
break;
|
||||||
case 11:
|
case 11:
|
||||||
servoRateUp = value;
|
g_iServoRateUp = value;
|
||||||
sendAck();
|
sendAck();
|
||||||
break;
|
break;
|
||||||
case 12:
|
case 12:
|
||||||
servoRateDown = value;
|
g_iServoRateDown = value;
|
||||||
sendAck();
|
sendAck();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -278,17 +280,20 @@ void stepperModeConfigure()
|
|||||||
|
|
||||||
void sendVersion()
|
void sendVersion()
|
||||||
{
|
{
|
||||||
|
Log(__FUNCTION__);
|
||||||
Serial.print(initSting);
|
Serial.print(initSting);
|
||||||
Serial.print("\r\n");
|
Serial.print("\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void unrecognized(const char *command)
|
void unrecognized(const char *command)
|
||||||
{
|
{
|
||||||
|
Log(__FUNCTION__);
|
||||||
sendError();
|
sendError();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ignore()
|
void ignore()
|
||||||
{
|
{
|
||||||
|
Log(__FUNCTION__);
|
||||||
sendAck();
|
sendAck();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ void initHardware()
|
|||||||
{
|
{
|
||||||
if (!initConfigStore())
|
if (!initConfigStore())
|
||||||
{
|
{
|
||||||
g_iPEN_UP_POS = 5;
|
g_iPenUpPos = 5;
|
||||||
g_iPEN_DOWN_POS = 20;
|
g_iPenDownPos = 20;
|
||||||
}
|
}
|
||||||
penState = g_iPEN_UP_POS;
|
g_iPenState = g_iPenUpPos;
|
||||||
|
|
||||||
g_stepEngine.init();
|
g_stepEngine.init();
|
||||||
g_pStepperRotate = g_stepEngine.stepperConnectToPin(step1);
|
g_pStepperRotate = g_stepEngine.stepperConnectToPin(step1);
|
||||||
@@ -36,7 +36,7 @@ void initHardware()
|
|||||||
|
|
||||||
motorsOff();
|
motorsOff();
|
||||||
penServo.attach(servoPin);
|
penServo.attach(servoPin);
|
||||||
penServo.write(penState);
|
penServo.write(g_iPenState);
|
||||||
}
|
}
|
||||||
|
|
||||||
void storePenUpPosInEE()
|
void storePenUpPosInEE()
|
||||||
@@ -51,35 +51,36 @@ void storePenDownPosInEE()
|
|||||||
|
|
||||||
void sendAck()
|
void sendAck()
|
||||||
{
|
{
|
||||||
|
Log(__FUNCTION__);
|
||||||
Serial.print("OK\r\n");
|
Serial.print("OK\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendError()
|
void sendError()
|
||||||
{
|
{
|
||||||
|
Log(__FUNCTION__);
|
||||||
Serial.print("unknown CMD\r\n");
|
Serial.print("unknown CMD\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void motorsOff()
|
void motorsOff()
|
||||||
{
|
{
|
||||||
// digitalWrite(enableRotMotor, HIGH);
|
Log(__FUNCTION__);
|
||||||
// digitalWrite(enablePenMotor, HIGH);
|
|
||||||
g_pStepperPen->disableOutputs();
|
g_pStepperPen->disableOutputs();
|
||||||
g_pStepperRotate->disableOutputs();
|
g_pStepperRotate->disableOutputs();
|
||||||
motorsEnabled = 0;
|
g_bMotorsEnabled = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void motorsOn()
|
void motorsOn()
|
||||||
{
|
{
|
||||||
// digitalWrite(enableRotMotor, LOW) ;
|
Log(__FUNCTION__);
|
||||||
// digitalWrite(enablePenMotor, LOW) ;
|
|
||||||
g_pStepperPen->enableOutputs();
|
g_pStepperPen->enableOutputs();
|
||||||
g_pStepperRotate->enableOutputs();
|
g_pStepperRotate->enableOutputs();
|
||||||
motorsEnabled = 1;
|
g_bMotorsEnabled = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void toggleMotors()
|
void toggleMotors()
|
||||||
{
|
{
|
||||||
if (motorsEnabled)
|
Log(__FUNCTION__);
|
||||||
|
if (g_bMotorsEnabled)
|
||||||
{
|
{
|
||||||
motorsOff();
|
motorsOff();
|
||||||
}
|
}
|
||||||
@@ -117,36 +118,18 @@ bool parseSMArgs(uint16_t *duration, int *penStepsEBB, int *rotStepsEBB)
|
|||||||
|
|
||||||
void prepareMove(uint16_t duration, int penStepsEBB, int rotStepsEBB)
|
void prepareMove(uint16_t duration, int penStepsEBB, int rotStepsEBB)
|
||||||
{
|
{
|
||||||
if (!motorsEnabled)
|
if (!g_bMotorsEnabled)
|
||||||
{
|
{
|
||||||
motorsOn();
|
motorsOn();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (duration == 0)
|
|
||||||
{
|
|
||||||
duration = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (penStepCorrection == 0)
|
if ((1 == fROT_STEP_CORRECTION) && (1 == fPEN_STEP_CORRECTION))
|
||||||
{
|
|
||||||
penStepCorrection = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rotStepCorrection == 0)
|
|
||||||
{
|
|
||||||
rotStepCorrection = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((1 == rotStepCorrection) && (1 == penStepCorrection))
|
|
||||||
{ // if coordinatessystems are identical
|
{ // if coordinatessystems are identical
|
||||||
// set Coordinates and Speed
|
// set Coordinates and Speed
|
||||||
// rotMotor.move(rotStepsEBB);
|
|
||||||
// rotMotor.setSpeed(abs((float)rotStepsEBB * (float)1000 / (float)duration));
|
|
||||||
g_pStepperRotate->move(rotStepsEBB);
|
g_pStepperRotate->move(rotStepsEBB);
|
||||||
g_pStepperRotate->setSpeedInTicks(abs((float)rotStepsEBB * (float)1000 / (float)duration));
|
g_pStepperRotate->setSpeedInTicks(abs((float)rotStepsEBB * (float)1000 / (float)duration));
|
||||||
|
|
||||||
// penMotor.move(penStepsEBB);
|
|
||||||
// penMotor.setSpeed(abs((float)penStepsEBB * (float)1000 / (float)duration));
|
|
||||||
g_pStepperPen->move(penStepsEBB);
|
g_pStepperPen->move(penStepsEBB);
|
||||||
g_pStepperPen->setSpeedInTicks(abs((float)penStepsEBB * (float)1000 / (float)duration));
|
g_pStepperPen->setSpeedInTicks(abs((float)penStepsEBB * (float)1000 / (float)duration));
|
||||||
}
|
}
|
||||||
@@ -154,14 +137,14 @@ void prepareMove(uint16_t duration, int penStepsEBB, int rotStepsEBB)
|
|||||||
{
|
{
|
||||||
// incoming EBB-Steps will be multiplied by 16, then Integer-maths is done, result will be divided by 16
|
// incoming EBB-Steps will be multiplied by 16, then Integer-maths is done, result will be divided by 16
|
||||||
// This make thinks here really complicated, but floating point-math kills performance and memory, believe me... I tried...
|
// This make thinks here really complicated, but floating point-math kills performance and memory, believe me... I tried...
|
||||||
long rotSteps = ((long)rotStepsEBB * 16 / rotStepCorrection) + (long)rotStepError; // correct incoming EBB-Steps to our microstep-Setting and multiply by 16 to avoid floatingpoint...
|
long rotSteps = ((long)rotStepsEBB * 16 / fROT_STEP_CORRECTION) + (long)g_iRotStepError; // correct incoming EBB-Steps to our microstep-Setting and multiply by 16 to avoid floatingpoint...
|
||||||
long penSteps = ((long)penStepsEBB * 16 / penStepCorrection) + (long)penStepError;
|
long penSteps = ((long)penStepsEBB * 16 / fPEN_STEP_CORRECTION) + (long)g_iPenStepError;
|
||||||
|
|
||||||
int rotStepsToGo = (int)(rotSteps / 16); // Calc Steps to go, which are possible on our machine
|
int rotStepsToGo = (int)(rotSteps / 16); // Calc Steps to go, which are possible on our machine
|
||||||
int penStepsToGo = (int)(penSteps / 16);
|
int penStepsToGo = (int)(penSteps / 16);
|
||||||
|
|
||||||
rotStepError = (long)rotSteps - ((long)rotStepsToGo * (long)16); // calc Position-Error, if there is one
|
g_iRotStepError = (long)rotSteps - ((long)rotStepsToGo * (long)16); // calc Position-Error, if there is one
|
||||||
penStepError = (long)penSteps - ((long)penStepsToGo * (long)16);
|
g_iPenStepError = (long)penSteps - ((long)penStepsToGo * (long)16);
|
||||||
|
|
||||||
long temp_rotSpeed = ((long)rotStepsToGo * (long)1000 / (long)duration); // calc Speed in Integer Math
|
long temp_rotSpeed = ((long)rotStepsToGo * (long)1000 / (long)duration); // calc Speed in Integer Math
|
||||||
long temp_penSpeed = ((long)penStepsToGo * (long)1000 / (long)duration);
|
long temp_penSpeed = ((long)penStepsToGo * (long)1000 / (long)duration);
|
||||||
@@ -170,13 +153,9 @@ void prepareMove(uint16_t duration, int penStepsEBB, int rotStepsEBB)
|
|||||||
float penSpeed = (float)abs(temp_penSpeed);
|
float penSpeed = (float)abs(temp_penSpeed);
|
||||||
|
|
||||||
// set Coordinates and Speed
|
// set Coordinates and Speed
|
||||||
// rotMotor.move(rotStepsToGo); // finally, let us set the target position...
|
|
||||||
// rotMotor.setSpeed(rotSpeed); // and the Speed!
|
|
||||||
g_pStepperRotate->move(rotStepsToGo);
|
g_pStepperRotate->move(rotStepsToGo);
|
||||||
g_pStepperRotate->setSpeedInTicks(rotSpeed);
|
g_pStepperRotate->setSpeedInTicks(rotSpeed);
|
||||||
|
|
||||||
// penMotor.move(penStepsToGo);
|
|
||||||
// penMotor.setSpeed(penSpeed);
|
|
||||||
g_pStepperPen->move(penStepsToGo);
|
g_pStepperPen->move(penStepsToGo);
|
||||||
g_pStepperPen->setSpeedInTicks(penSpeed);
|
g_pStepperPen->setSpeedInTicks(penSpeed);
|
||||||
}
|
}
|
||||||
@@ -184,27 +163,15 @@ void prepareMove(uint16_t duration, int penStepsEBB, int rotStepsEBB)
|
|||||||
|
|
||||||
void moveOneStep()
|
void moveOneStep()
|
||||||
{
|
{
|
||||||
while (g_pStepperPen->isRunning() || g_pStepperRotate->isRunning())
|
while (g_pStepperPen->isRunning() || g_pStepperRotate->isRunning());
|
||||||
;
|
|
||||||
// if (penMotor.distanceToGo() || rotMotor.distanceToGo())
|
|
||||||
// {
|
|
||||||
// penMotor.runSpeedToPosition(); // Moving.... moving... moving....
|
|
||||||
// rotMotor.runSpeedToPosition();
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void moveToDestination()
|
void moveToDestination()
|
||||||
{
|
{
|
||||||
while (g_pStepperPen->isRunning() || g_pStepperRotate->isRunning())
|
while (g_pStepperPen->isRunning() || g_pStepperRotate->isRunning());
|
||||||
;
|
|
||||||
// while (penMotor.distanceToGo() || rotMotor.distanceToGo())
|
|
||||||
// {
|
|
||||||
// penMotor.runSpeedToPosition(); // Moving.... moving... moving....
|
|
||||||
// rotMotor.runSpeedToPosition();
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setprgButtonState()
|
void setprgButtonState()
|
||||||
{
|
{
|
||||||
prgButtonState = 1;
|
g_bPrgButtonState = 1;
|
||||||
}
|
}
|
||||||
|
|||||||
38
src/main.cpp
38
src/main.cpp
@@ -34,8 +34,6 @@ FastAccelStepper *g_pStepperRotate = NULL;
|
|||||||
FastAccelStepper *g_pStepperPen = NULL;
|
FastAccelStepper *g_pStepperPen = NULL;
|
||||||
|
|
||||||
// make Objects
|
// make Objects
|
||||||
// FastAccelStepper rotMotor(FastAccelStepper::DRIVER, step1, dir1);
|
|
||||||
// FastAccelStepper penMotor(FastAccelStepper::DRIVER, step2, dir2);
|
|
||||||
Servo penServo;
|
Servo penServo;
|
||||||
SerialCommand SCmd;
|
SerialCommand SCmd;
|
||||||
|
|
||||||
@@ -49,29 +47,28 @@ Button penToggle(penToggleButton, doTogglePen);
|
|||||||
#ifdef motorsButton
|
#ifdef motorsButton
|
||||||
Button motorsToggle(motorsButton, toggleMotors);
|
Button motorsToggle(motorsButton, toggleMotors);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Variables... be careful, by messing around here, everything has a reason and crossrelations...
|
// Variables... be careful, by messing around here, everything has a reason and crossrelations...
|
||||||
int penMin = 0;
|
int g_iPenUpPos = 5; // can be overwritten from EBB-Command SC
|
||||||
int penMax = 0;
|
int g_iPenDownPos = 20; // can be overwritten from EBB-Command SC
|
||||||
int g_iPEN_UP_POS = 5; // can be overwritten from EBB-Command SC
|
int g_iServoRateUp = 0; // from EBB-Protocol not implemented on machine-side
|
||||||
int g_iPEN_DOWN_POS = 20; // can be overwritten from EBB-Command SC
|
int g_iServoRateDown = 0; // from EBB-Protocol not implemented on machine-side
|
||||||
int servoRateUp = 0; // from EBB-Protocol not implemented on machine-side
|
long g_iRotStepError = 0;
|
||||||
int servoRateDown = 0; // from EBB-Protocol not implemented on machine-side
|
long g_iPenStepError = 0;
|
||||||
long rotStepError = 0;
|
int g_iPenState = g_iPenUpPos;
|
||||||
long penStepError = 0;
|
uint32_t g_uiNodeCount = 0;
|
||||||
int penState = g_iPEN_UP_POS;
|
unsigned int g_uiLayer = 0;
|
||||||
uint32_t nodeCount = 0;
|
boolean g_bPrgButtonState = 0;
|
||||||
unsigned int layer = 0;
|
float fROT_STEP_CORRECTION = 16.0 / rotMicrostep; // devide EBB-Coordinates by this factor to get EGGduino-Steps
|
||||||
boolean prgButtonState = 0;
|
float fPEN_STEP_CORRECTION = 16.0 / penMicrostep; // devide EBB-Coordinates by this factor to get EGGduino-Steps
|
||||||
uint8_t rotStepCorrection = 16 / rotMicrostep; // devide EBB-Coordinates by this factor to get EGGduino-Steps
|
boolean g_bMotorsEnabled = 0;
|
||||||
uint8_t penStepCorrection = 16 / penMicrostep; // devide EBB-Coordinates by this factor to get EGGduino-Steps
|
|
||||||
float rotSpeed = 0;
|
|
||||||
float penSpeed = 0; // these are local variables for Function SteppermotorMove-Command, but for performance-reasons it will be initialized here
|
|
||||||
boolean motorsEnabled = 0;
|
|
||||||
|
|
||||||
// Stepper Test
|
// Stepper Test
|
||||||
|
#ifdef TEST
|
||||||
// #define dirPinStepper 16
|
// #define dirPinStepper 16
|
||||||
// #define enablePinStepper 12
|
// #define enablePinStepper 12
|
||||||
// #define stepPinStepper 26
|
// #define stepPinStepper 26
|
||||||
|
#endif
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
@@ -135,10 +132,11 @@ void loop()
|
|||||||
}
|
}
|
||||||
Log("Alive");
|
Log("Alive");
|
||||||
}
|
}
|
||||||
#endif
|
#else
|
||||||
// moveOneStep();
|
// moveOneStep();
|
||||||
SCmd.readSerial();
|
SCmd.readSerial();
|
||||||
handleWebInterface();
|
handleWebInterface();
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef penToggleButton
|
#ifdef penToggleButton
|
||||||
penToggle.check();
|
penToggle.check();
|
||||||
|
|||||||
Reference in New Issue
Block a user