项目名称:智能停车系统
平台:arm
soc:s5pc100
os: linux
源码链接:http://download.csdn.net/detail/lucasxu01/9533329
平台:arm
soc:s5pc100
os: linux
知识点:c, linux, 进程,线程,网络,数据库, arm, 驱动
可扩展摄像头,主机传送数据保存数据库,现在实现了停车,选择收费类型,计时,出车库计算费用,并且打印在LCD屏幕。
主函数:
#include <my.h>
#include"key.h"
#include"led.h"
#include"pwm.h"
#include"IC_serial.h"
#include <string.h>
#include <stdio.h>
#include "lcd.h"
#include "lcd_show_jpeg.h"
int main(void)
{
USR *user = NULL;
char buf[20] = "\0";
char buf2[20] = "\0";
user = user_init();
led_init();
key_init();
pwm_open();
pwm_outset();
led_outset();
LCD_Init();
LCD_Clear(Red);
//LCD_PutString(115,15,"welcome to the park manager",Black,Red);
//usleep(100000);
LCD_PutString(115,15,"welcome to ",Black,Red);
usleep(100000);
LCD_PutString(115,15,"welcome to the ",Black,Red);
usleep(100000);
LCD_PutString(115,15,"welcome to the park",Black,Red);
usleep(100000);
LCD_PutString(115,15,"welcome to the park",Black,Red);
for(;;)
{
input_userinfo(user);
start_time(user);
//printf("PRESS ENTER KEY CONTINUE...\n");
//getchar();
read_from_serial(buf2);
printf("firdt card = %s\n",user->card);
printf("second card = %s\n",buf2);
printf("------------------------------------------------------%s\n","");
printf("compare:%d\n",strcmp(buf2,user->card));
FLAG:
if(strcmp(buf2,user->card)==0)
{
end_time(user);
//****************************************
LCD_PutString(65,95,"***************end parking**************",Black,Red);
//****************************************
print_userinfo(user);
}
else
{
printf(" ~~~~~please input your own card !!!!~~~~~~ %s\n","");
//****************************************
LCD_PutString(65,95,"*****~~~~~please input your own card !!!!~~~~~~****",Black,Red);
//****************************************
buf2 == "";
read_from_serial(buf2);
goto FLAG;
}
//printf("!!!!!!buf2[1]= %s\n",buf2);
//end_time(user);
//print_userinfo(user);
}
user_exit(user);
led_exit();
key_exit();
pwm_close();
return 0;
}
#include <my.h>
#include"key.h"
#include <lcd.h>
USR *user_init(void)
{
USR *temp = NULL;
if((temp = (USR *)malloc(sizeof(USR))) == NULL)
{
perror("MALLOC ERROR");
exit(EXIT_FAILURE);
}
return temp;
}
void user_exit(USR *temp)
{
free(temp);
return;
}
void input_userinfo(USR *temp)
{
int num;
//-------------------------------
//char buf[20] = "\0";
open_port();
uart_init();
//-------------------------------
printf("=====================WELCOME==================\n");
printf("Please input name:>");
//****************************************
LCD_PutString(20,35,"Please input name:>",Black,Red);
//****************************************
scanf("%s", temp->name);
//****************************************
LCD_PutString(180,35,temp->name,Black,Red);
//****************************************
//****************************************
LCD_PutString(20,55,"Please input card:>",Black,Red);
//****************************************
printf("Please input card:>\n");
//printf("Please input card:>");
//-------------------------------
read_from_serial(temp->card);
printf("temp->card = %s\n",temp->card);
//------------------------------------
//scanf("%s", temp->card);
//****************************************
LCD_PutString(180,55,temp->card,Black,Red);
//****************************************
//****************************************
LCD_PutString(20,75,"please select type:>",Black,Red);
//****************************************
FLAG:
printf("-------------------------please select type----------------------:\n");
printf("TYPE LIST:\n");
printf("1----20/h\n");
printf("2----15/h\n");
printf("3----10/h\n");
printf("4----5/h\n");
printf("please choose:>");
num=key_read();
//****************************************
//LCD_PutString(180,75,"****",Black,Red);
//****************************************
pwm_outset();
switch(num)
{
case 1: temp->type=1;
temp->money=20.00f;
//****************************************
LCD_PutString(180,75,"1----20/h----start to count money!",Black,Red);
//****************************************
break;
case 2: temp->type=2;
temp->money=15.00f;
//****************************************
LCD_PutString(180,75,"2----15/h----start to count money!",Black,Red);
//****************************************
break;
case 3: temp->type=3;
temp->money=10.00f;
//****************************************
LCD_PutString(180,75,"3----10/h----start to count money!",Black,Red);
//****************************************
break;
case 4: temp->type=4;
temp->money=5.00f;
//****************************************
LCD_PutString(180,75,"3----10/h----start to count money!",Black,Red);
//****************************************
break;
default:
printf("ERROR, INPUT AGAIN!");
goto FLAG;
}
/* scanf("%d", &temp->type);
switch(temp->type)
{
case 1: temp->money = 20.00f; break;
case 2: temp->money = 15.00f; break;
case 3: temp->money = 10.00f; break;
case 4: temp->money = 5.00f; break;
default:
printf("ERROR, INPUT AGAIN!");
goto FLAG;
}
*/
getchar();
return;
}
void start_time(USR *temp)
{
time_t mytm;
struct tm *val = NULL;
mytm = time(NULL);
val = localtime(&mytm);
memcpy(&temp->start_time, val, sizeof(struct tm));
printf("start time: %d-%d-%d %d:%d:%d\n", val->tm_year+1900, val->tm_mon+1\
,val->tm_mday, val->tm_hour, val->tm_min, val->tm_sec);
printf("------------------------start count money------------------------------%s\n","");
return;
}
void end_time(USR *temp)
{
time_t mytm;
struct tm *val = NULL;
mytm = time(NULL);
val = localtime(&mytm);
memcpy(&temp->end_time, val, sizeof(struct tm));
printf("end time: %d-%d-%d %d:%d:%d\n", val->tm_year+1900, val->tm_mon+1\
,val->tm_mday, val->tm_hour, val->tm_min, val->tm_sec);
return;
}
void print_userinfo(USR *temp)
{
int val;
val = temp->end_time.tm_sec - temp->start_time.tm_sec;
if(val < 0)
val += 60;
printf("NAME:%s\n", temp->name);
printf("CARD:%s\n", temp->card);
printf("TYPE:%d\n", temp->type);
printf("MONEY:%.2f\n", temp->money * val);
printf("==BYEBYE===\n");
//****************************************
LCD_PutString(60,115,"user name: ",Black,Red);
LCD_PutString(60,135,"user card: ",Black,Red);
LCD_PutString(300,115,temp->name,Black,Red);
LCD_PutString(300,135,temp->card,Black,Red);
LCD_PutString(60,155,"selected type:",Black,Red);
LCD_PutString(60,175,"parking time:",Black,Red);
LCD_PutString(60,195,"cost of park: ",Black,Red);
char a = '0';
a=a+temp->type;
LCD_PutChar(300,155,a,Black,Red);
char jin1[20],jin2[20];
sprintf(jin1,"%d",val);
sprintf(jin2,"%f",temp->money * val);
LCD_PutString(300,175,jin1,Black,Red);//time
LCD_PutString(300,195,jin2,Black,Red);//money
LCD_PutString(60,230,"------>good bye , welcome to come again!<-----",Black,Red);
//LCD_PutString(20,135,temp->card,Black,Red);
//****************************************
return;
}
源码链接:http://download.csdn.net/detail/lucasxu01/9533329