From 24cbc7a34bd2ca1dafb9f051629950f524d952a8 Mon Sep 17 00:00:00 2001 From: Kai Ryu Date: Wed, 22 Apr 2015 18:49:49 +0900 Subject: [PATCH] Modify softpwm_led to support more custom callback function --- common/softpwm_led.c | 10 ++++++++-- common/softpwm_led.h | 4 +++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/common/softpwm_led.c b/common/softpwm_led.c index dfef5c94..26bc7df6 100644 --- a/common/softpwm_led.c +++ b/common/softpwm_led.c @@ -269,7 +269,7 @@ ISR(TIMER1_COMPA_vect) for (uint8_t i = 0; i < LED_COUNT; i++) { // LED on if (pwm == 0) { - softpwm_led_on(i); + if (softpwm_led_ocr[i]) softpwm_led_on(i); softpwm_led_ocr[i] = softpwm_led_ocr_buff[i]; } // LED off @@ -284,7 +284,7 @@ ISR(TIMER1_COMPA_vect) counter = 0; fading_led_proc(); breathing_led_proc(); - custom_led_proc(); + softpwm_led_custom(); } #endif } @@ -306,6 +306,9 @@ void fading_led_proc(void) } } } +#ifdef CUSTOM_LED_ENABLE + fading_led_custom(softpwm_led_ocr); +#endif } } } @@ -326,6 +329,9 @@ void breathing_led_proc(void) softpwm_led_ocr_buff[i] = value; } } +#ifdef CUSTOM_LED_ENABLE + breathing_led_custom(softpwm_led_ocr); +#endif if (direction) { if (index == 0) { direction = 0; diff --git a/common/softpwm_led.h b/common/softpwm_led.h index 4735fd8d..ad982fcc 100644 --- a/common/softpwm_led.h +++ b/common/softpwm_led.h @@ -70,7 +70,9 @@ void breathing_led_set_duration(uint8_t dur); #endif #ifdef CUSTOM_LED_ENABLE -void custom_led_proc(void); +void softpwm_led_custom(void); +void fading_led_custom(uint8_t *value); +void breathing_led_custom(uint8_t *value); #else #define custom_led_proc() #endif