Skip to content

Commit

Permalink
PR InfiniTimeOrg#681: Motion: keep screen awake while showing motion app
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit 4022680
Author: Reinhold Gschweicher <pyro4hell@gmail.com>
Date:   Mon Sep 20 21:33:21 2021 +0200

    Motion: keep screen awake while showing motion app

    Instead of having to manually periodically tap on the phone to keep the
    screen awake, just prevent the screen to go to sleep while showing the
    motion sensor graph.
  • Loading branch information
FintasticMan committed Dec 13, 2021
1 parent cbc158a commit 5863c4e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/displayapp/DisplayApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
ReturnApp(Apps::Launcher, FullRefreshDirections::Down, TouchEvents::None);
break;
case Apps::Motion:
currentScreen = std::make_unique<Screens::Motion>(this, motionController);
currentScreen = std::make_unique<Screens::Motion>(this, motionController, *systemTask);
break;
case Apps::Steps:
currentScreen = std::make_unique<Screens::Steps>(this, motionController, settingsController);
Expand Down
7 changes: 5 additions & 2 deletions src/displayapp/screens/Motion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

using namespace Pinetime::Applications::Screens;

Motion::Motion(Pinetime::Applications::DisplayApp* app, Controllers::MotionController& motionController)
: Screen(app), motionController {motionController} {
Motion::Motion(Pinetime::Applications::DisplayApp* app, Controllers::MotionController& motionController, System::SystemTask& systemTask)
: Screen(app), motionController {motionController}, systemTask {systemTask} {
chart = lv_chart_create(lv_scr_act(), NULL);
lv_obj_set_size(chart, 240, 240);
lv_obj_align(chart, NULL, LV_ALIGN_IN_TOP_MID, 0, 0);
Expand Down Expand Up @@ -37,12 +37,15 @@ Motion::Motion(Pinetime::Applications::DisplayApp* app, Controllers::MotionContr
lv_obj_align(labelStep, chart, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
lv_label_set_text(labelStep, "Steps ---");

systemTask.PushMessage(System::Messages::DisableSleeping);

taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
}

Motion::~Motion() {
lv_task_del(taskRefresh);
lv_obj_clean(lv_scr_act());
systemTask.PushMessage(System::Messages::EnableSleeping);
}

void Motion::Refresh() {
Expand Down
4 changes: 3 additions & 1 deletion src/displayapp/screens/Motion.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,22 @@
#include <lvgl/src/lv_core/lv_style.h>
#include <lvgl/src/lv_core/lv_obj.h>
#include <components/motion/MotionController.h>
#include "systemtask/SystemTask.h"

namespace Pinetime {
namespace Applications {
namespace Screens {

class Motion : public Screen {
public:
Motion(DisplayApp* app, Controllers::MotionController& motionController);
Motion(DisplayApp* app, Controllers::MotionController& motionController, System::SystemTask& systemTask);
~Motion() override;

void Refresh() override;

private:
Controllers::MotionController& motionController;
System::SystemTask& systemTask;
lv_obj_t* chart;
lv_chart_series_t* ser1;
lv_chart_series_t* ser2;
Expand Down

0 comments on commit 5863c4e

Please sign in to comment.