taskDriven by claude - must be checked

This commit is contained in:
2026-01-03 22:59:36 -06:00
parent 4e4add5287
commit daced162ba
11 changed files with 378 additions and 198 deletions

View File

@@ -3,6 +3,7 @@
#include "esp_log.h"
#include "soc/gpio_struct.h"
#include "servo.hpp"
#include "defines.h"
static const char *TAG = "ENCODER";
@@ -47,18 +48,32 @@ void IRAM_ATTR Encoder::isr_handler(void* arg)
if (encoder->last_count_base > 3) {
encoder->count += 1;
encoder->last_count_base -= 4;
if (calibListen) servoCalibListen();
if (encoder->feedWDog) esp_timer_restart(encoder->watchdog_handle, 500000);
if (encoder->wandListen) servoWandListen();
if (encoder->serverListen) servoServerListen();
// DEFER to task via queue instead of direct function calls
encoder_event_t event = {
.count = encoder->count.load(),
.is_top_encoder = (encoder == topEnc)
};
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
if (g_encoder_event_queue != NULL) {
xQueueSendFromISR(g_encoder_event_queue, &event, &xHigherPriorityTaskWoken);
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}
}
else if (encoder->last_count_base < 0) {
encoder->count -= 1;
encoder->last_count_base += 4;
if (calibListen) servoCalibListen();
if (encoder->feedWDog) esp_timer_restart(encoder->watchdog_handle, 500000);
if (encoder->wandListen) servoWandListen();
if (encoder->serverListen) servoServerListen();
// DEFER to task via queue instead of direct function calls
encoder_event_t event = {
.count = encoder->count.load(),
.is_top_encoder = (encoder == topEnc)
};
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
if (g_encoder_event_queue != NULL) {
xQueueSendFromISR(g_encoder_event_queue, &event, &xHigherPriorityTaskWoken);
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}
}
encoder->last_state_a = current_a;