Parse integer from serial input.
- Returns
- Parsed integer value, or 0 if no valid integer found
Skips non-numeric characters until a number is found, then parses it. Stops at first non-numeric character after the number.
Definition at line 222 of file serial.cpp.hpp.
222 {
223 bool negative = false;
225 bool foundDigit = false;
227
228
232 if (c == -1) {
233 continue;
234 }
235
236
237 if (c == '-') {
238 negative = true;
240 break;
241 } else if (c == '+') {
243 break;
244 } else if (c >= '0' && c <= '9') {
245 break;
246 } else {
249 }
250 }
251 }
252
253
258 if (c == -1) {
259 continue;
260 }
261
262 if (c >= '0' && c <= '9') {
265 foundDigit = true;
267 } else {
268 break;
269 }
270 }
271 }
272
273 return foundDigit ? (negative ? -
value :
value) : 0;
274}
int read() FL_NO_EXCEPT
Read next byte from serial input.
int peek() FL_NO_EXCEPT
Peek at next byte without removing it from buffer.
int available() FL_NO_EXCEPT
Check how many bytes are available to read.
constexpr int type_rank< T >::value
fl::u32 millis() FL_NO_EXCEPT
Universal millisecond timer - returns milliseconds since system startup.
References available(), fl::FL_NO_EXCEPT, fl::millis(), mTimeoutMs, peek(), read(), and fl::type_rank< T >::value.