Skip to content

Commit 59ab72c

Browse files
committed
Check for power while the splash screen is shown/only show empty battery symbol when power is not ready.
1 parent d73bcc2 commit 59ab72c

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed

src/Braccio++.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ class BraccioClass
161161

162162
// default display APIs
163163
void lvgl_splashScreen(unsigned long const duration_ms);
164+
void lvgl_emptyBatterySymbol();
164165
void defaultMenu();
165166

166167
void setID(int id) {

src/Braccio.cpp

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,8 @@ bool BraccioClass::begin(voidFuncPtr customMenu) {
127127

128128
lvgl_splashScreen(2000);
129129

130-
{
131-
lv_style_set_text_font(&_lv_style, &lv_font_montserrat_48);
132-
lv_obj_t * label1 = lv_label_create(lv_scr_act());
133-
lv_obj_add_style(label1, &_lv_style, 0);
134-
lv_label_set_text(label1, LV_SYMBOL_BATTERY_EMPTY);
135-
lv_obj_set_align(label1, LV_ALIGN_CENTER);
136-
lv_obj_set_pos(label1, 0, 0);
137-
}
130+
if (!PD_UFP.is_PPS_ready())
131+
lvgl_emptyBatterySymbol();
138132

139133
for(auto const now = millis();
140134
((millis() - now) < 5000) && !PD_UFP.is_PPS_ready();)
@@ -226,13 +220,36 @@ void BraccioClass::lvgl_splashScreen(unsigned long const duration_ms)
226220
lv_gif_set_src(img, &img_bulb_gif);
227221
lv_obj_align(img, LV_ALIGN_CENTER, 0, 0);
228222

229-
/* Wait until the splash screen duration is over. */
230-
for (unsigned long const start = millis(); millis() - start < duration_ms; delay(10)) { }
223+
/* Wait until the splash screen duration is over.
224+
* Meanwhile use the wait time for checking the
225+
* power.
226+
*/
227+
for (unsigned long const start = millis(); millis() - start < duration_ms;)
228+
{
229+
if (!PD_UFP.is_PPS_ready())
230+
{
231+
i2c_mutex.lock();
232+
PD_UFP.print_status(Serial);
233+
PD_UFP.set_PPS(PPS_V(7.2), PPS_A(2.0));
234+
delay(10);
235+
i2c_mutex.unlock();
236+
}
237+
}
231238

232239
lv_obj_del(img);
233240
lv_obj_clean(lv_scr_act());
234241
}
235242

243+
void BraccioClass::lvgl_emptyBatterySymbol()
244+
{
245+
lv_style_set_text_font(&_lv_style, &lv_font_montserrat_48);
246+
lv_obj_t * label1 = lv_label_create(lv_scr_act());
247+
lv_obj_add_style(label1, &_lv_style, 0);
248+
lv_label_set_text(label1, LV_SYMBOL_BATTERY_EMPTY);
249+
lv_obj_set_align(label1, LV_ALIGN_CENTER);
250+
lv_obj_set_pos(label1, 0, 0);
251+
}
252+
236253
void BraccioClass::defaultMenu() {
237254

238255
// TODO: create a meaningful default menu

0 commit comments

Comments
 (0)