aboutsummaryrefslogtreecommitdiff
path: root/spaghetti-monster/fsm-ramping.c
diff options
context:
space:
mode:
authorSelene ToyKeeper2020-10-18 15:19:29 -0600
committerSelene ToyKeeper2020-10-18 15:19:29 -0600
commit6ae4e78bc385b78ac810e35fd9381a15f5f698c5 (patch)
treeec85e844bf75e6df8534805b0babbd98764734d2 /spaghetti-monster/fsm-ramping.c
parentminor update to anduril-ui.png (added clarification of what "3H" means) (diff)
parentcleaned up cfg-fw3x-lume1.h a little: (diff)
downloadanduril-6ae4e78bc385b78ac810e35fd9381a15f5f698c5.tar.gz
anduril-6ae4e78bc385b78ac810e35fd9381a15f5f698c5.tar.bz2
anduril-6ae4e78bc385b78ac810e35fd9381a15f5f698c5.zip
merged lume1 branch for LoneOceans' FW3A-Lume1 driver support
Diffstat (limited to 'spaghetti-monster/fsm-ramping.c')
-rw-r--r--spaghetti-monster/fsm-ramping.c24
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;