Refresh rework
This commit is contained in:
parent
57b3397078
commit
97c761a5c7
|
@ -239,7 +239,7 @@ void DisplayApp::Refresh() {
|
|||
}
|
||||
|
||||
void DisplayApp::RunningState() {
|
||||
if (!currentScreen->Refresh()) {
|
||||
if (!currentScreen->IsRunning()) {
|
||||
LoadApp(returnToApp, returnDirection);
|
||||
}
|
||||
lv_task_handler();
|
||||
|
|
|
@ -34,12 +34,6 @@ ApplicationList::~ApplicationList() {
|
|||
lv_obj_clean(lv_scr_act());
|
||||
}
|
||||
|
||||
bool ApplicationList::Refresh() {
|
||||
if (running)
|
||||
running = screens.Refresh();
|
||||
return running;
|
||||
}
|
||||
|
||||
bool ApplicationList::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
||||
return screens.OnTouchEvent(event);
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ namespace Pinetime {
|
|||
Pinetime::Controllers::Battery& batteryController,
|
||||
Controllers::DateTime& dateTimeController);
|
||||
~ApplicationList() override;
|
||||
bool Refresh() override;
|
||||
bool OnTouchEvent(TouchEvents event) override;
|
||||
|
||||
private:
|
||||
|
@ -33,4 +32,4 @@ namespace Pinetime {
|
|||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,11 +4,6 @@
|
|||
|
||||
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)
|
||||
: Screen(app), batteryController {batteryController} {
|
||||
|
||||
|
@ -49,16 +44,16 @@ BatteryInfo::BatteryInfo(Pinetime::Applications::DisplayApp* app, Pinetime::Cont
|
|||
lv_obj_set_pos(backgroundLabel, 0, 0);
|
||||
lv_label_set_text_static(backgroundLabel, "");
|
||||
|
||||
taskUpdate = lv_task_create(lv_update_task, 5000, LV_TASK_PRIO_LOW, this);
|
||||
UpdateScreen();
|
||||
taskRefresh = lv_task_create(RefreshTaskCallback, 5000, LV_TASK_PRIO_MID, this);
|
||||
Refresh();
|
||||
}
|
||||
|
||||
BatteryInfo::~BatteryInfo() {
|
||||
lv_task_del(taskUpdate);
|
||||
lv_task_del(taskRefresh);
|
||||
lv_obj_clean(lv_scr_act());
|
||||
}
|
||||
|
||||
void BatteryInfo::UpdateScreen() {
|
||||
void BatteryInfo::Refresh() {
|
||||
|
||||
batteryController.Update();
|
||||
|
||||
|
@ -85,7 +80,3 @@ void BatteryInfo::UpdateScreen() {
|
|||
lv_label_set_text_fmt(voltage, "%1i.%02i volts", batteryVoltage / 1000, batteryVoltage % 1000 / 10);
|
||||
lv_bar_set_value(charging_bar, batteryPercent, LV_ANIM_ON);
|
||||
}
|
||||
|
||||
bool BatteryInfo::Refresh() {
|
||||
return running;
|
||||
}
|
||||
|
|
|
@ -19,9 +19,7 @@ namespace Pinetime {
|
|||
BatteryInfo(DisplayApp* app, Pinetime::Controllers::Battery& batteryController);
|
||||
~BatteryInfo() override;
|
||||
|
||||
bool Refresh() override;
|
||||
|
||||
void UpdateScreen();
|
||||
void Refresh() override;
|
||||
|
||||
private:
|
||||
Pinetime::Controllers::Battery& batteryController;
|
||||
|
@ -31,7 +29,7 @@ namespace Pinetime {
|
|||
lv_obj_t* charging_bar;
|
||||
lv_obj_t* status;
|
||||
|
||||
lv_task_t* taskUpdate;
|
||||
lv_task_t* taskRefresh;
|
||||
|
||||
uint8_t batteryPercent = 0;
|
||||
uint16_t batteryVoltage = 0;
|
||||
|
|
|
@ -30,10 +30,6 @@ Brightness::~Brightness() {
|
|||
lv_obj_clean(lv_scr_act());
|
||||
}
|
||||
|
||||
bool Brightness::Refresh() {
|
||||
return running;
|
||||
}
|
||||
|
||||
const char* Brightness::LevelToString(Pinetime::Controllers::BrightnessController::Levels level) {
|
||||
switch (level) {
|
||||
case Pinetime::Controllers::BrightnessController::Levels::Off:
|
||||
|
|
|
@ -12,7 +12,6 @@ namespace Pinetime {
|
|||
public:
|
||||
Brightness(DisplayApp* app, Controllers::BrightnessController& brightness);
|
||||
~Brightness() override;
|
||||
bool Refresh() override;
|
||||
|
||||
bool OnTouchEvent(TouchEvents event) override;
|
||||
|
||||
|
@ -31,4 +30,4 @@ namespace Pinetime {
|
|||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,11 +55,6 @@ Clock::~Clock() {
|
|||
lv_obj_clean(lv_scr_act());
|
||||
}
|
||||
|
||||
bool Clock::Refresh() {
|
||||
screen->Refresh();
|
||||
return running;
|
||||
}
|
||||
|
||||
bool Clock::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
||||
return screen->OnTouchEvent(event);
|
||||
}
|
||||
|
@ -101,4 +96,4 @@ std::unique_ptr<Screen> Clock::WatchFaceCustomScreen() {
|
|||
return std::make_unique<Screens::WatchFaceCustom>(app, dateTimeController, batteryController, bleController, notificatioManager,
|
||||
settingsController);
|
||||
}
|
||||
*/
|
||||
*/
|
||||
|
|
|
@ -34,8 +34,6 @@ namespace Pinetime {
|
|||
Controllers::MotionController& motionController);
|
||||
~Clock() override;
|
||||
|
||||
bool Refresh() override;
|
||||
|
||||
bool OnTouchEvent(TouchEvents event) override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -30,36 +30,40 @@ FirmwareUpdate::FirmwareUpdate(Pinetime::Applications::DisplayApp* app, Pinetime
|
|||
lv_label_set_text(percentLabel, "");
|
||||
lv_obj_set_auto_realign(percentLabel, true);
|
||||
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);
|
||||
}
|
||||
|
||||
FirmwareUpdate::~FirmwareUpdate() {
|
||||
lv_task_del(taskRefresh);
|
||||
lv_obj_clean(lv_scr_act());
|
||||
}
|
||||
|
||||
bool FirmwareUpdate::Refresh() {
|
||||
void FirmwareUpdate::Refresh() {
|
||||
switch (bleController.State()) {
|
||||
default:
|
||||
case Pinetime::Controllers::Ble::FirmwareUpdateStates::Idle:
|
||||
case Pinetime::Controllers::Ble::FirmwareUpdateStates::Running:
|
||||
if (state != States::Running)
|
||||
state = States::Running;
|
||||
return DisplayProgression();
|
||||
DisplayProgression();
|
||||
return;
|
||||
case Pinetime::Controllers::Ble::FirmwareUpdateStates::Validated:
|
||||
if (state != States::Validated) {
|
||||
UpdateValidated();
|
||||
state = States::Validated;
|
||||
}
|
||||
return running;
|
||||
return;
|
||||
case Pinetime::Controllers::Ble::FirmwareUpdateStates::Error:
|
||||
if (state != States::Error) {
|
||||
UpdateError();
|
||||
state = States::Error;
|
||||
}
|
||||
return running;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
bool FirmwareUpdate::DisplayProgression() const {
|
||||
void FirmwareUpdate::DisplayProgression() const {
|
||||
float current = bleController.FirmwareUpdateCurrentBytes() / 1024.0f;
|
||||
float total = bleController.FirmwareUpdateTotalBytes() / 1024.0f;
|
||||
int16_t pc = (current / total) * 100.0f;
|
||||
|
@ -67,7 +71,6 @@ bool FirmwareUpdate::DisplayProgression() const {
|
|||
lv_label_set_text(percentLabel, percentStr);
|
||||
|
||||
lv_bar_set_value(bar1, pc, LV_ANIM_OFF);
|
||||
return running;
|
||||
}
|
||||
|
||||
void FirmwareUpdate::UpdateValidated() {
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Pinetime {
|
|||
FirmwareUpdate(DisplayApp* app, Pinetime::Controllers::Ble& bleController);
|
||||
~FirmwareUpdate() override;
|
||||
|
||||
bool Refresh() override;
|
||||
void Refresh() override;
|
||||
|
||||
private:
|
||||
enum class States { Idle, Running, Validated, Error };
|
||||
|
@ -27,11 +27,13 @@ namespace Pinetime {
|
|||
|
||||
States state;
|
||||
|
||||
bool DisplayProgression() const;
|
||||
void DisplayProgression() const;
|
||||
|
||||
void UpdateValidated();
|
||||
|
||||
void UpdateError();
|
||||
|
||||
lv_task_t* taskRefresh;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,10 +61,6 @@ FirmwareValidation::~FirmwareValidation() {
|
|||
lv_obj_clean(lv_scr_act());
|
||||
}
|
||||
|
||||
bool FirmwareValidation::Refresh() {
|
||||
return running;
|
||||
}
|
||||
|
||||
void FirmwareValidation::OnButtonEvent(lv_obj_t* object, lv_event_t event) {
|
||||
if (object == buttonValidate && event == LV_EVENT_PRESSED) {
|
||||
validator.Validate();
|
||||
|
|
|
@ -16,8 +16,6 @@ namespace Pinetime {
|
|||
FirmwareValidation(DisplayApp* app, Pinetime::Controllers::FirmwareValidator& validator);
|
||||
~FirmwareValidation() override;
|
||||
|
||||
bool Refresh() override;
|
||||
|
||||
void OnButtonEvent(lv_obj_t* object, lv_event_t event);
|
||||
|
||||
private:
|
||||
|
|
|
@ -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) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -16,8 +16,6 @@ namespace Pinetime {
|
|||
FlashLight(DisplayApp* app, System::SystemTask& systemTask, Controllers::BrightnessController& brightness);
|
||||
~FlashLight() override;
|
||||
|
||||
bool Refresh() override;
|
||||
|
||||
bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override;
|
||||
void OnClickEvent(lv_obj_t* obj, lv_event_t event);
|
||||
|
||||
|
|
|
@ -64,14 +64,17 @@ HeartRate::HeartRate(Pinetime::Applications::DisplayApp* app,
|
|||
UpdateStartStopButton(isHrRunning);
|
||||
if (isHrRunning)
|
||||
systemTask.PushMessage(Pinetime::System::Messages::DisableSleeping);
|
||||
|
||||
taskRefresh = lv_task_create(RefreshTaskCallback, 100, LV_TASK_PRIO_MID, this);
|
||||
}
|
||||
|
||||
HeartRate::~HeartRate() {
|
||||
lv_task_del(taskRefresh);
|
||||
lv_obj_clean(lv_scr_act());
|
||||
systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
|
||||
}
|
||||
|
||||
bool HeartRate::Refresh() {
|
||||
void HeartRate::Refresh() {
|
||||
|
||||
auto state = heartRateController.State();
|
||||
switch (state) {
|
||||
|
@ -86,8 +89,6 @@ bool HeartRate::Refresh() {
|
|||
|
||||
lv_label_set_text(label_status, ToString(state));
|
||||
lv_obj_align(label_status, label_hr, LV_ALIGN_OUT_BOTTOM_MID, 0, 10);
|
||||
|
||||
return running;
|
||||
}
|
||||
|
||||
void HeartRate::OnStartStopEvent(lv_event_t event) {
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace Pinetime {
|
|||
HeartRate(DisplayApp* app, Controllers::HeartRateController& HeartRateController, System::SystemTask& systemTask);
|
||||
~HeartRate() override;
|
||||
|
||||
bool Refresh() override;
|
||||
void Refresh() override;
|
||||
|
||||
void OnStartStopEvent(lv_event_t event);
|
||||
|
||||
|
@ -33,6 +33,8 @@ namespace Pinetime {
|
|||
lv_obj_t* label_status;
|
||||
lv_obj_t* btn_startStop;
|
||||
lv_obj_t* label_startStop;
|
||||
|
||||
lv_task_t* taskRefresh;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,10 +15,6 @@ InfiniPaint::~InfiniPaint() {
|
|||
lv_obj_clean(lv_scr_act());
|
||||
}
|
||||
|
||||
bool InfiniPaint::Refresh() {
|
||||
return running;
|
||||
}
|
||||
|
||||
bool InfiniPaint::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
||||
switch (event) {
|
||||
case Pinetime::Applications::TouchEvents::LongTap:
|
||||
|
|
|
@ -17,8 +17,6 @@ namespace Pinetime {
|
|||
|
||||
~InfiniPaint() override;
|
||||
|
||||
bool Refresh() override;
|
||||
|
||||
bool OnTouchEvent(TouchEvents event) override;
|
||||
|
||||
bool OnTouchEvent(uint16_t x, uint16_t y) override;
|
||||
|
|
|
@ -36,7 +36,3 @@ Label::Label(uint8_t screenID, uint8_t numScreens, Pinetime::Applications::Displ
|
|||
Label::~Label() {
|
||||
lv_obj_clean(lv_scr_act());
|
||||
}
|
||||
|
||||
bool Label::Refresh() {
|
||||
return running;
|
||||
}
|
||||
|
|
|
@ -12,8 +12,6 @@ namespace Pinetime {
|
|||
Label(uint8_t screenID, uint8_t numScreens, DisplayApp* app, lv_obj_t* labelText);
|
||||
~Label() override;
|
||||
|
||||
bool Refresh() override;
|
||||
|
||||
private:
|
||||
bool running = true;
|
||||
|
||||
|
@ -25,4 +23,4 @@ namespace Pinetime {
|
|||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,11 +102,6 @@ List::~List() {
|
|||
lv_obj_clean(lv_scr_act());
|
||||
}
|
||||
|
||||
bool List::Refresh() {
|
||||
|
||||
return running;
|
||||
}
|
||||
|
||||
void List::OnButtonEvent(lv_obj_t* object, lv_event_t event) {
|
||||
if (event == LV_EVENT_RELEASED) {
|
||||
for (int i = 0; i < MAXLISTITEMS; i++) {
|
||||
|
|
|
@ -27,8 +27,6 @@ namespace Pinetime {
|
|||
std::array<Applications, MAXLISTITEMS>& applications);
|
||||
~List() override;
|
||||
|
||||
bool Refresh() override;
|
||||
|
||||
void OnButtonEvent(lv_obj_t* object, lv_event_t event);
|
||||
|
||||
private:
|
||||
|
|
|
@ -20,17 +20,17 @@ Meter::Meter(Pinetime::Applications::DisplayApp* app) : Screen(app) {
|
|||
|
||||
lv_obj_set_size(lmeter, 200, 200);
|
||||
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() {
|
||||
|
||||
lv_task_del(taskRefresh);
|
||||
lv_obj_clean(lv_scr_act());
|
||||
}
|
||||
|
||||
bool Meter::Refresh() {
|
||||
void Meter::Refresh() {
|
||||
lv_linemeter_set_value(lmeter, value++); /*Set the current value*/
|
||||
if (value >= 60)
|
||||
value = 0;
|
||||
|
||||
return running;
|
||||
}
|
||||
|
|
|
@ -14,13 +14,15 @@ namespace Pinetime {
|
|||
Meter(DisplayApp* app);
|
||||
~Meter() override;
|
||||
|
||||
bool Refresh() override;
|
||||
void Refresh() override;
|
||||
|
||||
private:
|
||||
lv_style_t style_lmeter;
|
||||
lv_obj_t* lmeter;
|
||||
|
||||
uint32_t value = 0;
|
||||
|
||||
lv_task_t* taskRefresh;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,9 +85,12 @@ Metronome::Metronome(DisplayApp* app, Controllers::MotorController& motorControl
|
|||
lv_label_set_text(playPauseLabel, Symbols::play);
|
||||
|
||||
app->SetTouchMode(DisplayApp::TouchModes::Polling);
|
||||
|
||||
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
|
||||
}
|
||||
|
||||
Metronome::~Metronome() {
|
||||
lv_task_del(taskRefresh);
|
||||
app->SetTouchMode(DisplayApp::TouchModes::Gestures);
|
||||
systemTask.PushMessage(System::Messages::EnableSleeping);
|
||||
lv_obj_clean(lv_scr_act());
|
||||
|
@ -97,7 +100,7 @@ bool Metronome::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Metronome::Refresh() {
|
||||
void Metronome::Refresh() {
|
||||
switch (currentState) {
|
||||
case States::Stopped: {
|
||||
break;
|
||||
|
@ -117,7 +120,6 @@ bool Metronome::Refresh() {
|
|||
break;
|
||||
}
|
||||
}
|
||||
return running;
|
||||
}
|
||||
|
||||
void Metronome::OnEvent(lv_obj_t* obj, lv_event_t event) {
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace Pinetime::Applications::Screens {
|
|||
public:
|
||||
Metronome(DisplayApp* app, Controllers::MotorController& motorController, System::SystemTask& systemTask);
|
||||
~Metronome() override;
|
||||
bool Refresh() override;
|
||||
void Refresh() override;
|
||||
bool OnTouchEvent(TouchEvents event) override;
|
||||
void OnEvent(lv_obj_t* obj, lv_event_t event);
|
||||
enum class States { Running, Stopped };
|
||||
|
@ -30,5 +30,7 @@ namespace Pinetime::Applications::Screens {
|
|||
lv_obj_t *bpmArc, *bpmTap, *bpmValue, *bpmLegend;
|
||||
lv_obj_t *bpbDropdown, *bpbLegend;
|
||||
lv_obj_t *playPause, *playPauseLabel;
|
||||
|
||||
lv_task_t* taskRefresh;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -32,18 +32,20 @@ Motion::Motion(Pinetime::Applications::DisplayApp* app, Controllers::MotionContr
|
|||
lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
|
||||
lv_obj_align(label, NULL, LV_ALIGN_IN_TOP_MID, 0, 10);
|
||||
lv_label_set_recolor(label, true);
|
||||
|
||||
|
||||
labelStep = lv_label_create(lv_scr_act(), NULL);
|
||||
lv_obj_align(labelStep, chart, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
|
||||
lv_label_set_text(labelStep, "Steps ---");
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
bool Motion::Refresh() {
|
||||
void Motion::Refresh() {
|
||||
lv_chart_set_next(chart, ser1, motionController.X());
|
||||
lv_chart_set_next(chart, ser2, motionController.Y());
|
||||
lv_chart_set_next(chart, ser3, motionController.Z());
|
||||
|
@ -52,8 +54,6 @@ bool Motion::Refresh() {
|
|||
|
||||
lv_label_set_text_fmt(label, "X #FF0000 %d# Y #008000 %d# Z #FFFF00 %d#", motionController.X() / 0x10, motionController.Y() / 0x10, motionController.Z() / 0x10);
|
||||
lv_obj_align(label, NULL, LV_ALIGN_IN_TOP_MID, 0, 10);
|
||||
|
||||
return running;
|
||||
}
|
||||
|
||||
bool Motion::OnButtonPushed() {
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace Pinetime {
|
|||
Motion(DisplayApp* app, Controllers::MotionController& motionController);
|
||||
~Motion() override;
|
||||
|
||||
bool Refresh() override;
|
||||
void Refresh() override;
|
||||
bool OnButtonPushed() override;
|
||||
|
||||
private:
|
||||
|
@ -32,7 +32,9 @@ namespace Pinetime {
|
|||
static constexpr uint8_t nbStepsBufferSize = 9;
|
||||
char nbStepsBuffer[nbStepsBufferSize + 1];
|
||||
bool running = true;
|
||||
|
||||
lv_task_t* taskRefresh;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -146,13 +146,16 @@ Music::Music(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Mus
|
|||
frameB = false;
|
||||
|
||||
musicService.event(Controllers::MusicService::EVENT_MUSIC_OPEN);
|
||||
|
||||
taskRefresh = lv_task_create(RefreshTaskCallback, 5000, LV_TASK_PRIO_MID, this);
|
||||
}
|
||||
|
||||
Music::~Music() {
|
||||
lv_task_del(taskRefresh);
|
||||
lv_obj_clean(lv_scr_act());
|
||||
}
|
||||
|
||||
bool Music::Refresh() {
|
||||
void Music::Refresh() {
|
||||
if (artist != musicService.getArtist()) {
|
||||
artist = musicService.getArtist();
|
||||
currentLength = 0;
|
||||
|
@ -216,8 +219,6 @@ bool Music::Refresh() {
|
|||
} else {
|
||||
lv_label_set_text(txtPlayPause, Symbols::play);
|
||||
}
|
||||
|
||||
return running;
|
||||
}
|
||||
|
||||
void Music::UpdateLength() {
|
||||
|
@ -303,4 +304,4 @@ bool Music::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace Pinetime {
|
|||
|
||||
~Music() override;
|
||||
|
||||
bool Refresh() override;
|
||||
void Refresh() override;
|
||||
|
||||
void OnObjectEvent(lv_obj_t* obj, lv_event_t event);
|
||||
|
||||
|
@ -78,6 +78,8 @@ namespace Pinetime {
|
|||
|
||||
bool playing;
|
||||
|
||||
lv_task_t* taskRefresh;
|
||||
|
||||
/** Watchapp */
|
||||
};
|
||||
}
|
||||
|
|
|
@ -161,13 +161,16 @@ Navigation::Navigation(Pinetime::Applications::DisplayApp* app, Pinetime::Contro
|
|||
lv_bar_set_anim_time(barProgress, 500);
|
||||
lv_bar_set_range(barProgress, 0, 100);
|
||||
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() {
|
||||
lv_task_del(taskRefresh);
|
||||
lv_obj_clean(lv_scr_act());
|
||||
}
|
||||
|
||||
bool Navigation::Refresh() {
|
||||
void Navigation::Refresh() {
|
||||
if (flag != navService.getFlag()) {
|
||||
flag = navService.getFlag();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
return running;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace Pinetime {
|
|||
Navigation(DisplayApp* app, Pinetime::Controllers::NavigationService& nav);
|
||||
~Navigation() override;
|
||||
|
||||
bool Refresh() override;
|
||||
void Refresh() override;
|
||||
|
||||
private:
|
||||
lv_obj_t* imgFlag;
|
||||
|
@ -49,6 +49,8 @@ namespace Pinetime {
|
|||
std::string narrative;
|
||||
std::string manDist;
|
||||
int progress;
|
||||
|
||||
lv_task_t* taskRefresh;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,13 +47,16 @@ Notifications::Notifications(DisplayApp* app,
|
|||
timeoutTickCountStart = xTaskGetTickCount();
|
||||
timeoutTickCountEnd = timeoutTickCountStart + (5 * 1024);
|
||||
}
|
||||
|
||||
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
|
||||
}
|
||||
|
||||
Notifications::~Notifications() {
|
||||
lv_task_del(taskRefresh);
|
||||
lv_obj_clean(lv_scr_act());
|
||||
}
|
||||
|
||||
bool Notifications::Refresh() {
|
||||
void Notifications::Refresh() {
|
||||
if (mode == Modes::Preview) {
|
||||
auto tick = xTaskGetTickCount();
|
||||
int32_t pos = 240 - ((tick - timeoutTickCountStart) / ((timeoutTickCountEnd - timeoutTickCountStart) / 240));
|
||||
|
@ -63,8 +66,6 @@ bool Notifications::Refresh() {
|
|||
timeoutLinePoints[1].x = pos;
|
||||
lv_line_set_points(timeoutLine, timeoutLinePoints, 2);
|
||||
}
|
||||
|
||||
return running;
|
||||
}
|
||||
|
||||
bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace Pinetime {
|
|||
Modes mode);
|
||||
~Notifications() override;
|
||||
|
||||
bool Refresh() override;
|
||||
void Refresh() override;
|
||||
bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override;
|
||||
|
||||
class NotificationItem {
|
||||
|
@ -35,9 +35,6 @@ namespace Pinetime {
|
|||
Modes mode,
|
||||
Pinetime::Controllers::AlertNotificationService& alertNotificationService);
|
||||
~NotificationItem();
|
||||
bool Refresh() {
|
||||
return false;
|
||||
}
|
||||
void OnAcceptIncomingCall(lv_event_t event);
|
||||
void OnMuteIncomingCall(lv_event_t event);
|
||||
void OnRejectIncomingCall(lv_event_t event);
|
||||
|
@ -78,6 +75,8 @@ namespace Pinetime {
|
|||
lv_obj_t* timeoutLine;
|
||||
uint32_t timeoutTickCountStart;
|
||||
uint32_t timeoutTickCountEnd;
|
||||
|
||||
lv_task_t* taskRefresh;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,15 +29,18 @@ 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_radius(ball, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
|
||||
lv_obj_set_size(ball, ballSize, ballSize);
|
||||
|
||||
taskRefresh = lv_task_create(RefreshTaskCallback, 20, LV_TASK_PRIO_MID, this);
|
||||
}
|
||||
|
||||
Paddle::~Paddle() {
|
||||
lv_task_del(taskRefresh);
|
||||
// Reset the touchmode
|
||||
app->SetTouchMode(DisplayApp::TouchModes::Gestures);
|
||||
lv_obj_clean(lv_scr_act());
|
||||
}
|
||||
|
||||
bool Paddle::Refresh() {
|
||||
void Paddle::Refresh() {
|
||||
ballX += dx;
|
||||
ballY += dy;
|
||||
|
||||
|
@ -69,7 +72,6 @@ bool Paddle::Refresh() {
|
|||
}
|
||||
}
|
||||
lv_label_set_text_fmt(points, "%04d", score);
|
||||
return running;
|
||||
}
|
||||
|
||||
bool Paddle::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Pinetime {
|
|||
Paddle(DisplayApp* app, Pinetime::Components::LittleVgl& lvgl);
|
||||
~Paddle() override;
|
||||
|
||||
bool Refresh() override;
|
||||
void Refresh() override;
|
||||
|
||||
bool OnTouchEvent(TouchEvents event) override;
|
||||
bool OnTouchEvent(uint16_t x, uint16_t y) override;
|
||||
|
@ -40,6 +40,8 @@ namespace Pinetime {
|
|||
lv_obj_t* paddle;
|
||||
lv_obj_t* ball;
|
||||
lv_obj_t* background;
|
||||
|
||||
lv_task_t* taskRefresh;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -200,13 +200,17 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
|
|||
lv_obj_set_size(backgroundLabel, 240, 240);
|
||||
lv_obj_set_pos(backgroundLabel, 0, 0);
|
||||
lv_label_set_text(backgroundLabel, "");
|
||||
|
||||
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
|
||||
Refresh();
|
||||
}
|
||||
|
||||
PineTimeStyle::~PineTimeStyle() {
|
||||
lv_task_del(taskRefresh);
|
||||
lv_obj_clean(lv_scr_act());
|
||||
}
|
||||
|
||||
bool PineTimeStyle::Refresh() {
|
||||
void PineTimeStyle::Refresh() {
|
||||
batteryPercentRemaining = batteryController.PercentRemaining();
|
||||
if (batteryPercentRemaining.IsUpdated()) {
|
||||
auto batteryPercent = batteryPercentRemaining.Get();
|
||||
|
@ -335,6 +339,4 @@ bool PineTimeStyle::Refresh() {
|
|||
lv_obj_set_style_local_scale_grad_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
||||
}
|
||||
}
|
||||
|
||||
return running;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace Pinetime {
|
|||
Controllers::MotionController& motionController);
|
||||
~PineTimeStyle() override;
|
||||
|
||||
bool Refresh() override;
|
||||
void Refresh() override;
|
||||
|
||||
void OnObjectEvent(lv_obj_t* pObj, lv_event_t i);
|
||||
|
||||
|
@ -80,6 +80,8 @@ namespace Pinetime {
|
|||
Controllers::NotificationManager& notificatioManager;
|
||||
Controllers::Settings& settingsController;
|
||||
Controllers::MotionController& motionController;
|
||||
|
||||
lv_task_t* taskRefresh;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,2 +1,6 @@
|
|||
#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();
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <cstdint>
|
||||
#include "../TouchEvents.h"
|
||||
#include <lvgl/lvgl.h>
|
||||
|
||||
namespace Pinetime {
|
||||
namespace Applications {
|
||||
|
@ -34,25 +35,20 @@ namespace Pinetime {
|
|||
};
|
||||
|
||||
class Screen {
|
||||
private:
|
||||
virtual void Refresh() {
|
||||
}
|
||||
|
||||
public:
|
||||
explicit Screen(DisplayApp* app) : app {app} {
|
||||
}
|
||||
virtual ~Screen() = default;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* 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;
|
||||
static void RefreshTaskCallback(lv_task_t* task);
|
||||
|
||||
bool IsRunning() const {
|
||||
return running;
|
||||
}
|
||||
|
||||
/** @return false if the button hasn't been handled by the app, true if it has been handled */
|
||||
virtual bool OnButtonPushed() {
|
||||
|
|
|
@ -30,11 +30,6 @@ namespace Pinetime {
|
|||
lv_obj_clean(lv_scr_act());
|
||||
}
|
||||
|
||||
bool Refresh() override {
|
||||
running = current->Refresh();
|
||||
return running;
|
||||
}
|
||||
|
||||
bool OnTouchEvent(TouchEvents event) override {
|
||||
|
||||
if (mode == ScreenListModes::UpDown) {
|
||||
|
@ -110,4 +105,4 @@ namespace Pinetime {
|
|||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,20 +50,20 @@ Steps::Steps(
|
|||
lv_obj_set_size(backgroundLabel, 240, 240);
|
||||
lv_obj_set_pos(backgroundLabel, 0, 0);
|
||||
lv_label_set_text_static(backgroundLabel, "");
|
||||
|
||||
taskRefresh = lv_task_create(RefreshTaskCallback, 100, LV_TASK_PRIO_MID, this);
|
||||
}
|
||||
|
||||
Steps::~Steps() {
|
||||
lv_task_del(taskRefresh);
|
||||
lv_obj_clean(lv_scr_act());
|
||||
}
|
||||
|
||||
bool Steps::Refresh() {
|
||||
|
||||
void Steps::Refresh() {
|
||||
stepsCount = motionController.NbSteps();
|
||||
|
||||
|
||||
lv_label_set_text_fmt(lSteps, "%li", stepsCount);
|
||||
lv_obj_align(lSteps, nullptr, LV_ALIGN_CENTER, 0, -20);
|
||||
|
||||
lv_arc_set_value(stepsArc, int16_t(500 * stepsCount / settingsController.GetStepsGoal()));
|
||||
|
||||
return running;
|
||||
lv_arc_set_value(stepsArc, int16_t(500 * stepsCount / settingsController.GetStepsGoal()));
|
||||
}
|
||||
|
|
|
@ -15,24 +15,23 @@ namespace Pinetime {
|
|||
namespace Screens {
|
||||
|
||||
class Steps : public Screen {
|
||||
public:
|
||||
Steps(DisplayApp* app, Controllers::MotionController& motionController, Controllers::Settings &settingsController);
|
||||
~Steps() override;
|
||||
public:
|
||||
Steps(DisplayApp* app, Controllers::MotionController& motionController, Controllers::Settings& settingsController);
|
||||
~Steps() override;
|
||||
|
||||
bool Refresh() override;
|
||||
|
||||
void Refresh() override;
|
||||
|
||||
private:
|
||||
private:
|
||||
Controllers::MotionController& motionController;
|
||||
Controllers::Settings& settingsController;
|
||||
|
||||
Controllers::MotionController& motionController;
|
||||
Controllers::Settings& settingsController;
|
||||
lv_obj_t* lSteps;
|
||||
lv_obj_t* lStepsIcon;
|
||||
lv_obj_t* stepsArc;
|
||||
|
||||
lv_obj_t * lSteps;
|
||||
lv_obj_t * lStepsIcon;
|
||||
lv_obj_t * stepsArc;
|
||||
|
||||
uint32_t stepsCount;
|
||||
uint32_t stepsCount;
|
||||
|
||||
lv_task_t* taskRefresh;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
: Screen(app),
|
||||
systemTask {systemTask},
|
||||
running {true},
|
||||
currentState {States::Init},
|
||||
startTime {},
|
||||
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_align(lapTwoText, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 50, 55);
|
||||
lv_label_set_text(lapTwoText, "");
|
||||
|
||||
taskRefresh = lv_task_create(RefreshTaskCallback, 20, LV_TASK_PRIO_MID, this);
|
||||
}
|
||||
|
||||
StopWatch::~StopWatch() {
|
||||
lv_task_del(taskRefresh);
|
||||
systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
|
||||
lv_obj_clean(lv_scr_act());
|
||||
}
|
||||
|
@ -149,7 +151,7 @@ void StopWatch::pause() {
|
|||
systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
|
||||
}
|
||||
|
||||
bool StopWatch::Refresh() {
|
||||
void StopWatch::Refresh() {
|
||||
if (currentState == States::Running) {
|
||||
timeElapsed = calculateDelta(startTime, xTaskGetTickCount());
|
||||
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(msecTime, "%02d", currentTimeSeparated.hundredths);
|
||||
}
|
||||
return running;
|
||||
}
|
||||
|
||||
void StopWatch::playPauseBtnEventHandler(lv_event_t event) {
|
||||
|
@ -196,8 +197,7 @@ void StopWatch::stopLapBtnEventHandler(lv_event_t event) {
|
|||
bool StopWatch::OnButtonPushed() {
|
||||
if (currentState == States::Running) {
|
||||
pause();
|
||||
} else {
|
||||
running = false;
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ namespace Pinetime::Applications::Screens {
|
|||
public:
|
||||
StopWatch(DisplayApp* app, System::SystemTask& systemTask);
|
||||
~StopWatch() override;
|
||||
bool Refresh() override;
|
||||
void Refresh() override;
|
||||
|
||||
void playPauseBtnEventHandler(lv_event_t event);
|
||||
void stopLapBtnEventHandler(lv_event_t event);
|
||||
|
@ -77,7 +77,6 @@ namespace Pinetime::Applications::Screens {
|
|||
private:
|
||||
Pinetime::System::SystemTask& systemTask;
|
||||
TickType_t timeElapsed;
|
||||
bool running;
|
||||
States currentState;
|
||||
TickType_t startTime;
|
||||
TickType_t oldTimeElapsed;
|
||||
|
@ -86,5 +85,7 @@ namespace Pinetime::Applications::Screens {
|
|||
int lapNr = 0;
|
||||
lv_obj_t *time, *msecTime, *btnPlayPause, *btnStopLap, *txtPlayPause, *txtStopLap;
|
||||
lv_obj_t *lapOneText, *lapTwoText;
|
||||
|
||||
lv_task_t* taskRefresh;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -63,13 +63,6 @@ SystemInfo::~SystemInfo() {
|
|||
lv_obj_clean(lv_scr_act());
|
||||
}
|
||||
|
||||
bool SystemInfo::Refresh() {
|
||||
if (running) {
|
||||
screens.Refresh();
|
||||
}
|
||||
return running;
|
||||
}
|
||||
|
||||
bool SystemInfo::OnButtonPushed() {
|
||||
running = false;
|
||||
return true;
|
||||
|
|
|
@ -30,7 +30,6 @@ namespace Pinetime {
|
|||
Pinetime::Drivers::WatchdogView& watchdog,
|
||||
Pinetime::Controllers::MotionController& motionController);
|
||||
~SystemInfo() override;
|
||||
bool Refresh() override;
|
||||
bool OnButtonPushed() override;
|
||||
bool OnTouchEvent(TouchEvents event) override;
|
||||
|
||||
|
@ -56,4 +55,4 @@ namespace Pinetime {
|
|||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,10 +120,6 @@ void Tile::UpdateScreen() {
|
|||
lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryController.PercentRemaining()));
|
||||
}
|
||||
|
||||
bool Tile::Refresh() {
|
||||
return running;
|
||||
}
|
||||
|
||||
void Tile::OnObjectEvent(lv_obj_t* obj, lv_event_t event, uint32_t buttonId) {
|
||||
if (event == LV_EVENT_VALUE_CHANGED) {
|
||||
app->StartApp(apps[buttonId], DisplayApp::FullRefreshDirections::Up);
|
||||
|
|
|
@ -30,7 +30,6 @@ namespace Pinetime {
|
|||
|
||||
~Tile() override;
|
||||
|
||||
bool Refresh() override;
|
||||
void UpdateScreen();
|
||||
void OnObjectEvent(lv_obj_t* obj, lv_event_t event, uint32_t buttonId);
|
||||
|
||||
|
|
|
@ -4,10 +4,8 @@
|
|||
#include "Symbols.h"
|
||||
#include "lvgl/lvgl.h"
|
||||
|
||||
|
||||
using namespace Pinetime::Applications::Screens;
|
||||
|
||||
|
||||
static void btnEventHandler(lv_obj_t* obj, lv_event_t event) {
|
||||
Timer* screen = static_cast<Timer*>(obj->user_data);
|
||||
screen->OnButtonEvent(obj, event);
|
||||
|
@ -22,7 +20,7 @@ void Timer::createButtons() {
|
|||
lv_obj_set_width(btnMinutesUp, 60);
|
||||
txtMUp = lv_label_create(btnMinutesUp, nullptr);
|
||||
lv_label_set_text(txtMUp, "+");
|
||||
|
||||
|
||||
btnMinutesDown = lv_btn_create(lv_scr_act(), nullptr);
|
||||
btnMinutesDown->user_data = this;
|
||||
lv_obj_set_event_cb(btnMinutesDown, btnEventHandler);
|
||||
|
@ -31,7 +29,7 @@ void Timer::createButtons() {
|
|||
lv_obj_set_width(btnMinutesDown, 60);
|
||||
txtMDown = lv_label_create(btnMinutesDown, nullptr);
|
||||
lv_label_set_text(txtMDown, "-");
|
||||
|
||||
|
||||
btnSecondsUp = lv_btn_create(lv_scr_act(), nullptr);
|
||||
btnSecondsUp->user_data = this;
|
||||
lv_obj_set_event_cb(btnSecondsUp, btnEventHandler);
|
||||
|
@ -40,7 +38,7 @@ void Timer::createButtons() {
|
|||
lv_obj_set_width(btnSecondsUp, 60);
|
||||
txtSUp = lv_label_create(btnSecondsUp, nullptr);
|
||||
lv_label_set_text(txtSUp, "+");
|
||||
|
||||
|
||||
btnSecondsDown = lv_btn_create(lv_scr_act(), nullptr);
|
||||
btnSecondsDown->user_data = this;
|
||||
lv_obj_set_event_cb(btnSecondsDown, btnEventHandler);
|
||||
|
@ -49,24 +47,20 @@ void Timer::createButtons() {
|
|||
lv_obj_set_width(btnSecondsDown, 60);
|
||||
txtSDown = lv_label_create(btnSecondsDown, nullptr);
|
||||
lv_label_set_text(txtSDown, "-");
|
||||
|
||||
}
|
||||
|
||||
|
||||
Timer::Timer(DisplayApp* app, Controllers::TimerController& timerController)
|
||||
: Screen(app),
|
||||
running{true},
|
||||
timerController{timerController} {
|
||||
|
||||
: Screen(app), running {true}, timerController {timerController} {
|
||||
|
||||
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_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
|
||||
|
||||
|
||||
uint32_t seconds = timerController.GetTimeRemaining() / 1000;
|
||||
lv_label_set_text_fmt(time, "%02lu:%02lu", seconds / 60, seconds % 60);
|
||||
|
||||
lv_obj_align(time, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -20);
|
||||
|
||||
|
||||
btnPlayPause = lv_btn_create(lv_scr_act(), nullptr);
|
||||
btnPlayPause->user_data = this;
|
||||
lv_obj_set_event_cb(btnPlayPause, btnEventHandler);
|
||||
|
@ -79,20 +73,20 @@ Timer::Timer(DisplayApp* app, Controllers::TimerController& timerController)
|
|||
lv_label_set_text(txtPlayPause, Symbols::play);
|
||||
createButtons();
|
||||
}
|
||||
|
||||
|
||||
taskRefresh = lv_task_create(RefreshTaskCallback, 20, LV_TASK_PRIO_MID, this);
|
||||
}
|
||||
|
||||
Timer::~Timer() {
|
||||
lv_task_del(taskRefresh);
|
||||
lv_obj_clean(lv_scr_act());
|
||||
|
||||
}
|
||||
|
||||
bool Timer::Refresh() {
|
||||
void Timer::Refresh() {
|
||||
if (timerController.IsRunning()) {
|
||||
uint32_t seconds = timerController.GetTimeRemaining() / 1000;
|
||||
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) {
|
||||
|
@ -105,11 +99,11 @@ void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
|
|||
secondsToSet = seconds % 60;
|
||||
timerController.StopTimer();
|
||||
createButtons();
|
||||
|
||||
|
||||
} else if (secondsToSet + minutesToSet > 0) {
|
||||
lv_label_set_text(txtPlayPause, Symbols::pause);
|
||||
timerController.StartTimer((secondsToSet + minutesToSet * 60) * 1000);
|
||||
|
||||
|
||||
lv_obj_del(btnSecondsDown);
|
||||
btnSecondsDown = nullptr;
|
||||
lv_obj_del(btnSecondsUp);
|
||||
|
@ -118,7 +112,6 @@ void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
|
|||
btnMinutesDown = nullptr;
|
||||
lv_obj_del(btnMinutesUp);
|
||||
btnMinutesUp = nullptr;
|
||||
|
||||
}
|
||||
} else {
|
||||
if (!timerController.IsRunning()) {
|
||||
|
@ -129,7 +122,7 @@ void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
|
|||
minutesToSet++;
|
||||
}
|
||||
lv_label_set_text_fmt(time, "%02d:%02d", minutesToSet, secondsToSet);
|
||||
|
||||
|
||||
} else if (obj == btnMinutesDown) {
|
||||
if (minutesToSet == 0) {
|
||||
minutesToSet = 59;
|
||||
|
@ -137,7 +130,7 @@ void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
|
|||
minutesToSet--;
|
||||
}
|
||||
lv_label_set_text_fmt(time, "%02d:%02d", minutesToSet, secondsToSet);
|
||||
|
||||
|
||||
} else if (obj == btnSecondsUp) {
|
||||
if (secondsToSet >= 59) {
|
||||
secondsToSet = 0;
|
||||
|
@ -145,7 +138,7 @@ void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
|
|||
secondsToSet++;
|
||||
}
|
||||
lv_label_set_text_fmt(time, "%02d:%02d", minutesToSet, secondsToSet);
|
||||
|
||||
|
||||
} else if (obj == btnSecondsDown) {
|
||||
if (secondsToSet == 0) {
|
||||
secondsToSet = 59;
|
||||
|
@ -153,21 +146,16 @@ void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
|
|||
secondsToSet--;
|
||||
}
|
||||
lv_label_set_text_fmt(time, "%02d:%02d", minutesToSet, secondsToSet);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Timer::setDone() {
|
||||
lv_label_set_text(time, "00:00");
|
||||
lv_label_set_text(txtPlayPause, Symbols::play);
|
||||
secondsToSet = 0;
|
||||
minutesToSet = 0;
|
||||
createButtons();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,35 +8,32 @@
|
|||
#include "components/timer/TimerController.h"
|
||||
|
||||
namespace Pinetime::Applications::Screens {
|
||||
|
||||
|
||||
|
||||
class Timer : public Screen {
|
||||
public:
|
||||
|
||||
enum class Modes {
|
||||
Normal, Done
|
||||
};
|
||||
|
||||
enum class Modes { Normal, Done };
|
||||
|
||||
Timer(DisplayApp* app, Controllers::TimerController& timerController);
|
||||
|
||||
|
||||
~Timer() override;
|
||||
|
||||
bool Refresh() override;
|
||||
|
||||
|
||||
void Refresh() override;
|
||||
|
||||
void setDone();
|
||||
|
||||
|
||||
void OnButtonEvent(lv_obj_t* obj, lv_event_t event);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
bool running;
|
||||
uint8_t secondsToSet = 0;
|
||||
uint8_t minutesToSet = 0;
|
||||
Controllers::TimerController& timerController;
|
||||
|
||||
|
||||
void createButtons();
|
||||
|
||||
lv_obj_t* time, * msecTime, * btnPlayPause, * txtPlayPause, * btnMinutesUp, * btnMinutesDown, * btnSecondsUp, * btnSecondsDown, * txtMUp,
|
||||
* txtMDown, * txtSUp, * txtSDown;
|
||||
|
||||
lv_obj_t *time, *msecTime, *btnPlayPause, *txtPlayPause, *btnMinutesUp, *btnMinutesDown, *btnSecondsUp, *btnSecondsDown, *txtMUp,
|
||||
*txtMDown, *txtSUp, *txtSDown;
|
||||
|
||||
lv_task_t* taskRefresh;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,10 +102,6 @@ Twos::~Twos() {
|
|||
lv_obj_clean(lv_scr_act());
|
||||
}
|
||||
|
||||
bool Twos::Refresh() {
|
||||
return running;
|
||||
}
|
||||
|
||||
bool Twos::placeNewTile() {
|
||||
std::vector<std::pair<int, int>> availableCells;
|
||||
for (int row = 0; row < 4; row++) {
|
||||
|
@ -295,4 +291,4 @@ void Twos::updateGridDisplay(Tile grid[][4]) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ namespace Pinetime {
|
|||
public:
|
||||
Twos(DisplayApp* app);
|
||||
~Twos() override;
|
||||
bool Refresh() override;
|
||||
|
||||
bool OnTouchEvent(TouchEvents event) override;
|
||||
|
||||
|
@ -36,4 +35,4 @@ namespace Pinetime {
|
|||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -119,10 +119,12 @@ WatchFaceAnalog::WatchFaceAnalog(Pinetime::Applications::DisplayApp* app,
|
|||
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);
|
||||
|
||||
taskRefresh = lv_task_create(RefreshTaskCallback, 20, LV_TASK_PRIO_MID, this);
|
||||
UpdateClock();
|
||||
}
|
||||
|
||||
WatchFaceAnalog::~WatchFaceAnalog() {
|
||||
lv_task_del(taskRefresh);
|
||||
|
||||
lv_style_reset(&hour_line_style);
|
||||
lv_style_reset(&hour_line_style_trace);
|
||||
|
@ -176,7 +178,7 @@ void WatchFaceAnalog::UpdateClock() {
|
|||
}
|
||||
}
|
||||
|
||||
bool WatchFaceAnalog::Refresh() {
|
||||
void WatchFaceAnalog::Refresh() {
|
||||
batteryPercentRemaining = batteryController.PercentRemaining();
|
||||
if (batteryPercentRemaining.IsUpdated()) {
|
||||
auto batteryPercent = batteryPercentRemaining.Get();
|
||||
|
@ -211,6 +213,4 @@ bool WatchFaceAnalog::Refresh() {
|
|||
currentDay = day;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace Pinetime {
|
|||
|
||||
~WatchFaceAnalog() override;
|
||||
|
||||
bool Refresh() override;
|
||||
void Refresh() override;
|
||||
|
||||
private:
|
||||
uint8_t sHour, sMinute, sSecond;
|
||||
|
@ -83,6 +83,8 @@ namespace Pinetime {
|
|||
Controllers::Settings& settingsController;
|
||||
|
||||
void UpdateClock();
|
||||
|
||||
lv_task_t* taskRefresh;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,13 +100,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_label_set_text(stepIcon, Symbols::shoe);
|
||||
lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0);
|
||||
|
||||
taskRefresh = lv_task_create(RefreshTaskCallback, 20, LV_TASK_PRIO_MID, this);
|
||||
Refresh();
|
||||
}
|
||||
|
||||
WatchFaceDigital::~WatchFaceDigital() {
|
||||
lv_task_del(taskRefresh);
|
||||
lv_obj_clean(lv_scr_act());
|
||||
}
|
||||
|
||||
bool WatchFaceDigital::Refresh() {
|
||||
void WatchFaceDigital::Refresh() {
|
||||
batteryPercentRemaining = batteryController.PercentRemaining();
|
||||
if (batteryPercentRemaining.IsUpdated()) {
|
||||
auto batteryPercent = batteryPercentRemaining.Get();
|
||||
|
@ -240,6 +244,4 @@ bool WatchFaceDigital::Refresh() {
|
|||
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, -5, -2);
|
||||
lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0);
|
||||
}
|
||||
|
||||
return running;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace Pinetime {
|
|||
Controllers::MotionController& motionController);
|
||||
~WatchFaceDigital() override;
|
||||
|
||||
bool Refresh() override;
|
||||
void Refresh() override;
|
||||
|
||||
void OnObjectEvent(lv_obj_t* pObj, lv_event_t i);
|
||||
|
||||
|
@ -75,6 +75,8 @@ namespace Pinetime {
|
|||
Controllers::Settings& settingsController;
|
||||
Controllers::HeartRateController& heartRateController;
|
||||
Controllers::MotionController& motionController;
|
||||
|
||||
lv_task_t* taskRefresh;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -164,7 +164,3 @@ bool QuickSettings::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool QuickSettings::Refresh() {
|
||||
return running;
|
||||
}
|
||||
|
|
|
@ -27,8 +27,6 @@ namespace Pinetime {
|
|||
|
||||
~QuickSettings() override;
|
||||
|
||||
bool Refresh() override;
|
||||
|
||||
bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override;
|
||||
void OnButtonEvent(lv_obj_t* object, lv_event_t event);
|
||||
|
||||
|
|
|
@ -80,10 +80,6 @@ SettingDisplay::~SettingDisplay() {
|
|||
settingsController.SaveSettings();
|
||||
}
|
||||
|
||||
bool SettingDisplay::Refresh() {
|
||||
return running;
|
||||
}
|
||||
|
||||
void SettingDisplay::UpdateSelected(lv_obj_t* object, lv_event_t event) {
|
||||
if (event == LV_EVENT_VALUE_CHANGED) {
|
||||
for (int i = 0; i < optionsTotal; i++) {
|
||||
|
@ -110,4 +106,4 @@ void SettingDisplay::UpdateSelected(lv_obj_t* object, lv_event_t event) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ namespace Pinetime {
|
|||
SettingDisplay(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
|
||||
~SettingDisplay() override;
|
||||
|
||||
bool Refresh() override;
|
||||
void UpdateSelected(lv_obj_t* object, lv_event_t event);
|
||||
|
||||
private:
|
||||
|
|
|
@ -70,11 +70,6 @@ SettingSteps::~SettingSteps() {
|
|||
settingsController.SaveSettings();
|
||||
}
|
||||
|
||||
bool SettingSteps::Refresh() {
|
||||
return running;
|
||||
}
|
||||
|
||||
|
||||
void SettingSteps::UpdateSelected(lv_obj_t *object, lv_event_t event) {
|
||||
uint32_t value = settingsController.GetStepsGoal();
|
||||
if(object == btnPlus && (event == LV_EVENT_PRESSED)) {
|
||||
|
@ -95,4 +90,4 @@ void SettingSteps::UpdateSelected(lv_obj_t *object, lv_event_t event) {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,22 +10,19 @@ namespace Pinetime {
|
|||
namespace Applications {
|
||||
namespace Screens {
|
||||
|
||||
class SettingSteps : public Screen{
|
||||
public:
|
||||
SettingSteps(DisplayApp* app, Pinetime::Controllers::Settings &settingsController);
|
||||
~SettingSteps() override;
|
||||
class SettingSteps : public Screen {
|
||||
public:
|
||||
SettingSteps(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
|
||||
~SettingSteps() override;
|
||||
|
||||
bool Refresh() override;
|
||||
void UpdateSelected(lv_obj_t *object, lv_event_t event);
|
||||
|
||||
private:
|
||||
void UpdateSelected(lv_obj_t* object, lv_event_t event);
|
||||
|
||||
Controllers::Settings& settingsController;
|
||||
private:
|
||||
Controllers::Settings& settingsController;
|
||||
|
||||
lv_obj_t * stepValue;
|
||||
lv_obj_t * btnPlus;
|
||||
lv_obj_t * btnMinus;
|
||||
|
||||
lv_obj_t* stepValue;
|
||||
lv_obj_t* btnPlus;
|
||||
lv_obj_t* btnMinus;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,10 +64,6 @@ SettingTimeFormat::~SettingTimeFormat() {
|
|||
settingsController.SaveSettings();
|
||||
}
|
||||
|
||||
bool SettingTimeFormat::Refresh() {
|
||||
return running;
|
||||
}
|
||||
|
||||
void SettingTimeFormat::UpdateSelected(lv_obj_t* object, lv_event_t event) {
|
||||
if (event == LV_EVENT_VALUE_CHANGED) {
|
||||
for (int i = 0; i < optionsTotal; i++) {
|
||||
|
@ -86,4 +82,4 @@ void SettingTimeFormat::UpdateSelected(lv_obj_t* object, lv_event_t event) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ namespace Pinetime {
|
|||
SettingTimeFormat(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
|
||||
~SettingTimeFormat() override;
|
||||
|
||||
bool Refresh() override;
|
||||
void UpdateSelected(lv_obj_t* object, lv_event_t event);
|
||||
|
||||
private:
|
||||
|
|
|
@ -72,10 +72,6 @@ SettingWakeUp::~SettingWakeUp() {
|
|||
settingsController.SaveSettings();
|
||||
}
|
||||
|
||||
bool SettingWakeUp::Refresh() {
|
||||
return running;
|
||||
}
|
||||
|
||||
void SettingWakeUp::UpdateSelected(lv_obj_t* object, lv_event_t event) {
|
||||
using WakeUpMode = Pinetime::Controllers::Settings::WakeUpMode;
|
||||
if (event == LV_EVENT_VALUE_CHANGED && !ignoringEvents) {
|
||||
|
|
|
@ -15,7 +15,6 @@ namespace Pinetime {
|
|||
SettingWakeUp(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
|
||||
~SettingWakeUp() override;
|
||||
|
||||
bool Refresh() override;
|
||||
void UpdateSelected(lv_obj_t* object, lv_event_t event);
|
||||
|
||||
private:
|
||||
|
|
|
@ -75,10 +75,6 @@ SettingWatchFace::~SettingWatchFace() {
|
|||
settingsController.SaveSettings();
|
||||
}
|
||||
|
||||
bool SettingWatchFace::Refresh() {
|
||||
return running;
|
||||
}
|
||||
|
||||
void SettingWatchFace::UpdateSelected(lv_obj_t* object, lv_event_t event) {
|
||||
if (event == LV_EVENT_VALUE_CHANGED) {
|
||||
for (uint8_t i = 0; i < optionsTotal; i++) {
|
||||
|
@ -90,4 +86,4 @@ void SettingWatchFace::UpdateSelected(lv_obj_t* object, lv_event_t event) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ namespace Pinetime {
|
|||
SettingWatchFace(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
|
||||
~SettingWatchFace() override;
|
||||
|
||||
bool Refresh() override;
|
||||
void UpdateSelected(lv_obj_t* object, lv_event_t event);
|
||||
|
||||
private:
|
||||
|
|
|
@ -26,13 +26,6 @@ Settings::~Settings() {
|
|||
lv_obj_clean(lv_scr_act());
|
||||
}
|
||||
|
||||
bool Settings::Refresh() {
|
||||
|
||||
if (running)
|
||||
running = screens.Refresh();
|
||||
return running;
|
||||
}
|
||||
|
||||
bool Settings::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
||||
return screens.OnTouchEvent(event);
|
||||
}
|
||||
|
|
|
@ -14,8 +14,6 @@ namespace Pinetime {
|
|||
Settings(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
|
||||
~Settings() override;
|
||||
|
||||
bool Refresh() override;
|
||||
|
||||
bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override;
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue
Block a user