You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// First perform all checks which would cause the function to return the current value of numStr. This includes the end of the buffer, and the end of the number.
251
279
if(c == -1){ // Return numStr if end of buffer is reached
252
-
if(debug){ std::cout << "parseFloat(): Reached end of buffer, returning " << numStr << "\n"; }
280
+
if(this->debug){ std::cout << "parseFloat(): Reached end of buffer, returning " << numStr << "\n"; }
253
281
return (numStr.length() > 0)? std::stof(numStr) : 0; // If numStr is empty, return 0
254
282
}
255
283
if(numStr.length() > 0 && !isdigit(c) && c != '.' && c != '-'){ // Return numStr if numStr.length() > 0 and the current character is not a digit, decimal point, or negative sign
256
-
if(debug){ std::cout << "parseFloat(): Found non-digit, non-decimal point, non-negative sign, returning " << numStr << "\n"; }
284
+
if(this->debug){ std::cout << "parseFloat(): Found non-digit, non-decimal point, non-negative sign, returning " << numStr << "\n"; }
257
285
return (numStr.length() > 0)? std::stof(numStr) : 0; // If numStr is empty, return 0
258
286
}
259
287
if(c == '.' && !allowDecimal){ // Return numStr if the current character is a decimal point and allowDecimal is false
260
-
if(debug){ std::cout << "parseFloat(): Found second decimal point, returning " << numStr << "\n"; }
288
+
if(this->debug){ std::cout << "parseFloat(): Found second decimal point, returning " << numStr << "\n"; }
261
289
return (numStr.length() > 0)? std::stof(numStr) : 0; // If numStr is empty, return 0
262
290
}
263
291
if(c == '-' && numStr.length() > 0){ // Return numStr if the current character is a negative sign and numStr.length() > 0
264
-
if(debug){ std::cout << "parseFloat(): Found negative sign in the middle of a number, returning " << numStr << "\n"; }
292
+
if(this->debug){ std::cout << "parseFloat(): Found negative sign in the middle of a number, returning " << numStr << "\n"; }
265
293
return (numStr.length() > 0)? std::stof(numStr) : 0; // If numStr is empty, return 0
266
294
}
267
295
// Now that we know that we dont have to return numStr, we can add the current character to numStr (as long as it is a digit, decimal point, or negative sign)
268
296
if(c == '.'){ allowDecimal = false; }
269
297
if(isdigit(c) || c == '.' || c == '-'){ numStr += c; }
270
298
271
299
}
272
-
if(debug){ std::cout << "parseFloat(): Timed out while searching for a float, returning " << numStr << "\n"; }
300
+
if(this->debug){ std::cout << "parseFloat(): Timed out while searching for a float, returning " << numStr << "\n"; }
273
301
return (numStr.length() > 0)? std::stof(numStr) : 0; // If numStr is empty, return 0
274
302
}
275
303
@@ -291,11 +319,11 @@ long arduinoSerial::parseInt(){
291
319
}
292
320
num = num * 10 + (c - '0');
293
321
}elseif(num != 0){
294
-
if(debug){ std::cout << "parseInt(): Found integer " << num * (sign? 1 : -1) << "\n"; }
322
+
if(this->debug){ std::cout << "parseInt(): Found integer " << num * (sign? 1 : -1) << "\n"; }
295
323
return num * (sign? 1 : -1);
296
324
}
297
325
}
298
-
if(debug){ std::cout << "parseInt(): Timed out while searching for an integer, returning " << num * (sign? 1 : -1) << "\n"; }
326
+
if(this->debug){ std::cout << "parseInt(): Timed out while searching for an integer, returning " << num * (sign? 1 : -1) << "\n"; }
0 commit comments