Skip to content

Commit 93b1392

Browse files
cmagliefacchinm
authored andcommitted
UpdateBootloader now accepts no-newline inputs
1 parent f9015a0 commit 93b1392

File tree

1 file changed

+5
-27
lines changed

1 file changed

+5
-27
lines changed

Diff for: libraries/SAMD_BootloaderUpdater/examples/UpdateBootloader/UpdateBootloader.ino

+5-27
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
66
If it is not, it prompts you to update it.
77
8-
NOTE: please make sure the line ending setting in the Serial Monitor is set to "Both NL & CR"
9-
108
Circuit:
119
- MKR Vidor 4000
1210
@@ -41,10 +39,12 @@ retry:
4139
Serial.println("Would you like to proceed with updating it? (y/N)");
4240
Serial.println();
4341

44-
String input = readLine();
45-
input.toLowerCase();
4642

47-
if (input != "y") {
43+
while (Serial.available() == 0) {
44+
delay(100);
45+
}
46+
char in = Serial.read();
47+
if (in != 'y' && in != 'Y') {
4848
Serial.println("That's all folks!");
4949
while (1);
5050
}
@@ -86,25 +86,3 @@ void loop() {
8686
delay(100);
8787
}
8888

89-
String readLine() {
90-
String line;
91-
92-
while (1) {
93-
if (Serial.available()) {
94-
char c = Serial.read();
95-
96-
if (c == '\r') {
97-
// ignore
98-
} else if (c == '\n') {
99-
break;
100-
}
101-
102-
line += c;
103-
}
104-
}
105-
106-
line.trim();
107-
108-
return line;
109-
}
110-

0 commit comments

Comments
 (0)