diff options
author | Joel Challis <git@zvecr.com> | 2020-03-07 12:09:49 +0000 |
---|---|---|
committer | Florian Didron <fdidron@users.noreply.github.com> | 2020-06-12 17:00:27 +0900 |
commit | cd1ba27a7b5d2021b8b906ebffd99a269d4b2688 (patch) | |
tree | bf0ed0c3f58c4ebd36a1c5a861cf6db3ad5fe582 /quantum/backlight | |
parent | 0f8a5d1d3891ef8dfe74e57b0bdf9af280b8c893 (diff) |
Backlight - Carve out a better location for private driver functionality (#8329)
* rename backlight_soft to match rules.mk
* rename backlight_soft to match rules.mk - update common_features
* Carve out a better location for private driver backlight functionality
Diffstat (limited to 'quantum/backlight')
-rw-r--r-- | quantum/backlight/backlight.c | 49 | ||||
-rw-r--r-- | quantum/backlight/backlight.h | 8 | ||||
-rw-r--r-- | quantum/backlight/backlight_arm.c | 4 | ||||
-rw-r--r-- | quantum/backlight/backlight_avr.c | 5 | ||||
-rw-r--r-- | quantum/backlight/backlight_driver_common.c | 49 | ||||
-rw-r--r-- | quantum/backlight/backlight_driver_common.h | 7 | ||||
-rw-r--r-- | quantum/backlight/backlight_software.c (renamed from quantum/backlight/backlight_soft.c) | 5 |
7 files changed, 64 insertions, 63 deletions
diff --git a/quantum/backlight/backlight.c b/quantum/backlight/backlight.c index 4a0eac64c6..34dd8cbdb5 100644 --- a/quantum/backlight/backlight.c +++ b/quantum/backlight/backlight.c @@ -20,6 +20,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "eeconfig.h" #include "debug.h" +#if defined(STM32F0XX) || defined(STM32F0xx) +# pragma message("Backlight support for STMF072 has had limited testing, YMMV. If unsure, set 'BACKLIGHT_ENABLE = no' in your rules.mk") +#endif + backlight_config_t backlight_config; #ifdef BACKLIGHT_BREATHING @@ -27,51 +31,6 @@ backlight_config_t backlight_config; static uint8_t breathing_period = BREATHING_PERIOD; #endif -#ifndef BACKLIGHT_CUSTOM_DRIVER -# if defined(BACKLIGHT_PINS) -static const pin_t backlight_pins[] = BACKLIGHT_PINS; -# ifndef BACKLIGHT_LED_COUNT -# define BACKLIGHT_LED_COUNT (sizeof(backlight_pins) / sizeof(pin_t)) -# endif - -# define FOR_EACH_LED(x) \ - for (uint8_t i = 0; i < BACKLIGHT_LED_COUNT; i++) { \ - pin_t backlight_pin = backlight_pins[i]; \ - { x } \ - } -# else -// we support only one backlight pin -static const pin_t backlight_pin = BACKLIGHT_PIN; -# define FOR_EACH_LED(x) x -# endif - -static inline void backlight_on(pin_t backlight_pin) { -# if BACKLIGHT_ON_STATE == 0 - writePinLow(backlight_pin); -# else - writePinHigh(backlight_pin); -# endif -} - -static inline void backlight_off(pin_t backlight_pin) { -# if BACKLIGHT_ON_STATE == 0 - writePinHigh(backlight_pin); -# else - writePinLow(backlight_pin); -# endif -} - -void backlight_pins_init(void) { - // Setup backlight pin as output and output to off state. - FOR_EACH_LED(setPinOutput(backlight_pin); backlight_off(backlight_pin);) -} - -void backlight_pins_on(void) { FOR_EACH_LED(backlight_on(backlight_pin);) } - -void backlight_pins_off(void) { FOR_EACH_LED(backlight_off(backlight_pin);) } - -#endif - /** \brief Backlight initialization * * FIXME: needs doc diff --git a/quantum/backlight/backlight.h b/quantum/backlight/backlight.h index 07a4880e9f..3e506737d4 100644 --- a/quantum/backlight/backlight.h +++ b/quantum/backlight/backlight.h @@ -44,10 +44,6 @@ typedef union { }; } backlight_config_t; -void backlight_pins_init(void); -void backlight_pins_on(void); -void backlight_pins_off(void); - void backlight_init(void); void backlight_toggle(void); void backlight_enable(void); @@ -79,11 +75,11 @@ void breathing_period_default(void); void breathing_period_inc(void); void breathing_period_dec(void); +void breathing_toggle(void); + // implementation specific void breathing_enable(void); void breathing_disable(void); -void breathing_toggle(void); bool is_breathing(void); void breathing_pulse(void); -void breathing_task(void); #endif diff --git a/quantum/backlight/backlight_arm.c b/quantum/backlight/backlight_arm.c index a6d38a1a02..723544adb9 100644 --- a/quantum/backlight/backlight_arm.c +++ b/quantum/backlight/backlight_arm.c @@ -6,10 +6,6 @@ // TODO: remove short term bodge when refactoring BACKLIGHT_CUSTOM_DRIVER out #ifdef BACKLIGHT_PIN -# if defined(STM32F0XX) || defined(STM32F0xx) -# pragma message("Backlight support for STMF072 has had limited testing, YMMV. If unsure, set 'BACKLIGHT_ENABLE = no' in your rules.mk") -# endif - // GPIOV2 && GPIOV3 # ifndef BACKLIGHT_PAL_MODE # define BACKLIGHT_PAL_MODE 2 diff --git a/quantum/backlight/backlight_avr.c b/quantum/backlight/backlight_avr.c index 40291d3821..ce13f11184 100644 --- a/quantum/backlight/backlight_avr.c +++ b/quantum/backlight/backlight_avr.c @@ -1,11 +1,8 @@ #include "quantum.h" #include "backlight.h" +#include "backlight_driver_common.h" #include "debug.h" -#if !defined(BACKLIGHT_PIN) && !defined(BACKLIGHT_PINS) -# error "Backlight pin/pins not defined. Please configure." -#endif - // This logic is a bit complex, we support 3 setups: // // 1. Hardware PWM when backlight is wired to a PWM pin. diff --git a/quantum/backlight/backlight_driver_common.c b/quantum/backlight/backlight_driver_common.c new file mode 100644 index 0000000000..270a43c67e --- /dev/null +++ b/quantum/backlight/backlight_driver_common.c @@ -0,0 +1,49 @@ +#include "quantum.h" +#include "backlight.h" +#include "backlight_driver_common.h" + +#if !defined(BACKLIGHT_PIN) && !defined(BACKLIGHT_PINS) +# error "Backlight pin/pins not defined. Please configure." +#endif + +#if defined(BACKLIGHT_PINS) +static const pin_t backlight_pins[] = BACKLIGHT_PINS; +# ifndef BACKLIGHT_LED_COUNT +# define BACKLIGHT_LED_COUNT (sizeof(backlight_pins) / sizeof(pin_t)) +# endif + +# define FOR_EACH_LED(x) \ + for (uint8_t i = 0; i < BACKLIGHT_LED_COUNT; i++) { \ + pin_t backlight_pin = backlight_pins[i]; \ + { x } \ + } +#else +// we support only one backlight pin +static const pin_t backlight_pin = BACKLIGHT_PIN; +# define FOR_EACH_LED(x) x +#endif + +static inline void backlight_on(pin_t backlight_pin) { +#if BACKLIGHT_ON_STATE == 0 + writePinLow(backlight_pin); +#else + writePinHigh(backlight_pin); +#endif +} + +static inline void backlight_off(pin_t backlight_pin) { +#if BACKLIGHT_ON_STATE == 0 + writePinHigh(backlight_pin); +#else + writePinLow(backlight_pin); +#endif +} + +void backlight_pins_init(void) { + // Setup backlight pin as output and output to off state. + FOR_EACH_LED(setPinOutput(backlight_pin); backlight_off(backlight_pin);) +} + +void backlight_pins_on(void) { FOR_EACH_LED(backlight_on(backlight_pin);) } + +void backlight_pins_off(void) { FOR_EACH_LED(backlight_off(backlight_pin);) } diff --git a/quantum/backlight/backlight_driver_common.h b/quantum/backlight/backlight_driver_common.h new file mode 100644 index 0000000000..36e8a5fa6b --- /dev/null +++ b/quantum/backlight/backlight_driver_common.h @@ -0,0 +1,7 @@ +#pragma once + +void backlight_pins_init(void); +void backlight_pins_on(void); +void backlight_pins_off(void); + +void breathing_task(void); diff --git a/quantum/backlight/backlight_soft.c b/quantum/backlight/backlight_software.c index 8552384a42..709304f559 100644 --- a/quantum/backlight/backlight_soft.c +++ b/quantum/backlight/backlight_software.c @@ -1,9 +1,6 @@ #include "quantum.h" #include "backlight.h" - -#if !defined(BACKLIGHT_PIN) && !defined(BACKLIGHT_PINS) -# error "Backlight pin/pins not defined. Please configure." -#endif +#include "backlight_driver_common.h" #ifdef BACKLIGHT_BREATHING # error "Backlight breathing is not available for software PWM. Please disable." |