Fix crash upon leaving app.

Code formatting
This commit is contained in:
Tim Keller 2021-09-30 00:04:51 +00:00
parent d6b22645e3
commit 5c13200238
3 changed files with 28 additions and 34 deletions

View file

@ -48,6 +48,7 @@ bool MotionController::Should_ShakeWake(uint16_t thresh) {
bool wake = false;
auto diff = xTaskGetTickCount() - lastShakeTime;
lastShakeTime = xTaskGetTickCount();
/* Currently Polling at 10hz, If this ever goes faster scalar and EMA might need adjusting */
int32_t speed = std::abs(z + (y / 2) + (x / 4) - lastYForShake - lastZForShake) / diff * 100;
//(.2 * speed) + ((1 - .2) * accumulatedspeed);
// implemented without floats as .25Alpha

View file

@ -4,7 +4,6 @@
#include "displayapp/screens/Screen.h"
#include "displayapp/screens/Symbols.h"
using namespace Pinetime::Applications::Screens;
namespace {
@ -18,10 +17,7 @@ SettingShakeThreshold::SettingShakeThreshold(DisplayApp* app,
Controllers::Settings& settingsController,
Controllers::MotionController& motionController,
System::SystemTask& systemTask)
: Screen(app),
settingsController {settingsController},
motionController {motionController},
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");
@ -56,14 +52,15 @@ SettingShakeThreshold::SettingShakeThreshold(DisplayApp* app,
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() {
settingsController.SetShakeThreshold(lv_arc_get_value(positionArc));
if (taskCount > 0) {
lv_task_del(refreshTask);
lv_obj_clean(lv_scr_act());
}
settingsController.SaveSettings();
lv_obj_clean(lv_scr_act());
}
void SettingShakeThreshold::Refresh() {
@ -77,7 +74,6 @@ void SettingShakeThreshold::Refresh() {
taskCount = 0;
lv_task_del(refreshTask);
}
}
void SettingShakeThreshold::UpdateSelected(lv_obj_t* object, lv_event_t event) {
@ -87,7 +83,7 @@ void SettingShakeThreshold::UpdateSelected(lv_obj_t* object, lv_event_t event) {
if (object == calButton) {
if (taskCount == 0) {
lv_arc_set_value(positionArc, 0);
refreshTask = lv_task_create(RefreshTaskCallback, 100, LV_TASK_PRIO_MID, this);
refreshTask = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
lv_label_set_text(calLabel, "Shake!!!");
} else {

View file

@ -26,9 +26,6 @@ namespace Pinetime {
Controllers::MotionController& motionController;
System::SystemTask& systemTask;
uint8_t taskCount;
lv_obj_t* cbOption[2];
lv_obj_t *positionArc, *calButton, *calLabel;