aboutsummaryrefslogtreecommitdiff
path: root/spaghetti-monster/fsm-ramping.c
diff options
context:
space:
mode:
authorSelene ToyKeeper2022-04-14 19:59:55 -0600
committerSelene ToyKeeper2022-04-14 19:59:55 -0600
commit2527602a3680f2e0d4217359e0a142920621f739 (patch)
treeb60de4907679be3108abe0c26450c9dd735203ef /spaghetti-monster/fsm-ramping.c
parentrevert spurious change to version.h (diff)
parentCreated LED_DISABLE_DELAY option and enabled it for SP10 Pro to hopefully eli... (diff)
downloadanduril-2527602a3680f2e0d4217359e0a142920621f739.tar.gz
anduril-2527602a3680f2e0d4217359e0a142920621f739.tar.bz2
anduril-2527602a3680f2e0d4217359e0a142920621f739.zip
merged gchart's latest changes:
- sp10-pro shutoff fix - mt35-mini support - power channel enable/disable timing delays (though I wouldn't recommend doing 80ms like the thefreeman code does, since that's more than one WDT cycle (16ms))
Diffstat (limited to 'spaghetti-monster/fsm-ramping.c')
-rw-r--r--spaghetti-monster/fsm-ramping.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/spaghetti-monster/fsm-ramping.c b/spaghetti-monster/fsm-ramping.c
index abbfbde..2e6901d 100644
--- a/spaghetti-monster/fsm-ramping.c
+++ b/spaghetti-monster/fsm-ramping.c
@@ -93,6 +93,10 @@ void set_level(uint8_t level) {
TINT1_LVL = 0;
TINT2_LVL = 0;
#endif
+ // for drivers with a slow regulator chip (eg, boost converter, delay before turning off to prevent flashes
+ #ifdef LED_DISABLE_DELAY
+ delay_4ms(LED_DISABLE_DELAY/4);
+ #endif
// disable the power channel, if relevant
#ifdef LED_ENABLE_PIN
LED_ENABLE_PORT &= ~(1 << LED_ENABLE_PIN);
@@ -104,6 +108,10 @@ void set_level(uint8_t level) {
// enable the power channel, if relevant
#ifndef USE_TINT_RAMPING // update_tint handles this better
#ifdef LED_ENABLE_PIN
+ #ifdef LED_ENABLE_DELAY
+ uint8_t led_enable_port_save = LED_ENABLE_PORT;
+ #endif
+
#ifndef LED_ENABLE_PIN_LEVEL_MIN
LED_ENABLE_PORT |= (1 << LED_ENABLE_PIN);
#else
@@ -114,9 +122,25 @@ void set_level(uint8_t level) {
else // disable during other parts of the ramp
LED_ENABLE_PORT &= ~(1 << LED_ENABLE_PIN);
#endif
+
+ // for drivers with a slow regulator chip (eg, boost converter, delay before lighting up to prevent flashes
+ #ifdef LED_ENABLE_DELAY
+ if (LED_ENABLE_PORT != led_enable_port_save) // only delay if the pin status changed
+ delay_4ms(LED_ENABLE_DELAY/4);
+ #endif
#endif
#ifdef LED2_ENABLE_PIN
- LED2_ENABLE_PORT |= (1 << LED2_ENABLE_PIN);
+ #ifdef LED2_ENABLE_DELAY
+ uint8_t led2_enable_port_save = LED2_ENABLE_PORT;
+ #endif
+
+ LED2_ENABLE_PORT |= (1 << LED2_ENABLE_PIN);
+
+ // for drivers with a slow regulator chip (eg, boost converter, delay before lighting up to prevent flashes
+ #ifdef LED2_ENABLE_DELAY
+ if (LED2_ENABLE_PORT != led2_enable_port_save) // only delay if the pin status changed
+ delay_4ms(LED2_ENABLE_DELAY/4);
+ #endif
#endif
#endif // ifndef USE_TINT_RAMPING