2025-10-18 13:58:40 +08:00
|
|
|
|
#include "bsp_init.h"
|
2025-06-27 00:32:57 +08:00
|
|
|
|
#include "date.h"
|
2025-10-18 13:58:40 +08:00
|
|
|
|
#include "main.h"
|
|
|
|
|
|
#include "mywin_demo.h"
|
2025-06-27 00:32:57 +08:00
|
|
|
|
#include "mywin_user_lock.h"
|
2025-10-18 13:58:40 +08:00
|
|
|
|
#include "nrf.h"
|
|
|
|
|
|
#include "rtthread.h"
|
2025-06-27 00:32:57 +08:00
|
|
|
|
#include "stdlib.h"
|
|
|
|
|
|
|
2025-10-18 13:58:40 +08:00
|
|
|
|
volatile int32_t ITM_RxBuffer = ITM_RXBUFFER_EMPTY;
|
2025-06-27 00:32:57 +08:00
|
|
|
|
|
2025-10-18 13:58:40 +08:00
|
|
|
|
static void Touch_Task(void *p_arg);
|
2025-06-27 00:32:57 +08:00
|
|
|
|
|
2025-10-18 13:58:40 +08:00
|
|
|
|
// ʹ<><CAB9>RTThread
|
2025-06-27 00:32:57 +08:00
|
|
|
|
|
2025-10-18 13:58:40 +08:00
|
|
|
|
void my_delay_ms(uint32_t ms) { rt_thread_delay(ms); }
|
2025-06-27 00:32:57 +08:00
|
|
|
|
|
2025-10-18 13:58:40 +08:00
|
|
|
|
int main(void) {
|
|
|
|
|
|
RTC_InitStruct rtc_init = {0};
|
|
|
|
|
|
rtc_init.delay_ms = my_delay_ms;
|
|
|
|
|
|
RTC_InitNormal(&rtc_init);
|
|
|
|
|
|
bsp_init_all();
|
2025-06-27 00:32:57 +08:00
|
|
|
|
|
2025-10-18 13:58:40 +08:00
|
|
|
|
uint8_t ret = 0;
|
|
|
|
|
|
static FATFS SD_FatFs; // <20>ļ<EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD>
|
|
|
|
|
|
ret = f_mount(&SD_FatFs, "0:", 1);
|
2025-06-27 00:32:57 +08:00
|
|
|
|
|
2025-10-18 13:58:40 +08:00
|
|
|
|
SysFile_SetFileInit();
|
2025-06-27 00:32:57 +08:00
|
|
|
|
|
|
|
|
|
|
void test_init(void);
|
|
|
|
|
|
test_init();
|
|
|
|
|
|
|
2025-10-18 13:58:40 +08:00
|
|
|
|
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) {
|
|
|
|
|
|
LED2_ON;
|
|
|
|
|
|
my_delay_ms(500);
|
|
|
|
|
|
LED2_OFF;
|
|
|
|
|
|
my_delay_ms(500);
|
|
|
|
|
|
if (SysFile_CheckAlarm() == 1) {
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>䵽<EFBFBD><E4B5BD><EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
|
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);
|
|
|
|
|
|
}
|
2025-06-27 00:32:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-18 13:58:40 +08:00
|
|
|
|
static void creat_lock(void *ptr) {
|
|
|
|
|
|
WIN_WindowStruct *win = WIN_GetCurrentWindow();
|
|
|
|
|
|
LOCK_EnterLock("0:/PIC/3.pic");
|
|
|
|
|
|
}
|
2025-06-27 00:32:57 +08:00
|
|
|
|
|
2025-10-18 13:58:40 +08:00
|
|
|
|
#define SEND_RIGHT 0x80
|
|
|
|
|
|
#define SEND_LEFT 0x40
|
|
|
|
|
|
#define SEND_DOWN 0x20
|
|
|
|
|
|
#define SEND_UP 0x10
|
|
|
|
|
|
#define SEND_START 0x08
|
2025-06-27 00:32:57 +08:00
|
|
|
|
#define SEND_SELECT 0x04
|
2025-10-18 13:58:40 +08:00
|
|
|
|
#define SEND_B 0x02
|
|
|
|
|
|
#define SEND_A 0x01
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>ֵת<D6B5><D7AA>ΪMYWIN<49>ļ<EFBFBD>ֵ
|
|
|
|
|
|
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,
|
2025-06-27 00:32:57 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
2025-10-18 13:58:40 +08:00
|
|
|
|
int getKeyMyWin(WIN_KeyStruct *k) {
|
|
|
|
|
|
uint8_t 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;
|
2025-06-27 00:32:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-18 13:58:40 +08:00
|
|
|
|
static void Touch_Task(void *p_arg) {
|
|
|
|
|
|
(void)p_arg;
|
|
|
|
|
|
uint8_t key = 0;
|
|
|
|
|
|
uint8_t key_state = 0;
|
|
|
|
|
|
WIN_TouchStruct t = {0};
|
|
|
|
|
|
WIN_KeyStruct k = {0};
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Ϊ5<CEAA><35>
|
|
|
|
|
|
SysFile_GetSysFile()->screenOffTime = 0;
|
|
|
|
|
|
|
|
|
|
|
|
int screen_off_timer = 0;
|
|
|
|
|
|
int key_shield_timer = 0;
|
|
|
|
|
|
int key_press = 0;
|
|
|
|
|
|
while (1) {
|
|
|
|
|
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD><EFBFBD><EFBFBD>״̬
|
|
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD>Ͱ<EFBFBD><CDB0><EFBFBD><EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>GUI
|
|
|
|
|
|
if (key_shield_timer == 0) {
|
|
|
|
|
|
WIN_StorKeyStruct(&k);
|
|
|
|
|
|
WIN_StorTouchStruct(&t);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// <20>Զ<EFBFBD>Ϩ<EFBFBD><CFA8><EFBFBD><EFBFBD>ʱ
|
|
|
|
|
|
my_delay_ms(20);
|
|
|
|
|
|
if (SysFile_GetSysFile()->screenOffTime &&
|
|
|
|
|
|
(SysFile_GetSysFile()->screenOffTime * 1000 < screen_off_timer)) {
|
|
|
|
|
|
ui_setScreenBackLightPower(0);
|
|
|
|
|
|
|
|
|
|
|
|
// ֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD><EFBFBD>̵߳<DFB3><CCB5>ú<EFBFBD><C3BA><EFBFBD>
|
|
|
|
|
|
// WIN_RunInWindow("home",creat_lock,0);
|
|
|
|
|
|
key_shield_timer = 1;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// <20>ڹ<EFBFBD><DAB9><EFBFBD>300ms<6D><73><EFBFBD>Ұ<EFBFBD><D2B0><EFBFBD><EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD>û<EFBFBD>а<EFBFBD><D0B0><EFBFBD>ʱȡ<CAB1><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
screen_off_timer += 20;
|
|
|
|
|
|
if ((screen_off_timer > 300) && key_press == 0) {
|
|
|
|
|
|
key_shield_timer = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-06-27 00:32:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
/*--C<><43><EFBFBD>Կ⺯<D4BF><E2BAAF>--*/
|
2025-06-27 00:32:57 +08:00
|
|
|
|
|
2025-10-18 13:58:40 +08:00
|
|
|
|
void exit(int err) {
|
|
|
|
|
|
while (1)
|
|
|
|
|
|
;
|
2025-06-27 00:32:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-18 13:58:40 +08:00
|
|
|
|
int system(const char *cmd) { return 0; }
|