153 lines
3.4 KiB
C
153 lines
3.4 KiB
C
#include "include.h"
|
||
#include "func.h"
|
||
#include "m_sportInfo.h"
|
||
#include "api.h"
|
||
#include "ancs_msg.h"
|
||
#include "m_storage.h"
|
||
#include "app_variable.h"
|
||
#include "m_remind.h"
|
||
#if TRACE_EN
|
||
#define TRACE(...) printf(__VA_ARGS__)
|
||
#else
|
||
#define TRACE(...)
|
||
#endif
|
||
#define APP_AUDIO_STATE_WTONE 3
|
||
typedef struct f_ringtest_t_ {
|
||
u32 enter_tick;
|
||
} f_ringtest_t;
|
||
|
||
enum {
|
||
COMPO_ID_BTN_LEF = 1,
|
||
COMPO_ID_BTN_CEN,
|
||
COMPO_ID_BTN_RIG,
|
||
};
|
||
|
||
static int color_index = 0;
|
||
|
||
/* 工厂模式声音测试运行状态:true正在运行,false未在运行 */
|
||
static bool ring_test_run_state = false;
|
||
static void func_ring_test_run_state_set(bool state)
|
||
{
|
||
ring_test_run_state = state;
|
||
}
|
||
|
||
static bool func_ring_test_run_state_get(void)
|
||
{
|
||
return ring_test_run_state;
|
||
}
|
||
|
||
compo_form_t *func_ringtest_form_create(void)
|
||
{
|
||
compo_form_t *frm = compo_form_create(true);
|
||
|
||
compo_textbox_t *txt_off = compo_textbox_create(frm, 110);
|
||
compo_textbox_set_align_center(txt_off, false);
|
||
compo_textbox_set_pos(txt_off, GUI_SCREEN_CENTER_X-60, GUI_SCREEN_CENTER_Y);
|
||
compo_textbox_set(txt_off, "Ringtone test");
|
||
// compo_textbox_set_autoroll_mode(txt_off, TEXT_AUTOROLL_MODE_SROLL);
|
||
return frm;
|
||
}
|
||
|
||
static void ring_play_check(void)
|
||
{
|
||
if (!tone_get_status()) {
|
||
tone_play_test();
|
||
}
|
||
|
||
}
|
||
|
||
static void func_ringtest_process(void)
|
||
{
|
||
func_process();
|
||
}
|
||
|
||
static void func_ringtest_message(size_msg_t msg)
|
||
{
|
||
/* 检测窗体是否被外部改变,只允许用户主动改变退出 */
|
||
if (func_cb.sta != FUNC_SUB_RING) {
|
||
func_cb.sta = FUNC_SUB_RING;
|
||
}
|
||
|
||
switch (msg) {
|
||
case MSG_CTP_CLICK:
|
||
break;
|
||
case MSG_CTP_SHORT_UP:
|
||
break;
|
||
|
||
case MSG_CTP_SHORT_DOWN:
|
||
break;
|
||
|
||
case MSG_CTP_LONG:
|
||
break;
|
||
|
||
case KEY_RIGHT:
|
||
break;
|
||
case KEY_LEFT:
|
||
break;
|
||
case KEY_BACK:
|
||
break;
|
||
|
||
case MSG_CTP_SHORT_RIGHT:
|
||
func_message(msg);
|
||
|
||
/* 右滑退出厂测模式 */
|
||
if (func_cb.sta == FUNC_FACTORY_TEST) {
|
||
func_ring_test_run_state_set(false);
|
||
}
|
||
break;
|
||
|
||
default:
|
||
func_message(msg);
|
||
break;
|
||
}
|
||
}
|
||
|
||
AT(.text.func.btring)
|
||
static void bsp_bt_ring_res_play(u32 addr, u32 len)
|
||
{
|
||
printf("%s: addr: %x, len: %x\n", __func__, addr, len);
|
||
|
||
dac_set_anl_offset(0);
|
||
bt_audio_bypass();
|
||
music_control(MUSIC_MSG_STOP);
|
||
bsp_change_volume(WARNING_VOLUME);
|
||
|
||
if(judge_disturd()== true)
|
||
return;
|
||
if (len == 0) {
|
||
return;
|
||
}
|
||
if (sys_cb.mute) {
|
||
bsp_loudspeaker_unmute();
|
||
delay_5ms(6);
|
||
}
|
||
mp3_res_play_kick(addr, len);
|
||
}
|
||
static void func_ringtest_enter(void)
|
||
{
|
||
func_cb.f_cb = func_zalloc(sizeof(f_ringtest_t));
|
||
func_cb.frm_main = func_ringtest_form_create();
|
||
func_cb.mp3_res_play = func_bt_mp3_res_play;
|
||
bsp_bt_ring_res_play(RES_BUF_RING_RING_MP3, RES_LEN_RING_RING_MP3);
|
||
}
|
||
|
||
static void func_ringtest_exit(void)
|
||
{
|
||
func_cb.last = FUNC_SUB_RING;
|
||
}
|
||
|
||
void func_ringtest(void)
|
||
{
|
||
printf("%s\n", __func__);
|
||
func_ringtest_enter();
|
||
|
||
/* 厂测过程除用户主动退出外 不响应外部窗体切换 */
|
||
func_ring_test_run_state_set(true);
|
||
|
||
while (func_ring_test_run_state_get()) {
|
||
func_ringtest_process();
|
||
func_ringtest_message(msg_dequeue());
|
||
}
|
||
func_ringtest_exit();
|
||
}
|