mirror of
https://github.com/qmk/qmk_firmware
synced 2024-11-17 17:35:30 +00:00
Backlight: add defines for default level and breathing state (#12560)
This commit is contained in:
parent
e128d45420
commit
06aea834c4
5 changed files with 35 additions and 28 deletions
|
@ -62,15 +62,17 @@ Valid driver values are `pwm`, `software`, `custom` or `no`. See below for help
|
|||
|
||||
To configure the backlighting, `#define` these in your `config.h`:
|
||||
|
||||
| Define | Default | Description |
|
||||
|------------------------|---------------|-------------------------------------------------------------------------------------------------------------------|
|
||||
| `BACKLIGHT_PIN` | *Not defined* | The pin that controls the LED(s) |
|
||||
| `BACKLIGHT_LEVELS` | `3` | The number of brightness levels (maximum 31 excluding off) |
|
||||
| `BACKLIGHT_CAPS_LOCK` | *Not defined* | Enable Caps Lock indicator using backlight (for keyboards without dedicated LED) |
|
||||
| `BACKLIGHT_BREATHING` | *Not defined* | Enable backlight breathing, if supported |
|
||||
| `BREATHING_PERIOD` | `6` | The length of one backlight "breath" in seconds |
|
||||
| `BACKLIGHT_ON_STATE` | `1` | The state of the backlight pin when the backlight is "on" - `1` for high, `0` for low |
|
||||
| `BACKLIGHT_LIMIT_VAL ` | `255` | The maximum duty cycle of the backlight -- `255` allows for full brightness, any lower will decrease the maximum. |
|
||||
|Define |Default |Description |
|
||||
|-----------------------------|------------------|-----------------------------------------------------------------------------------------------------------------|
|
||||
|`BACKLIGHT_PIN` |*Not defined* |The pin that controls the LED(s) |
|
||||
|`BACKLIGHT_LEVELS` |`3` |The number of brightness levels (maximum 31 excluding off) |
|
||||
|`BACKLIGHT_CAPS_LOCK` |*Not defined* |Enable Caps Lock indicator using backlight (for keyboards without dedicated LED) |
|
||||
|`BACKLIGHT_BREATHING` |*Not defined* |Enable backlight breathing, if supported |
|
||||
|`BREATHING_PERIOD` |`6` |The length of one backlight "breath" in seconds |
|
||||
|`BACKLIGHT_ON_STATE` |`1` |The state of the backlight pin when the backlight is "on" - `1` for high, `0` for low |
|
||||
|`BACKLIGHT_LIMIT_VAL` |`255` |The maximum duty cycle of the backlight -- `255` allows for full brightness, any lower will decrease the maximum.|
|
||||
|`BACKLIGHT_DEFAULT_LEVEL` |`BACKLIGHT_LEVELS`|The default backlight level to use upon clearing the EEPROM |
|
||||
|`BACKLIGHT_DEFAULT_BREATHING`|*Not defined* |Whether to enable backlight breathing upon clearing the EEPROM |
|
||||
|
||||
Unless you are designing your own keyboard, you generally should not need to change the `BACKLIGHT_PIN` or `BACKLIGHT_ON_STATE`.
|
||||
|
||||
|
|
|
@ -22,6 +22,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
backlight_config_t backlight_config;
|
||||
|
||||
#ifndef BACKLIGHT_DEFAULT_LEVEL
|
||||
# define BACKLIGHT_DEFAULT_LEVEL BACKLIGHT_LEVELS
|
||||
#endif
|
||||
|
||||
#ifdef BACKLIGHT_BREATHING
|
||||
// TODO: migrate to backlight_config_t
|
||||
static uint8_t breathing_period = BREATHING_PERIOD;
|
||||
|
@ -35,6 +39,7 @@ void backlight_init(void) {
|
|||
/* check signature */
|
||||
if (!eeconfig_is_enabled()) {
|
||||
eeconfig_init();
|
||||
eeconfig_update_backlight_default();
|
||||
}
|
||||
backlight_config.raw = eeconfig_read_backlight();
|
||||
if (backlight_config.level > BACKLIGHT_LEVELS) {
|
||||
|
@ -152,11 +157,23 @@ void backlight_level(uint8_t level) {
|
|||
eeconfig_update_backlight(backlight_config.raw);
|
||||
}
|
||||
|
||||
/** \brief Update current backlight state to EEPROM
|
||||
*
|
||||
*/
|
||||
uint8_t eeconfig_read_backlight(void) { return eeprom_read_byte(EECONFIG_BACKLIGHT); }
|
||||
|
||||
void eeconfig_update_backlight(uint8_t val) { eeprom_update_byte(EECONFIG_BACKLIGHT, val); }
|
||||
|
||||
void eeconfig_update_backlight_current(void) { eeconfig_update_backlight(backlight_config.raw); }
|
||||
|
||||
void eeconfig_update_backlight_default(void) {
|
||||
backlight_config.enable = 1;
|
||||
#ifdef BACKLIGHT_DEFAULT_BREATHING
|
||||
backlight_config.breathing = 1;
|
||||
#else
|
||||
backlight_config.breathing = 0;
|
||||
#endif
|
||||
backlight_config.level = BACKLIGHT_DEFAULT_LEVEL;
|
||||
eeconfig_update_backlight(backlight_config.raw);
|
||||
}
|
||||
|
||||
/** \brief Get backlight level
|
||||
*
|
||||
* FIXME: needs doc
|
||||
|
|
|
@ -55,7 +55,11 @@ void backlight_decrease(void);
|
|||
void backlight_level_noeeprom(uint8_t level);
|
||||
void backlight_level(uint8_t level);
|
||||
uint8_t get_backlight_level(void);
|
||||
|
||||
uint8_t eeconfig_read_backlight(void);
|
||||
void eeconfig_update_backlight(uint8_t val);
|
||||
void eeconfig_update_backlight_current(void);
|
||||
void eeconfig_update_backlight_default(void);
|
||||
|
||||
// implementation specific
|
||||
void backlight_init_ports(void);
|
||||
|
|
|
@ -155,17 +155,6 @@ void eeconfig_update_keymap(uint16_t val) {
|
|||
eeprom_update_byte(EECONFIG_KEYMAP_UPPER_BYTE, (val >> 8) & 0xFF);
|
||||
}
|
||||
|
||||
/** \brief eeconfig read backlight
|
||||
*
|
||||
* FIXME: needs doc
|
||||
*/
|
||||
uint8_t eeconfig_read_backlight(void) { return eeprom_read_byte(EECONFIG_BACKLIGHT); }
|
||||
/** \brief eeconfig update backlight
|
||||
*
|
||||
* FIXME: needs doc
|
||||
*/
|
||||
void eeconfig_update_backlight(uint8_t val) { eeprom_update_byte(EECONFIG_BACKLIGHT, val); }
|
||||
|
||||
/** \brief eeconfig read audio
|
||||
*
|
||||
* FIXME: needs doc
|
||||
|
|
|
@ -94,11 +94,6 @@ void eeconfig_update_default_layer(uint8_t val);
|
|||
uint16_t eeconfig_read_keymap(void);
|
||||
void eeconfig_update_keymap(uint16_t val);
|
||||
|
||||
#ifdef BACKLIGHT_ENABLE
|
||||
uint8_t eeconfig_read_backlight(void);
|
||||
void eeconfig_update_backlight(uint8_t val);
|
||||
#endif
|
||||
|
||||
#ifdef AUDIO_ENABLE
|
||||
uint8_t eeconfig_read_audio(void);
|
||||
void eeconfig_update_audio(uint8_t val);
|
||||
|
|
Loading…
Reference in a new issue