File tree Expand file tree Collapse file tree 1 file changed +20
-7
lines changed
Firmware/pico-ice-default Expand file tree Collapse file tree 1 file changed +20
-7
lines changed Original file line number Diff line number Diff line change @@ -55,11 +55,9 @@ static int repl_getchar(void)
5555 return repl_last_char ;
5656 }
5757
58- // busy-wait with a slow delay: this is for interactive I/O, no need to be fast
59- while ((c = getchar_timeout_us (10000 )) == PICO_ERROR_TIMEOUT ) {
60- // call tud_task() since we are blocking
61- tud_task ();
62- }
58+ c = getchar_timeout_us (0 );
59+ if (c == PICO_ERROR_TIMEOUT )
60+ return c ;
6361
6462 if (c == '\r' || c == '\n' ) {
6563 printf ("\r\n" );
@@ -108,6 +106,11 @@ static void repl_command_version(void)
108106 printf ("pico-ice-sdk %s\r\n" , VERSION );
109107}
110108
109+ static void repl_prompt (void )
110+ {
111+ printf ("\x1b[1mpico-ice>\x1b[m " );
112+ }
113+
111114int main (void )
112115{
113116 // Enable USB-CDC #0 (serial console)
@@ -128,12 +131,19 @@ int main(void)
128131 // Prevent the LEDs from glowing slightly
129132 ice_led_init ();
130133
134+ // Print repl prompt
135+ repl_prompt ();
136+
131137 while (true) {
132138 tud_task ();
133139
134- printf ("\x1b[1mpico-ice>\x1b[m " );
140+ int chr = repl_getchar ();
141+ if (chr == PICO_ERROR_TIMEOUT )
142+ continue ;
135143
136- switch (repl_getchar ()) {
144+ // not timeout, something received
145+
146+ switch (chr ) {
137147 case 'v' :
138148 repl_command_version ();
139149 break ;
@@ -154,6 +164,9 @@ int main(void)
154164 printf ("\r\n" );
155165 break ;
156166 }
167+
168+ // reprint prompt
169+ repl_prompt ();
157170 }
158171
159172 return 0 ;
You can’t perform that action at this time.
0 commit comments