From 6469684b548402af1f71679488dfbd9886866ca6 Mon Sep 17 00:00:00 2001 From: Fisch Date: Sun, 9 Feb 2025 13:10:01 +0100 Subject: [PATCH] add comments --- movinghead/platformio.ini | 2 +- movinghead/src/main.cpp | 25 +++++++++++++++++-------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/movinghead/platformio.ini b/movinghead/platformio.ini index bb5b6de..a249172 100644 --- a/movinghead/platformio.ini +++ b/movinghead/platformio.ini @@ -30,4 +30,4 @@ build_flags = -D PAN_STEP_PIN=D7 -D PAN_DIR_PIN=D4 -D ENDSTOP_PAN=D5 - -D PIN_LIGHT=D6 \ No newline at end of file + -D PIN_OUTPUT=D6 \ No newline at end of file diff --git a/movinghead/src/main.cpp b/movinghead/src/main.cpp index 98ff0ef..a091d27 100644 --- a/movinghead/src/main.cpp +++ b/movinghead/src/main.cpp @@ -48,7 +48,8 @@ bool homedTilt=false; AccelStepper stepperPan(AccelStepper::DRIVER, PAN_STEP_PIN, PAN_DIR_PIN); AccelStepper stepperTilt(AccelStepper::DRIVER, TILT_STEP_PIN, TILT_DIR_PIN); - +void setOutput(bool o); +bool getOutput(); void setEnable(bool t); bool getEnable(); void setStepperPreset(Stepperpreset preset,Stepper s); @@ -60,6 +61,12 @@ void testMovementTilt(); bool isEndstopPan(); bool isEndstopTilt(); +void setOutput(bool o) { + digitalWrite(PIN_OUTPUT, o); +} +bool getOutput() { + return digitalRead(PIN_OUTPUT); +} void setEnable(bool t){ digitalWrite(EN_PIN,!t); //active low @@ -123,11 +130,11 @@ void setStepperPreset(Stepperpreset preset,Stepper s) void setup() { Serial.begin(115200); - pinMode(EN_PIN,OUTPUT); pinMode(ENDSTOP_TILT,INPUT_PULLUP); pinMode(ENDSTOP_PAN,INPUT_PULLUP); - pinMode(PIN_LIGHT, OUTPUT); - digitalWrite(PIN_LIGHT, LOW); + pinMode(PIN_OUTPUT, OUTPUT); + setOutput(false); + pinMode(EN_PIN,OUTPUT); setEnable(false); @@ -322,9 +329,11 @@ void testMovementPan() last_positionReached=0; if (stepperPan.currentPosition()