From e437c32c28df63adbb6636841c7fc66052651109 Mon Sep 17 00:00:00 2001 From: pulipakaa24 Date: Thu, 8 Jan 2026 17:59:33 -0600 Subject: [PATCH] add bottom encoder stuff --- include/servo.cpp | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/include/servo.cpp b/include/servo.cpp index 65b6d7c..500b0da 100644 --- a/include/servo.cpp +++ b/include/servo.cpp @@ -292,23 +292,16 @@ void servoControlTask(void* arg) { // Handle calibration listening if (calibListen) { - int32_t effDiff = (bottomEnc->getCount() - topEnc->getCount()) - baseDiff; - if (effDiff > 1) { - servoOn(CCW, manual); - } - else if (effDiff < -1) { - servoOn(CW, manual); - } - else { - servoOff(); - } + servoCalibListen(); } // Only process top encoder events for watchdog and listeners if (enc_event.is_top_encoder) { // Feed watchdog in task context (not ISR) if (topEnc->feedWDog) { - esp_timer_restart(topEnc->watchdog_handle, 500000); + esp_timer_stop(topEnc->watchdog_handle); + esp_timer_start_once(topEnc->watchdog_handle, 500000); + debugLEDTgl(); } // Check wand listener - now safe in task context @@ -321,6 +314,26 @@ void servoControlTask(void* arg) { servoServerListen(); } } + + // Only process top encoder events for watchdog and listeners + else { + // Feed watchdog in task context (not ISR) + if (bottomEnc->feedWDog) { + esp_timer_stop(bottomEnc->watchdog_handle); + esp_timer_start_once(bottomEnc->watchdog_handle, 500000); + debugLEDTgl(); + } + + // Check wand listener - now safe in task context + if (bottomEnc->wandListen) { + servoWandListen(); + } + + // Check server listener - now safe in task context + if (bottomEnc->serverListen) { + servoServerListen(); + } + } } // Check for direct servo commands (lower priority)