summaryrefslogtreecommitdiff
path: root/src/displayapp/screens
diff options
context:
space:
mode:
Diffstat (limited to 'src/displayapp/screens')
-rw-r--r--src/displayapp/screens/settings/SettingShakeThreshold.cpp118
-rw-r--r--src/displayapp/screens/settings/SettingShakeThreshold.h20
2 files changed, 78 insertions, 60 deletions
diff --git a/src/displayapp/screens/settings/SettingShakeThreshold.cpp b/src/displayapp/screens/settings/SettingShakeThreshold.cpp
index 6665e4b6..19afa24f 100644
--- a/src/displayapp/screens/settings/SettingShakeThreshold.cpp
+++ b/src/displayapp/screens/settings/SettingShakeThreshold.cpp
@@ -4,6 +4,7 @@
#include "displayapp/screens/Screen.h"
#include "displayapp/screens/Symbols.h"
+
using namespace Pinetime::Applications::Screens;
namespace {
@@ -13,77 +14,82 @@ namespace {
}
}
-SettingShakeThreshold::SettingShakeThreshold(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController)
- : Screen(app), settingsController {settingsController} {
-
- lv_obj_t* container1 = lv_cont_create(lv_scr_act(), nullptr);
-
- // lv_obj_set_style_local_bg_color(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x111111));
- lv_obj_set_style_local_bg_opa(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP);
- lv_obj_set_style_local_pad_all(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 10);
- lv_obj_set_style_local_pad_inner(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 5);
- lv_obj_set_style_local_border_width(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 0);
-
- lv_obj_set_pos(container1, 10, 60);
- lv_obj_set_width(container1, LV_HOR_RES - 20);
- lv_obj_set_height(container1, LV_VER_RES - 50);
- lv_cont_set_layout(container1, LV_LAYOUT_COLUMN_LEFT);
+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, "Shake Threshold");
lv_label_set_align(title, LV_LABEL_ALIGN_CENTER);
- lv_obj_align(title, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 10, 15);
-
- lv_obj_t* icon = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_text_color(icon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE);
- lv_label_set_text_static(icon, Symbols::home);
- lv_label_set_align(icon, LV_LABEL_ALIGN_CENTER);
- lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0);
-
- optionsTotal = 0;
- cbOption[optionsTotal] = lv_checkbox_create(container1, nullptr);
- lv_checkbox_set_text_static(cbOption[optionsTotal], " High");
- cbOption[optionsTotal]->user_data = this;
- lv_obj_set_event_cb(cbOption[optionsTotal], event_handler);
- if (settingsController.GetShakeThreshold() == 150) {
- lv_checkbox_set_checked(cbOption[optionsTotal], true);
- }
+ lv_obj_align(title, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 0, 0);
- optionsTotal++;
- cbOption[optionsTotal] = lv_checkbox_create(container1, nullptr);
- lv_checkbox_set_text_static(cbOption[optionsTotal], " Medium");
- cbOption[optionsTotal]->user_data = this;
- lv_obj_set_event_cb(cbOption[optionsTotal], event_handler);
- if (settingsController.GetShakeThreshold() == 300) {
- lv_checkbox_set_checked(cbOption[optionsTotal], true);
- }
- optionsTotal++;
- cbOption[optionsTotal] = lv_checkbox_create(container1, nullptr);
- lv_checkbox_set_text_static(cbOption[optionsTotal], " Low");
- cbOption[optionsTotal]->user_data = this;
- lv_obj_set_event_cb(cbOption[optionsTotal], event_handler);
- if (settingsController.GetShakeThreshold() == 450) {
- lv_checkbox_set_checked(cbOption[optionsTotal], true);
- }
+ positionArc = lv_arc_create(lv_scr_act(), nullptr);
+ // Why do this?
+ positionArc->user_data = this;
- optionsTotal++;
-}
+ lv_obj_set_event_cb(positionArc, event_handler);
+ // lv_arc_set_start_angle(positionArc,270);
+ lv_arc_set_angles(positionArc, 180, 360);
+ lv_arc_set_bg_angles(positionArc, 180, 360);
+
+ // lv_arc_set_rotation(positionArc, 135);
+ lv_arc_set_range(positionArc, 10, 4095);
+ lv_arc_set_value(positionArc, settingsController.GetShakeThreshold());
+ lv_obj_set_size(positionArc, 240, 180);
+ lv_arc_set_adjustable(positionArc, false);
+ lv_obj_align(positionArc, title, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10);
+
+ calButton = lv_btn_create(lv_scr_act(), nullptr);
+ calButton->user_data = this;
+ lv_obj_set_event_cb(calButton, event_handler);
+ lv_btn_set_fit(calButton, LV_FIT_TIGHT);
+
+ // lv_obj_set_style_local_bg_opa(calButton, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP);
+ lv_obj_set_height(calButton, 80);
+ lv_obj_align(calButton, lv_scr_act(), LV_ALIGN_IN_BOTTOM_MID, 0, 0);
+ calLabel = lv_label_create(calButton, NULL);
+ lv_label_set_text(calLabel, "Calibrate");
+
+ }
SettingShakeThreshold::~SettingShakeThreshold() {
lv_obj_clean(lv_scr_act());
settingsController.SaveSettings();
}
+void SettingShakeThreshold::Refresh() {
+
+ taskCount++; //100ms Update time so finish @100
+ if((motionController.currentShakeSpeed()-200) > lv_arc_get_value(positionArc)){
+ lv_arc_set_value(positionArc,(int16_t)motionController.currentShakeSpeed()-200);
+ }
+ if(taskCount >= 100){
+ lv_label_set_text(calLabel, "Calibrate");
+ lv_task_del(refreshTask);
+ }
+
+}
+
void SettingShakeThreshold::UpdateSelected(lv_obj_t* object, lv_event_t event) {
- if (event == LV_EVENT_VALUE_CHANGED) {
- for (uint8_t i = 0; i < optionsTotal; i++) {
- if (object == cbOption[i]) {
- lv_checkbox_set_checked(cbOption[i], true);
- settingsController.SetShakeThreshold((i+1)*150);
- } else {
- lv_checkbox_set_checked(cbOption[i], false);
+
+ switch (event) {
+ case LV_EVENT_PRESSED: {
+ taskCount = 0;
+ refreshTask = lv_task_create(RefreshTaskCallback, 100, LV_TASK_PRIO_MID, this);
+ lv_label_set_text(calLabel, "Shake!!!");
+ break;
+ }
+ case LV_EVENT_VALUE_CHANGED: {
+ if (object == positionArc) {
+ settingsController.SetShakeThreshold(lv_arc_get_value(positionArc));
}
+ break;
}
}
}
diff --git a/src/displayapp/screens/settings/SettingShakeThreshold.h b/src/displayapp/screens/settings/SettingShakeThreshold.h
index 387f0b6f..f6918f4d 100644
--- a/src/displayapp/screens/settings/SettingShakeThreshold.h
+++ b/src/displayapp/screens/settings/SettingShakeThreshold.h
@@ -4,7 +4,7 @@
#include <lvgl/lvgl.h>
#include "components/settings/Settings.h"
#include "displayapp/screens/Screen.h"
-
+#include <components/motion/MotionController.h>
namespace Pinetime {
namespace Applications {
@@ -12,15 +12,27 @@ namespace Pinetime {
class SettingShakeThreshold : public Screen {
public:
- SettingShakeThreshold(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
- ~SettingShakeThreshold() override;
+ 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;
- uint8_t optionsTotal;
+ Controllers::MotionController& motionController;
+ System::SystemTask& systemTask;
+
+
+
+
+ uint8_t taskCount;
lv_obj_t* cbOption[2];
+ lv_obj_t *positionArc, *calButton, *calLabel;
+ lv_task_t* refreshTask;
};
}
}