添加开机延时

This commit is contained in:
flym 2025-12-30 16:44:42 +08:00
parent 8eef0ec399
commit 41ca46e68f
9 changed files with 14818 additions and 14805 deletions

View File

@ -2,8 +2,8 @@
#include "avctp_user.h" #include "avctp_user.h"
#include "key_event_deal.h" #include "key_event_deal.h"
#include "app_task.h" #include "app_task.h"
//#include "audio_eq.h" // #include "audio_eq.h"
//#include "media/audio_eq_drc_apply.h" // #include "media/audio_eq_drc_apply.h"
#include "audio_dec.h" #include "audio_dec.h"
typedef struct _kts_ typedef struct _kts_
@ -12,9 +12,9 @@ typedef struct _kts_
u32 t_cnt; // 上电标志 u32 t_cnt; // 上电标志
u8 led_flag; u8 led_flag;
// u8 conn_flag; // u8 conn_flag;
u8 volume; // 0-30 u8 volume; // 0-30
s8 treble; // -12-12 s8 treble; // -12-12
s8 bass; // -12-12 s8 bass; // -12-12
} _kts; } _kts;
static _kts kts_var; static _kts kts_var;
@ -27,19 +27,19 @@ void kt_boot_init(void)
gpio_set_direction(KTCFG_BASS_AD_PIN, 1); gpio_set_direction(KTCFG_BASS_AD_PIN, 1);
gpio_set_pull_up(KTCFG_BASS_AD_PIN, 0); gpio_set_pull_up(KTCFG_BASS_AD_PIN, 0);
gpio_set_pull_down(KTCFG_BASS_AD_PIN, 0); gpio_set_pull_down(KTCFG_BASS_AD_PIN, 0);
adc_add_sample_ch(KTCFG_TREBLE_AD_CHANNEL); adc_add_sample_ch(KTCFG_TREBLE_AD_CHANNEL);
gpio_set_die(KTCFG_TREBLE_AD_PIN, 0); gpio_set_die(KTCFG_TREBLE_AD_PIN, 0);
gpio_set_direction(KTCFG_TREBLE_AD_PIN, 1); gpio_set_direction(KTCFG_TREBLE_AD_PIN, 1);
gpio_set_pull_up(KTCFG_TREBLE_AD_PIN, 0); gpio_set_pull_up(KTCFG_TREBLE_AD_PIN, 0);
gpio_set_pull_down(KTCFG_TREBLE_AD_PIN, 0); gpio_set_pull_down(KTCFG_TREBLE_AD_PIN, 0);
adc_add_sample_ch(KTCFG_VOLUME_AD_CHANNEL); adc_add_sample_ch(KTCFG_VOLUME_AD_CHANNEL);
gpio_set_die(KTCFG_VOLUME_AD_PIN, 0); gpio_set_die(KTCFG_VOLUME_AD_PIN, 0);
gpio_set_direction(KTCFG_VOLUME_AD_PIN, 1); gpio_set_direction(KTCFG_VOLUME_AD_PIN, 1);
gpio_set_pull_up(KTCFG_VOLUME_AD_PIN, 0); gpio_set_pull_up(KTCFG_VOLUME_AD_PIN, 0);
gpio_set_pull_down(KTCFG_VOLUME_AD_PIN, 0); gpio_set_pull_down(KTCFG_VOLUME_AD_PIN, 0);
gpio_set_pull_up(KTCFG_PA_MUTE_PIN, 0); gpio_set_pull_up(KTCFG_PA_MUTE_PIN, 0);
gpio_set_pull_down(KTCFG_PA_MUTE_PIN, 0); gpio_set_pull_down(KTCFG_PA_MUTE_PIN, 0);
gpio_set_direction(KTCFG_PA_MUTE_PIN, 0); gpio_set_direction(KTCFG_PA_MUTE_PIN, 0);
@ -67,7 +67,7 @@ void kt_boot_init(void)
static void led_tim_callback(void) static void led_tim_callback(void)
{ {
app_task_put_key_msg(KEY_USER_CHECK_AD, 0); app_task_put_key_msg(KEY_USER_CHECK_AD, 0);
if (app_get_curr_task() == APP_BT_TASK) if (app_get_curr_task() == APP_BT_TASK)
{ {
@ -133,7 +133,6 @@ static void start_timer(void)
__this->timer = sys_timer_add(NULL, led_tim_callback, 100); __this->timer = sys_timer_add(NULL, led_tim_callback, 100);
} }
void user_eq_tre(int freq, int gain) void user_eq_tre(int freq, int gain)
{ {
struct high_bass parm = {0}; struct high_bass parm = {0};
@ -152,11 +151,20 @@ void user_eq_bass(int freq, int gain)
mix_out_high_bass(AUDIO_EQ_BASS, &parm); mix_out_high_bass(AUDIO_EQ_BASS, &parm);
} }
void kt_init(void) void kt_init(void)
{ {
u32 delay_10ms_cnt = 0;
PA_MUTE();
while (1)
{
clr_wdt();
os_time_dly(2);
delay_10ms_cnt++;
if (delay_10ms_cnt > 40)
{
break;
}
}
__this->bass = (adc_get_value(KTCFG_BASS_AD_CHANNEL) * 24 / 1023) - 12; __this->bass = (adc_get_value(KTCFG_BASS_AD_CHANNEL) * 24 / 1023) - 12;
user_eq_bass(0, __this->bass); user_eq_bass(0, __this->bass);
__this->treble = (adc_get_value(KTCFG_TREBLE_AD_CHANNEL) * 24 / 1023) - 12; __this->treble = (adc_get_value(KTCFG_TREBLE_AD_CHANNEL) * 24 / 1023) - 12;
@ -179,12 +187,12 @@ u8 kt_key_event_filter_after(int key_event)
switch (key_event) switch (key_event)
{ {
case KEY_USER_CHECK_AD: case KEY_USER_CHECK_AD:
//led_tim_callback(); // led_tim_callback();
//printf("KEY_USER_CHECK_AD\n"); // printf("KEY_USER_CHECK_AD\n");
{ {
//u32 val = adc_get_value(KTCFG_VOLUME_AD_CHANNEL); // 0-1023 // u32 val = adc_get_value(KTCFG_VOLUME_AD_CHANNEL); // 0-1023
s8 vol = (adc_get_value(KTCFG_VOLUME_AD_CHANNEL) * 30 / 1023); s8 vol = (adc_get_value(KTCFG_VOLUME_AD_CHANNEL) * 30 / 1023);
if (vol != __this->volume) if (vol != __this->volume)
{ {
printf("volume: %d\n", vol); printf("volume: %d\n", vol);
@ -192,10 +200,9 @@ u8 kt_key_event_filter_after(int key_event)
app_audio_set_volume(APP_AUDIO_STATE_MUSIC, __this->volume, 1); app_audio_set_volume(APP_AUDIO_STATE_MUSIC, __this->volume, 1);
} }
// 读取BASS AD值并转换为-12到12的范围 // 读取BASS AD值并转换为-12到12的范围
s8 bass = (adc_get_value(KTCFG_BASS_AD_CHANNEL) * 24 / 1023) - 12; s8 bass = (adc_get_value(KTCFG_BASS_AD_CHANNEL) * 24 / 1023) - 12;
if (bass != __this->bass) if (bass != __this->bass)
{ {
printf("bass: %d\n", bass); printf("bass: %d\n", bass);
@ -205,7 +212,7 @@ u8 kt_key_event_filter_after(int key_event)
// 读取TREBLE AD值并转换为-12到12的范围 // 读取TREBLE AD值并转换为-12到12的范围
s8 treble = (adc_get_value(KTCFG_TREBLE_AD_CHANNEL) * 24 / 1023) - 12; s8 treble = (adc_get_value(KTCFG_TREBLE_AD_CHANNEL) * 24 / 1023) - 12;
if (treble != __this->treble) if (treble != __this->treble)
{ {
printf("treble: %d\n", treble); printf("treble: %d\n", treble);
@ -215,9 +222,9 @@ u8 kt_key_event_filter_after(int key_event)
} }
ret = true; ret = true;
} }
//printf("bass_ad_value: %d\n", adc_get_value(KTCFG_BASS_AD_CHANNEL)); // printf("bass_ad_value: %d\n", adc_get_value(KTCFG_BASS_AD_CHANNEL));
//printf("treble_ad_value: %d\n", adc_get_value(KTCFG_TREBLE_AD_CHANNEL)); // printf("treble_ad_value: %d\n", adc_get_value(KTCFG_TREBLE_AD_CHANNEL));
//printf("volume_ad_value: %d\n", adc_get_value(KTCFG_VOLUME_AD_CHANNEL)); // printf("volume_ad_value: %d\n", adc_get_value(KTCFG_VOLUME_AD_CHANNEL));
break; break;
case KEY_MUSIC_PP: case KEY_MUSIC_PP:
bled_set(); bled_set();

Binary file not shown.

View File

@ -1867,6 +1867,8 @@ objs/apps/kaotings/kt.c.o
-r=objs/apps/kaotings/kt.c.o,mix_out_high_bass,l -r=objs/apps/kaotings/kt.c.o,mix_out_high_bass,l
-r=objs/apps/kaotings/kt.c.o,user_eq_bass,pl -r=objs/apps/kaotings/kt.c.o,user_eq_bass,pl
-r=objs/apps/kaotings/kt.c.o,kt_init,pl -r=objs/apps/kaotings/kt.c.o,kt_init,pl
-r=objs/apps/kaotings/kt.c.o,clr_wdt,l
-r=objs/apps/kaotings/kt.c.o,os_time_dly,l
-r=objs/apps/kaotings/kt.c.o,adc_get_value,l -r=objs/apps/kaotings/kt.c.o,adc_get_value,l
-r=objs/apps/kaotings/kt.c.o,app_audio_set_volume,l -r=objs/apps/kaotings/kt.c.o,app_audio_set_volume,l
-r=objs/apps/kaotings/kt.c.o,bled_set,pl -r=objs/apps/kaotings/kt.c.o,bled_set,pl

File diff suppressed because it is too large Load Diff