Files
player/Project/Src/MyWinApp/mywin_user_set.c
andy fed557e2e1 解决一些软件bug
1.make.py添加输出源文件的命令
2.解决找不到usart设备导致文件管理无法退出卡死的问题
3.解决点击关于本机卡死的问题
4.解决工具界面中文工具显示乱码的问题
2025-07-05 23:48:54 +08:00

232 lines
4.9 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "mywin_inc.h"
#include "mywin_user_menu.h"
#include "flash_manager.h"
#include "mywin_user_timeset.h"
#include "mywin_user_backlightset.h"
#include "mywin_user_sysfile.h"
#include "mywin_user_filder.h"
#include "mywin_user_time.h"
#include "mywin_user_light.h"
#include "mywin_user_theme.h"
#include "mywin_user_bluetooth.h"
#include "mywin_user_set.h"
#include "mywin_user_debug.h"
#include "dac.h"
#include "nrf.h"
const static MENU_ItemStruct ptr[]={
{0, "主题设置"},
{0, "时间和日期" } ,
{0, "背光设置" } ,
{0, "重置" } ,
{0, "关于本机" } ,
{0, "系统文件" } ,
{0, "文件管理" } ,
{0, "迷你音响"},
{0, "调试信息"}
};
//进入设置页面
WIN_MenuStruct *MENU_Setting (WIN_WindowStruct *base,WIN_PicStruct *pic)
{
WIN_MenuStruct *menu=WIN_CreatMenu (base,(void (*)(WIN_WindowStruct *,WIN_MsgStruct *))MENU_SettingMsgLoop,
0,0,base->x_size,base->y_size);
((WIN_WindowStruct *)menu)->intercept=1;//不发送按键消息到父窗口
WIN_SetBackPicPath ((WIN_WindowStruct *)menu,base->pic_path);
MENU_SetTitle (menu,0,"设置");
MENU_SetMaxItem(menu,9);
for (int i=0;i<9;i++)
{
MENU_AddItem (menu,ptr[i].img,(char *)ptr[i].txt);
}
WIN_ShowWindow((WIN_WindowStruct*)menu);
return menu;
}
//定义获取程序下载位置的变量
// #define APP_SOURCE (*(u32 *)(0x08020000+4*7))
// #define APP_APPNAME (*(char **)(0x08020000+4*8))
// #define APP_SIZE (*(u32 *)(0x08020000+4*9))
#define APP_SOURCE (*(u32 *)(0x08000000+4*7))
#define APP_APPNAME (*(char **)(0x08000000+4*8))
#define APP_SIZE (*(u32 *)(0x08000000+4*9))
static void enter_sound(WIN_WindowStruct *base);
static void MENU_DoEnter (WIN_MenuStruct *menu)
{
//选择了一个设置项
if (MENU_GetIndex(menu)==0) MENU_ThemeSet((WIN_WindowStruct *)menu);
else if (MENU_GetIndex(menu)==1) TIMEBOX_TimeSet ((WIN_WindowStruct *)menu);
else if (MENU_GetIndex(menu)==2) MENU_LightSet((WIN_WindowStruct *)menu);//BACKLIGHTSETBOX_BackLightSet ();
else if (MENU_GetIndex(menu)==3) {MSGBOX_Inquiry ((WIN_WindowStruct *)menu,"重置","再按一次确定键重置","确定","返回");}
else if (MENU_GetIndex(menu)==4)
{
char *txt=mymalloc (512);
if (APP_SOURCE)
{
sprintf (txt,"型号RC520\n软件版本1.11 Beta1\n编译:%s\n本程序通过IAP升级\n"
"程序名:%s\n程序大小:%d Byte"
,__DATE__ " " __TIME__,APP_APPNAME,APP_SIZE);
}
else
{
sprintf (txt,"型号RC520\n软件版本1.11 Beta1\n编译:%s\n本程序通过SWD下载"
,__DATE__ " " __TIME__);
}
MSGBOX_TipsTime ((WIN_WindowStruct*)menu,"关于", txt,"确定",5000);
myfree(txt);
}
else if (MENU_GetIndex(menu)==5) SYSFILE_ChooseFile((WIN_WindowStruct *)menu);
else if (MENU_GetIndex(menu)==6) FILDER_ChooseFile ((WIN_WindowStruct *)menu,"0:");
else if(MENU_GetIndex(menu)==7) enter_sound((WIN_WindowStruct *)menu);
else if(MENU_GetIndex(menu)==8) DEBUG_EnterPrint();
else MSGBOX_TipsTime ((WIN_WindowStruct*)menu,"提示",MENU_GetSelectItem(menu) ,"确定",5000);
}
//消息处理函数
void MENU_SettingMsgLoop (WIN_MenuStruct *menu,WIN_MsgStruct *msg)
{
WIN_MoveStruct *m=0;
WIN_TouchStruct *t=0;
WIN_KeyStruct *k=0;
switch (msg->msg)
{
case WIN_MSG_KEY:
k=msg->data.p;
if (k->shortPress&KEY_VALUE_ENTER)
{
MENU_DoEnter(menu);
}
else
{
MENU_DefaultMsgLoop (menu,msg);
}
break;//case WIN_MSG_KEY:
case WIN_MSG_MOVE:
m=msg->data.p;
switch (m->moveType)
{
case MOVE_DATA_SHORT:
// if (m->y_move>((WIN_WindowStruct *)menu)->y_size/2-20&&m->y_move<((WIN_WindowStruct *)menu)->y_size/2+20)
// {
// MENU_DoEnter(menu);
// }
break;
default:
MENU_DefaultMsgLoop (menu,msg);
break;
}
break;
case WIN_MSG_CHID:
switch (msg->data.v)
{
case CHID_DELETE:
break;
case CHID_USER:
{
if (msg->srcWin==menu->bar)
{
if (msg->data2.v==SCROLLBAR_PRESSED)
{
MENU_DoEnter(menu);
}
}
else
{
MENU_DefaultMsgLoop (menu,msg);
}
}
break;
default:
break;
}
break;
default:
MENU_DefaultMsgLoop (menu,msg);
break;
}
}
// 读取一个值返回0成功
static int recv_value(uint16_t *value)
{
uint8_t v1=0;
uint8_t v2=0;
if(nrf_read_byte(&v1)==NRF_OK&&nrf_read_byte(&v2)==NRF_OK)
{
*value=(v2<<8)|v1;
return 0;
}
else
{
nrf_clear();
return -1;
}
}
static int g_work=0;
static int cb_sound_fun(void *ptr)
{
DAC_FifolInit();
nrf_init();
nrf_set_no_respond(1);
g_work=1;
uint16_t value=0;
DAC_SetSetValuwFun(recv_value);
while(g_work)
{
// while(recv_value(&value)==0)
// {
// DAC_SaveValue(value);
// }
rt_thread_delay(5);
}
DAC_FifoDeInit();
nrf_deinit();
return 0;
}
static void cb_sound_bread(void *ptr)
{
g_work=0;
}
static void enter_sound(WIN_WindowStruct *base)
{
int ret=WORKING_DoWorkPro(base,"正在接收音频",cb_sound_fun,0,
cb_sound_bread,0,0,18);
}