|
6 | 6 | #include "projdefs.h" |
7 | 7 | #include "FreeRTOSConfig.h" |
8 | 8 | #include "task.h" |
| 9 | +#include "BatteryIcon.h" |
9 | 10 |
|
10 | 11 | #include <tuple> |
11 | 12 |
|
@@ -48,11 +49,13 @@ static void stop_lap_event_handler(lv_obj_t* obj, lv_event_t event) { |
48 | 49 | StopWatch::StopWatch(DisplayApp* app, |
49 | 50 | System::SystemTask& systemTask, |
50 | 51 | Controllers::DateTime& dateTimeController, |
51 | | - Controllers::StopWatch& stopWatchController) |
| 52 | + Controllers::StopWatch& stopWatchController, |
| 53 | + Controllers::Battery& batteryController) |
52 | 54 | : Screen(app), |
53 | 55 | systemTask {systemTask}, |
54 | 56 | dateTimeController {dateTimeController}, |
55 | 57 | stopWatchController {stopWatchController}, |
| 58 | + batteryController {batteryController}, |
56 | 59 | timeElapsed {}, |
57 | 60 | currentTimeSeparated {} { |
58 | 61 |
|
@@ -112,6 +115,11 @@ StopWatch::StopWatch(DisplayApp* app, |
112 | 115 | lv_obj_align(dateTime, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0); |
113 | 116 | lv_obj_set_style_local_text_color(dateTime, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); |
114 | 117 |
|
| 118 | + // Battery |
| 119 | + batteryIcon = lv_label_create(lv_scr_act(), nullptr); |
| 120 | + lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryController.PercentRemaining())); |
| 121 | + lv_obj_align(batteryIcon, nullptr, LV_ALIGN_IN_TOP_RIGHT, -8, 0); |
| 122 | + |
115 | 123 | taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); |
116 | 124 |
|
117 | 125 | // Figure out what the current state of the stopwatch is and select the correct display |
@@ -196,6 +204,7 @@ void StopWatch::updateLaps() { |
196 | 204 |
|
197 | 205 | void StopWatch::Refresh() { |
198 | 206 | lv_label_set_text_fmt(dateTime, "%02i:%02i", dateTimeController.Hours(), dateTimeController.Minutes()); |
| 207 | + lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryController.PercentRemaining())); |
199 | 208 | if (stopWatchController.isRunning()) { |
200 | 209 | timeElapsed = calculateDelta(stopWatchController.getStart(), xTaskGetTickCount()); |
201 | 210 | currentTimeSeparated = convertTicksToTimeSegments((stopWatchController.getElapsedPreviously() + timeElapsed)); |
|
0 commit comments