implement run skeleton

This commit is contained in:
Ronald Schaten 2022-02-10 18:16:49 +01:00
parent 886f72f03a
commit 3b674d75ab
3 changed files with 54 additions and 8 deletions

View File

@ -82,6 +82,7 @@ result enter_jog() {
result enter_run() { result enter_run() {
Serial.println("enter_run()"); Serial.println("enter_run()");
state = STATE_RUN; state = STATE_RUN;
scenerunner.start();
return proceed; return proceed;
} }

View File

@ -11,10 +11,51 @@ Scenerunner::Scenerunner(LiquidCrystal *lcd, BasicStepperDriver *stepper, int pi
_pin_shutter = pin_shutter; _pin_shutter = pin_shutter;
} }
void Scenerunner::nextAction(){ void Scenerunner::start() {
// TODO: implement actions
_lcd->clear(); _lcd->clear();
_lcd->print("Running..."); _lcd->print("Running...");
_lcd->setCursor(0, 1); steps_left = nSteps;
_lcd->print("[sel] to exit"); runStep = RUN_SETTLE;
runStepStart = millis();
}
void Scenerunner::nextAction() {
_lcd->setCursor(0, 1);
switch (runStep) {
case RUN_OFF:
_lcd->print("rS: OFF ");
break;
case RUN_SETTLE:
_lcd->print("rS: SETTLE ");
if (millis() >= runStepStart + tSettle) {
runStep = RUN_FOCUS;
runStepStart = millis();
}
break;
case RUN_FOCUS:
_lcd->print("rS: FOCUS ");
if (millis() >= runStepStart + tFocus) {
runStep = RUN_SHUTTER;
runStepStart = millis();
}
break;
case RUN_SHUTTER:
_lcd->print("rS: SHUTTER ");
if (millis() >= runStepStart + tShutter) {
runStep = RUN_MOVE;
runStepStart = millis();
}
break;
case RUN_MOVE:
_lcd->print("rS: MOVE ");
if (millis() >= runStepStart + 1234) {
// dummy wait time
runStep = RUN_SETTLE;
runStepStart = millis();
}
break;
case RUN_RETURN:
_lcd->print("rS: RETURN ");
break;
}
} }

View File

@ -9,9 +9,9 @@ class Scenerunner {
public: public:
// configuration values // configuration values
int tSettle = 100; int tSettle = 1000;
int tFocus = 500; int tFocus = 1000;
int tShutter = 500; int tShutter = 1000;
bool bReturn = true; bool bReturn = true;
bool bDarkenLcd = true; bool bDarkenLcd = true;
@ -20,6 +20,7 @@ class Scenerunner {
float distance = 0.5; float distance = 0.5;
Scenerunner(LiquidCrystal *lcd, BasicStepperDriver *stepper, int pin_focus, int pin_shutter); Scenerunner(LiquidCrystal *lcd, BasicStepperDriver *stepper, int pin_focus, int pin_shutter);
void start();
void nextAction(); void nextAction();
private: private:
@ -27,8 +28,11 @@ class Scenerunner {
BasicStepperDriver *_stepper; BasicStepperDriver *_stepper;
int _pin_focus; int _pin_focus;
int _pin_shutter; int _pin_shutter;
enum RunStep { RUN_OFF, RUN_SETTLE, RUN_FOCUS, RUN_SHUTTER, RUN_RETURN };
int steps_left;
enum RunStep { RUN_OFF, RUN_SETTLE, RUN_FOCUS, RUN_SHUTTER, RUN_MOVE, RUN_RETURN };
RunStep runStep = RUN_OFF; RunStep runStep = RUN_OFF;
unsigned long int runStepStart;
}; };