feat: shuffle mode

This commit is contained in:
2025-11-15 16:53:23 +01:00
parent 331258692b
commit 7aec14cbb9
14 changed files with 167 additions and 2358 deletions
+10 -4
View File
@@ -3,13 +3,14 @@
#include "stepperDrv.hpp"
#include "stepperMotor.hpp"
#include <cmath>
#include "syslog.hpp"
class WatchMotor {
static constexpr uint8_t Positions = 6;
public:
using AllmostFinishedCb = void (*)(uint8_t newIdx);
WatchMotor(IStepperMotor &stepper, AllmostFinishedCb onDone)
using AlmostFinishedCb = void (*)(uint8_t newIdx);
WatchMotor(IStepperMotor &stepper, AlmostFinishedCb onDone)
: _stepper(stepper),
_onFinCb(onDone) {
}
@@ -44,7 +45,12 @@ class WatchMotor {
ESP_LOGD("MV", "Moving to %d by %.2f + %.2f", sign, delta, corr);
_stepper.moveBy(delta + corr, profile, accel, speed, [&]() {
_stepper.moveBy(delta + corr, profile, accel, speed, [&](int diff) {
Syslog::logv(Syslog::Severity::Debug,"Almost done with head=%i",diff);
if (diff < 6) {
Syslog::logv(Syslog::Severity::Warning,"Low headroom in Profile pipeline=%i",diff);
}
if (_onFinCb) {
_onFinCb(position);
}
@@ -58,5 +64,5 @@ class WatchMotor {
private:
IStepperMotor &_stepper;
uint8_t _currentIndex{};
AllmostFinishedCb _onFinCb{};
AlmostFinishedCb _onFinCb{};
};
@@ -19,7 +19,7 @@ class StepperMotorMock : public IStepperMotor {
lastAngle = angle;
lastProfile = profile;
}
void moveBy(float angle, uint8_t profile, float accel, float speed, std::function<void()> profileDone = nullptr) override {
void moveBy(float angle, uint8_t profile, float accel, float speed, std::function<void(int diff)> profileDone = nullptr) override {
lastAngle = angle;
lastProfile = profile;
}