164 lines
4.5 KiB
C
164 lines
4.5 KiB
C
#include "include.h"
|
|
#include "func.h"
|
|
#include "app_variable.h"
|
|
|
|
#if TRACE_EN
|
|
#define TRACE(...) printf(__VA_ARGS__)
|
|
#else
|
|
#define TRACE(...)
|
|
#endif
|
|
|
|
extern bool is_play_music_before_protocol_msg_flag;
|
|
|
|
typedef struct f_find_device_t_ {
|
|
u32 enter_tick;
|
|
} f_find_device_t;
|
|
|
|
//创建logo窗体
|
|
compo_form_t *func_find_device_form_create(void)
|
|
{
|
|
//新建窗体
|
|
compo_form_t *frm = compo_form_create(true);
|
|
//创建按键
|
|
compo_picturebox_t *pic = compo_picturebox_create(frm, UI_BUF_FIND_WEATCH_BIN);
|
|
compo_picturebox_set_pos(pic, 120, 140);
|
|
|
|
//创建文本
|
|
compo_textbox_t *txt = compo_textbox_create(frm, 110);
|
|
// compo_textbox_set_align_center(txt, true);
|
|
compo_textbox_set_multiline(txt, true);
|
|
compo_textbox_set_location(txt, 120, 226 +20,GUI_SCREEN_WIDTH - 20,60);
|
|
compo_textbox_set_autosize(txt, false);
|
|
compo_textbox_set(txt, i18n[STR_FIND_DEVICE]);
|
|
compo_textbox_set_autoroll_mode(txt, TEXT_AUTOROLL_MODE_SROLL);
|
|
return frm;
|
|
}
|
|
|
|
|
|
static void func_find_device_animation(void)
|
|
{
|
|
|
|
if(tick_check_expire(func_cb.enter_tick,5000)) {
|
|
//为规避 在二维码界面播放音乐铃声退回到二维码界面时会有刺耳的噪音,改成直接回到表盘
|
|
if(func_cb.last == FUNC_SCAN)
|
|
{
|
|
func_switch_to_clock();
|
|
}
|
|
else{
|
|
func_back_to();
|
|
}
|
|
}
|
|
}
|
|
|
|
//logo事件处理
|
|
static void func_find_device_process(void)
|
|
{
|
|
func_find_device_animation();
|
|
func_process();
|
|
// if(get_mp3_res_sta() == 0)
|
|
// {
|
|
// func_cb.mp3_res_play = func_bt_mp3_res_play;
|
|
// func_mp3_res_play(RES_BUF_RING_RING_MP3, RES_LEN_RING_RING_MP3);
|
|
// }
|
|
|
|
}
|
|
|
|
//logo消息处理
|
|
static void func_find_device_message(size_msg_t msg)
|
|
{
|
|
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 MSG_CTP_SHORT_RIGHT:
|
|
case KU_BACK:
|
|
//为规避 在二维码界面播放音乐铃声退回到二维码界面时会有刺耳的噪音,改成直接回到表盘
|
|
if(func_cb.last == FUNC_SCAN)
|
|
{
|
|
func_switch_to_clock();
|
|
}
|
|
else{
|
|
func_back_to();
|
|
}
|
|
break;
|
|
default:
|
|
func_message(msg);
|
|
break;
|
|
}
|
|
}
|
|
|
|
//进入logo
|
|
static void func_find_device_enter(void)
|
|
{
|
|
func_cb.f_cb = func_zalloc(sizeof(f_find_device_t));
|
|
func_cb.frm_main = func_find_device_form_create();
|
|
func_cb.enter_tick = tick_get();
|
|
sys_cb.motor_flag = 1;
|
|
set_func_motor(80,5,5,5);
|
|
|
|
// //判断当前苹果手机未唤出语音助手
|
|
if (!bt_get_siri_status())
|
|
{
|
|
func_cb.mp3_res_play = func_bt_mp3_res_play;
|
|
// // f_fac_det.vol_temp = SysVariable.vol;
|
|
// // SysVariable.vol = VOL_MAX;
|
|
// // bsp_change_volume(SysVariable.vol);
|
|
|
|
// mp3_res_play_do();
|
|
func_mp3_res_play(RES_BUF_RING_RING_MP3, RES_LEN_RING_RING_MP3);
|
|
}
|
|
}
|
|
|
|
//退出logo
|
|
static void func_find_device_exit(void)
|
|
{
|
|
printf("%s\n", __func__);
|
|
printf("is_play_music_before_protocol_msg_flag: %d\n", is_play_music_before_protocol_msg_flag);
|
|
|
|
if(get_mp3_res_sta())
|
|
{
|
|
music_control(MUSIC_MSG_STOP);
|
|
}
|
|
// 如果在查找设备前播放了音乐,并进行了暂停,则在查找设备结束后,恢复音乐播放
|
|
if (is_play_music_before_protocol_msg_flag == TRUE)
|
|
{
|
|
is_play_music_before_protocol_msg_flag = FALSE;
|
|
|
|
if (!bt_cb.music_playing)
|
|
{
|
|
if (bt_is_connected()) {
|
|
bt_music_play_pause();
|
|
bt_cb.music_playing = bt_cb.music_playing ? 0 : 1;
|
|
} else if (ble_ams_is_connected()) {
|
|
ble_ams_remote_ctrl(AMS_REMOTE_CMD_PLAY_PAUSE);
|
|
bt_cb.music_playing = bt_cb.music_playing ? 0 : 1;
|
|
}
|
|
}
|
|
}
|
|
|
|
bsp_motor_stop(MOTOR_PORT);
|
|
|
|
/* 查找设备退出后将不在存于历史(意味着设备已被发现),避免被其他打断再次返回查找界面 */
|
|
task_stack_del(task_stack_find(FUNC_FIND_DEVICE));
|
|
}
|
|
|
|
//logo
|
|
void func_find_device(void)
|
|
{
|
|
printf("%s\n", __func__);
|
|
func_find_device_enter();
|
|
while (func_cb.sta == FUNC_FIND_DEVICE) {
|
|
func_find_device_process();
|
|
func_find_device_message(msg_dequeue());
|
|
}
|
|
func_find_device_exit();
|
|
}
|