瀏覽代碼

2021-08-25 / Eason Yang
Action:
1. Added : Added new define for led action.
2. Added : Added logic for led status when the system on Idle mode.
3. Added : Added timer for led change status.
4. Fixed : wifi & 4g icon logic.
5. Improve : Reservation led status.

File:
1. main.c
Action 2
Action 5

2. main.h
Action 1
Action 3

3. Module_LcmControl.c
Action 4

Version: D0.55.XX.XXXX.XX

8009 3 年之前
父節點
當前提交
d8657c7640

+ 9 - 0
EVSE/Projects/AW-CCS/Apps/LCM/Module_LcmControl.c

@@ -731,6 +731,11 @@ void setWifi4GIcon()
 			}
 		}
 	}
+	else if(ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'E')
+	{
+		setDisplayValue(ICON_WIFI_CONNECTION, DISAPPEAR);
+		setDisplayValue(ICON_4G_CONNECTION, DISAPPEAR);
+	}
 	else
 	{
 		// SET 4G ICON STATUS ( ONLINE OR OFFLINE )
@@ -745,6 +750,8 @@ void setWifi4GIcon()
 
 					break;
 				case ENABLE_4G:
+					// Clean icon
+					setDisplayValue(ICON_4G_CONNECTION, DISAPPEAR);
 
 					if(ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectVia4Gi == ON)
 						setDisplayValue(ICON_WIFI_CONNECTION, TELECOM_OFFLINE);
@@ -769,6 +776,8 @@ void setWifi4GIcon()
 
 					break;
 				case WIFI_STATION:
+					// Clean icon
+					setDisplayValue(ICON_4G_CONNECTION, DISAPPEAR);
 
 					if(ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaWiFi == ON)
 						setDisplayValue(ICON_WIFI_CONNECTION, WIFI_OFFLINE);

+ 61 - 3
EVSE/Projects/AW-CCS/Apps/main.c

@@ -32,6 +32,7 @@
 #define TIMEOUT_SPEC_POWERSAVING_LCD			120000
 #define TIMEOUT_SPEC_POWERSAVING_RFID			120000
 #define TIMEOUT_SPEC_POWERSAVING_METER			120000
+#define TIMEOUT_SPEC_POWERSAVING_LED_STATUS		120000
 
 //==========================
 // GPIO constant define
@@ -3175,6 +3176,24 @@ void setLedMotion(unsigned char gun_index,unsigned char led_mode)
 		case LED_ACTION_INTERNET_DISCONNECT:
 			ShmCharger->gun_info[gun_index].primaryMcuLed.mode = LED_ACTION_INTERNET_DISCONNECT;
 			break;
+		case LED_ACTION_RESTORE_SETTING:
+			ShmCharger->gun_info[gun_index].primaryMcuLed.mode = LED_ACTION_RESTORE_SETTING;
+			break;
+		case LED_ACTION_IDLE_BACKEND_CONNECTED:
+			ShmCharger->gun_info[gun_index].primaryMcuLed.mode = LED_ACTION_IDLE_BACKEND_CONNECTED;
+			break;
+		case LED_ACTION_IDLE_BACKEND_CONNECTED_SLEEP:
+			ShmCharger->gun_info[gun_index].primaryMcuLed.mode = LED_ACTION_IDLE_BACKEND_CONNECTED_SLEEP;
+			break;
+		case LED_ACTION_IDLE_BACKEND_DISCONNECTED:
+			ShmCharger->gun_info[gun_index].primaryMcuLed.mode = LED_ACTION_IDLE_BACKEND_DISCONNECTED;
+			break;
+		case LED_ACTION_IDLE_BACKEND_DISCONNECTED_SLEEP:
+			ShmCharger->gun_info[gun_index].primaryMcuLed.mode = LED_ACTION_IDLE_BACKEND_DISCONNECTED_SLEEP;
+			break;
+		case LED_ACTION_RESERVATION_MODE:
+			ShmCharger->gun_info[gun_index].primaryMcuLed.mode = LED_ACTION_RESERVATION_MODE;
+			break;
 	}
 }
 
@@ -4658,6 +4677,7 @@ int main(void)
 				ftime(&startTime[gun_index][TMR_IDX_POWERSAVING_LCD]);
 				ftime(&startTime[gun_index][TMR_IDX_POWERSAVING_RFID]);
 				ftime(&startTime[gun_index][TMR_IDX_POWERSAVING_METER]);
+				ftime(&startTime[gun_index][TMR_IDX_POWERSAVING_LED_STATUS]);
 			}
 			else
 			{
@@ -4671,6 +4691,7 @@ int main(void)
 					ftime(&startTime[gun_index][TMR_IDX_POWERSAVING_LCD]);
 					ftime(&startTime[gun_index][TMR_IDX_POWERSAVING_RFID]);
 					ftime(&startTime[gun_index][TMR_IDX_POWERSAVING_METER]);
+					ftime(&startTime[gun_index][TMR_IDX_POWERSAVING_LED_STATUS]);
 				}
 			}
 
@@ -4712,7 +4733,7 @@ int main(void)
 
 			if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_POWERSAVING_METER]) > TIMEOUT_SPEC_POWERSAVING_METER)
 			{
-				if(ShmCharger->gun_info[gun_index].isMeterOn )
+				if(ShmCharger->gun_info[gun_index].isMeterOn)
 				{
 					DEBUG_INFO("Meter into power saving...%d\n", DiffTimebWithNow(startTime[gun_index][TMR_IDX_POWERSAVING_METER]));
 					ShmCharger->gun_info[gun_index].isMeterOn = OFF;
@@ -4720,12 +4741,29 @@ int main(void)
 			}
 			else
 			{
-				if(!ShmCharger->gun_info[gun_index].isMeterOn )
+				if(!ShmCharger->gun_info[gun_index].isMeterOn)
 				{
 					DEBUG_INFO("Meter exit power saving...%d\n", DiffTimebWithNow(startTime[gun_index][TMR_IDX_POWERSAVING_METER]));
 					ShmCharger->gun_info[gun_index].isMeterOn = ON;
 				}
 			}
+			
+			if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_POWERSAVING_LED_STATUS]) > TIMEOUT_SPEC_POWERSAVING_LED_STATUS)
+			{
+				if(ShmCharger->gun_info[gun_index].isSleepOn == OFF)
+				{
+					DEBUG_INFO("LED status into power saving...%d\n", DiffTimebWithNow(startTime[gun_index][TMR_IDX_POWERSAVING_LED_STATUS]));
+					ShmCharger->gun_info[gun_index].isSleepOn = ON;
+				}
+			}
+			else
+			{
+				if(ShmCharger->gun_info[gun_index].isSleepOn == ON)
+				{
+					DEBUG_INFO("LED status exit power saving...%d\n", DiffTimebWithNow(startTime[gun_index][TMR_IDX_POWERSAVING_LED_STATUS]));
+					ShmCharger->gun_info[gun_index].isSleepOn = OFF;
+				}
+			}
 
 			//==========================================
 			// Synchronize current rating value from MCU
@@ -4830,6 +4868,7 @@ int main(void)
 						ftime(&startTime[gun_index][TMR_IDX_POWERSAVING_RFID]);
 						ftime(&startTime[gun_index][TMR_IDX_POWERSAVING_METER]);
 						ftime(&startTime[gun_index][TMR_IDX_POWERSAVING_STATE_B]);
+						ftime(&startTime[gun_index][TMR_IDX_POWERSAVING_LED_STATUS]);
 					}
 
 					if(ShmCharger->gun_info[gun_index].mcuFlag.isReadFwVerPass &&
@@ -4892,6 +4931,9 @@ int main(void)
 
 						// Default LCM brightness to 100
 						ShmCharger->isLcdOn = ON;
+						
+						// Defaule led status to not sleep mode
+						ShmCharger->gun_info[gun_index].isSleepOn = OFF;
 
 						// If Web Server OPCC URL is empty kill Module_OcppBackend
 						if((strcmp((char *)&ShmSysConfigAndInfo->SysConfig.OcppServerURL,"") == 0) || ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharging)
@@ -4951,6 +4993,22 @@ int main(void)
 						if(ShmCharger->isCcsEnable)system("pkill Module_CCS");
 						DB_Check_Record_Buf(localDb, gun_index);
 					}
+					
+					// LED status in Idle mode
+					if(ShmSysConfigAndInfo->SysInfo.OcppConnStatus == ON)
+					{
+						if(ShmCharger->gun_info[gun_index].isSleepOn == OFF)
+							setLedMotion(gun_index,LED_ACTION_IDLE_BACKEND_CONNECTED);
+						else
+							setLedMotion(gun_index,LED_ACTION_IDLE_BACKEND_CONNECTED_SLEEP);
+					}
+					else
+					{
+						if(ShmCharger->gun_info[gun_index].isSleepOn == OFF)
+							setLedMotion(gun_index,LED_ACTION_IDLE_BACKEND_DISCONNECTED);
+						else
+							setLedMotion(gun_index,LED_ACTION_IDLE_BACKEND_DISCONNECTED_SLEEP);
+					}
 
 					if(((ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_DISABLE) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_B)) ||
 					   ((ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_DISABLE) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_C)) ||
@@ -5953,7 +6011,7 @@ int main(void)
 				case SYS_MODE_RESERVATION:
 					if(isModeChange(gun_index))
 					{}
-					setLedMotion(gun_index,LED_ACTION_MAINTAIN);
+					setLedMotion(gun_index,LED_ACTION_RESERVATION_MODE);
 
 					if(isReservationExpired(gun_index))
 					{

+ 10 - 3
EVSE/Projects/AW-CCS/Apps/main.h

@@ -153,7 +153,13 @@ enum LED_ACTION
 	LED_RELAY_ON,
 	LED_RELAY_OFF,
 	LED_ACTION_HANDSHAKE_FAIL,
-	LED_ACTION_INTERNET_DISCONNECT
+	LED_ACTION_INTERNET_DISCONNECT,
+	LED_ACTION_RESTORE_SETTING,
+	LED_ACTION_IDLE_BACKEND_CONNECTED,
+	LED_ACTION_IDLE_BACKEND_CONNECTED_SLEEP,
+	LED_ACTION_IDLE_BACKEND_DISCONNECTED,
+	LED_ACTION_IDLE_BACKEND_DISCONNECTED_SLEEP,
+	LED_ACTION_RESERVATION_MODE
 };
 
 //===================================
@@ -222,7 +228,7 @@ enum TIMER_IDX
 	TMR_IDX_POWERSAVING_METER,
 	TMR_IDX_POWERSAVING_STATE_B,
 	TMR_IDX_CHECK_TASK,
-	TMR_IDX_12,
+	TMR_IDX_POWERSAVING_LED_STATUS,
 	TMR_IDX_13,
 	TMR_IDX_14,
 	TMR_IDX_15,
@@ -746,7 +752,8 @@ typedef struct GUN_INFO
 	uint16_t										isDoEvReadyOnce:1;
 	uint16_t										isChargerStopByCondition:1;
 	uint16_t										isMeterOn:1;
-	uint16_t										:3;
+	uint16_t										isSleepOn:1;
+	uint16_t										:2;
 }Gun_Info;
 
 struct Charger