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 225 of file serial.cpp.hpp.
225 {
226 bool negative = false;
228 bool foundDigit = false;
230
231
235 if (c == -1) {
236 continue;
237 }
238
239
240 if (c == '-') {
241 negative = true;
243 break;
244 } else if (c == '+') {
246 break;
247 } else if (c >= '0' && c <= '9') {
248 break;
249 } else {
252 }
253 }
254 }
255
256
261 if (c == -1) {
262 continue;
263 }
264
265 if (c >= '0' && c <= '9') {
268 foundDigit = true;
270 } else {
271 break;
272 }
273 }
274 }
275
276 return foundDigit ? (negative ? -
value :
value) : 0;
277}
int peek()
Peek at next byte without removing it from buffer.
int available()
Check how many bytes are available to read.
int read()
Read next byte from serial input.
constexpr int type_rank< T >::value
fl::u32 millis()
Universal millisecond timer - returns milliseconds since system startup.
References available(), fl::millis(), mTimeoutMs, peek(), read(), and fl::type_rank< T >::value.