From 431ce2daafd9c306f2c853ff8415466f4d708b25 Mon Sep 17 00:00:00 2001 From: SnickerSun Date: Wed, 9 Oct 2024 12:22:43 +0800 Subject: [PATCH] =?utf8?q?=E4=BC=98=E5=8C=96=E6=8A=AC=E8=85=95=E4=BA=AE?= =?utf8?q?=E5=B1=8Ftp=E9=A9=B1=E5=8A=A8=E6=81=A2=E5=A4=8D=E6=9C=89?= =?utf8?q?=E6=97=B6=E5=A4=B1=E6=95=88=E9=97=AE=E9=A2=98=20=E6=B6=88?= =?utf8?q?=E6=81=AF=E6=8F=90=E9=86=92=E5=94=A4=E9=86=92=E5=90=8E=E9=A9=AC?= =?utf8?q?=E8=BE=BE=E9=9C=87=E5=8A=A8=E8=BF=87=E4=B9=85=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../src/actions/display_action.c | 10 +++++--- .../vibrator/service/vibrator_service.cpp | 25 +++++++++++++------ .../vibrator/service/vibrator_service.h | 3 ++- .../drivers/peripheral/vibrator/vibrator.c | 6 ++--- .../peripheral/vibrator/vibrator_at_cmd.c | 9 +++++++ .../peripheral/vibrator/vibrator_hal.c | 16 +++++++++--- .../peripheral/vibrator/vibrator_hal.h | 2 +- 7 files changed, 52 insertions(+), 19 deletions(-) diff --git a/code/sdk/application/wearable/service/power_manager/src/actions/display_action.c b/code/sdk/application/wearable/service/power_manager/src/actions/display_action.c index c10e3951d..934d86b39 100755 --- a/code/sdk/application/wearable/service/power_manager/src/actions/display_action.c +++ b/code/sdk/application/wearable/service/power_manager/src/actions/display_action.c @@ -100,7 +100,7 @@ static void caculate_screen_off_time() screen_context_t *sc = power_display_get_screen_context(); sc->screen_off_time_interval = screen_off_time; } - +extern errcode_t hal_custom_resume_touch(void); static uint32_t action_display_lcd_on() { last_screen_on_timestamp = get_display_timestamp(); @@ -167,8 +167,12 @@ static uint32_t action_display_lcd_on() #endif if ((g_pms_lcd_on_first_flag == false) && (g_pms_dpu_ready == false)) { // touch_screen_resume();// open touch/ - if (touch_resume_in_cmd_queue() != 0) - post_func_to_graphic(touch_screen_resume); // open touch 太耗时,放到GraphicService里延迟执行,加快亮屏速度。 + ret = hal_custom_resume_touch(); // 更高优先级处理touch + if ( ret != 0) + { + POWER_DISPLAY_PRINT_ERR(0, "hal_custom_resume_touch error ret=%x , resume touch in graphic thread\r\n", ret); + touch_screen_resume();// post_func_to_graphic(touch_screen_resume); // open touch 太耗时,放到GraphicService里延迟执行,加快亮屏速度。 + } rotary_encoder_resume(); } #ifdef CONFIG_CLDO1PD_SUPPORT diff --git a/code/sdk/drivers/peripheral/vibrator/service/vibrator_service.cpp b/code/sdk/drivers/peripheral/vibrator/service/vibrator_service.cpp index 70c173413..c78c31dcd 100644 --- a/code/sdk/drivers/peripheral/vibrator/service/vibrator_service.cpp +++ b/code/sdk/drivers/peripheral/vibrator/service/vibrator_service.cpp @@ -1,8 +1,8 @@ /* * @Author: penglei 1624952103@qq.com * @Date: 2024-08-08 16:33:23 - * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2024-09-28 20:17:37 + * @LastEditors: SnickerSun snickersun@163.com + * @LastEditTime: 2024-10-09 12:08:23 * @FilePath: /FD230/code/sdk/drivers/peripheral/vibrator/service/vibrator_service.cpp * @Description: * @@ -148,11 +148,12 @@ void uapi_vibrator_service_deinit(void) -void do_vibrator_cmd(vibrator_cmd_t cmd) +errcode_t do_vibrator_cmd(vibrator_cmd_t cmd) { int ret; vibrator_cmd_t mail = {0}; + mail.cmd_type = cmd.cmd_type; mail.cycle_time_ms = cmd.cycle_time_ms; mail.duty = cmd.duty; mail.duration_time_ms = cmd.duration_time_ms; @@ -160,10 +161,12 @@ void do_vibrator_cmd(vibrator_cmd_t cmd) sizeof(vibrator_cmd_t), 0); if (ret != OSAL_SUCCESS) { PRINT("Error vibrator Check MSG 0x%02X send failed! err=0x%x! \r\n",cmd, ret); + return ret; } + return ERRCODE_SUCC; } - +extern void touch_screen_resume(void); static void vibrator_service_check_task(void *arg) { unused(arg); @@ -178,8 +181,16 @@ static void vibrator_service_check_task(void *arg) continue; } - g_VibratorFunc( mail.duty , mail.cycle_time_ms, mail.duration_time_ms); - + switch(mail.cmd_type) + { + case 0: + g_VibratorFunc( mail.duty , mail.cycle_time_ms, mail.duration_time_ms); + break; + case 1: + touch_screen_resume(); + break; + } + } } void create_vib_queue(void) @@ -195,7 +206,7 @@ errcode_t uapi_vibrator_service_init(void) app_task_definition_t taskcfg={0}; taskcfg.create_queue_handle = create_vib_queue; taskcfg.attr.name="vib_service"; - taskcfg.attr.priority = TASK_PRIORITY_TRANSMIT; + taskcfg.attr.priority = TASK_PRIORITY_SDK; taskcfg.attr.stack_size = APP_BOARD_TASK_SIZE; taskcfg.func = vibrator_service_check_task; taskcfg.use_mem = USE_EXTEND_MEM; diff --git a/code/sdk/drivers/peripheral/vibrator/service/vibrator_service.h b/code/sdk/drivers/peripheral/vibrator/service/vibrator_service.h index 24094b6e9..c9dcbe412 100644 --- a/code/sdk/drivers/peripheral/vibrator/service/vibrator_service.h +++ b/code/sdk/drivers/peripheral/vibrator/service/vibrator_service.h @@ -21,6 +21,7 @@ extern "C" { typedef struct { + uint32_t cmd_type; uint32_t duty; //占空比 uint32_t cycle_time_ms; //频率 uint32_t duration_time_ms;//震动时间 @@ -29,7 +30,7 @@ typedef struct { /** * 测试指令 参数cmd 选项: VIB_CMD_MSG_ONE VIB_CMD_MSG_TWO VIB_CMD_MSG_THREE */ -extern void do_vibrator_cmd(vibrator_cmd_t cmd); +extern errcode_t do_vibrator_cmd(vibrator_cmd_t cmd); // UI 界面震动一次接口 void ui_api_vibrate_once_func(void); diff --git a/code/sdk/drivers/peripheral/vibrator/vibrator.c b/code/sdk/drivers/peripheral/vibrator/vibrator.c index 23767827c..80b9f6605 100644 --- a/code/sdk/drivers/peripheral/vibrator/vibrator.c +++ b/code/sdk/drivers/peripheral/vibrator/vibrator.c @@ -23,7 +23,6 @@ #include "vibrator.h" // #define VIB_DEBUG - #ifdef VIB_USE_PWM #define VIBRATOR_GPIOPPIN S_AGPIO_R2 // #define VIBRATORPIN_MODE HAL_PIO_FUNC_PWMP1_M2 @@ -174,8 +173,9 @@ void g_VibratorFunc(uint16_t duty , uint16_t cycle_time_ms,uint16_t duration_tim pwm_start(duty,cycle_time_ms); - LOS_Msleep(duration_time_ms); - + // LOS_Msleep(duration_time_ms); + LOS_Mdelay(duration_time_ms); + pwm_stop(); vibrating = 0; diff --git a/code/sdk/drivers/peripheral/vibrator/vibrator_at_cmd.c b/code/sdk/drivers/peripheral/vibrator/vibrator_at_cmd.c index cdcd7fd0b..c26d38ae6 100644 --- a/code/sdk/drivers/peripheral/vibrator/vibrator_at_cmd.c +++ b/code/sdk/drivers/peripheral/vibrator/vibrator_at_cmd.c @@ -68,9 +68,18 @@ static uint32_t vibrator_do_test(uint8_t *para, uint32_t paraLen, char *strCommo hal_custom_VibratorFunc(duty,cycle,duration); return ERRCODE_SUCC; } +extern errcode_t hal_custom_resume_touch(void); +static uint32_t resume_touch(uint8_t *para, uint32_t paraLen, char *strCommonCmd) +{ + PRINT("VIBRATORTEST ATCMD Custom_resume_touch \n"); + hal_custom_resume_touch(); + return ERRCODE_SUCC; +} static const at_cmd_table_t g_vibrator_cmd[] = { { (char *)"AT^VIBRATORTEST", vibrator_do_test, (char *)"1" }, + { (char *)"AT^RESUMETOUCH", resume_touch, (char *)"1" }, + }; at_cmd_table_t *get_vibrator_cmd_table(uint32_t *cmd_count) diff --git a/code/sdk/drivers/peripheral/vibrator/vibrator_hal.c b/code/sdk/drivers/peripheral/vibrator/vibrator_hal.c index 11f318efa..26b193801 100644 --- a/code/sdk/drivers/peripheral/vibrator/vibrator_hal.c +++ b/code/sdk/drivers/peripheral/vibrator/vibrator_hal.c @@ -2,7 +2,7 @@ #include "vibrator_hal.h" #include "vibrator_service.h" #include "debug_print.h" -void hal_custom_VibratorFunc(uint16_t duty , uint16_t cycle_time_ms,uint16_t duration_time_ms) +errcode_t hal_custom_VibratorFunc(uint16_t duty , uint16_t cycle_time_ms,uint16_t duration_time_ms) { vibrator_cmd_t cmd = {0}; @@ -10,7 +10,15 @@ void hal_custom_VibratorFunc(uint16_t duty , uint16_t cycle_time_ms,uint16_t dur cmd.cycle_time_ms = cycle_time_ms; cmd.duration_time_ms = duration_time_ms; cmd.duty = duty; - do_vibrator_cmd(cmd); - + return do_vibrator_cmd(cmd); -} \ No newline at end of file +} + +errcode_t hal_custom_resume_touch(void) +{ + vibrator_cmd_t cmd = {0}; + + PRINT("hal_custom_resume_touch\r\n"); + cmd.cmd_type = 1; + return do_vibrator_cmd(cmd); +} diff --git a/code/sdk/drivers/peripheral/vibrator/vibrator_hal.h b/code/sdk/drivers/peripheral/vibrator/vibrator_hal.h index 12f47cd7a..89f3e2bb6 100644 --- a/code/sdk/drivers/peripheral/vibrator/vibrator_hal.h +++ b/code/sdk/drivers/peripheral/vibrator/vibrator_hal.h @@ -22,7 +22,7 @@ extern "C" { #endif /* __cplusplus */ #endif /* __cplusplus */ -void hal_custom_VibratorFunc(uint16_t duty , uint16_t cycle_time_ms,uint16_t duration_time_ms); +errcode_t hal_custom_VibratorFunc(uint16_t duty , uint16_t cycle_time_ms,uint16_t duration_time_ms); #ifdef __cplusplus #if __cplusplus } -- 2.17.1