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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions src/displayapp/screens/BatteryInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,23 @@ BatteryInfo::BatteryInfo(const Pinetime::Controllers::Battery& batteryController
lv_obj_set_style_local_line_color(chargingArc, LV_ARC_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_LIME);

status = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_text_static(status, "Reading Battery status");
lv_label_set_align(status, LV_LABEL_ALIGN_CENTER);
lv_obj_align(status, nullptr, LV_ALIGN_IN_BOTTOM_MID, 0, -17);
lv_obj_align(status, voltage, LV_ALIGN_IN_BOTTOM_MID, 0, -27);
lv_obj_set_auto_realign(status, true);

percent = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(percent, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42);
lv_label_set_text_fmt(percent, "%i%%", batteryPercent);
lv_label_set_align(percent, LV_LABEL_ALIGN_LEFT);
lv_obj_align(percent, chargingArc, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_auto_realign(percent, true);

voltage = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(voltage, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::orange);
lv_label_set_text_fmt(voltage, "%1i.%02i volts", batteryVoltage / 1000, batteryVoltage % 1000 / 10);
lv_label_set_align(voltage, LV_LABEL_ALIGN_CENTER);
lv_obj_align(voltage, nullptr, LV_ALIGN_IN_BOTTOM_MID, 0, -7);

taskRefresh = lv_task_create(RefreshTaskCallback, 5000, LV_TASK_PRIO_MID, this);
Refresh();
taskRefresh = lv_task_create(RefreshTaskCallback, 5000, LV_TASK_PRIO_MID, this);
}

BatteryInfo::~BatteryInfo() {
Expand Down Expand Up @@ -72,9 +71,6 @@ void BatteryInfo::Refresh() {
}

lv_label_set_text_fmt(percent, "%i%%", batteryPercent);
lv_obj_align(percent, chargingArc, LV_ALIGN_CENTER, 0, 0);

lv_obj_align(status, voltage, LV_ALIGN_IN_BOTTOM_MID, 0, -27);
lv_label_set_text_fmt(voltage, "%1i.%02i volts", batteryVoltage / 1000, batteryVoltage % 1000 / 10);
lv_arc_set_value(chargingArc, batteryPercent);
}
13 changes: 2 additions & 11 deletions src/displayapp/screens/Dice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,20 +123,11 @@ Dice::Dice(Controllers::MotionController& motionController,
0,
0);

// Spagetti code in motion controller: it only updates the shake speed when shake to wake is on...
enableShakeForDice = !settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::Shake);
if (enableShakeForDice) {
settingsController.setWakeUpMode(Pinetime::Controllers::Settings::WakeUpMode::Shake, true);
}
Refresh();
refreshTask = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
}

Dice::~Dice() {
// reset the shake to wake mode.
if (enableShakeForDice) {
settingsController.setWakeUpMode(Pinetime::Controllers::Settings::WakeUpMode::Shake, false);
enableShakeForDice = false;
}
lv_task_del(refreshTask);
lv_obj_clean(lv_scr_act());
}
Expand Down Expand Up @@ -185,7 +176,7 @@ void Dice::Roll() {
}

lv_label_set_text_fmt(resultTotalLabel, "%d", resultTotal);
if (openingRoll == false) {
if (!openingRoll) {
motorController.RunForDuration(30);
NextColor();
currentRollHysteresis = rollHysteresis;
Expand Down
1 change: 0 additions & 1 deletion src/displayapp/screens/Dice.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ namespace Pinetime {
lv_obj_t* resultTotalLabel;
lv_obj_t* resultIndividualLabel;
lv_task_t* refreshTask;
bool enableShakeForDice = false;

std::mt19937 gen;

Expand Down
4 changes: 3 additions & 1 deletion src/displayapp/screens/FirmwareUpdate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ FirmwareUpdate::FirmwareUpdate(const Pinetime::Controllers::Ble& bleController)
lv_label_set_recolor(percentLabel, true);
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);

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

FirmwareUpdate::~FirmwareUpdate() {
Expand Down
10 changes: 3 additions & 7 deletions src/displayapp/screens/HeartRate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,23 @@ HeartRate::HeartRate(Controllers::HeartRateController& heartRateController, Syst
: heartRateController {heartRateController}, wakeLock(systemTask) {
bool isHrRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped;
label_hr = lv_label_create(lv_scr_act(), nullptr);

lv_obj_set_style_local_text_font(label_hr, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76);

if (isHrRunning) {
lv_obj_set_style_local_text_color(label_hr, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::highlight);
} else {
lv_obj_set_style_local_text_color(label_hr, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray);
}

lv_label_set_text_static(label_hr, "---");
lv_obj_align(label_hr, nullptr, LV_ALIGN_CENTER, 0, -40);
lv_obj_set_auto_realign(label_hr, true);

label_bpm = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_text_static(label_bpm, "Heart rate BPM");
lv_obj_align(label_bpm, label_hr, LV_ALIGN_OUT_TOP_MID, 0, -20);

label_status = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(label_status, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
lv_label_set_text_static(label_status, ToString(Pinetime::Controllers::HeartRateController::States::NotEnoughData));

lv_obj_align(label_status, label_hr, LV_ALIGN_OUT_BOTTOM_MID, 0, 10);
lv_obj_set_auto_realign(label_status, true);

btn_startStop = lv_btn_create(lv_scr_act(), nullptr);
btn_startStop->user_data = this;
Expand All @@ -66,6 +62,7 @@ HeartRate::HeartRate(Controllers::HeartRateController& heartRateController, Syst
wakeLock.Lock();
}

Refresh();
taskRefresh = lv_task_create(RefreshTaskCallback, 100, LV_TASK_PRIO_MID, this);
}

Expand All @@ -92,7 +89,6 @@ void HeartRate::Refresh() {
}

lv_label_set_text_static(label_status, ToString(state));
lv_obj_align(label_status, label_hr, LV_ALIGN_OUT_BOTTOM_MID, 0, 10);
}

void HeartRate::OnStartStopEvent(lv_event_t event) {
Expand Down
1 change: 1 addition & 0 deletions src/displayapp/screens/Metronome.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ Metronome::Metronome(Controllers::MotorController& motorController, System::Syst
lblPlayPause = lv_label_create(playPause, nullptr);
lv_label_set_text_static(lblPlayPause, Symbols::play);

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

Expand Down
3 changes: 1 addition & 2 deletions src/displayapp/screens/Motion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,14 @@ Motion::Motion(Controllers::MotionController& motionController) : motionControll
lv_chart_refresh(chart); /*Required after direct set*/

label = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_text_fmt(label, "X #FF0000 %d# Y #00B000 %d# Z #FFFF00 %d#", 0, 0, 0);
lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
lv_obj_align(label, nullptr, LV_ALIGN_IN_TOP_MID, 0, 10);
lv_label_set_recolor(label, true);

labelStep = lv_label_create(lv_scr_act(), nullptr);
lv_obj_align(labelStep, chart, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
lv_label_set_text_static(labelStep, "Steps ---");

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

Expand Down
15 changes: 6 additions & 9 deletions src/displayapp/screens/Music.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ Music::Music(Pinetime::Controllers::MusicService& music) : musicService(music) {
txtTrackDuration = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_long_mode(txtTrackDuration, LV_LABEL_LONG_SROLL);
lv_obj_align(txtTrackDuration, nullptr, LV_ALIGN_IN_TOP_LEFT, 12, 20);
lv_label_set_text_static(txtTrackDuration, "--:--/--:--");
lv_label_set_align(txtTrackDuration, LV_ALIGN_IN_LEFT_MID);
lv_obj_set_width(txtTrackDuration, LV_HOR_RES);

Expand Down Expand Up @@ -142,6 +141,7 @@ Music::Music(Pinetime::Controllers::MusicService& music) : musicService(music) {

musicService.event(Controllers::MusicService::EVENT_MUSIC_OPEN);

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

Expand All @@ -168,6 +168,11 @@ void Music::Refresh() {

if (playing != musicService.isPlaying()) {
playing = musicService.isPlaying();
if (playing) {
lv_label_set_text_static(txtPlayPause, Symbols::pause);
} else {
lv_label_set_text_static(txtPlayPause, Symbols::play);
}
}

if (currentPosition != musicService.getProgress()) {
Expand All @@ -181,7 +186,6 @@ void Music::Refresh() {
}

if (playing) {
lv_label_set_text_static(txtPlayPause, Symbols::pause);
if (xTaskGetTickCount() - 1024 >= lastIncrement) {

if (frameB) {
Expand All @@ -191,15 +195,8 @@ void Music::Refresh() {
}
frameB = !frameB;

if (currentPosition >= totalLength) {
// Let's assume the getTrack finished, paused when the timer ends
// and there's no new getTrack being sent to us
playing = false;
}
lastIncrement = xTaskGetTickCount();
}
} else {
lv_label_set_text_static(txtPlayPause, Symbols::play);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/displayapp/screens/Navigation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ Navigation::Navigation(Pinetime::Controllers::NavigationService& nav) : navServi
lv_bar_set_range(barProgress, 0, 100);
lv_bar_set_value(barProgress, 0, LV_ANIM_OFF);

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

Expand Down
1 change: 1 addition & 0 deletions src/displayapp/screens/Notifications.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Notifications::Notifications(DisplayApp* app,
interacted = false;
}

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

Expand Down
3 changes: 2 additions & 1 deletion src/displayapp/screens/Paddle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ Paddle::Paddle(Pinetime::Components::LittleVgl& lvgl) : lvgl {lvgl} {

points = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(points, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42);
lv_label_set_text_static(points, "0000");
lv_obj_align(points, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 0, 10);
lv_obj_set_auto_realign(points, true);

paddle = lv_obj_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_bg_color(paddle, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
Expand All @@ -30,6 +30,7 @@ Paddle::Paddle(Pinetime::Components::LittleVgl& lvgl) : lvgl {lvgl} {
lv_obj_set_style_local_radius(ball, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
lv_obj_set_size(ball, ballSize, ballSize);

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

Expand Down
14 changes: 4 additions & 10 deletions src/displayapp/screens/Steps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ using namespace Pinetime::Applications::Screens;

using Days = Pinetime::Controllers::MotionController::Days;

namespace {
constexpr const char* yesterdayStr = "Yest: %5lu";
}

static void lap_event_handler(lv_obj_t* obj, lv_event_t event) {
auto* steps = static_cast<Steps*>(obj->user_data);
steps->lapBtnEventHandler(event);
Expand Down Expand Up @@ -39,8 +35,8 @@ Steps::Steps(Controllers::MotionController& motionController, Controllers::Setti
lSteps = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(lSteps, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_LIME);
lv_obj_set_style_local_text_font(lSteps, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42);
lv_label_set_text_fmt(lSteps, "%lu", stepsCount);
lv_obj_align(lSteps, nullptr, LV_ALIGN_CENTER, 0, -40);
lv_obj_set_auto_realign(lSteps, true);

lv_obj_t* lstepsL = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(lstepsL, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray);
Expand All @@ -49,9 +45,9 @@ Steps::Steps(Controllers::MotionController& motionController, Controllers::Setti

lStepsYesterday = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(lStepsYesterday, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray);
lv_label_set_text_fmt(lStepsYesterday, yesterdayStr, motionController.NbSteps(Days::Yesterday));
lv_label_set_align(lStepsYesterday, LV_LABEL_ALIGN_CENTER);
lv_obj_align(lStepsYesterday, lSteps, LV_ALIGN_OUT_BOTTOM_MID, 0, 20);
lv_obj_set_auto_realign(lStepsYesterday, true);

lv_obj_t* lstepsGoal = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(lstepsGoal, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_CYAN);
Expand All @@ -73,9 +69,9 @@ Steps::Steps(Controllers::MotionController& motionController, Controllers::Setti

tripLabel = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(tripLabel, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_YELLOW);
lv_label_set_text_fmt(tripLabel, "Trip: %5li", currentTripSteps);
lv_obj_align(tripLabel, lstepsGoal, LV_ALIGN_IN_LEFT_MID, 0, 20);

Refresh();
taskRefresh = lv_task_create(RefreshTaskCallback, 100, LV_TASK_PRIO_MID, this);
}

Expand All @@ -89,10 +85,8 @@ void Steps::Refresh() {
currentTripSteps = motionController.GetTripSteps();

lv_label_set_text_fmt(lSteps, "%lu", stepsCount);
lv_obj_align(lSteps, nullptr, LV_ALIGN_CENTER, 0, -40);

lv_label_set_text_fmt(lStepsYesterday, yesterdayStr, motionController.NbSteps(Days::Yesterday));
lv_obj_align(lSteps, nullptr, LV_ALIGN_CENTER, 0, -40);
lv_label_set_text_fmt(lStepsYesterday, "Yest: %5lu", motionController.NbSteps(Days::Yesterday));

if (currentTripSteps < 100000) {
lv_label_set_text_fmt(tripLabel, "Trip: %5li", currentTripSteps);
Expand Down
12 changes: 4 additions & 8 deletions src/displayapp/screens/StopWatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ StopWatch::StopWatch(System::SystemTask& systemTask, StopWatchController& stopWa

lapText = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(lapText, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray);
lv_label_set_text_static(lapText, "");
lv_label_set_long_mode(lapText, LV_LABEL_LONG_BREAK);
lv_label_set_align(lapText, LV_LABEL_ALIGN_CENTER);
lv_obj_set_width(lapText, LV_HOR_RES_MAX);
Expand All @@ -66,26 +65,21 @@ StopWatch::StopWatch(System::SystemTask& systemTask, StopWatchController& stopWa
time = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DISABLED, Colors::lightGray);
lv_obj_set_style_local_text_font(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76);
lv_label_set_text_static(time, "00:00");
lv_label_set_long_mode(time, LV_LABEL_LONG_CROP);
lv_label_set_align(time, LV_LABEL_ALIGN_CENTER);
lv_obj_set_width(time, LV_HOR_RES_MAX);
lv_obj_align(time, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 0, 0);

msecTime = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(msecTime, LV_LABEL_PART_MAIN, LV_STATE_DISABLED, Colors::lightGray);
lv_label_set_text_static(msecTime, "00");
lv_obj_align(msecTime, time, LV_ALIGN_OUT_BOTTOM_MID, 0, -2);

taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
lv_obj_set_auto_realign(msecTime, true);

// Figure out what the current state of the stopwatch is and select the correct display
if (stopWatchController.IsCleared()) {
DisplayCleared();
} else {
if (stopWatchController.GetMaxLapNumber() > 0) {
RenderLaps();
}
RenderLaps();
RenderTime();

if (stopWatchController.IsRunning()) {
Expand All @@ -99,6 +93,8 @@ StopWatch::StopWatch(System::SystemTask& systemTask, StopWatchController& stopWa
DisplayPaused();
}
}

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

StopWatch::~StopWatch() {
Expand Down
1 change: 1 addition & 0 deletions src/displayapp/screens/Timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Timer::Timer(Controllers::Timer& timerController, Controllers::MotorController&
SetTimerStopped();
}

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

Expand Down
4 changes: 1 addition & 3 deletions src/displayapp/screens/WatchFaceAnalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController,

notificationIcon = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_LIME);
lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(false));
lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0);

// Date - Day / Week day
Expand Down Expand Up @@ -157,9 +156,8 @@ WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController,
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, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);

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

WatchFaceAnalog::~WatchFaceAnalog() {
Expand Down
Loading