Merge pull request #497 from Riksu9000/refresh_rework

Rework Refresh
This commit is contained in:
JF002 2021-08-28 16:39:48 +02:00 committed by GitHub
commit 2870d3ae6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
72 changed files with 182 additions and 287 deletions

View File

@ -275,7 +275,7 @@ void DisplayApp::Refresh() {
} }
void DisplayApp::RunningState() { void DisplayApp::RunningState() {
if (!currentScreen->Refresh()) { if (!currentScreen->IsRunning()) {
LoadApp(returnToApp, returnDirection); LoadApp(returnToApp, returnDirection);
} }
lv_task_handler(); lv_task_handler();

View File

@ -34,12 +34,6 @@ ApplicationList::~ApplicationList() {
lv_obj_clean(lv_scr_act()); lv_obj_clean(lv_scr_act());
} }
bool ApplicationList::Refresh() {
if (running)
running = screens.Refresh();
return running;
}
bool ApplicationList::OnTouchEvent(Pinetime::Applications::TouchEvents event) { bool ApplicationList::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
return screens.OnTouchEvent(event); return screens.OnTouchEvent(event);
} }

View File

@ -18,7 +18,6 @@ namespace Pinetime {
Pinetime::Controllers::Battery& batteryController, Pinetime::Controllers::Battery& batteryController,
Controllers::DateTime& dateTimeController); Controllers::DateTime& dateTimeController);
~ApplicationList() override; ~ApplicationList() override;
bool Refresh() override;
bool OnTouchEvent(TouchEvents event) override; bool OnTouchEvent(TouchEvents event) override;
private: private:

View File

@ -4,11 +4,6 @@
using namespace Pinetime::Applications::Screens; using namespace Pinetime::Applications::Screens;
static void lv_update_task(struct _lv_task_t* task) {
auto user_data = static_cast<BatteryInfo*>(task->user_data);
user_data->UpdateScreen();
}
BatteryInfo::BatteryInfo(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Battery& batteryController) BatteryInfo::BatteryInfo(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Battery& batteryController)
: Screen(app), batteryController {batteryController} { : Screen(app), batteryController {batteryController} {
@ -49,16 +44,16 @@ BatteryInfo::BatteryInfo(Pinetime::Applications::DisplayApp* app, Pinetime::Cont
lv_obj_set_pos(backgroundLabel, 0, 0); lv_obj_set_pos(backgroundLabel, 0, 0);
lv_label_set_text_static(backgroundLabel, ""); lv_label_set_text_static(backgroundLabel, "");
taskUpdate = lv_task_create(lv_update_task, 5000, LV_TASK_PRIO_LOW, this); taskRefresh = lv_task_create(RefreshTaskCallback, 5000, LV_TASK_PRIO_MID, this);
UpdateScreen(); Refresh();
} }
BatteryInfo::~BatteryInfo() { BatteryInfo::~BatteryInfo() {
lv_task_del(taskUpdate); lv_task_del(taskRefresh);
lv_obj_clean(lv_scr_act()); lv_obj_clean(lv_scr_act());
} }
void BatteryInfo::UpdateScreen() { void BatteryInfo::Refresh() {
batteryController.Update(); batteryController.Update();
@ -85,7 +80,3 @@ void BatteryInfo::UpdateScreen() {
lv_label_set_text_fmt(voltage, "%1i.%02i volts", batteryVoltage / 1000, batteryVoltage % 1000 / 10); lv_label_set_text_fmt(voltage, "%1i.%02i volts", batteryVoltage / 1000, batteryVoltage % 1000 / 10);
lv_bar_set_value(charging_bar, batteryPercent, LV_ANIM_ON); lv_bar_set_value(charging_bar, batteryPercent, LV_ANIM_ON);
} }
bool BatteryInfo::Refresh() {
return running;
}

View File

@ -19,9 +19,7 @@ namespace Pinetime {
BatteryInfo(DisplayApp* app, Pinetime::Controllers::Battery& batteryController); BatteryInfo(DisplayApp* app, Pinetime::Controllers::Battery& batteryController);
~BatteryInfo() override; ~BatteryInfo() override;
bool Refresh() override; void Refresh() override;
void UpdateScreen();
private: private:
Pinetime::Controllers::Battery& batteryController; Pinetime::Controllers::Battery& batteryController;
@ -31,7 +29,7 @@ namespace Pinetime {
lv_obj_t* charging_bar; lv_obj_t* charging_bar;
lv_obj_t* status; lv_obj_t* status;
lv_task_t* taskUpdate; lv_task_t* taskRefresh;
uint8_t batteryPercent = 0; uint8_t batteryPercent = 0;
uint16_t batteryVoltage = 0; uint16_t batteryVoltage = 0;

View File

@ -30,10 +30,6 @@ Brightness::~Brightness() {
lv_obj_clean(lv_scr_act()); lv_obj_clean(lv_scr_act());
} }
bool Brightness::Refresh() {
return running;
}
const char* Brightness::LevelToString(Pinetime::Controllers::BrightnessController::Levels level) { const char* Brightness::LevelToString(Pinetime::Controllers::BrightnessController::Levels level) {
switch (level) { switch (level) {
case Pinetime::Controllers::BrightnessController::Levels::Off: case Pinetime::Controllers::BrightnessController::Levels::Off:

View File

@ -12,7 +12,6 @@ namespace Pinetime {
public: public:
Brightness(DisplayApp* app, Controllers::BrightnessController& brightness); Brightness(DisplayApp* app, Controllers::BrightnessController& brightness);
~Brightness() override; ~Brightness() override;
bool Refresh() override;
bool OnTouchEvent(TouchEvents event) override; bool OnTouchEvent(TouchEvents event) override;

View File

@ -50,11 +50,6 @@ Clock::~Clock() {
lv_obj_clean(lv_scr_act()); lv_obj_clean(lv_scr_act());
} }
bool Clock::Refresh() {
screen->Refresh();
return running;
}
bool Clock::OnTouchEvent(Pinetime::Applications::TouchEvents event) { bool Clock::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
return screen->OnTouchEvent(event); return screen->OnTouchEvent(event);
} }

View File

@ -31,8 +31,6 @@ namespace Pinetime {
Controllers::MotionController& motionController); Controllers::MotionController& motionController);
~Clock() override; ~Clock() override;
bool Refresh() override;
bool OnTouchEvent(TouchEvents event) override; bool OnTouchEvent(TouchEvents event) override;
private: private:

View File

@ -30,14 +30,16 @@ FirmwareUpdate::FirmwareUpdate(Pinetime::Applications::DisplayApp* app, Pinetime
lv_label_set_text(percentLabel, "Waiting..."); lv_label_set_text(percentLabel, "Waiting...");
lv_obj_set_auto_realign(percentLabel, true); lv_obj_set_auto_realign(percentLabel, true);
lv_obj_align(percentLabel, bar1, LV_ALIGN_OUT_TOP_MID, 0, 60); lv_obj_align(percentLabel, bar1, LV_ALIGN_OUT_TOP_MID, 0, 60);
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
startTime = xTaskGetTickCount(); startTime = xTaskGetTickCount();
} }
FirmwareUpdate::~FirmwareUpdate() { FirmwareUpdate::~FirmwareUpdate() {
lv_task_del(taskRefresh);
lv_obj_clean(lv_scr_act()); lv_obj_clean(lv_scr_act());
} }
bool FirmwareUpdate::Refresh() { void FirmwareUpdate::Refresh() {
switch (bleController.State()) { switch (bleController.State()) {
default: default:
case Pinetime::Controllers::Ble::FirmwareUpdateStates::Idle: case Pinetime::Controllers::Ble::FirmwareUpdateStates::Idle:
@ -73,7 +75,6 @@ bool FirmwareUpdate::Refresh() {
} }
break; break;
} }
return running;
} }
void FirmwareUpdate::DisplayProgression() const { void FirmwareUpdate::DisplayProgression() const {

View File

@ -16,7 +16,7 @@ namespace Pinetime {
FirmwareUpdate(DisplayApp* app, Pinetime::Controllers::Ble& bleController); FirmwareUpdate(DisplayApp* app, Pinetime::Controllers::Ble& bleController);
~FirmwareUpdate() override; ~FirmwareUpdate() override;
bool Refresh() override; void Refresh() override;
private: private:
enum class States { Idle, Running, Validated, Error }; enum class States { Idle, Running, Validated, Error };
@ -36,6 +36,7 @@ namespace Pinetime {
void UpdateError(); void UpdateError();
lv_task_t* taskRefresh;
TickType_t startTime; TickType_t startTime;
}; };
} }

View File

@ -63,10 +63,6 @@ FirmwareValidation::~FirmwareValidation() {
lv_obj_clean(lv_scr_act()); lv_obj_clean(lv_scr_act());
} }
bool FirmwareValidation::Refresh() {
return running;
}
void FirmwareValidation::OnButtonEvent(lv_obj_t* object, lv_event_t event) { void FirmwareValidation::OnButtonEvent(lv_obj_t* object, lv_event_t event) {
if (object == buttonValidate && event == LV_EVENT_CLICKED) { if (object == buttonValidate && event == LV_EVENT_CLICKED) {
validator.Validate(); validator.Validate();

View File

@ -16,8 +16,6 @@ namespace Pinetime {
FirmwareValidation(DisplayApp* app, Pinetime::Controllers::FirmwareValidator& validator); FirmwareValidation(DisplayApp* app, Pinetime::Controllers::FirmwareValidator& validator);
~FirmwareValidation() override; ~FirmwareValidation() override;
bool Refresh() override;
void OnButtonEvent(lv_obj_t* object, lv_event_t event); void OnButtonEvent(lv_obj_t* object, lv_event_t event);
private: private:

View File

@ -65,10 +65,6 @@ void FlashLight::OnClickEvent(lv_obj_t* obj, lv_event_t event) {
} }
} }
bool FlashLight::Refresh() {
return running;
}
bool FlashLight::OnTouchEvent(Pinetime::Applications::TouchEvents event) { bool FlashLight::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
return false; return false;
} }

View File

@ -16,8 +16,6 @@ namespace Pinetime {
FlashLight(DisplayApp* app, System::SystemTask& systemTask, Controllers::BrightnessController& brightness); FlashLight(DisplayApp* app, System::SystemTask& systemTask, Controllers::BrightnessController& brightness);
~FlashLight() override; ~FlashLight() override;
bool Refresh() override;
bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override; bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override;
void OnClickEvent(lv_obj_t* obj, lv_event_t event); void OnClickEvent(lv_obj_t* obj, lv_event_t event);

View File

@ -64,14 +64,17 @@ HeartRate::HeartRate(Pinetime::Applications::DisplayApp* app,
UpdateStartStopButton(isHrRunning); UpdateStartStopButton(isHrRunning);
if (isHrRunning) if (isHrRunning)
systemTask.PushMessage(Pinetime::System::Messages::DisableSleeping); systemTask.PushMessage(Pinetime::System::Messages::DisableSleeping);
taskRefresh = lv_task_create(RefreshTaskCallback, 100, LV_TASK_PRIO_MID, this);
} }
HeartRate::~HeartRate() { HeartRate::~HeartRate() {
lv_task_del(taskRefresh);
lv_obj_clean(lv_scr_act()); lv_obj_clean(lv_scr_act());
systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping); systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
} }
bool HeartRate::Refresh() { void HeartRate::Refresh() {
auto state = heartRateController.State(); auto state = heartRateController.State();
switch (state) { switch (state) {
@ -86,8 +89,6 @@ bool HeartRate::Refresh() {
lv_label_set_text(label_status, ToString(state)); lv_label_set_text(label_status, ToString(state));
lv_obj_align(label_status, label_hr, LV_ALIGN_OUT_BOTTOM_MID, 0, 10); lv_obj_align(label_status, label_hr, LV_ALIGN_OUT_BOTTOM_MID, 0, 10);
return running;
} }
void HeartRate::OnStartStopEvent(lv_event_t event) { void HeartRate::OnStartStopEvent(lv_event_t event) {

View File

@ -20,7 +20,7 @@ namespace Pinetime {
HeartRate(DisplayApp* app, Controllers::HeartRateController& HeartRateController, System::SystemTask& systemTask); HeartRate(DisplayApp* app, Controllers::HeartRateController& HeartRateController, System::SystemTask& systemTask);
~HeartRate() override; ~HeartRate() override;
bool Refresh() override; void Refresh() override;
void OnStartStopEvent(lv_event_t event); void OnStartStopEvent(lv_event_t event);
@ -33,6 +33,8 @@ namespace Pinetime {
lv_obj_t* label_status; lv_obj_t* label_status;
lv_obj_t* btn_startStop; lv_obj_t* btn_startStop;
lv_obj_t* label_startStop; lv_obj_t* label_startStop;
lv_task_t* taskRefresh;
}; };
} }
} }

View File

@ -12,10 +12,6 @@ InfiniPaint::~InfiniPaint() {
lv_obj_clean(lv_scr_act()); lv_obj_clean(lv_scr_act());
} }
bool InfiniPaint::Refresh() {
return running;
}
bool InfiniPaint::OnTouchEvent(Pinetime::Applications::TouchEvents event) { bool InfiniPaint::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
switch (event) { switch (event) {
case Pinetime::Applications::TouchEvents::LongTap: case Pinetime::Applications::TouchEvents::LongTap:

View File

@ -17,8 +17,6 @@ namespace Pinetime {
~InfiniPaint() override; ~InfiniPaint() override;
bool Refresh() override;
bool OnTouchEvent(TouchEvents event) override; bool OnTouchEvent(TouchEvents event) override;
bool OnTouchEvent(uint16_t x, uint16_t y) override; bool OnTouchEvent(uint16_t x, uint16_t y) override;

View File

@ -36,7 +36,3 @@ Label::Label(uint8_t screenID, uint8_t numScreens, Pinetime::Applications::Displ
Label::~Label() { Label::~Label() {
lv_obj_clean(lv_scr_act()); lv_obj_clean(lv_scr_act());
} }
bool Label::Refresh() {
return running;
}

View File

@ -12,8 +12,6 @@ namespace Pinetime {
Label(uint8_t screenID, uint8_t numScreens, DisplayApp* app, lv_obj_t* labelText); Label(uint8_t screenID, uint8_t numScreens, DisplayApp* app, lv_obj_t* labelText);
~Label() override; ~Label() override;
bool Refresh() override;
private: private:
lv_obj_t* labelText = nullptr; lv_obj_t* labelText = nullptr;
lv_point_t pageIndicatorBasePoints[2]; lv_point_t pageIndicatorBasePoints[2];

View File

@ -98,11 +98,6 @@ List::~List() {
lv_obj_clean(lv_scr_act()); lv_obj_clean(lv_scr_act());
} }
bool List::Refresh() {
return running;
}
void List::OnButtonEvent(lv_obj_t* object, lv_event_t event) { void List::OnButtonEvent(lv_obj_t* object, lv_event_t event) {
if (event == LV_EVENT_CLICKED) { if (event == LV_EVENT_CLICKED) {
for (int i = 0; i < MAXLISTITEMS; i++) { for (int i = 0; i < MAXLISTITEMS; i++) {

View File

@ -27,8 +27,6 @@ namespace Pinetime {
std::array<Applications, MAXLISTITEMS>& applications); std::array<Applications, MAXLISTITEMS>& applications);
~List() override; ~List() override;
bool Refresh() override;
void OnButtonEvent(lv_obj_t* object, lv_event_t event); void OnButtonEvent(lv_obj_t* object, lv_event_t event);
private: private:

View File

@ -20,17 +20,17 @@ Meter::Meter(Pinetime::Applications::DisplayApp* app) : Screen(app) {
lv_obj_set_size(lmeter, 200, 200); lv_obj_set_size(lmeter, 200, 200);
lv_obj_align(lmeter, nullptr, LV_ALIGN_CENTER, 0, 0); lv_obj_align(lmeter, nullptr, LV_ALIGN_CENTER, 0, 0);
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
} }
Meter::~Meter() { Meter::~Meter() {
lv_task_del(taskRefresh);
lv_obj_clean(lv_scr_act()); lv_obj_clean(lv_scr_act());
} }
bool Meter::Refresh() { void Meter::Refresh() {
lv_linemeter_set_value(lmeter, value++); /*Set the current value*/ lv_linemeter_set_value(lmeter, value++); /*Set the current value*/
if (value >= 60) if (value >= 60)
value = 0; value = 0;
return running;
} }

View File

@ -14,13 +14,15 @@ namespace Pinetime {
Meter(DisplayApp* app); Meter(DisplayApp* app);
~Meter() override; ~Meter() override;
bool Refresh() override; void Refresh() override;
private: private:
lv_style_t style_lmeter; lv_style_t style_lmeter;
lv_obj_t* lmeter; lv_obj_t* lmeter;
uint32_t value = 0; uint32_t value = 0;
lv_task_t* taskRefresh;
}; };
} }
} }

View File

@ -66,14 +66,17 @@ Metronome::Metronome(DisplayApp* app, Controllers::MotorController& motorControl
lv_obj_set_size(playPause, 115, 50); lv_obj_set_size(playPause, 115, 50);
lv_obj_align(playPause, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0); lv_obj_align(playPause, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
lv_obj_set_style_local_value_str(playPause, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Symbols::play); lv_obj_set_style_local_value_str(playPause, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Symbols::play);
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
} }
Metronome::~Metronome() { Metronome::~Metronome() {
lv_task_del(taskRefresh);
systemTask.PushMessage(System::Messages::EnableSleeping); systemTask.PushMessage(System::Messages::EnableSleeping);
lv_obj_clean(lv_scr_act()); lv_obj_clean(lv_scr_act());
} }
bool Metronome::Refresh() { void Metronome::Refresh() {
if (metronomeStarted) { if (metronomeStarted) {
if (xTaskGetTickCount() - startTime > 60 * configTICK_RATE_HZ / bpm) { if (xTaskGetTickCount() - startTime > 60 * configTICK_RATE_HZ / bpm) {
startTime += 60 * configTICK_RATE_HZ / bpm; startTime += 60 * configTICK_RATE_HZ / bpm;
@ -86,7 +89,6 @@ bool Metronome::Refresh() {
} }
} }
} }
return running;
} }
void Metronome::OnEvent(lv_obj_t* obj, lv_event_t event) { void Metronome::OnEvent(lv_obj_t* obj, lv_event_t event) {

View File

@ -11,7 +11,7 @@ namespace Pinetime {
public: public:
Metronome(DisplayApp* app, Controllers::MotorController& motorController, System::SystemTask& systemTask); Metronome(DisplayApp* app, Controllers::MotorController& motorController, System::SystemTask& systemTask);
~Metronome() override; ~Metronome() override;
bool Refresh() override; void Refresh() override;
void OnEvent(lv_obj_t* obj, lv_event_t event); void OnEvent(lv_obj_t* obj, lv_event_t event);
private: private:
@ -28,6 +28,8 @@ namespace Pinetime {
lv_obj_t *bpmArc, *bpmTap, *bpmValue; lv_obj_t *bpmArc, *bpmTap, *bpmValue;
lv_obj_t *bpbDropdown, *currentBpbText; lv_obj_t *bpbDropdown, *currentBpbText;
lv_obj_t *playPause; lv_obj_t *playPause;
lv_task_t* taskRefresh;
}; };
} }
} }

View File

@ -36,13 +36,16 @@ Motion::Motion(Pinetime::Applications::DisplayApp* app, Controllers::MotionContr
labelStep = lv_label_create(lv_scr_act(), NULL); labelStep = lv_label_create(lv_scr_act(), NULL);
lv_obj_align(labelStep, chart, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0); lv_obj_align(labelStep, chart, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
lv_label_set_text(labelStep, "Steps ---"); lv_label_set_text(labelStep, "Steps ---");
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
} }
Motion::~Motion() { Motion::~Motion() {
lv_task_del(taskRefresh);
lv_obj_clean(lv_scr_act()); lv_obj_clean(lv_scr_act());
} }
bool Motion::Refresh() { void Motion::Refresh() {
lv_chart_set_next(chart, ser1, motionController.X()); lv_chart_set_next(chart, ser1, motionController.X());
lv_chart_set_next(chart, ser2, motionController.Y()); lv_chart_set_next(chart, ser2, motionController.Y());
lv_chart_set_next(chart, ser3, motionController.Z()); lv_chart_set_next(chart, ser3, motionController.Z());
@ -55,6 +58,4 @@ bool Motion::Refresh() {
motionController.Y() / 0x10, motionController.Y() / 0x10,
motionController.Z() / 0x10); motionController.Z() / 0x10);
lv_obj_align(label, NULL, LV_ALIGN_IN_TOP_MID, 0, 10); lv_obj_align(label, NULL, LV_ALIGN_IN_TOP_MID, 0, 10);
return running;
} }

View File

@ -17,7 +17,7 @@ namespace Pinetime {
Motion(DisplayApp* app, Controllers::MotionController& motionController); Motion(DisplayApp* app, Controllers::MotionController& motionController);
~Motion() override; ~Motion() override;
bool Refresh() override; void Refresh() override;
private: private:
Controllers::MotionController& motionController; Controllers::MotionController& motionController;
@ -28,6 +28,7 @@ namespace Pinetime {
lv_obj_t* label; lv_obj_t* label;
lv_obj_t* labelStep; lv_obj_t* labelStep;
lv_task_t* taskRefresh;
}; };
} }
} }

View File

@ -139,14 +139,17 @@ Music::Music(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Mus
frameB = false; frameB = false;
musicService.event(Controllers::MusicService::EVENT_MUSIC_OPEN); musicService.event(Controllers::MusicService::EVENT_MUSIC_OPEN);
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
} }
Music::~Music() { Music::~Music() {
lv_task_del(taskRefresh);
lv_style_reset(&btn_style); lv_style_reset(&btn_style);
lv_obj_clean(lv_scr_act()); lv_obj_clean(lv_scr_act());
} }
bool Music::Refresh() { void Music::Refresh() {
if (artist != musicService.getArtist()) { if (artist != musicService.getArtist()) {
artist = musicService.getArtist(); artist = musicService.getArtist();
currentLength = 0; currentLength = 0;
@ -210,8 +213,6 @@ bool Music::Refresh() {
} else { } else {
lv_label_set_text(txtPlayPause, Symbols::play); lv_label_set_text(txtPlayPause, Symbols::play);
} }
return running;
} }
void Music::UpdateLength() { void Music::UpdateLength() {

View File

@ -35,7 +35,7 @@ namespace Pinetime {
~Music() override; ~Music() override;
bool Refresh() override; void Refresh() override;
void OnObjectEvent(lv_obj_t* obj, lv_event_t event); void OnObjectEvent(lv_obj_t* obj, lv_event_t event);
@ -79,6 +79,8 @@ namespace Pinetime {
bool playing; bool playing;
lv_task_t* taskRefresh;
/** Watchapp */ /** Watchapp */
}; };
} }

View File

@ -161,13 +161,16 @@ Navigation::Navigation(Pinetime::Applications::DisplayApp* app, Pinetime::Contro
lv_bar_set_anim_time(barProgress, 500); lv_bar_set_anim_time(barProgress, 500);
lv_bar_set_range(barProgress, 0, 100); lv_bar_set_range(barProgress, 0, 100);
lv_bar_set_value(barProgress, 0, LV_ANIM_OFF); lv_bar_set_value(barProgress, 0, LV_ANIM_OFF);
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
} }
Navigation::~Navigation() { Navigation::~Navigation() {
lv_task_del(taskRefresh);
lv_obj_clean(lv_scr_act()); lv_obj_clean(lv_scr_act());
} }
bool Navigation::Refresh() { void Navigation::Refresh() {
if (flag != navService.getFlag()) { if (flag != navService.getFlag()) {
flag = navService.getFlag(); flag = navService.getFlag();
lv_label_set_text(imgFlag, iconForName(flag)); lv_label_set_text(imgFlag, iconForName(flag));
@ -192,8 +195,4 @@ bool Navigation::Refresh() {
lv_obj_set_style_local_bg_color(barProgress, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_ORANGE); lv_obj_set_style_local_bg_color(barProgress, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_ORANGE);
} }
} }
return running;
} }

View File

@ -35,7 +35,7 @@ namespace Pinetime {
Navigation(DisplayApp* app, Pinetime::Controllers::NavigationService& nav); Navigation(DisplayApp* app, Pinetime::Controllers::NavigationService& nav);
~Navigation() override; ~Navigation() override;
bool Refresh() override; void Refresh() override;
private: private:
lv_obj_t* imgFlag; lv_obj_t* imgFlag;
@ -49,6 +49,8 @@ namespace Pinetime {
std::string narrative; std::string narrative;
std::string manDist; std::string manDist;
int progress; int progress;
lv_task_t* taskRefresh;
}; };
} }
} }

View File

@ -52,15 +52,18 @@ Notifications::Notifications(DisplayApp* app,
timeoutTickCountEnd = timeoutTickCountStart + (5 * 1024); timeoutTickCountEnd = timeoutTickCountStart + (5 * 1024);
} }
} }
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
} }
Notifications::~Notifications() { Notifications::~Notifications() {
lv_task_del(taskRefresh);
// make sure we stop any vibrations before exiting // make sure we stop any vibrations before exiting
Controllers::MotorController::StopRinging(); Controllers::MotorController::StopRinging();
lv_obj_clean(lv_scr_act()); lv_obj_clean(lv_scr_act());
} }
bool Notifications::Refresh() { void Notifications::Refresh() {
if (mode == Modes::Preview && timeoutLine != nullptr) { if (mode == Modes::Preview && timeoutLine != nullptr) {
auto tick = xTaskGetTickCount(); auto tick = xTaskGetTickCount();
int32_t pos = 240 - ((tick - timeoutTickCountStart) / ((timeoutTickCountEnd - timeoutTickCountStart) / 240)); int32_t pos = 240 - ((tick - timeoutTickCountStart) / ((timeoutTickCountEnd - timeoutTickCountStart) / 240));
@ -70,7 +73,7 @@ bool Notifications::Refresh() {
timeoutLinePoints[1].x = pos; timeoutLinePoints[1].x = pos;
lv_line_set_points(timeoutLine, timeoutLinePoints, 2); lv_line_set_points(timeoutLine, timeoutLinePoints, 2);
} }
return running && currentItem->IsRunning(); running = currentItem->IsRunning();
} }
bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) { bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {

View File

@ -24,7 +24,7 @@ namespace Pinetime {
Modes mode); Modes mode);
~Notifications() override; ~Notifications() override;
bool Refresh() override; void Refresh() override;
bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override; bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override;
class NotificationItem { class NotificationItem {
@ -79,6 +79,8 @@ namespace Pinetime {
lv_obj_t* timeoutLine = nullptr; lv_obj_t* timeoutLine = nullptr;
uint32_t timeoutTickCountStart; uint32_t timeoutTickCountStart;
uint32_t timeoutTickCountEnd; uint32_t timeoutTickCountEnd;
lv_task_t* taskRefresh;
}; };
} }
} }

View File

@ -27,13 +27,16 @@ Paddle::Paddle(Pinetime::Applications::DisplayApp* app, Pinetime::Components::Li
lv_obj_set_style_local_bg_color(ball, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); lv_obj_set_style_local_bg_color(ball, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
lv_obj_set_style_local_radius(ball, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE); lv_obj_set_style_local_radius(ball, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
lv_obj_set_size(ball, ballSize, ballSize); lv_obj_set_size(ball, ballSize, ballSize);
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
} }
Paddle::~Paddle() { Paddle::~Paddle() {
lv_task_del(taskRefresh);
lv_obj_clean(lv_scr_act()); lv_obj_clean(lv_scr_act());
} }
bool Paddle::Refresh() { void Paddle::Refresh() {
ballX += dx; ballX += dx;
ballY += dy; ballY += dy;
@ -65,7 +68,6 @@ bool Paddle::Refresh() {
} }
} }
lv_label_set_text_fmt(points, "%04d", score); lv_label_set_text_fmt(points, "%04d", score);
return running;
} }
bool Paddle::OnTouchEvent(Pinetime::Applications::TouchEvents event) { bool Paddle::OnTouchEvent(Pinetime::Applications::TouchEvents event) {

View File

@ -16,7 +16,7 @@ namespace Pinetime {
Paddle(DisplayApp* app, Pinetime::Components::LittleVgl& lvgl); Paddle(DisplayApp* app, Pinetime::Components::LittleVgl& lvgl);
~Paddle() override; ~Paddle() override;
bool Refresh() override; void Refresh() override;
bool OnTouchEvent(TouchEvents event) override; bool OnTouchEvent(TouchEvents event) override;
bool OnTouchEvent(uint16_t x, uint16_t y) override; bool OnTouchEvent(uint16_t x, uint16_t y) override;
@ -40,6 +40,8 @@ namespace Pinetime {
lv_obj_t* paddle; lv_obj_t* paddle;
lv_obj_t* ball; lv_obj_t* ball;
lv_obj_t* background; lv_obj_t* background;
lv_task_t* taskRefresh;
}; };
} }
} }

View File

@ -193,13 +193,17 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
lv_obj_set_size(backgroundLabel, 240, 240); lv_obj_set_size(backgroundLabel, 240, 240);
lv_obj_set_pos(backgroundLabel, 0, 0); lv_obj_set_pos(backgroundLabel, 0, 0);
lv_label_set_text(backgroundLabel, ""); lv_label_set_text(backgroundLabel, "");
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
Refresh();
} }
PineTimeStyle::~PineTimeStyle() { PineTimeStyle::~PineTimeStyle() {
lv_task_del(taskRefresh);
lv_obj_clean(lv_scr_act()); lv_obj_clean(lv_scr_act());
} }
bool PineTimeStyle::Refresh() { void PineTimeStyle::Refresh() {
batteryPercentRemaining = batteryController.PercentRemaining(); batteryPercentRemaining = batteryController.PercentRemaining();
if (batteryPercentRemaining.IsUpdated()) { if (batteryPercentRemaining.IsUpdated()) {
auto batteryPercent = batteryPercentRemaining.Get(); auto batteryPercent = batteryPercentRemaining.Get();
@ -303,6 +307,4 @@ bool PineTimeStyle::Refresh() {
lv_obj_set_style_local_scale_grad_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); lv_obj_set_style_local_scale_grad_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
} }
} }
return running;
} }

View File

@ -30,7 +30,7 @@ namespace Pinetime {
Controllers::MotionController& motionController); Controllers::MotionController& motionController);
~PineTimeStyle() override; ~PineTimeStyle() override;
bool Refresh() override; void Refresh() override;
private: private:
char displayedChar[5]; char displayedChar[5];
@ -75,6 +75,8 @@ namespace Pinetime {
Controllers::NotificationManager& notificatioManager; Controllers::NotificationManager& notificatioManager;
Controllers::Settings& settingsController; Controllers::Settings& settingsController;
Controllers::MotionController& motionController; Controllers::MotionController& motionController;
lv_task_t* taskRefresh;
}; };
} }
} }

View File

@ -1,2 +1,6 @@
#include "Screen.h" #include "Screen.h"
using namespace Pinetime::Applications::Screens; using namespace Pinetime::Applications::Screens;
void Screen::RefreshTaskCallback(lv_task_t* task) {
static_cast<Screen*>(task->user_data)->Refresh();
}

View File

@ -2,6 +2,7 @@
#include <cstdint> #include <cstdint>
#include "../TouchEvents.h" #include "../TouchEvents.h"
#include <lvgl/lvgl.h>
namespace Pinetime { namespace Pinetime {
namespace Applications { namespace Applications {
@ -38,25 +39,20 @@ namespace Pinetime {
}; };
class Screen { class Screen {
private:
virtual void Refresh() {
}
public: public:
explicit Screen(DisplayApp* app) : app {app} { explicit Screen(DisplayApp* app) : app {app} {
} }
virtual ~Screen() = default; virtual ~Screen() = default;
/** static void RefreshTaskCallback(lv_task_t* task);
* Most of the time, apps only react to events (touch events, for example).
* In this case you don't need to do anything in this method. bool IsRunning() const {
* return running;
* For example, InfiniPaint does nothing in Refresh(). }
* But, if you want to update your display periodically, draw an animation...
* you cannot do it in a touch event handler because these handlers are not
* called if the user does not touch the screen.
*
* That's why Refresh() is there: update the display periodically.
*
* @return false if the app can be closed, true if it must continue to run
**/
virtual bool Refresh() = 0;
/** @return false if the button hasn't been handled by the app, true if it has been handled */ /** @return false if the button hasn't been handled by the app, true if it has been handled */
virtual bool OnButtonPushed() { virtual bool OnButtonPushed() {

View File

@ -30,11 +30,6 @@ namespace Pinetime {
lv_obj_clean(lv_scr_act()); lv_obj_clean(lv_scr_act());
} }
bool Refresh() override {
running = current->Refresh();
return running;
}
bool OnTouchEvent(TouchEvents event) override { bool OnTouchEvent(TouchEvents event) override {
if (mode == ScreenListModes::UpDown) { if (mode == ScreenListModes::UpDown) {

View File

@ -47,20 +47,20 @@ Steps::Steps(Pinetime::Applications::DisplayApp* app,
lv_obj_set_size(backgroundLabel, 240, 240); lv_obj_set_size(backgroundLabel, 240, 240);
lv_obj_set_pos(backgroundLabel, 0, 0); lv_obj_set_pos(backgroundLabel, 0, 0);
lv_label_set_text_static(backgroundLabel, ""); lv_label_set_text_static(backgroundLabel, "");
taskRefresh = lv_task_create(RefreshTaskCallback, 100, LV_TASK_PRIO_MID, this);
} }
Steps::~Steps() { Steps::~Steps() {
lv_task_del(taskRefresh);
lv_obj_clean(lv_scr_act()); lv_obj_clean(lv_scr_act());
} }
bool Steps::Refresh() { void Steps::Refresh() {
stepsCount = motionController.NbSteps(); stepsCount = motionController.NbSteps();
lv_label_set_text_fmt(lSteps, "%li", stepsCount); lv_label_set_text_fmt(lSteps, "%li", stepsCount);
lv_obj_align(lSteps, nullptr, LV_ALIGN_CENTER, 0, -20); lv_obj_align(lSteps, nullptr, LV_ALIGN_CENTER, 0, -20);
lv_arc_set_value(stepsArc, int16_t(500 * stepsCount / settingsController.GetStepsGoal())); lv_arc_set_value(stepsArc, int16_t(500 * stepsCount / settingsController.GetStepsGoal()));
return running;
} }

View File

@ -16,23 +16,22 @@ namespace Pinetime {
class Steps : public Screen { class Steps : public Screen {
public: public:
Steps(DisplayApp* app, Controllers::MotionController& motionController, Controllers::Settings &settingsController); Steps(DisplayApp* app, Controllers::MotionController& motionController, Controllers::Settings& settingsController);
~Steps() override; ~Steps() override;
bool Refresh() override; void Refresh() override;
private: private:
Controllers::MotionController& motionController; Controllers::MotionController& motionController;
Controllers::Settings& settingsController; Controllers::Settings& settingsController;
lv_obj_t * lSteps; lv_obj_t* lSteps;
lv_obj_t * lStepsIcon; lv_obj_t* lStepsIcon;
lv_obj_t * stepsArc; lv_obj_t* stepsArc;
uint32_t stepsCount; uint32_t stepsCount;
lv_task_t* taskRefresh;
}; };
} }
} }

View File

@ -48,7 +48,6 @@ static void stop_lap_event_handler(lv_obj_t* obj, lv_event_t event) {
StopWatch::StopWatch(DisplayApp* app, System::SystemTask& systemTask) StopWatch::StopWatch(DisplayApp* app, System::SystemTask& systemTask)
: Screen(app), : Screen(app),
systemTask {systemTask}, systemTask {systemTask},
running {true},
currentState {States::Init}, currentState {States::Init},
startTime {}, startTime {},
oldTimeElapsed {}, oldTimeElapsed {},
@ -101,9 +100,12 @@ StopWatch::StopWatch(DisplayApp* app, System::SystemTask& systemTask)
lv_obj_set_style_local_text_color(lapTwoText, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_YELLOW); lv_obj_set_style_local_text_color(lapTwoText, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_YELLOW);
lv_obj_align(lapTwoText, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 50, 55); lv_obj_align(lapTwoText, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 50, 55);
lv_label_set_text(lapTwoText, ""); lv_label_set_text(lapTwoText, "");
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
} }
StopWatch::~StopWatch() { StopWatch::~StopWatch() {
lv_task_del(taskRefresh);
systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping); systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
lv_obj_clean(lv_scr_act()); lv_obj_clean(lv_scr_act());
} }
@ -149,7 +151,7 @@ void StopWatch::pause() {
systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping); systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
} }
bool StopWatch::Refresh() { void StopWatch::Refresh() {
if (currentState == States::Running) { if (currentState == States::Running) {
timeElapsed = calculateDelta(startTime, xTaskGetTickCount()); timeElapsed = calculateDelta(startTime, xTaskGetTickCount());
currentTimeSeparated = convertTicksToTimeSegments((oldTimeElapsed + timeElapsed)); currentTimeSeparated = convertTicksToTimeSegments((oldTimeElapsed + timeElapsed));
@ -157,7 +159,6 @@ bool StopWatch::Refresh() {
lv_label_set_text_fmt(time, "%02d:%02d", currentTimeSeparated.mins, currentTimeSeparated.secs); lv_label_set_text_fmt(time, "%02d:%02d", currentTimeSeparated.mins, currentTimeSeparated.secs);
lv_label_set_text_fmt(msecTime, "%02d", currentTimeSeparated.hundredths); lv_label_set_text_fmt(msecTime, "%02d", currentTimeSeparated.hundredths);
} }
return running;
} }
void StopWatch::playPauseBtnEventHandler(lv_event_t event) { void StopWatch::playPauseBtnEventHandler(lv_event_t event) {
@ -196,8 +197,7 @@ void StopWatch::stopLapBtnEventHandler(lv_event_t event) {
bool StopWatch::OnButtonPushed() { bool StopWatch::OnButtonPushed() {
if (currentState == States::Running) { if (currentState == States::Running) {
pause(); pause();
} else {
running = false;
}
return true; return true;
}
return false;
} }

View File

@ -64,7 +64,7 @@ namespace Pinetime::Applications::Screens {
public: public:
StopWatch(DisplayApp* app, System::SystemTask& systemTask); StopWatch(DisplayApp* app, System::SystemTask& systemTask);
~StopWatch() override; ~StopWatch() override;
bool Refresh() override; void Refresh() override;
void playPauseBtnEventHandler(lv_event_t event); void playPauseBtnEventHandler(lv_event_t event);
void stopLapBtnEventHandler(lv_event_t event); void stopLapBtnEventHandler(lv_event_t event);
@ -77,7 +77,6 @@ namespace Pinetime::Applications::Screens {
private: private:
Pinetime::System::SystemTask& systemTask; Pinetime::System::SystemTask& systemTask;
TickType_t timeElapsed; TickType_t timeElapsed;
bool running;
States currentState; States currentState;
TickType_t startTime; TickType_t startTime;
TickType_t oldTimeElapsed; TickType_t oldTimeElapsed;
@ -86,5 +85,7 @@ namespace Pinetime::Applications::Screens {
int lapNr = 0; int lapNr = 0;
lv_obj_t *time, *msecTime, *btnPlayPause, *btnStopLap, *txtPlayPause, *txtStopLap; lv_obj_t *time, *msecTime, *btnPlayPause, *btnStopLap, *txtPlayPause, *txtStopLap;
lv_obj_t *lapOneText, *lapTwoText; lv_obj_t *lapOneText, *lapTwoText;
lv_task_t* taskRefresh;
}; };
} }

View File

@ -65,13 +65,6 @@ SystemInfo::~SystemInfo() {
lv_obj_clean(lv_scr_act()); lv_obj_clean(lv_scr_act());
} }
bool SystemInfo::Refresh() {
if (running) {
screens.Refresh();
}
return running;
}
bool SystemInfo::OnTouchEvent(Pinetime::Applications::TouchEvents event) { bool SystemInfo::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
return screens.OnTouchEvent(event); return screens.OnTouchEvent(event);
} }

View File

@ -30,7 +30,6 @@ namespace Pinetime {
Pinetime::Drivers::WatchdogView& watchdog, Pinetime::Drivers::WatchdogView& watchdog,
Pinetime::Controllers::MotionController& motionController); Pinetime::Controllers::MotionController& motionController);
~SystemInfo() override; ~SystemInfo() override;
bool Refresh() override;
bool OnTouchEvent(TouchEvents event) override; bool OnTouchEvent(TouchEvents event) override;
private: private:

View File

@ -123,10 +123,6 @@ void Tile::UpdateScreen() {
lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryController.PercentRemaining())); lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryController.PercentRemaining()));
} }
bool Tile::Refresh() {
return running;
}
void Tile::OnValueChangedEvent(lv_obj_t* obj, uint32_t buttonId) { void Tile::OnValueChangedEvent(lv_obj_t* obj, uint32_t buttonId) {
if(obj != btnm1) return; if(obj != btnm1) return;

View File

@ -30,7 +30,6 @@ namespace Pinetime {
~Tile() override; ~Tile() override;
bool Refresh() override;
void UpdateScreen(); void UpdateScreen();
void OnValueChangedEvent(lv_obj_t* obj, uint32_t buttonId); void OnValueChangedEvent(lv_obj_t* obj, uint32_t buttonId);

View File

@ -4,10 +4,8 @@
#include "Symbols.h" #include "Symbols.h"
#include "lvgl/lvgl.h" #include "lvgl/lvgl.h"
using namespace Pinetime::Applications::Screens; using namespace Pinetime::Applications::Screens;
static void btnEventHandler(lv_obj_t* obj, lv_event_t event) { static void btnEventHandler(lv_obj_t* obj, lv_event_t event) {
Timer* screen = static_cast<Timer*>(obj->user_data); Timer* screen = static_cast<Timer*>(obj->user_data);
screen->OnButtonEvent(obj, event); screen->OnButtonEvent(obj, event);
@ -49,14 +47,10 @@ void Timer::createButtons() {
lv_obj_set_width(btnSecondsDown, 60); lv_obj_set_width(btnSecondsDown, 60);
txtSDown = lv_label_create(btnSecondsDown, nullptr); txtSDown = lv_label_create(btnSecondsDown, nullptr);
lv_label_set_text(txtSDown, "-"); lv_label_set_text(txtSDown, "-");
} }
Timer::Timer(DisplayApp* app, Controllers::TimerController& timerController) Timer::Timer(DisplayApp* app, Controllers::TimerController& timerController)
: Screen(app), : Screen(app), running {true}, timerController {timerController} {
running{true},
timerController{timerController} {
time = lv_label_create(lv_scr_act(), nullptr); time = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76); lv_obj_set_style_local_text_font(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76);
@ -80,19 +74,19 @@ Timer::Timer(DisplayApp* app, Controllers::TimerController& timerController)
createButtons(); createButtons();
} }
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
} }
Timer::~Timer() { Timer::~Timer() {
lv_task_del(taskRefresh);
lv_obj_clean(lv_scr_act()); lv_obj_clean(lv_scr_act());
} }
bool Timer::Refresh() { void Timer::Refresh() {
if (timerController.IsRunning()) { if (timerController.IsRunning()) {
uint32_t seconds = timerController.GetTimeRemaining() / 1000; uint32_t seconds = timerController.GetTimeRemaining() / 1000;
lv_label_set_text_fmt(time, "%02lu:%02lu", seconds / 60, seconds % 60); lv_label_set_text_fmt(time, "%02lu:%02lu", seconds / 60, seconds % 60);
} }
return running;
} }
void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) { void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
@ -118,7 +112,6 @@ void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
btnMinutesDown = nullptr; btnMinutesDown = nullptr;
lv_obj_del(btnMinutesUp); lv_obj_del(btnMinutesUp);
btnMinutesUp = nullptr; btnMinutesUp = nullptr;
} }
} else { } else {
if (!timerController.IsRunning()) { if (!timerController.IsRunning()) {
@ -153,17 +146,12 @@ void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
secondsToSet--; secondsToSet--;
} }
lv_label_set_text_fmt(time, "%02d:%02d", minutesToSet, secondsToSet); lv_label_set_text_fmt(time, "%02d:%02d", minutesToSet, secondsToSet);
} }
} }
} }
} }
} }
void Timer::setDone() { void Timer::setDone() {
lv_label_set_text(time, "00:00"); lv_label_set_text(time, "00:00");
lv_label_set_text(txtPlayPause, Symbols::play); lv_label_set_text(txtPlayPause, Symbols::play);

View File

@ -9,26 +9,21 @@
namespace Pinetime::Applications::Screens { namespace Pinetime::Applications::Screens {
class Timer : public Screen { class Timer : public Screen {
public: public:
enum class Modes { Normal, Done };
enum class Modes {
Normal, Done
};
Timer(DisplayApp* app, Controllers::TimerController& timerController); Timer(DisplayApp* app, Controllers::TimerController& timerController);
~Timer() override; ~Timer() override;
bool Refresh() override; void Refresh() override;
void setDone(); void setDone();
void OnButtonEvent(lv_obj_t* obj, lv_event_t event); void OnButtonEvent(lv_obj_t* obj, lv_event_t event);
private: private:
bool running; bool running;
uint8_t secondsToSet = 0; uint8_t secondsToSet = 0;
uint8_t minutesToSet = 0; uint8_t minutesToSet = 0;
@ -36,7 +31,9 @@ namespace Pinetime::Applications::Screens {
void createButtons(); void createButtons();
lv_obj_t* time, * msecTime, * btnPlayPause, * txtPlayPause, * btnMinutesUp, * btnMinutesDown, * btnSecondsUp, * btnSecondsDown, * txtMUp, lv_obj_t *time, *msecTime, *btnPlayPause, *txtPlayPause, *btnMinutesUp, *btnMinutesDown, *btnSecondsUp, *btnSecondsDown, *txtMUp,
* txtMDown, * txtSUp, * txtSDown; *txtMDown, *txtSUp, *txtSDown;
lv_task_t* taskRefresh;
}; };
} }

View File

@ -102,10 +102,6 @@ Twos::~Twos() {
lv_obj_clean(lv_scr_act()); lv_obj_clean(lv_scr_act());
} }
bool Twos::Refresh() {
return running;
}
bool Twos::placeNewTile() { bool Twos::placeNewTile() {
std::vector<std::pair<int, int>> availableCells; std::vector<std::pair<int, int>> availableCells;
for (int row = 0; row < 4; row++) { for (int row = 0; row < 4; row++) {

View File

@ -14,7 +14,6 @@ namespace Pinetime {
public: public:
Twos(DisplayApp* app); Twos(DisplayApp* app);
~Twos() override; ~Twos() override;
bool Refresh() override;
bool OnTouchEvent(TouchEvents event) override; bool OnTouchEvent(TouchEvents event) override;

View File

@ -118,10 +118,13 @@ WatchFaceAnalog::WatchFaceAnalog(Pinetime::Applications::DisplayApp* app,
lv_style_set_line_rounded(&hour_line_style_trace, LV_STATE_DEFAULT, false); lv_style_set_line_rounded(&hour_line_style_trace, LV_STATE_DEFAULT, false);
lv_obj_add_style(hour_body_trace, LV_LINE_PART_MAIN, &hour_line_style_trace); lv_obj_add_style(hour_body_trace, LV_LINE_PART_MAIN, &hour_line_style_trace);
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
UpdateClock(); UpdateClock();
} }
WatchFaceAnalog::~WatchFaceAnalog() { WatchFaceAnalog::~WatchFaceAnalog() {
lv_task_del(taskRefresh);
lv_style_reset(&hour_line_style); lv_style_reset(&hour_line_style);
lv_style_reset(&hour_line_style_trace); lv_style_reset(&hour_line_style_trace);
lv_style_reset(&minute_line_style); lv_style_reset(&minute_line_style);
@ -173,7 +176,7 @@ void WatchFaceAnalog::UpdateClock() {
} }
} }
bool WatchFaceAnalog::Refresh() { void WatchFaceAnalog::Refresh() {
batteryPercentRemaining = batteryController.PercentRemaining(); batteryPercentRemaining = batteryController.PercentRemaining();
if (batteryPercentRemaining.IsUpdated()) { if (batteryPercentRemaining.IsUpdated()) {
auto batteryPercent = batteryPercentRemaining.Get(); auto batteryPercent = batteryPercentRemaining.Get();
@ -203,6 +206,4 @@ bool WatchFaceAnalog::Refresh() {
currentDay = day; currentDay = day;
} }
} }
return true;
} }

View File

@ -32,7 +32,7 @@ namespace Pinetime {
~WatchFaceAnalog() override; ~WatchFaceAnalog() override;
bool Refresh() override; void Refresh() override;
private: private:
uint8_t sHour, sMinute, sSecond; uint8_t sHour, sMinute, sSecond;
@ -81,6 +81,8 @@ namespace Pinetime {
Controllers::Settings& settingsController; Controllers::Settings& settingsController;
void UpdateClock(); void UpdateClock();
lv_task_t* taskRefresh;
}; };
} }
} }

View File

@ -91,13 +91,17 @@ WatchFaceDigital::WatchFaceDigital(DisplayApp* app,
lv_obj_set_style_local_text_color(stepIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FFE7)); lv_obj_set_style_local_text_color(stepIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FFE7));
lv_label_set_text(stepIcon, Symbols::shoe); lv_label_set_text(stepIcon, Symbols::shoe);
lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0); lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0);
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
Refresh();
} }
WatchFaceDigital::~WatchFaceDigital() { WatchFaceDigital::~WatchFaceDigital() {
lv_task_del(taskRefresh);
lv_obj_clean(lv_scr_act()); lv_obj_clean(lv_scr_act());
} }
bool WatchFaceDigital::Refresh() { void WatchFaceDigital::Refresh() {
batteryPercentRemaining = batteryController.PercentRemaining(); batteryPercentRemaining = batteryController.PercentRemaining();
if (batteryPercentRemaining.IsUpdated()) { if (batteryPercentRemaining.IsUpdated()) {
auto batteryPercent = batteryPercentRemaining.Get(); auto batteryPercent = batteryPercentRemaining.Get();
@ -219,6 +223,4 @@ bool WatchFaceDigital::Refresh() {
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0); lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0); lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0);
} }
return running;
} }

View File

@ -33,7 +33,7 @@ namespace Pinetime {
Controllers::MotionController& motionController); Controllers::MotionController& motionController);
~WatchFaceDigital() override; ~WatchFaceDigital() override;
bool Refresh() override; void Refresh() override;
private: private:
char displayedChar[5] {}; char displayedChar[5] {};
@ -72,6 +72,8 @@ namespace Pinetime {
Controllers::Settings& settingsController; Controllers::Settings& settingsController;
Controllers::HeartRateController& heartRateController; Controllers::HeartRateController& heartRateController;
Controllers::MotionController& motionController; Controllers::MotionController& motionController;
lv_task_t* taskRefresh;
}; };
} }
} }

View File

@ -156,7 +156,3 @@ void QuickSettings::OnButtonEvent(lv_obj_t* object, lv_event_t event) {
app->StartApp(Apps::Settings, DisplayApp::FullRefreshDirections::Up); app->StartApp(Apps::Settings, DisplayApp::FullRefreshDirections::Up);
} }
} }
bool QuickSettings::Refresh() {
return running;
}

View File

@ -27,8 +27,6 @@ namespace Pinetime {
~QuickSettings() override; ~QuickSettings() override;
bool Refresh() override;
void OnButtonEvent(lv_obj_t* object, lv_event_t event); void OnButtonEvent(lv_obj_t* object, lv_event_t event);
void UpdateScreen(); void UpdateScreen();

View File

@ -80,10 +80,6 @@ SettingDisplay::~SettingDisplay() {
settingsController.SaveSettings(); settingsController.SaveSettings();
} }
bool SettingDisplay::Refresh() {
return running;
}
void SettingDisplay::UpdateSelected(lv_obj_t* object, lv_event_t event) { void SettingDisplay::UpdateSelected(lv_obj_t* object, lv_event_t event) {
if (event == LV_EVENT_CLICKED) { if (event == LV_EVENT_CLICKED) {
for (int i = 0; i < optionsTotal; i++) { for (int i = 0; i < optionsTotal; i++) {

View File

@ -15,7 +15,6 @@ namespace Pinetime {
SettingDisplay(DisplayApp* app, Pinetime::Controllers::Settings& settingsController); SettingDisplay(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
~SettingDisplay() override; ~SettingDisplay() override;
bool Refresh() override;
void UpdateSelected(lv_obj_t* object, lv_event_t event); void UpdateSelected(lv_obj_t* object, lv_event_t event);
private: private:

View File

@ -70,11 +70,6 @@ SettingSteps::~SettingSteps() {
settingsController.SaveSettings(); settingsController.SaveSettings();
} }
bool SettingSteps::Refresh() {
return running;
}
void SettingSteps::UpdateSelected(lv_obj_t *object, lv_event_t event) { void SettingSteps::UpdateSelected(lv_obj_t *object, lv_event_t event) {
uint32_t value = settingsController.GetStepsGoal(); uint32_t value = settingsController.GetStepsGoal();
if(object == btnPlus && (event == LV_EVENT_PRESSED)) { if(object == btnPlus && (event == LV_EVENT_PRESSED)) {

View File

@ -10,22 +10,19 @@ namespace Pinetime {
namespace Applications { namespace Applications {
namespace Screens { namespace Screens {
class SettingSteps : public Screen{ class SettingSteps : public Screen {
public: public:
SettingSteps(DisplayApp* app, Pinetime::Controllers::Settings &settingsController); SettingSteps(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
~SettingSteps() override; ~SettingSteps() override;
bool Refresh() override; void UpdateSelected(lv_obj_t* object, lv_event_t event);
void UpdateSelected(lv_obj_t *object, lv_event_t event);
private: private:
Controllers::Settings& settingsController; Controllers::Settings& settingsController;
lv_obj_t * stepValue; lv_obj_t* stepValue;
lv_obj_t * btnPlus; lv_obj_t* btnPlus;
lv_obj_t * btnMinus; lv_obj_t* btnMinus;
}; };
} }
} }

View File

@ -64,10 +64,6 @@ SettingTimeFormat::~SettingTimeFormat() {
settingsController.SaveSettings(); settingsController.SaveSettings();
} }
bool SettingTimeFormat::Refresh() {
return running;
}
void SettingTimeFormat::UpdateSelected(lv_obj_t* object, lv_event_t event) { void SettingTimeFormat::UpdateSelected(lv_obj_t* object, lv_event_t event) {
if (event == LV_EVENT_VALUE_CHANGED) { if (event == LV_EVENT_VALUE_CHANGED) {
for (int i = 0; i < optionsTotal; i++) { for (int i = 0; i < optionsTotal; i++) {

View File

@ -15,7 +15,6 @@ namespace Pinetime {
SettingTimeFormat(DisplayApp* app, Pinetime::Controllers::Settings& settingsController); SettingTimeFormat(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
~SettingTimeFormat() override; ~SettingTimeFormat() override;
bool Refresh() override;
void UpdateSelected(lv_obj_t* object, lv_event_t event); void UpdateSelected(lv_obj_t* object, lv_event_t event);
private: private:

View File

@ -72,10 +72,6 @@ SettingWakeUp::~SettingWakeUp() {
settingsController.SaveSettings(); settingsController.SaveSettings();
} }
bool SettingWakeUp::Refresh() {
return running;
}
void SettingWakeUp::UpdateSelected(lv_obj_t* object, lv_event_t event) { void SettingWakeUp::UpdateSelected(lv_obj_t* object, lv_event_t event) {
using WakeUpMode = Pinetime::Controllers::Settings::WakeUpMode; using WakeUpMode = Pinetime::Controllers::Settings::WakeUpMode;
if (event == LV_EVENT_VALUE_CHANGED && !ignoringEvents) { if (event == LV_EVENT_VALUE_CHANGED && !ignoringEvents) {

View File

@ -15,7 +15,6 @@ namespace Pinetime {
SettingWakeUp(DisplayApp* app, Pinetime::Controllers::Settings& settingsController); SettingWakeUp(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
~SettingWakeUp() override; ~SettingWakeUp() override;
bool Refresh() override;
void UpdateSelected(lv_obj_t* object, lv_event_t event); void UpdateSelected(lv_obj_t* object, lv_event_t event);
private: private:

View File

@ -75,10 +75,6 @@ SettingWatchFace::~SettingWatchFace() {
settingsController.SaveSettings(); settingsController.SaveSettings();
} }
bool SettingWatchFace::Refresh() {
return running;
}
void SettingWatchFace::UpdateSelected(lv_obj_t* object, lv_event_t event) { void SettingWatchFace::UpdateSelected(lv_obj_t* object, lv_event_t event) {
if (event == LV_EVENT_VALUE_CHANGED) { if (event == LV_EVENT_VALUE_CHANGED) {
for (uint8_t i = 0; i < optionsTotal; i++) { for (uint8_t i = 0; i < optionsTotal; i++) {

View File

@ -15,7 +15,6 @@ namespace Pinetime {
SettingWatchFace(DisplayApp* app, Pinetime::Controllers::Settings& settingsController); SettingWatchFace(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
~SettingWatchFace() override; ~SettingWatchFace() override;
bool Refresh() override;
void UpdateSelected(lv_obj_t* object, lv_event_t event); void UpdateSelected(lv_obj_t* object, lv_event_t event);
private: private:

View File

@ -26,13 +26,6 @@ Settings::~Settings() {
lv_obj_clean(lv_scr_act()); lv_obj_clean(lv_scr_act());
} }
bool Settings::Refresh() {
if (running)
running = screens.Refresh();
return running;
}
bool Settings::OnTouchEvent(Pinetime::Applications::TouchEvents event) { bool Settings::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
return screens.OnTouchEvent(event); return screens.OnTouchEvent(event);
} }

View File

@ -14,8 +14,6 @@ namespace Pinetime {
Settings(DisplayApp* app, Pinetime::Controllers::Settings& settingsController); Settings(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
~Settings() override; ~Settings() override;
bool Refresh() override;
bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override; bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override;
private: private: