Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/components/motion/MotionController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ void MotionController::Update(int16_t x, int16_t y, int16_t z, uint32_t nbSteps)
int32_t deltaSteps = nbSteps - oldSteps;
if (deltaSteps > 0) {
currentTripSteps += deltaSteps;
locomotionDecay = 100; // 10 seconds x 10Hz
} else if (locomotionDecay > 0) {
locomotionDecay--;
}
SetSteps(Days::Today, nbSteps);
}
Expand Down
5 changes: 5 additions & 0 deletions src/components/motion/MotionController.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ namespace Pinetime {
return service;
}

bool Locomotion() const {
return (locomotionDecay != 0);
}

private:
Utility::CircularBuffer<uint32_t, stepHistorySize> nbSteps = {0};
uint32_t currentTripSteps = 0;
Expand Down Expand Up @@ -112,6 +116,7 @@ namespace Pinetime {

DeviceTypes deviceType = DeviceTypes::Unknown;
Pinetime::Controllers::MotionService* service = nullptr;
uint8_t locomotionDecay = 0;
};
}
}
12 changes: 12 additions & 0 deletions src/components/settings/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,17 @@ namespace Pinetime {
return settings.alwaysOnDisplay;
}

void SetMotionAutoBrightSetting(bool state) {
if (state != settings.motionAutoBright) {
settingsChanged = true;
}
settings.motionAutoBright = state;
}

bool GetMotionAutoBrightSetting() const {
return settings.motionAutoBright;
}

void SetShakeThreshold(uint16_t thresh) {
if (settings.shakeWakeThreshold != thresh) {
settings.shakeWakeThreshold = thresh;
Expand Down Expand Up @@ -362,6 +373,7 @@ namespace Pinetime {
uint32_t screenTimeOut = 15000;

bool alwaysOnDisplay = false;
bool motionAutoBright = false;

ClockType clockType = ClockType::H24;
WeatherFormat weatherFormat = WeatherFormat::Metric;
Expand Down
6 changes: 6 additions & 0 deletions src/displayapp/DisplayApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,9 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
notificationManager,
systemTask->nimble().alertService(),
motorController,
brightnessController,
motionController,
settingsController,
*systemTask,
Screens::Notifications::Modes::Normal);
break;
Expand All @@ -576,6 +579,9 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
notificationManager,
systemTask->nimble().alertService(),
motorController,
brightnessController,
motionController,
settingsController,
*systemTask,
Screens::Notifications::Modes::Preview);
break;
Expand Down
11 changes: 11 additions & 0 deletions src/displayapp/screens/Notifications.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include "displayapp/DisplayApp.h"
#include "components/ble/MusicService.h"
#include "components/ble/AlertNotificationService.h"
#include "components/brightness/BrightnessController.h"
#include "components/motion/MotionController.h"
#include "displayapp/screens/Symbols.h"
#include <algorithm>
#include "displayapp/InfiniTimeTheme.h"
Expand All @@ -14,12 +16,18 @@ Notifications::Notifications(DisplayApp* app,
Pinetime::Controllers::NotificationManager& notificationManager,
Pinetime::Controllers::AlertNotificationService& alertNotificationService,
Pinetime::Controllers::MotorController& motorController,
Pinetime::Controllers::BrightnessController& brightnessController,
Pinetime::Controllers::MotionController& motionController,
Pinetime::Controllers::Settings& settingsController,
System::SystemTask& systemTask,
Modes mode)
: app {app},
notificationManager {notificationManager},
alertNotificationService {alertNotificationService},
motorController {motorController},
brightnessController {brightnessController},
motionController {motionController},
settingsController {settingsController},
wakeLock(systemTask),
mode {mode} {

Expand Down Expand Up @@ -58,6 +66,9 @@ Notifications::Notifications(DisplayApp* app,
interacted = false;
}

if (settingsController.GetMotionAutoBrightSetting() && motionController.Locomotion()) {
brightnessController.Set(Pinetime::Controllers::BrightnessController::Levels::High);
}
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
}

Expand Down
9 changes: 9 additions & 0 deletions src/displayapp/screens/Notifications.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
#include "displayapp/screens/Screen.h"
#include "components/ble/NotificationManager.h"
#include "components/motor/MotorController.h"
#include "components/brightness/BrightnessController.h"
#include "components/motion/MotionController.h"
#include <components/settings/Settings.h>
#include "systemtask/SystemTask.h"
#include "systemtask/WakeLock.h"

Expand All @@ -25,6 +28,9 @@ namespace Pinetime {
Pinetime::Controllers::NotificationManager& notificationManager,
Pinetime::Controllers::AlertNotificationService& alertNotificationService,
Pinetime::Controllers::MotorController& motorController,
Pinetime::Controllers::BrightnessController& brightnessController,
Pinetime::Controllers::MotionController& motionController,
Pinetime::Controllers::Settings& settingsController,
System::SystemTask& systemTask,
Modes mode);
~Notifications() override;
Expand Down Expand Up @@ -74,6 +80,9 @@ namespace Pinetime {
Pinetime::Controllers::NotificationManager& notificationManager;
Pinetime::Controllers::AlertNotificationService& alertNotificationService;
Pinetime::Controllers::MotorController& motorController;
Pinetime::Controllers::BrightnessController& brightnessController;
Pinetime::Controllers::MotionController& motionController;
Pinetime::Controllers::Settings& settingsController;
System::WakeLock wakeLock;
Modes mode = Modes::Normal;
std::unique_ptr<NotificationItem> currentItem;
Expand Down
21 changes: 20 additions & 1 deletion src/displayapp/screens/settings/SettingDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ namespace {
screen->ToggleAlwaysOn();
}
}

void MotionAutoBrightEventHandler(lv_obj_t* obj, lv_event_t event) {
if (event == LV_EVENT_VALUE_CHANGED) {
auto* screen = static_cast<SettingDisplay*>(obj->user_data);
screen->ToggleMotionAutoBright();
}
}
}

constexpr std::array<uint16_t, 6> SettingDisplay::options;
Expand Down Expand Up @@ -64,11 +71,18 @@ SettingDisplay::SettingDisplay(Pinetime::Controllers::Settings& settingsControll
}

alwaysOnCheckbox = lv_checkbox_create(container1, nullptr);
lv_checkbox_set_text(alwaysOnCheckbox, "Always On");
lv_checkbox_set_text(alwaysOnCheckbox, "AOD");
lv_checkbox_set_checked(alwaysOnCheckbox, settingsController.GetAlwaysOnDisplaySetting());
lv_obj_add_state(alwaysOnCheckbox, LV_STATE_DEFAULT);
alwaysOnCheckbox->user_data = this;
lv_obj_set_event_cb(alwaysOnCheckbox, AlwaysOnEventHandler);

motionAutoBrightCheckbox = lv_checkbox_create(container1, nullptr);
lv_checkbox_set_text(motionAutoBrightCheckbox, "MAB");
lv_checkbox_set_checked(motionAutoBrightCheckbox, settingsController.GetMotionAutoBrightSetting());
lv_obj_add_state(motionAutoBrightCheckbox, LV_STATE_DEFAULT);
motionAutoBrightCheckbox->user_data = this;
lv_obj_set_event_cb(motionAutoBrightCheckbox, MotionAutoBrightEventHandler);
}

SettingDisplay::~SettingDisplay() {
Expand All @@ -81,6 +95,11 @@ void SettingDisplay::ToggleAlwaysOn() {
lv_checkbox_set_checked(alwaysOnCheckbox, settingsController.GetAlwaysOnDisplaySetting());
}

void SettingDisplay::ToggleMotionAutoBright() {
settingsController.SetMotionAutoBrightSetting(!settingsController.GetMotionAutoBrightSetting());
lv_checkbox_set_checked(motionAutoBrightCheckbox, settingsController.GetMotionAutoBrightSetting());
}

void SettingDisplay::UpdateSelected(lv_obj_t* object, lv_event_t event) {
if (event == LV_EVENT_CLICKED) {
for (unsigned int i = 0; i < options.size(); i++) {
Expand Down
2 changes: 2 additions & 0 deletions src/displayapp/screens/settings/SettingDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ namespace Pinetime {

void UpdateSelected(lv_obj_t* object, lv_event_t event);
void ToggleAlwaysOn();
void ToggleMotionAutoBright();

private:
static constexpr std::array<uint16_t, 6> options = {5000, 7000, 10000, 15000, 20000, 30000};

Controllers::Settings& settingsController;
lv_obj_t* cbOption[options.size()];
lv_obj_t* alwaysOnCheckbox;
lv_obj_t* motionAutoBrightCheckbox;
};
}
}
Expand Down
Loading