mirror of
https://github.com/whowechina/mai_pico.git
synced 2024-11-11 23:27:10 +01:00
Update command in CLI
This commit is contained in:
parent
6c3ac34040
commit
1eafa6a21a
Binary file not shown.
@ -6,6 +6,7 @@
|
||||
|
||||
#include "pico/stdio.h"
|
||||
#include "pico/stdlib.h"
|
||||
#include "pico/bootrom.h"
|
||||
#include "cli.h"
|
||||
#include "save.h"
|
||||
|
||||
@ -87,6 +88,13 @@ static void handle_fps(int argc, char *argv[])
|
||||
printf("FPS: core 0: %d, core 1: %d\n", fps[0], fps[1]);
|
||||
}
|
||||
|
||||
static void handle_update(int argc, char *argv[])
|
||||
{
|
||||
printf("Boot into update mode.\n");
|
||||
fflush(stdout);
|
||||
sleep_ms(100);
|
||||
reset_usb_boot(0, 2);
|
||||
}
|
||||
int cli_extract_non_neg_int(const char *param, int len)
|
||||
{
|
||||
if (len == 0) {
|
||||
@ -94,7 +102,7 @@ int cli_extract_non_neg_int(const char *param, int len)
|
||||
}
|
||||
int result = 0;
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (!isdigit(param[i])) {
|
||||
if (!isdigit((uint8_t)param[i])) {
|
||||
return -1;
|
||||
}
|
||||
result = result * 10 + param[i] - '0';
|
||||
@ -181,4 +189,5 @@ void cli_init(const char *prompt, const char *logo)
|
||||
|
||||
cli_register("?", handle_help, "Display this help message.");
|
||||
cli_register("fps", handle_fps, "Display FPS.");
|
||||
cli_register("update", handle_update, "Update firmware.");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user