File tree 2 files changed +25
-0
lines changed
avr/libraries/LottieLemon/src/utility
2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -307,3 +307,24 @@ void MotorBoard::reset() {
307
307
begin ();
308
308
stopCurrentActions ();
309
309
}
310
+
311
+ float MotorBoard::getBatteryTerminalVolts () {
312
+ // Read battery voltage on multiplexer channel 5.
313
+ int adcValue = _multiplexer.analogRead (5 );
314
+ float adcVoltage = (5 .0f / 1023 .0f ) * adcValue;
315
+ return 2 .0f * adcVoltage; // Compensate for voltage divider.
316
+ }
317
+
318
+ float MotorBoard::getBatteryChargeMilliamps () {
319
+ // Read battery charge current on multiplexer channel 6.
320
+ int adcValue = _multiplexer.analogRead (6 );
321
+ float adcVoltage = (5 .0f / 1023 .0f ) * adcValue;
322
+ return adcVoltage / 0 .00075f ; // Compensate sense resistor and gain.
323
+ }
324
+
325
+ float MotorBoard::getBatteryDischargeMilliamps () {
326
+ // Read battery discharge current on multiplexer channel 7.
327
+ int adcValue = _multiplexer.analogRead (7 );
328
+ float adcVoltage = (5 .0f / 1023 .0f ) * adcValue;
329
+ return adcVoltage / 0 .00075f ; // Compensate sense resistor and gain.
330
+ }
Original file line number Diff line number Diff line change @@ -35,6 +35,10 @@ namespace LottieLemon {
35
35
36
36
int IRread (uint8_t num);
37
37
38
+ float getBatteryTerminalVolts ();
39
+ float getBatteryChargeMilliamps ();
40
+ float getBatteryDischargeMilliamps ();
41
+
38
42
void setMode (uint8_t mode);
39
43
void pauseMode (bool onOff);
40
44
You can’t perform that action at this time.
0 commit comments