魔盒最新版本,更新了充电检测,鸟叫,dp4对声音的控制,声音模块由于硬件问题暂未实测

This commit is contained in:
2026-09-09 15:32:50 +08:00
parent 3ab37b7845
commit b576f31113
22 changed files with 871 additions and 528 deletions
+21 -19
View File
@@ -19,6 +19,9 @@
#include "app_mode.h"
#include "app_led.h"
#include "app_shake_wake.h"
#include "app_no_disturb.h"
#include "car_audio_test.h"
#include "app_audio_debug.h"
#include "app_time_util.h"
#include "bsp_hw.h"
#include "board_pin.h"
@@ -46,7 +49,6 @@ typedef struct {
volatile uint8_t play_write_pending;
volatile uint8_t play_write_mode;
uint8_t shake_wake;
uint8_t no_disturb;
} AppFunctionCtx_t;
static AppFunctionCtx_t s_func;
@@ -71,7 +73,6 @@ void app_function_init(void)
app_shake_wake_init(function_shake_wake_allowed,
function_shake_wake_trigger);
s_func.shake_wake = !!gDevData.shake_wake;
s_func.no_disturb = !!gDevData.no_disturb_enable[0];
app_shake_wake_set_enable(s_func.shake_wake);
}
@@ -105,12 +106,6 @@ void app_function_set_shake_wake(uint8_t enable)
app_shake_wake_set_enable(s_func.shake_wake);
}
void app_function_set_no_disturb(uint8_t enable)
{
s_func.no_disturb = !!enable;
app_shake_wake_reset();
}
/**
* @brief 跟随 APP 下发的 DP0/DP1,并处理 DP2 手动点动
* @return 无
@@ -120,10 +115,6 @@ void app_function_poll(void)
if (s_func.shake_wake != !!gDevData.shake_wake) {
app_function_set_shake_wake(gDevData.shake_wake);
}
if (s_func.no_disturb != !!gDevData.no_disturb_enable[0]) {
app_function_set_no_disturb(gDevData.no_disturb_enable[0]);
}
if (s_func.power_write_pending) {
uint8_t enable = s_func.power_write_value;
s_func.power_write_pending = 0;
@@ -265,6 +256,10 @@ static void function_play_mode_apply(uint8_t mode)
{
uint8_t old_mode = s_func.play_mode;
MAGIC_AUDIO_LOG("模式切换请求:旧=%u,请求=%u,DP4=%u,功能开关=%u,充电=%u,关机中=%uOTA=%u",
old_mode, mode, gDevData.beep_trig, s_func.app_power,
app_power_usb_online(), app_power_poweroff_pending(), app_led_is_ota());
if (mode > PLAY_MODE_5) {
mode = 0;
}
@@ -284,10 +279,17 @@ static void function_play_mode_apply(uint8_t mode)
} else {
app_mode_start(mode);
}
// MAGIC_AUDIO_LOG("模式切换结果:旧=%u,实际=%u;当前测试不拦截DP4", old_mode, mode);
if (mode != old_mode) {
app_led_request_mode_blink(); /* 模式真变了才闪两下 */
app_led_request_mode_blink(); /* 模式真变了才闪两下 */
/* DP4:0=关闭模式切换鸟叫,1=允许播放 */
//&& gDevData.beep_trig
if ((mode != PLAY_MODE_0) && gDevData.beep_trig) {
Car_Audio_Test_Play();
}
}
}
/**
* @brief 跟随 APP 下发的 DP1 自动模式
@@ -384,7 +386,7 @@ static void function_hand_poll(void)
s_func.play_mode = 0;
s_func.play_ms = 0;
gDevData.play_mode = 0;
app_mode_stop(); /* 自动切手动:先停自动玩法 */
app_mode_stop();
s_func.hand_busy = 1;
s_func.hand_ms = 0;
gDevData.hand_mode = cmd;
@@ -395,10 +397,10 @@ static void function_hand_poll(void)
bsp_drive_set(BSP_MOTOR_STOP, 0,
BSP_MOTOR_FORWARD, 5500);
}
app_led_request_mode_blink(); /* 自动/空闲切到手动,闪两下提示 */
log_info("hand cmd=%d %s max=%ums\n", cmd,
(cmd == HAND_MODE_1) ? "upper" : "lower",
(unsigned)BOARD_HAND_PULSE_MS);
app_led_request_mode_blink();
if (gDevData.beep_trig) {
Car_Audio_Test_Play();
}
} else {
gDevData.hand_mode = HAND_MODE_0;
if (s_func.hand_busy) {
@@ -501,7 +503,7 @@ static uint8_t function_power_on(uint8_t show_hint)
static uint8_t function_shake_wake_allowed(void)
{
return s_func.shake_wake &&
!s_func.no_disturb &&
!app_no_disturb_is_active() &&
!s_func.app_power &&
!app_power_usb_online() &&
!app_power_poweroff_pending() &&