diff options
| author | Michele Bini <michele.bini@gmail.com> | 2022-03-31 07:02:46 (GMT) |
|---|---|---|
| committer | Michele Bini <michele.bini@gmail.com> | 2022-03-31 07:02:46 (GMT) |
| commit | d081bc82fa01b5ecb373671d38fa88397c49a235 (patch) | |
| tree | 97e0bc4df52704d12f0b01a2b14c9f514546d7e2 | |
| parent | 465cea4cadb30725dee605babe5d9fb722207b70 (diff) | |
mix work
| -rw-r--r-- | src/displayapp/screens/WatchFaceDigital.cpp | 47 | ||||
| -rw-r--r-- | src/displayapp/screens/WatchFaceDigital.h | 4 |
2 files changed, 50 insertions, 1 deletions
diff --git a/src/displayapp/screens/WatchFaceDigital.cpp b/src/displayapp/screens/WatchFaceDigital.cpp index e2215c2..f7a7aa3 100644 --- a/src/displayapp/screens/WatchFaceDigital.cpp +++ b/src/displayapp/screens/WatchFaceDigital.cpp @@ -3,6 +3,7 @@ #include <date/date.h> #include <lvgl/lvgl.h> #include <cstdio> +#include "drivers/Hrs3300.h" #include "displayapp/screens/BatteryIcon.h" #include "displayapp/screens/BleIcon.h" #include "displayapp/screens/NotificationIcon.h" @@ -16,6 +17,28 @@ #include "displayapp/fonts/neofont.h" using namespace Pinetime::Applications::Screens; +static inline uint8_t sprintuint4hex(uint8_t x) { + return x < 10 ? '0' + x : ('A' - 10) + x; +} + +static void sprintuint32hex(char x[9], uint32_t v) { + uint16_t p = v; + uint16_t q = v >> 16; + uint8_t a = q >> 8; + x[0] = sprintuint4hex(a>>4); + x[1] = sprintuint4hex(a&0xf); + a = q; + x[2] = sprintuint4hex(a>>4); + x[3] = sprintuint4hex(a&0xf); + a = p >> 8; + x[4] = sprintuint4hex(a>>4); + x[5] = sprintuint4hex(a&0xf); + a = p; + x[6] = sprintuint4hex(a>>4); + x[7] = sprintuint4hex(a&0xf); + x[8] = 0; +} + WatchFaceDigital::WatchFaceDigital(DisplayApp* app, Controllers::DateTime& dateTimeController, Controllers::Battery& batteryController, @@ -242,7 +265,7 @@ WatchFaceDigital::WatchFaceDigital(DisplayApp* app, lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B)); lv_obj_set_style_local_text_font(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont2); lv_label_set_text_static(heartbeatIcon, Symbols::heartBeat); - lv_obj_align(heartbeatIcon, area8, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0); + lv_obj_align(heartbeatIcon, area8, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0); heartbeatValue = lv_label_create(lv_scr_act(), nullptr); lv_obj_set_style_local_text_color(heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B)); @@ -251,6 +274,20 @@ WatchFaceDigital::WatchFaceDigital(DisplayApp* app, lv_obj_align(heartbeatValue, heartbeatIcon, LV_ALIGN_OUT_RIGHT_MID, 0, 0); lv_label_set_align(heartbeatValue, LV_LABEL_ALIGN_RIGHT); + sprintuint32hex(hrs_label_text, 0x33); + hrsValue = lv_label_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_text_color( hrsValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xFFFFFF)); + lv_obj_set_style_local_text_font( hrsValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont15); + lv_obj_align(hrsValue, heartbeatValue, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0); + lv_label_set_text_static(hrsValue, hrs_label_text); + + sprintuint32hex(als_label_text, 0x15617811); + alsValue = lv_label_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_text_color( alsValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xFFFFAA)); + lv_obj_set_style_local_text_font( alsValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont15); + lv_obj_align(alsValue, hrsValue, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0); + lv_label_set_text_static(alsValue, als_label_text); + taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); lv_obj_del(area1); @@ -403,4 +440,12 @@ void WatchFaceDigital::Refresh() { lv_obj_realign(heartbeatIcon); lv_obj_realign(heartbeatValue); } + + { + auto &sensor = systemTask.heartRateSensor; + sprintuint32hex(als_label_text, sensor.ReadHrs()); + sprintuint32hex(hrs_label_text, sensor.ReadAls()); + lv_label_set_text_static(hrsValue, hrs_label_text); + lv_label_set_text_static(alsValue, als_label_text); + } } diff --git a/src/displayapp/screens/WatchFaceDigital.h b/src/displayapp/screens/WatchFaceDigital.h index 93719c1..353a7fc 100644 --- a/src/displayapp/screens/WatchFaceDigital.h +++ b/src/displayapp/screens/WatchFaceDigital.h @@ -49,6 +49,8 @@ namespace Pinetime { uint8_t currentDay = 0; char hhmm_label_text[6] = { '?', '?', ':', '?', '?', 0 }; + char hrs_label_text[9] = { '?', 0,0,0,0, 0,0,0,0 }; + char als_label_text[9] = { '?', 0,0,0,0, 0,0,0,0 }; DirtyValue<uint8_t> batteryPercentRemaining {}; DirtyValue<bool> powerPresent {}; @@ -74,6 +76,8 @@ namespace Pinetime { lv_obj_t* batteryPlug; lv_obj_t* heartbeatIcon; lv_obj_t* heartbeatValue; + lv_obj_t* hrsValue; + lv_obj_t* alsValue; lv_obj_t* stepIcon; lv_obj_t* stepValue; lv_obj_t* notificationIcon; |
