一、电路设计
此电路由最小系统板、LCD1602液晶模块和AS608指纹模块组成。
二、运行效果
三、主代码
/*想要更多项目私wo!!!*/
#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 "MMC_SD.h"
#include "ff.h"
#include "exfuns.h"
#include "fontupd.h"
#include "text.h"
#include "usart2.h"
#include "AS608.h"
#include "timer.h"
#define usart2_baund 57600//串口2波特率,根据指纹模块波特率更改
SysPara AS608Para;//指纹模块AS608参数
u16 ValidN;//模块内有效模板个数
u8** kbd_tbl;
const u8* kbd_menu[15]={"del_fp"," : ","add_fp","1","2","3","4","5","6","7","8","9","DEL","0","Enter",};//按键表
const u8* kbd_delFR[15]={"BACK"," : ","del_all","1","2","3","4","5","6","7","8","9","DEL","0","Enter",};//按键表
void Add_FR(void); //录指纹
void Del_FR(void); //删除指纹
void press_FR(void);//刷指纹
void ShowErrMessage(u8 ensure);//显示确认码错误信息
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 ensure;
u8 key_num;
char *str;
Stm32_Clock_Init(9); //系统时钟设置
delay_init(72); //延时初始化
uart_init(72,115200); //串口1初始化,用于支持USMART
LCD_Init(); //初始化液晶
KEY_Init(); //按键初始化
usmart_dev.init(72); //usmart初始化
usart2_init(36,usart2_baund); //初始化串口2,用于与指纹模块通讯
PS_StaGPIO_Init(); //初始化FR读状态引脚
tp_dev.init(); //触摸屏初始化
mem_init(); //初始化内存池
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,"Adjust the touch screen?",16,240);
POINT_COLOR=BLUE;
Show_Str_Mid(0,60,"YES: KEY1 NO: 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,"AS608 Fingerprint module test",16,240);
Show_Str_Mid(0,20,"Author: @ALIENTEK",16,240);
POINT_COLOR=BLUE;
Show_Str_Mid(0,40,"Connect with AS608....",16,240);
while(PS_HandShake(&AS608Addr))//与AS608模块握手
{
LCD_Fill(0,40,240,80,WHITE);
Show_Str_Mid(0,40,"Cannot connect with AS608!",16,240);
delay_ms(1000);
LCD_Fill(0,40,240,80,WHITE);
Show_Str_Mid(0,40,"Try to connect again....",16,240);
delay_ms(1000);
}
LCD_Fill(0,40,240,320,WHITE);
Show_Str_Mid(0,40,"Connect success!",16,240);//通讯成功
str=mymalloc(30);
sprintf(str,"Baudrate:%d Addr:%x",usart2_baund,AS608Addr);//显示波特率
Show_Str(0,60,240,16,(u8*)str,16,0);
delay_ms(100);
ensure=PS_ValidTempleteNum(&ValidN);//读库指纹个数
if(ensure!=0x00)
ShowErrMessage(ensure);//显示确认码错误信息
ensure=PS_ReadSysPara(&AS608Para); //读AS608模块参数
if(ensure==0x00)
{
mymemset(str,0,50);
sprintf(str,"RemainNum:%d Level:%d",AS608Para.PS_max-ValidN,AS608Para.PS_level);//显示剩余指纹数量和安全等级
Show_Str(0,80,240,16,(u8*)str,16,0);
}
else
ShowErrMessage(ensure);
myfree(str);
AS608_load_keyboard(0,170,(u8**)kbd_menu);//加载虚拟键盘
while(1)
{
key_num=AS608_get_keynum(0,170);
if(key_num)
{
if(key_num==1)Del_FR(); //删指纹
if(key_num==3)Add_FR(); //录指纹
}
if(PS_Sta) //检测PS_Sta状态,如果有手指按下
{
press_FR();//刷指纹
}
}
}
上一篇:51单片机游戏(贪吃蛇)
下一篇:单片机设计 超声波测距仿真
推荐阅读最新更新时间:2024-11-17 22:10
设计资源 培训 开发板 精华推荐
- 【立创开发板】基于梁山派的游戏机Miao_
- AM3G-0505DZ ±5V 3 瓦 DC 至 DC 转换器的典型应用
- 虚拟地双电源
- LTC1143 低压差双路 5V/2A、3.3V/1A 转换器的典型应用电路
- AM1G-4815SZ 15V 1 瓦 DC-DC 转换器的典型应用
- NCP5425 3.3 V 至 1.5 V/10 A 和 1.8 V/5.0 A 同步降压控制器的典型应用
- 使用 LTC2389CLX-18 ADC 驱动器、单端输入至差分输出的典型应用
- 征集令 |基于ESP32-S3的物联网小车驱动板
- 二合一IC卡
- RD-330,用于 LCD 显示器的 25.4W、5V、14V AC 到 DC 多输出电源的参考设计