Port of arduino-st4 (Kevin Ferrare) to ESP32/PlatformIO with: - FreeRTOS mutex protection at every layer (Pin, Axis, Pulse, Controller) - Hardware timer pulse guiding with ISR-safe deferred stop pattern - Backward-compatible serial protocol (57600 baud, #-terminated) - Extended commands: PULSE, POS?, SYNC, STATUS?, VERSION? - Optional WiFi/WebSocket control (gated by ST4_WIFI_ENABLED) - Dead-reckoning position tracker using esp_timer microsecond precision All 4 examples build clean against esp32dev target.
32 lines
698 B
C++
32 lines
698 B
C++
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
// ST4-ESP32: Dead-reckoning position tracker
|
|
// Port of ASCOM AxisMovementTracker.cs using esp_timer microsecond precision
|
|
|
|
#pragma once
|
|
|
|
#include <freertos/FreeRTOS.h>
|
|
#include <freertos/semphr.h>
|
|
#include "ST4Types.h"
|
|
|
|
class ST4Tracker {
|
|
double position_;
|
|
double slewRate_;
|
|
int64_t startTime_;
|
|
mutable SemaphoreHandle_t mutex_;
|
|
|
|
double calculateDelta() const;
|
|
|
|
public:
|
|
ST4Tracker();
|
|
~ST4Tracker();
|
|
|
|
void begin();
|
|
void start(double slewRate);
|
|
void stop();
|
|
|
|
double position() const;
|
|
void setPosition(double pos);
|
|
double slewRate() const;
|
|
bool isMoving() const;
|
|
};
|