summaryrefslogtreecommitdiff
path: root/tmk_core/common/backlight.c
diff options
context:
space:
mode:
authorPhillip Tennen <phillip.ennen@gmail.com>2018-11-14 16:45:46 +0100
committerDrashna Jaelre <drashna@live.com>2018-11-14 07:45:46 -0800
commit0cda2f43e2c95fe5dd440e6391ae807f508b040b (patch)
tree05d9cd5db86789ca0f475f43db7b0fbcb6251f1d /tmk_core/common/backlight.c
parentf7fcba329dbd659a4bb37acdf7e2dc24204a81c8 (diff)
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.c51
1 files changed, 45 insertions, 6 deletions
diff --git a/tmk_core/common/backlight.c b/tmk_core/common/backlight.c
index 3e29aacc49..8ddacd98b6 100644
--- a/tmk_core/common/backlight.c
+++ b/tmk_core/common/backlight.c
@@ -76,12 +76,51 @@ void backlight_decrease(void)
*/
void backlight_toggle(void)
{
- backlight_config.enable ^= 1;
- if (backlight_config.raw == 1) // enabled but level = 0
- backlight_config.level = 1;
- eeconfig_update_backlight(backlight_config.raw);
- dprintf("backlight toggle: %u\n", backlight_config.enable);
- backlight_set(backlight_config.enable ? backlight_config.level : 0);
+ bool enabled = backlight_config.enable;
+ dprintf("backlight toggle: %u\n", enabled);
+ if (enabled)
+ backlight_disable();
+ else
+ backlight_enable();
+}
+
+/** \brief Enable backlight
+ *
+ * FIXME: needs doc
+ */
+void backlight_enable(void)
+{
+ if (backlight_config.enable) return; // do nothing if backlight is already on
+
+ backlight_config.enable = true;
+ if (backlight_config.raw == 1) // enabled but level == 0
+ backlight_config.level = 1;
+ eeconfig_update_backlight(backlight_config.raw);
+ dprintf("backlight enable\n");
+ backlight_set(backlight_config.level);
+}
+
+/** /brief Disable backlight
+ *
+ * FIXME: needs doc
+ */
+void backlight_disable(void)
+{
+ if (!backlight_config.enable) return; // do nothing if backlight is already off
+
+ backlight_config.enable = false;
+ eeconfig_update_backlight(backlight_config.raw);
+ dprintf("backlight disable\n");
+ backlight_set(0);
+}
+
+/** /brief Get the backlight status
+ *
+ * FIXME: needs doc
+ */
+bool is_backlight_enabled(void)
+{
+ return backlight_config.enable;
}
/** \brief Backlight step through levels