@@ -73,14 +73,19 @@ const int LED_PIN = 13;
7373/*
7474 * Command definitions
7575 */
76- const char Serial_Number[] = " Serial Number: " ;
77- const char Manufacture_Date[] = " Manufacture Date (YYYY-MM-DD):" ;
76+ const char Serial_Number[] PROGMEM = " Serial Number: " ;
77+ const char Manufacture_Date[] PROGMEM = " Manufacture Date (YYYY-MM-DD):" ;
7878const char Design_Capacity[] PROGMEM = " Design Capacity: " ;
7979const char Design_Voltage[] PROGMEM = " Design Voltage: " ;
80- const char Charging_Current[] PROGMEM = " Charging Current: " ;
80+ const char Charging_Current[] PROGMEM = " Charging Current: " ;
8181const char Charging_Voltage[] PROGMEM = " Charging Voltage: " ;
8282const char Remaining_Capacity_Alarm[] PROGMEM = " Remaining Capacity Alarm: " ;
83-
83+ const char Specification_Info[] PROGMEM = " Specification Info: " ;
84+ const char Cycle_Count[] PROGMEM = " Cycle Count: " ;
85+ const char Max_Error_of_charge_calculation[] PROGMEM = " Max Error of charge calculation (%): " ;
86+ const char RemainingTimeAlarm[] PROGMEM = " RemainingTimeAlarm: " ;
87+ const char Battery_Mode[] PROGMEM = " Battery Mode (BIN): 0b" ;
88+ const char Pack_Status[] PROGMEM = " Pack Status (BIN): " ;
8489#define INDEX_OF_DESIGN_VOLTAGE 3 // to retrieve last value for mWh to mA conversion
8590struct SBMFunctionDescriptionStruct sSBMStaticFunctionDescriptionArray [] = { {
8691SERIAL_NUM, Serial_Number }, {
@@ -89,34 +94,39 @@ DESIGN_CAPACITY, Design_Capacity, &printCapacity }, {
8994DESIGN_VOLTAGE, Design_Voltage, &printVoltage }, {
9095CHARGING_CURRENT, Charging_Current, &printCurrent }, {
9196CHARGING_VOLTAGE, Charging_Voltage, &printVoltage }, {
92- SPEC_INFO, " Specification Info: " }, {
93- CYCLE_COUNT, " Cycle Count: " }, {
94- MAX_ERROR, " Max Error of charge calculation (%): " }, {
95- REMAINING_TIME_ALARM, " RemainingTimeAlarm: " , &printTime }, {
97+ SPEC_INFO, Specification_Info }, {
98+ CYCLE_COUNT, Cycle_Count }, {
99+ MAX_ERROR, Max_Error_of_charge_calculation }, {
100+ REMAINING_TIME_ALARM, RemainingTimeAlarm, &printTime }, {
96101REMAINING_CAPACITY_ALARM, Remaining_Capacity_Alarm, &printCapacity }, {
97- BATTERY_MODE, " Battery Mode (BIN): 0b " , &printBatteryMode }, {
98- PACK_STATUS, " Pack Status (BIN): " , &printBinary } };
102+ BATTERY_MODE, Battery_Mode , &printBatteryMode }, {
103+ PACK_STATUS, Pack_Status , &printBinary } };
99104
100105const char Full_Charge_Capacity[] PROGMEM = " Full Charge Capacity: " ;
101106const char Remaining_Capacity[] PROGMEM = " Remaining Capacity: " ;
102-
107+ const char Relative_Charge[] PROGMEM = " Relative Charge: " ;
108+ const char Absolute_Charge[] PROGMEM = " Absolute Charge(%): " ;
109+ const char Minutes_remaining_until_empty[] PROGMEM = " Minutes remaining until empty: " ;
110+ const char Average_minutes_remaining_until_empty[] PROGMEM = " Average minutes remaining until empty: " ;
111+ const char Minutes_remaining_for_full_charge[] PROGMEM = " Minutes remaining for full charge: " ;
112+ const char Battery_Status[] PROGMEM = " Battery Status (BIN): 0b" ;
103113const char Voltage[] PROGMEM = " Voltage: " ;
104114const char Current[] PROGMEM = " Current: " ;
105115const char Average_Current_of_last_minute[] PROGMEM = " Average Current of last minute: " ;
106-
116+ const char Temperature[] PROGMEM = " Temperature: " ;
107117struct SBMFunctionDescriptionStruct sSBMDynamicFunctionDescriptionArray [] = { {
108118FULL_CHARGE_CAPACITY, Full_Charge_Capacity, &printCapacity }, {
109119REMAINING_CAPACITY, Remaining_Capacity, &printCapacity, " Capacity " }, {
110- RELATIVE_SOC, " Relative Charge: " , &printPercentage, " rel Charge " }, {
111- ABSOLUTE_SOC, " Absolute Charge(%): " , NULL , " % Abs Charge " }, {
112- RUN_TIME_TO_EMPTY, " Minutes remaining until empty: " , &printTime }, {
113- AVERAGE_TIME_TO_EMPTY, " Average minutes remaining until empty: " , &printTime, " min to Empty " }, {
114- TIME_TO_FULL, " Minutes remaining for full charge: " , &printTime, " min to Full " }, {
115- BATTERY_STATUS, " Battery Status (BIN): 0b " , &printBatteryStatus }, {
120+ RELATIVE_SOC, Relative_Charge , &printPercentage, " rel Charge " }, {
121+ ABSOLUTE_SOC, Absolute_Charge , NULL , " % Abs Charge " }, {
122+ RUN_TIME_TO_EMPTY, Minutes_remaining_until_empty , &printTime }, {
123+ AVERAGE_TIME_TO_EMPTY, Average_minutes_remaining_until_empty , &printTime, " min to Empty " }, {
124+ TIME_TO_FULL, Minutes_remaining_for_full_charge , &printTime, " min to Full " }, {
125+ BATTERY_STATUS, Battery_Status , &printBatteryStatus }, {
116126VOLTAGE, Voltage, &printVoltage, " Voltage: " }, {
117127CURRENT, Current, &printCurrent, " Current: " }, {
118128AverageCurrent, Average_Current_of_last_minute, &printCurrent }, {
119- TEMPERATURE, " Temperature: " , &printTemperature } };
129+ TEMPERATURE, Temperature, &printTemperature } };
120130
121131/*
122132 * These aren't part of the standard, but work with some packs.
@@ -125,30 +135,38 @@ const char Cell_1_Voltage[] PROGMEM = "Cell 1 Voltage: ";
125135const char Cell_2_Voltage[] PROGMEM = " Cell 2 Voltage: " ;
126136const char Cell_3_Voltage[] PROGMEM = " Cell 3 Voltage: " ;
127137const char Cell_4_Voltage[] PROGMEM = " Cell 4 Voltage: " ;
138+ const char State_of_Health[] PROGMEM = " State of Health: " ;
139+
128140
129141int nonStandardInfoSupportedByPack = 0 ; // 0 not initialized, 1 supported, > 1 not supported
130142struct SBMFunctionDescriptionStruct sSBMNonStandardFunctionDescriptionArray [] = { {
131143CELL1_VOLTAGE, Cell_1_Voltage, &printVoltage }, {
132144CELL2_VOLTAGE, Cell_2_Voltage, &printVoltage }, {
133145CELL3_VOLTAGE, Cell_3_Voltage, &printVoltage }, {
134146CELL4_VOLTAGE, Cell_4_Voltage, &printVoltage }, {
135- STATE_OF_HEALTH, " State of Health: " } };
147+ STATE_OF_HEALTH, State_of_Health } };
136148
137149bool sCapacityModePower = false ; // false = current, true = power
138150uint16_t sDesignVoltage ; // to retrieve last value for mWh to mA conversion
139151
140152/*
141153 * Value depends on capacity mode
142154 */
155+ const char TimeToFull_at_rate[] PROGMEM = " TimeToFull at rate: " ;
156+ const char TimeToEmpty_at_rate[] PROGMEM = " TimeToEmpty at rate: " ;
157+ const char Can_be_delivered_for_10_seconds_at_rate[] PROGMEM = " Can be delivered for 10 seconds at rate: " ;
158+
143159struct SBMFunctionDescriptionStruct sSBMATRateFunctionDescriptionArray [] = { {
144- AtRateTimeToFull, " TimeToFull at rate: " , &printTime }, {
145- AtRateTimeToEmpty, " TimeToEmpty at rate: " , &printTime }, {
146- AtRateOK, " Can be delivered for 10 seconds at rate: " }, };
160+ AtRateTimeToFull, TimeToFull_at_rate , &printTime }, {
161+ AtRateTimeToEmpty, TimeToEmpty_at_rate , &printTime }, {
162+ AtRateOK, Can_be_delivered_for_10_seconds_at_rate } };
147163
164+ const char Charging_Status[] PROGMEM = " Charging Status: " ;
165+ const char Operation_Status[] PROGMEM = " Operation Status: " ;
148166const char Pack_Voltage[] PROGMEM = " Pack Voltage: " ;
149167struct SBMFunctionDescriptionStruct sSBMbq20z70FunctionDescriptionArray [] = { {
150- BQ20Z70_ChargingStatus, " Charging Status: " , &printBinary }, {
151- BQ20Z70_OperationStatus, " Operation Status: " , &printBinary }, {
168+ BQ20Z70_ChargingStatus, Charging_Status , &printBinary }, {
169+ BQ20Z70_OperationStatus, Operation_Status , &printBinary }, {
152170BQ20Z70_PackVoltage, Pack_Voltage, &printVoltage } };
153171
154172/*
@@ -343,7 +361,7 @@ void printDescriptionPGM(const char * aDescription) {
343361void printValue (struct SBMFunctionDescriptionStruct * aSBMFunctionDescription, uint16_t tActualValue) {
344362 {
345363 if (aSBMFunctionDescription->ValueFormatter == NULL ) {
346- Serial.print (aSBMFunctionDescription->Description );
364+ Serial.print (( const __FlashStringHelper *) aSBMFunctionDescription->Description );
347365 Serial.println (tActualValue);
348366 aSBMFunctionDescription->lastValue = tActualValue;
349367 } else {
@@ -381,13 +399,13 @@ void readWordAndPrint(struct SBMFunctionDescriptionStruct *aSBMFunctionDescripti
381399}
382400
383401void printBinary (struct SBMFunctionDescriptionStruct * aDescription, uint16_t aValue) {
384- Serial.print (aDescription->Description );
402+ Serial.print (( const __FlashStringHelper *) aDescription->Description );
385403 Serial.print (" 0b" );
386404 Serial.println (aValue, BIN);
387405}
388406
389407void printSigned (struct SBMFunctionDescriptionStruct * aDescription, uint16_t aValue) {
390- Serial.print (aDescription->Description );
408+ Serial.print (( const __FlashStringHelper *) aDescription->Description );
391409 Serial.println ((int ) aValue);
392410}
393411
@@ -425,7 +443,7 @@ void printCapacity(struct SBMFunctionDescriptionStruct * aDescription, uint16_t
425443}
426444
427445void printPercentage (struct SBMFunctionDescriptionStruct * aDescription, uint16_t aPercentage) {
428- Serial.print (aDescription->Description );
446+ Serial.print (( const __FlashStringHelper *) aDescription->Description );
429447 Serial.print (aPercentage);
430448 Serial.println (" %" );
431449 if (aDescription->DescriptionLCD != NULL ) {
@@ -437,7 +455,7 @@ void printPercentage(struct SBMFunctionDescriptionStruct * aDescription, uint16_
437455}
438456
439457void printTime (struct SBMFunctionDescriptionStruct * aDescription, uint16_t aMinutes) {
440- Serial.print (aDescription->Description );
458+ Serial.print (( const __FlashStringHelper *) aDescription->Description );
441459 if (aMinutes == 65535 ) {
442460 Serial.println (F (" Battery not beeing (dis)charged" ));
443461 } else {
@@ -491,7 +509,7 @@ void printCurrent(struct SBMFunctionDescriptionStruct * aDescription, uint16_t a
491509 */
492510void printTemperature (struct SBMFunctionDescriptionStruct * aDescription, uint16_t aTemperature) {
493511 if (aTemperature < aDescription->lastValue - 100 || aDescription->lastValue + 100 < aTemperature) {
494- Serial.print (aDescription->Description );
512+ Serial.print (( const __FlashStringHelper *) aDescription->Description );
495513 Serial.print ((float ) (aTemperature / 10.0 ) - 273.15 );
496514 Serial.println (" C" );
497515 }
@@ -501,7 +519,7 @@ void printTemperature(struct SBMFunctionDescriptionStruct * aDescription, uint16
501519 * Format as ISO date
502520 */
503521void printManufacturerDate (struct SBMFunctionDescriptionStruct * aDescription, uint16_t aDate) {
504- Serial.print (aDescription->Description );
522+ Serial.print (( const __FlashStringHelper *) aDescription->Description );
505523
506524 int tDay = aDate & 0x1F ;
507525 int tMonth = (aDate >> 5 ) & 0x0F ;
@@ -516,7 +534,7 @@ void printManufacturerDate(struct SBMFunctionDescriptionStruct * aDescription, u
516534}
517535
518536void printBatteryMode (struct SBMFunctionDescriptionStruct * aDescription, uint16_t aMode) {
519- Serial.print (aDescription->Description );
537+ Serial.print (( const __FlashStringHelper *) aDescription->Description );
520538
521539 Serial.println (aMode, BIN);
522540 if (aMode & INTERNAL_CHARGE_CONTROLLER) {
@@ -547,7 +565,7 @@ void printBatteryMode(struct SBMFunctionDescriptionStruct * aDescription, uint16
547565 }
548566}
549567void printBatteryStatus (struct SBMFunctionDescriptionStruct * aDescription, uint16_t aStatus) {
550- Serial.print (aDescription->Description );
568+ Serial.print (( const __FlashStringHelper *) aDescription->Description );
551569 Serial.println (aStatus, BIN);
552570 /*
553571 * Error Bits
0 commit comments