File tree Expand file tree Collapse file tree 2 files changed +20
-8
lines changed
Expand file tree Collapse file tree 2 files changed +20
-8
lines changed Original file line number Diff line number Diff line change 1717#include " lib/maapi.h"
1818#include " serial.h"
1919
20+ uint32_t serialDataTimer = 0 ;
21+
2022//
2123// setup the Serial device
2224// Teensy 4.x uses USB serial. Setup is done at startup. Communication
@@ -63,16 +65,26 @@ void dev_trace_line(int lineNo) {
6365// process events
6466//
6567int dev_events (int wait_flag) {
66- int result;
68+ int result = 0 ;
69+
6770 if (wait_flag) {
6871 delay (10 );
6972 }
70- // #if INTERACTIVE
71- // break when new code available
72- result = Serial.available () > 0 ? -2 : 0 ;
73- // #else
74- // result = 0;
75- // #endif
73+
74+ if (Serial) {
75+ if (Serial.available ()) {
76+ if (serialDataTimer == 0 ) {
77+ serialDataTimer = millis ();
78+ }
79+ if (millis () - serialDataTimer > 1000 ) {
80+ serialDataTimer = 0 ;
81+ result = -2 ; // end program
82+ }
83+ } else {
84+ serialDataTimer = 0 ;
85+ }
86+ }
87+
7688 yield ();
7789 return result;
7890}
Original file line number Diff line number Diff line change @@ -176,7 +176,7 @@ void interactive_main() {
176176 delay (250 );
177177 }
178178
179- dev_print (" Interactive mode - waiting for data...\r\n " );
179+ dev_print (" \r\n\033 [30;47mInteractive mode - waiting for data...\033 [0m \r\n " );
180180
181181 serial_read ();
182182 if (!sbasic_main (SERIAL_SD_BAS)) {
You can’t perform that action at this time.
0 commit comments