Skip to content
Snippets Groups Projects
Commit d088487c authored by schneider's avatar schneider Committed by q3k
Browse files

recovery: show progress bar

parent bbb3f61d
No related branches found
No related tags found
No related merge requests found
......@@ -42,6 +42,24 @@ void rec_erasing_draw(void) {
st3m_gfx_drawctx_pipe_put(target);
}
void rec_flashing_draw(int percent) {
st3m_ctx_desc_t *target = st3m_gfx_drawctx_free_get(portMAX_DELAY);
_header_draw(target);
ctx_move_to(target->ctx, 0, 0);
ctx_font_size(target->ctx, 20.0);
ctx_gray(target->ctx, 0.8);
char buf[128];
snprintf(buf, sizeof(buf), "Flashing... %2d%%", percent);
ctx_text(target->ctx, buf);
ctx_rectangle(target->ctx, -120, 20, 240 * percent / 100, 20);
ctx_fill(target->ctx);
st3m_gfx_drawctx_pipe_put(target);
}
void rec_menu_draw(menu_t *menu) {
st3m_ctx_desc_t *target = st3m_gfx_drawctx_free_get(portMAX_DELAY);
_header_draw(target);
......
......@@ -17,5 +17,6 @@ typedef struct {
} menu_t;
void rec_erasing_draw(void);
void rec_flashing_draw(int percent);
void rec_menu_draw(menu_t *menu);
void rec_menu_process(menu_t *menu);
......@@ -127,6 +127,11 @@ static void _list_select(void) {
rec_fatal("Could not open file :(");
}
fseek(f, 0, SEEK_END);
size_t size = ftell(f);
fseek(f, 0, SEEK_SET);
rec_flashing_draw(0);
do {
n = fread(buf, 1, sizeof(buf), f);
if (n > 0) {
......@@ -134,6 +139,7 @@ static void _list_select(void) {
esp_partition_write(p, offset, buf, n);
offset += n;
ESP_LOGI(TAG, "wrote %u bytes", offset);
rec_flashing_draw(offset * 100 / size);
}
} while (n == sizeof(buf));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment