gui: Actions: Toggle backlight on power key

Create GUIAction to handle KEY_POWER with a screen backlight toggle.

Change-Id: Iad0a7923b4a776e0336722db74d6fc46cd0107a2
This commit is contained in:
Matt Mower
2016-01-20 18:12:47 -06:00
committed by Dees Troy
parent 874136434a
commit 9472ba1d39
13 changed files with 69 additions and 6 deletions

View File

@@ -116,3 +116,37 @@ void blanktimer::resetTimerAndUnblank(void) {
pthread_mutex_unlock(&mutex);
#endif
}
void blanktimer::blank(void) {
/* 1) No need for timer handling since checkForTimeout() verifies
* state of screen before performing screen-off
* 2) Assume screen-off causes issues for devices that set
* TW_NO_SCREEN_TIMEOUT and do not blank screen here either
*/
#ifndef TW_NO_SCREEN_TIMEOUT
pthread_mutex_lock(&mutex);
if (state == kOn) {
orig_brightness = getBrightness();
state = kOff;
TWFunc::Set_Brightness("0");
TWFunc::check_and_run_script("/sbin/postscreenblank.sh", "blank");
}
#ifndef TW_NO_SCREEN_BLANK
if (state == kOff) {
gr_fb_blank(true);
state = kBlanked;
}
#endif
pthread_mutex_unlock(&mutex);
#endif
}
void blanktimer::toggleBlank(void) {
if (state == kOn) {
blank();
PageManager::ChangeOverlay("lock");
} else {
resetTimerAndUnblank();
}
}