这个是07年,我管这个时期叫做:
【新石器时代】
这是07年中的一个研发项目,是一个电力抄表终端,下面代码是他的液晶显示屏(128x64)的菜单部分。
代码有点长,先看头文件:
menu.h
#include"display_leaf.h" //定义了显示叶子的函数
//字模数组
extern root_canshu[],root_shuju[],root_zhuangtai[],exit[],zhongduancanshu[],fukongcanshu[],celiangdian0[],
celiangdian0canshu[],celiangdian1canshu[],
celiangdian1[],celiangdian2[],celiangdian3[],zhongduanzhuangtai[],zhuzhantongxin[],fuhekongzhi[]
,tongxincanshu[],gaojingcanshu[],duankoucanshu[],biaoxieyi[],jibencanshu[],gongkongcanshu[]
,diankongcanshu[],dianzijishu[],biaojitongxin[],gongkongfangan[],diankongfangan[],diannengliang[],
xuliang[],shunshiliang[],huanyingshiyong[],celiangdian0shuju[],celiangdian1shuju[],celiangdian2shuju[],celiangdian3shuju[];
//--------------------------------------------------------------------------
//-------------------------------------------
// 子界面编号数组
//-------------------------------------------
unsigned char Son0[1] ={1}; //对应界面0
unsigned char Son1[4] ={2,3,4,0};
unsigned char Son2[5] ={5,6,7,8,1};
unsigned char Son3[5] ={9,10,11,12,1};
unsigned char Son4[5] ={55,56,57,58,1};
unsigned char Son5[5] ={31,32,33,34,2};
unsigned char Son6[5] ={35,36,37,38,2};
unsigned char Son7[3] ={39,40,2};
unsigned char Son8[3] ={41,42,2};
unsigned char Son9[4] ={43,44,45,3};
unsigned char Son10[4] ={46,47,48,3};
unsigned char Son11[4] ={49,50,51,3};
unsigned char Son12[4] ={52,53,54,3};
//*****************
//以下是增加的叶子
//*****************
//-----------------------------------------------------------
//各个界面显示内容指针数组
//-----------------------------------------------------------
unsigned char *menu_char0[1]={huanyingshiyong};
unsigned char *menu_char1[4]={root_canshu,root_shuju,root_zhuangtai,exit}; //各元素枝指向对应行显示内容的字模数组
unsigned char *menu_char2[5]={zhongduancanshu,fukongcanshu,celiangdian0canshu,celiangdian1canshu,exit};
unsigned char *menu_char3[5]={celiangdian0shuju,celiangdian1shuju,celiangdian2shuju,celiangdian3shuju,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[3]={jibencanshu,gaojingcanshu,exit};
unsigned char *menu_char9[4]={diannengliang,xuliang,shunshiliang,exit};
unsigned char *menu_char10[4]={diannengliang,xuliang,shunshiliang,exit};
unsigned char *menu_char11[4]={diannengliang,xuliang,shunshiliang,exit};
unsigned char *menu_char12[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] = {4,4,6,6,2};
unsigned char char_num3[5] = {6,6,6,6,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[3] = {4,4,2};
unsigned char char_num9[4] = {3,2,3,2};
unsigned char char_num10[4] = {3,2,3,2};
unsigned char char_num11[4] = {3,2,3,2};
unsigned char char_num12[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[13] =
{
{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},
{3,menu_char8,Son8,char_num8},
{4,menu_char9,Son9,char_num9},
{4,menu_char10,Son10,char_num10},
{4,menu_char11,Son11,char_num11},
{4,menu_char12,Son12,char_num12}
};
//叶子节点的数据结构
struct LEAF
{
unsigned char Father_num; //该叶子要返回的父亲界面号
void (*Display_leaf)(); //指向该叶子的显示函数的指针
};
struct LEAF leaf[28] =
{
{5,display_tongxincanshu}, {5,display_gaojingcanshu},
{5,display_duankoucanshu}, {5,display_biaoxieyi},
{6,display_jibencanshu}, {6,display_gongkongcanshu},
{6,display_diankongcanshu}, {6,display_gongkongfangan},
{7,display_cljibencanshu}, {7,display_clgaojingcanshu},
{8,display_cljibencanshu}, {8,display_clgaojingcanshu},
{9,display_diannengliang}, {9,display_xuliang},
{9,display_shunshiliang}, {10,display_diannengliang},
{10,display_xuliang}, {10,display_shunshiliang},
{11,display_diannengliang}, {11,display_xuliang},
{11,display_shunshiliang}, {12,display_diannengliang},
{12,display_xuliang}, {12,display_shunshiliang},
{4,display_zhongduanzhuangtai}, {4,display_zhuzhantongxinzhuangtai},
{4,display_biaojitongxinzhuangtai},{4,display_fuhekongzhizhuangtai}
};
//-----------------------------------------函数--------------------------------------------------
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);
// |