diff options
Diffstat (limited to 'quantum/backlight/backlight.c')
| -rw-r--r-- | quantum/backlight/backlight.c | 49 |
1 files changed, 4 insertions, 45 deletions
diff --git a/quantum/backlight/backlight.c b/quantum/backlight/backlight.c index 4a0eac64c..34dd8cbdb 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/>. | |||
| 20 | #include "eeconfig.h" | 20 | #include "eeconfig.h" |
| 21 | #include "debug.h" | 21 | #include "debug.h" |
| 22 | 22 | ||
| 23 | #if defined(STM32F0XX) || defined(STM32F0xx) | ||
| 24 | # pragma message("Backlight support for STMF072 has had limited testing, YMMV. If unsure, set 'BACKLIGHT_ENABLE = no' in your rules.mk") | ||
| 25 | #endif | ||
| 26 | |||
| 23 | backlight_config_t backlight_config; | 27 | backlight_config_t backlight_config; |
| 24 | 28 | ||
| 25 | #ifdef BACKLIGHT_BREATHING | 29 | #ifdef BACKLIGHT_BREATHING |
| @@ -27,51 +31,6 @@ backlight_config_t backlight_config; | |||
| 27 | static uint8_t breathing_period = BREATHING_PERIOD; | 31 | static uint8_t breathing_period = BREATHING_PERIOD; |
| 28 | #endif | 32 | #endif |
| 29 | 33 | ||
| 30 | #ifndef BACKLIGHT_CUSTOM_DRIVER | ||
| 31 | # if defined(BACKLIGHT_PINS) | ||
| 32 | static const pin_t backlight_pins[] = BACKLIGHT_PINS; | ||
| 33 | # ifndef BACKLIGHT_LED_COUNT | ||
| 34 | # define BACKLIGHT_LED_COUNT (sizeof(backlight_pins) / sizeof(pin_t)) | ||
| 35 | # endif | ||
| 36 | |||
| 37 | # define FOR_EACH_LED(x) \ | ||
| 38 | for (uint8_t i = 0; i < BACKLIGHT_LED_COUNT; i++) { \ | ||
| 39 | pin_t backlight_pin = backlight_pins[i]; \ | ||
| 40 | { x } \ | ||
| 41 | } | ||
| 42 | # else | ||
| 43 | // we support only one backlight pin | ||
| 44 | static const pin_t backlight_pin = BACKLIGHT_PIN; | ||
| 45 | # define FOR_EACH_LED(x) x | ||
| 46 | # endif | ||
| 47 | |||
| 48 | static inline void backlight_on(pin_t backlight_pin) { | ||
| 49 | # if BACKLIGHT_ON_STATE == 0 | ||
| 50 | writePinLow(backlight_pin); | ||
| 51 | # else | ||
| 52 | writePinHigh(backlight_pin); | ||
| 53 | # endif | ||
| 54 | } | ||
| 55 | |||
| 56 | static inline void backlight_off(pin_t backlight_pin) { | ||
| 57 | # if BACKLIGHT_ON_STATE == 0 | ||
| 58 | writePinHigh(backlight_pin); | ||
| 59 | # else | ||
| 60 | writePinLow(backlight_pin); | ||
| 61 | # endif | ||
| 62 | } | ||
| 63 | |||
| 64 | void backlight_pins_init(void) { | ||
| 65 | // Setup backlight pin as output and output to off state. | ||
| 66 | FOR_EACH_LED(setPinOutput(backlight_pin); backlight_off(backlight_pin);) | ||
| 67 | } | ||
| 68 | |||
| 69 | void backlight_pins_on(void) { FOR_EACH_LED(backlight_on(backlight_pin);) } | ||
| 70 | |||
| 71 | void backlight_pins_off(void) { FOR_EACH_LED(backlight_off(backlight_pin);) } | ||
| 72 | |||
| 73 | #endif | ||
| 74 | |||
| 75 | /** \brief Backlight initialization | 34 | /** \brief Backlight initialization |
| 76 | * | 35 | * |
| 77 | * FIXME: needs doc | 36 | * FIXME: needs doc |
