Author: Jean-François Milants <jf@codingfield.com>
InfiniTime FOSDEM 2023 special edition Add a background image in Digital and Analog watchface. The content of the image is read from /images/fosdem.bin in external storage. Generate fosdem.bin from fosdem.png and add it in the external resource pack.
src/displayapp/screens/SystemInfo.cpp | 3 ++- src/displayapp/screens/WatchFaceAnalog.cpp | 11 ++++++++--- src/displayapp/screens/WatchFaceAnalog.h | 4 ++++ src/displayapp/screens/WatchFaceDigital.cpp | 9 +++++++++ src/displayapp/screens/WatchFaceDigital.h | 3 +++ src/resources/images.json | 7 +++++++
diff --git a/src/displayapp/screens/SystemInfo.cpp b/src/displayapp/screens/SystemInfo.cpp index 01c351955ec4fd772e1f48c4868b1dabfd611860..9bd921bc46c2ece328930901daa5b9d7cc69525b 100644 --- a/src/displayapp/screens/SystemInfo.cpp +++ b/src/displayapp/screens/SystemInfo.cpp @@ -80,10 +80,11 @@ lv_label_set_recolor(label, true); lv_label_set_text_fmt(label, "#FFFF00 InfiniTime#\n\n" "#808080 Version# %ld.%ld.%ld\n" + "#AB1B94 FOSDEM edition#\n" "#808080 Short Ref# %s\n" "#808080 Build date#\n" "%s\n" - "%s\n\n" + "%s\n" "#808080 Bootloader# %s", Version::Major(), Version::Minor(), diff --git a/src/displayapp/screens/WatchFaceAnalog.cpp b/src/displayapp/screens/WatchFaceAnalog.cpp index 5e5317eefe6a2ee7791e51ee391ef90874ec6438..f9b222e9587e11cff68fed36add91c94c51fba1f 100644 --- a/src/displayapp/screens/WatchFaceAnalog.cpp +++ b/src/displayapp/screens/WatchFaceAnalog.cpp @@ -61,9 +61,8 @@ sHour = 99; sMinute = 99; sSecond = 99; - lv_obj_t* bg_clock_img = lv_img_create(lv_scr_act(), NULL); - lv_img_set_src(bg_clock_img, &bg_clock); - lv_obj_align(bg_clock_img, NULL, LV_ALIGN_CENTER, 0, 0); + bg = lv_img_create(lv_scr_act(), nullptr); + lv_obj_align(bg, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0); batteryIcon.Create(lv_scr_act()); lv_obj_align(batteryIcon.GetObject(), nullptr, LV_ALIGN_IN_TOP_RIGHT, 0, 0); @@ -124,6 +123,7 @@ taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); Refresh(); + doNotLoadBg = false; } WatchFaceAnalog::~WatchFaceAnalog() { @@ -186,6 +186,11 @@ batteryIcon.SetBatteryPercentage(batteryPercent); } void WatchFaceAnalog::Refresh() { + if(!bgLoaded && !doNotLoadBg) { + lv_img_set_src(bg, "F:/images/fosdem.bin"); + bgLoaded = true; + } + isCharging = batteryController.IsCharging(); if (isCharging.IsUpdated()) { if (isCharging.Get()) { diff --git a/src/displayapp/screens/WatchFaceAnalog.h b/src/displayapp/screens/WatchFaceAnalog.h index 04d9e7117ce4b1ac6522eacaa53b39afda674207..874ee53dccb228249038c0a396e0e1474a1e8498 100644 --- a/src/displayapp/screens/WatchFaceAnalog.h +++ b/src/displayapp/screens/WatchFaceAnalog.h @@ -70,6 +70,10 @@ lv_obj_t* notificationIcon; BatteryIcon batteryIcon; + lv_obj_t* bg; + bool bgLoaded = false; + bool doNotLoadBg = true; + const Controllers::DateTime& dateTimeController; Controllers::Battery& batteryController; Controllers::Ble& bleController; diff --git a/src/displayapp/screens/WatchFaceDigital.cpp b/src/displayapp/screens/WatchFaceDigital.cpp index 47f40dabbe6cd115e98adf9f638c1ed51783d410..aa126a88eadd9ff2070017a08a229aea23ad36dc 100644 --- a/src/displayapp/screens/WatchFaceDigital.cpp +++ b/src/displayapp/screens/WatchFaceDigital.cpp @@ -31,6 +31,9 @@ heartRateController {heartRateController}, motionController {motionController}, statusIcons(batteryController, bleController) { + bg = lv_img_create(lv_scr_act(), nullptr); + lv_obj_align(bg, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0); + statusIcons.Create(); notificationIcon = lv_label_create(lv_scr_act(), nullptr); @@ -73,6 +76,7 @@ lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0); taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); Refresh(); + doNotLoadBg = false; } WatchFaceDigital::~WatchFaceDigital() { @@ -81,6 +85,11 @@ lv_obj_clean(lv_scr_act()); } void WatchFaceDigital::Refresh() { + if(!bgLoaded && !doNotLoadBg) { + lv_img_set_src(bg, "F:/images/fosdem.bin"); + bgLoaded = true; + } + statusIcons.Update(); notificationState = notificationManager.AreNewNotificationsAvailable(); diff --git a/src/displayapp/screens/WatchFaceDigital.h b/src/displayapp/screens/WatchFaceDigital.h index 60446afaa77e16c31695ca42983799a778bd0914..613ae2c29073db9f12c15da5b0efff24e08a4d94 100644 --- a/src/displayapp/screens/WatchFaceDigital.h +++ b/src/displayapp/screens/WatchFaceDigital.h @@ -64,6 +64,9 @@ lv_obj_t* heartbeatValue; lv_obj_t* stepIcon; lv_obj_t* stepValue; lv_obj_t* notificationIcon; + lv_obj_t* bg; + bool bgLoaded = false; + bool doNotLoadBg = true; Controllers::DateTime& dateTimeController; Controllers::NotificationManager& notificationManager; diff --git a/src/resources/images/fosdem.png b/src/resources/images/fosdem.png new file mode 100644 index 0000000000000000000000000000000000000000..525620b38fb9118ca0adf26a2f60f1a30e8d5f46 Binary files /dev/null and b/src/resources/images/fosdem.png differ diff --git a/src/resources/images.json b/src/resources/images.json index db2ccab088a76e096c04e1474387034ed51963e5..78fd5254e57297dc9be315fe5e2a25a5db98b58c 100644 --- a/src/resources/images.json +++ b/src/resources/images.json @@ -5,5 +5,12 @@ "color_format": "CF_TRUE_COLOR_ALPHA", "output_format": "bin", "binary_format": "ARGB8565_RBSWAP", "target_path": "/images/" + }, + "fosdem" : { + "sources": "images/fosdem.png", + "color_format": "CF_INDEXED_1_BIT", + "output_format": "bin", + "binary_format": "ARGB8565_RBSWAP", + "target_path": "/images/" } }