雷鸟优化马达控制,背光控制,开机增加音频 2268/1 2268/head 2269/target/1
authorpenglei <1624952103@qq.com>
Tue, 16 Sep 2025 11:03:14 +0000 (19:03 +0800)
committerpenglei <1624952103@qq.com>
Tue, 16 Sep 2025 11:03:14 +0000 (19:03 +0800)
13 files changed:
code/sdk/application/wearable/ln/service/power_manager/src/power_display_service.c
code/sdk/build/config/target_config/brandy/config.py
code/sdk/build/config/target_config/brandy/mk_fs_image/leiniao/fs/user/music/PowerOn.mp3 [new file with mode: 0644]
code/sdk/drivers/boards/brandy_evb/board_config/board_leiniao.h
code/sdk/middleware/services/media/foundation/player/interfaces/kits/player.h
code/sdk/zhihui/drivers/vibrator/service/vibrator_service.cpp
code/sdk/zhihui/drivers/vibrator/vibrator.c
code/sdk/zhihui/drivers/vibrator/vibrator.h
code/sdk/zhihui/drivers/vibrator/vibrator_at_cmd.c
code/sdk/zhihui/utils/custom_utils.c
code/sdk/zhihui/utilscpp/CMakeLists.txt
code/sdk/zhihui/utilscpp/custom_utilscpp.cpp
code/sdk/zhihui/utilscpp/custom_utilscpp.h

index 297dd3a..f9f4cbd 100644 (file)
 #include "graphic_service_wrapper.h"\r
 #endif\r
 \r
+#ifdef CUSTOM_UTILS\r
+#include "custom_utils.h"\r
+#endif\r
+\r
 #define DISPLAY_AUTO_POWER_OFF_PERIOD_MS 5000\r
 #define DISPLAY_DEFAULT_BRIGHTNESS 50\r
 #define POWER_DISPLAY_QUEUE_MAX_SIZE 64\r
@@ -90,6 +94,9 @@ static errcode_t power_display_msg_write(uint32_t msg_id, uint8_t *msg, uint16_t
 \r
 static errcode_t power_display_turn_on_screen(void)\r
 {\r
+#if defined(CUSTOM_UTILS) && defined(BOARD_LEINIAO)\r
+    uapi_lcd_backlight_on(50);\r
+#endif\r
 #ifndef SUPPORT_OHOSFWK\r
     message_type_t mt = TURN_ON_SCREEN_CMD;\r
     uint32_t event_info = 0;\r
@@ -105,6 +112,9 @@ static errcode_t power_display_turn_on_screen(void)
 \r
 static errcode_t power_display_turn_off_screen(void)\r
 {\r
+#if defined(CUSTOM_UTILS) && defined(BOARD_LEINIAO)\r
+    uapi_lcd_backlight_off();\r
+#endif\r
 #ifndef SUPPORT_OHOSFWK\r
     message_type_t mt = TURN_OFF_SCREEN_CMD;\r
     uint32_t event_info = 0;\r
index d98a52c..176043c 100644 (file)
@@ -1225,7 +1225,7 @@ target = {
             # 'WEARABLE_LOG_DEBUG',
             'SUPPORT_RC_CALIBRATION',
             # 'PPG_HX3695',
-            'VIB_USE_PWM',
+            # 'VIB_USE_PWM',
             'CONFIG_PWM_SUPPORT',
             # 'ACC_LIS2DOC',
             'ENABLE_CUSTOM_I2C',
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/leiniao/fs/user/music/PowerOn.mp3 b/code/sdk/build/config/target_config/brandy/mk_fs_image/leiniao/fs/user/music/PowerOn.mp3
new file mode 100644 (file)
index 0000000..b1488e2
Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/leiniao/fs/user/music/PowerOn.mp3 differ
index 969738e..07a30ca 100644 (file)
@@ -46,11 +46,11 @@ const hal_pio_config_t g_pio_function_config[PIN_MAX_NUMBER] = {
     { HAL_PIO_FUNC_OPI, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_DOWN,  HAL_PIO_IE_ENBALE },    // S_EGPIO24
     { HAL_PIO_FUNC_OPI, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_DOWN,  HAL_PIO_IE_ENBALE },    // S_EGPIO25
 
-    { HAL_PIO_FUNC_GPIO, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_DOWN, HAL_PIO_IE_DISABLE },    // S_HGPIO0 NC
+    { HAL_PIO_FUNC_GPIO, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_MAX, HAL_PIO_IE_DISABLE },    // S_HGPIO0 NC
     { HAL_PIO_FUNC_GPIO, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_DOWN, HAL_PIO_IE_DISABLE },    // S_HGPIO1 NC
     { HAL_PIO_FUNC_GPIO, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_DOWN, HAL_PIO_IE_DISABLE },    // S_HGPIO2 NC
     { HAL_PIO_FUNC_GPIO, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_DOWN, HAL_PIO_IE_DISABLE },    // S_HGPIO3 NC
-    { HAL_PIO_FUNC_GPIO, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_DOWN, HAL_PIO_IE_DISABLE },    // S_HGPIO4 NC
+    { HAL_PIO_FUNC_GPIO, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_MAX, HAL_PIO_IE_DISABLE },    // S_HGPIO4 NC
     { HAL_PIO_FUNC_GPIO, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_DOWN, HAL_PIO_IE_DISABLE },    // S_HGPIO5 NC
 #if (defined CFG_DRIVERS_NANDFLASH)
     { HAL_PIO_FUNC_QSPI1, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_UP, HAL_PIO_IE_ENBALE },   // S_HGPIO6
@@ -185,7 +185,7 @@ const hal_pio_config_t g_pio_function_config[PIN_MAX_NUMBER] = {
     { HAL_PIO_FUNC_GPIO, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_MAX, HAL_PIO_IE_ENBALE },   // S_AGPIO_L29    charge done info 检测是否充满电
     { HAL_PIO_FUNC_GPIO, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_MAX, HAL_PIO_IE_DISABLE },   // S_AGPIO_L30   KP_MKIN1 唤醒 CAT1 ,输出
     { HAL_PIO_FUNC_GPIO, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_MAX, HAL_PIO_IE_ENBALE },   // S_AGPIO_L31    KP_MKOUIT1 唤醒 蓝牙 ,输入
-    { HAL_PIO_FUNC_GPIO, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_DOWN, HAL_PIO_IE_DISABLE },   // S_AGPIO_L32    NC
+    { HAL_PIO_FUNC_GPIO, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_MAX, HAL_PIO_IE_DISABLE },   // S_AGPIO_L32    NC
 
     { HAL_PIO_FUNC_GPIO, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_MAX, HAL_PIO_IE_DISABLE },   // S_AGPIO_R0   PRG_LED_POWER ON  心率等电源控制脚
     { HAL_PIO_FUNC_GPIO, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_MAX, HAL_PIO_IE_DISABLE },   // S_AGPIO_R1   SE_REST 安全芯片复位唤醒脚
@@ -262,7 +262,7 @@ const hal_gpio_config_t g_gpio_function_config[PIN_MAX_NUMBER] = {
   //    S_AGPIO_L23 CAT_1_PWR_ON ----- high power on
     {   S_AGPIO_L23, HAL_GPIO_DIRECTION_OUTPUT, HAL_GPIO_LEVEL_LOW, 0, NULL },
    // S_AGPIO_L28   Cat1 reset  ---- low reset
-    // {   S_AGPIO_L28, HAL_GPIO_DIRECTION_OUTPUT, HAL_GPIO_LEVEL_LOW, 0, NULL },
+    // {   S_AGPIO_L24, HAL_GPIO_DIRECTION_OUTPUT, HAL_GPIO_LEVEL_LOW, 0, NULL },
 #endif
     // S_AGPIO_L17   HX3507_INT 
     // {   S_AGPIO_L17, HAL_GPIO_DIRECTION_INPUT, HAL_GPIO_LEVEL_LOW, 0, NULL },
@@ -272,9 +272,9 @@ const hal_gpio_config_t g_gpio_function_config[PIN_MAX_NUMBER] = {
     // {   S_AGPIO_L13, HAL_GPIO_DIRECTION_OUTPUT, HAL_GPIO_LEVEL_LOW, 0, NULL },
 
      // S_AGPIO_L26 心率复位 PPG reset
-    {   S_AGPIO_L26, HAL_GPIO_DIRECTION_OUTPUT, HAL_GPIO_LEVEL_LOW, 0, NULL },
+    // {   S_AGPIO_L26, HAL_GPIO_DIRECTION_OUTPUT, HAL_GPIO_LEVEL_LOW, 0, NULL },
     // S_AGPIO_R0 PRG_LED_POWER ON  心率等电源控制脚
-    {   S_AGPIO_R0, HAL_GPIO_DIRECTION_OUTPUT, HAL_GPIO_LEVEL_LOW, 0, NULL },
+    // {   S_AGPIO_R0, HAL_GPIO_DIRECTION_OUTPUT, HAL_GPIO_LEVEL_LOW, 0, NULL },
 
     //S_AGPIO_L21 NTC_VDD_ON 给低打开 NTC上拉电源 ,默认关闭
     {   S_AGPIO_L21, HAL_GPIO_DIRECTION_OUTPUT, HAL_GPIO_LEVEL_HIGH, 0, NULL },
@@ -287,10 +287,15 @@ const hal_gpio_config_t g_gpio_function_config[PIN_MAX_NUMBER] = {
     {   S_AGPIO_R9, HAL_GPIO_DIRECTION_OUTPUT, HAL_GPIO_LEVEL_LOW, 0, NULL },
     {   S_AGPIO_L20, HAL_GPIO_DIRECTION_OUTPUT, HAL_GPIO_LEVEL_HIGH, 0, NULL },
 #endif
-    //开机开启背光
-    {   S_AGPIO_L16, HAL_GPIO_DIRECTION_OUTPUT, HAL_GPIO_LEVEL_HIGH, 0, NULL },
+
+    // {   S_AGPIO_L16, HAL_GPIO_DIRECTION_OUTPUT, HAL_GPIO_LEVEL_HIGH, 0, NULL },
 //默认关闭马达
-    {   S_AGPIO_R2, HAL_GPIO_DIRECTION_OUTPUT, HAL_GPIO_LEVEL_LOW, 0, NULL },
+    {   S_AGPIO_L32, HAL_GPIO_DIRECTION_OUTPUT, HAL_GPIO_LEVEL_LOW, 0, NULL },
+    {   S_AGPIO_R0, HAL_GPIO_DIRECTION_OUTPUT, HAL_GPIO_LEVEL_LOW, 0, NULL },
+    {   S_HGPIO4, HAL_GPIO_DIRECTION_OUTPUT, HAL_GPIO_LEVEL_LOW, 0, NULL },
+    {   S_HGPIO0, HAL_GPIO_DIRECTION_OUTPUT, HAL_GPIO_LEVEL_LOW, 0, NULL },
+
+
 //默认开启 EXT LDO V3.0 V1.8
     // {   S_AGPIO_L18, HAL_GPIO_DIRECTION_OUTPUT, HAL_GPIO_LEVEL_HIGH, 0, NULL },
     {   S_AGPIO_L14, HAL_GPIO_DIRECTION_OUTPUT, HAL_GPIO_LEVEL_HIGH, 0, NULL },
@@ -302,7 +307,7 @@ const hal_gpio_config_t g_gpio_function_config[PIN_MAX_NUMBER] = {
     //{   S_AGPIO_L19, HAL_GPIO_DIRECTION_INPUT, NULL, GPIO_INTERRUPT_DEDGE, cywee_int_callback },
 #endif    
     /**S_AGPIO_R1 GPO alipay默认resetpin*/
-    {   S_AGPIO_R1, HAL_GPIO_DIRECTION_OUTPUT, HAL_GPIO_LEVEL_HIGH, 0, NULL },
+    // {   S_AGPIO_R1, HAL_GPIO_DIRECTION_OUTPUT, HAL_GPIO_LEVEL_HIGH, 0, NULL },
 #ifdef SUPPORT_CAT1_SERVICE
     /**cat1 ring input key*/
     // {   S_AGPIO_L31, HAL_GPIO_DIRECTION_INPUT, NULL, GPIO_INTERRUPT_DEDGE,  cat1_ring_isr_callback},
index 5db2684..9df3599 100644 (file)
@@ -64,12 +64,12 @@ enum PlayerSeekMode : int32_t {
     /** Moves the media position to the latest synchronization frame located after the given time position. */\r
     PLAYER_SEEK_NEXT_SYNC,\r
     /** Moves the media position to the latest synchronization frame located before or after the given time position. */\r
-    PLAYER_SEEK_CLOSEST_SYNC,
-    /** Moves the media position to the latest frame located before or after the given time position. */
-    PLAYER_SEEK_CLOSEST,
-};
-
-/**
+    PLAYER_SEEK_CLOSEST_SYNC,\r
+    /** Moves the media position to the latest frame located before or after the given time position. */\r
+    PLAYER_SEEK_CLOSEST,\r
+};\r
+\r
+/**\r
  * @brief Enumerates player states.\r
  *\r
  * @since 1.0\r
@@ -272,13 +272,13 @@ public:
     int32_t Rewind(int64_t mSeconds, int32_t mode);\r
 \r
     /**\r
-     * @brief Sets the volume of the player.
-     *
-     * This function can be used during playback or pause. The value <b>0</b> indicates no sound, and <b>100</b>
-     * indicates the original volume.
-     *
-     * @param leftVolume Indicates the target volume of the left audio channel to set, ranging from 0 to 300.
-     * @param rightVolume Indicates the target volume of the right audio channel to set, ranging from 0 to 300.
+     * @brief Sets the volume of the player.\r
+     *\r
+     * This function can be used during playback or pause. The value <b>0</b> indicates no sound, and <b>100</b>\r
+     * indicates the original volume.\r
+     *\r
+     * @param leftVolume Indicates the target volume of the left audio channel to set, ranging from 0 to 300.\r
+     * @param rightVolume Indicates the target volume of the right audio channel to set, ranging from 0 to 300.\r
      * @return Returns <b>0</b> if the setting is successful; returns <b>-1</b> otherwise.\r
      * @since 1.0\r
      * @version 1.0\r
@@ -316,22 +316,22 @@ public:
      * @return Returns <b>true</b> if the player is looping; returns <b>false</b> otherwise.\r
      * @since 1.0\r
      * @version 1.0\r
-     */
-    bool IsSingleLooping();
-
-    /**
-     * @brief Obtains the player state.
-     *
-     * @param state Indicates the player state. For details, see {@link PlayerStates}.
-     * @return Returns <b>0</b> if the player state is obtained; returns <b>-1</b> otherwise.
-     * @since 1.0
-     * @version 1.0
-     */
-    int32_t GetPlayerState(int32_t &state) const;
-
-    /**
-     * @brief Obtains the playback position, accurate to millisecond.
-     *
+     */\r
+    bool IsSingleLooping();\r
+\r
+    /**\r
+     * @brief Obtains the player state.\r
+     *\r
+     * @param state Indicates the player state. For details, see {@link PlayerStates}.\r
+     * @return Returns <b>0</b> if the player state is obtained; returns <b>-1</b> otherwise.\r
+     * @since 1.0\r
+     * @version 1.0\r
+     */\r
+    int32_t GetPlayerState(int32_t &state) const;\r
+\r
+    /**\r
+     * @brief Obtains the playback position, accurate to millisecond.\r
+     *\r
      * @param time Indicates the playback position.\r
      * @return Returns <b>0</b> if the playback position is obtained; returns <b>-1</b> otherwise.\r
      * @since 1.0\r
@@ -352,38 +352,38 @@ public:
      * @version 1.0\r
      */\r
     int32_t GetDuration(int64_t &durationMs) const;\r
-
-    /**
-     * Sets the playback speed.
-     *
-     * @param speed Indicates the playback speed to set, which support {-128/-64/-32/-16/-8/-4/-2/1/2/4/8/16/32/64/128}
-     * @return Returns {@code 0} if the playback speed is set; returns {@code -1} otherwise.
-     */
-    int32_t SetPlaybackSpeed(float speed);
-    /**
-     * Obtains the playback speed.
-     *
-     * @param speed Indicates the playback speed.
-     * @return Returns {@code 0} if the playback speed is set; returns {@code -1} otherwise.
-     */
-    int32_t GetPlaybackSpeed(float &speed);
-    /**
-     * Sets the audio type.
-     *
-     * @param type Indicates the audio type.
-     * @return Returns {@code 0} if the setting is successful; returns {@code -1} otherwise.
-     */
-    int32_t SetAudioStreamType(int32_t type);
-    /**
-     * Obtains the audio type.
-     *
-     * @param type Indicates the audio type.
-     * @return Returns {@code 0} if the playback speed is set; returns {@code -1} otherwise.
-     */
-    int32_t GetAudioStreamType(int32_t &type);
-    /**
-     * @brief Restores the player to the initial state.
-     *
+\r
+    /**\r
+     * Sets the playback speed.\r
+     *\r
+     * @param speed Indicates the playback speed to set, which support {-128/-64/-32/-16/-8/-4/-2/1/2/4/8/16/32/64/128}\r
+     * @return Returns {@code 0} if the playback speed is set; returns {@code -1} otherwise.\r
+     */\r
+    int32_t SetPlaybackSpeed(float speed);\r
+    /**\r
+     * Obtains the playback speed.\r
+     *\r
+     * @param speed Indicates the playback speed.\r
+     * @return Returns {@code 0} if the playback speed is set; returns {@code -1} otherwise.\r
+     */\r
+    int32_t GetPlaybackSpeed(float &speed);\r
+    /**\r
+     * Sets the audio type.\r
+     *\r
+     * @param type Indicates the audio type.\r
+     * @return Returns {@code 0} if the setting is successful; returns {@code -1} otherwise.\r
+     */\r
+    int32_t SetAudioStreamType(int32_t type);\r
+    /**\r
+     * Obtains the audio type.\r
+     *\r
+     * @param type Indicates the audio type.\r
+     * @return Returns {@code 0} if the playback speed is set; returns {@code -1} otherwise.\r
+     */\r
+    int32_t GetAudioStreamType(int32_t &type);\r
+    /**\r
+     * @brief Restores the player to the initial state.\r
+     *\r
      * @return Returns <b>0</b> if the player is restored; returns <b>-1</b> otherwise.\r
      * @since 1.0\r
      * @version 1.0\r
@@ -404,18 +404,18 @@ public:
      *\r
      * @param cb Indicates the listener to register. For details, see {@link PlayerCallback}.\r
      * @since 1.0\r
-     * @version 1.0
-     */
-    void SetPlayerCallback(const std::shared_ptr<PlayerCallback> &cb);
-    /**
-     * set parameter through format, extended interface.
-     *
-     * @param params Indicates the extended-informations. Format see {@link Format}
-     * @return Returns {@code 0} if set parameter successfully; returns {@code -1} otherwise.
-     * @note not support on current version
-     */
-    int32_t SetParameter(const Format &params);
-    /**
+     * @version 1.0\r
+     */\r
+    void SetPlayerCallback(const std::shared_ptr<PlayerCallback> &cb);\r
+    /**\r
+     * set parameter through format, extended interface.\r
+     *\r
+     * @param params Indicates the extended-informations. Format see {@link Format}\r
+     * @return Returns {@code 0} if set parameter successfully; returns {@code -1} otherwise.\r
+     * @note not support on current version\r
+     */\r
+    int32_t SetParameter(const Format &params);\r
+    /**\r
      * get parameter through format, extended interface.\r
      *\r
      * @param params Indicates the extended-informations. Format see {@link Format}\r
@@ -423,44 +423,44 @@ public:
      */\r
     int32_t GetParameter(Format &params);\r
     /**\r
-     * get the total number of the tracks.
-     *
-     * @param totalTracks Indicates the total number of the tracks.
-     * @return Returns {@code 0} if set parameter successfully; returns {@code -1} otherwise.
-     */
+     * get the total number of the tracks.\r
+     *\r
+     * @param totalTracks Indicates the total number of the tracks.\r
+     * @return Returns {@code 0} if set parameter successfully; returns {@code -1} otherwise.\r
+     */\r
     int32_t GetTotalTracks(int32_t &totalTracks);\r
     /**\r
      * set audio sessionid.\r
-     *
+     *\r
      * @param sessionId indicates sessionid to be set.\r
      * @return Returns {@code 0} if set parameter successfully; returns {@code -1} otherwise.\r
      */\r
     int32_t SetAudioSessionId(uint32_t sessionId);\r
     /**\r
      * get current audio sessionid.\r
-     *
+     *\r
      * @param indicates sessionid.\r
      * @return Returns {@code 0} if get parameter successfully; returns {@code -1} otherwise.\r
      */\r
     int32_t GetAudioSessionId(uint32_t &sessionId);\r
     /**\r
      * set output device.\r
-     *
+     *\r
      * @param deviceId indicates device to be set.\r
      * @return Returns {@code 0} if set parameter successfully; returns {@code -1} otherwise.\r
      */\r
     int32_t SetOutputDevice(int32_t deviceId);\r
     /**\r
      * get current route device.\r
-     *
+     *\r
      * @param deviceId indicates the output device.\r
      * @return Returns {@code 0} if get parameter successfully; returns {@code -1} otherwise.\r
      */\r
     int32_t GetRoutedDeviceId(int32_t &deviceId);\r
 \r
     int32_t DumpInfo(PlayerDebugInfo *playerInfo);\r
-private:
-    class PlayerImpl;
+private:\r
+    class PlayerImpl;\r
     std::unique_ptr<PlayerImpl> impl_;\r
 };\r
 }  // namespace Media\r
index 4ee1aee..1a37565 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: penglei 1624952103@qq.com
  * @Date: 2024-08-08 16:33:23
  * @LastEditors: penglei 1624952103@qq.com
- * @LastEditTime: 2025-07-31 17:09:45
+ * @LastEditTime: 2025-09-16 15:56:41
  * @FilePath: /FD230/code/sdk/drivers/peripheral/vibrator/service/vibrator_service.cpp
  * @Description: 
  * 
@@ -61,17 +61,17 @@ void custom_VibratorFunc_int(int vibratorType)
     case 3:
         mail.cycle_time_ms = 235;
         mail.duty = 50;
-        mail.duration_time_ms = 60;
+        mail.duration_time_ms = 600;
         break;
     case 2:
         mail.cycle_time_ms = 235;
         mail.duty = 50;
-        mail.duration_time_ms = 40;
+        mail.duration_time_ms = 400;
         break;
     case 1:
         mail.cycle_time_ms = 235;
         mail.duty = 50;
-        mail.duration_time_ms = 20;
+        mail.duration_time_ms = 200;
         break;
     default:
         break;
index ea6965b..fe98004 100644 (file)
 #include "chip_core_irq.h"
 #include "pwm.h"
 #include "pwm_porting.h"
-#include "pinctrl.h"
 #include "vibrator.h"
 
+#ifdef BOARD_LEINIAO
+#define VIBRATOR_GPIOPPIN S_HGPIO4
+#else
+#define VIBRATOR_GPIOPPIN S_AGPIO_R2
+#endif
+
 // #define VIB_DEBUG
 #ifdef  VIB_USE_PWM
-#define VIBRATOR_GPIOPPIN S_AGPIO_R2
+
 // #define VIBRATORPIN_MODE HAL_PIO_FUNC_PWMP1_M2 
 #define VIBRATORPIN_MODE HAL_PIO_FUNC_PWMN1_M3 
 
@@ -188,7 +193,7 @@ void g_VibratorFunc(uint16_t duty , uint16_t cycle_time_ms,uint16_t duration_tim
 }
 
 #else
-#define VIBRATOR_GPIOPPIN S_AGPIO_R2
+
 #define VIBRATORPIN_MODE HAL_PIO_FUNC_GPIO 
 static  pin_t pin = VIBRATOR_GPIOPPIN;
 static  pin_mode_t mode = VIBRATORPIN_MODE;
@@ -221,7 +226,7 @@ void g_VibratorFunc(uint16_t duty , uint16_t cycle_time_ms,uint16_t duration_tim
         if (delaytime_ms_low == 0) delaytime_ms_low = 1;
         if (delaytime_ms_high == 0) delaytime_ms_high = 1;
 
-        // PRINT("g_VibratorFunc delaytime_ms_high  %u ,  delaytime_ms_low %u \r\n",delaytime_ms_high,delaytime_ms_low );
+        printf("fac:g_VibratorFunc delaytime_ms_high  %u ,  delaytime_ms_low %u \r\n",delaytime_ms_high,delaytime_ms_low );
         
         while(duration_time_ms)
         {
index 0793915..84c4230 100644 (file)
@@ -25,6 +25,10 @@ extern "C" {
 */
 void g_VibratorFunc(uint16_t duty , uint16_t cycle_time_ms,uint16_t duration_time_ms);
 
+#ifdef BOARD_LEINIAO
+void uapi_motor_test(void);
+#endif
+
 /**
  * @}
  */
index 6743ef6..7b8128e 100644 (file)
@@ -68,7 +68,9 @@ static uint32_t vibrator_do_test(uint8_t *para, uint32_t paraLen, char *strCommo
         PRINT("VIBRATORTEST ATCMD Convert Command Failed\n");
         return ERRCODE_FAIL;
     }
-
+#ifdef BOARD_LEINIAO
+    uapi_motor_test();
+#else
     if (argc != 3) {
         PRINT("VIBRATORTEST ATCMD Set Parameter Failed argc %d, should be AT^VIBRATORTEST=duration cycle duty \n",argc);
         return ERRCODE_FAIL;
@@ -78,6 +80,8 @@ static uint32_t vibrator_do_test(uint8_t *para, uint32_t paraLen, char *strCommo
     uint16_t duty = (uint16_t)atoi((char*)argv[2]);
     PRINT("VIBRATORTEST ATCMD custom_VibratorFunc duration %u,cycle %u,duty %u\n",duration,cycle,duty);
     hal_custom_VibratorFunc(duty,cycle,duration);
+#endif
+
     return ERRCODE_SUCC;
 }
 
index b9c93d7..2bd48c7 100644 (file)
@@ -584,7 +584,11 @@ void startup_post_init_task(void)
     struct tm* timeinfo;
 
     PRINT("startup_post_init_task !\r\n");
-
+#ifdef BOARD_LEINIAO
+    custom_play_audio("/user/music/PowerOn.mp3",100);
+    LOS_Msleep(1500);
+    custom_stop_play_audio();
+#endif
 #ifdef SUPPORT_CYWEE_SERVICE
     do_cywee_service_check_msg(CYWEE_SERVICE_CMD_TIME_SYNC,NULL);
 #endif
@@ -4341,6 +4345,9 @@ void uapi_lcd_backlight_off(void)
 
 void uapi_lcd_backlight_on(uint8_t brightness)
 {
+#ifdef CUSTOM_ZHIHUI
+    brightness = cm_getScreenBrightness();
+#endif
     uint8_t fall_edge_cnt = 0;
     if (brightness <= 11)      fall_edge_cnt = 7;
     else if (brightness <= 24) fall_edge_cnt = 6;
index 99caae4..2c25884 100644 (file)
@@ -18,7 +18,10 @@ set(PRIVATE_HEADER
     ${CMAKE_SOURCE_DIR}/middleware/utils/update/inner_include
     ${CMAKE_SOURCE_DIR}/middleware/services/gui/uikit/proprietary/include
     ${CMAKE_SOURCE_DIR}/middleware/services/gui/uikit/utils/interfaces/kits
+    ${CMAKE_SOURCE_DIR}/middleware/services/gui/uikit/surface/interfaces/kits
     ${CMAKE_SOURCE_DIR}/middleware/services/gui/uikit/utils/interfaces/innerkits
+    ${CMAKE_SOURCE_DIR}/middleware/services/media/foundation/player/interfaces/kits
+    ${CMAKE_SOURCE_DIR}/open_source/openharmony/drivers/peripheral/display/interfaces/include
 )
 
 set(PRIVATE_DEFINES
index cae32a9..48020d9 100644 (file)
@@ -21,6 +21,8 @@
 
 #include "audio_manager.h"
 #include "audio_base_type.h"
+#include "player_lite/js/builtin/include/audio_player.h"
+
 
 
 #include "bts_br_gap.h"
@@ -444,4 +446,125 @@ void custom_factory_bt_scan_stop(void)
       
       #endif
 #endif
+}
+
+/**
+ * @brief 播放指定路径的音频文件
+ * @param filePath 音频文件路径
+ * @param volume 音量 (0-100)
+ * @return 0: 成功, -1: 失败
+ */
+int custom_play_audio(const char* filePath, float volume)
+{
+    if (!filePath) {
+        filePath = "/user/userdata/1.mp3";
+    }
+    
+    printf("=== Starting AudioPlayer playback ===\n");
+    printf("File: %s, Volume: %.1f%%\n", filePath, volume);
+    
+    // 检查文件是否存在
+    struct stat fileStat;
+    if (stat(filePath, &fileStat) != 0 || !S_ISREG(fileStat.st_mode)) {
+        printf("ERROR: Audio file not found: %s\n", filePath);
+        return -1;
+    }
+    printf("Audio file exists, size: %ld bytes\n", fileStat.st_size);
+    
+    // 获取AudioPlayer单例
+    OHOS::ACELite::AudioPlayer* player = OHOS::ACELite::AudioPlayer::GetInstance();
+    if (!player) {
+        printf("ERROR: Failed to get AudioPlayer instance\n");
+        return -1;
+    }
+    printf("AudioPlayer instance obtained\n");
+    
+    // 检查初始状态
+    bool initialPlaying = player->IsPlaying();
+    printf("Initial playing state: %s\n", initialPlaying ? "true" : "false");
+    
+    // 先停止当前播放
+    if (initialPlaying) {
+        printf("Stopping current playback...\n");
+        bool stopResult = player->Stop();
+        printf("Initial stop result: %s\n", stopResult ? "SUCCESS" : "FAILED");
+    }
+    
+    // 设置音频源
+    printf("Setting audio source...\n");
+    if (!player->SetSrc(const_cast<char*>(filePath), false)) {
+        printf("ERROR: Failed to set audio source\n");
+        return -1;
+    }
+    printf("Audio source set successfully\n");
+    
+    // 设置音量 (AudioPlayer的音量范围是0.0-1.0)
+    double normalizedVolume = volume / 100.0;
+    if (normalizedVolume > 1.0) normalizedVolume = 1.0;
+    if (normalizedVolume < 0.0) normalizedVolume = 0.0;
+    
+    printf("Setting volume to %.2f (%.1f%%)\n", normalizedVolume, volume);
+    if (!player->SetVolume(normalizedVolume)) {
+        printf("WARNING: Failed to set volume, continuing anyway\n");
+        // 不返回错误,音量设置失败不应该阻止播放
+    }
+    
+    // 开始播放
+    printf("Starting playback...\n");
+    if (!player->Play()) {
+        printf("ERROR: Failed to start playback\n");
+        return -1;
+    }
+    
+    // 检查播放状态
+    bool finalPlaying = player->IsPlaying();
+    const char* finalStatus = player->GetStatus();
+    printf("Final state - Status: %s, IsPlaying: %s\n", 
+           finalStatus ? finalStatus : "null", finalPlaying ? "true" : "false");
+    
+    printf("=== AudioPlayer playback started successfully ===\n");
+    return 0;
+}
+
+/**
+ * @brief 停止播放当前音频
+ * @return 0: 成功, -1: 失败
+ */
+int custom_stop_play_audio(void)
+{
+    printf("=== Starting AudioPlayer stop process ===\n");
+    
+    OHOS::ACELite::AudioPlayer* player = OHOS::ACELite::AudioPlayer::GetInstance();
+    if (!player) {
+        printf("ERROR: AudioPlayer instance is null\n");
+        return -1;
+    }
+    
+    printf("AudioPlayer instance obtained successfully\n");
+    
+    // 检查当前播放状态
+    bool isPlaying = player->IsPlaying();
+    const char* status = player->GetStatus();
+    printf("Current status: %s, IsPlaying: %s\n", 
+           status ? status : "null", isPlaying ? "true" : "false");
+    
+    printf("Attempting to stop playback...\n");
+    bool stopResult = player->Stop();
+    printf("Stop result: %s\n", stopResult ? "SUCCESS" : "FAILED");
+    
+    // 再次检查状态
+    bool isStillPlaying = player->IsPlaying();
+    const char* newStatus = player->GetStatus();
+    printf("After stop - Status: %s, IsPlaying: %s\n", 
+            newStatus ? newStatus : "null", isStillPlaying ? "true" : "false");
+    
+    if (!stopResult) {
+        printf("ERROR: Failed to stop AudioPlayer\n");
+        player->Stop();
+    }
+    
+    
+    
+    printf("=== AudioPlayer stop process completed ===\n");
+    return 0;
 }
\ No newline at end of file
index 74c5db6..47b1593 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: penglei 1624952103@qq.com
  * @Date: 2024-07-09 20:22:54
  * @LastEditors: penglei 1624952103@qq.com
- * @LastEditTime: 2025-08-20 15:13:20
+ * @LastEditTime: 2025-09-16 15:27:29
  * @FilePath: /FD230/code/sdk/drivers/peripheral/utilscpp/custom_utilscpp.h
  * @Description: 
  * 
@@ -34,6 +34,9 @@ void custom_set_volume(uint8_t channel,int32_t sounding);
 void custom_factory_bt_scan_start(void);
 void custom_factory_bt_scan_stop(void);
 
+int custom_play_audio(const char* filePath, float volume);
+int custom_stop_play_audio(void);
+
 /**
  * input: 
  *     func  函数指针