diff options
| author | Selene ToyKeeper | 2017-09-10 16:38:40 -0600 |
|---|---|---|
| committer | Selene ToyKeeper | 2017-09-10 16:38:40 -0600 |
| commit | e5864361c5e05aa5356d06cba6a19441ea0dc996 (patch) | |
| tree | 93309c8dafc981338a15018dcbddbcae80f3532f | |
| parent | Applied recent changes to UI description text. (diff) | |
| download | anduril-e5864361c5e05aa5356d06cba6a19441ea0dc996.tar.gz anduril-e5864361c5e05aa5356d06cba6a19441ea0dc996.tar.bz2 anduril-e5864361c5e05aa5356d06cba6a19441ea0dc996.zip | |
Fixed a bug in gradual_tick(), I think.
It was off by one, and caused actual_level to be off by one,
which caused other parts of the code to do weird things...
- end-of-ramp blink would happen repeatedly.
- ramping up went slower (or not at all, with gradual_tick on each tick)
- would sometimes trigger underheating code at moon level,
and then glide up to the minimum regulation floor
Diffstat (limited to '')
| -rw-r--r-- | spaghetti-monster/anduril/anduril.c | 1 | ||||
| -rw-r--r-- | spaghetti-monster/fsm-ramping.c | 6 |
2 files changed, 4 insertions, 3 deletions
diff --git a/spaghetti-monster/anduril/anduril.c b/spaghetti-monster/anduril/anduril.c index 6cc0095..3d08b26 100644 --- a/spaghetti-monster/anduril/anduril.c +++ b/spaghetti-monster/anduril/anduril.c @@ -320,7 +320,6 @@ uint8_t steady_state(EventPtr event, uint16_t arg) { } #endif #ifdef USE_THERMAL_REGULATION - // TODO: test this on a real light // overheating: drop by an amount proportional to how far we are above the ceiling else if (event == EV_temperature_high) { /* diff --git a/spaghetti-monster/fsm-ramping.c b/spaghetti-monster/fsm-ramping.c index 092c242..cc5f486 100644 --- a/spaghetti-monster/fsm-ramping.c +++ b/spaghetti-monster/fsm-ramping.c @@ -67,10 +67,12 @@ inline void set_level_gradually(uint8_t lvl) { // call this every frame or every few frames to change brightness very smoothly void gradual_tick() { // go by only one ramp level at a time instead of directly to the target - uint8_t gt = gradual_target - 1; + uint8_t gt = gradual_target; if (gt < actual_level) gt = actual_level - 1; else if (gt > actual_level) gt = actual_level + 1; + gt --; // convert 1-based number to 0-based + uint8_t target; #if PWM_CHANNELS >= 1 @@ -111,7 +113,7 @@ void gradual_tick() { #endif ) { - actual_level = gt; + actual_level = gt + 1; } } #endif |
