summaryrefslogtreecommitdiff
path: root/src/displayapp
diff options
context:
space:
mode:
authorMichele Bini <michele.bini@gmail.com>2022-03-27 06:57:01 (GMT)
committerMichele Bini <michele.bini@gmail.com>2022-03-27 06:57:01 (GMT)
commit8413e62eeab686fad4f3d280e4732571372088e3 (patch)
tree261000c41a03f35adbbf700fe472554b38c61de8 /src/displayapp
parentce7fd962caf64fa0037d1b80baa48deb88839010 (diff)
Sans shakewake and leftover modifications: Size: 228360
Diffstat (limited to 'src/displayapp')
-rw-r--r--src/displayapp/Apps.h1
-rw-r--r--src/displayapp/DisplayApp.cpp6
-rw-r--r--src/displayapp/screens/settings/SettingShakeThreshold.cpp137
-rw-r--r--src/displayapp/screens/settings/SettingShakeThreshold.h37
-rw-r--r--src/displayapp/screens/settings/SettingWakeUp.cpp8
-rw-r--r--src/displayapp/screens/settings/Settings.cpp15
6 files changed, 1 insertions, 203 deletions
diff --git a/src/displayapp/Apps.h b/src/displayapp/Apps.h
index 929cfaf..c308c75 100644
--- a/src/displayapp/Apps.h
+++ b/src/displayapp/Apps.h
@@ -15,7 +15,6 @@ namespace Pinetime {
SettingTimeFormat,
SettingDisplay,
SettingWakeUp,
- SettingShakeThreshold,
Error
};
}
diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp
index e62bd81..574f964 100644
--- a/src/displayapp/DisplayApp.cpp
+++ b/src/displayapp/DisplayApp.cpp
@@ -11,7 +11,6 @@
#include "displayapp/screens/Clock.h"
#include "displayapp/screens/FirmwareUpdate.h"
#include "displayapp/screens/FirmwareValidation.h"
-#include "displayapp/screens/Meter.h"
#include "displayapp/screens/Notifications.h"
#include "displayapp/screens/Tile.h"
#include "displayapp/screens/Error.h"
@@ -27,7 +26,6 @@
#include "displayapp/screens/settings/SettingTimeFormat.h"
#include "displayapp/screens/settings/SettingWakeUp.h"
#include "displayapp/screens/settings/SettingDisplay.h"
-#include "displayapp/screens/settings/SettingShakeThreshold.h"
#include "libs/lv_conf.h"
@@ -346,10 +344,6 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
currentScreen = std::make_unique<Screens::SettingDisplay>(this, settingsController);
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
break;
- case Apps::SettingShakeThreshold:
- currentScreen = std::make_unique<Screens::SettingShakeThreshold>(this, settingsController, motionController, *systemTask);
- ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
- break;
}
currentApp = app;
}
diff --git a/src/displayapp/screens/settings/SettingShakeThreshold.cpp b/src/displayapp/screens/settings/SettingShakeThreshold.cpp
deleted file mode 100644
index 9d40fcf..0000000
--- a/src/displayapp/screens/settings/SettingShakeThreshold.cpp
+++ /dev/null
@@ -1,137 +0,0 @@
-#include "displayapp/screens/settings/SettingShakeThreshold.h"
-#include <lvgl/lvgl.h>
-#include "displayapp/DisplayApp.h"
-#include "displayapp/screens/Screen.h"
-#include "displayapp/screens/Symbols.h"
-
-using namespace Pinetime::Applications::Screens;
-
-namespace {
- void event_handler(lv_obj_t* obj, lv_event_t event) {
- SettingShakeThreshold* screen = static_cast<SettingShakeThreshold*>(obj->user_data);
- screen->UpdateSelected(obj, event);
- }
-}
-
-SettingShakeThreshold::SettingShakeThreshold(DisplayApp* app,
- Controllers::Settings& settingsController,
- Controllers::MotionController& motionController,
- System::SystemTask& systemTask)
- : Screen(app), settingsController {settingsController}, motionController {motionController}, systemTask {systemTask} {
-
- lv_obj_t* title = lv_label_create(lv_scr_act(), nullptr);
- lv_label_set_text_static(title, "Wake Sensitivity");
- lv_label_set_align(title, LV_LABEL_ALIGN_CENTER);
- lv_obj_align(title, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 0, 0);
-
- positionArc = lv_arc_create(lv_scr_act(), nullptr);
- positionArc->user_data = this;
-
- lv_obj_set_event_cb(positionArc, event_handler);
- lv_arc_set_bg_angles(positionArc, 180, 360);
- lv_arc_set_range(positionArc, 0, 4095);
- lv_arc_set_adjustable(positionArc, true);
- lv_obj_set_width(positionArc, lv_obj_get_width(lv_scr_act()) - 10);
- lv_obj_set_height(positionArc, 240);
- lv_obj_align(positionArc, title, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
-
- animArc = lv_arc_create(positionArc, positionArc);
- lv_arc_set_adjustable(animArc, false);
- lv_obj_set_width(animArc, lv_obj_get_width(positionArc));
- lv_obj_set_height(animArc, lv_obj_get_height(positionArc));
- lv_obj_align_mid(animArc, positionArc, LV_ALIGN_CENTER, 0, 0);
- lv_obj_set_style_local_line_opa(animArc, LV_ARC_PART_BG, LV_STATE_DEFAULT, 0);
- lv_obj_set_style_local_line_opa(animArc, LV_ARC_PART_INDIC, LV_STATE_DEFAULT, LV_OPA_70);
- lv_obj_set_style_local_line_opa(animArc, LV_ARC_PART_KNOB, LV_STATE_DEFAULT, LV_OPA_0);
- lv_obj_set_style_local_line_color(animArc, LV_ARC_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_RED);
- lv_obj_set_style_local_bg_color(animArc, LV_ARC_PART_BG, LV_STATE_CHECKED, LV_COLOR_TRANSP);
-
- animArc->user_data = this;
- lv_obj_set_click(animArc, false);
-
- calButton = lv_btn_create(lv_scr_act(), nullptr);
- calButton->user_data = this;
- lv_obj_set_event_cb(calButton, event_handler);
- lv_obj_set_height(calButton, 80);
- lv_obj_set_width(calButton, 200);
- lv_obj_align(calButton, lv_scr_act(), LV_ALIGN_IN_BOTTOM_MID, 0, 0);
- lv_btn_set_checkable(calButton, true);
- calLabel = lv_label_create(calButton, NULL);
- lv_label_set_text(calLabel, "Calibrate");
-
- lv_arc_set_value(positionArc, settingsController.GetShakeThreshold());
-
- vDecay = xTaskGetTickCount();
- calibrating = false;
- EnableForCal = false;
- if(!settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::Shake)){
- EnableForCal = true;
- settingsController.setWakeUpMode(Pinetime::Controllers::Settings::WakeUpMode::Shake,true);
- }
- refreshTask = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
-}
-
-SettingShakeThreshold::~SettingShakeThreshold() {
- settingsController.SetShakeThreshold(lv_arc_get_value(positionArc));
-
- if(EnableForCal){
- settingsController.setWakeUpMode(Pinetime::Controllers::Settings::WakeUpMode::Shake,false);
- EnableForCal = false;
- }
- lv_task_del(refreshTask);
- settingsController.SaveSettings();
- lv_obj_clean(lv_scr_act());
-}
-
-void SettingShakeThreshold::Refresh() {
-
- if (calibrating == 1) {
- if (xTaskGetTickCount() - vCalTime > pdMS_TO_TICKS(2000)) {
- vCalTime = xTaskGetTickCount();
- calibrating = 2;
- lv_obj_set_style_local_bg_color(calButton, LV_BTN_PART_MAIN, LV_STATE_CHECKED, LV_COLOR_RED);
- lv_obj_set_style_local_bg_color(calButton, LV_BTN_PART_MAIN, LV_STATE_CHECKED, LV_COLOR_RED);
- lv_label_set_text(calLabel, "Shake!!");
- }
- }
- if (calibrating == 2) {
-
- if ((motionController.currentShakeSpeed() - 300) > lv_arc_get_value(positionArc)) {
- lv_arc_set_value(positionArc, (int16_t) motionController.currentShakeSpeed() - 300);
- }
- if (xTaskGetTickCount() - vCalTime > pdMS_TO_TICKS(7500)) {
- lv_btn_set_state(calButton, LV_STATE_DEFAULT);
- lv_event_send(calButton, LV_EVENT_VALUE_CHANGED, NULL);
- }
- }
- if (motionController.currentShakeSpeed() - 300 > lv_arc_get_value(animArc)) {
- lv_arc_set_value(animArc, (uint16_t) motionController.currentShakeSpeed() - 300);
- vDecay = xTaskGetTickCount();
- } else if ((xTaskGetTickCount() - vDecay) > pdMS_TO_TICKS(1500)) {
- lv_arc_set_value(animArc, lv_arc_get_value(animArc) - 25);
- }
-}
-
-void SettingShakeThreshold::UpdateSelected(lv_obj_t* object, lv_event_t event) {
-
- switch (event) {
- case LV_EVENT_VALUE_CHANGED: {
- if (object == calButton) {
- if (lv_btn_get_state(calButton) == LV_BTN_STATE_CHECKED_RELEASED && calibrating == 0) {
- lv_arc_set_value(positionArc, 0);
- calibrating = 1;
- vCalTime = xTaskGetTickCount();
- lv_label_set_text(calLabel, "Ready!");
- lv_obj_set_click(positionArc, false);
- lv_obj_set_style_local_bg_color(calButton, LV_BTN_PART_MAIN, LV_STATE_CHECKED, LV_COLOR_GREEN);
- lv_obj_set_style_local_bg_color(calButton, LV_BTN_PART_MAIN, LV_STATE_CHECKED, LV_COLOR_GREEN);
- } else if (lv_btn_get_state(calButton) == LV_BTN_STATE_RELEASED) {
- calibrating = 0;
- lv_obj_set_click(positionArc, true);
- lv_label_set_text(calLabel, "Calibrate");
- }
- break;
- }
- }
- }
-}
diff --git a/src/displayapp/screens/settings/SettingShakeThreshold.h b/src/displayapp/screens/settings/SettingShakeThreshold.h
deleted file mode 100644
index 37f4a65..0000000
--- a/src/displayapp/screens/settings/SettingShakeThreshold.h
+++ /dev/null
@@ -1,37 +0,0 @@
-#pragma once
-
-#include <cstdint>
-#include <lvgl/lvgl.h>
-#include "components/settings/Settings.h"
-#include "displayapp/screens/Screen.h"
-#include <components/motion/MotionController.h>
-#include "systemtask/SystemTask.h"
-namespace Pinetime {
-
- namespace Applications {
- namespace Screens {
-
- class SettingShakeThreshold : public Screen {
- public:
- SettingShakeThreshold(DisplayApp* app,
- Pinetime::Controllers::Settings& settingsController,
- Controllers::MotionController& motionController,
- System::SystemTask& systemTask);
-
- ~SettingShakeThreshold() override;
- void Refresh() override;
- void UpdateSelected(lv_obj_t* object, lv_event_t event);
-
- private:
- Controllers::Settings& settingsController;
- Controllers::MotionController& motionController;
- System::SystemTask& systemTask;
- uint8_t calibrating;
- bool EnableForCal;
- uint32_t vDecay,vCalTime;
- lv_obj_t *positionArc, *animArc,*calButton, *calLabel;
- lv_task_t* refreshTask;
- };
- }
- }
-}
diff --git a/src/displayapp/screens/settings/SettingWakeUp.cpp b/src/displayapp/screens/settings/SettingWakeUp.cpp
index e1b6e36..8339d9a 100644
--- a/src/displayapp/screens/settings/SettingWakeUp.cpp
+++ b/src/displayapp/screens/settings/SettingWakeUp.cpp
@@ -65,14 +65,6 @@ SettingWakeUp::SettingWakeUp(Pinetime::Applications::DisplayApp* app, Pinetime::
lv_checkbox_set_checked(cbOption[optionsTotal], true);
}
optionsTotal++;
- cbOption[optionsTotal] = lv_checkbox_create(container1, nullptr);
- lv_checkbox_set_text_static(cbOption[optionsTotal], " Shake Wake");
- cbOption[optionsTotal]->user_data = this;
- lv_obj_set_event_cb(cbOption[optionsTotal], event_handler);
- if (settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::Shake)) {
- lv_checkbox_set_checked(cbOption[optionsTotal], true);
- }
- optionsTotal++;
}
SettingWakeUp::~SettingWakeUp() {
diff --git a/src/displayapp/screens/settings/Settings.cpp b/src/displayapp/screens/settings/Settings.cpp
index 01dd534..b71e333 100644
--- a/src/displayapp/screens/settings/Settings.cpp
+++ b/src/displayapp/screens/settings/Settings.cpp
@@ -17,9 +17,6 @@ Settings::Settings(Pinetime::Applications::DisplayApp* app, Pinetime::Controller
[this]() -> std::unique_ptr<Screen> {
return CreateScreen1();
},
- [this]() -> std::unique_ptr<Screen> {
- return CreateScreen2();
- },
},
Screens::ScreenListModes::UpDown} {
}
@@ -37,20 +34,10 @@ std::unique_ptr<Screen> Settings::CreateScreen1() {
{Symbols::sun, "Display", Apps::SettingDisplay},
{Symbols::eye, "Wake Up", Apps::SettingWakeUp},
{Symbols::clock, "Time format", Apps::SettingTimeFormat},
- {Symbols::none, "None", Apps::None}
+ {Symbols::check, "Firmware", Apps::FirmwareValidation},
}};
return std::make_unique<Screens::List>(0, 1, app, settingsController, applications);
}
-std::unique_ptr<Screen> Settings::CreateScreen2() {
- std::array<Screens::List::Applications, 4> applications {{
- {Symbols::tachometer, "Shake Calib.", Apps::SettingShakeThreshold},
- {Symbols::check, "Firmware", Apps::FirmwareValidation},
- {Symbols::none, "None", Apps::None},
- {Symbols::none, "None", Apps::None}
-}};
-
- return std::make_unique<Screens::List>(1, 2, app, settingsController, applications);
-}