Skip to content

Commit 3b3701c

Browse files
JF002serosi
andcommitted
Restore brightness level when closing the Flashlight application
The brightness level is stored when entering the app, and restored when closing it. Based on another fixed suggested by serosi. Co-authored-by: serosi <68392668+serosi@users.noreply.github.com>
1 parent 7dbb8f5 commit 3b3701c

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/displayapp/screens/FlashLight.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace {
1515
}
1616

1717
FlashLight::FlashLight(System::SystemTask& systemTask, Controllers::BrightnessController& brightnessController)
18-
: systemTask {systemTask}, brightnessController {brightnessController} {
18+
: systemTask {systemTask}, brightnessController {brightnessController}, backupBrightnessLevel {brightnessController.Level()} {
1919

2020
brightnessController.Set(Controllers::BrightnessController::Levels::Low);
2121

@@ -52,6 +52,7 @@ FlashLight::FlashLight(System::SystemTask& systemTask, Controllers::BrightnessCo
5252
FlashLight::~FlashLight() {
5353
lv_obj_clean(lv_scr_act());
5454
lv_obj_set_style_local_bg_color(lv_scr_act(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
55+
brightnessController.Set(backupBrightnessLevel);
5556
systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
5657
}
5758

src/displayapp/screens/FlashLight.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace Pinetime {
2727
Controllers::BrightnessController& brightnessController;
2828

2929
Controllers::BrightnessController::Levels brightnessLevel = Controllers::BrightnessController::Levels::High;
30-
30+
Controllers::BrightnessController::Levels backupBrightnessLevel;
3131
lv_obj_t* flashLight;
3232
lv_obj_t* backgroundAction;
3333
lv_obj_t* indicators[3];

0 commit comments

Comments
 (0)