This commit is contained in:
stark1898y 2025-05-22 11:49:10 +08:00
parent 0a51ba710b
commit 4790bbcd08
4 changed files with 76 additions and 16 deletions

View File

@ -35,10 +35,13 @@ static uint8_t key_press_cnt = 0;
void app_task_handler(TeAppEvtType app_evt_type) void app_task_handler(TeAppEvtType app_evt_type)
{ {
// FEED_IWDG(); // FEED_IWDG();
gValveData.bat = BSP_ReadVbat();
BSP_RequestBoost();
BSP_BlockSleep(); BSP_BlockSleep();
BSP_RequestBoost(); BSP_RequestBoost();
logDebug("BSP_RequestBoost"); logDebug("BSP_RequestBoost");
DelayMs(5);
#if 1 #if 1
switch (app_evt_type) switch (app_evt_type)
@ -47,9 +50,9 @@ void app_task_handler(TeAppEvtType app_evt_type)
{ {
logDebug("button short press"); logDebug("button short press");
DelayMs(30); // DelayMs(30);
LDect_Init(); // LDect_Init();
logDebug("LDect_Init"); // logDebug("LDect_Init");
key_press_cnt++; key_press_cnt++;
logDebug("key_press_cnt = %d", key_press_cnt); logDebug("key_press_cnt = %d", key_press_cnt);
@ -61,8 +64,32 @@ void app_task_handler(TeAppEvtType app_evt_type)
// tmos_set_event(led_task_id, LED_SHOW_START_EVT); // tmos_set_event(led_task_id, LED_SHOW_START_EVT);
BSP_BlockSleep(); BSP_BlockSleep();
// BSP_RequestBoost(); // BSP_RequestBoost();
DelayMs(3); DelayMs(5);
ShowLed(); // ShowLed();
// 电压过低就关阀
if (gValveData.bat <= LOW_VABAT_ALARM_VALUE)
{
LED_ALL_OFF_DEINIT;
LED_Y_ON;
// BEEP_ON;
logDebug("LED_Y_ON");
}
else if (gValveData.switch_status == kUnknown || gValveData.switch_status == kClosed)
{
LED_ALL_OFF_DEINIT;
LED_R_ON;
logDebug("LED_R_ON");
}
else if (gValveData.switch_status == kOpened)
{
LED_ALL_OFF_DEINIT;
LED_G_ON;
logDebug("LED_G_ON");
}
// tmos_stop_task(led_task_id, LED_SHOW_ONCE_EVT); // tmos_stop_task(led_task_id, LED_SHOW_ONCE_EVT);
// tmos_start_task(led_task_id, LED_SHOW_ONCE_EVT, 1000); // tmos_start_task(led_task_id, LED_SHOW_ONCE_EVT, 1000);
} }
@ -75,8 +102,23 @@ void app_task_handler(TeAppEvtType app_evt_type)
gValveData.switch_status = kOpened; gValveData.switch_status = kOpened;
BSP_BlockSleep(); BSP_BlockSleep();
// BSP_RequestBoost(); // BSP_RequestBoost();
DelayMs(3); DelayMs(5);
ShowLed(); // ShowLed();
if (gValveData.switch_status == kUnknown || gValveData.switch_status == kClosed)
{
LED_ALL_OFF_DEINIT;
LED_R_ON;
logDebug("LED_R_ON");
}
else if (gValveData.switch_status == kOpened)
{
LED_ALL_OFF_DEINIT;
LED_G_ON;
logDebug("LED_G_ON");
}
// tmos_stop_task(led_task_id, LED_SHOW_ONCE_EVT); // tmos_stop_task(led_task_id, LED_SHOW_ONCE_EVT);
// tmos_start_task(led_task_id, LED_SHOW_ONCE_EVT, 1000); // tmos_start_task(led_task_id, LED_SHOW_ONCE_EVT, 1000);
} }
@ -89,8 +131,23 @@ void app_task_handler(TeAppEvtType app_evt_type)
// tmos_set_event(led_task_id, LED_SHOW_START_EVT); // tmos_set_event(led_task_id, LED_SHOW_START_EVT);
BSP_BlockSleep(); BSP_BlockSleep();
// BSP_RequestBoost(); // BSP_RequestBoost();
DelayMs(3); DelayMs(5);
ShowLed(); // ShowLed();
if (gValveData.switch_status == kUnknown || gValveData.switch_status == kClosed)
{
LED_ALL_OFF_DEINIT;
LED_R_ON;
logDebug("LED_R_ON");
}
else if (gValveData.switch_status == kOpened)
{
LED_ALL_OFF_DEINIT;
LED_G_ON;
logDebug("LED_G_ON");
}
// tmos_stop_task(led_task_id, LED_SHOW_ONCE_EVT); // tmos_stop_task(led_task_id, LED_SHOW_ONCE_EVT);
// tmos_start_task(led_task_id, LED_SHOW_ONCE_EVT, 1000); // tmos_start_task(led_task_id, LED_SHOW_ONCE_EVT, 1000);
} }
@ -112,7 +169,7 @@ void app_task_handler(TeAppEvtType app_evt_type)
LED_ALL_OFF_DEINIT; LED_ALL_OFF_DEINIT;
BEEP_OFF_DEINIT; BEEP_OFF_DEINIT;
LDect_Deinit(); // LDect_Deinit();
BSP_NoNeedBoost(); BSP_NoNeedBoost();
BSP_RequestSleep(); BSP_RequestSleep();

View File

@ -23,8 +23,8 @@ tmosTaskID led_task_id = INVALID_TASK_ID;
void ShowLed() void ShowLed()
{ {
gValveData.bat = BSP_ReadVbat(); // gValveData.bat = BSP_ReadVbat();
BSP_RequestBoost(); // BSP_RequestBoost();
// 电压过低就关阀 // 电压过低就关阀
if (gValveData.bat <= LOW_VABAT_ALARM_VALUE) if (gValveData.bat <= LOW_VABAT_ALARM_VALUE)

View File

@ -2,7 +2,7 @@
* @Author : stark1898y 1658608470@qq.com * @Author : stark1898y 1658608470@qq.com
* @Date : 2024-12-15 15:01:15 * @Date : 2024-12-15 15:01:15
* @LastEditors : stark1898y 1658608470@qq.com * @LastEditors : stark1898y 1658608470@qq.com
* @LastEditTime : 2025-05-21 17:23:23 * @LastEditTime : 2025-05-22 11:08:37
* @FilePath : \BLE_TYQ_CH584M\BSP\src\bsp_valve.c * @FilePath : \BLE_TYQ_CH584M\BSP\src\bsp_valve.c
* @Description : * @Description :
* *
@ -650,7 +650,10 @@ void BSP_VAVLE_Init(void)
tmos_start_task(vavle_task_id, VAVLE_LOOP_DECT_EVT, MS1_TO_SYSTEM_TIME(VALVE_DECT_PERIOD_MS)); tmos_start_task(vavle_task_id, VAVLE_LOOP_DECT_EVT, MS1_TO_SYSTEM_TIME(VALVE_DECT_PERIOD_MS));
LDect_Init(); // GPIOA_ResetBits(GPIO_Pin_2);
// GPIOA_ModeCfg(GPIO_Pin_2, GPIO_ModeIN_PU);
// LDect_Init();
#if 0 #if 0
// PA2 // PA2
/* 定时器3CAP捕捉 */ /* 定时器3CAP捕捉 */

View File

@ -55,7 +55,7 @@ __HIGH_CODE
void BSP_NoNeedBoost(void) void BSP_NoNeedBoost(void)
{ {
block_boost_flag = true; block_boost_flag = true;
LDect_Deinit(); // LDect_Deinit();
BOOST_OFF_DEINIT; BOOST_OFF_DEINIT;
} }
@ -93,7 +93,7 @@ uint32_t CH58x_LowPower(uint32_t time)
// logDebug("block_sleep"); // logDebug("block_sleep");
return 0; return 0;
} }
LDect_Deinit(); // LDect_Deinit();
#if (defined(HAL_SLEEP)) && (HAL_SLEEP == TRUE) #if (defined(HAL_SLEEP)) && (HAL_SLEEP == TRUE)
volatile uint32_t i; volatile uint32_t i;
uint32_t time_tign, time_sleep, time_curr; uint32_t time_tign, time_sleep, time_curr;