improve output, count steps

This commit is contained in:
Ronald Schaten 2022-02-10 20:44:01 +01:00
parent 69a47940ce
commit 780262155a
2 changed files with 38 additions and 9 deletions

View File

@ -12,9 +12,10 @@ Scenerunner::Scenerunner(LiquidCrystal *lcd, BasicStepperDriver *stepper, int pi
}
void Scenerunner::start() {
step = 1;
_lcd->clear();
_lcd->print("Running...");
steps_left = nSteps;
_lcd->print("Step ");
_lcd->print(step);
runStep = RUN_SETTLE;
runStepStart = millis();
}
@ -26,8 +27,13 @@ void Scenerunner::_runHandler_off() {
void Scenerunner::_runHandler_settle() {
_lcd->setCursor(0, 1);
_lcd->print("rS: SETTLE ");
_lcd->print("Settling ");
_lcd->print(tSettle);
_lcd->print("ms");
if (millis() >= runStepStart + tSettle) {
_lcd->clear();
_lcd->print("Step ");
_lcd->print(step);
runStep = RUN_FOCUS;
runStepStart = millis();
}
@ -35,8 +41,13 @@ void Scenerunner::_runHandler_settle() {
void Scenerunner::_runHandler_focus() {
_lcd->setCursor(0, 1);
_lcd->print("rS: FOCUS ");
_lcd->print("Focusing ");
_lcd->print(tFocus);
_lcd->print("ms");
if (millis() >= runStepStart + tFocus) {
_lcd->clear();
_lcd->print("Step ");
_lcd->print(step);
runStep = RUN_SHUTTER;
runStepStart = millis();
}
@ -44,18 +55,36 @@ void Scenerunner::_runHandler_focus() {
void Scenerunner::_runHandler_shutter() {
_lcd->setCursor(0, 1);
_lcd->print("rS: SHUTTER ");
_lcd->print("Shutter ");
_lcd->print(tShutter);
_lcd->print("ms");
if (millis() >= runStepStart + tShutter) {
runStep = RUN_MOVE;
runStepStart = millis();
if (step >= nSteps) {
_lcd->clear();
_lcd->print("Return to start");
runStep = RUN_RETURN;
runStepStart = millis();
} else {
step++;
_lcd->clear();
_lcd->print("Step ");
_lcd->print(step);
runStep = RUN_MOVE;
runStepStart = millis();
}
}
}
void Scenerunner::_runHandler_move() {
_lcd->setCursor(0, 1);
_lcd->print("rS: MOVE ");
_lcd->print("Moving ");
_lcd->print(distance);
_lcd->print("mm");
if (millis() >= runStepStart + 1234) {
// dummy wait time
_lcd->clear();
_lcd->print("Step ");
_lcd->print(step);
runStep = RUN_SETTLE;
runStepStart = millis();
}

View File

@ -29,7 +29,7 @@ class Scenerunner {
int _pin_focus;
int _pin_shutter;
int steps_left;
int step;
enum RunStep { RUN_OFF, RUN_SETTLE, RUN_FOCUS, RUN_SHUTTER, RUN_MOVE, RUN_RETURN };
RunStep runStep = RUN_OFF;
unsigned long int runStepStart;