make footsteps enhancement to two steps, 0, and 15db. and default is 15db

This commit is contained in:
Steven Dan
2026-06-04 10:04:35 +08:00
parent 9205b48882
commit b8f93ea5f5
2 changed files with 36 additions and 40 deletions

View File

@@ -3,7 +3,7 @@
#else #else
#define DEBUG_PRINT_ENABLE 0 #define DEBUG_PRINT_ENABLE 0
#endif #endif
//#define DISABLE_REBOOT 1 #define DISABLE_REBOOT 1
#include <xs1.h> #include <xs1.h>
#include <assert.h> #include <assert.h>
@@ -535,8 +535,8 @@ void button_task(chanend c_hidSendData, chanend cc_mic_level, chanend c_uac_vol,
// active_mode: 0=off, 1=music (LED_MUSIC, no algorithm), // active_mode: 0=off, 1=music (LED_MUSIC, no algorithm),
// 2=game (LED_GAME_MODE, IR_GAME), 3=AI7.1 (LED_AI7_1, IR_7_1_GAME) // 2=game (LED_GAME_MODE, IR_GAME), 3=AI7.1 (LED_AI7_1, IR_7_1_GAME)
unsigned active_mode = 0; unsigned active_mode = 0;
// 脚步增强3档状态: 0=关(0dB), 1=中亮/6dB, 2=高亮/12dB出厂默认开启(12dB) // 改动原因脚步增强改为2档——0=关(0dB)1=开(15dB);出厂默认开启(15dB)
unsigned flag_footsteps_enhancement = 2; unsigned flag_footsteps_enhancement = 1;
// 出厂默认AI降噪开启 // 出厂默认AI降噪开启
unsigned flag_aidenoise_onoff = 1; unsigned flag_aidenoise_onoff = 1;
unsigned dnr_strength_saved = 100; // AI降噪重新开启时恢复的强度0x85可更新 unsigned dnr_strength_saved = 100; // AI降噪重新开启时恢复的强度0x85可更新
@@ -548,7 +548,7 @@ void button_task(chanend c_hidSendData, chanend cc_mic_level, chanend c_uac_vol,
unsigned push_button_game_mode_state_old = 1; // Active low unsigned push_button_game_mode_state_old = 1; // Active low
unsigned push_button_footsteps_enhancement_state_old = 0; // Active low unsigned push_button_footsteps_enhancement_state_old = 0; // Active low
unsigned push_button_aidenoise_onoff_state_old = 1; // Active low unsigned push_button_aidenoise_onoff_state_old = 1; // Active low
unsigned char saved_footstep = 0; unsigned char saved_footstep = 15; // 改动原因与出厂默认15dB一致flash加载前临时初值
@@ -615,22 +615,26 @@ void button_task(chanend c_hidSendData, chanend cc_mic_level, chanend c_uac_vol,
debug_printf("Loaded game_mode from flash: %d\n", saved_mode); debug_printf("Loaded game_mode from flash: %d\n", saved_mode);
#if USE_EX3D == 1 #if USE_EX3D == 1
// 加载脚步增强状态(保存值为expand_gain: 0/6/12 // 改动原因:加载脚步增强2档 expand_gain: 0/15旧固件6/12等非零值迁移为15
{ {
unsigned char footstep_path[] = "footstep"; unsigned char footstep_path[] = "footstep";
saved_footstep = load_value(footstep_path); saved_footstep = load_value(footstep_path);
debug_printf("Loaded footstep gain from flash: %d\n", saved_footstep); debug_printf("Loaded footstep gain from flash: %d\n", saved_footstep);
if (saved_footstep == 0) { if (saved_footstep == 0) {
flag_footsteps_enhancement = 0; flag_footsteps_enhancement = 0;
} else if (saved_footstep <= 6) { } else if (saved_footstep == 15) {
flag_footsteps_enhancement = 1; flag_footsteps_enhancement = 1;
} else if (saved_footstep <= 20) { } else if (saved_footstep > 0 && saved_footstep <= 20) {
flag_footsteps_enhancement = 2; // 旧3档(6/12)或其它历史非零增益统一迁移为15dB开档
saved_footstep = 15;
flag_footsteps_enhancement = 1;
save_value(footstep_path, (unsigned char)15);
debug_printf("Migrated footstep gain to flash: %d\n", saved_footstep);
} else { } else {
// 未初始化(255)或异常值:出厂默认脚步增强开启(12dB)写入flash // 未初始化(255)或异常值:出厂默认脚步增强开启(15dB)写入flash
saved_footstep = 12; saved_footstep = 15;
flag_footsteps_enhancement = 2; flag_footsteps_enhancement = 1;
save_value(footstep_path, (unsigned char)12); save_value(footstep_path, (unsigned char)15);
debug_printf("Saved footstep gain to flash: %d\n", saved_footstep); debug_printf("Saved footstep gain to flash: %d\n", saved_footstep);
} }
debug_printf("Loaded footstep gain from flash: %d, state=%d\n", saved_footstep, flag_footsteps_enhancement); debug_printf("Loaded footstep gain from flash: %d, state=%d\n", saved_footstep, flag_footsteps_enhancement);
@@ -972,13 +976,10 @@ void button_task(chanend c_hidSendData, chanend cc_mic_level, chanend c_uac_vol,
} }
} }
// 恢复脚步增强LED初始状态 // 改动原因2档脚步增强——仅开档(15dB)点亮LED
if (flag_footsteps_enhancement == 1) { if (flag_footsteps_enhancement == 1) {
led_on(&led_ctx, LED_FOOTSTEP_MODE); led_on(&led_ctx, LED_FOOTSTEP_MODE);
led_update_all(&led_ctx); led_update_all(&led_ctx);
} else if (flag_footsteps_enhancement == 2) {
led_set_brightness(&led_ctx, LED_FOOTSTEP_MODE, 128);
led_update_all(&led_ctx);
} }
#endif #endif
@@ -1024,7 +1025,7 @@ void button_task(chanend c_hidSendData, chanend cc_mic_level, chanend c_uac_vol,
{ {
unsigned music_init, game_init; unsigned music_init, game_init;
p_button_music_mode :> music_init; p_button_music_mode :> music_init;
p_button_game_mode :> game_init; p_button_game_mode :> game_init;//
if (music_init == 0 && game_init == 0) { if (music_init == 0 && game_init == 0) {
fr_inhibit = 1; fr_inhibit = 1;
btn_combo_active = 1; btn_combo_active = 1;
@@ -1600,8 +1601,8 @@ void button_task(chanend c_hidSendData, chanend cc_mic_level, chanend c_uac_vol,
case 3: led_on(&led_ctx, LED_AI7_1); break; case 3: led_on(&led_ctx, LED_AI7_1); break;
default: break; default: break;
} }
// 改动原因2档脚步增强开档(15dB)恢复全亮LED
if (flag_footsteps_enhancement == 1) led_on(&led_ctx, LED_FOOTSTEP_MODE); if (flag_footsteps_enhancement == 1) led_on(&led_ctx, LED_FOOTSTEP_MODE);
else if (flag_footsteps_enhancement == 2) led_set_brightness(&led_ctx, LED_FOOTSTEP_MODE, 128);
if (flag_aidenoise_onoff) led_on(&led_ctx, LED_ANC); if (flag_aidenoise_onoff) led_on(&led_ctx, LED_ANC);
led_update_all(&led_ctx); led_update_all(&led_ctx);
// 等待松键,防止重启后再次触发出厂恢复循环 // 等待松键,防止重启后再次触发出厂恢复循环
@@ -1650,10 +1651,10 @@ void button_task(chanend c_hidSendData, chanend cc_mic_level, chanend c_uac_vol,
{ {
if(push_button_footsteps_enhancement_state_old == 1) if(push_button_footsteps_enhancement_state_old == 1)
{ {
// 3档循环: 0(关/0dB) 1(中亮/6dB) → 2(高亮/12dB) → 0 // 改动原因2档循环: 0(关/0dB) 1(/15dB)
flag_footsteps_enhancement = (flag_footsteps_enhancement + 1) % 3; flag_footsteps_enhancement = (flag_footsteps_enhancement + 1) % 2;
mode_change = 1; mode_change = 1;
debug_printf("Footstep mode changed: %d -> %d\n", flag_footsteps_enhancement, flag_footsteps_enhancement + 1); debug_printf("Footstep mode changed to state=%d\n", flag_footsteps_enhancement);
} }
} }
push_button_footsteps_enhancement_state_old = button_footsteps_enhancement; push_button_footsteps_enhancement_state_old = button_footsteps_enhancement;
@@ -1661,18 +1662,13 @@ void button_task(chanend c_hidSendData, chanend cc_mic_level, chanend c_uac_vol,
{ {
if(flag_footsteps_enhancement == 0) if(flag_footsteps_enhancement == 0)
{ {
saved_footstep = 0; saved_footstep = 0; // 改动原因:关档 0dB
led_off(&led_ctx, LED_FOOTSTEP_MODE); led_off(&led_ctx, LED_FOOTSTEP_MODE);
} }
else if(flag_footsteps_enhancement == 1)
{
saved_footstep = 6;
led_on(&led_ctx, LED_FOOTSTEP_MODE);
}
else else
{ {
saved_footstep = 12; saved_footstep = 15; // 改动原因:开档 15dB唯一增强档
led_set_brightness(&led_ctx, LED_FOOTSTEP_MODE, 128); led_on(&led_ctx, LED_FOOTSTEP_MODE);
} }
led_update_all(&led_ctx); led_update_all(&led_ctx);
// 发送expand_gain到tile1执行 // 发送expand_gain到tile1执行
@@ -1690,30 +1686,29 @@ void button_task(chanend c_hidSendData, chanend cc_mic_level, chanend c_uac_vol,
GET_SHARED_GLOBAL(hid_gain_req, g_hid_expand_gain_request); GET_SHARED_GLOBAL(hid_gain_req, g_hid_expand_gain_request);
if (hid_gain_req != (unsigned)-1) { if (hid_gain_req != (unsigned)-1) {
SET_SHARED_GLOBAL(g_hid_expand_gain_request, (unsigned)-1); SET_SHARED_GLOBAL(g_hid_expand_gain_request, (unsigned)-1);
// 增益映射到footstep档位 // 改动原因HID增益映射到2档——0=关非0=开(15dB)
unsigned new_state; unsigned new_state;
unsigned char gain_to_save;
if (hid_gain_req == 0) { if (hid_gain_req == 0) {
new_state = 0; new_state = 0;
} else if (hid_gain_req <= 6) { gain_to_save = 0;
new_state = 1;
} else { } else {
new_state = 2; new_state = 1;
gain_to_save = 15;
} }
if (new_state != (unsigned)flag_footsteps_enhancement) { if (new_state != (unsigned)flag_footsteps_enhancement) {
flag_footsteps_enhancement = (int)new_state; flag_footsteps_enhancement = (int)new_state;
if (flag_footsteps_enhancement == 0) { if (flag_footsteps_enhancement == 0) {
led_off(&led_ctx, LED_FOOTSTEP_MODE); led_off(&led_ctx, LED_FOOTSTEP_MODE);
} else if (flag_footsteps_enhancement == 1) {
led_on(&led_ctx, LED_FOOTSTEP_MODE);
} else { } else {
led_set_brightness(&led_ctx, LED_FOOTSTEP_MODE, 128); led_on(&led_ctx, LED_FOOTSTEP_MODE);
} }
led_update_all(&led_ctx); led_update_all(&led_ctx);
} }
unsigned char fp[] = "footstep"; unsigned char fp[] = "footstep";
save_value(fp, (unsigned char)hid_gain_req); save_value(fp, gain_to_save);
saved_footstep = hid_gain_req; saved_footstep = gain_to_save;
debug_printf("HID set footstep gain=%d, state=%d\n", hid_gain_req, flag_footsteps_enhancement); debug_printf("HID set footstep gain=%d, state=%d\n", hid_gain_req, flag_footsteps_enhancement);
} }
} }

View File

@@ -53,7 +53,7 @@ static volatile int g_runtime_angle_written = 0;
// 通过该标志判断EX3D是否已完成初始化若已完成则在收到0xF9时立即应用角度。 // 通过该标志判断EX3D是否已完成初始化若已完成则在收到0xF9时立即应用角度。
static volatile int g_ex3d_init_done = 0; static volatile int g_ex3d_init_done = 0;
// audio_ex3d_init会覆盖Ex3dExpandGain为库默认值用此变量保存0xFD boot sync收到的值 // audio_ex3d_init会覆盖Ex3dExpandGain为库默认值用此变量保存0xFD boot sync收到的值
static volatile int32_t g_boot_footstep_expand_gain_value = 12; static volatile int32_t g_boot_footstep_expand_gain_value = 15; // 改动原因脚步增强默认15dB2档0/15
static volatile int32_t g_boot_lmt_threshold_value = -5; static volatile int32_t g_boot_lmt_threshold_value = -5;
static volatile uint32_t g_boot_angle_values[8] = {315, 45, 0, 0, 225, 135, 270, 90}; static volatile uint32_t g_boot_angle_values[8] = {315, 45, 0, 0, 225, 135, 270, 90};
@@ -1175,7 +1175,8 @@ void ex3d_task(){
} }
// audio_ex3d_init内部会将Ex3dExpandGain重置为库默认值(6),这里始终用保存值恢复 // audio_ex3d_init内部会将Ex3dExpandGain重置为库默认值(6),这里始终用保存值恢复
Ex3dExpandGain = g_boot_footstep_expand_gain_loaded ? g_boot_footstep_expand_gain_value : 12; // 改动原因无flash/boot同步时脚步增强默认15dB原12dB为旧3档高亮档
Ex3dExpandGain = g_boot_footstep_expand_gain_loaded ? g_boot_footstep_expand_gain_value : 15;
Ex3dLimiterThreshold = g_boot_lmt_threshold_loaded ? g_boot_lmt_threshold_value : -15; Ex3dLimiterThreshold = g_boot_lmt_threshold_loaded ? g_boot_lmt_threshold_value : -15;
EX3DAudio_SetOnGain(Ex3dOnGain); EX3DAudio_SetOnGain(Ex3dOnGain);