mirror of
https://github.com/openstenoproject/qmk
synced 2024-11-10 10:39:09 +00:00
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
This commit is contained in:
parent
f7fcba329d
commit
0cda2f43e2
3 changed files with 60 additions and 14 deletions
|
@ -54,14 +54,17 @@ In this handler, the value of an incrementing counter is mapped onto a precomput
|
||||||
|
|
||||||
## Backlight Functions
|
## Backlight Functions
|
||||||
|
|
||||||
|Function |Description |
|
|Function |Description |
|
||||||
|----------|----------------------------------------------------------|
|
|----------|-----------------------------------------------------------|
|
||||||
|`backlight_toggle()` |Turn the backlight on or off |
|
|`backlight_toggle()` |Turn the backlight on or off |
|
||||||
|`backlight_step()` |Cycle through backlight levels |
|
|`backlight_enable()` |Turn the backlight on |
|
||||||
|`backlight_increase()` |Increase the backlight level |
|
|`backlight_disable()` |Turn the backlight off |
|
||||||
|`backlight_decrease()` |Decrease the backlight level |
|
|`backlight_step()` |Cycle through backlight levels |
|
||||||
|`backlight_level(x)` |Sets the backlight level to specified level |
|
|`backlight_increase()` |Increase the backlight level |
|
||||||
|`get_backlight_level()`|Return the current backlight level |
|
|`backlight_decrease()` |Decrease the backlight level |
|
||||||
|
|`backlight_level(x)` |Sets the backlight level to specified level |
|
||||||
|
|`get_backlight_level()` |Return the current backlight level |
|
||||||
|
|`is_backlight_enabled()`|Return whether the backlight is currently on |
|
||||||
|
|
||||||
### Backlight Breathing Functions
|
### Backlight Breathing Functions
|
||||||
|
|
||||||
|
|
|
@ -76,12 +76,51 @@ void backlight_decrease(void)
|
||||||
*/
|
*/
|
||||||
void backlight_toggle(void)
|
void backlight_toggle(void)
|
||||||
{
|
{
|
||||||
backlight_config.enable ^= 1;
|
bool enabled = backlight_config.enable;
|
||||||
if (backlight_config.raw == 1) // enabled but level = 0
|
dprintf("backlight toggle: %u\n", enabled);
|
||||||
backlight_config.level = 1;
|
if (enabled)
|
||||||
eeconfig_update_backlight(backlight_config.raw);
|
backlight_disable();
|
||||||
dprintf("backlight toggle: %u\n", backlight_config.enable);
|
else
|
||||||
backlight_set(backlight_config.enable ? backlight_config.level : 0);
|
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
|
/** \brief Backlight step through levels
|
||||||
|
|
|
@ -32,7 +32,11 @@ void backlight_init(void);
|
||||||
void backlight_increase(void);
|
void backlight_increase(void);
|
||||||
void backlight_decrease(void);
|
void backlight_decrease(void);
|
||||||
void backlight_toggle(void);
|
void backlight_toggle(void);
|
||||||
|
void backlight_enable(void);
|
||||||
|
void backlight_disable(void);
|
||||||
|
bool is_backlight_enabled(void);
|
||||||
void backlight_step(void);
|
void backlight_step(void);
|
||||||
void backlight_set(uint8_t level);
|
void backlight_set(uint8_t level);
|
||||||
void backlight_level(uint8_t level);
|
void backlight_level(uint8_t level);
|
||||||
uint8_t get_backlight_level(void);
|
uint8_t get_backlight_level(void);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue