//字模数组 extern root_canshu[],root_shuju[],root_zhuangtai[],exit[],zhongduan[],fukong[],celiangdian0[], celiangdian1[],celiangdian2[],celiangdian3[],zhongduanzhuangtai[],zhuzhantongxin[],fuhekongzhi[] ,tongxincanshu[],gaojingcanshu[],duankoucanshu[],biaoxieyi[],jibencanshu[],gongkongcanshu[] ,diankongcanshu[],dianzijishu[],biaojitongxin[],gongkongfangan[],diankongfangan[],diannengliang[], xuliang[],shunshiliang[]; //-------------------------------------------------------------------------- //------------------------------------------- // 子界面编号数组 //------------------------------------------- unsigned char Son0[1] ={1}; //对应界面0 unsigned char Son1[4] ={2,3,4,0}; unsigned char Son2[5] ={5,6,7,7,1}; unsigned char Son3[5] ={8,8,8,8,1}; unsigned char Son4[5] ={0,0,0,0,1}; unsigned char Son5[5] ={0,0,0,0,2}; unsigned char Son6[5] ={0,0,0,0,2}; unsigned char Son7[3] ={0,0,2}; unsigned char Son8[4] ={0,0,0,3};
//----------------------------------------------------------- //各个界面显示内容指针数组 //----------------------------------------------------------- unsigned char *menu_char0[1]={dianzijishu}; unsigned char *menu_char1[4]={root_canshu,root_shuju,root_zhuangtai,exit}; //各元素枝指向对应行显示内容的字模数组 unsigned char *menu_char2[5]={zhongduan,fukong,celiangdian0,celiangdian1,exit}; unsigned char *menu_char3[5]={celiangdian0,celiangdian1,celiangdian2,celiangdian3,exit}; unsigned char *menu_char4[5]={zhongduanzhuangtai,zhuzhantongxin,biaojitongxin,fuhekongzhi,exit}; unsigned char *menu_char5[5]={tongxincanshu,gaojingcanshu,duankoucanshu,biaoxieyi,exit}; unsigned char *menu_char6[5]={jibencanshu,gongkongcanshu,diankongcanshu,gongkongfangan,exit}; unsigned char *menu_char7[3]={jibencanshu,gaojingcanshu,exit}; unsigned char *menu_char8[4]={diannengliang,xuliang,shunshiliang,exit};
//----------------------------------------------------------- // 各行文字数量 //----------------------------------------------------------- unsigned char char_num0[1] = {4}; unsigned char char_num1[4] = {2,2,2,2}; unsigned char char_num2[5] = {2,2,4,4,2}; unsigned char char_num3[5] = {4,4,4,4,2}; unsigned char char_num4[5] = {4,4,4,4,2}; unsigned char char_num5[5] = {4,4,4,3,2}; unsigned char char_num6[5] = {4,4,4,4,2}; unsigned char char_num7[3] = {4,4,2}; unsigned char char_num8[4] = {3,2,3,2}; //----------------------------------------------------------- struct INTERFACE { //当前行号对应子菜单编号,和反显行,对于不需要反显示的无意义 //行号在每次进入新的界面时清零 unsigned char MAX_ROW_NUM; //该界面的最大行数 unsigned char **MENU_char; //指向一指针数组,该数组元素为指向各行显示内容的指针 unsigned char *Son_num; //指向当前界面子界面编号数组的指针 unsigned char *Row_num; //指向当前界面各行文字数量数组的指针 };
struct INTERFACE Windows[9] = { {1,menu_char0,Son0,char_num0}, {4,menu_char1,Son1,char_num1}, {5,menu_char2,Son2,char_num2}, {5,menu_char3,Son3,char_num3}, {5,menu_char4,Son4,char_num4}, {5,menu_char5,Son5,char_num5}, {5,menu_char6,Son6,char_num6}, {3,menu_char7,Son7,char_num7}, {4,menu_char8,Son8,char_num8} }; //-----------------------------------------函数-------------------------------------------------- void Display_char(unsigned char,unsigned char ,unsigned char *,unsigned char); void Display_row(unsigned char,unsigned char ,unsigned char ,unsigned char *,unsigned char); void Display_window(unsigned char,unsigned char);
//############################################################### //我这里只是核心的数据结构 //字模数组可以自己提取 //最下边的函数可以自己实现:分别是显示一个字,显示一行,显示一个界面 //*—####################################################### //---------------------------------------------------------------------------------------------------------- // 叶子只有退出键 // 根只有进入键 // 叶子和根的显示内容如果要随时间变化,可以在时间中断中刷新显示内容或控制 控制是否现实,或直接在其中显示 //------------------------------------------------------------------------------------------------------------ #include"lcd.h" #include"menu.h" extern tongxincanshu[],signal[],ant[],smallchar[],Net[],Point[],num[],dianzijishu[],youxiangongsi[],henan[],yuanwei[]; extern unsigned char Interface_num,Old_Interface_num; //当前显示界面在界面数组中的位置 extern unsigned char Row_num,Old_Row_num; void LCD_WrCHr16x16(unsigned char,unsigned char,unsigned char *,unsigned char,unsigned char); void LCD_Clr(void); void test(void); //-----------------------指示液晶显示时间------------------------------ unsigned char time[4]={1,0,1,4}; //小时十位,小时个位,分十位,分个位 unsigned char date[6]={0,7,0,6,0,1}; //年十位,年个位,月十位,月个位,日十位,日个位 unsigned char signel=5; unsigned char uf1[] = {0xff}; /******************************************************************************* * * 函 数 名: void Display_char() * 功能描述: row:所在行 char_num: 第几个字符 **:是否反显示 s:所在字模数组 * 函数说明: 显示时需要row和char_num确定显示坐标,由char_num在字模数组中确定要显示的内容 * 调用函数: * 全局变量: * 输 入: char_num的取值范围是0~7 * 返 回: * 设 计 者: 日期: * 修 改 者: 日期: * 版 本: ********************************************************************************/ /* void Display_char(unsigned char row,unsigned char char_num,unsigned char *s,unsigned char **) { unsigned char i; if(char_num <= 2) { LCD_Write_ComL(0xb8|(row*2)); LCD_Write_ComL(0x40|(char_num*16 + 16)); for(i=0;i<=15;i++) LCD_Write_DatL(*(s + char_num*32)); } else if((char_num > 2)&&(char_num <=5)) { LCD_Write_ComR(0xb8|(row*2)); LCD_Write_ComR(0x40|(char_num*16 + 16)); for(i=0;i<=15;i++) LCD_Write_DatR(*(s + char_num*32)); } } */ /******************************************************************************* * * 函 数 名: void Display_row * 功能描述: 显示编号为row_num的行,**:是否反显示 *s: 要显示的内容 * 函数说明: 显示时一行内容对应一个指针 * 调用函数: * 全局变量: * 输 入: row_num的取值范围是0~3 * 返 回: * 设 计 者: 日期: * 修 改 者: 日期: * 版 本: ********************************************************************************/ void Display_row(unsigned char begin_row,unsigned char end_row,unsigned char row_num,unsigned char *s,unsigned char **) { unsigned char i; for(i = begin_row;i <= end_row;i ++) //该行空余的地方用0x00填充 { LCD_WrCHr16x16(row_num,i*2,s,i,**); //第一行显示16x16中文字符 // Display_char(row_num,i,s,**); // } }
/******************************************************************************* * * 函 数 名: void Display_window(unsigned char win_num,unsigned char sel_row) * 功能描述: 显示编号为win_num的窗口,当前选中行为sel_row。 * 函数说明: * 调用函数: Display_row; * 全局变量: * 输 入: 界面号 行号 指向显示内容的指针 * 返 回: * 设 计 者: 日期: * 修 改 者: 日期: * 版 本: ********************************************************************************/
void Display_window(unsigned char win_num,unsigned char sel_row) { unsigned char i,add,j; add = sel_row/4; //sel_row的编号从0开始,在这里得到显示第几屏的内容 j = Windows[win_num].MAX_ROW_NUM - 1; if((j>=4)&&(sel_row < add*4))j=3; // else if((j>=4)&&(sel_row >= add*4))j = Windows[win_num].MAX_ROW_NUM - 1 - add*4; for(i=0;i<=j;i++) //@@@@@@@@@@@@@ { if(i == (sel_row % 4)) Display_row(0,*(Windows[win_num].Row_num + i) - 1,i*2,*(Windows[win_num].MENU_char + add*4 + i),1); //反显示 else Display_row(0,*(Windows[win_num].Row_num + i) - 1,i*2,*(Windows[win_num].MENU_char + add*4 + i),0); //其它行不反显示 } } //------------------------------------------------------------------- void get_key(void) { if(bit_is_clear(PINB,0)) { DelayMs(10); if(bit_is_clear(PINB,0)) { Old_Interface_num = Interface_num; //@@@@@@@@@@@@@@@ Interface_num = *(Windows[Interface_num].Son_num + Row_num); //暂时试验用 // Row_num = Old_Row_num = 0; // //@@@@@@@@@@@@@@@ } while(bit_is_clear(PINB,0)); DelayMs(10); while(bit_is_clear(PINB,0)); } if(bit_is_clear(PINB,1)) { DelayMs(10); // if(bit_is_clear(PINB,1)) // { Old_Row_num = Row_num; // Row_num ++; if(Row_num > (Windows[Interface_num].MAX_ROW_NUM - 1)) Row_num = 0; } while(bit_is_clear(PINB,1)); DelayMs(10); while(bit_is_clear(PINB,1)); } } void Display(void) { if(Old_Row_num != Row_num) { Old_Row_num = Row_num; LCD_Clr(); } Display_window(Interface_num,Row_num); if(Old_Interface_num != Interface_num) { Old_Interface_num = Interface_num; Old_Row_num = 0; Row_num = 0; LCD_Clr(); if(Interface_num == 0) { test(); } else { Display_window(Interface_num,Row_num); } } } |