|
@@ -46,7 +46,8 @@ void setPresentChargedEnergy(uint8_t gun_index);
|
|
|
void setPresentChargingPower(uint8_t gun_index);
|
|
|
void setBatteryPercentageValue(uint8_t gun_index);
|
|
|
void setPresentChargedDuration(uint8_t gun_index);
|
|
|
-void setQRcodeContent(char *input, uint8_t length);
|
|
|
+void setPresentPowerConsumption(uint8_t gun_index);
|
|
|
+void setQRcodeContent(char *input, uint8_t length, uint8_t mode);
|
|
|
void setDisplayValue(uint16_t address, uint8_t value);
|
|
|
void setGunPluginAnimation(uint8_t gun_index);
|
|
|
void setBatteryAnimation(uint8_t gun_index, uint8_t system_mode);
|
|
@@ -54,6 +55,7 @@ void setConnectionAnimation(uint8_t gun_index, uint8_t system_mode);
|
|
|
void setPresentFinalCost(float cost);
|
|
|
float getPresentFinalCost(uint8_t gun_index);
|
|
|
void setDefaultValue(uint8_t gun_index, uint8_t system_mode);
|
|
|
+void setStartButtonAnimation(uint8_t gun_index);
|
|
|
|
|
|
void setUserPrice(uint8_t type);
|
|
|
void setDefaultPrice(uint8_t type);
|
|
@@ -68,6 +70,7 @@ void setBackendIcon();
|
|
|
void setEthernetIcon();
|
|
|
void setAlarmCodeAndIcon();
|
|
|
void setBillingFromWebsite();
|
|
|
+void setQRCodeReceipt(uint8_t gun_index);
|
|
|
|
|
|
//=======================================
|
|
|
// Declare Timer
|
|
@@ -80,7 +83,7 @@ enum TMR_IDX
|
|
|
TMR_IDX_ALARM,
|
|
|
TMR_IDX_PRICE,
|
|
|
TMR_IDX_EMULATOR,
|
|
|
- TMR_IDX_6,
|
|
|
+ TMR_IDX_STARTBUTTON,
|
|
|
TMR_IDX_7,
|
|
|
TMR_IDX_8,
|
|
|
TMR_IDX_SHOW_AUTH_RESULT
|
|
@@ -91,8 +94,9 @@ struct timeb startTime[AC_QUANTITY][10];
|
|
|
#define TIME_ANIMATION_PLUGIN 1000
|
|
|
#define TIME_ANIMATION_BATTERY 1000
|
|
|
#define TIME_ANIMATION_CONNECTION 1000
|
|
|
+#define TIME_ANIMATION_START_BUTTON 1000
|
|
|
#define TIME_ANIMATION_ALARM 5000
|
|
|
-#define TIME_REFRESH_TIME 2000
|
|
|
+#define TIME_REFRESH_TIME 5000
|
|
|
#define TIME_AUTH_RESULT_TIME 5000
|
|
|
|
|
|
//=======================================
|
|
@@ -101,6 +105,7 @@ struct timeb startTime[AC_QUANTITY][10];
|
|
|
uint8_t BATTERY_LEVEL_STATUS = BATTERY_LEVEL_5;
|
|
|
uint8_t CONNECTION_LEVEL_STATUS = CONNECTION_LEVEL_0;
|
|
|
uint8_t GUN_PLUGING_LEVEL_STATUS = GUN_PLUGING_LEVEL_0;
|
|
|
+uint8_t START_BUTTON_LEVEL_STATUS = START_BUTTON_LEVEL_0;
|
|
|
uint8_t WarningCount = 255;
|
|
|
|
|
|
int Uart1Fd;
|
|
@@ -116,8 +121,7 @@ uint8_t isCharging = YES;
|
|
|
//=======================================
|
|
|
// Record version and date
|
|
|
//=======================================
|
|
|
-char *FIRMWARE_UPDATE_IMAGE[3] = {"V0.18", "2021-06-23", "REV.01.00"};
|
|
|
-
|
|
|
+char *FIRMWARE_UPDATE_IMAGE[3] = {"V0.19", "2021-09-28", "REV.01.00"};
|
|
|
|
|
|
//=======================================
|
|
|
// Common routine
|
|
@@ -275,23 +279,46 @@ void page_booting()
|
|
|
|
|
|
void page_idle(uint8_t gun_index, uint8_t system_mode)
|
|
|
{
|
|
|
- if((getCurrentPage() != SYSTEM_SCREEN_IDLE) && (ShmCharger->gun_info[gun_index].resultAuthorization != VALIDATED_RFID))
|
|
|
+ if(ShmCharger->gun_info[gun_index].isSleepOn == YES)
|
|
|
{
|
|
|
- setCurrentPage(SYSTEM_SCREEN_IDLE);
|
|
|
- setDefaultValue(gun_index, system_mode);
|
|
|
- DEBUG_INFO("Setting page to idle.\n");
|
|
|
+ if((getCurrentPage() != SYSTEM_SCREEN_SLEEP))
|
|
|
+ {
|
|
|
+ setCurrentPage(SYSTEM_SCREEN_SLEEP);
|
|
|
+ START_BUTTON_LEVEL_STATUS = START_BUTTON_LEVEL_0;
|
|
|
+ ftime(&startTime[gun_index][TMR_IDX_STARTBUTTON]);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ setStartButtonAnimation(gun_index);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- setRfidIcon();
|
|
|
- setQRCodeIcon();
|
|
|
-
|
|
|
- if(isEmulator == YES)
|
|
|
+ if(ShmCharger->gun_info[gun_index].isCheckPowerConsumption == YES)
|
|
|
{
|
|
|
- //if(isCharging == YES)
|
|
|
- //PERCENTAGE = 0;
|
|
|
- //else
|
|
|
- //PERCENTAGE = 100;
|
|
|
+ setCurrentPage(SYSTEM_SCREEN_POWER_CONSUMPTION);
|
|
|
+ setDisplayValue(ICON_POWER_CONSUMPTION, APPEAR);
|
|
|
+ setPresentPowerConsumption(gun_index);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if((getCurrentPage() != SYSTEM_SCREEN_IDLE) && (ShmCharger->gun_info[gun_index].resultAuthorization != VALIDATED_RFID))
|
|
|
+ {
|
|
|
+ setCurrentPage(SYSTEM_SCREEN_IDLE);
|
|
|
+ setDefaultValue(gun_index, system_mode);
|
|
|
+ DEBUG_INFO("Setting page to idle.\n");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ setRfidIcon();
|
|
|
+ setQRCodeIcon();
|
|
|
+
|
|
|
+ if(isEmulator == YES)
|
|
|
+ {
|
|
|
+ //if(isCharging == YES)
|
|
|
+ //PERCENTAGE = 0;
|
|
|
+ //else
|
|
|
+ //PERCENTAGE = 100;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -393,10 +420,23 @@ void page_complete(uint8_t gun_index, uint8_t system_mode)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- setPresentChargedDuration(gun_index);
|
|
|
setPresentChargedEnergy(gun_index);
|
|
|
+ setPresentChargedDuration(gun_index);
|
|
|
setBatteryAnimation(gun_index, system_mode);
|
|
|
|
|
|
+ // DISPLAY FOR QR CODE RECEIPT
|
|
|
+ if(strstr((char *)&ShmSysConfigAndInfo->SysConfig.OcppServerURL, "phihong"))
|
|
|
+ {
|
|
|
+ setDisplayValue(ICON_THE_CHARGE_COMPLETE, DISAPPEAR);
|
|
|
+ setDisplayValue(ICON_CONNECTION_COMPLETE, DISAPPEAR);
|
|
|
+ setQRCodeReceipt(gun_index);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ setDisplayValue(ICON_THE_CHARGE_COMPLETE, APPEAR);
|
|
|
+ setDisplayValue(ICON_CONNECTION_COMPLETE, APPEAR);
|
|
|
+ }
|
|
|
+
|
|
|
// SHOW FINAL COST AND ACCOUNT BALANCE AFTER THE END OF TRANSACTION
|
|
|
if((ShmSysConfigAndInfo->SysInfo.OcppConnStatus == ON))
|
|
|
{
|
|
@@ -578,7 +618,7 @@ void page_header(uint8_t gun_index, uint8_t system_mode)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- // EVERY 2 SECONDS TO UPDATE PRICE
|
|
|
+ // EVERY 5 SECONDS TO UPDATE PRICE
|
|
|
if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_PRICE]) > (TIME_REFRESH_TIME))
|
|
|
{
|
|
|
ftime(&startTime[gun_index][TMR_IDX_PRICE]);
|
|
@@ -878,6 +918,7 @@ void setPresentFinalCost(float cost)
|
|
|
|
|
|
memset(data, 0x00, ARRAY_SIZE(data));
|
|
|
memset(finalCost, 0x00, ARRAY_SIZE(finalCost));
|
|
|
+
|
|
|
sprintf((char *)finalCost, "%.2f", cost);
|
|
|
string2ByteArray(finalCost, data);
|
|
|
lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_COST_COMPLETE, data, ARRAY_SIZE(data));
|
|
@@ -937,7 +978,7 @@ void setBillingFromBackend(uint8_t gun_index, uint8_t system_mode)
|
|
|
{
|
|
|
/*
|
|
|
* 1. SEARCHING USER PRICE FOR PRICE TEXT
|
|
|
- * 2. SEARCHING USER PRICE FOR URRENCY AND UNIT TO APPEAR
|
|
|
+ * 2. SEARCHING USER PRICE FOR CURRENCY AND UNIT TO APPEAR
|
|
|
*/
|
|
|
setUserPrice(CURRENT_RATE);
|
|
|
setCurrencyAndUnitFromBackend(SET_USER_PRICE, CURRENT_RATE,gun_index);
|
|
@@ -1357,12 +1398,12 @@ void setQRCodeIcon()
|
|
|
if(ShmSysConfigAndInfo->SysConfig.QRCodeMadeMode == NO)
|
|
|
{
|
|
|
length = strlen((char *)ShmSysConfigAndInfo->SysConfig.SystemId);
|
|
|
- setQRcodeContent((char *)ShmSysConfigAndInfo->SysConfig.SystemId, length);
|
|
|
+ setQRcodeContent((char *)ShmSysConfigAndInfo->SysConfig.SystemId, length, QRCODE_FOR_IDLE);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
length = strlen((char *)ShmSysConfigAndInfo->SysConfig.QRCodeContent);
|
|
|
- setQRcodeContent((char *)ShmSysConfigAndInfo->SysConfig.QRCodeContent, length);
|
|
|
+ setQRcodeContent((char *)ShmSysConfigAndInfo->SysConfig.QRCodeContent, length, QRCODE_FOR_IDLE);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
@@ -1372,10 +1413,48 @@ void setQRCodeIcon()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+//=======================================
|
|
|
+// Setting QRCODE icon for receipt
|
|
|
+//=======================================
|
|
|
+void setQRCodeReceipt(uint8_t gun_index)
|
|
|
+{
|
|
|
+ uint8_t length = 0;
|
|
|
+ uint8_t data[128];
|
|
|
+ int TransactionId;
|
|
|
+ unsigned char QRCodeContent[128];
|
|
|
+ unsigned char QRCodeReceipt[128];
|
|
|
+
|
|
|
+ memset(QRCodeReceipt, 0x00, ARRAY_SIZE(QRCodeReceipt));
|
|
|
+ memset(QRCodeReceipt, 0x00, ARRAY_SIZE(QRCodeReceipt));
|
|
|
+ memset(data, 0x00, ARRAY_SIZE(data));
|
|
|
+
|
|
|
+ strcpy((char*)QRCodeContent, "https://ocpp.phihong.com.tw/CDFA/");
|
|
|
+
|
|
|
+ if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
|
|
|
+ {
|
|
|
+ TransactionId = ShmOCPP16Data->StopTransaction[gun_index].TransactionId;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {}
|
|
|
+
|
|
|
+ sprintf((char *)QRCodeReceipt, "%s%d", QRCodeContent,TransactionId);
|
|
|
+ string2ByteArray(QRCodeReceipt, data);
|
|
|
+
|
|
|
+ if(ShmSysConfigAndInfo->SysInfo.OcppConnStatus == ON)
|
|
|
+ {
|
|
|
+ length = strlen((char *)data);
|
|
|
+ setQRcodeContent((char *)data, length, QRCODE_FOR_COMPLETE);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ setDisplayValue(TEXT_QRCODE_RECEIPT, DISAPPEAR);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
//=======================================
|
|
|
// Setting QR code content
|
|
|
//=======================================
|
|
|
-void setQRcodeContent(char *input, uint8_t length)
|
|
|
+void setQRcodeContent(char *input, uint8_t length, uint8_t mode)
|
|
|
{
|
|
|
uint8_t output[length];
|
|
|
int loop = 0;
|
|
@@ -1389,7 +1468,18 @@ void setQRcodeContent(char *input, uint8_t length)
|
|
|
loop++;
|
|
|
}
|
|
|
|
|
|
- lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_QRCODE_CONTENT, output, ARRAY_SIZE(output)+1);
|
|
|
+ switch(mode)
|
|
|
+ {
|
|
|
+ case QRCODE_FOR_IDLE:
|
|
|
+ lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_QRCODE_CONTENT, output, ARRAY_SIZE(output)+1);
|
|
|
+ break;
|
|
|
+ case QRCODE_FOR_COMPLETE:
|
|
|
+ lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_QRCODE_RECEIPT, output, ARRAY_SIZE(output)+1);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_QRCODE_CONTENT, output, ARRAY_SIZE(output)+1);
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//=======================================
|
|
@@ -1709,7 +1799,6 @@ void setConnectionAnimation(uint8_t gun_index, uint8_t system_mode)
|
|
|
|
|
|
break;
|
|
|
case SYS_MODE_CHARGING:
|
|
|
-
|
|
|
if((ShmCharger->gun_info[gun_index].primaryMcuState.relay_state == ON))
|
|
|
{
|
|
|
if((CONNECTION_LEVEL_STATUS == CONNECTION_LEVEL_0) && (DiffTimebWithNow(startTime[gun_index][TMR_IDX_CONNECTION]) > (TIME_ANIMATION_CONNECTION)))
|
|
@@ -1786,6 +1875,24 @@ void setGunPluginAnimation(uint8_t gun_index)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+//=======================================
|
|
|
+// Setting start button animation
|
|
|
+//=======================================
|
|
|
+void setStartButtonAnimation(uint8_t gun_index)
|
|
|
+{
|
|
|
+ if((START_BUTTON_LEVEL_STATUS == START_BUTTON_LEVEL_0) && (DiffTimebWithNow(startTime[gun_index][TMR_IDX_STARTBUTTON]) > (TIME_ANIMATION_START_BUTTON)))
|
|
|
+ {
|
|
|
+ setDisplayValue(ICON_START_BUTTON, APPEAR);
|
|
|
+ START_BUTTON_LEVEL_STATUS = START_BUTTON_LEVEL_1;
|
|
|
+ }
|
|
|
+ else if((START_BUTTON_LEVEL_STATUS == START_BUTTON_LEVEL_1) && (DiffTimebWithNow(startTime[gun_index][TMR_IDX_STARTBUTTON]) > (TIME_ANIMATION_START_BUTTON*2)))
|
|
|
+ {
|
|
|
+ setDisplayValue(ICON_START_BUTTON, DISAPPEAR);
|
|
|
+ START_BUTTON_LEVEL_STATUS = START_BUTTON_LEVEL_0;
|
|
|
+ ftime(&startTime[gun_index][TMR_IDX_STARTBUTTON]);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
//=======================================
|
|
|
// Setting battery SOC value
|
|
|
//=======================================
|
|
@@ -1834,6 +1941,22 @@ void setPresentChargedEnergy(uint8_t gun_index)
|
|
|
lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_ENERGY_CHARGING, data, ARRAY_SIZE(data));
|
|
|
}
|
|
|
|
|
|
+//=======================================
|
|
|
+// Setting present power consumption
|
|
|
+//=======================================
|
|
|
+void setPresentPowerConsumption(uint8_t gun_index)
|
|
|
+{
|
|
|
+ uint8_t data[32];
|
|
|
+ uint8_t powerConsumption[32];
|
|
|
+
|
|
|
+ memset(data, 0x00, ARRAY_SIZE(data));
|
|
|
+ memset(powerConsumption, 0x00, ARRAY_SIZE(powerConsumption));
|
|
|
+
|
|
|
+ sprintf((char *)powerConsumption, "%.4f kWh", ((float)ShmCharger->gun_info[gun_index].powerConsumptionTotal.power_consumption/10000.0));
|
|
|
+ string2ByteArray(powerConsumption, data);
|
|
|
+ lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_POWER_CONSUMPTION, data, ARRAY_SIZE(data));
|
|
|
+}
|
|
|
+
|
|
|
//=======================================
|
|
|
// Setting present charged duration
|
|
|
//=======================================
|