|
@@ -25,16 +25,86 @@ void LightDriver_Init(void)
|
|
|
HAL_GPIO_Init(LIGHT_B_GPIO_Port, &GPIO_InitStruct);
|
|
|
}
|
|
|
|
|
|
-void LightDriver_Process(MC_LightSwitch_Struct_t LightSwitchCode)
|
|
|
+void LightDriver_Process(TrueOrFalse_Flag_Struct_t IsBreakFlag, MC_LightSwitch_Struct_t LightSwitchCode)
|
|
|
{
|
|
|
- if(LightSwitchCode == MC_LightSwitch_ON)
|
|
|
+ if(HAL_GetTick() < 3000)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ //前灯
|
|
|
+ if(LightSwitchCode == MC_LightSwitch_ON)
|
|
|
{
|
|
|
HAL_GPIO_WritePin(LIGHT_F_GPIO_Port, LIGHT_F_Pin, GPIO_PIN_SET);
|
|
|
- HAL_GPIO_WritePin(LIGHT_B_GPIO_Port, LIGHT_B_Pin, GPIO_PIN_SET);
|
|
|
}
|
|
|
else if(LightSwitchCode == MC_LightSwitch_OFF)
|
|
|
{
|
|
|
HAL_GPIO_WritePin(LIGHT_F_GPIO_Port, LIGHT_F_Pin, GPIO_PIN_RESET);
|
|
|
- HAL_GPIO_WritePin(LIGHT_B_GPIO_Port, LIGHT_B_Pin, GPIO_PIN_RESET);
|
|
|
+ }
|
|
|
+
|
|
|
+ //尾灯
|
|
|
+ static uint16_t FlashTimeCnt = 0;
|
|
|
+ if(strncmp("FLASH", (char*)UserString2, 5) == 0)//利用UserString2作为尾灯刹车时显示状态
|
|
|
+ {
|
|
|
+ if(IsBreakFlag == TRUE)//刹车时,快闪
|
|
|
+ {
|
|
|
+ if(FlashTimeCnt < 600)
|
|
|
+ {
|
|
|
+ HAL_GPIO_WritePin(LIGHT_B_GPIO_Port, LIGHT_B_Pin, GPIO_PIN_SET);
|
|
|
+ }
|
|
|
+ else if(FlashTimeCnt < 1200)
|
|
|
+ {
|
|
|
+ HAL_GPIO_WritePin(LIGHT_B_GPIO_Port, LIGHT_B_Pin, GPIO_PIN_RESET);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ FlashTimeCnt = 0;
|
|
|
+ }
|
|
|
+ FlashTimeCnt++;
|
|
|
+ }
|
|
|
+ else//无刹车时,开灯亮
|
|
|
+ {
|
|
|
+ if(LightSwitchCode == MC_LightSwitch_ON)
|
|
|
+ {
|
|
|
+ HAL_GPIO_WritePin(LIGHT_B_GPIO_Port, LIGHT_B_Pin, GPIO_PIN_SET);
|
|
|
+ }
|
|
|
+ else if(LightSwitchCode == MC_LightSwitch_OFF)
|
|
|
+ {
|
|
|
+ HAL_GPIO_WritePin(LIGHT_B_GPIO_Port, LIGHT_B_Pin, GPIO_PIN_RESET);
|
|
|
+ }
|
|
|
+ FlashTimeCnt = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(IsBreakFlag == TRUE)//刹车时,高亮
|
|
|
+ {
|
|
|
+ HAL_GPIO_WritePin(LIGHT_B_GPIO_Port, LIGHT_B_Pin, GPIO_PIN_SET);
|
|
|
+ FlashTimeCnt = 0;
|
|
|
+ }
|
|
|
+ else//无刹车时,开灯低亮
|
|
|
+ {
|
|
|
+ if(LightSwitchCode == MC_LightSwitch_ON)
|
|
|
+ {
|
|
|
+ if(FlashTimeCnt < 138)
|
|
|
+ {
|
|
|
+ HAL_GPIO_WritePin(LIGHT_B_GPIO_Port, LIGHT_B_Pin, GPIO_PIN_SET);
|
|
|
+ }
|
|
|
+ else if(FlashTimeCnt < 200)
|
|
|
+ {
|
|
|
+ HAL_GPIO_WritePin(LIGHT_B_GPIO_Port, LIGHT_B_Pin, GPIO_PIN_RESET);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ FlashTimeCnt = 0;
|
|
|
+ }
|
|
|
+ FlashTimeCnt++;
|
|
|
+ }
|
|
|
+ else if(LightSwitchCode == MC_LightSwitch_OFF)
|
|
|
+ {
|
|
|
+ HAL_GPIO_WritePin(LIGHT_B_GPIO_Port, LIGHT_B_Pin, GPIO_PIN_RESET);
|
|
|
+ FlashTimeCnt = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|