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
749 B
C++
32 lines
749 B
C++
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
// ST4-ESP32: Dual-pin axis with mutual exclusion
|
|
// Deactivates opposing pin before activating (matches original safety pattern)
|
|
|
|
#pragma once
|
|
|
|
#include <freertos/FreeRTOS.h>
|
|
#include <freertos/semphr.h>
|
|
#include "ST4Pin.h"
|
|
#include "ST4Types.h"
|
|
|
|
class ST4Axis {
|
|
ST4Pin plusPin_;
|
|
ST4Pin minusPin_;
|
|
volatile ST4Direction direction_;
|
|
SemaphoreHandle_t mutex_;
|
|
|
|
public:
|
|
ST4Axis();
|
|
~ST4Axis();
|
|
|
|
void begin(int plusPin, int minusPin,
|
|
ST4PinLogic logic = ST4PinLogic::ACTIVE_HIGH);
|
|
void plus();
|
|
void minus();
|
|
void stop();
|
|
void move(ST4Direction dir);
|
|
|
|
ST4Direction direction() const;
|
|
bool isActive() const;
|
|
};
|