|
105 | 105 | double _mAh; // Current Capacity
|
106 | 106 | double _mAhMax; // Capacity when Battery is full
|
107 | 107 | double _mAhRated; // Capacity stated on the Battery's label
|
108 |
| - double _mAhChange; // Capacity lost (!_wasCharging) or gained (_wasCharging) |
| 108 | + double _mAChange; // Capacity lost (!_wasCharging) or gained (_wasCharging) |
109 | 109 | volatile BatteryState _state; // Is the Battery Charging or Discharging?
|
110 | 110 | uint8_t _pinInterrupt; // The GPIO Pin to use as the Interrupt
|
111 | 111 | uint8_t _pinPolarity; // The GPIO Pin to interrogate the Polarity
|
|
158 | 158 | _mAhRated = defaultCapacity;
|
159 | 159 | _mAh = _pStorage->getLastBatteryCapacity(defaultCapacity);
|
160 | 160 | _mAhMax = _pStorage->getMaxmimumBatteryCapacity(defaultCapacity);
|
161 |
| - _mAhChange = 0.00; // Default is that there was no change. |
| 161 | + _mAChange = 0.00; // Default is that there was no change. |
162 | 162 | _percentage = (_mAh / _mAhMax) * 100.00;
|
163 | 163 | _percentQuanta = 1.0 / (_mAhMax / 1000.0 * 5859.0 / 100.0);
|
164 | 164 | _isr = false;
|
|
210 | 210 | }
|
211 | 211 | }
|
212 | 212 |
|
213 |
| - _mAhChange = 614.4/((_deltaTime)/1000000.0); // Calculate by how much the capacity just changed. |
| 213 | + _mAChange = 614.4/((_deltaTime)/1000000.0); // Calculate by how much the capacity just changed. |
214 | 214 |
|
215 | 215 | _pStorage->setLastBatteryCapacity(_mAh);
|
216 | 216 | _pStorage->setMaximumBatteryCapacity(_mAhMax);
|
|
254 | 254 |
|
255 | 255 | inline double getCurrentCapacity() { return _mAh; };
|
256 | 256 | inline double getMaximumCapacity() { return _mAhMax; };
|
257 |
| - inline double getChangeCapacity() { return _mAhChange; }; |
| 257 | + inline double getChangeCapacity() { return _mAChange; }; |
258 | 258 | inline double getPercentage() { return _percentage; };
|
259 | 259 | inline bool getIsCharging() { return _state == Charging; };
|
260 | 260 | inline bool getIsDischarging() { return _state == Discharging; };
|
261 | 261 | inline BatteryState getState() { return _state; };
|
262 | 262 |
|
263 |
| - inline double getChangeCapacityWithPolarity() { return _lastState == Charging ? _mAhChange : _mAhChange * -1.0; }; // This is corrected for negative value on Discharge, positive on Charge. |
| 263 | + inline double getChangeCapacityWithPolarity() { return _lastState == Charging ? _mAChange : _mAChange * -1.0; }; // This is corrected for negative value on Discharge, positive on Charge. |
| 264 | + inline double getChangeCapacityPerHourWithPolarity() { return _lastState == Charging ? (_mAChange / _deltaTime) * 3600000000.00 : ((_mAChange / _deltaTime) * 3600000000.00) * -1.0; }; |
264 | 265 | inline unsigned long getLastTime() { return _lastTime; };
|
265 | 266 | inline unsigned long getDeltaTime() { return _deltaTime; };
|
266 | 267 |
|
267 | 268 | // Discharging Times
|
268 |
| - inline double getTimeToDischargeInHours() { return getIsCharging() ? __DBL_MAX__ : _mAh / _mAhChange; }; |
| 269 | + inline double getTimeToDischargeInHours() { return getIsCharging() ? __DBL_MAX__ : _mAh / _mAChange; }; |
269 | 270 | inline double getTimeToDischargeInMinutes() { return getIsCharging() ? __DBL_MAX__ : getTimeToDischargeInHours() * 60.00; };
|
270 | 271 | inline double getTimeToDischargeInSeconds() { return getIsCharging() ? __DBL_MAX__ : getTimeToDischargeInMinutes() * 60.00; };
|
271 | 272 | inline double getTimeToDischargeInMilliseconds() { return getIsCharging() ? __DBL_MAX__ : getTimeToDischargeInSeconds() * 1000.00; };
|
272 | 273 | inline double getTimeToDischargeInMicroseconds() { return getIsCharging() ? __DBL_MAX__ : getTimeToDischargeInMilliseconds() * 1000.00; };
|
273 | 274 | // Charging Times
|
274 |
| - inline double getTimeToChargeInHours() { return getIsDischarging() ? __DBL_MAX__ : (_mAhMax - _mAh) / _mAhChange; }; |
| 275 | + inline double getTimeToChargeInHours() { return getIsDischarging() ? __DBL_MAX__ : (_mAhMax - _mAh) / _mAChange; }; |
275 | 276 | inline double getTimeToChargeInMinutes() { return getIsDischarging() ? __DBL_MAX__ : getTimeToChargeInHours() * 60.00; };
|
276 | 277 | inline double getTimeToChargeInSeconds() { return getIsDischarging() ? __DBL_MAX__ : getTimeToChargeInMinutes() * 60.00; };
|
277 | 278 | inline double getTimeToChargeInMilliseconds() { return getIsDischarging() ? __DBL_MAX__ : getTimeToChargeInSeconds() * 1000.00; };
|
|
0 commit comments