forked from qmk/qmk_firmware
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backlight - Carve out a better location for private driver functional…
…ity (qmk#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
- Loading branch information
Showing
8 changed files
with
73 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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);) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |
5 changes: 1 addition & 4 deletions
5
quantum/backlight/backlight_soft.c → quantum/backlight/backlight_software.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters