Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backlight status functions #4259

Merged
merged 6 commits into from
Nov 14, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add functions to set specific backlight state
codyd51 committed Oct 27, 2018
commit e87587f8f2b48c508449409c0db01c90c3a8a13d
44 changes: 38 additions & 6 deletions tmk_core/common/backlight.c
Original file line number Diff line number Diff line change
@@ -76,12 +76,44 @@ 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 Backlight step through levels
3 changes: 3 additions & 0 deletions tmk_core/common/backlight.h
Original file line number Diff line number Diff line change
@@ -32,7 +32,10 @@ void backlight_init(void);
void backlight_increase(void);
void backlight_decrease(void);
void backlight_toggle(void);
void backlight_enable(void);
void backlight_disable(void);
void backlight_step(void);
void backlight_set(uint8_t level);
void backlight_level(uint8_t level);
uint8_t get_backlight_level(void);