diff options
| author | Selene ToyKeeper | 2020-09-07 00:28:15 -0600 |
|---|---|---|
| committer | Selene ToyKeeper | 2020-09-07 00:28:15 -0600 |
| commit | 3750bda97cc9590def2b46c49a23b4ac29a4c94c (patch) | |
| tree | c8f51cdfef02c203a6c80b4e64e9562709ad1b0b /spaghetti-monster | |
| parent | added support for external thermal sensors in fsm-adc.c (diff) | |
| download | anduril-3750bda97cc9590def2b46c49a23b4ac29a4c94c.tar.gz anduril-3750bda97cc9590def2b46c49a23b4ac29a4c94c.tar.bz2 anduril-3750bda97cc9590def2b46c49a23b4ac29a4c94c.zip | |
added support for LED_ENABLE_PIN having a min/max ramp level where it turns on
Diffstat (limited to 'spaghetti-monster')
| -rw-r--r-- | spaghetti-monster/fsm-ramping.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/spaghetti-monster/fsm-ramping.c b/spaghetti-monster/fsm-ramping.c index c3ad8b4..3791030 100644 --- a/spaghetti-monster/fsm-ramping.c +++ b/spaghetti-monster/fsm-ramping.c @@ -76,16 +76,25 @@ void set_level(uint8_t level) { LED_ENABLE2_PORT &= ~(1 << LED_ENABLE2_PIN); #endif } else { - level --; - // enable the power channel, if relevant #ifdef LED_ENABLE_PIN - LED_ENABLE_PORT |= (1 << LED_ENABLE_PIN); + #ifndef LED_ENABLE_PIN_LEVEL_MIN + LED_ENABLE_PORT |= (1 << LED_ENABLE_PIN); + #else + // only enable during part of the ramp + if ((level >= LED_ENABLE_PIN_LEVEL_MIN) + && (level <= LED_ENABLE_PIN_LEVEL_MAX)) + LED_ENABLE_PORT |= (1 << LED_ENABLE_PIN); + else // disable during other parts of the ramp + LED_ENABLE_PORT &= ~(1 << LED_ENABLE_PIN); + #endif #endif #ifdef LED_ENABLE2_PIN LED_ENABLE2_PORT |= (1 << LED_ENABLE2_PIN); #endif + level --; + #ifdef USE_TINT_RAMPING #ifndef TINT_RAMPING_CORRECTION #define TINT_RAMPING_CORRECTION 26 // 140% brightness at middle tint @@ -156,6 +165,15 @@ void gradual_tick() { if (gt < actual_level) gt = actual_level - 1; else if (gt > actual_level) gt = actual_level + 1; + #ifdef LED_ENABLE_PIN_LEVEL_MIN + // only enable during part of the ramp + if ((gt >= LED_ENABLE_PIN_LEVEL_MIN) + && (gt <= LED_ENABLE_PIN_LEVEL_MAX)) + LED_ENABLE_PORT |= (1 << LED_ENABLE_PIN); + else // disable during other parts of the ramp + LED_ENABLE_PORT &= ~(1 << LED_ENABLE_PIN); + #endif + gt --; // convert 1-based number to 0-based PWM_DATATYPE target; |
