feat(MCU课设): 菜单选择

This commit is contained in:
iridiumR 2022-06-05 21:03:15 +08:00
parent aae1585b5c
commit 5a7be07450
7 changed files with 850 additions and 649 deletions

File diff suppressed because it is too large Load diff

View file

@ -11,8 +11,8 @@ sbit CSB = P2 ^ 5;
void drawNUMBER()
{
unsigned int j;
for(j =0 ; j < 64; j++)
unsigned int j;
for(j = 0 ; j < 64; j++)
{
@ -44,7 +44,7 @@ void drawNUMBER()
}
for(j =0 ; j < 16; j++)
for(j = 0 ; j < 16; j++)
{
@ -111,21 +111,21 @@ void drawNAME()
write();
}
}
void drawMAINMENU()
void drawMAINMENU(unsigned char i)
{
unsigned int j;
for(j = 0; j < 32; j++)
{
CSA = 0;
CSB = 1;
CSA = 1;
CSB = 0;
RS = 0;
RW = 0;
P1 = 0xb8 + 0;
write();
P1 = 0X40 + j;
write(); //Ò³0ÁÐjÆÁA
P1 = 0X40 + 31 + j;
write(); //Ňł0ÁĐ31+jĆÁB
RS = 1;
RW = 0;
@ -136,12 +136,107 @@ void drawMAINMENU()
RW = 0;
P1 = 0xb8 + 1;
write();
P1 = 0X40 + j;
write(); //Ò³1ÁÐjÆÁA
P1 = 0X40 + 31 + j;
write(); //Ňł1ÁĐ31+jĆÁB
RS = 1;
RW = 0;
P1 = MAINMANU_PAGE1[j - 1];
write();
CSA = 1;
CSB = 0;
RS = 0;
RW = 0;
P1 = 0xb8 + 2;
write();
P1 = 0X40 + j;
write(); //Ňł2ÁĐjĆÁA
RS = 1;
RW = 0;
if(i==1)
P1 = ~MAINMANU_PAGE2[j - 1];
else
P1 = MAINMANU_PAGE2[j - 1];
write();
RS = 0;
RW = 0;
P1 = 0xb8 + 3;
write();
P1 = 0X40 + j;
write(); //Ňł3ÁĐjĆÁA
RS = 1;
RW = 0;
if(i==1)
P1 = ~MAINMANU_PAGE3[j - 1];
else
P1 = MAINMANU_PAGE3[j - 1];
write();
RS = 0;
RW = 0;
P1 = 0xb8 + 4;
write();
P1 = 0X40 + j;
write(); //Ňł4ÁĐjĆÁA
RS = 1;
RW = 0;
if(i==2)
P1 = ~MAINMANU_PAGE4[j - 1];
else
P1 = MAINMANU_PAGE4[j - 1];
write();
RS = 0;
RW = 0;
P1 = 0xb8 + 5;
write();
P1 = 0X40 + j;
write(); //Ňł5ÁĐjĆÁA
RS = 1;
RW = 0;
if(i==2)
P1 = ~MAINMANU_PAGE5[j - 1];
else
P1 = MAINMANU_PAGE5[j - 1];
write();
RS = 0;
RW = 0;
P1 = 0xb8 + 6;
write();
P1 = 0X40 + j;
write(); //Ňł6ÁĐjĆÁA
RS = 1;
RW = 0;
if(i==3)
P1 = ~MAINMANU_PAGE6[j - 1];
else
P1 = MAINMANU_PAGE6[j - 1];
write();
RS = 0;
RW = 0;
P1 = 0xb8 + 7;
write();
P1 = 0X40 + j;
write(); //Ňł7ÁĐjĆÁA
RS = 1;
RW = 0;
if(i==3)
P1 = ~MAINMANU_PAGE7[j - 1];
else
P1 = MAINMANU_PAGE7[j - 1];
write();
}
}

View file

@ -3,5 +3,5 @@
void drawNAME();
void drawNUMBER();
void drawMAINMENU();
void drawMAINMENU(unsigned char);
#endif

View file

@ -1,17 +1,15 @@
#ifndef _IMG_H_
#define _IMG_H_
//=================== 关于字库 ==================
//名字
code unsigned char NAME_PAGE0[] =
{
code unsigned char NAME_PAGE0[] ={
0x10, 0x60, 0x02, 0x0C, 0xC0, 0x04, 0x04, 0x04, 0x04, 0xFC, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00,
0x20, 0x24, 0x24, 0xA4, 0xFE, 0x23, 0x22, 0x20, 0x00, 0xF8, 0x08, 0x08, 0x08, 0xF8, 0x00, 0x00,
};
code unsigned char NAME_PAGE1[] =
{
code unsigned char NAME_PAGE1[] ={
0x04, 0x04, 0x7C, 0x03, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3F, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x10, 0x08, 0x06, 0x01, 0xFF, 0x01, 0x06, 0x00, 0x00, 0x3F, 0x10, 0x10, 0x10, 0x3F, 0x00, 0x00
@ -41,17 +39,17 @@ code unsigned char NUMBER_PAGE1[]={
0x00,0x06,0x05,0x24,0x24,0x3F,0x24,0x24,
};
//学号 右
code unsigned char NUMBER_RPAGE0[]=
{
code unsigned char NUMBER_RPAGE0[]={
0x00,0xF0,0x08,0x08,0x08,0x10,0xE0,0x00,
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,
};
code unsigned char NUMBER_RPAGE1[]=
{
code unsigned char NUMBER_RPAGE1[]={
0x00,0x01,0x12,0x22,0x22,0x11,0x0F,0x00,
0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,
};
//=================== 菜单字库 ==================
//第一行:菜单
code unsigned char MAINMANU_PAGE0[]={
0x04,0x04,0x44,0xC4,0x4F,0x44,0x44,0xC4,0x24,0x24,0x2F,0xB4,0x24,0x04,0x04,0x00,
@ -62,33 +60,31 @@ code unsigned char MAINMANU_PAGE1[]={
0x10,0x10,0x13,0x12,0x12,0x12,0x12,0xFF,0x12,0x12,0x12,0x12,0x13,0x10,0x10,0x00,
};
//void writeData(unsigned char d)
//{
// RS = 1;
// RW = 0;
// P1 = d;
//}
//void setCommand(unsigned char d)
//{
// RS = 0;
// RW = 0;
// P1 = d;
//}
//void setPage(unsigned char p)
//{
// setCommand(0xb8 + p);
//}
//void setLine(unsigned char p)
//{
// setCommand(0xc0 + p);
//}
//void setY(unsigned char p)
//{
// setCommand(0x40 + p);
//}
//第二行:方块
code unsigned char MAINMANU_PAGE2[]={
0x08,0x08,0x08,0x08,0x08,0xF8,0x89,0x8E,0x88,0x88,0x88,0x88,0x08,0x08,0x08,0x00,
0x20,0x20,0x20,0xFF,0x20,0x20,0x08,0x08,0x08,0xFF,0x08,0x08,0x08,0xF8,0x00,0x00,
};
code unsigned char MAINMANU_PAGE3[]={
0x00,0x80,0x40,0x20,0x18,0x07,0x00,0x00,0x40,0x80,0x40,0x3F,0x00,0x00,0x00,0x00,
0x10,0x30,0x10,0x0F,0x88,0x48,0x21,0x11,0x0D,0x03,0x0D,0x11,0x21,0x41,0x81,0x00,
};
//第三行:弹球
code unsigned char MAINMANU_PAGE4[]={
0x02,0xE2,0x22,0x22,0x3E,0x00,0x00,0xF9,0x4A,0x4C,0xF8,0x4C,0x4A,0xF9,0x00,0x00,
0x04,0x84,0x84,0xFC,0x84,0x84,0x10,0x50,0x90,0x10,0xFF,0x90,0x11,0x16,0x90,0x00,
};
code unsigned char MAINMANU_PAGE5[]={
0x00,0x43,0x82,0x42,0x3E,0x00,0x10,0x13,0x12,0x12,0xFF,0x12,0x12,0x13,0x10,0x00,
0x20,0x60,0x20,0x1F,0x10,0x10,0x10,0x08,0x45,0x82,0x7F,0x01,0x06,0x09,0x10,0x00,
};
//第四行:关于
code unsigned char MAINMANU_PAGE6[]={
0x00,0x00,0x10,0x11,0x16,0x10,0x10,0xF0,0x10,0x10,0x14,0x13,0x10,0x00,0x00,0x00,
0x40,0x40,0x42,0x42,0x42,0x42,0x42,0xFE,0x42,0x42,0x42,0x42,0x42,0x40,0x40,0x00,
};
code unsigned char MAINMANU_PAGE7[]={
0x81,0x81,0x41,0x41,0x21,0x11,0x0D,0x03,0x0D,0x11,0x21,0x41,0x41,0x81,0x81,0x00,
0x00,0x00,0x00,0x00,0x00,0x40,0x80,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
#endif

View file

@ -4,7 +4,7 @@
unsigned char TH, TL;
extern Menu *NOW; //꽉데寧濾
enum OPR opr = idle; //°´¼ü״̬
extern enum OPR opr; //°´¼ü״̬
unsigned char freshScreenTriger = 0;
@ -85,6 +85,6 @@ int main()
while(1)
{
NOW->f(NOW, opr);
NOW->f(NOW);
}
}

View file

@ -3,6 +3,7 @@
#include "delay.h"
#include "draw.h"
#include <stdio.h>
#include <stdlib.h>
Menu M_STARTUP;
Menu M_MAINMENU;//寮꽉데
Menu M_PLAYMODE1; //띤쭈薑렘욥
@ -11,20 +12,20 @@ Menu M_PLAYMODE1; //
Menu* NOW; //뎠품꽉데寧濾
Menu* LAST=NULL;//上一个状态的菜单
Menu* LAST = NULL; //上一个状态的菜单
enum OPR opr = idle;
static unsigned char local[10] = {0};
//놓迦꽉데
void m_startup(struct _menu* this, enum OPR opr)
void m_startup(struct _menu* this)
{
if(LAST != &M_STARTUP)
{
LAST = &M_STARTUP;
LAST = &M_STARTUP;
drawNAME(); //삥齡츰俚
delay(1000);
@ -40,20 +41,30 @@ void m_startup(struct _menu* this, enum OPR opr)
}
void m_mainmenu(struct _menu* this, enum OPR opr)
void m_mainmenu(struct _menu* this)
{
if(LAST != &M_MAINMENU)
{
local[0] = 0;
LAST = &M_MAINMENU;
drawMAINMENU();
drawMAINMENU(local[0]);
}
if(opr == right)
{
local[0]++;
if(local[0] > 3)
local[0] = 3;
}
if(opr == left)
{
if(local[0] != 0)
local[0]--;
}
if(opr != idle)
{
opr = idle;
NOW = &M_STARTUP;
clear();
drawMAINMENU(local[0]);
}
}

View file

@ -4,10 +4,8 @@
typedef struct _menu
{
unsigned char *local;
unsigned char *len;
struct _menu* n;
void(*f)(struct _menu* this, enum OPR opr);
void(*f)(struct _menu* this);
}Menu;
void menuInit();