aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSelene ToyKeeper2020-09-07 00:28:15 -0600
committerSelene ToyKeeper2020-09-07 00:28:15 -0600
commit3750bda97cc9590def2b46c49a23b4ac29a4c94c (patch)
treec8f51cdfef02c203a6c80b4e64e9562709ad1b0b
parentadded support for external thermal sensors in fsm-adc.c (diff)
downloadanduril-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
-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;
If you find this content useful please consider a small donation via bitcoin: bitcoin:1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2?amount=0.001&message=Donation Scraping git contents via cgit is very resource intensive. The continued hosting of these git repositories is entirely financed by your bitcoin contributions. For donations of a least 1 mBTC you include your IP address in the message of your bitcoin donation. This will remove this message in the future for requests from your IP, which will significantly reduce token usage. In any case, any contributions to bitcoin address 1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2 are very welcome. Thanks in advance for you contribution to a self-sustaining ecosystem.