diff --git a/bootloader/echoplayer.c b/bootloader/echoplayer.c index da7d9fecb3..2afa85819d 100644 --- a/bootloader/echoplayer.c +++ b/bootloader/echoplayer.c @@ -25,9 +25,61 @@ #include "lcd.h" #include "backlight.h" #include "button.h" +#include "timefuncs.h" +#include "storage.h" +#include "disk.h" +#include "file_internal.h" extern void show_logo(void); +static void demo_rtc(void) +{ + int y = 0; + struct tm *time = get_time(); + + lcd_clear_display(); + + lcd_putsf(0, y++, "time: %02d:%02d:%02d", + time->tm_hour, time->tm_min, time->tm_sec); + lcd_putsf(0, y++, "year: %d", time->tm_year + 1900); + lcd_putsf(0, y++, "month: %d", time->tm_mon); + lcd_putsf(0, y++, "day: %d", time->tm_mday); + + lcd_update(); +} + +static void demo_storage(void) +{ + int y = 0; + + lcd_clear_display(); + lcd_putsf(0, y++, "tick %ld", current_tick); + + struct partinfo pinfo; + if (storage_present(IF_MD(0,)) && disk_partinfo(0, &pinfo)) + { + lcd_putsf(0, y++, "start %d", (int)pinfo.start); + lcd_putsf(0, y++, "count %d", (int)pinfo.size); + lcd_putsf(0, y++, "type %d", (int)pinfo.type); + + DIR *d = opendir("/"); + struct dirent *ent; + while ((ent = readdir(d))) + { + lcd_putsf(0, y++, "/%s", ent->d_name); + } + + closedir(d); + } + + lcd_update(); +} + +static void (*demo_funcs[]) (void) = { + demo_rtc, + demo_storage, +}; + void main(void) { system_init(); @@ -35,13 +87,42 @@ void main(void) rtc_init(); lcd_init(); + button_init(); + backlight_init(); backlight_on(); show_logo(); - while (1) { - lcd_putsxyf(60, 140, "btn: %08x", button_read_device()); - lcd_update(); + storage_init(); + filesystem_init(); + disk_mount_all(); + + int demo_page = 0; + const int num_pages = ARRAYLEN(demo_funcs); + + while (1) + { + int btn = button_get_w_tmo(HZ); + switch (btn) + { + case BUTTON_START: + demo_page += 1; + if (demo_page >= num_pages) + demo_page = 0; + break; + + case BUTTON_SELECT: + if (demo_page == 0) + demo_page = num_pages - 1; + else + demo_page -= 1; + break; + + default: + break; + } + + demo_funcs[demo_page](); } }