Removed unused variables.

This commit is contained in:
2026-02-21 15:43:09 +01:00
parent c1bc52c5a3
commit 556c7888de
5 changed files with 87 additions and 123 deletions

View File

@@ -4,10 +4,10 @@ void initHardware()
{
if (!initConfigStore())
{
g_iPEN_UP_POS = 5;
g_iPEN_DOWN_POS = 20;
g_iPenUpPos = 5;
g_iPenDownPos = 20;
}
penState = g_iPEN_UP_POS;
g_iPenState = g_iPenUpPos;
g_stepEngine.init();
g_pStepperRotate = g_stepEngine.stepperConnectToPin(step1);
@@ -36,7 +36,7 @@ void initHardware()
motorsOff();
penServo.attach(servoPin);
penServo.write(penState);
penServo.write(g_iPenState);
}
void storePenUpPosInEE()
@@ -51,35 +51,36 @@ void storePenDownPosInEE()
void sendAck()
{
Log(__FUNCTION__);
Serial.print("OK\r\n");
}
void sendError()
{
Log(__FUNCTION__);
Serial.print("unknown CMD\r\n");
}
void motorsOff()
{
// digitalWrite(enableRotMotor, HIGH);
// digitalWrite(enablePenMotor, HIGH);
Log(__FUNCTION__);
g_pStepperPen->disableOutputs();
g_pStepperRotate->disableOutputs();
motorsEnabled = 0;
g_bMotorsEnabled = 0;
}
void motorsOn()
{
// digitalWrite(enableRotMotor, LOW) ;
// digitalWrite(enablePenMotor, LOW) ;
Log(__FUNCTION__);
g_pStepperPen->enableOutputs();
g_pStepperRotate->enableOutputs();
motorsEnabled = 1;
g_bMotorsEnabled = 1;
}
void toggleMotors()
{
if (motorsEnabled)
Log(__FUNCTION__);
if (g_bMotorsEnabled)
{
motorsOff();
}
@@ -117,36 +118,18 @@ bool parseSMArgs(uint16_t *duration, int *penStepsEBB, int *rotStepsEBB)
void prepareMove(uint16_t duration, int penStepsEBB, int rotStepsEBB)
{
if (!motorsEnabled)
if (!g_bMotorsEnabled)
{
motorsOn();
}
if (duration == 0)
{
duration = 1;
}
if (penStepCorrection == 0)
{
penStepCorrection = 1;
}
if (rotStepCorrection == 0)
{
rotStepCorrection = 1;
}
if ((1 == rotStepCorrection) && (1 == penStepCorrection))
if ((1 == fROT_STEP_CORRECTION) && (1 == fPEN_STEP_CORRECTION))
{ // if coordinatessystems are identical
// set Coordinates and Speed
// rotMotor.move(rotStepsEBB);
// rotMotor.setSpeed(abs((float)rotStepsEBB * (float)1000 / (float)duration));
g_pStepperRotate->move(rotStepsEBB);
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->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
// 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 penSteps = ((long)penStepsEBB * 16 / penStepCorrection) + (long)penStepError;
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 / fPEN_STEP_CORRECTION) + (long)g_iPenStepError;
int rotStepsToGo = (int)(rotSteps / 16); // Calc Steps to go, which are possible on our machine
int penStepsToGo = (int)(penSteps / 16);
rotStepError = (long)rotSteps - ((long)rotStepsToGo * (long)16); // calc Position-Error, if there is one
penStepError = (long)penSteps - ((long)penStepsToGo * (long)16);
g_iRotStepError = (long)rotSteps - ((long)rotStepsToGo * (long)16); // calc Position-Error, if there is one
g_iPenStepError = (long)penSteps - ((long)penStepsToGo * (long)16);
long temp_rotSpeed = ((long)rotStepsToGo * (long)1000 / (long)duration); // calc Speed in Integer Math
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);
// 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->setSpeedInTicks(rotSpeed);
// penMotor.move(penStepsToGo);
// penMotor.setSpeed(penSpeed);
g_pStepperPen->move(penStepsToGo);
g_pStepperPen->setSpeedInTicks(penSpeed);
}
@@ -184,27 +163,15 @@ void prepareMove(uint16_t duration, int penStepsEBB, int rotStepsEBB)
void moveOneStep()
{
while (g_pStepperPen->isRunning() || g_pStepperRotate->isRunning())
;
// if (penMotor.distanceToGo() || rotMotor.distanceToGo())
// {
// penMotor.runSpeedToPosition(); // Moving.... moving... moving....
// rotMotor.runSpeedToPosition();
// }
while (g_pStepperPen->isRunning() || g_pStepperRotate->isRunning());
}
void moveToDestination()
{
while (g_pStepperPen->isRunning() || g_pStepperRotate->isRunning())
;
// while (penMotor.distanceToGo() || rotMotor.distanceToGo())
// {
// penMotor.runSpeedToPosition(); // Moving.... moving... moving....
// rotMotor.runSpeedToPosition();
// }
while (g_pStepperPen->isRunning() || g_pStepperRotate->isRunning());
}
void setprgButtonState()
{
prgButtonState = 1;
g_bPrgButtonState = 1;
}