文档库 最新最全的文档下载
当前位置:文档库 › 液晶操作菜单程序menu.c

液晶操作菜单程序menu.c

/**********************************************************************************
//概述:
//作者:大胡子书生 时间: 2011-06-27 16:30 地点:研发部
//CPU型号: 系统主频:
//版本号:
***********************************************************************************/
/**********************************************************************************
文件包含区
***********************************************************************************/
//#include "font.h"
#include "LDC_config.h"
#include "menu.h"
#include
#include "key.h"
/**********************************************************************************
常量定义区
***********************************************************************************/
const char str1[] = "T_PV(C): ";
const char str2[] = "O2_PV(mv): ";
const char str3[] = "Pul_PV(%): ";
const char str4[] = "PID_KP: ";
const char str5[] = "PID_KI: ";
const char str6[] = "O2_LSV(mv):";
const char str7[] = "O2_HSV(mv):";
const char str8[] = "T_SV(C): ";
const char str9[] = "Pul_REF(%):";
const char str10[] = "Pul_SV(%): ";
const char str11[] = "MODE: ";
const char str12[] = "-5C_PulKP: ";
const char str13[] = "0C_PulKP: ";
const char str14[] = "5C_PulKP: ";
const char str15[] = "10C_PulKP: ";
const char str16[] = "15C_PulKP: ";
const char str17[] = "45C_PulKP: ";
const char str18[] = "50C_PulKP: ";

const char str19[] = "START_TIME:";
const char str20[] = "PID_Dmax: ";
const char str21[] = "Speed_KP: ";
const char str22[] = "password: ";
const char str23[] = "err_name: ";
const char str24[] = "password: ";
/**********************************************************************************
公共变量定义去5
***********************************************************************************/
Menu_list menu;
/**********************************************************************************
私有变量定义区
***********************************************************************************/
Menu_tab tab_list1[24];

/**********************************************************************************
外部变量声明区
***********************************************************************************/
/**********************************************************************************
测试变量定义区
***********************************************************************************/
/**********************************************************************************
内部函数声明区
***********************************************************************************/
/**********************************************************************************
功能代码定义区
**********************************************************************************/
/*************************************************
Function: //
Description: //

Input: //
//
Output: //
Return: //
Others: //
*************************************************/
unsigned char GET_focusite (Menu_list* m)
{
unsigned char itemp1 = 0;
unsigned char itemp2;
while (itemp1 < m->line_number)
{
itemp2 = m->top +itemp1;
itemp2 %= m->number;
if(itemp2 == m->focus)
{return itemp1;}
itemp1 ++ ;
if( itemp1 >= m->number )
{break;}
}
return m->line_number;
}
/*************************************************
Function: //
Description: //
Input: //
//
Output: //
Return: //
Others: //
*************************************************/
void Relocation (Menu_list* m)
{
unsigned char itemp;
unsigned char itemp1;
itemp = GET_focusite ( m);
itemp1 = m->line_number -1;
if( itemp > itemp1)
{
m->focus = m->top;
}
}

/*************************************************
Function: //
Description: //
Input: //
//
Output: //
Return: //
Others: //
*************************************************/
void MENU_init (void)
{
menu.width = 15;
menu.top = 0;
menu.focus = 0;
menu.number = 24;
menu.tab = tab_list1;
menu.line_number = 2;

menu.tab[0].name = (unsigned char*)str1; //"T_PV(C): ";
menu.tab[0].width =strlen(str1);
menu.tab[0].value = 1;
menu.tab[0].CSR.bit.EN = 0x00;
menu.tab[0].CSR.bit.CE = 0x01;

menu.tab[1].name = (unsigned char*)str2; //const char str2[] = "O2_PV(mv): ";
menu.tab[1].width = strlen(str2);
menu.tab[1].value = 2;
menu.tab[1].CSR.bit.EN = 0x00;
menu.tab[1].CSR.bit.CE = 0x01;

menu.tab[2].name = (unsigned char*)str3; //const char str3[] = "Pul_PV(%): ";
menu.tab[2].width = strlen(str3);
menu.tab[2].value = 3;
menu.tab[2].CSR.bit.EN = 0x00;
menu.tab[2].CSR.bit.CE = 0x00;

menu.tab[3].name = (unsigned char*)str4; //const char str4[] = "PID_KP: ";
menu.tab[3].width = strlen(str4);
menu.tab[3].value = 4;
menu.tab[3].CSR.bit.EN = 0x00;
menu.tab[3].CSR.bit.CE = 0x00;

menu.tab[4].name = (unsigned char*)str5; //const char str5[] = "PID_KI: ";
menu.tab[4].width = strlen(str5);
menu.tab[4].value = 5;
menu.tab[4].CSR.bit.EN = 0x00;
menu.tab[4].CSR.bit.CE = 0x00;

menu.tab[5].name = (unsigned char*)str6; //const char str6[] = "O2_LSV(mv):";
menu.tab[5].width = strlen(str6);
menu.tab[5].value = 6;
menu.tab[5].CSR.bit.EN = 0x00;
menu.tab[5].CSR.bit.CE = 0x00;

menu.tab[6].name = (unsigned char*)str7; //const char str7[] = "O2_HSV(mv):";
menu.tab[6].width = strlen(str7);
menu.tab[6].value = 7;
menu.tab[6].CSR.bit.EN = 0x00;
menu.tab[6].CSR.bit.CE = 0x00;

menu.tab[7].name = (unsigned char*)str8; //const char str8[] = "T_SV(C): ";
menu.tab[7].w

idth = strlen(str8);
menu.tab[7].value = 8;
menu.tab[7].CSR.bit.EN = 0x00;
menu.tab[7].CSR.bit.CE = 0x00;

menu.tab[8].name = (unsigned char*)str9; //const char str9[] = "Pul_REF(%):";
menu.tab[8].width = strlen(str9);
menu.tab[8].value = 9;
menu.tab[8].CSR.bit.EN = 0x00;
menu.tab[8].CSR.bit.CE = 0x00;

menu.tab[9].name = (unsigned char*)str10; //const char str10[] = "Pul_SV(%): ";
menu.tab[9].width = strlen(str10);
menu.tab[9].value = 10;
menu.tab[9].CSR.bit.EN = 0x00;
menu.tab[9].CSR.bit.CE = 0x00;

menu.tab[10].name = (unsigned char*)str11; //const char str11[] = "MODE: ";
menu.tab[10].width = strlen(str11);
menu.tab[10].value = 11;
menu.tab[10].CSR.bit.EN = 0x00;
menu.tab[10].CSR.bit.CE = 0x00;

menu.tab[11].name = (unsigned char*)str12; //const char str12[] = "-5C_PulKP: ";
menu.tab[11].width = strlen(str12);
menu.tab[11].value = 0;
menu.tab[11].CSR.bit.EN = 0x00;
menu.tab[11].CSR.bit.CE = 0x00;

menu.tab[12].name = (unsigned char*)str13; //const char str13[] = "0C_PulKP: ";
menu.tab[12].width = strlen(str13);
menu.tab[12].value = 13;
menu.tab[12].CSR.bit.EN = 0x00;
menu.tab[12].CSR.bit.CE = 0x00;

menu.tab[13].name = (unsigned char*)str14; //const char str14[] = "5C_PulKP: ";
menu.tab[13].width = strlen(str14);
menu.tab[13].value = 13;
menu.tab[13].CSR.bit.EN = 0x00;
menu.tab[13].CSR.bit.CE = 0x00;

menu.tab[14].name = (unsigned char*)str15; //const char str15[] = "10C_PulKP: ";
menu.tab[14].width = strlen(str15);
menu.tab[14].value = 13;
menu.tab[14].CSR.bit.EN = 0x00;
menu.tab[14].CSR.bit.CE = 0x00;

menu.tab[15].name = (unsigned char*)str16; //const char str16[] = "15C_PulKP: ";
menu.tab[15].width = strlen(str16);
menu.tab[15].value = 13;
menu.tab[15].CSR.bit.EN = 0x00;
menu.tab[15].CSR.bit.CE = 0x00;

menu.tab[16].name = (unsigned char*)str17; //const char str17[] = "45C_PulKP: ";
menu.tab[16].width = strlen(str17);
menu.tab[16].value = 13;
menu.tab[16].CSR.bit.EN = 0x00;
menu.tab[16].CSR.bit.CE = 0x00;

menu.tab[17].name = (unsigned char*)str18; //const char str18[] = "50C_PulKP: ";
menu.tab[17].width = strlen(str18);
menu.tab[17].value = 13;
menu.tab[17].CSR.bit.EN = 0x00;
menu.tab[17].CSR.bit.CE = 0x00;

menu.tab[18].name = (unsigned char*)str19; //const char str19[] = "START_TIME:";
menu.tab[18].width = strlen(str19);
menu.tab[18].value = 13;
menu.tab[18].CSR.bit.EN = 0x00;
menu.tab[18].CSR.bit.CE = 0x00;

menu.tab[19].name = (unsigned char*)str20; //const char str20[] = "PID_Dmax: ";
menu.tab[19].width = strlen(str20);
menu.tab[19].value = 13;
menu.tab[19].CSR.bit.EN = 0x00;
menu.tab[19].CSR.bit.CE = 0x00;

menu.tab[20].name = (unsigned char*)str21; //const char str21[] = "Speed_KP: ";
menu.tab[20].width = strlen(str21);
menu.tab[20].value = 13;
menu.tab[20].CSR.bit.EN = 0x00;
menu.

tab[20].CSR.bit.CE = 0x00;

menu.tab[21].name = (unsigned char*)str22; //const char str22[] = "password: ";
menu.tab[21].width = strlen(str22);
menu.tab[21].value = 13;
menu.tab[21].CSR.bit.EN = 0x00;
menu.tab[21].CSR.bit.CE = 0x00;

menu.tab[22].name = (unsigned char*)str23; //const char str23[] = "err_name: ";
menu.tab[22].width = strlen(str22);
menu.tab[22].value = 13;
menu.tab[22].CSR.bit.EN = 0x00;
menu.tab[22].CSR.bit.CE = 0x00;

menu.tab[23].name = (unsigned char*)str24; //const char str24[] = "password: ";
menu.tab[23].width = strlen(str24);
menu.tab[23].value = 13;
menu.tab[23].CSR.bit.EN = 0x01;
menu.tab[23].CSR.bit.CE = 0x01;
}
/*************************************************
Function: //
Description: //
Input: //
//
Output: //
Return: //
Others: //
*************************************************/
void MENU_full (void)
{
menu.tab[0].CSR.bit.EN = 0x00;
menu.tab[0].CSR.bit.CE = 0x01;

menu.tab[1].CSR.bit.EN = 0x00;
menu.tab[1].CSR.bit.CE = 0x01;

menu.tab[2].CSR.bit.EN = 0x00;
menu.tab[2].CSR.bit.CE = 0x01;

menu.tab[3].CSR.bit.EN = 0x01;
menu.tab[3].CSR.bit.CE = 0x01;

menu.tab[4].CSR.bit.EN = 0x01;
menu.tab[4].CSR.bit.CE = 0x01;

menu.tab[5].CSR.bit.EN = 0x01;
menu.tab[5].CSR.bit.CE = 0x01;

menu.tab[6].CSR.bit.EN = 0x01;
menu.tab[6].CSR.bit.CE = 0x01;

menu.tab[7].CSR.bit.EN = 0x01;
menu.tab[7].CSR.bit.CE = 0x01;

menu.tab[8].CSR.bit.EN = 0x01;
menu.tab[8].CSR.bit.CE = 0x01;

menu.tab[9].CSR.bit.EN = 0x01;
menu.tab[9].CSR.bit.CE = 0x01;

menu.tab[10].CSR.bit.EN = 0x01;
menu.tab[10].CSR.bit.CE = 0x01;

menu.tab[11].CSR.bit.EN = 0x01;
menu.tab[11].CSR.bit.CE = 0x01;

menu.tab[12].CSR.bit.EN = 0x01;
menu.tab[12].CSR.bit.CE = 0x01;

menu.tab[13].CSR.bit.EN = 0x01;
menu.tab[13].CSR.bit.CE = 0x01;

menu.tab[14].CSR.bit.EN = 0x01;
menu.tab[14].CSR.bit.CE = 0x01;

menu.tab[15].CSR.bit.EN = 0x01;
menu.tab[15].CSR.bit.CE = 0x01;

menu.tab[16].CSR.bit.EN = 0x01;
menu.tab[16].CSR.bit.CE = 0x01;

menu.tab[17].CSR.bit.EN = 0x01;
menu.tab[17].CSR.bit.CE = 0x01;

menu.tab[18].CSR.bit.EN = 0x01;
menu.tab[18].CSR.bit.CE = 0x01;

menu.tab[19].CSR.bit.EN = 0x01;
menu.tab[19].CSR.bit.CE = 0x01;

menu.tab[20].CSR.bit.EN = 0x01;
menu.tab[20].CSR.bit.CE = 0x01;

menu.tab[21].CSR.bit.EN = 0x01;
menu.tab[21].CSR.bit.CE = 0x01;

menu.tab[22].CSR.bit.EN = 0x00;
menu.tab[22].CSR.bit.CE = 0x00;

menu.tab[23].CSR.bit.EN = 0x00;
menu.tab[23].CSR.bit.CE = 0x00;
}
/*************************************************
Function: //
Description: //
Input: //
//
Output: //
Return: //
Others: //
*************************************

************/
void MENU_incomplete (void)
{
menu.tab[0].CSR.bit.EN = 0x00;
menu.tab[0].CSR.bit.CE = 0x01;

menu.tab[1].CSR.bit.EN = 0x00;
menu.tab[1].CSR.bit.CE = 0x01;

menu.tab[2].CSR.bit.EN = 0x00;
menu.tab[2].CSR.bit.CE = 0x00;

menu.tab[3].CSR.bit.EN = 0x00;
menu.tab[3].CSR.bit.CE = 0x00;

menu.tab[4].CSR.bit.EN = 0x00;
menu.tab[4].CSR.bit.CE = 0x00;

menu.tab[5].CSR.bit.EN = 0x00;
menu.tab[5].CSR.bit.CE = 0x00;

menu.tab[6].CSR.bit.EN = 0x00;
menu.tab[6].CSR.bit.CE = 0x00;

menu.tab[7].CSR.bit.EN = 0x00;
menu.tab[7].CSR.bit.CE = 0x00;

menu.tab[8].CSR.bit.EN = 0x00;
menu.tab[8].CSR.bit.CE = 0x00;

menu.tab[9].CSR.bit.EN = 0x00;
menu.tab[9].CSR.bit.CE = 0x00;

menu.tab[10].CSR.bit.EN = 0x00;
menu.tab[10].CSR.bit.CE = 0x00;

menu.tab[11].CSR.bit.EN = 0x00;
menu.tab[11].CSR.bit.CE = 0x00;

menu.tab[12].CSR.bit.EN = 0x00;
menu.tab[12].CSR.bit.CE = 0x00;

menu.tab[13].CSR.bit.EN = 0x00;
menu.tab[13].CSR.bit.CE = 0x00;

menu.tab[14].CSR.bit.EN = 0x00;
menu.tab[14].CSR.bit.CE = 0x00;

menu.tab[15].CSR.bit.EN = 0x00;
menu.tab[15].CSR.bit.CE = 0x00;

menu.tab[16].CSR.bit.EN = 0x00;
menu.tab[16].CSR.bit.CE = 0x00;

menu.tab[17].CSR.bit.EN = 0x00;
menu.tab[17].CSR.bit.CE = 0x00;

menu.tab[18].CSR.bit.EN = 0x00;
menu.tab[18].CSR.bit.CE = 0x00;

menu.tab[19].CSR.bit.EN = 0x00;
menu.tab[19].CSR.bit.CE = 0x00;

menu.tab[20].CSR.bit.EN = 0x00;
menu.tab[20].CSR.bit.CE = 0x00;

menu.tab[21].CSR.bit.EN = 0x00;
menu.tab[21].CSR.bit.CE = 0x00;

menu.tab[22].CSR.bit.EN = 0x00;
menu.tab[22].CSR.bit.CE = 0x00;

menu.tab[23].CSR.bit.EN = 0x01;
menu.tab[23].CSR.bit.CE = 0x01;
}
/*************************************************
Function: //
Description: //
Input: //
//
Output: //
Return: //
Others: //
*************************************************/
void MENU_redraw ( Menu_list* m )
{
unsigned char itemp1 = 0;
unsigned char itemp2;
unsigned char itemp3 = 0;
unsigned char itemp4 = 0;
itemp2 = m->top;
while (itemp1 < m->line_number)
{
// if( itemp1 == m->focus)
//{itemp3 = 1;}
if(m->tab[itemp2].CSR.bit.CE)
{
LCD_Write_str( m->X, m->Y+itemp1 , m->tab[itemp2].name,itemp3);
itemp1 ++ ;
}
itemp2 ++;
itemp2 %= m->number;
itemp4 ++;
if( itemp4 >= m->number )
{break;}
}
MENU_updata ( m );
}
/*************************************************
Function: //
Description: //
Input: //
//
Output: //
Return: //
Others: //
*************************************************/
void MENU_updata ( Menu_list* m )
{
unsigned char itemp1 = 0;
unsigned char itemp2;
unsigned char itemp3 = 0;
unsigned char i

temp4 = 0;
unsigned short X = 0;
itemp2 = m->top;
while (itemp1 < m->line_number)
{
if((itemp2 == m->focus)&&(key_state !=0 ))
{itemp3 = 1;}
else
{itemp3 = 0;}
X = m->X + (m->tab[itemp2].width);
if(m->tab[itemp2].CSR.bit.CE)
{
LCD_Write_short(X ,m->Y+itemp1 , &(m->tab[itemp2].value) , itemp3);
itemp1 ++ ;
}
itemp2 ++;
itemp2 %= m->number;
itemp4 ++ ;
if( itemp4 >= menu.number )
{break;}
}
}
/*************************************************
Function: //
Description: //
Input: //
//
Output: //
Return: //
Others: //
*************************************************/
void MENU_up ( Menu_list* m )
{
unsigned char itemp;
unsigned char itemp1;
itemp = GET_focusite ( m);
itemp1 = m->line_number -1;
if( itemp > itemp1)
{
m->focus = m->top;
MENU_redraw ( m );
}
else
{
if(itemp == 0)
{
do
{
if(0 == m->top)
{m->top = m->number -1;}
else
{ m->top -- ;}
}
while (0 == m->tab[m->top].CSR.bit.CE ); //是否可见
m->focus = m->top;
MENU_redraw ( m );
}
else
{
do
{
if(0 == m->focus)
{m->focus = m->number -1;}
else
{m->focus -- ;}
}
while (0 == m->tab[m->top].CSR.bit.CE ); //是否可见
}
}
}
/*************************************************
Function: //
Description: //
Input: //
//
Output: //
Return: //
Others: //
*************************************************/
void MENU_down ( Menu_list* m )
{
unsigned char itemp;
unsigned char itemp1;
itemp = GET_focusite ( m);
itemp1 = m->line_number -1;
if( itemp >= itemp1)
{
MENU_down_lab1 :
m->top ++;
m->top %= m->number;
if(m->tab[m->top].CSR.bit.CE)
{
m->focus = m->top +itemp1;
MENU_down_lab3 :
m->focus %= m->number;
if(m->tab[m->focus].CSR.bit.CE)
{
MENU_redraw ( m );
}
else
{
m->focus ++;
goto MENU_down_lab3;
}
}
else
goto MENU_down_lab1;
}
else
{
MENU_down_lab2 :
m->focus ++;
m->focus %= m->number;
if(0 == m->tab[m->focus].CSR.bit.CE)
{
goto MENU_down_lab2;
}
}
}


相关文档
相关文档 最新文档