You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
497 B
19 lines
497 B
|
|
|
|
bool isNumberRelatedChar(char c) {
|
|
return (isDigit(c) || (c == '.') || (c == '+') || (c == '-'));
|
|
}
|
|
|
|
int parseNextNumberFromString(String text_buffer, int start_ind, float &value) {
|
|
//find start of number
|
|
while (!isNumberRelatedChar(text_buffer[start_ind])) start_ind++;
|
|
|
|
//find end of number
|
|
int end_ind = start_ind;
|
|
while (isNumberRelatedChar(text_buffer[end_ind])) end_ind++;
|
|
|
|
//extract number
|
|
value = text_buffer.substring(start_ind, end_ind).toFloat();
|
|
|
|
return end_ind;
|
|
}
|
|
|