-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Description
If the TinyPICO helper is created and used immediately, the battery voltage reported is incorrect.
Rationale:
-
lastMeasuredVoltage isn't initialized in the constructor. Fix: in the constructor: lastMeasuredVoltage = 0.0f;
-
nextVoltage is set the current time, so if immediately after GetBatteryVoltage is called 'nextVoltage - millis() > 0' is false and the (currently uninitialized) lastMeasuredVoltage is returned without a new ADC read. Fix: in the constructor, change the nextVoltage initialization to: nextVoltage = millis() - 1; //do a '-1' to ensure I can get the battery voltage this msec.
Note that isToneInit isn't initialized in the constructor as well, even not related to this issue, I guess that initializing to false might be wise.
russelljahn
Metadata
Metadata
Assignees
Labels
No labels