// SPDX-License-Identifier: LGPL-3.0-or-later // ST4-ESP32: Hardware timer pulse guiding (non-blocking) // Uses esp_timer one-shot with deferred stop via FreeRTOS task #pragma once #include #include #include #include #include "ST4Axis.h" #include "ST4Tracker.h" class ST4Pulse { // Static instance for timer callback (standard embedded ISR pattern) static ST4Pulse* instance_; esp_timer_handle_t timer_; SemaphoreHandle_t pulseDoneSem_; SemaphoreHandle_t mutex_; TaskHandle_t pulseTaskHandle_; ST4Axis* activeAxis_; ST4Tracker* activeTracker_; volatile bool active_; volatile bool shutdown_; static constexpr uint32_t MAX_PULSE_MS = 10000; void cancelLocked(); static void timerCallback(void* arg); static void pulseTaskFunc(void* arg); public: ST4Pulse(); ~ST4Pulse(); void begin(); bool pulse(ST4Axis& axis, ST4Tracker& tracker, ST4Direction dir, double slewRate, uint32_t ms); bool isActive() const; void cancel(); };