add comments

This commit is contained in:
interfisch 2025-02-09 13:10:01 +01:00
parent 3ce29a4e29
commit 6469684b54
2 changed files with 18 additions and 9 deletions

View file

@ -30,4 +30,4 @@ build_flags =
-D PAN_STEP_PIN=D7 -D PAN_STEP_PIN=D7
-D PAN_DIR_PIN=D4 -D PAN_DIR_PIN=D4
-D ENDSTOP_PAN=D5 -D ENDSTOP_PAN=D5
-D PIN_LIGHT=D6 -D PIN_OUTPUT=D6

View file

@ -48,7 +48,8 @@ bool homedTilt=false;
AccelStepper stepperPan(AccelStepper::DRIVER, PAN_STEP_PIN, PAN_DIR_PIN); AccelStepper stepperPan(AccelStepper::DRIVER, PAN_STEP_PIN, PAN_DIR_PIN);
AccelStepper stepperTilt(AccelStepper::DRIVER, TILT_STEP_PIN, TILT_DIR_PIN); AccelStepper stepperTilt(AccelStepper::DRIVER, TILT_STEP_PIN, TILT_DIR_PIN);
void setOutput(bool o);
bool getOutput();
void setEnable(bool t); void setEnable(bool t);
bool getEnable(); bool getEnable();
void setStepperPreset(Stepperpreset preset,Stepper s); void setStepperPreset(Stepperpreset preset,Stepper s);
@ -60,6 +61,12 @@ void testMovementTilt();
bool isEndstopPan(); bool isEndstopPan();
bool isEndstopTilt(); bool isEndstopTilt();
void setOutput(bool o) {
digitalWrite(PIN_OUTPUT, o);
}
bool getOutput() {
return digitalRead(PIN_OUTPUT);
}
void setEnable(bool t){ void setEnable(bool t){
digitalWrite(EN_PIN,!t); //active low digitalWrite(EN_PIN,!t); //active low
@ -123,11 +130,11 @@ void setStepperPreset(Stepperpreset preset,Stepper s)
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
pinMode(EN_PIN,OUTPUT);
pinMode(ENDSTOP_TILT,INPUT_PULLUP); pinMode(ENDSTOP_TILT,INPUT_PULLUP);
pinMode(ENDSTOP_PAN,INPUT_PULLUP); pinMode(ENDSTOP_PAN,INPUT_PULLUP);
pinMode(PIN_LIGHT, OUTPUT); pinMode(PIN_OUTPUT, OUTPUT);
digitalWrite(PIN_LIGHT, LOW); setOutput(false);
pinMode(EN_PIN,OUTPUT);
setEnable(false); setEnable(false);
@ -322,9 +329,11 @@ void testMovementPan()
last_positionReached=0; last_positionReached=0;
if (stepperPan.currentPosition()<stepsPerRotationPan-100) { if (stepperPan.currentPosition()<stepsPerRotationPan-100) {
stepperPan.moveTo(stepsPerRotationPan); stepperPan.moveTo(stepsPerRotationPan); //move to home
setOutput(false); //test output
}else{ }else{
stepperPan.moveTo(stepsPerRotationPan-random(200,stepsPerRotationPan)); stepperPan.moveTo(stepsPerRotationPan-random(200,stepsPerRotationPan)); //move somewhere else
setOutput(true); //test output
} }
} }
} }
@ -339,9 +348,9 @@ void testMovementTilt()
last_positionReached=0; last_positionReached=0;
if (stepperTilt.currentPosition()<stepsPerRotationTilt-100) { if (stepperTilt.currentPosition()<stepsPerRotationTilt-100) {
stepperTilt.moveTo(stepsPerRotationTilt); stepperTilt.moveTo(stepsPerRotationTilt); //move to home
}else{ }else{
stepperTilt.moveTo(stepsPerRotationTilt-random(200,stepsPerRotationTilt)); stepperTilt.moveTo(stepsPerRotationTilt-random(200,stepsPerRotationTilt)); //move somewhere else
} }