remove moving flag

Signed-off-by: Stepan Usatyuk <usaatyuk@ustk.me>
This commit is contained in:
2019-05-29 14:52:26 +03:00
parent 1f56ab71a3
commit d386913630

View File

@@ -7,7 +7,6 @@
int curRPM = DEF_RPM; int curRPM = DEF_RPM;
int adjustDelay = 100; int adjustDelay = 100;
bool needAdjust; bool needAdjust;
bool moving;
int calculateDelay(float rpm, int stepsPerRevolution) { int calculateDelay(float rpm, int stepsPerRevolution) {
return ((float)1000 * (float)60) / (rpm * (float)stepsPerRevolution); return ((float)1000 * (float)60) / (rpm * (float)stepsPerRevolution);
@@ -29,8 +28,10 @@ void adjustRPM() {
} }
} }
} }
cli();
eggStepperDelay = calculateDelay(eggStepperRPM, STEPS_PER_REVOLUTION); eggStepperDelay = calculateDelay(eggStepperRPM, STEPS_PER_REVOLUTION);
servoStepperDelay = calculateDelay(servoStepperRPM, STEPS_PER_REVOLUTION); servoStepperDelay = calculateDelay(servoStepperRPM, STEPS_PER_REVOLUTION);
sei();
} }
int curFloat = 0; int curFloat = 0;
@@ -80,7 +81,7 @@ void requestEvent() {
void execCommand(float *command) { void execCommand(float *command) {
executing = true; executing = true;
moving = false; cli();
if (command[0] == G01 || command[0] == G00) { if (command[0] == G01 || command[0] == G00) {
if (command[0] == G01) { if (command[0] == G01) {
needAdjust = true; needAdjust = true;
@@ -107,10 +108,10 @@ void execCommand(float *command) {
adjustRPM(); adjustRPM();
moving = true; sei();
return; return;
} }
sei();
} }
void setup() { void setup() {
@@ -133,13 +134,11 @@ unsigned int ms = 0;
ISR(TIMER2_COMP_vect) { ISR(TIMER2_COMP_vect) {
ms++; ms++;
if (moving) { if (ms % eggStepperDelay == 0) {
if (ms % eggStepperDelay == 0) { eggStepper.doStep();
eggStepper.doStep(); }
} if (ms % servoStepperDelay == 0) {
if (ms % servoStepperDelay == 0) { servoStepper.doStep();
servoStepper.doStep();
}
} }
} }