10#include <ESP32Servo.h>
12#include <freertos/FreeRTOS.h>
13#include <freertos/task.h>
31 explicit Turret(Servo& servo);
40 void jog(
float pan,
float tilt)
override;
55 enum class CommandKind : uint8_t {
None, Target, Jog, Home };
58 CommandKind kind = CommandKind::None;
61 float jog_tilt = 0.0f;
62 uint32_t sequence = 0;
65 static void task_entry(
void* arg);
67 void write_coils(
int phase);
71 TaskHandle_t _task =
nullptr;
76 uint32_t late_ticks = 0;
77 uint32_t stack_free = 0;
86 bool _coils_on =
false;
87 uint32_t _last_step_ms = 0;
88 float _tilt_target = 90.0f;
89 float _tilt_current = 90.0f;
90 float _tilt_rate = 0.0f;
91 int _servo_written = 90;
What the controller can ask of the pan/tilt turret. Thread-safe: called from loop(),...
Definition base_turret.h:11
Non-blocking turret: callers post commands, a 1 kHz motor task executes them.
Definition turret.h:28
aiming::Angles position_deg() const override
Current angles (pan from the step counter, tilt as last written to the servo).
Definition turret.cpp:105
Turret(Servo &servo)
Definition turret.cpp:40
void jog(float pan, float tilt) override
Manual velocity, each axis -1..1 of its max speed; 0,0 stops (with deceleration).
Definition turret.cpp:85
void set_target_deg(const aiming::Angles &target) override
Move to absolute angles (clamped to the soft limits).
Definition turret.cpp:76
bool begin()
Configure pins (coils LOW), attach the servo at home tilt and start the motor task.
Definition turret.cpp:48
float pan_speed() const override
Current stepper speed, steps/s (signed).
Definition turret.cpp:120
void home() override
Same as set_target_deg({0, home tilt}).
Definition turret.cpp:97
uint32_t stack_free() const
Minimum free stack of the motor task seen so far, in bytes (high-water mark, sampled every 1000 ticks...
Definition turret.cpp:115
uint32_t late_ticks() const
Count of late wake-ups (lag of more than 1 tick) where missed 1 ms ticks were dropped.
Definition turret.cpp:110
Definition step_planner.h:27
A value of type T that owns its own spinlock; every access is one short critical section.
Definition sync.h:54
Trapezoidal velocity planner for the pan stepper, ticked at 1 kHz (pure C++20, natively tested).
Turret pose: pan degrees from home (positive = right), tilt servo degrees (larger = up).
Definition aim_map.h:30
Small RAII wrappers for the two locking patterns the firmware uses (device only).