* @Author: penglei 1624952103@qq.com
* @Date: 2024-08-08 16:33:23
* @LastEditors: penglei 1624952103@qq.com
- * @LastEditTime: 2025-11-28 12:07:56
+ * @LastEditTime: 2026-01-13 16:57:17
* @FilePath: /FD230/code/sdk/drivers/peripheral/vibrator/service/vibrator_service.cpp
* @Description:
*
#include "custom_save_runtime.h"
#include "input_app.h"
+#ifdef ROTARYENCODER_HX3508
+#include "hx3508.h"
+#endif
+
void custom_VibratorFunc_int(int vibratorType)
{
uapi_save_runtime_log(RUNTIME_LOG_MOTOR_START);
}
+static void custom_VibratorFunc_for_encoder(int vibratorType)
+{
+ uapi_save_runtime_log(RUNTIME_LOG_MOTOR_START);
+
+ //忽略系统调用参数,只按照configmodel里保存的值来震动
+ uint8_t vibmod = uapi_dev_runtime_get_vibmod();
+
+ vibrator_cmd_t mail = {1};
+ if(vibratorType == 4)
+ vibmod = 4;
+ else if(vibratorType == 5)
+ vibmod = 5;
+ switch (vibmod)
+ {
+ case 5:
+ mail.cycle_time_ms = 235;
+ mail.duty = 65;
+ mail.duration_time_ms = 100;
+ break;
+ case 4:
+ mail.cycle_time_ms = 235;
+ mail.duty = 65;
+ mail.duration_time_ms = 2000;
+ break;
+ case 3:
+ mail.cycle_time_ms = 235;
+ mail.duty = 50;
+ mail.duration_time_ms = 60;
+ break;
+ case 2:
+ mail.cycle_time_ms = 235;
+ mail.duty = 50;
+ mail.duration_time_ms = 40;
+ break;
+ case 1:
+ mail.cycle_time_ms = 235;
+ mail.duty = 50;
+ mail.duration_time_ms = 20;
+ break;
+ default:
+ break;
+ }
+ // PRINT("cycle_time_ms[%d], duty[%d], duration_time_ms[%d] \n",mail.cycle_time_ms,mail.duty,mail.duration_time_ms);
+ do_vibrator_cmd(mail);
+}
+
+
void custom_VibratorFunc(OHOS::VibratorType vibratorType)
{
switch (vibratorType)
{
case OHOS::VibratorType::VIBRATOR_TYPE_ONE:
- custom_VibratorFunc_int(1);
+ custom_VibratorFunc_for_encoder(1);
break;
case OHOS::VibratorType::VIBRATOR_TYPE_TWO:
- custom_VibratorFunc_int(2);
+ custom_VibratorFunc_for_encoder(2);
break;
case OHOS::VibratorType::VIBRATOR_TYPE_THREE:
- custom_VibratorFunc_int(3);
+ custom_VibratorFunc_for_encoder(3);
break;
}
}
case 0:
g_VibratorFunc( mail.duty , mail.cycle_time_ms, mail.duration_time_ms);
break;
+
case 1:
+ #ifdef ROTARYENCODER_HX3508
+ if(hx3508_get_stand_still())
+ {
+ break;
+ }
+ #endif
+ g_VibratorFunc( mail.duty , mail.cycle_time_ms, mail.duration_time_ms);
+ break;
+
+ case 2:
// touch_screen_resume();
break;
}