mirror of
https://github.com/whowechina/aic_pico.git
synced 2025-02-22 13:10:39 +01:00
CLI welcomes you when connected
This commit is contained in:
parent
a583f81de6
commit
7488756bb7
@ -149,6 +149,32 @@ static void process_cmd()
|
|||||||
|
|
||||||
void cli_run()
|
void cli_run()
|
||||||
{
|
{
|
||||||
|
static bool was_connected = false;
|
||||||
|
static uint64_t connect_time = 0;
|
||||||
|
static bool welcomed = false;
|
||||||
|
|
||||||
|
bool connected = stdio_usb_connected();
|
||||||
|
|
||||||
|
bool just_connected = connected && !was_connected;
|
||||||
|
was_connected = connected;
|
||||||
|
|
||||||
|
if (!connected) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (just_connected) {
|
||||||
|
connect_time = time_us_64();
|
||||||
|
welcomed = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!welcomed && (time_us_64() - connect_time > 200000)) {
|
||||||
|
welcomed = true;
|
||||||
|
cmd_len = 0;
|
||||||
|
handle_help(0, NULL);
|
||||||
|
printf("\n%s", cli_prompt);
|
||||||
|
}
|
||||||
|
|
||||||
int c = getchar_timeout_us(0);
|
int c = getchar_timeout_us(0);
|
||||||
if (c == EOF) {
|
if (c == EOF) {
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user