From 95d931dc167ae01d6af1973ea68496584fe03541 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Sun, 19 Nov 2023 01:44:35 -0700 Subject: ramp-mode: allow hwdef to adjust gradual tick speed The gradual tick frequency was written for 8-bit PWM, but it can be too slow on hardware with more bits. The hwdef can compensate by using larger steps, but that makes adjustments more visible... So this provides an option to increase speed without visibility. --- ui/anduril/config-default.h | 6 ++++++ ui/anduril/ramp-mode.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ui/anduril/config-default.h b/ui/anduril/config-default.h index 04fc956..cd25b52 100644 --- a/ui/anduril/config-default.h +++ b/ui/anduril/config-default.h @@ -113,6 +113,12 @@ // timer is available in regular ramp mode and candle mode #define USE_SUNSET_TIMER +// optionally make gradual ticks happen faster +// Affects: thermal regulation speed, sunset mode, maybe other features +// (default is calibrated for 8-bit PWM, +// but 10-bit should set this value to 4 instead of 1) +#define GRADUAL_ADJUST_SPEED 1 + ///// What to do when power is connected ///// // factory reset function erases user's runtime configuration in eeprom diff --git a/ui/anduril/ramp-mode.c b/ui/anduril/ramp-mode.c index 9e19025..4c535b4 100644 --- a/ui/anduril/ramp-mode.c +++ b/ui/anduril/ramp-mode.c @@ -287,7 +287,7 @@ uint8_t steady_state(Event event, uint16_t arg) { static uint16_t ticks_since_adjust = 0; ticks_since_adjust++; if (diff) { - uint16_t ticks_per_adjust = 256; + uint16_t ticks_per_adjust = 256 / GRADUAL_ADJUST_SPEED; if (diff < 0) { //diff = -diff; if (actual_level > THERM_FASTER_LEVEL) { -- cgit v1.2.3