正点原子精英开发板
模块化封装,入口函数简明,易上手操作
展示main.c代码,完整代码请下载
点击下载代码
#include "sys.h"
#include "delay.h"
#include "usart.h"
#include "lcd.h"
#include "key.h"
#include "touch.h"
#include "malloc.h"
#include "usmart.h"
#include "sdio_sdcard.h"
#include "w25qxx.h"
#include "ff.h"
#include "exfuns.h"
#include "fontupd.h"
#include "text.h"
#include "led.h"
u8** kbd_tbl;
const u8* kbd_menu[15]={"命令1",":","命令2","1","2","3","4","5","6","7","8","9","开灯","0","关灯",};//按键表
const u8* kbd_delFR[15]={"返回",":","清空","1","2","3","4","5","6","7","8","9","DEL","0","Enter",};//按键表
void Handle(void); //处理
void AS608_load_keyboard(u16 x,u16 y,u8 **kbtbl);//加载虚拟键盘
u8 AS608_get_keynum(u16 x,u16 y);//获取键盘数
u16 GET_NUM(void);//获取数值
int main(void)
{
u8 key_num;
int key;
u8 wifi_con=0;//记录wifi连接状态 1:连接 0:断开
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//设置系统中断优先级分组2
delay_init(); //初始化延时函数
uart_init(115200); //初始化串口1波特率为115200,用于支持USMART
KEY_Init(); //按键初始化
LCD_Init(); //LCD初始化
LED_Init(); //LED端口初始化
W25QXX_Init(); //初始化W25Q128
tp_dev.init(); //初始化触摸屏
usmart_dev.init(72); //初始化USMART
my_mem_init(SRAMIN); //初始化内部内存池
exfuns_init(); //为fatfs相关变量申请内存
f_mount(fs[1],"1:",1); //挂载FLASH.
POINT_COLOR=RED;
while(font_init()) //检查字库
{
LCD_ShowString(60,50,240,16,16,"Font Error!");
delay_ms(200);
LCD_Fill(60,50,240,66,WHITE);//清除显示
delay_ms(200);
}
if(!(tp_dev.touchtype&0x80))//如果是电阻屏
{
Show_Str_Mid(0,30,"是否进行触摸屏校准",16,240);
POINT_COLOR=BLUE;
Show_Str_Mid(0,60,"是:KEY1 否:KEY0",16,240);
while(1)
{
key_num=KEY_Scan(0);
if(key_num==KEY0_PRES)
break;
if(key_num==KEY1_PRES)
{
LCD_Clear(WHITE);
TP_Adjust(); //屏幕校准
TP_Save_Adjdata();//保存校准参数
break;
}
}
}
LCD_Clear(WHITE);
POINT_COLOR=RED;
Show_Str_Mid(0,0,"触摸屏实验",16,240);
Show_Str_Mid(0,20,"虚拟键盘模拟",16,240);
AS608_load_keyboard(0,170,(u8**)kbd_menu);//加载虚拟键盘
while(1)
{
key_num=AS608_get_keynum(0,170);
if(key_num)
{
printf("\r\nkey_num:%d\r\n",key_num);
if(key_num==1||key_num==3)Handle(); //处理
if(key_num==13)LED0=0; //开灯
if(key_num==15)LED0=1; //关灯
}
}
}