diff --git a/lib/freertos/senseshift/freertos/task.hpp b/lib/freertos/senseshift/freertos/task.hpp index 4d1ddceb..4ed9fba9 100644 --- a/lib/freertos/senseshift/freertos/task.hpp +++ b/lib/freertos/senseshift/freertos/task.hpp @@ -142,7 +142,6 @@ class ComponentUpdateTask : public Task> { [[noreturn]] void run() { auto now = millis(); - auto targetHz = 1000 / this->updateDelay_; while (true) { now = millis(); @@ -151,7 +150,7 @@ class ComponentUpdateTask : public Task> { const auto elapsed = millis() - now; - log_d("T: %d, Fmax: %dHz, Ft: %dHz", elapsed, 1000 / elapsed, targetHz); + log_d("T: %d, Fmax: %dHz, Ft: %dHz", elapsed, 1000 / elapsed, 1000 / this->updateDelay_); if (elapsed < this->updateDelay_) { delay(this->updateDelay_ - elapsed); } diff --git a/lib/io/senseshift/input/filter.hpp b/lib/io/senseshift/input/filter.hpp index d0a3fab8..906c3524 100644 --- a/lib/io/senseshift/input/filter.hpp +++ b/lib/io/senseshift/input/filter.hpp @@ -259,9 +259,9 @@ class ExponentialMovingAverageFilter : public IFilter { /// Deadzone filter. Clamps acc_ to center if it is within the deadzone. /// Usually used to filter out noise in the joystick. -class CenterDeadzoneFilter : public IFilter { +class SinglePointDeadzoneFilter : public IFilter { public: - explicit CenterDeadzoneFilter(float deadzone, float center = 0.5F) : deadzone_(deadzone), center_(center){}; + explicit SinglePointDeadzoneFilter(float deadzone, float center = 0.5F) : deadzone_(deadzone), center_(center){}; inline auto filter(ISimpleSensor* /*sensor*/, float value) -> float override { @@ -270,11 +270,12 @@ class CenterDeadzoneFilter : public IFilter { } private: + const float deadzone_; const float center_; - - float deadzone_; }; +using CenterDeadzoneFilter = SinglePointDeadzoneFilter; + /// Interpolates the value from the lookup table. /// Can be used to determine battery level from the voltage. /// diff --git a/lib/io/senseshift/input/sensor.hpp b/lib/io/senseshift/input/sensor.hpp index 2883571e..1731db82 100644 --- a/lib/io/senseshift/input/sensor.hpp +++ b/lib/io/senseshift/input/sensor.hpp @@ -142,7 +142,7 @@ class SimpleSensorDecorator : public Sensor { using ValueType = Tp; using SourceType = ISimpleSensor; - explicit SimpleSensorDecorator(SourceType* source) : source_(source), Sensor() + explicit SimpleSensorDecorator(SourceType* source) : Sensor(), source_(source) { } diff --git a/lib/io/senseshift/input/sensor/analog_threshold.hpp b/lib/io/senseshift/input/sensor/analog_threshold.hpp index 8a9af64f..d105e9db 100644 --- a/lib/io/senseshift/input/sensor/analog_threshold.hpp +++ b/lib/io/senseshift/input/sensor/analog_threshold.hpp @@ -16,8 +16,8 @@ class AnalogThresholdSensor : public BinarySensor { Sensor* source, Tp threshold_upper, Tp threshold_lower, bool attach_callbacks = false ) : source_(source), - threshold_upper_(threshold_upper), threshold_lower_(threshold_lower), + threshold_upper_(threshold_upper), attach_callbacks_(attach_callbacks) { }