From 8a71f2b9e00718b16f860af9f24f3d1c77613b7f Mon Sep 17 00:00:00 2001 From: mabuch Date: Sun, 5 Jun 2022 19:34:37 +0200 Subject: [PATCH] remove unused Brightness App (#1170) --- src/CMakeLists.txt | 2 - src/displayapp/DisplayApp.cpp | 1 - src/displayapp/screens/Brightness.cpp | 103 -------------------------- src/displayapp/screens/Brightness.h | 33 --------- 4 files changed, 139 deletions(-) delete mode 100644 src/displayapp/screens/Brightness.cpp delete mode 100644 src/displayapp/screens/Brightness.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 44d47dd4..443e2de9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -383,7 +383,6 @@ list(APPEND SOURCE_FILES displayapp/screens/BatteryIcon.cpp displayapp/screens/BleIcon.cpp displayapp/screens/NotificationIcon.cpp - displayapp/screens/Brightness.cpp displayapp/screens/SystemInfo.cpp displayapp/screens/Label.cpp displayapp/screens/FirmwareUpdate.cpp @@ -598,7 +597,6 @@ set(INCLUDE_FILES displayapp/screens/BatteryIcon.h displayapp/screens/BleIcon.h displayapp/screens/NotificationIcon.h - displayapp/screens/Brightness.h displayapp/screens/SystemInfo.h displayapp/screens/ScreenList.h displayapp/screens/Label.h diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index a50f6766..07170d99 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -11,7 +11,6 @@ #include "components/motion/MotionController.h" #include "components/motor/MotorController.h" #include "displayapp/screens/ApplicationList.h" -#include "displayapp/screens/Brightness.h" #include "displayapp/screens/Clock.h" #include "displayapp/screens/FirmwareUpdate.h" #include "displayapp/screens/FirmwareValidation.h" diff --git a/src/displayapp/screens/Brightness.cpp b/src/displayapp/screens/Brightness.cpp deleted file mode 100644 index d9901ae8..00000000 --- a/src/displayapp/screens/Brightness.cpp +++ /dev/null @@ -1,103 +0,0 @@ -#include "displayapp/screens/Brightness.h" -#include - -using namespace Pinetime::Applications::Screens; - -void slider_event_cb(lv_obj_t* slider, lv_event_t event) { - if (event == LV_EVENT_VALUE_CHANGED) { - auto* brightnessSlider = static_cast(slider->user_data); - brightnessSlider->OnValueChanged(); - } -} - -Brightness::Brightness(Pinetime::Applications::DisplayApp* app, Controllers::BrightnessController& brightness) - : Screen(app), brightness {brightness} { - slider = lv_slider_create(lv_scr_act(), nullptr); - lv_obj_set_user_data(slider, this); - lv_obj_set_width(slider, LV_DPI * 2); - lv_obj_align(slider, nullptr, LV_ALIGN_CENTER, 0, 0); - lv_obj_set_event_cb(slider, slider_event_cb); - lv_slider_set_range(slider, 0, 2); - lv_slider_set_value(slider, LevelToInt(brightness.Level()), LV_ANIM_OFF); - - slider_label = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_text(slider_label, LevelToString(brightness.Level())); - lv_obj_set_auto_realign(slider_label, true); - lv_obj_align(slider_label, slider, LV_ALIGN_OUT_BOTTOM_MID, 0, 30); -} - -Brightness::~Brightness() { - lv_obj_clean(lv_scr_act()); -} - -const char* Brightness::LevelToString(Pinetime::Controllers::BrightnessController::Levels level) { - switch (level) { - case Pinetime::Controllers::BrightnessController::Levels::Off: - return "Off"; - case Pinetime::Controllers::BrightnessController::Levels::Low: - return "Low"; - case Pinetime::Controllers::BrightnessController::Levels::Medium: - return "Medium"; - case Pinetime::Controllers::BrightnessController::Levels::High: - return "High"; - default: - return "???"; - } -} - -void Brightness::OnValueChanged() { - SetValue(lv_slider_get_value(slider)); -} - -void Brightness::SetValue(uint8_t value) { - switch (value) { - case 0: - brightness.Set(Controllers::BrightnessController::Levels::Low); - break; - case 1: - brightness.Set(Controllers::BrightnessController::Levels::Medium); - break; - case 2: - brightness.Set(Controllers::BrightnessController::Levels::High); - break; - } - lv_label_set_text(slider_label, LevelToString(brightness.Level())); -} - -uint8_t Brightness::LevelToInt(Pinetime::Controllers::BrightnessController::Levels level) { - switch (level) { - case Pinetime::Controllers::BrightnessController::Levels::Off: - return 0; - case Pinetime::Controllers::BrightnessController::Levels::Low: - return 0; - case Pinetime::Controllers::BrightnessController::Levels::Medium: - return 1; - case Pinetime::Controllers::BrightnessController::Levels::High: - return 2; - default: - return 0; - } -} - -bool Brightness::OnTouchEvent(Pinetime::Applications::TouchEvents event) { - switch (event) { - case TouchEvents::SwipeLeft: - brightness.Lower(); - if (brightness.Level() == Pinetime::Controllers::BrightnessController::Levels::Off) { - brightness.Set(Controllers::BrightnessController::Levels::Low); - } - SetValue(); - return true; - case TouchEvents::SwipeRight: - brightness.Higher(); - SetValue(); - return true; - default: - return false; - } -} - -void Brightness::SetValue() { - lv_slider_set_value(slider, LevelToInt(brightness.Level()), LV_ANIM_OFF); - lv_label_set_text(slider_label, LevelToString(brightness.Level())); -} diff --git a/src/displayapp/screens/Brightness.h b/src/displayapp/screens/Brightness.h deleted file mode 100644 index 693570c7..00000000 --- a/src/displayapp/screens/Brightness.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#include -#include -#include "displayapp/screens/Screen.h" -#include "components/brightness/BrightnessController.h" - -namespace Pinetime { - namespace Applications { - namespace Screens { - class Brightness : public Screen { - public: - Brightness(DisplayApp* app, Controllers::BrightnessController& brightness); - ~Brightness() override; - - bool OnTouchEvent(TouchEvents event) override; - - void OnValueChanged(); - - private: - Controllers::BrightnessController& brightness; - - lv_obj_t* slider_label; - lv_obj_t* slider; - - const char* LevelToString(Controllers::BrightnessController::Levels level); - uint8_t LevelToInt(Controllers::BrightnessController::Levels level); - void SetValue(uint8_t value); - void SetValue(); - }; - } - } -}