|
@@ -2,9 +2,9 @@
|
|
|
* Module_LcmControl.c
|
|
|
*
|
|
|
* Created on : 2020-10-20
|
|
|
- * Update on : 2021-12-20
|
|
|
+ * Update on : 2021-12-24
|
|
|
* Author : Folus Wen, Eason Yang
|
|
|
- * Version : V0.24
|
|
|
+ * Version : V0.25
|
|
|
*
|
|
|
*/
|
|
|
|
|
@@ -58,7 +58,6 @@ void setPriceFromWebsite(float monry_rate);
|
|
|
void setAuthorizationPage(uint8_t gun_index);
|
|
|
float getPresentFinalCost(uint8_t gun_index);
|
|
|
void setGunPluginAnimation(uint8_t gun_index);
|
|
|
-void setPresentChargedEnergy(uint8_t gun_index);
|
|
|
void setPresentChargedgPower(uint8_t gun_index);
|
|
|
void setPlugAndChargeAnimation(uint8_t gun_index);
|
|
|
void setPresentChargedDuration(uint8_t gun_index);
|
|
@@ -72,6 +71,7 @@ void setDefaultValue(uint8_t gun_index, uint8_t system_mode);
|
|
|
void setQRcodeContent(char *input, uint8_t length, uint8_t mode);
|
|
|
void setBillingFromBackend(uint8_t gun_index, uint8_t system_mode);
|
|
|
void setConnectionAnimation(uint8_t gun_index, uint8_t system_mode);
|
|
|
+void setPresentChargedEnergy(uint8_t gun_index, uint8_t system_mode);
|
|
|
void setMarqueeControl(uint16_t address, uint8_t gun_index, uint8_t type);
|
|
|
void setCurrencyAndUnitFromBackend(uint8_t type_price,uint8_t type_currency_unit, uint8_t gun_index);
|
|
|
|
|
@@ -85,7 +85,7 @@ enum TMR_IDX
|
|
|
TMR_IDX_PLUGIN,
|
|
|
TMR_IDX_ALARM,
|
|
|
TMR_IDX_PRICE,
|
|
|
- TMR_IDX_5,
|
|
|
+ TMR_IDX_REFRESH_INFO,
|
|
|
TMR_IDX_6,
|
|
|
TMR_IDX_7,
|
|
|
TMR_IDX_8,
|
|
@@ -100,6 +100,7 @@ struct timespec startTime[AC_QUANTITY][TMR_IDX_SHOW_AUTH_RESULT];
|
|
|
#define TIME_ANIMATION_ALARM 5 // Unit: Second
|
|
|
#define TIME_REFRESH_TIME 5 // Unit: Second
|
|
|
#define TIME_AUTH_RESULT_TIME 5 // Unit: Second
|
|
|
+#define TIME_REFRESH_INFO 3 // Unit: Second
|
|
|
|
|
|
//=======================================
|
|
|
// Declare Variable
|
|
@@ -113,7 +114,7 @@ int Uart1Fd;
|
|
|
//=======================================
|
|
|
// Record version and date
|
|
|
//=======================================
|
|
|
-char *FIRMWARE_UPDATE_IMAGE[3] = {"V0.24", "2021-12-14", "REV.02.00"};
|
|
|
+char *FIRMWARE_UPDATE_IMAGE[3] = {"V0.25", "2021-12-24", "REV.02.00"};
|
|
|
|
|
|
//=======================================
|
|
|
// Common routine
|
|
@@ -420,6 +421,7 @@ void page_preparing(uint8_t gun_index, uint8_t system_mode)
|
|
|
else
|
|
|
{
|
|
|
setConnectionAnimation(gun_index, system_mode);
|
|
|
+ setPresentChargedEnergy(gun_index, system_mode);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
@@ -435,12 +437,15 @@ void page_preparing(uint8_t gun_index, uint8_t system_mode)
|
|
|
setPresentConnectionTimeout(gun_index);
|
|
|
setConnectionAnimation(gun_index, system_mode);
|
|
|
setGunPluginAnimation(gun_index);
|
|
|
+ setPresentChargedEnergy(gun_index, system_mode);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void page_charging(uint8_t gun_index, uint8_t system_mode)
|
|
|
{
|
|
|
+ static char runningCost[256] = {0};
|
|
|
+
|
|
|
if((getCurrentPage() != SYSTEM_SCREEN_CHARGING) && (!ShmCharger->isAuthrizing && !ShmCharger->isGetAuthResult))
|
|
|
{
|
|
|
setCurrentPage(SYSTEM_SCREEN_CHARGING);
|
|
@@ -451,37 +456,44 @@ void page_charging(uint8_t gun_index, uint8_t system_mode)
|
|
|
{
|
|
|
setConnectionAnimation(gun_index, system_mode);
|
|
|
setPresentChargedDuration(gun_index);
|
|
|
- setPresentChargedEnergy(gun_index);
|
|
|
setPresentChargedgPower(gun_index);
|
|
|
|
|
|
- if((ShmSysConfigAndInfo->SysInfo.OcppConnStatus == ON))
|
|
|
- {
|
|
|
- if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
|
|
|
- {
|
|
|
- setRunningCost(gun_index, TOTAL_COST);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- // DISPLAY BY OCPP 2.0.1
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
+ if((getDiffSecNow(startTime[gun_index][TMR_IDX_REFRESH_INFO]) >= TIME_REFRESH_INFO) || (strcmp((char*)ShmOCPP16Data->Cost.RunningCost[gun_index].description, runningCost) != 0))
|
|
|
{
|
|
|
- if(ShmSysConfigAndInfo->SysConfig.BillingData.isBilling == ON)
|
|
|
+ setPresentChargedEnergy(gun_index, system_mode);
|
|
|
+ memcpy((char*) runningCost,(char*)ShmOCPP16Data->Cost.RunningCost[gun_index].description,ARRAY_SIZE(ShmOCPP16Data->Cost.RunningCost[gun_index].description));
|
|
|
+
|
|
|
+ if((ShmSysConfigAndInfo->SysInfo.OcppConnStatus == ON))
|
|
|
{
|
|
|
- setDisplayValue(ICON_CHARGING_COST, APPEAR);
|
|
|
- setPresentFinalCost(getPresentFinalCost(gun_index));
|
|
|
+ if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
|
|
|
+ {
|
|
|
+ setRunningCost(gun_index, TOTAL_COST);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // DISPLAY BY OCPP 2.0.1
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- // User spend cost
|
|
|
- setDisplayValue(ICON_CHARGING_COST, DISAPPEAR);
|
|
|
- setDisplayValue(TEXT_CHARGING_COST, DISAPPEAR);
|
|
|
+ if(ShmSysConfigAndInfo->SysConfig.BillingData.isBilling == ON)
|
|
|
+ {
|
|
|
+ setDisplayValue(ICON_CHARGING_COST, APPEAR);
|
|
|
+ setPresentFinalCost(getPresentFinalCost(gun_index));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // User spend cost
|
|
|
+ setDisplayValue(ICON_CHARGING_COST, DISAPPEAR);
|
|
|
+ setDisplayValue(TEXT_CHARGING_COST, DISAPPEAR);
|
|
|
|
|
|
- // User account balance
|
|
|
- setDisplayValue(ICON_COMPLETE_WALLET, DISAPPEAR);
|
|
|
- setDisplayValue(TEXT_REMAINING_ACCOUNT_BALANCE, DISAPPEAR);
|
|
|
+ // User account balance
|
|
|
+ setDisplayValue(ICON_COMPLETE_WALLET, DISAPPEAR);
|
|
|
+ setDisplayValue(TEXT_REMAINING_ACCOUNT_BALANCE, DISAPPEAR);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_REFRESH_INFO]);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -513,7 +525,7 @@ void page_complete(uint8_t gun_index, uint8_t system_mode)
|
|
|
}
|
|
|
|
|
|
setPresentChargedDuration(gun_index);
|
|
|
- setPresentChargedEnergy(gun_index);
|
|
|
+ setPresentChargedEnergy(gun_index, system_mode);
|
|
|
|
|
|
if((ShmSysConfigAndInfo->SysInfo.OcppConnStatus == ON))
|
|
|
{
|
|
@@ -562,7 +574,7 @@ void page_terminating(uint8_t gun_index, uint8_t system_mode)
|
|
|
else
|
|
|
{
|
|
|
setPresentChargedDuration(gun_index);
|
|
|
- setPresentChargedEnergy(gun_index);
|
|
|
+ setPresentChargedEnergy(gun_index, system_mode);
|
|
|
setPresentChargedgPower(gun_index);
|
|
|
|
|
|
if((ShmSysConfigAndInfo->SysInfo.OcppConnStatus == ON))
|
|
@@ -1435,28 +1447,33 @@ void setRunningCost(uint8_t gun_index, uint8_t type)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if((strstr((char*)ShmOCPP16Data->Cost.RunningCost[gun_index].description, "Total Cost:") > 0))
|
|
|
+ if(strlen((char*)ShmOCPP16Data->Cost.RunningCost[gun_index].description) > 0)
|
|
|
{
|
|
|
- // APPEAR COST ICON
|
|
|
- setDisplayValue(ICON_CHARGING_COST, APPEAR);
|
|
|
+ if((strstr((char*)ShmOCPP16Data->Cost.RunningCost[gun_index].description, "Total Cost:") > 0))
|
|
|
+ {
|
|
|
+ // APPEAR COST ICON
|
|
|
+ setDisplayValue(ICON_CHARGING_COST, APPEAR);
|
|
|
|
|
|
- // APPEAR COST TEXT
|
|
|
- strcpy((char*)tmp,(char*)ShmOCPP16Data->Cost.RunningCost[gun_index].description);
|
|
|
- split((char**)splitString, tmp, Symbol);
|
|
|
- memcpy(input_data, splitString[3], strlen(splitString[3]));
|
|
|
- length = strlen(input_data);
|
|
|
- trim_string(input_data,length);
|
|
|
- memcpy(output_data ,input_data, strlen(input_data));
|
|
|
- lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_COST, output_data, ARRAY_SIZE(output_data));
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- setDisplayValue(ICON_CHARGING_COST, APPEAR);
|
|
|
+ // APPEAR COST TEXT
|
|
|
+ strcpy((char*)tmp,(char*)ShmOCPP16Data->Cost.RunningCost[gun_index].description);
|
|
|
+ split((char**)splitString, tmp, Symbol);
|
|
|
+ memcpy(input_data, splitString[3], strlen(splitString[3]));
|
|
|
+ length = strlen(input_data);
|
|
|
+ trim_string(input_data,length);
|
|
|
+ memcpy(output_data ,input_data, strlen(input_data));
|
|
|
+ lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_COST, output_data, ARRAY_SIZE(output_data));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ setDisplayValue(ICON_CHARGING_COST, APPEAR);
|
|
|
|
|
|
- strcpy((char*)cost_empty, "-----");
|
|
|
- string2ByteArray(cost_empty, output_data);
|
|
|
- lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_COST, output_data, ARRAY_SIZE(output_data));
|
|
|
+ strcpy((char*)cost_empty, "-----");
|
|
|
+ string2ByteArray(cost_empty, output_data);
|
|
|
+ lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_COST, output_data, ARRAY_SIZE(output_data));
|
|
|
+ }
|
|
|
}
|
|
|
+ else
|
|
|
+ {}
|
|
|
}
|
|
|
|
|
|
break;
|
|
@@ -1954,7 +1971,7 @@ void setPresentChargedgPower(uint8_t gun_index)
|
|
|
//=======================================
|
|
|
// Setting Present Charging [ Energy ]
|
|
|
//=======================================
|
|
|
-void setPresentChargedEnergy(uint8_t gun_index)
|
|
|
+void setPresentChargedEnergy(uint8_t gun_index, uint8_t system_mode)
|
|
|
{
|
|
|
uint8_t data[16];
|
|
|
uint8_t energy[16];
|
|
@@ -1962,9 +1979,22 @@ void setPresentChargedEnergy(uint8_t gun_index)
|
|
|
memset(data, 0x00, ARRAY_SIZE(data));
|
|
|
memset(energy, 0x00, ARRAY_SIZE(energy));
|
|
|
|
|
|
- sprintf((char *)energy, "%.4f kWh", ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy);
|
|
|
- string2ByteArray(energy, data);
|
|
|
- lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_ENERGY, data, ARRAY_SIZE(data));
|
|
|
+ switch(system_mode)
|
|
|
+ {
|
|
|
+ case SYS_MODE_PREPARING:
|
|
|
+ sprintf((char *)energy, "%s kWh", "0.0000");
|
|
|
+ string2ByteArray(energy, data);
|
|
|
+ lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_ENERGY, data, ARRAY_SIZE(data));
|
|
|
+ break;
|
|
|
+ case SYS_MODE_CHARGING:
|
|
|
+ case SYS_MODE_TERMINATING:
|
|
|
+ case SYS_MODE_COMPLETE:
|
|
|
+ default:
|
|
|
+ sprintf((char *)energy, "%.3f0 kWh", ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy);
|
|
|
+ string2ByteArray(energy, data);
|
|
|
+ lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_ENERGY, data, ARRAY_SIZE(data));
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//=======================================
|
|
@@ -2080,17 +2110,20 @@ void setDefaultValue(uint8_t gun_index, uint8_t system_mode)
|
|
|
setDisplayValue(ICON_PRECHARGING_ANIMATION, CONNECTION_FLASHING_1);
|
|
|
CONNECTION_LEVEL_STATUS = CONNECTION_LEVEL_0;
|
|
|
refreshStartTimer(&startTime[gun_index][TMR_IDX_CONNECTION]);
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_REFRESH_INFO]);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
setDisplayValue(ICON_PREPARING_PLUG_ARROW, PLUGIN_ARROW_1);
|
|
|
GUN_PLUGING_LEVEL_STATUS = GUN_PLUGING_LEVEL_0;
|
|
|
refreshStartTimer(&startTime[gun_index][TMR_IDX_PLUGIN]);
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_REFRESH_INFO]);
|
|
|
}
|
|
|
break;
|
|
|
case SYS_MODE_CHARGING:
|
|
|
setDisplayValue(ICON_CHARGING_ANIMATION, CONNECTION_FLASHING_1);
|
|
|
refreshStartTimer(&startTime[gun_index][TMR_IDX_CONNECTION]);
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_REFRESH_INFO]);
|
|
|
CONNECTION_LEVEL_STATUS = CONNECTION_LEVEL_0;
|
|
|
break;
|
|
|
case SYS_MODE_TERMINATING:
|