diff options
| author | Selene ToyKeeper | 2020-10-18 15:23:57 -0600 |
|---|---|---|
| committer | Selene ToyKeeper | 2020-10-18 15:23:57 -0600 |
| commit | 65017fef69e8b5a4c5cd63fab8d235a0331e543c (patch) | |
| tree | d3268655d1cbd8ddb66a99c7b31797a160bf563a /spaghetti-monster/fsm-ramping.c | |
| parent | added ramp 3H -> momentary turbo (diff) | |
| parent | merged lume1 branch for LoneOceans' FW3A-Lume1 driver support (diff) | |
| download | anduril-65017fef69e8b5a4c5cd63fab8d235a0331e543c.tar.gz anduril-65017fef69e8b5a4c5cd63fab8d235a0331e543c.tar.bz2 anduril-65017fef69e8b5a4c5cd63fab8d235a0331e543c.zip | |
merged fsm branch, mostly to get Lume1 driver support
Diffstat (limited to 'spaghetti-monster/fsm-ramping.c')
| -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 6c6d0cb..8ad4b65 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; |
