优化抬腕亮屏tp驱动恢复有时失效问题
authorSnickerSun <snickersun@163.com>
Wed, 9 Oct 2024 04:22:43 +0000 (12:22 +0800)
committerSnickerSun <snickersun@163.com>
Wed, 9 Oct 2024 04:22:43 +0000 (12:22 +0800)
消息提醒唤醒后马达震动过久问题

code/sdk/application/wearable/service/power_manager/src/actions/display_action.c
code/sdk/drivers/peripheral/vibrator/service/vibrator_service.cpp
code/sdk/drivers/peripheral/vibrator/service/vibrator_service.h
code/sdk/drivers/peripheral/vibrator/vibrator.c
code/sdk/drivers/peripheral/vibrator/vibrator_at_cmd.c
code/sdk/drivers/peripheral/vibrator/vibrator_hal.c
code/sdk/drivers/peripheral/vibrator/vibrator_hal.h

index c10e395..934d86b 100755 (executable)
@@ -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
index 70c1734..c78c31d 100644 (file)
@@ -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;
index 24094b6..c9dcbe4 100644 (file)
@@ -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);
index 2376782..80b9f66 100644 (file)
@@ -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;
index cdcd7fd..c26d38a 100644 (file)
@@ -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)
index 11f318e..26b1938 100644 (file)
@@ -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);
+}
index 12f47cd..89f3e2b 100644 (file)
@@ -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
 }