st-4-esp32/examples/serial_compatible/serial_compatible.ino
Ryan Malloy 4c91fd4811 ESP32 ST-4 autoguider library with thread-safe pulse guiding
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.
2026-02-17 19:46:03 -07:00

28 lines
782 B
C++

// ST4-ESP32 Serial Compatible Example
// Drop-in replacement for original ArduinoCode.ino
// Works with the ASCOM ArduinoST4 driver at 57600 baud
//
// Original commands: CONNECT# DISCONNECT# RA+# RA-# RA0# DEC+# DEC-# DEC0#
// Extended commands: PULSE RA+ 500# POS?# SYNC 12.345 45.678# STATUS?# VERSION?#
#include <ST4.h>
ST4Controller controller;
ST4Serial st4Serial;
void setup() {
controller.begin(
ST4_PIN_RA_PLUS, ST4_PIN_RA_MINUS,
ST4_PIN_DEC_PLUS, ST4_PIN_DEC_MINUS,
ST4_PIN_LED
);
// Extended mode adds PULSE, POS?, SYNC, STATUS?, VERSION?
// Set to false for strict original protocol compatibility
st4Serial.begin(controller, Serial, true);
}
void loop() {
st4Serial.update();
}