Commit b2d8daf8 authored by Armin's avatar Armin
Browse files

Converted all description strings to PROGMEM

parent 7e07c394
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
</option> </option>
<option id="de.innot.avreclipse.cppcompiler.option.def.1867196469" name="Define Syms (-D)" superClass="de.innot.avreclipse.cppcompiler.option.def" useByScannerDiscovery="false"/> <option id="de.innot.avreclipse.cppcompiler.option.def.1867196469" name="Define Syms (-D)" superClass="de.innot.avreclipse.cppcompiler.option.def" useByScannerDiscovery="false"/>
<option id="de.innot.avreclipse.cppcompiler.option.otherflags.1482621375" name="Other flags" superClass="de.innot.avreclipse.cppcompiler.option.otherflags" useByScannerDiscovery="false" value="-x c++" valueType="string"/> <option id="de.innot.avreclipse.cppcompiler.option.otherflags.1482621375" name="Other flags" superClass="de.innot.avreclipse.cppcompiler.option.otherflags" useByScannerDiscovery="false" value="-x c++" valueType="string"/>
<option id="de.innot.avreclipse.cppcompiler.option.verbose.485998240" name="Verbose (-v)" superClass="de.innot.avreclipse.cppcompiler.option.verbose" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<inputType id="de.innot.avreclipse.cppcompiler.input.1320840307" superClass="de.innot.avreclipse.cppcompiler.input"/> <inputType id="de.innot.avreclipse.cppcompiler.input.1320840307" superClass="de.innot.avreclipse.cppcompiler.input"/>
</tool> </tool>
<tool id="de.innot.avreclipse.tool.linker.winavr.app.release.1098932434" name="AVR C Linker" superClass="de.innot.avreclipse.tool.linker.winavr.app.release"/> <tool id="de.innot.avreclipse.tool.linker.winavr.app.release.1098932434" name="AVR C Linker" superClass="de.innot.avreclipse.tool.linker.winavr.app.release"/>
......
...@@ -73,14 +73,19 @@ const int LED_PIN = 13; ...@@ -73,14 +73,19 @@ const int LED_PIN = 13;
/* /*
* Command definitions * Command definitions
*/ */
const char Serial_Number[] = "Serial Number: "; const char Serial_Number[] PROGMEM = "Serial Number: ";
const char Manufacture_Date[] = "Manufacture Date (YYYY-MM-DD):"; const char Manufacture_Date[] PROGMEM = "Manufacture Date (YYYY-MM-DD):";
const char Design_Capacity[] PROGMEM = "Design Capacity: "; const char Design_Capacity[] PROGMEM = "Design Capacity: ";
const char Design_Voltage[] PROGMEM = "Design Voltage: "; const char Design_Voltage[] PROGMEM = "Design Voltage: ";
const char Charging_Current[] PROGMEM = "Charging Current: "; const char Charging_Current[] PROGMEM = "Charging Current: ";
const char Charging_Voltage[] PROGMEM = "Charging Voltage: "; const char Charging_Voltage[] PROGMEM = "Charging Voltage: ";
const char Remaining_Capacity_Alarm[] PROGMEM = "Remaining Capacity Alarm: "; const char Remaining_Capacity_Alarm[] PROGMEM = "Remaining Capacity Alarm: ";
const char Specification_Info[] PROGMEM = "Specification Info: ";
const char Cycle_Count[] PROGMEM = "Cycle Count: ";
const char Max_Error_of_charge_calculation[] PROGMEM = "Max Error of charge calculation (%): ";
const char RemainingTimeAlarm[] PROGMEM = "RemainingTimeAlarm: ";
const char Battery_Mode[] PROGMEM = "Battery Mode (BIN): 0b";
const char Pack_Status[] PROGMEM = "Pack Status (BIN): ";
#define INDEX_OF_DESIGN_VOLTAGE 3 // to retrieve last value for mWh to mA conversion #define INDEX_OF_DESIGN_VOLTAGE 3 // to retrieve last value for mWh to mA conversion
struct SBMFunctionDescriptionStruct sSBMStaticFunctionDescriptionArray[] = { { struct SBMFunctionDescriptionStruct sSBMStaticFunctionDescriptionArray[] = { {
SERIAL_NUM, Serial_Number }, { SERIAL_NUM, Serial_Number }, {
...@@ -89,34 +94,39 @@ DESIGN_CAPACITY, Design_Capacity, &printCapacity }, { ...@@ -89,34 +94,39 @@ DESIGN_CAPACITY, Design_Capacity, &printCapacity }, {
DESIGN_VOLTAGE, Design_Voltage, &printVoltage }, { DESIGN_VOLTAGE, Design_Voltage, &printVoltage }, {
CHARGING_CURRENT, Charging_Current, &printCurrent }, { CHARGING_CURRENT, Charging_Current, &printCurrent }, {
CHARGING_VOLTAGE, Charging_Voltage, &printVoltage }, { CHARGING_VOLTAGE, Charging_Voltage, &printVoltage }, {
SPEC_INFO, "Specification Info: " }, { SPEC_INFO, Specification_Info }, {
CYCLE_COUNT, "Cycle Count: " }, { CYCLE_COUNT, Cycle_Count }, {
MAX_ERROR, "Max Error of charge calculation (%): " }, { MAX_ERROR, Max_Error_of_charge_calculation }, {
REMAINING_TIME_ALARM, "RemainingTimeAlarm: ", &printTime }, { REMAINING_TIME_ALARM, RemainingTimeAlarm, &printTime }, {
REMAINING_CAPACITY_ALARM, Remaining_Capacity_Alarm, &printCapacity }, { REMAINING_CAPACITY_ALARM, Remaining_Capacity_Alarm, &printCapacity }, {
BATTERY_MODE, "Battery Mode (BIN): 0b", &printBatteryMode }, { BATTERY_MODE, Battery_Mode, &printBatteryMode }, {
PACK_STATUS, "Pack Status (BIN): ", &printBinary } }; PACK_STATUS, Pack_Status, &printBinary } };
const char Full_Charge_Capacity[] PROGMEM = "Full Charge Capacity: "; const char Full_Charge_Capacity[] PROGMEM = "Full Charge Capacity: ";
const char Remaining_Capacity[] PROGMEM = "Remaining Capacity: "; const char Remaining_Capacity[] PROGMEM = "Remaining Capacity: ";
const char Relative_Charge[] PROGMEM = "Relative Charge: ";
const char Absolute_Charge[] PROGMEM = "Absolute Charge(%): ";
const char Minutes_remaining_until_empty[] PROGMEM = "Minutes remaining until empty: ";
const char Average_minutes_remaining_until_empty[] PROGMEM = "Average minutes remaining until empty: ";
const char Minutes_remaining_for_full_charge[] PROGMEM = "Minutes remaining for full charge: ";
const char Battery_Status[] PROGMEM = "Battery Status (BIN): 0b";
const char Voltage[] PROGMEM = "Voltage: "; const char Voltage[] PROGMEM = "Voltage: ";
const char Current[] PROGMEM = "Current: "; const char Current[] PROGMEM = "Current: ";
const char Average_Current_of_last_minute[] PROGMEM = "Average Current of last minute: "; const char Average_Current_of_last_minute[] PROGMEM = "Average Current of last minute: ";
const char Temperature[] PROGMEM = "Temperature: ";
struct SBMFunctionDescriptionStruct sSBMDynamicFunctionDescriptionArray[] = { { struct SBMFunctionDescriptionStruct sSBMDynamicFunctionDescriptionArray[] = { {
FULL_CHARGE_CAPACITY, Full_Charge_Capacity, &printCapacity }, { FULL_CHARGE_CAPACITY, Full_Charge_Capacity, &printCapacity }, {
REMAINING_CAPACITY, Remaining_Capacity, &printCapacity, "Capacity " }, { REMAINING_CAPACITY, Remaining_Capacity, &printCapacity, "Capacity " }, {
RELATIVE_SOC, "Relative Charge: ", &printPercentage, " rel Charge " }, { RELATIVE_SOC, Relative_Charge, &printPercentage, " rel Charge " }, {
ABSOLUTE_SOC, "Absolute Charge(%): ", NULL, "% Abs Charge " }, { ABSOLUTE_SOC, Absolute_Charge, NULL, "% Abs Charge " }, {
RUN_TIME_TO_EMPTY, "Minutes remaining until empty: ", &printTime }, { RUN_TIME_TO_EMPTY, Minutes_remaining_until_empty, &printTime }, {
AVERAGE_TIME_TO_EMPTY, "Average minutes remaining until empty: ", &printTime, " min to Empty " }, { AVERAGE_TIME_TO_EMPTY, Average_minutes_remaining_until_empty, &printTime, " min to Empty " }, {
TIME_TO_FULL, "Minutes remaining for full charge: ", &printTime, " min to Full " }, { TIME_TO_FULL, Minutes_remaining_for_full_charge, &printTime, " min to Full " }, {
BATTERY_STATUS, "Battery Status (BIN): 0b", &printBatteryStatus }, { BATTERY_STATUS, Battery_Status, &printBatteryStatus }, {
VOLTAGE, Voltage, &printVoltage, "Voltage: " }, { VOLTAGE, Voltage, &printVoltage, "Voltage: " }, {
CURRENT, Current, &printCurrent, "Current: " }, { CURRENT, Current, &printCurrent, "Current: " }, {
AverageCurrent, Average_Current_of_last_minute, &printCurrent }, { AverageCurrent, Average_Current_of_last_minute, &printCurrent }, {
TEMPERATURE, "Temperature: ", &printTemperature } }; TEMPERATURE, Temperature, &printTemperature } };
/* /*
* These aren't part of the standard, but work with some packs. * These aren't part of the standard, but work with some packs.
...@@ -125,6 +135,8 @@ const char Cell_1_Voltage[] PROGMEM = "Cell 1 Voltage: "; ...@@ -125,6 +135,8 @@ const char Cell_1_Voltage[] PROGMEM = "Cell 1 Voltage: ";
const char Cell_2_Voltage[] PROGMEM = "Cell 2 Voltage: "; const char Cell_2_Voltage[] PROGMEM = "Cell 2 Voltage: ";
const char Cell_3_Voltage[] PROGMEM = "Cell 3 Voltage: "; const char Cell_3_Voltage[] PROGMEM = "Cell 3 Voltage: ";
const char Cell_4_Voltage[] PROGMEM = "Cell 4 Voltage: "; const char Cell_4_Voltage[] PROGMEM = "Cell 4 Voltage: ";
const char State_of_Health[] PROGMEM = "State of Health: ";
int nonStandardInfoSupportedByPack = 0; // 0 not initialized, 1 supported, > 1 not supported int nonStandardInfoSupportedByPack = 0; // 0 not initialized, 1 supported, > 1 not supported
struct SBMFunctionDescriptionStruct sSBMNonStandardFunctionDescriptionArray[] = { { struct SBMFunctionDescriptionStruct sSBMNonStandardFunctionDescriptionArray[] = { {
...@@ -132,7 +144,7 @@ CELL1_VOLTAGE, Cell_1_Voltage, &printVoltage }, { ...@@ -132,7 +144,7 @@ CELL1_VOLTAGE, Cell_1_Voltage, &printVoltage }, {
CELL2_VOLTAGE, Cell_2_Voltage, &printVoltage }, { CELL2_VOLTAGE, Cell_2_Voltage, &printVoltage }, {
CELL3_VOLTAGE, Cell_3_Voltage, &printVoltage }, { CELL3_VOLTAGE, Cell_3_Voltage, &printVoltage }, {
CELL4_VOLTAGE, Cell_4_Voltage, &printVoltage }, { CELL4_VOLTAGE, Cell_4_Voltage, &printVoltage }, {
STATE_OF_HEALTH, "State of Health: " } }; STATE_OF_HEALTH, State_of_Health } };
bool sCapacityModePower = false; // false = current, true = power bool sCapacityModePower = false; // false = current, true = power
uint16_t sDesignVoltage; // to retrieve last value for mWh to mA conversion uint16_t sDesignVoltage; // to retrieve last value for mWh to mA conversion
...@@ -140,15 +152,21 @@ uint16_t sDesignVoltage; // to retrieve last value for mWh to mA conversion ...@@ -140,15 +152,21 @@ uint16_t sDesignVoltage; // to retrieve last value for mWh to mA conversion
/* /*
* Value depends on capacity mode * Value depends on capacity mode
*/ */
const char TimeToFull_at_rate[] PROGMEM = "TimeToFull at rate: ";
const char TimeToEmpty_at_rate[] PROGMEM = "TimeToEmpty at rate: ";
const char Can_be_delivered_for_10_seconds_at_rate[] PROGMEM = "Can be delivered for 10 seconds at rate: ";
struct SBMFunctionDescriptionStruct sSBMATRateFunctionDescriptionArray[] = { { struct SBMFunctionDescriptionStruct sSBMATRateFunctionDescriptionArray[] = { {
AtRateTimeToFull, "TimeToFull at rate: ", &printTime }, { AtRateTimeToFull, TimeToFull_at_rate, &printTime }, {
AtRateTimeToEmpty, "TimeToEmpty at rate: ", &printTime }, { AtRateTimeToEmpty, TimeToEmpty_at_rate, &printTime }, {
AtRateOK, "Can be delivered for 10 seconds at rate: " }, }; AtRateOK, Can_be_delivered_for_10_seconds_at_rate } };
const char Charging_Status[] PROGMEM = "Charging Status: ";
const char Operation_Status[] PROGMEM = "Operation Status: ";
const char Pack_Voltage[] PROGMEM = "Pack Voltage: "; const char Pack_Voltage[] PROGMEM = "Pack Voltage: ";
struct SBMFunctionDescriptionStruct sSBMbq20z70FunctionDescriptionArray[] = { { struct SBMFunctionDescriptionStruct sSBMbq20z70FunctionDescriptionArray[] = { {
BQ20Z70_ChargingStatus, "Charging Status: ", &printBinary }, { BQ20Z70_ChargingStatus, Charging_Status, &printBinary }, {
BQ20Z70_OperationStatus, "Operation Status: ", &printBinary }, { BQ20Z70_OperationStatus, Operation_Status, &printBinary }, {
BQ20Z70_PackVoltage, Pack_Voltage, &printVoltage } }; BQ20Z70_PackVoltage, Pack_Voltage, &printVoltage } };
/* /*
...@@ -343,7 +361,7 @@ void printDescriptionPGM(const char * aDescription) { ...@@ -343,7 +361,7 @@ void printDescriptionPGM(const char * aDescription) {
void printValue(struct SBMFunctionDescriptionStruct* aSBMFunctionDescription, uint16_t tActualValue) { void printValue(struct SBMFunctionDescriptionStruct* aSBMFunctionDescription, uint16_t tActualValue) {
{ {
if (aSBMFunctionDescription->ValueFormatter == NULL) { if (aSBMFunctionDescription->ValueFormatter == NULL) {
Serial.print(aSBMFunctionDescription->Description); Serial.print((const __FlashStringHelper *) aSBMFunctionDescription->Description);
Serial.println(tActualValue); Serial.println(tActualValue);
aSBMFunctionDescription->lastValue = tActualValue; aSBMFunctionDescription->lastValue = tActualValue;
} else { } else {
...@@ -381,13 +399,13 @@ void readWordAndPrint(struct SBMFunctionDescriptionStruct *aSBMFunctionDescripti ...@@ -381,13 +399,13 @@ void readWordAndPrint(struct SBMFunctionDescriptionStruct *aSBMFunctionDescripti
} }
void printBinary(struct SBMFunctionDescriptionStruct * aDescription, uint16_t aValue) { void printBinary(struct SBMFunctionDescriptionStruct * aDescription, uint16_t aValue) {
Serial.print(aDescription->Description); Serial.print((const __FlashStringHelper *) aDescription->Description);
Serial.print("0b"); Serial.print("0b");
Serial.println(aValue, BIN); Serial.println(aValue, BIN);
} }
void printSigned(struct SBMFunctionDescriptionStruct * aDescription, uint16_t aValue) { void printSigned(struct SBMFunctionDescriptionStruct * aDescription, uint16_t aValue) {
Serial.print(aDescription->Description); Serial.print((const __FlashStringHelper *) aDescription->Description);
Serial.println((int) aValue); Serial.println((int) aValue);
} }
...@@ -425,7 +443,7 @@ void printCapacity(struct SBMFunctionDescriptionStruct * aDescription, uint16_t ...@@ -425,7 +443,7 @@ void printCapacity(struct SBMFunctionDescriptionStruct * aDescription, uint16_t
} }
void printPercentage(struct SBMFunctionDescriptionStruct * aDescription, uint16_t aPercentage) { void printPercentage(struct SBMFunctionDescriptionStruct * aDescription, uint16_t aPercentage) {
Serial.print(aDescription->Description); Serial.print((const __FlashStringHelper *) aDescription->Description);
Serial.print(aPercentage); Serial.print(aPercentage);
Serial.println(" %"); Serial.println(" %");
if (aDescription->DescriptionLCD != NULL) { if (aDescription->DescriptionLCD != NULL) {
...@@ -437,7 +455,7 @@ void printPercentage(struct SBMFunctionDescriptionStruct * aDescription, uint16_ ...@@ -437,7 +455,7 @@ void printPercentage(struct SBMFunctionDescriptionStruct * aDescription, uint16_
} }
void printTime(struct SBMFunctionDescriptionStruct * aDescription, uint16_t aMinutes) { void printTime(struct SBMFunctionDescriptionStruct * aDescription, uint16_t aMinutes) {
Serial.print(aDescription->Description); Serial.print((const __FlashStringHelper *) aDescription->Description);
if (aMinutes == 65535) { if (aMinutes == 65535) {
Serial.println(F("Battery not beeing (dis)charged")); Serial.println(F("Battery not beeing (dis)charged"));
} else { } else {
...@@ -491,7 +509,7 @@ void printCurrent(struct SBMFunctionDescriptionStruct * aDescription, uint16_t a ...@@ -491,7 +509,7 @@ void printCurrent(struct SBMFunctionDescriptionStruct * aDescription, uint16_t a
*/ */
void printTemperature(struct SBMFunctionDescriptionStruct * aDescription, uint16_t aTemperature) { void printTemperature(struct SBMFunctionDescriptionStruct * aDescription, uint16_t aTemperature) {
if (aTemperature < aDescription->lastValue - 100 || aDescription->lastValue + 100 < aTemperature) { if (aTemperature < aDescription->lastValue - 100 || aDescription->lastValue + 100 < aTemperature) {
Serial.print(aDescription->Description); Serial.print((const __FlashStringHelper *) aDescription->Description);
Serial.print((float) (aTemperature / 10.0) - 273.15); Serial.print((float) (aTemperature / 10.0) - 273.15);
Serial.println(" C"); Serial.println(" C");
} }
...@@ -501,7 +519,7 @@ void printTemperature(struct SBMFunctionDescriptionStruct * aDescription, uint16 ...@@ -501,7 +519,7 @@ void printTemperature(struct SBMFunctionDescriptionStruct * aDescription, uint16
* Format as ISO date * Format as ISO date
*/ */
void printManufacturerDate(struct SBMFunctionDescriptionStruct * aDescription, uint16_t aDate) { void printManufacturerDate(struct SBMFunctionDescriptionStruct * aDescription, uint16_t aDate) {
Serial.print(aDescription->Description); Serial.print((const __FlashStringHelper *) aDescription->Description);
int tDay = aDate & 0x1F; int tDay = aDate & 0x1F;
int tMonth = (aDate >> 5) & 0x0F; int tMonth = (aDate >> 5) & 0x0F;
...@@ -516,7 +534,7 @@ void printManufacturerDate(struct SBMFunctionDescriptionStruct * aDescription, u ...@@ -516,7 +534,7 @@ void printManufacturerDate(struct SBMFunctionDescriptionStruct * aDescription, u
} }
void printBatteryMode(struct SBMFunctionDescriptionStruct * aDescription, uint16_t aMode) { void printBatteryMode(struct SBMFunctionDescriptionStruct * aDescription, uint16_t aMode) {
Serial.print(aDescription->Description); Serial.print((const __FlashStringHelper *) aDescription->Description);
Serial.println(aMode, BIN); Serial.println(aMode, BIN);
if (aMode & INTERNAL_CHARGE_CONTROLLER) { if (aMode & INTERNAL_CHARGE_CONTROLLER) {
...@@ -547,7 +565,7 @@ void printBatteryMode(struct SBMFunctionDescriptionStruct * aDescription, uint16 ...@@ -547,7 +565,7 @@ void printBatteryMode(struct SBMFunctionDescriptionStruct * aDescription, uint16
} }
} }
void printBatteryStatus(struct SBMFunctionDescriptionStruct * aDescription, uint16_t aStatus) { void printBatteryStatus(struct SBMFunctionDescriptionStruct * aDescription, uint16_t aStatus) {
Serial.print(aDescription->Description); Serial.print((const __FlashStringHelper *) aDescription->Description);
Serial.println(aStatus, BIN); Serial.println(aStatus, BIN);
/* /*
* Error Bits * Error Bits
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment