diff options
author | Phillip Tennen <phillip.ennen@gmail.com> | 2018-11-14 16:45:46 +0100 |
---|---|---|
committer | Drashna Jaelre <drashna@live.com> | 2018-11-14 07:45:46 -0800 |
commit | 0cda2f43e2c95fe5dd440e6391ae807f508b040b (patch) | |
tree | 05d9cd5db86789ca0f475f43db7b0fbcb6251f1d /tmk_core/common/backlight.c | |
parent | f7fcba329dbd659a4bb37acdf7e2dc24204a81c8 (diff) | |
download | qmk_firmware-0cda2f43e2c95fe5dd440e6391ae807f508b040b.tar.gz qmk_firmware-0cda2f43e2c95fe5dd440e6391ae807f508b040b.zip |
Backlight status functions (#4259)
* add functions to set specific backlight state
* add function to query backlight state
* update documentation with new backlight functions
* Update tmk_core/common/backlight.c
Co-Authored-By: codyd51 <phillip.ennen@gmail.com>
* Update tmk_core/common/backlight.h
Co-Authored-By: codyd51 <phillip.ennen@gmail.com>
* update docs for is_backlight_enabled() name change
Diffstat (limited to 'tmk_core/common/backlight.c')
-rw-r--r-- | tmk_core/common/backlight.c | 51 |
1 files changed, 45 insertions, 6 deletions
diff --git a/tmk_core/common/backlight.c b/tmk_core/common/backlight.c index 3e29aacc4..8ddacd98b 100644 --- a/tmk_core/common/backlight.c +++ b/tmk_core/common/backlight.c | |||
@@ -76,12 +76,51 @@ void backlight_decrease(void) | |||
76 | */ | 76 | */ |
77 | void backlight_toggle(void) | 77 | void backlight_toggle(void) |
78 | { | 78 | { |
79 | backlight_config.enable ^= 1; | 79 | bool enabled = backlight_config.enable; |
80 | if (backlight_config.raw == 1) // enabled but level = 0 | 80 | dprintf("backlight toggle: %u\n", enabled); |
81 | backlight_config.level = 1; | 81 | if (enabled) |
82 | eeconfig_update_backlight(backlight_config.raw); | 82 | backlight_disable(); |
83 | dprintf("backlight toggle: %u\n", backlight_config.enable); | 83 | else |
84 | backlight_set(backlight_config.enable ? backlight_config.level : 0); | 84 | backlight_enable(); |
85 | } | ||
86 | |||
87 | /** \brief Enable backlight | ||
88 | * | ||
89 | * FIXME: needs doc | ||
90 | */ | ||
91 | void backlight_enable(void) | ||
92 | { | ||
93 | if (backlight_config.enable) return; // do nothing if backlight is already on | ||
94 | |||
95 | backlight_config.enable = true; | ||
96 | if (backlight_config.raw == 1) // enabled but level == 0 | ||
97 | backlight_config.level = 1; | ||
98 | eeconfig_update_backlight(backlight_config.raw); | ||
99 | dprintf("backlight enable\n"); | ||
100 | backlight_set(backlight_config.level); | ||
101 | } | ||
102 | |||
103 | /** /brief Disable backlight | ||
104 | * | ||
105 | * FIXME: needs doc | ||
106 | */ | ||
107 | void backlight_disable(void) | ||
108 | { | ||
109 | if (!backlight_config.enable) return; // do nothing if backlight is already off | ||
110 | |||
111 | backlight_config.enable = false; | ||
112 | eeconfig_update_backlight(backlight_config.raw); | ||
113 | dprintf("backlight disable\n"); | ||
114 | backlight_set(0); | ||
115 | } | ||
116 | |||
117 | /** /brief Get the backlight status | ||
118 | * | ||
119 | * FIXME: needs doc | ||
120 | */ | ||
121 | bool is_backlight_enabled(void) | ||
122 | { | ||
123 | return backlight_config.enable; | ||
85 | } | 124 | } |
86 | 125 | ||
87 | /** \brief Backlight step through levels | 126 | /** \brief Backlight step through levels |