小学期Deadline之GEC6818点奶茶系统

Posted MangataTS

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了小学期Deadline之GEC6818点奶茶系统相关的知识,希望对你有一定的参考价值。

效果

如图:





流程

用户登录 -> 功能选择 -> 相应的功能

思路

  • 对于整个软件的使用而言,触摸屏坐标点的获取是必不可缺的,所以我们单独开一个获取触摸屏坐标点的线程,从始至终运行

  • 然后考虑到密码登录有两种形式,我们得开两个线程去处理,我们可以设置一个是否登录的全局变量,然后当未登陆的时候就一直循环,这样登陆得问题就得到解决了

  • 接下来是功能页面,当用户登陆界面结束后,就跳转到功能选择页面,这里我做的是左边是“立即下单”,右边是“历史订单”

  • 对于“立即下单”,我们要做的就是对每个商品能进行增加或者减少的操作,最终下单,下单后我们将这个单号的数据存储到对应的文件里面

  • 对于“历史订单”我们需要注意对于订单号的存储信息处理以及布局即可,我这里省事所以就只显示10条记录

  • 还有就是要创建一个获取温湿度的线程,然后在用户登陆后实时显示在左上角

代码

主要逻辑流程

为了更加清楚的看懂流程,我这里只展示main.c的内容,其余内容请在Github中获取https://github.com/MangataTS/GEC6818-project

如果打不开的话,可以从这里快速下载:http://acm.mangata.ltd/file/2/project.zip

#include <stdio.h>
#include <pthread.h>
#include "picture.h"
#include "getxy.h"
#include "font.h"
#include "UARTdh11.h"
#include "RFID.h"
#include <stdbool.h>
#include <string.h>
#include <termios.h>
#include <stdlib.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

#define true 1
#define false 0
#define PASSLEN 4
//************素材内容************
char *number[]=//数字
        "sucai/0.bmp",
        "sucai/1.bmp",
        "sucai/2.bmp",
        "sucai/3.bmp",
        "sucai/4.bmp",
        "sucai/5.bmp",
        "sucai/6.bmp",
        "sucai/7.bmp",
        "sucai/8.bmp",
        "sucai/9.bmp",
;
char *del="sucai/del.bmp";
char *login="sucai/login.bmp";
char *background="sucai/back.bmp";
char *whiteblock="sucai/whiteblock.bmp";
char *shownumbers="sucai/shownumbers.bmp";
char *Error_login="sucai/errorlogin.bmp";
char *Login_Logo="sucai/login_logo.bmp";
char *NC[]=
        "sucai/CMWZ.bmp",
        "sucai/FMYZC.bmp",
        "sucai/KKNC.bmp",
        "sucai/LMBH.bmp"
;
char *JGB="sucai/JGB.bmp";
char *XIADAN="sucai/XDCN.bmp";
//************素材内容************
int locpass=0;
int tolid = 0;
struct Good
    int value;
    int number;
    char name[20];
;
int IDok;	//身份识别默认失败 0失败 1成功
char a[20][40];
extern char WsdString[20];

void *Pcamera(void *arg);

#if 1
//初始化,从文件中读取信息
void Message_init()
    FILE *fp_message = fopen("Message_table.txt","r");
    if(fp_message == NULL) 
        fp_message = fopen("Message_table.txt","w");
        fclose(fp_message);
        return;
    
    char buf[40];
    while(fgets(buf,40,fp_message))//读取这些订单信息
       strcpy(a[tolid++],buf);
       tolid %= 10;//限制读取十条
    
    fclose(fp_message);

//显示主界面
void show_Main()
    show_anybmp(background,0,0);//背景
    show_anybmp(Login_Logo,90,90);//logo
    Init_Font();
    Display_characterX(300,0,"全全奶茶",0x00D2691E,3);
    UnInit_Font();
    //显示数字键盘
    for(int x = 310,i = 1;i <= 3; ++i,x += 60)
        for(int y = 240,j = 1;j <= 3; ++j,y += 60)
            show_anybmp(number[(i-1)*3+j],x,y);
        
    
    show_anybmp(number[0],360,420);//数字0
    show_anybmp(del,590,240);//删除键
    show_anybmp(login,590,340);//登陆键
    show_anybmp(shownumbers,280,90);//显示输入的数字

//下单界面
void show_Right(struct Good *goods)
    Init_Font();
    Clean_Area(0, 0,  800, 480, 0x00FFFFFF);
    printf("YES2\\n");
    show_anybmp(NC[0],250,0);
    show_anybmp(NC[1],500,0);
    show_anybmp(NC[2],250,240);
    show_anybmp(NC[3],500,240);
    show_anybmp(JGB,700,0);
    //商品的左上角显示商品的数量
    char num[10];
    Clean_Area(250,0,20,20,0x00FF0000);
    sprintf(num,"%d",goods[0].number);
    Display_characterX(250,0,num,0x00FFFFFF,1);

    Clean_Area(500,0,20,20,0x00FF0000);
    sprintf(num,"%d",goods[1].number);
    Display_characterX(500,0,num,0x00FFFFFF,1);

    Clean_Area(250,240,20,20,0x00FF0000);
    sprintf(num,"%d",goods[2].number);
    Display_characterX(250,240,num,0x00FFFFFF,1);

    Clean_Area(500,240,20,20,0x00FF0000);
    sprintf(num,"%d",goods[3].number);
    Display_characterX(500,240,num,0x00FFFFFF,1);

    //商品的左上角显示商品的数量
    //logo?
    int sum_number = 0;
    int sum_value = 0;
    for(int i = 0;i < 4; ++i)
        sum_number += goods[i].number;//总数量
        sum_value += goods[i].value * goods[i].number;//总价值
    
//    Display_characterX(10,10,"温湿度:",0x00D2691E,2);
    Display_characterX(10,90,WsdString,0x00D2691E,2);

    Display_characterX(10,300,"数量:",0x00D2691E,2);
    sprintf(num,"%d",sum_number);
    Display_characterX(120,300,num,0x00D2691E,2);

    Display_characterX(10,350,"共计:",0x00D2691E,2);
    sprintf(num,"%d¥",sum_value);
    Display_characterX(120,350,num,0x00D2691E,2);

    Clean_Area(0,0,250,80,0x00FFD700);//返回按钮
    Display_characterX(65,20,"返回",0x00FFFFFF,3);
    Clean_Area(0,400,250,80,0x00FFD700);//确认按钮
    Display_characterX(10,420,"确定下单",0x00FFFFFF,3);

    //数量
//  左上角的商品
    Clean_Area(250, 200,  199, 40, 0x00FFF0F5);
    Display_characterX(250,180,"-",0x00D2691E,5);
    Display_characterX(350,180,"+",0x00D2691E,5);
//  右上角的商品
    Clean_Area(500, 200,  199, 40, 0x00FFF0F5);
    Display_characterX(500,180,"-",0x00D2691E,5);
    Display_characterX(600,180,"+",0x00D2691E,5);
//  左下角的商品
    Clean_Area(250, 440,  199, 40, 0x00FFF0F5);
    Display_characterX(250,420,"-",0x00D2691E,5);
    Display_characterX(350,420,"+",0x00D2691E,5);
//  右下角的商品
    Clean_Area(500, 440,  199, 40, 0x00FFF0F5);
    Display_characterX(500,420,"-",0x00D2691E,5);
    Display_characterX(600,420,"+",0x00D2691E,5);
    UnInit_Font();

void Faild_login()
    show_anybmp(Error_login,100,90);
    sleep(1);//睡1s
    show_Main();//清空主界面
    locpass = 0;//将密码指针移到开头

//密码线程
int is_in(int x,int y,int startx,int starty,int endx,int endy)//判断触摸点是否在这个点内
    if(x >= startx && x <= endx && y >= starty && y<= endy)//如果在这个范围内返回1
        return 1;
    
    return 0;

//
void *Ppass(void *arg)

    char password[4];
    char *banzipassword="4399";//内置密码
    while(!IDok)
    
//        printf("(%d,%d)\\n",x,y);
        if(x == -1 || y == -1) continue;
        if(x > 590 && x < 690 && y > 240 && y < 300)//点击删除框is_in(x,y,590,240,690,300)
            if(locpass == 0) //表示密码框为空
                printf("密码框为空!\\n");
            
            else//删除操作
                locpass--;
                show_anybmp(whiteblock,280+60*locpass,90);//覆盖前面一个位置
            
            x = y = 0;
        
        else if(x > 590 && x < 690 && y > 340 && y < 400)//点击登陆框is_in(x,y,590,340,690,400)
            if(locpass != 4)
                printf("密码框未输满!\\n");
            
            else
                int fg = true;
                for(int i = 0;i < PASSLEN; ++i) 
                    if(password[i] != banzipassword[i])
                        fg = false;
                    
                
                if(fg) //如果对了,那么显示奖励图片
                    printf("密码正确!\\n");
                    x = y = 0;
                    IDok = 1;
                    printf("通过密码认证!\\n");
                
                else //如果错了
                    printf("密码错误!\\n");
                    Faild_login();
                
            
            x = y = -1;
        
        else
            if(locpass == 4) //密码框已满
                printf("密码框已满!\\n");
            
            else//点击数字框
                int locnumber;
                for(int XX = 310,i = 1;i <= 3; ++i,XX += 60)
                    for(int YY = 240,j = 1;j <= 3; ++j,YY += 60)
                        if(x > XX && x < (XX + 60) && y > YY && y < (YY + 60))//is_in(x,y,XX,YY,XX+60,YY+60)
                            locnumber = (i-1)*3+j;
                            show_anybmp(number[locnumber],280+locpass*60,90);//显示输入的数字
                            password[locpass++] = '0'+locnumber;
                        
                    
                
                if(x > 360 && x < 420 && y > 420 && y < 480) //数字0  is_in(x,y,360,420,420,480)
                    locnumber = 0;
                    show_anybmp(number[locnumber], 280 + locpass * 60, 90);
                    password[locpass++] = '0' + locnumber;
                
            
            x = y = -1;
        粤嵌gec6818LED屏幕上画图 太极图 图片显示 电子相册 2048小游戏 实现识别触摸坐标的识别 电子自助点餐设计等项目

粤嵌GEC6818板子TCP网络编程发送命令控制音视频

粤嵌GEC6818,基于LVGL和mplayer的音视频播放器

粤嵌GEC6818-学习笔记2-屏幕相关及音频播放

GEC6818开发板JPG图像显示,科大讯飞离线语音识别包Linux_aitalk_exp1227_1398d7c6运行demo程序,开发板实现录音

粤嵌gec6818开发板LED屏幕上画图(数组与内存映射的采用)换图片 电子相册 实现识别触摸坐标的识别等项目