st-4-esp32/examples/basic_gpio/basic_gpio.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

53 lines
1.0 KiB
C++

// ST4-ESP32 Basic GPIO Example
// Cycles through all axis directions to verify wiring
// Use multimeter or logic analyzer on TLP521-4 outputs to verify
#include <ST4.h>
ST4Axis ra;
ST4Axis dec;
void setup() {
Serial.begin(115200);
Serial.println("ST4 Basic GPIO Test");
ra.begin(ST4_PIN_RA_PLUS, ST4_PIN_RA_MINUS);
dec.begin(ST4_PIN_DEC_PLUS, ST4_PIN_DEC_MINUS);
Serial.println("Pins initialized. Cycling directions...");
}
void loop() {
Serial.println("RA+");
ra.plus();
delay(2000);
Serial.println("RA stop");
ra.stop();
delay(1000);
Serial.println("RA-");
ra.minus();
delay(2000);
Serial.println("RA stop");
ra.stop();
delay(1000);
Serial.println("DEC+");
dec.plus();
delay(2000);
Serial.println("DEC stop");
dec.stop();
delay(1000);
Serial.println("DEC-");
dec.minus();
delay(2000);
Serial.println("All stop");
dec.stop();
delay(3000);
}