This commit is contained in:
stark1898y 2025-03-27 10:31:31 +08:00
parent afa04bd401
commit 828b44ec21
2 changed files with 90 additions and 7 deletions

View File

@ -41,6 +41,7 @@ __attribute__((aligned(4))) uint32_t MEM_BUF[BLE_MEMHEAP_SIZE / 4];
static uint8_t key_press_cnt = 0;
#if 0
void app_task_handler(TeAppEvtType app_evt_type)
{
BSP_BlockSleep();
@ -124,6 +125,87 @@ void app_task_handler(TeAppEvtType app_evt_type)
}
}
#endif
void app_task_handler(TeAppEvtType app_evt_type)
{
BSP_BlockSleep();
// BSP_BlockSleep();
BSP_RequestBoost();
switch(app_evt_type)
{
case kKeyShort:
logDebug("button short press");
key_press_cnt++;
logDebug("key_press_cnt = %d", key_press_cnt);
if (key_press_cnt == 1)
{
logDebug("LED显示状态");
// tmos_set_event(led_task_id, LED_SHOW_START_EVT);
BSP_BlockSleep();
BSP_RequestBoost();
DelayMs(1);
ShowLed();
// tmos_stop_task(led_task_id, LED_SHOW_ONCE_EVT);
// tmos_start_task(led_task_id, LED_SHOW_ONCE_EVT, 1000);
}
else if (key_press_cnt == 2)
{
if (gValveData.switch_status == kClosed)
{
logDebug("kClosed-->kOpened");
// tmos_set_event(led_task_id, LED_SHOW_START_EVT);
gValveData.switch_status = kOpened;
BSP_BlockSleep();
BSP_RequestBoost();
DelayMs(1);
ShowLed();
// tmos_stop_task(led_task_id, LED_SHOW_ONCE_EVT);
// tmos_start_task(led_task_id, LED_SHOW_ONCE_EVT, 1000);
}
else if (gValveData.switch_status != kClosed)
{
logDebug("kOpened-->kClosed");
gValveData.switch_status = kClosed;
tmos_set_event(vavle_task_id, VAVLE_CLOSE_START_EVT);
// tmos_set_event(led_task_id, LED_SHOW_START_EVT);
BSP_BlockSleep();
BSP_RequestBoost();
DelayMs(1);
ShowLed();
// tmos_stop_task(led_task_id, LED_SHOW_ONCE_EVT);
// tmos_start_task(led_task_id, LED_SHOW_ONCE_EVT, 1000);
}
}
break;
case kKeyLong:
logDebug("button long press");
break;
case kKeyRelease:
// BSP_KEY_EnterLowpower();
// DelayMs(10);
key_press_cnt = 0;
// BSP_RequestSleep();
// tmos_set_event(led_task_id, LED_SHOW_END_EVT);
LED_ALL_OFF_DEINIT;
BEEP_OFF_DEINIT;
BSP_NoNeedBoost();
BSP_RequestSleep();
logDebug("gpio relase;BSP_RequestSleep");
break;
default:
break;
}
}
/*********************************************************************
* @fn Main_Circulation
*
@ -182,9 +264,9 @@ int main(void)
DelayMs(1000 * 3);
CH58x_BLEInit();
HAL_Init();
GAPRole_PeripheralInit();
Peripheral_Init();
// HAL_Init();
// GAPRole_PeripheralInit();
// Peripheral_Init();
logDebug("GetSysClock = %d Hz", GetSysClock());
@ -221,9 +303,9 @@ int main(void)
BSP_VAVLE_Init();
// HAL_Init();
// GAPRole_PeripheralInit();
// Peripheral_Init();
HAL_Init();
GAPRole_PeripheralInit();
Peripheral_Init();
BSP_BlockSleep();
BSP_RequestBoost();

View File

@ -255,8 +255,9 @@ void BSP_KEY_Init(app_task_evt_handler_t handler)
// GPIOA_ModeCfg(GPIO_Pin_2, GPIO_ModeIN_PU);
// GPIOB_ModeCfg(GPIO_Pin_16, GPIO_ModeIN_Floating);
GPIOB_ModeCfg(GPIO_Pin_16, GPIO_ModeIN_PU);
GPIOB_ModeCfg(GPIO_Pin_0, GPIO_ModeIN_Floating);
GPIOB_ModeCfg(GPIO_Pin_0, GPIO_ModeIN_PU);
// GPIOB_ModeCfg(GPIO_Pin_1, GPIO_ModeIN_Floating);
#if 1