基于STM32F103+AS608的智能打卡系统
工程源码链接
链接:https://pan.baidu.com/s/1RRc03nTrcTp--xfQnv2r9Q?pwd=in9p
提取码:in9p
--来自百度网盘超级会员V5的分享
一、功能描述
基于STM32F013+AS608实行的智能打卡系统
1》进行打卡功能
2》指纹添加(多指纹添加 最大容量300)
3》删除指纹(这里进行指纹删除时按顺序删除从最新添加的开始,还没有写删除指定指纹)
4》查看指纹列表(通过该功能可以查看现有的指纹)
扩展功能:可以通过指纹实现一系列的其他控制(待完成)
二、硬件
TFT LCD 3.5 320*480 RGB彩色屏 | 数量1 |
---|---|
STM32F103最小系统 | 数量1 |
AS608指纹模块 | 数量1 |
ST-LINK | 数量1 |
TTL转串口 | 数量1 |
杜邦线 | 若干 |
硬件实物
1.TFT彩屏
2.F103最小系统
3.AS608指纹模块
4.ST-LINK烧入器
5.TTL串口打印
三、部分程序
usart_view.c
#include "usart1_view.h"
#include "USART_Config.h"
#include "lcd.h"
#include "lcd_init.h"
#include "delay.h"
#include "AS608_use.h"
#include "as608.h"void Operation_Interface(void);
extern void Add_FR(u16 FR_ID); /*录哪个ID的指纹*/
extern void Del_FR(u16 FR_ID); /*删除哪个ID的指纹*/
//SysPara AS608Para; /*指纹模块AS608参数*/
unsigned char List_Index = 1,Temp_Index; /*选择项索引 和缓存索引 界面返回时需要用*/
unsigned char Add_Flag; /*指纹添加成功失败标志 1成功 0 失败*/
unsigned char Del_Flag; /*指纹删除失败标志 1成功 0 失败*/
unsigned char Figer_Info[4][12];
unsigned int Temp = 0,Temp1= 0; /*缓存有效指纹*/
extern unsigned int Count; /*有效指纹数记录*/
unsigned int ID_Array[300],id_index = 0; /*存储ID号*/
unsigned int ID_Flag; /*用来记录当前ID*/
unsigned char Score; /*记录匹配得分*/
unsigned char Sign_Flag; /*签到成功标志 1成功 0 失败*/
unsigned int ID_Num = 0; /*每次添加时ID_Num表示一个指纹*/extern SysPara AS608Para; /*指纹模块AS608参数*/
extern u16 ValidN; /*模块内有效指纹个数*/void usart1_execute(void) /*串口一接收到数据后执行子函数*/
{extern u8 eu8_Flag;extern u8 eu8_what;unsigned char i =0,j = 0;if(eu8_Flag){eu8_Flag=0;switch(eu8_what){case '1':{List_Index++;Temp_Index = List_Index; //进行选择性的缓存if(List_Index == 1){LCD_ShowString(320,80,(unsigned char *)"<=",RED,HS,32,0);LCD_ShowString(320,120,(unsigned char *)" ",RED,HS,32,0);LCD_ShowString(320,160,(unsigned char *)" ",RED,HS,32,0);LCD_ShowString(320,200,(unsigned char *)" ",RED,HS,32,0);}else if(List_Index == 2){LCD_ShowString(320,120,(unsigned char *)"<=",RED,HS,32,0);LCD_ShowString(320,80,(unsigned char *)" ",RED,HS,32,0);LCD_ShowString(320,160,(unsigned char *)" ",RED,HS,32,0);LCD_ShowString(320,200,(unsigned char *)" ",RED,HS,32,0);}else if(List_Index == 3){LCD_ShowString(320,160,(unsigned char *)"<=",RED,HS,32,0);LCD_ShowString(320,120,(unsigned char *)" ",RED,HS,32,0);LCD_ShowString(320,80,(unsigned char *)" ",RED,HS,32,0);LCD_ShowString(320,200,(unsigned char *)" ",RED,HS,32,0);}else if(List_Index == 4){LCD_ShowString(320,160,(unsigned char *)" ",RED,HS,32,0);LCD_ShowString(320,120,(unsigned char *)" ",RED,HS,32,0);LCD_ShowString(320,80,(unsigned char *)" ",RED,HS,32,0);LCD_ShowString(320,200,(unsigned char *)"<=",RED,HS,32,0);List_Index = 0;}}break;case '2':{/*------------------------------------打卡————————————————————*/if(Temp_Index == 1){//打卡检测//首先进行界面切换LCD_Init(); //清屏 LCD_ShowChinese(80,0,(unsigned char *)"欢迎使用智能打卡系统",RED,Q_BLUE,32,0);LCD_ShowChinese(80,80,(unsigned char *)"请将手指放于打卡处",RED,GREEN,32,0);//如果检测到指纹则显示打卡成功 while(1){if(PS_Sta) //检测PS_Sta状态,如果有手指按下{Sign_Flag = press_FR();if(Sign_Flag) {LCD_ShowChinese(120,120,(unsigned char *)"打卡成功",RED,GREEN,32,0);//打卡人信息LCD_ShowChinese(120,160,(unsigned char *)"打卡",RED,GREEN,32,0);sprintf((char *)Figer_Info[4],"ID:%d ",ID_Flag);LCD_ShowString(180,160,(unsigned char *)Figer_Info[4],RED,GREEN,32,0);LCD_ShowChinese(120,200,(unsigned char *)"匹配得分:",RED,GREEN,32,0);LCD_ShowIntNum(280,200,Score,3,RED,GREEN,32); }else{LCD_ShowChinese(120,120,(unsigned char *)"打卡失败",RED,GREEN,32,0);} break; //退出循环 }} }/*----------------------------------指纹添加------------------------------*/else if(Temp_Index == 2){//指纹添加LCD_Init(); //清屏delay_ms(500);//进行指纹添加界面的切换 并显示当前空的指纹数LCD_ShowChinese(80,0,(unsigned char *)"欢迎使用智能打卡系统",RED,Q_BLUE,32,0);//剩余指纹容量LCD_ShowChinese(120,80,(unsigned char *)"指纹最大容量:",RED,GREEN,32,0);sprintf((char *)Figer_Info[0],"%d",AS608Para.PS_max);LCD_ShowString(340,80,Figer_Info[0],RED,HS,32,0);LCD_ShowChinese(120,120,(unsigned char *)"指纹添加中请稍等",RED,GREEN,32,0);ID_Num++; /*指纹数++*/Add_FR(ID_Num); /*录哪个ID的指纹*/Temp = Count; /*缓存指纹数*///指纹对比成功则显示添加成功if(Add_Flag){ID_Array[id_index++] = ID_Num; /*将每个指纹ID记录在该数组中*/LCD_ShowChinese(120,160,(unsigned char *)"添加成功",RED,GREEN,32,0); }//显示添加失败else{LCD_ShowChinese(120,160,(unsigned char *)"添加失败",RED,GREEN,32,0);}//指纹信息LCD_ShowChinese(120,200,(unsigned char *)"有效指纹:",RED,GREEN,32,0);sprintf((char *)Figer_Info[1],"%d ",Temp);LCD_ShowString(280,200,Figer_Info[1],RED,HS,32,0);LCD_ShowChinese(120,240,(unsigned char *)"剩余容量:",RED,GREEN,32,0);sprintf((char *)Figer_Info[2],"%d ",AS608Para.PS_max-Temp);LCD_ShowString(280,240,Figer_Info[2],RED,HS,32,0);}/*-------------------------------------删除指纹-------------------------------*///删除指纹else if(Temp_Index == 3){LCD_Init(); //清屏delay_ms(500);LCD_ShowChinese(80,0,(unsigned char *)"欢迎使用智能打卡系统",RED,Q_BLUE,32,0);//在删除指纹的索引值下进行LCD_ShowChinese(120,120,(unsigned char *)"有效指纹:",RED,GREEN,32,0);LCD_ShowIntNum(280,120,Count,2,RED,HS,32); Temp1 = ID_Num; /*删除时先缓存指纹数*/Del_FR(Temp1); /*删除哪个ID的指纹*/ ID_Num--; /*指纹数--*/Temp--; /*总的指纹数--*//*更新总的指纹数*///存在则删除成功 如果没有指纹或指纹错误则失败if(Del_Flag){LCD_ShowChinese(120,160,(unsigned char *)"删除成功",RED,GREEN,32,0); LCD_ShowChinese(120,120,(unsigned char *)"有效指纹:",RED,GREEN,32,0);LCD_ShowIntNum(280,120,Count,2,RED,HS,32); }else{LCD_ShowChinese(120,160,(unsigned char *)"删除失败",RED,GREEN,32,0);}}/*-----------------------------------指纹查看-------------------------------------*/else if(Temp_Index == 4) {LCD_Init(); //清屏delay_ms(500);LCD_ShowChinese(80,0,(unsigned char *)"欢迎使用智能打卡系统",RED,Q_BLUE,32,0);LCD_ShowChinese(150,60,(unsigned char *)"指纹列表",RED,GREEN,32,0);if(Count == 0){LCD_ShowString(180,100,(unsigned char *)"NULL",RED,GREEN,32,0);}for(i = 0;i < Temp;i++){ if(i <= 99){if(i % 6 == 0 && i!= 0){j += 40;}LCD_ShowIntNum(80*(i%6), 100 + j,ID_Array[i],2,RED,GREEN,32); }}}}break;/*-----------------------------------------界面返回--------------------------------*/case '3': //界面返回{LCD_Init(); //清屏List_Index = Temp_Index; //返回进行界面切换时的选择项Operation_Interface();if(List_Index == 4){List_Index = 0;} }break;default: printf("\r\n接收失败\r\n");break;} }
}
main.c
#include "public.h"
u8 eu8_Flag = 0; /*全局变量串口一发生中断标志位*/
u8 eu8_what = 0; /*全局变量串口一接收到的一位数据*/#define usart2_baund 57600 /*串口2波特率,根据指纹模块波特率更改*/
SysPara AS608Para; /*指纹模块AS608参数*/
u16 ValidN; /*模块内有效指纹个数*/
extern unsigned char List_Index ;
extern void Operation_Interface(void);
void Init_Interface(void);/*-------------------------------功能操作界面--------------------------*/
extern void Operation_Interface(void)
{LCD_ShowChinese(80,0,(unsigned char *)"欢迎使用智能打卡系统",RED,Q_BLUE,32,0);LCD_ShowChinese(150,80,(unsigned char *)"开始打卡",RED,GREEN,32,0);LCD_ShowChinese(150,120,(unsigned char *)"添加指纹",RED,GREEN,32,0);LCD_ShowChinese(150,160,(unsigned char *)"删除指纹",RED,GREEN,32,0);LCD_ShowChinese(150,200,(unsigned char *)"指纹列表",RED,GREEN,32,0);if(List_Index == 1){LCD_ShowString(320,80,(unsigned char *)"<=",RED,HS,32,0);LCD_ShowString(320,120,(unsigned char *)" ",RED,HS,32,0);LCD_ShowString(320,160,(unsigned char *)" ",RED,HS,32,0);LCD_ShowString(320,200,(unsigned char *)" ",RED,HS,32,0);}else if(List_Index == 2){LCD_ShowString(320,120,(unsigned char *)"<=",RED,HS,32,0);LCD_ShowString(320,80,(unsigned char *)" ",RED,HS,32,0);LCD_ShowString(320,160,(unsigned char *)" ",RED,HS,32,0);LCD_ShowString(320,200,(unsigned char *)" ",RED,HS,32,0);}else if(List_Index == 3){LCD_ShowString(320,160,(unsigned char *)"<=",RED,HS,32,0);LCD_ShowString(320,120,(unsigned char *)" ",RED,HS,32,0);LCD_ShowString(320,80,(unsigned char *)" ",RED,HS,32,0);LCD_ShowString(320,200,(unsigned char *)" ",RED,HS,32,0);}else if(List_Index == 4){LCD_ShowString(320,160,(unsigned char *)" ",RED,HS,32,0);LCD_ShowString(320,120,(unsigned char *)" ",RED,HS,32,0);LCD_ShowString(320,80,(unsigned char *)" ",RED,HS,32,0);LCD_ShowString(320,200,(unsigned char *)"<=",RED,HS,32,0);}}void Init_Interface(void)
{ static unsigned int i = 0;LCD_ShowChinese(80,0,(unsigned char *)"欢迎使用智能打卡系统",RED,Q_BLUE,32,0);LCD_ShowString(90,40,(unsigned char *)"Author:Slow-Walker",RED,GREEN,32,0);LCD_ShowString(110,80,(unsigned char *)"Date:2022-09-19",RED,GREEN,32,0);LCD_ShowString(130,120,(unsigned char *)"Version:1.0",RED,GREEN,32,0);LCD_ShowChinese(140,240,(unsigned char *)"加载中",RED,GREEN,32,0);while(i*8 < 472){LCD_ShowString(i*8,280,(unsigned char *)".",RED, WHITE,32,0);delay_ms(20); i++;}delay_ms(500);LCD_ShowChinese(140,240,(unsigned char *)"加载成功",RED,GREEN,32,0); delay_ms(2000);LCD_Init();Operation_Interface();
}int main()
{u8 ensure;NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//设置系统中断优先级分组2delay_init(); /*延时初始化*/USART_INIT(); /*串口一初始化*/LCD_Init();LCD_Fill(0,0,LCD_W,LCD_H,GREEN); //LCD屏颜色初始化printf("初始化中\r\n");USART3_init(usart2_baund); /*初始化串口2,用于与指纹模块通讯*/PS_StaGPIO_Init(); /*初始化FR读状态引脚*/printf("与指纹模块握手\r\n");while(PS_HandShake(&AS608Addr)) /*与AS608模块握手*/{delay_ms(400);printf("未检测到模块\r\n");delay_ms(800);printf("尝试重新连接模块\r\n"); }printf("通讯成功\r\n");printf("波特率:%d 地址:%x\r\n",usart2_baund,AS608Addr); /*打印信息*/PS_Empty(); /*清空所有指纹ID*/ensure=PS_ValidTempleteNum(&ValidN); /*读库指纹个数*/if(ensure!=0x00)ShowErrMessage(ensure); /*显示确认码错误信息*/ensure=PS_ReadSysPara(&AS608Para); /*读参数 */if(ensure==0x00){printf("库容量:%d 对比等级: %d",AS608Para.PS_max-ValidN,AS608Para.PS_level);}else{ShowErrMessage(ensure); }Init_Interface();while(1){usart1_execute(); /*串口一接收到串口屏数据后执行子函数*/}
}
四、效果展示
现在工程不开源了哦,需完整资料可私 创作不易拒绝白嫖