From 3bfa5f1065bce68e637be0b09089921577e88ce7 Mon Sep 17 00:00:00 2001 From: Gabriel Hart Date: Wed, 5 Jan 2022 09:09:50 -0600 Subject: Experimental: add optional delay when using LED_ENABLE_PIN to avoid flashes of light (this time for LED2_ENABLE pin) --- spaghetti-monster/fsm-ramping.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'spaghetti-monster/fsm-ramping.c') diff --git a/spaghetti-monster/fsm-ramping.c b/spaghetti-monster/fsm-ramping.c index 89e1f13..6bb2390 100644 --- a/spaghetti-monster/fsm-ramping.c +++ b/spaghetti-monster/fsm-ramping.c @@ -125,7 +125,17 @@ void set_level(uint8_t level) { #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 // PWM array index = level - 1 -- cgit v1.2.3