This repository has been archived on 2024-01-06. You can view files and clone it, but cannot push or open issues or pull requests.
justhomework/MCU/MCU_REAL _FINAL/menu.c

80 lines
1.1 KiB
C
Raw Normal View History

2022-05-19 13:07:52 +00:00
#include "menu.h"
#include "display.h"
#include "delay.h"
2022-05-25 07:12:42 +00:00
#include "draw.h"
#include <stdio.h>
2022-06-05 13:03:15 +00:00
#include <stdlib.h>
Menu M_STARTUP;
Menu M_MAINMENU;//<2F><><EFBFBD>˵<EFBFBD>
Menu M_PLAYMODE1; //<2F><><EFBFBD><EFBFBD>˹<EFBFBD><CBB9><EFBFBD><EFBFBD>
2022-05-19 13:07:52 +00:00
Menu* NOW; //<2F><>ǰ<EFBFBD>˵<EFBFBD>ָ<EFBFBD><D6B8>
2022-06-05 13:03:15 +00:00
Menu* LAST = NULL; //<2F><>һ<EFBFBD><D2BB>״̬<D7B4>IJ˵<C4B2>
2022-05-25 07:12:42 +00:00
2022-06-05 13:03:15 +00:00
enum OPR opr = idle;
static unsigned char local[10] = {0};
2022-05-25 07:12:42 +00:00
//<2F><>ʼ<EFBFBD>˵<EFBFBD>
2022-06-05 13:03:15 +00:00
void m_startup(struct _menu* this)
{
if(LAST != &M_STARTUP)
{
2022-06-05 13:03:15 +00:00
LAST = &M_STARTUP;
drawNAME(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
delay(1000);
drawNUMBER(); //<2F><><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7>
}
if(opr == confirm)
{
opr = idle;
NOW = this->n; //ת<><D7AA><EFBFBD><EFBFBD>һ<EFBFBD>˵<EFBFBD>
clear();
}
}
2022-06-05 13:03:15 +00:00
void m_mainmenu(struct _menu* this)
2022-05-19 13:07:52 +00:00
{
if(LAST != &M_MAINMENU)
{
2022-06-05 13:03:15 +00:00
local[0] = 0;
LAST = &M_MAINMENU;
2022-06-05 13:03:15 +00:00
drawMAINMENU(local[0]);
}
2022-06-05 13:03:15 +00:00
if(opr == right)
{
local[0]++;
if(local[0] > 3)
local[0] = 3;
}
if(opr == left)
{
2022-06-05 13:03:15 +00:00
if(local[0] != 0)
local[0]--;
}
if(opr != idle)
{
opr = idle;
2022-06-05 13:03:15 +00:00
drawMAINMENU(local[0]);
}
2022-05-19 13:07:52 +00:00
}
2022-05-19 13:07:52 +00:00
void menuInit()
{
M_STARTUP.n = &M_MAINMENU;
M_STARTUP.f = m_startup;
M_MAINMENU.f = m_mainmenu;
NOW = &M_STARTUP;
2022-05-19 13:07:52 +00:00
}