summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichele Bini <michele.bini@gmail.com>2022-03-25 12:30:52 (GMT)
committerMichele Bini <michele.bini@gmail.com>2022-03-25 12:30:52 (GMT)
commit09dfdbf9117853521a706dfe4724908082dc9695 (patch)
tree23497af1018d851152ad1729147d12451b38ae19
parent060f7949866303c27dc6b8cb6dcd97ab1019d7d1 (diff)
sans torch
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/displayapp/Apps.h1
-rw-r--r--src/displayapp/DisplayApp.cpp5
-rw-r--r--src/displayapp/screens/FlashLight.cpp134
-rw-r--r--src/displayapp/screens/FlashLight.h38
-rw-r--r--src/displayapp/screens/settings/QuickSettings.cpp4
-rw-r--r--src/displayapp/screens/settings/Settings.cpp2
7 files changed, 1 insertions, 184 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index cecdee9..5af6018 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -410,7 +410,6 @@ list(APPEND SOURCE_FILES
displayapp/screens/Notifications.cpp
displayapp/screens/HeartRate.cpp
displayapp/screens/Motion.cpp
- displayapp/screens/FlashLight.cpp
displayapp/screens/List.cpp
displayapp/screens/BatteryInfo.cpp
displayapp/screens/Steps.cpp
diff --git a/src/displayapp/Apps.h b/src/displayapp/Apps.h
index 3af1afa..c9393b5 100644
--- a/src/displayapp/Apps.h
+++ b/src/displayapp/Apps.h
@@ -12,7 +12,6 @@ namespace Pinetime {
NotificationsPreview,
Notifications,
Alarm,
- FlashLight,
BatteryInfo,
HeartRate,
Motion,
diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp
index 409ae5e..9243999 100644
--- a/src/displayapp/DisplayApp.cpp
+++ b/src/displayapp/DisplayApp.cpp
@@ -18,7 +18,6 @@
#include "displayapp/screens/Notifications.h"
#include "displayapp/screens/SystemInfo.h"
#include "displayapp/screens/Tile.h"
-#include "displayapp/screens/FlashLight.h"
#include "displayapp/screens/BatteryInfo.h"
#include "displayapp/screens/Steps.h"
#include "displayapp/screens/Error.h"
@@ -396,10 +395,6 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
this, dateTimeController, batteryController, brightnessController, bleController, watchdog, motionController, touchPanel);
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
break;
- case Apps::FlashLight:
- currentScreen = std::make_unique<Screens::FlashLight>(this, *systemTask, brightnessController);
- ReturnApp(Apps::QuickSettings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
- break;
case Apps::HeartRate:
currentScreen = std::make_unique<Screens::HeartRate>(this, heartRateController, *systemTask);
break;
diff --git a/src/displayapp/screens/FlashLight.cpp b/src/displayapp/screens/FlashLight.cpp
deleted file mode 100644
index c4d0264..0000000
--- a/src/displayapp/screens/FlashLight.cpp
+++ /dev/null
@@ -1,134 +0,0 @@
-#include "displayapp/screens/FlashLight.h"
-#include "displayapp/DisplayApp.h"
-#include "displayapp/screens/Symbols.h"
-
-using namespace Pinetime::Applications::Screens;
-
-namespace {
- void event_handler(lv_obj_t* obj, lv_event_t event) {
- auto* screen = static_cast<FlashLight*>(obj->user_data);
- screen->OnClickEvent(obj, event);
- }
-}
-
-FlashLight::FlashLight(Pinetime::Applications::DisplayApp* app,
- System::SystemTask& systemTask,
- Controllers::BrightnessController& brightnessController)
- : Screen(app),
- systemTask {systemTask},
- brightnessController {brightnessController}
-
-{
- brightnessController.Backup();
-
- brightnessLevel = brightnessController.Level();
-
- flashLight = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_text_font(flashLight, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48);
- lv_label_set_text_static(flashLight, Symbols::highlight);
- lv_obj_align(flashLight, nullptr, LV_ALIGN_CENTER, 0, 0);
-
- for (auto & i : indicators) {
- i = lv_obj_create(lv_scr_act(), nullptr);
- lv_obj_set_size(i, 15, 10);
- lv_obj_set_style_local_border_width(i, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 2);
- }
-
- lv_obj_align(indicators[1], flashLight, LV_ALIGN_OUT_BOTTOM_MID, 0, 5);
- lv_obj_align(indicators[0], indicators[1], LV_ALIGN_OUT_LEFT_MID, -8, 0);
- lv_obj_align(indicators[2], indicators[1], LV_ALIGN_OUT_RIGHT_MID, 8, 0);
-
- SetIndicators();
- SetColors();
-
- backgroundAction = lv_label_create(lv_scr_act(), nullptr);
- lv_label_set_long_mode(backgroundAction, LV_LABEL_LONG_CROP);
- lv_obj_set_size(backgroundAction, 240, 240);
- lv_obj_set_pos(backgroundAction, 0, 0);
- lv_label_set_text(backgroundAction, "");
- lv_obj_set_click(backgroundAction, true);
- backgroundAction->user_data = this;
- lv_obj_set_event_cb(backgroundAction, event_handler);
-
- systemTask.PushMessage(Pinetime::System::Messages::DisableSleeping);
-}
-
-FlashLight::~FlashLight() {
- 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);
- brightnessController.Restore();
- systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
-}
-
-void FlashLight::SetColors() {
- if (isOn) {
- lv_obj_set_style_local_bg_color(lv_scr_act(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
- lv_obj_set_style_local_text_color(flashLight, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
- for (auto & i : indicators) {
- lv_obj_set_style_local_bg_color(i, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
- lv_obj_set_style_local_bg_color(i, LV_OBJ_PART_MAIN, LV_STATE_DISABLED, LV_COLOR_WHITE);
- lv_obj_set_style_local_border_color(i, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
- }
- } else {
- 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_text_color(flashLight, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
- for (auto & i : indicators) {
- lv_obj_set_style_local_bg_color(i, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
- lv_obj_set_style_local_bg_color(i, LV_OBJ_PART_MAIN, LV_STATE_DISABLED, LV_COLOR_BLACK);
- lv_obj_set_style_local_border_color(i, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
- }
- }
-}
-
-void FlashLight::SetIndicators() {
- using namespace Pinetime::Controllers;
-
- if (brightnessLevel == BrightnessController::Levels::High) {
- lv_obj_set_state(indicators[1], LV_STATE_DEFAULT);
- lv_obj_set_state(indicators[2], LV_STATE_DEFAULT);
- } else if (brightnessLevel == BrightnessController::Levels::Medium) {
- lv_obj_set_state(indicators[1], LV_STATE_DEFAULT);
- lv_obj_set_state(indicators[2], LV_STATE_DISABLED);
- } else {
- lv_obj_set_state(indicators[1], LV_STATE_DISABLED);
- lv_obj_set_state(indicators[2], LV_STATE_DISABLED);
- }
-}
-
-void FlashLight::OnClickEvent(lv_obj_t* obj, lv_event_t event) {
- if (obj == backgroundAction && event == LV_EVENT_CLICKED) {
- isOn = !isOn;
- SetColors();
- }
-}
-
-bool FlashLight::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
- using namespace Pinetime::Controllers;
-
- if (event == TouchEvents::SwipeLeft) {
- if (brightnessLevel == BrightnessController::Levels::High) {
- brightnessLevel = BrightnessController::Levels::Medium;
- brightnessController.Set(brightnessLevel);
- SetIndicators();
- } else if (brightnessLevel == BrightnessController::Levels::Medium) {
- brightnessLevel = BrightnessController::Levels::Low;
- brightnessController.Set(brightnessLevel);
- SetIndicators();
- }
- return true;
- }
- if (event == TouchEvents::SwipeRight) {
- if (brightnessLevel == BrightnessController::Levels::Low) {
- brightnessLevel = BrightnessController::Levels::Medium;
- brightnessController.Set(brightnessLevel);
- SetIndicators();
- } else if (brightnessLevel == BrightnessController::Levels::Medium) {
- brightnessLevel = BrightnessController::Levels::High;
- brightnessController.Set(brightnessLevel);
- SetIndicators();
- }
- return true;
- }
-
- return false;
-}
diff --git a/src/displayapp/screens/FlashLight.h b/src/displayapp/screens/FlashLight.h
deleted file mode 100644
index e91a103..0000000
--- a/src/displayapp/screens/FlashLight.h
+++ /dev/null
@@ -1,38 +0,0 @@
-#pragma once
-
-#include "displayapp/screens/Screen.h"
-#include "components/brightness/BrightnessController.h"
-#include "systemtask/SystemTask.h"
-#include <cstdint>
-#include <lvgl/lvgl.h>
-
-namespace Pinetime {
-
- namespace Applications {
- namespace Screens {
-
- class FlashLight : public Screen {
- public:
- FlashLight(DisplayApp* app, System::SystemTask& systemTask, Controllers::BrightnessController& brightness);
- ~FlashLight() override;
-
- bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override;
- void OnClickEvent(lv_obj_t* obj, lv_event_t event);
-
- private:
- void SetIndicators();
- void SetColors();
-
- Pinetime::System::SystemTask& systemTask;
- Controllers::BrightnessController& brightnessController;
-
- Controllers::BrightnessController::Levels brightnessLevel;
-
- lv_obj_t* flashLight;
- lv_obj_t* backgroundAction;
- lv_obj_t* indicators[3];
- bool isOn = false;
- };
- }
- }
-}
diff --git a/src/displayapp/screens/settings/QuickSettings.cpp b/src/displayapp/screens/settings/QuickSettings.cpp
index cd56c14..c00518e 100644
--- a/src/displayapp/screens/settings/QuickSettings.cpp
+++ b/src/displayapp/screens/settings/QuickSettings.cpp
@@ -129,10 +129,6 @@ void QuickSettings::UpdateScreen() {
void QuickSettings::OnButtonEvent(lv_obj_t* object, lv_event_t event) {
if (object == btn2 && event == LV_EVENT_CLICKED) {
-
- running = false;
- app->StartApp(Apps::FlashLight, DisplayApp::FullRefreshDirections::Up);
-
} else if (object == btn1 && event == LV_EVENT_CLICKED) {
brightness.Step();
diff --git a/src/displayapp/screens/settings/Settings.cpp b/src/displayapp/screens/settings/Settings.cpp
index 6950090..7d259db 100644
--- a/src/displayapp/screens/settings/Settings.cpp
+++ b/src/displayapp/screens/settings/Settings.cpp
@@ -61,7 +61,7 @@ std::unique_ptr<Screen> Settings::CreateScreen2() {
std::unique_ptr<Screen> Settings::CreateScreen3() {
std::array<Screens::List::Applications, 4> applications {{
- {Symbols::clock, "Chimes", Apps::SettingChimes},
+ {Symbols::none, "None", Apps::None},
{Symbols::tachometer, "Shake Calib.", Apps::SettingShakeThreshold},
{Symbols::check, "Firmware", Apps::FirmwareValidation},
{Symbols::airplane, "Airplane mode", Apps::SettingAirplaneMode}