1
0
Fork 0

Remove backup brightness feature (#1180)

This feature is not needed and is probably more likely to cause issues. It's better to just use brightnessController.Set(settingsController.GetBrightness());
This commit is contained in:
Riku Isokoski 2022-06-18 12:54:41 +03:00 committed by GitHub
parent 9b775c6a91
commit 95ff285991
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 31 deletions

View file

@ -74,14 +74,6 @@ BrightnessController::Levels BrightnessController::Level() const {
return level; return level;
} }
void BrightnessController::Backup() {
backupLevel = level;
}
void BrightnessController::Restore() {
Set(backupLevel);
}
void BrightnessController::Step() { void BrightnessController::Step() {
switch (level) { switch (level) {
case Levels::Low: case Levels::Low:
@ -123,4 +115,4 @@ const char* BrightnessController::ToString() {
default: default:
return "???"; return "???";
} }
} }

View file

@ -15,15 +15,11 @@ namespace Pinetime {
void Higher(); void Higher();
void Step(); void Step();
void Backup();
void Restore();
const char* GetIcon(); const char* GetIcon();
const char* ToString(); const char* ToString();
private: private:
Levels level = Levels::High; Levels level = Levels::High;
Levels backupLevel = Levels::High;
}; };
} }
} }

View file

@ -129,6 +129,11 @@ void DisplayApp::InitHw() {
} }
void DisplayApp::Refresh() { void DisplayApp::Refresh() {
auto LoadPreviousScreen = [this]() {
brightnessController.Set(settingsController.GetBrightness());
LoadApp(returnToApp, returnDirection);
};
TickType_t queueTimeout; TickType_t queueTimeout;
switch (state) { switch (state) {
case States::Idle: case States::Idle:
@ -136,7 +141,7 @@ void DisplayApp::Refresh() {
break; break;
case States::Running: case States::Running:
if (!currentScreen->IsRunning()) { if (!currentScreen->IsRunning()) {
LoadApp(returnToApp, returnDirection); LoadPreviousScreen();
} }
queueTimeout = lv_task_handler(); queueTimeout = lv_task_handler();
break; break;
@ -149,12 +154,10 @@ void DisplayApp::Refresh() {
if (xQueueReceive(msgQueue, &msg, queueTimeout)) { if (xQueueReceive(msgQueue, &msg, queueTimeout)) {
switch (msg) { switch (msg) {
case Messages::DimScreen: case Messages::DimScreen:
// Backup brightness is the brightness to return to after dimming or sleeping
brightnessController.Backup();
brightnessController.Set(Controllers::BrightnessController::Levels::Low); brightnessController.Set(Controllers::BrightnessController::Levels::Low);
break; break;
case Messages::RestoreBrightness: case Messages::RestoreBrightness:
brightnessController.Restore(); brightnessController.Set(settingsController.GetBrightness());
break; break;
case Messages::GoToSleep: case Messages::GoToSleep:
while (brightnessController.Level() != Controllers::BrightnessController::Levels::Off) { while (brightnessController.Level() != Controllers::BrightnessController::Levels::Off) {
@ -165,7 +168,7 @@ void DisplayApp::Refresh() {
state = States::Idle; state = States::Idle;
break; break;
case Messages::GoToRunning: case Messages::GoToRunning:
brightnessController.Restore(); brightnessController.Set(settingsController.GetBrightness());
state = States::Running; state = States::Running;
break; break;
case Messages::UpdateTimeOut: case Messages::UpdateTimeOut:
@ -224,9 +227,7 @@ void DisplayApp::Refresh() {
break; break;
} }
} else if (returnTouchEvent == gesture) { } else if (returnTouchEvent == gesture) {
LoadApp(returnToApp, returnDirection); LoadPreviousScreen();
brightnessController.Set(settingsController.GetBrightness());
brightnessController.Backup();
} }
} else { } else {
touchHandler.CancelTap(); touchHandler.CancelTap();
@ -237,9 +238,7 @@ void DisplayApp::Refresh() {
if (currentApp == Apps::Clock) { if (currentApp == Apps::Clock) {
PushMessageToSystemTask(System::Messages::GoToSleep); PushMessageToSystemTask(System::Messages::GoToSleep);
} else { } else {
LoadApp(returnToApp, returnDirection); LoadPreviousScreen();
brightnessController.Set(settingsController.GetBrightness());
brightnessController.Backup();
} }
} }
break; break;

View file

@ -14,12 +14,7 @@ namespace {
FlashLight::FlashLight(Pinetime::Applications::DisplayApp* app, FlashLight::FlashLight(Pinetime::Applications::DisplayApp* app,
System::SystemTask& systemTask, System::SystemTask& systemTask,
Controllers::BrightnessController& brightnessController) Controllers::BrightnessController& brightnessController)
: Screen(app), : Screen(app), systemTask {systemTask}, brightnessController {brightnessController} {
systemTask {systemTask},
brightnessController {brightnessController}
{
brightnessController.Backup();
brightnessLevel = brightnessController.Level(); brightnessLevel = brightnessController.Level();
@ -56,7 +51,6 @@ FlashLight::FlashLight(Pinetime::Applications::DisplayApp* app,
FlashLight::~FlashLight() { FlashLight::~FlashLight() {
lv_obj_clean(lv_scr_act()); lv_obj_clean(lv_scr_act());
lv_obj_set_style_local_bg_color(lv_scr_act(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK); lv_obj_set_style_local_bg_color(lv_scr_act(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
brightnessController.Restore();
systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping); systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
} }