From 060244a7057dd11a76fa95ceb7374702cd21b304 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Mon, 13 Jan 2020 01:30:56 +0000 Subject: Relocate common backlight functionally (#7273) --- quantum/backlight/backlight_arm.c | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) (limited to 'quantum/backlight/backlight_arm.c') diff --git a/quantum/backlight/backlight_arm.c b/quantum/backlight/backlight_arm.c index 3f94ccef8e..d1b3b49452 100644 --- a/quantum/backlight/backlight_arm.c +++ b/quantum/backlight/backlight_arm.c @@ -110,7 +110,6 @@ void backlight_task(void) {} # define BREATHING_HALT_ON 2 # define BREATHING_STEPS 128 -static uint8_t breathing_period = BREATHING_PERIOD; static uint8_t breathing_halt = BREATHING_NO_HALT; static uint16_t breathing_counter = 0; @@ -118,7 +117,7 @@ bool is_breathing(void) { return BACKLIGHT_PWM_DRIVER.config == &pwmCFG_breathin static inline void breathing_min(void) { breathing_counter = 0; } -static inline void breathing_max(void) { breathing_counter = breathing_period * 256 / 2; } +static inline void breathing_max(void) { breathing_counter = get_breathing_period() * 256 / 2; } void breathing_interrupt_enable(void) { pwmStop(&BACKLIGHT_PWM_DRIVER); @@ -170,17 +169,6 @@ void breathing_toggle(void) { breathing_enable(); } -void breathing_period_set(uint8_t value) { - if (!value) value = 1; - breathing_period = value; -} - -void breathing_period_default(void) { breathing_period_set(BREATHING_PERIOD); } - -void breathing_period_inc(void) { breathing_period_set(breathing_period + 1); } - -void breathing_period_dec(void) { breathing_period_set(breathing_period - 1); } - /* To generate breathing curve in python: * from math import sin, pi; [int(sin(x/128.0*pi)**4*255) for x in range(128)] */ @@ -191,7 +179,8 @@ static inline uint16_t scale_backlight(uint16_t v) { return v / BACKLIGHT_LEVELS static void breathing_callback(PWMDriver *pwmp) { (void)pwmp; - uint16_t interval = (uint16_t)breathing_period * 256 / BREATHING_STEPS; + uint8_t breathing_period = get_breathing_period(); + uint16_t interval = (uint16_t)breathing_period * 256 / BREATHING_STEPS; // resetting after one period to prevent ugly reset at overflow. breathing_counter = (breathing_counter + 1) % (breathing_period * 256); uint8_t index = breathing_counter / interval % BREATHING_STEPS; @@ -207,12 +196,4 @@ static void breathing_callback(PWMDriver *pwmp) { chSysUnlockFromISR(); } -#else - -__attribute__((weak)) void backlight_init_ports(void) {} - -__attribute__((weak)) void backlight_set(uint8_t level) {} - -__attribute__((weak)) void backlight_task(void) {} - #endif -- cgit v1.2.3