diff options
| author | fauxpark <fauxpark@gmail.com> | 2019-07-16 17:56:36 +1000 |
|---|---|---|
| committer | skullydazed <skullydazed@users.noreply.github.com> | 2019-07-16 00:56:36 -0700 |
| commit | a32f7e1a25a8a200d838aa8256ffe39708fbd723 (patch) | |
| tree | b1ede8bd7ce3d6b31c7bfd83d0f23a804c8efc8f /tmk_core | |
| parent | e2dfb787da2a2ba88e0e074b396a2b988e10eccf (diff) | |
| download | qmk_firmware-a32f7e1a25a8a200d838aa8256ffe39708fbd723.tar.gz qmk_firmware-a32f7e1a25a8a200d838aa8256ffe39708fbd723.zip | |
Store backlight breathing state in EEPROM (#6105)
* Store backlight breathing state in EEPROM
* Reduce backlight_config.level from 6 bits to 4 (max 15 "on" levels)
* Error out if BACKLIGHT_LEVELS is > 15
* Remove mention of default backlight pin in rules.mk template
* Remove pointless comment
Diffstat (limited to 'tmk_core')
| -rw-r--r-- | tmk_core/common/backlight.c | 55 | ||||
| -rw-r--r-- | tmk_core/common/backlight.h | 19 |
2 files changed, 71 insertions, 3 deletions
diff --git a/tmk_core/common/backlight.c b/tmk_core/common/backlight.c index 8ddacd98b..c0e9fb5ee 100644 --- a/tmk_core/common/backlight.c +++ b/tmk_core/common/backlight.c | |||
| @@ -100,7 +100,7 @@ void backlight_enable(void) | |||
| 100 | backlight_set(backlight_config.level); | 100 | backlight_set(backlight_config.level); |
| 101 | } | 101 | } |
| 102 | 102 | ||
| 103 | /** /brief Disable backlight | 103 | /** \brief Disable backlight |
| 104 | * | 104 | * |
| 105 | * FIXME: needs doc | 105 | * FIXME: needs doc |
| 106 | */ | 106 | */ |
| @@ -162,3 +162,56 @@ uint8_t get_backlight_level(void) | |||
| 162 | { | 162 | { |
| 163 | return backlight_config.level; | 163 | return backlight_config.level; |
| 164 | } | 164 | } |
| 165 | |||
| 166 | #ifdef BACKLIGHT_BREATHING | ||
| 167 | /** \brief Backlight breathing toggle | ||
| 168 | * | ||
| 169 | * FIXME: needs doc | ||
| 170 | */ | ||
| 171 | void backlight_toggle_breathing(void) | ||
| 172 | { | ||
| 173 | bool breathing = backlight_config.breathing; | ||
| 174 | dprintf("backlight breathing toggle: %u\n", breathing); | ||
| 175 | if (breathing) | ||
| 176 | backlight_disable_breathing(); | ||
| 177 | else | ||
| 178 | backlight_enable_breathing(); | ||
| 179 | } | ||
| 180 | |||
| 181 | /** \brief Enable backlight breathing | ||
| 182 | * | ||
| 183 | * FIXME: needs doc | ||
| 184 | */ | ||
| 185 | void backlight_enable_breathing(void) | ||
| 186 | { | ||
| 187 | if (backlight_config.breathing) return; // do nothing if breathing is already on | ||
| 188 | |||
| 189 | backlight_config.breathing = true; | ||
| 190 | eeconfig_update_backlight(backlight_config.raw); | ||
| 191 | dprintf("backlight breathing enable\n"); | ||
| 192 | breathing_enable(); | ||
| 193 | } | ||
| 194 | |||
| 195 | /** \brief Disable backlight breathing | ||
| 196 | * | ||
| 197 | * FIXME: needs doc | ||
| 198 | */ | ||
| 199 | void backlight_disable_breathing(void) | ||
| 200 | { | ||
| 201 | if (!backlight_config.breathing) return; // do nothing if breathing is already off | ||
| 202 | |||
| 203 | backlight_config.breathing = false; | ||
| 204 | eeconfig_update_backlight(backlight_config.raw); | ||
| 205 | dprintf("backlight breathing disable\n"); | ||
| 206 | breathing_disable(); | ||
| 207 | } | ||
| 208 | |||
| 209 | /** \brief Get the backlight breathing status | ||
| 210 | * | ||
| 211 | * FIXME: needs doc | ||
| 212 | */ | ||
| 213 | bool is_backlight_breathing(void) | ||
| 214 | { | ||
| 215 | return backlight_config.breathing; | ||
| 216 | } | ||
| 217 | #endif | ||
diff --git a/tmk_core/common/backlight.h b/tmk_core/common/backlight.h index 420c9d19e..cc56fb9af 100644 --- a/tmk_core/common/backlight.h +++ b/tmk_core/common/backlight.h | |||
| @@ -20,11 +20,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 20 | #include <stdint.h> | 20 | #include <stdint.h> |
| 21 | #include <stdbool.h> | 21 | #include <stdbool.h> |
| 22 | 22 | ||
| 23 | #ifndef BACKLIGHT_LEVELS | ||
| 24 | #define BACKLIGHT_LEVELS 3 | ||
| 25 | #elif BACKLIGHT_LEVELS > 15 | ||
| 26 | #error "Maximum value of BACKLIGHT_LEVELS is 15" | ||
| 27 | #endif | ||
| 28 | |||
| 23 | typedef union { | 29 | typedef union { |
| 24 | uint8_t raw; | 30 | uint8_t raw; |
| 25 | struct { | 31 | struct { |
| 26 | bool enable :1; | 32 | bool enable :1; |
| 27 | uint8_t level :7; | 33 | bool breathing :1; |
| 34 | uint8_t level :4; | ||
| 28 | }; | 35 | }; |
| 29 | } backlight_config_t; | 36 | } backlight_config_t; |
| 30 | 37 | ||
| @@ -40,3 +47,11 @@ void backlight_set(uint8_t level); | |||
| 40 | void backlight_level(uint8_t level); | 47 | void backlight_level(uint8_t level); |
| 41 | uint8_t get_backlight_level(void); | 48 | uint8_t get_backlight_level(void); |
| 42 | 49 | ||
| 50 | #ifdef BACKLIGHT_BREATHING | ||
| 51 | void backlight_toggle_breathing(void); | ||
| 52 | void backlight_enable_breathing(void); | ||
| 53 | void backlight_disable_breathing(void); | ||
| 54 | bool is_backlight_breathing(void); | ||
| 55 | void breathing_enable(void); | ||
| 56 | void breathing_disable(void); | ||
| 57 | #endif | ||
