2025-06-27 00:32:57 +08:00
|
|
|
|
#include "main.h"
|
|
|
|
|
|
#include "rtthread.h"
|
|
|
|
|
|
#include "mywin_demo.h"
|
|
|
|
|
|
#include "date.h"
|
|
|
|
|
|
#include "mywin_user_lock.h"
|
|
|
|
|
|
#include "nrf.h"
|
|
|
|
|
|
#include "bsp_init.h"
|
|
|
|
|
|
#include "stdlib.h"
|
|
|
|
|
|
|
|
|
|
|
|
volatile int32_t ITM_RxBuffer=ITM_RXBUFFER_EMPTY;
|
|
|
|
|
|
|
|
|
|
|
|
static void Touch_Task (void *p_arg);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//ʹ<><CAB9>RTThread
|
2025-06-27 00:32:57 +08:00
|
|
|
|
|
|
|
|
|
|
void my_delay_ms(u32 ms)
|
|
|
|
|
|
{
|
|
|
|
|
|
rt_thread_delay (ms);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main (void)
|
|
|
|
|
|
{
|
|
|
|
|
|
RTC_InitStruct rtc_init={0};
|
|
|
|
|
|
rtc_init.delay_ms=my_delay_ms;
|
|
|
|
|
|
RTC_InitNormal (&rtc_init);
|
|
|
|
|
|
bsp_init_all();
|
|
|
|
|
|
|
|
|
|
|
|
u8 ret=0;
|
2025-07-05 19:47:28 +08:00
|
|
|
|
static FATFS SD_FatFs; // <20>ļ<EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
ret=f_mount(&SD_FatFs,"0:",1);
|
|
|
|
|
|
|
|
|
|
|
|
SysFile_SetFileInit ();
|
|
|
|
|
|
|
|
|
|
|
|
void test_init(void);
|
|
|
|
|
|
test_init();
|
|
|
|
|
|
|
|
|
|
|
|
ALIGN(RT_ALIGN_SIZE)
|
|
|
|
|
|
static rt_uint8_t rt_gui_tack[40*1024]={0};
|
|
|
|
|
|
static struct rt_thread rt_gui_thread={0};
|
|
|
|
|
|
rt_thread_init (&rt_gui_thread,"gui_task",mywin_demo_test,0,rt_gui_tack,sizeof (rt_gui_tack),20,20);
|
|
|
|
|
|
rt_thread_startup(&rt_gui_thread);
|
|
|
|
|
|
|
|
|
|
|
|
ALIGN(RT_ALIGN_SIZE)
|
|
|
|
|
|
static rt_uint8_t rt_scan_tack[1024]={0};
|
|
|
|
|
|
static struct rt_thread rt_scan_thread={0};
|
|
|
|
|
|
rt_thread_init (&rt_scan_thread,"scan_task",Touch_Task,0,rt_scan_tack,sizeof (rt_scan_tack),2,20);
|
|
|
|
|
|
rt_thread_startup(&rt_scan_thread);
|
|
|
|
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
|
|
{
|
2025-06-29 23:48:38 +08:00
|
|
|
|
LED2_ON;
|
|
|
|
|
|
my_delay_ms (500);
|
|
|
|
|
|
LED2_OFF;
|
|
|
|
|
|
my_delay_ms (500);
|
2025-06-27 00:32:57 +08:00
|
|
|
|
if (SysFile_CheckAlarm()==1)
|
|
|
|
|
|
{
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>䵽<EFBFBD><E4B5BD><EFBFBD><EFBFBD>Ϣ
|
2025-06-27 00:32:57 +08:00
|
|
|
|
SysFile_StructType alarm;
|
|
|
|
|
|
alarm.structType=SYSFILE_TYPE_ALARM;
|
|
|
|
|
|
WIN_PlaceExtData (&alarm,sizeof (SysFile_StructType));
|
|
|
|
|
|
}
|
|
|
|
|
|
// printf ("memused:%.1f,%.1f,%.1f\r\n",mem_perused()/100.0,exmem_perused()/100.0,ccm_perused()/100.0);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void creat_lock(void *ptr)
|
|
|
|
|
|
{
|
|
|
|
|
|
WIN_WindowStruct *win=WIN_GetCurrentWindow();
|
|
|
|
|
|
LOCK_EnterLock("0:/PIC/3.pic");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define SEND_RIGHT 0x80
|
|
|
|
|
|
#define SEND_LEFT 0x40
|
|
|
|
|
|
#define SEND_DOWN 0x20
|
|
|
|
|
|
#define SEND_UP 0x10
|
|
|
|
|
|
#define SEND_START 0x08
|
|
|
|
|
|
#define SEND_SELECT 0x04
|
|
|
|
|
|
#define SEND_B 0x02
|
|
|
|
|
|
#define SEND_A 0x01
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//<2F><><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>ֵת<D6B5><D7AA>ΪMYWIN<49>ļ<EFBFBD>ֵ
|
2025-06-27 00:32:57 +08:00
|
|
|
|
const int keyTranslatTable[]=
|
|
|
|
|
|
{
|
|
|
|
|
|
SEND_UP,
|
|
|
|
|
|
KEY_VALUE_UP,
|
|
|
|
|
|
SEND_DOWN,
|
|
|
|
|
|
KEY_VALUE_DOWN,
|
|
|
|
|
|
SEND_SELECT,
|
|
|
|
|
|
KEY_VALUE_ENTER,
|
|
|
|
|
|
SEND_START,
|
|
|
|
|
|
KEY_VALUE_HOME,
|
|
|
|
|
|
SEND_B,
|
|
|
|
|
|
KEY_VALUE_DES,
|
|
|
|
|
|
SEND_A,
|
|
|
|
|
|
KEY_VALUE_LIGHT,
|
|
|
|
|
|
SEND_LEFT,
|
|
|
|
|
|
KEY_VALUE_LEFT,
|
|
|
|
|
|
SEND_RIGHT,
|
|
|
|
|
|
KEY_VALUE_RIGHT,
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int getKeyMyWin (WIN_KeyStruct *k)
|
|
|
|
|
|
{
|
|
|
|
|
|
u8 key=0;
|
|
|
|
|
|
int mywin_key=0;
|
|
|
|
|
|
static int mywin_key_old=0;
|
|
|
|
|
|
key=USART3_GetKey();
|
|
|
|
|
|
for (int i=0;i<8;i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (key&keyTranslatTable[i*2])
|
|
|
|
|
|
mywin_key|=keyTranslatTable[i*2+1];
|
|
|
|
|
|
}
|
|
|
|
|
|
if (mywin_key)
|
|
|
|
|
|
{
|
|
|
|
|
|
k->state=1;
|
|
|
|
|
|
k->key=mywin_key;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
k->key=mywin_key_old;
|
|
|
|
|
|
k->state=0;
|
|
|
|
|
|
}
|
|
|
|
|
|
mywin_key_old=mywin_key;
|
|
|
|
|
|
return key;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void Touch_Task (void *p_arg)
|
|
|
|
|
|
{
|
|
|
|
|
|
(void)p_arg;
|
|
|
|
|
|
u8 key=0;
|
|
|
|
|
|
u8 key_state=0;
|
|
|
|
|
|
WIN_TouchStruct t={0};
|
|
|
|
|
|
WIN_KeyStruct k={0};
|
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Ϊ5<CEAA><35>
|
2025-06-29 11:53:35 +08:00
|
|
|
|
SysFile_GetSysFile()->screenOffTime=0;
|
2025-06-27 00:32:57 +08:00
|
|
|
|
|
|
|
|
|
|
int screen_off_timer=0;
|
|
|
|
|
|
int key_shield_timer=0;
|
|
|
|
|
|
int key_press=0;
|
|
|
|
|
|
while(1)
|
|
|
|
|
|
{
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD><EFBFBD><EFBFBD>״̬
|
2025-06-27 00:32:57 +08:00
|
|
|
|
Touch_Scan();
|
|
|
|
|
|
t.pressNum=Touch_GetState()->flag;
|
|
|
|
|
|
if (getKeyMyWin(&k)||t.pressNum)
|
|
|
|
|
|
{
|
|
|
|
|
|
screen_off_timer=0;ui_setScreenBackLightPower(1);
|
|
|
|
|
|
key_press=1;
|
|
|
|
|
|
}
|
|
|
|
|
|
else key_press=0;
|
|
|
|
|
|
if (t.pressNum)
|
|
|
|
|
|
{
|
|
|
|
|
|
t.x[0]=Touch_GetState()->x[0];
|
|
|
|
|
|
t.y[0]=Touch_GetState()->y[0];
|
|
|
|
|
|
LED1_ON;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
LED1_OFF;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//<2F><><EFBFBD>Ͱ<EFBFBD><CDB0><EFBFBD><EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>GUI
|
2025-06-27 00:32:57 +08:00
|
|
|
|
if (key_shield_timer==0)
|
|
|
|
|
|
{
|
|
|
|
|
|
WIN_StorKeyStruct (&k);
|
|
|
|
|
|
WIN_StorTouchStruct (&t);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//<2F>Զ<EFBFBD>Ϩ<EFBFBD><CFA8><EFBFBD><EFBFBD>ʱ
|
2025-06-27 00:32:57 +08:00
|
|
|
|
my_delay_ms (20);
|
|
|
|
|
|
if (SysFile_GetSysFile()->screenOffTime&&(SysFile_GetSysFile()->screenOffTime*1000<screen_off_timer))
|
|
|
|
|
|
{
|
|
|
|
|
|
ui_setScreenBackLightPower(0);
|
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
// ֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD><EFBFBD>̵߳<DFB3><CCB5>ú<EFBFBD><C3BA><EFBFBD>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
// WIN_RunInWindow("home",creat_lock,0);
|
|
|
|
|
|
key_shield_timer=1;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//<2F>ڹ<EFBFBD><DAB9><EFBFBD>300ms<6D><73><EFBFBD>Ұ<EFBFBD><D2B0><EFBFBD><EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD>û<EFBFBD>а<EFBFBD><D0B0><EFBFBD>ʱȡ<CAB1><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
screen_off_timer+=20;
|
|
|
|
|
|
if ((screen_off_timer>300)&&key_press==0)
|
|
|
|
|
|
{
|
|
|
|
|
|
key_shield_timer=0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
/*--C<><43><EFBFBD>Կ⺯<D4BF><E2BAAF>--*/
|
2025-06-27 00:32:57 +08:00
|
|
|
|
|
|
|
|
|
|
void exit(int err)
|
|
|
|
|
|
{
|
|
|
|
|
|
while(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int system(const char *cmd)
|
|
|
|
|
|
{
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|