This commit is contained in:
Ronald Schaten 2022-02-12 01:03:46 +01:00
parent 27093e3e56
commit 99aafb06bf
3 changed files with 73 additions and 11 deletions

View File

@ -0,0 +1,39 @@
#include "Arduino.h"
#include <LiquidCrystal.h>
#include <BasicStepperDriver.h>
#include "Jogrunner.h"
Jogrunner::Jogrunner(LiquidCrystal *lcd, BasicStepperDriver *stepper, int stepper_rpm) {
_lcd = lcd;
_stepper = stepper;
_stepper_rpm = stepper_rpm;
}
void Jogrunner::start() {
_lcd->clear();
_lcd->print("Jogging...");
_lcd->setCursor(0, 1);
_lcd->print("[sel] to return");
}
void Jogrunner::setSpeed(bool speed) {
if (speed == LOW) {
_stepper->setRPM(_stepper_rpm);
} else {
_stepper->setRPM(2 * _stepper_rpm);
}
}
void Jogrunner::stop() {
_stepper->stop();
setSpeed(LOW);
}
void Jogrunner::forward() {
_stepper->startMove(100 * 360);
}
void Jogrunner::backward() {
_stepper->startMove(-100 * 360);
}

25
PhotoStepper/Jogrunner.h Normal file
View File

@ -0,0 +1,25 @@
#ifndef Jogrunner_h
#define Jogrunner_h
#include "Arduino.h"
#include <LiquidCrystal.h>
#include <BasicStepperDriver.h>
class Jogrunner {
public:
Jogrunner(LiquidCrystal *lcd, BasicStepperDriver *stepper, int stepper_rpm);
void start();
void setSpeed(bool speed);
void stop();
void forward();
void backward();
private:
LiquidCrystal *_lcd;
BasicStepperDriver *_stepper;
int _stepper_rpm;
};
#endif

View File

@ -17,6 +17,7 @@
#include <menu.h> #include <menu.h>
#include <menuIO/liquidCrystalOut.h> #include <menuIO/liquidCrystalOut.h>
#include <menuIO/serialIO.h> #include <menuIO/serialIO.h>
#include "Jogrunner.h"
#include "Scenerunner.h" #include "Scenerunner.h"
// analog keypad // analog keypad
@ -62,6 +63,7 @@ BasicStepperDriver stepper(STEPPER_STEPS, PIN_STEPPER_DIR, PIN_STEPPER_STEP);
enum State { STATE_MENU, STATE_JOG, STATE_RUN }; enum State { STATE_MENU, STATE_JOG, STATE_RUN };
State state = STATE_MENU; State state = STATE_MENU;
Jogrunner jogrunner(&lcd, &stepper, STEPPER_RPM);
Scenerunner scenerunner(&lcd, &stepper, PIN_CAMERA_FOCUS, PIN_CAMERA_SHUTTER, PIN_LCD_BL); Scenerunner scenerunner(&lcd, &stepper, PIN_CAMERA_FOCUS, PIN_CAMERA_SHUTTER, PIN_LCD_BL);
// === // ===
@ -71,11 +73,8 @@ Scenerunner scenerunner(&lcd, &stepper, PIN_CAMERA_FOCUS, PIN_CAMERA_SHUTTER, PI
result enter_jog() { result enter_jog() {
Serial.println("enter_jog()"); Serial.println("enter_jog()");
lcd.clear();
lcd.print("Jogging...");
lcd.setCursor(0, 1);
lcd.print("[sel] to exit");
state = STATE_JOG; state = STATE_JOG;
jogrunner.start();
return proceed; return proceed;
} }
@ -170,29 +169,28 @@ void ButtonHandler_jog(const ButtonParam& param) {
break; break;
case ButtonState_Up: case ButtonState_Up:
Serial.println("Up"); Serial.println("Up");
stepper.stop(); jogrunner.stop();
stepper.setRPM(STEPPER_RPM);
break; break;
case ButtonState_Down: case ButtonState_Down:
Serial.println("Down"); Serial.println("Down");
switch (param.button) { switch (param.button) {
case KEY_UP: case KEY_UP:
stepper.startMove(100 * 360); jogrunner.forward();
break; break;
case KEY_DOWN: case KEY_DOWN:
stepper.startMove(-100 * 360); jogrunner.backward();
break; break;
} }
break; break;
case ButtonState_Hold: case ButtonState_Hold:
Serial.println("Hold"); Serial.println("Hold");
stepper.setRPM(2 * STEPPER_RPM); jogrunner.setSpeed(HIGH);
switch (param.button) { switch (param.button) {
case KEY_UP: case KEY_UP:
stepper.startMove(100 * 360); jogrunner.forward();
break; break;
case KEY_DOWN: case KEY_DOWN:
stepper.startMove(-100 * 360); jogrunner.backward();
break; break;
} }
break; break;