Skip to content

Commit 2826755

Browse files
committed
Update multi booter
change battery icon/text to top right
1 parent 26cde76 commit 2826755

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

Code/pico_multi_booter/sd_boot/main.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ void final_selection_callback(const char *path)
254254
if(path == NULL) {
255255
//load default app from flash
256256

257-
snprintf(status_message, sizeof(status_message), "SEL: %s", "FLASH+152k");
257+
snprintf(status_message, sizeof(status_message), "SEL: %s", "FLASH+200k");
258258
text_directory_ui_set_status(status_message);
259259
sleep_ms(200);
260260
load_firmware_by_path(path);
@@ -311,6 +311,7 @@ int main()
311311
DEBUG_PRINT("SD card not detected\n");
312312
text_directory_ui_set_status("Enter to exec.");
313313
text_directory_ui_update_header(1);
314+
text_directory_ui_update_title();
314315
// Poll until SD card is inserted
315316
text_directory_ui_draw_default_app();
316317
text_directory_ui_set_final_callback(final_selection_callback);
@@ -323,7 +324,7 @@ int main()
323324

324325
sleep_ms(20);
325326
if(cur_time - last_time > BAT_UPDATE_MS) {
326-
text_directory_ui_update_header(1);
327+
text_directory_ui_update_title();
327328
last_time = cur_time;
328329
}
329330
}

Code/pico_multi_booter/sd_boot/text_directory_ui.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ extern bool fs_init(void);
4949
// UI Colors
5050
#define COLOR_BG BLACK
5151
#define COLOR_FG WHITE
52-
#define COLOR_HIGHLIGHT GRAY
52+
#define COLOR_HIGHLIGHT LITEGRAY
5353

5454
// Maximum number of directory entries
5555
#define MAX_ENTRIES 128
@@ -146,7 +146,7 @@ static void format_file_size(off_t size, int is_dir, char *buf, size_t buf_size)
146146

147147
static void set_default_entry(){
148148
entry_count = 0;
149-
strncpy(entries[entry_count].name, "[Default app]", sizeof(entries[entry_count].name) - 1);
149+
strncpy(entries[entry_count].name, "[Default App]", sizeof(entries[entry_count].name) - 1);
150150
entries[entry_count].name[sizeof(entries[entry_count].name) - 1] = '\0';
151151
entries[entry_count].is_dir = IS_LAST_APP;
152152
entries[entry_count].file_size = 0;
@@ -340,8 +340,8 @@ static void ui_draw_directory_entry(int entry_idx)
340340
size_buffer, sizeof(size_buffer));
341341

342342
// Draw filename and file size
343-
draw_text(FILE_NAME_X, posY, display_buffer, COLOR_FG , is_selected ? COLOR_HIGHLIGHT : COLOR_BG);
344-
draw_text(FILE_SIZE_X, posY, size_buffer, COLOR_FG, is_selected ? COLOR_HIGHLIGHT : COLOR_BG);
343+
draw_text(FILE_NAME_X, posY, display_buffer, is_selected?COLOR_BG:COLOR_FG , is_selected ? COLOR_HIGHLIGHT : COLOR_BG);
344+
draw_text(FILE_SIZE_X, posY, size_buffer, is_selected?COLOR_BG: COLOR_FG, is_selected ? COLOR_HIGHLIGHT : COLOR_BG);
345345
}
346346

347347
/**
@@ -429,14 +429,16 @@ static void ui_draw_status_bar(void)
429429
static void ui_draw_battery_status(){
430430
char buf[8];
431431
int pcnt = keypad_get_battery();
432+
if(pcnt < 0) return;
432433
int level = pcnt * 13 / 100;
433434
int pad = 0;
434435
sprintf(buf,"%d%%",pcnt);
435-
int y = UI_Y + HEADER_TITLE_HEIGHT;
436+
int y = UI_Y;
436437
if(pcnt < 10) { pad = 8;}
437438
else if( pcnt >= 10 && pcnt < 100){pad = 0;}
438439
else if(pcnt == 100){pad = -8;}
439-
//draw_rect_spi(UI_X, y, UI_X + UI_WIDTH - 1, y + PATH_HEADER_HEIGHT - 1, COLOR_BG);
440+
441+
draw_rect_spi(UI_X + UI_WIDTH-16-20-5-8, y, UI_X + UI_WIDTH, y + HEADER_TITLE_HEIGHT, COLOR_BG);
440442
draw_text(UI_X + UI_WIDTH-16-20-5+pad, y + 2, buf, COLOR_FG, COLOR_BG);
441443
draw_battery_icon(UI_X+UI_WIDTH-16,y+4,level);
442444
}
@@ -452,7 +454,7 @@ static void ui_refresh(void)
452454
}else{
453455
ui_draw_status_bar();
454456
}
455-
ui_draw_battery_status();
457+
text_directory_ui_update_title();
456458
}
457459

458460
// Handle key events for navigation and selection
@@ -582,6 +584,9 @@ void text_directory_ui_set_status(const char *msg)
582584

583585
void text_directory_ui_update_header(uint8_t nosd) {
584586
ui_draw_path_header(nosd);
587+
}
588+
589+
void text_directory_ui_update_title(){
585590
ui_draw_battery_status();
586591
}
587592

@@ -616,13 +621,14 @@ void text_directory_ui_run(void)
616621
last_scroll_update = current_time;
617622
}
618623
if(current_time - last_bat_update > BAT_UPDATE_MS){
619-
text_directory_ui_update_header(!status_flag);
624+
text_directory_ui_update_title();
620625
last_bat_update = current_time;
621626
}
622627
// Check for SD card removal during runtime
623628
if (!sd_card_inserted()) {
624629
text_directory_ui_set_status("SD card removed. Please reinsert.");
625630
text_directory_ui_update_header(!status_flag);
631+
text_directory_ui_update_title();
626632
ui_clear_directory_list();
627633
update_required = 1;
628634
ui_draw_directory_list();
@@ -635,7 +641,7 @@ void text_directory_ui_run(void)
635641

636642
sleep_ms(20);
637643
if(current_time - last_bat_update > BAT_UPDATE_MS){
638-
text_directory_ui_update_header(!status_flag);
644+
text_directory_ui_update_title();
639645
last_bat_update = current_time;
640646
}
641647
}

Code/pico_multi_booter/sd_boot/text_directory_ui.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ void text_directory_ui_set_status(const char *msg);
3434

3535
void text_directory_ui_update_header(uint8_t nosd);
3636

37+
void text_directory_ui_update_title();
38+
3739
void text_directory_ui_draw_default_app();
3840

3941
void process_key_event(int);

0 commit comments

Comments
 (0)