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
4 changes: 3 additions & 1 deletion src/displayapp/screens/StopWatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using namespace Pinetime::Applications::Screens;
using namespace Pinetime::Controllers;

namespace {
namespace Pinetime::Applications::Screens {
TimeSeparated ConvertTicksToTimeSegments(const TickType_t timeElapsed) {
const uint32_t timeElapsedSecs = timeElapsed / configTICK_RATE_HZ;
const uint16_t timeElapsedFraction = timeElapsed % configTICK_RATE_HZ;
Expand All @@ -17,7 +17,9 @@ namespace {
const uint16_t hours = (timeElapsedSecs / 60) / 60;
return TimeSeparated {hours, mins, secs, hundredths, timeElapsedSecs};
}
}

namespace {
void PlayPauseEventHandler(lv_obj_t* obj, lv_event_t event) {
auto* stopWatch = static_cast<StopWatch*>(obj->user_data);
if (event == LV_EVENT_CLICKED) {
Expand Down
2 changes: 2 additions & 0 deletions src/displayapp/screens/StopWatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ namespace Pinetime::Applications {
uint32_t epochSecs;
};

TimeSeparated ConvertTicksToTimeSegments(const TickType_t timeElapsed);

class StopWatch : public Screen {
public:
explicit StopWatch(System::SystemTask& systemTask, Controllers::StopWatchController& stopWatchController);
Expand Down
34 changes: 34 additions & 0 deletions src/displayapp/screens/WatchFaceDigital.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include "displayapp/screens/NotificationIcon.h"
#include "displayapp/screens/Symbols.h"
#include "displayapp/screens/WeatherSymbols.h"
#include "displayapp/screens/WeatherSymbols.h"
#include "displayapp/screens/StopWatch.h"
#include "components/battery/BatteryController.h"
#include "components/ble/BleController.h"
#include "components/ble/NotificationManager.h"
Expand All @@ -24,13 +26,15 @@ WatchFaceDigital::WatchFaceDigital(Controllers::DateTime& dateTimeController,
Controllers::Settings& settingsController,
Controllers::HeartRateController& heartRateController,
Controllers::MotionController& motionController,
Controllers::StopWatchController& stopWatchController,
Controllers::SimpleWeatherService& weatherService)
: currentDateTime {{}},
dateTimeController {dateTimeController},
notificationManager {notificationManager},
settingsController {settingsController},
heartRateController {heartRateController},
motionController {motionController},
stopWatchController {stopWatchController},
weatherService {weatherService},
statusIcons(batteryController, bleController, alarmController) {

Expand Down Expand Up @@ -86,6 +90,16 @@ WatchFaceDigital::WatchFaceDigital(Controllers::DateTime& dateTimeController,
lv_label_set_text_static(stepIcon, Symbols::shoe);
lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0);

stopWatchIcon = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(stopWatchIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xFFFFFF));
lv_label_set_text_static(stopWatchIcon, "");
lv_obj_align(stopWatchIcon, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 0, 0);

stopWatchValue = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(stopWatchValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xFFFFFF));
lv_label_set_text_static(stopWatchValue, "");
lv_obj_align(stopWatchValue, stopWatchIcon, LV_ALIGN_OUT_RIGHT_MID, 5, 0);

taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
Refresh();
}
Expand Down Expand Up @@ -172,6 +186,26 @@ void WatchFaceDigital::Refresh() {
lv_obj_realign(stepIcon);
}

stopWatchTime = stopWatchController.GetElapsedTime();
stopWatchRunning = !stopWatchController.IsCleared();
if (stopWatchTime.IsUpdated() || stopWatchRunning.IsUpdated()) {
if (stopWatchRunning.Get()) {
TimeSeparated elapsedTime = ConvertTicksToTimeSegments(stopWatchTime.Get());
lv_label_set_text_fmt(stopWatchValue,
"%02d:%02d:%02d:%02d",
elapsedTime.hours,
elapsedTime.mins,
elapsedTime.secs,
elapsedTime.hundredths);
lv_label_set_text_static(stopWatchIcon, Symbols::stopWatch);
} else {
lv_label_set_text_fmt(stopWatchValue, "");
lv_label_set_text_static(stopWatchIcon, "");
}
lv_obj_realign(stopWatchValue);
lv_obj_realign(stopWatchIcon);
}

currentWeather = weatherService.Current();
if (currentWeather.IsUpdated()) {
auto optCurrentWeather = currentWeather.Get();
Expand Down
7 changes: 7 additions & 0 deletions src/displayapp/screens/WatchFaceDigital.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ namespace Pinetime {
Controllers::Settings& settingsController,
Controllers::HeartRateController& heartRateController,
Controllers::MotionController& motionController,
Controllers::StopWatchController& stopWatchController,
Controllers::SimpleWeatherService& weather);
~WatchFaceDigital() override;

Expand All @@ -47,6 +48,8 @@ namespace Pinetime {

Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::minutes>> currentDateTime {};
Utility::DirtyValue<uint32_t> stepCount {};
Utility::DirtyValue<TickType_t> stopWatchTime {};
Utility::DirtyValue<bool> stopWatchRunning {};
Utility::DirtyValue<uint8_t> heartbeat {};
Utility::DirtyValue<bool> heartbeatRunning {};
Utility::DirtyValue<bool> notificationState {};
Expand All @@ -61,6 +64,8 @@ namespace Pinetime {
lv_obj_t* heartbeatValue;
lv_obj_t* stepIcon;
lv_obj_t* stepValue;
lv_obj_t* stopWatchIcon;
lv_obj_t* stopWatchValue;
lv_obj_t* notificationIcon;
lv_obj_t* weatherIcon;
lv_obj_t* temperature;
Expand All @@ -70,6 +75,7 @@ namespace Pinetime {
Controllers::Settings& settingsController;
Controllers::HeartRateController& heartRateController;
Controllers::MotionController& motionController;
Controllers::StopWatchController& stopWatchController;
Controllers::SimpleWeatherService& weatherService;

lv_task_t* taskRefresh;
Expand All @@ -91,6 +97,7 @@ namespace Pinetime {
controllers.settingsController,
controllers.heartRateController,
controllers.motionController,
controllers.stopWatchController,
*controllers.weatherController);
};

Expand Down