diff options
-rw-r--r-- | docs/feature_backlight.md | 20 | ||||
-rw-r--r-- | quantum/backlight/backlight.c | 23 | ||||
-rw-r--r-- | quantum/backlight/backlight.h | 4 | ||||
-rw-r--r-- | tmk_core/common/eeconfig.c | 11 | ||||
-rw-r--r-- | tmk_core/common/eeconfig.h | 5 |
5 files changed, 35 insertions, 28 deletions
diff --git a/docs/feature_backlight.md b/docs/feature_backlight.md index 74511dd43..d47ecc682 100644 --- a/docs/feature_backlight.md +++ b/docs/feature_backlight.md | |||
@@ -62,15 +62,17 @@ Valid driver values are `pwm`, `software`, `custom` or `no`. See below for help | |||
62 | 62 | ||
63 | To configure the backlighting, `#define` these in your `config.h`: | 63 | To configure the backlighting, `#define` these in your `config.h`: |
64 | 64 | ||
65 | | Define | Default | Description | | 65 | |Define |Default |Description | |
66 | |------------------------|---------------|-------------------------------------------------------------------------------------------------------------------| | 66 | |-----------------------------|------------------|-----------------------------------------------------------------------------------------------------------------| |
67 | | `BACKLIGHT_PIN` | *Not defined* | The pin that controls the LED(s) | | 67 | |`BACKLIGHT_PIN` |*Not defined* |The pin that controls the LED(s) | |
68 | | `BACKLIGHT_LEVELS` | `3` | The number of brightness levels (maximum 31 excluding off) | | 68 | |`BACKLIGHT_LEVELS` |`3` |The number of brightness levels (maximum 31 excluding off) | |
69 | | `BACKLIGHT_CAPS_LOCK` | *Not defined* | Enable Caps Lock indicator using backlight (for keyboards without dedicated LED) | | 69 | |`BACKLIGHT_CAPS_LOCK` |*Not defined* |Enable Caps Lock indicator using backlight (for keyboards without dedicated LED) | |
70 | | `BACKLIGHT_BREATHING` | *Not defined* | Enable backlight breathing, if supported | | 70 | |`BACKLIGHT_BREATHING` |*Not defined* |Enable backlight breathing, if supported | |
71 | | `BREATHING_PERIOD` | `6` | The length of one backlight "breath" in seconds | | 71 | |`BREATHING_PERIOD` |`6` |The length of one backlight "breath" in seconds | |
72 | | `BACKLIGHT_ON_STATE` | `1` | The state of the backlight pin when the backlight is "on" - `1` for high, `0` for low | | 72 | |`BACKLIGHT_ON_STATE` |`1` |The state of the backlight pin when the backlight is "on" - `1` for high, `0` for low | |
73 | | `BACKLIGHT_LIMIT_VAL ` | `255` | The maximum duty cycle of the backlight -- `255` allows for full brightness, any lower will decrease the maximum. | | 73 | |`BACKLIGHT_LIMIT_VAL` |`255` |The maximum duty cycle of the backlight -- `255` allows for full brightness, any lower will decrease the maximum.| |
74 | |`BACKLIGHT_DEFAULT_LEVEL` |`BACKLIGHT_LEVELS`|The default backlight level to use upon clearing the EEPROM | | ||
75 | |`BACKLIGHT_DEFAULT_BREATHING`|*Not defined* |Whether to enable backlight breathing upon clearing the EEPROM | | ||
74 | 76 | ||
75 | Unless you are designing your own keyboard, you generally should not need to change the `BACKLIGHT_PIN` or `BACKLIGHT_ON_STATE`. | 77 | Unless you are designing your own keyboard, you generally should not need to change the `BACKLIGHT_PIN` or `BACKLIGHT_ON_STATE`. |
76 | 78 | ||
diff --git a/quantum/backlight/backlight.c b/quantum/backlight/backlight.c index 113beb832..1bc276899 100644 --- a/quantum/backlight/backlight.c +++ b/quantum/backlight/backlight.c | |||
@@ -22,6 +22,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
22 | 22 | ||
23 | backlight_config_t backlight_config; | 23 | backlight_config_t backlight_config; |
24 | 24 | ||
25 | #ifndef BACKLIGHT_DEFAULT_LEVEL | ||
26 | # define BACKLIGHT_DEFAULT_LEVEL BACKLIGHT_LEVELS | ||
27 | #endif | ||
28 | |||
25 | #ifdef BACKLIGHT_BREATHING | 29 | #ifdef BACKLIGHT_BREATHING |
26 | // TODO: migrate to backlight_config_t | 30 | // TODO: migrate to backlight_config_t |
27 | static uint8_t breathing_period = BREATHING_PERIOD; | 31 | static uint8_t breathing_period = BREATHING_PERIOD; |
@@ -35,6 +39,7 @@ void backlight_init(void) { | |||
35 | /* check signature */ | 39 | /* check signature */ |
36 | if (!eeconfig_is_enabled()) { | 40 | if (!eeconfig_is_enabled()) { |
37 | eeconfig_init(); | 41 | eeconfig_init(); |
42 | eeconfig_update_backlight_default(); | ||
38 | } | 43 | } |
39 | backlight_config.raw = eeconfig_read_backlight(); | 44 | backlight_config.raw = eeconfig_read_backlight(); |
40 | if (backlight_config.level > BACKLIGHT_LEVELS) { | 45 | if (backlight_config.level > BACKLIGHT_LEVELS) { |
@@ -152,11 +157,23 @@ void backlight_level(uint8_t level) { | |||
152 | eeconfig_update_backlight(backlight_config.raw); | 157 | eeconfig_update_backlight(backlight_config.raw); |
153 | } | 158 | } |
154 | 159 | ||
155 | /** \brief Update current backlight state to EEPROM | 160 | uint8_t eeconfig_read_backlight(void) { return eeprom_read_byte(EECONFIG_BACKLIGHT); } |
156 | * | 161 | |
157 | */ | 162 | void eeconfig_update_backlight(uint8_t val) { eeprom_update_byte(EECONFIG_BACKLIGHT, val); } |
163 | |||
158 | void eeconfig_update_backlight_current(void) { eeconfig_update_backlight(backlight_config.raw); } | 164 | void eeconfig_update_backlight_current(void) { eeconfig_update_backlight(backlight_config.raw); } |
159 | 165 | ||
166 | void eeconfig_update_backlight_default(void) { | ||
167 | backlight_config.enable = 1; | ||
168 | #ifdef BACKLIGHT_DEFAULT_BREATHING | ||
169 | backlight_config.breathing = 1; | ||
170 | #else | ||
171 | backlight_config.breathing = 0; | ||
172 | #endif | ||
173 | backlight_config.level = BACKLIGHT_DEFAULT_LEVEL; | ||
174 | eeconfig_update_backlight(backlight_config.raw); | ||
175 | } | ||
176 | |||
160 | /** \brief Get backlight level | 177 | /** \brief Get backlight level |
161 | * | 178 | * |
162 | * FIXME: needs doc | 179 | * FIXME: needs doc |
diff --git a/quantum/backlight/backlight.h b/quantum/backlight/backlight.h index 3e506737d..c30c70fd6 100644 --- a/quantum/backlight/backlight.h +++ b/quantum/backlight/backlight.h | |||
@@ -55,7 +55,11 @@ void backlight_decrease(void); | |||
55 | void backlight_level_noeeprom(uint8_t level); | 55 | void backlight_level_noeeprom(uint8_t level); |
56 | void backlight_level(uint8_t level); | 56 | void backlight_level(uint8_t level); |
57 | uint8_t get_backlight_level(void); | 57 | uint8_t get_backlight_level(void); |
58 | |||
59 | uint8_t eeconfig_read_backlight(void); | ||
60 | void eeconfig_update_backlight(uint8_t val); | ||
58 | void eeconfig_update_backlight_current(void); | 61 | void eeconfig_update_backlight_current(void); |
62 | void eeconfig_update_backlight_default(void); | ||
59 | 63 | ||
60 | // implementation specific | 64 | // implementation specific |
61 | void backlight_init_ports(void); | 65 | void backlight_init_ports(void); |
diff --git a/tmk_core/common/eeconfig.c b/tmk_core/common/eeconfig.c index 92a509217..ffa56ab56 100644 --- a/tmk_core/common/eeconfig.c +++ b/tmk_core/common/eeconfig.c | |||
@@ -155,17 +155,6 @@ void eeconfig_update_keymap(uint16_t val) { | |||
155 | eeprom_update_byte(EECONFIG_KEYMAP_UPPER_BYTE, (val >> 8) & 0xFF); | 155 | eeprom_update_byte(EECONFIG_KEYMAP_UPPER_BYTE, (val >> 8) & 0xFF); |
156 | } | 156 | } |
157 | 157 | ||
158 | /** \brief eeconfig read backlight | ||
159 | * | ||
160 | * FIXME: needs doc | ||
161 | */ | ||
162 | uint8_t eeconfig_read_backlight(void) { return eeprom_read_byte(EECONFIG_BACKLIGHT); } | ||
163 | /** \brief eeconfig update backlight | ||
164 | * | ||
165 | * FIXME: needs doc | ||
166 | */ | ||
167 | void eeconfig_update_backlight(uint8_t val) { eeprom_update_byte(EECONFIG_BACKLIGHT, val); } | ||
168 | |||
169 | /** \brief eeconfig read audio | 158 | /** \brief eeconfig read audio |
170 | * | 159 | * |
171 | * FIXME: needs doc | 160 | * FIXME: needs doc |
diff --git a/tmk_core/common/eeconfig.h b/tmk_core/common/eeconfig.h index 9e18fd4e1..a88071729 100644 --- a/tmk_core/common/eeconfig.h +++ b/tmk_core/common/eeconfig.h | |||
@@ -94,11 +94,6 @@ void eeconfig_update_default_layer(uint8_t val); | |||
94 | uint16_t eeconfig_read_keymap(void); | 94 | uint16_t eeconfig_read_keymap(void); |
95 | void eeconfig_update_keymap(uint16_t val); | 95 | void eeconfig_update_keymap(uint16_t val); |
96 | 96 | ||
97 | #ifdef BACKLIGHT_ENABLE | ||
98 | uint8_t eeconfig_read_backlight(void); | ||
99 | void eeconfig_update_backlight(uint8_t val); | ||
100 | #endif | ||
101 | |||
102 | #ifdef AUDIO_ENABLE | 97 | #ifdef AUDIO_ENABLE |
103 | uint8_t eeconfig_read_audio(void); | 98 | uint8_t eeconfig_read_audio(void); |
104 | void eeconfig_update_audio(uint8_t val); | 99 | void eeconfig_update_audio(uint8_t val); |