|
楼主 |
发表于 2008-5-2 02:24:15
|
显示全部楼层
程序:
#include"5110LCD.h"
#include"english_6x8.h"
#include"chinese.h"
#define menuNum 21 //子菜单数
#define flagPoint_X 4 //指示圆的X坐标
#define flagPoint_Y 19 //指示圆的起始Y坐标
#define flagPointAdd 14 //指示圆Y坐标步进
#define scroll_X 70 //滚动条的X坐标
#define scroll_Height 7 //滚动条的高度
#define scroll_Y 18 //滚动条的起始Y坐标
#define scrollEnd_Y 44 //滚动条的终止Y坐标
#define scrollAdd ((scrollEnd_Y - scroll_Height - scroll_Y + 1) / (menuNum - 1)) //滚动条步进,这里由于不能整除,所以要手动调整
#define menu_Y1 19 //菜单位置1
#define menu_Y2 33 //菜单位置2
unsigned char scrollLocation = 0;
void(*nemuListTable[][2])(unsigned char)=
{
&menuList1,&menuList2,
&menuList3,&menuList4,
&menuList5,&menuList6,
&menuList7,&menuList8,
&menuList9,&menuList10,
&menuList11,&menuList12,
&menuList13,&menuList14,
&menuList15,&menuList16,
&menuList17,&menuList18,
&menuList19,&menuList20,
&menuList21,&menuList22
};
void mainDraw(void)
{
DrawRectangleLine(0,0,83,47,1);
DrawRectangleLine(2,17,67,45,1);
DrawRectangleLine(69,17,81,45,1);
DrawLine(1,15,82,15);
DrawGraphics(Hzk[0],12,12,17,2);
DrawGraphics(Hzk[1],12,12,29,2);
DrawGraphics(Hzk[2],12,12,41,2);
DrawGraphics(Hzk[3],12,12,53,2);
menuList1(menu_Y1);
menuList2(menu_Y2);
DrawArea(scroll_X,scroll_Y,12,scroll_Height);
DrawGraphics(Hzk[5],12,12,flagPoint_X,flagPoint_Y);
}
void menuList1(unsigned char nenu_Y)//子菜单,因为以后使用中内容可能不同,所以下面的菜单名重写了
{
DrawGraphics(Hzk[4],12,12,16,nenu_Y);
DrawGraphics(Hzk[0],12,12,28,nenu_Y);
DrawGraphics(Hzk[1],12,12,40,nenu_Y);
DrawGraphics(font6x8[17],6,8,52,nenu_Y + 4);
}
void menuList2(unsigned char nenu_Y)
{
DrawGraphics(Hzk[4],12,12,16,nenu_Y);
DrawGraphics(Hzk[0],12,12,28,nenu_Y);
DrawGraphics(Hzk[1],12,12,40,nenu_Y);
DrawGraphics(font6x8[18],6,8,52,nenu_Y + 4);
}
void menuList3(unsigned char nenu_Y)
{
DrawGraphics(Hzk[4],12,12,16,nenu_Y);
DrawGraphics(Hzk[0],12,12,28,nenu_Y);
DrawGraphics(Hzk[1],12,12,40,nenu_Y);
DrawGraphics(font6x8[19],6,8,52,nenu_Y + 4);
}
void menuList4(unsigned char nenu_Y)
{
DrawGraphics(Hzk[4],12,12,16,nenu_Y);
DrawGraphics(Hzk[0],12,12,28,nenu_Y);
DrawGraphics(Hzk[1],12,12,40,nenu_Y);
DrawGraphics(font6x8[20],6,8,52,nenu_Y + 4);
}
void menuList5(unsigned char nenu_Y)
{
DrawGraphics(Hzk[4],12,12,16,nenu_Y);
DrawGraphics(Hzk[0],12,12,28,nenu_Y);
DrawGraphics(Hzk[1],12,12,40,nenu_Y);
DrawGraphics(font6x8[21],6,8,52,nenu_Y + 4);
}
void menuList6(unsigned char nenu_Y)
{
DrawGraphics(Hzk[4],12,12,16,nenu_Y);
DrawGraphics(Hzk[0],12,12,28,nenu_Y);
DrawGraphics(Hzk[1],12,12,40,nenu_Y);
DrawGraphics(font6x8[22],6,8,52,nenu_Y + 4);
}
void menuList7(unsigned char nenu_Y)
{
DrawGraphics(Hzk[4],12,12,16,nenu_Y);
DrawGraphics(Hzk[0],12,12,28,nenu_Y);
DrawGraphics(Hzk[1],12,12,40,nenu_Y);
DrawGraphics(font6x8[23],6,8,52,nenu_Y + 4);
}
void menuList8(unsigned char nenu_Y)
{
DrawGraphics(Hzk[4],12,12,16,nenu_Y);
DrawGraphics(Hzk[0],12,12,28,nenu_Y);
DrawGraphics(Hzk[1],12,12,40,nenu_Y);
DrawGraphics(font6x8[24],6,8,52,nenu_Y + 4);
}
void menuList9(unsigned char nenu_Y)
{
DrawGraphics(Hzk[4],12,12,16,nenu_Y);
DrawGraphics(Hzk[0],12,12,28,nenu_Y);
DrawGraphics(Hzk[1],12,12,40,nenu_Y);
DrawGraphics(font6x8[25],6,8,52,nenu_Y + 4);
}
void menuList10(unsigned char nenu_Y)
{
DrawGraphics(Hzk[4],12,12,16,nenu_Y);
DrawGraphics(Hzk[0],12,12,28,nenu_Y);
DrawGraphics(Hzk[1],12,12,40,nenu_Y);
DrawGraphics(font6x8[17],6,8,52,nenu_Y + 4);
DrawGraphics(font6x8[16],6,8,58,nenu_Y + 4);
}
void menuList11(unsigned char nenu_Y)
{
DrawGraphics(Hzk[4],12,12,16,nenu_Y);
DrawGraphics(Hzk[0],12,12,28,nenu_Y);
DrawGraphics(Hzk[1],12,12,40,nenu_Y);
DrawGraphics(font6x8[17],6,8,52,nenu_Y + 4);
DrawGraphics(font6x8[17],6,8,58,nenu_Y + 4);
}
void menuList12(unsigned char nenu_Y)
{
DrawGraphics(Hzk[4],12,12,16,nenu_Y);
DrawGraphics(Hzk[0],12,12,28,nenu_Y);
DrawGraphics(Hzk[1],12,12,40,nenu_Y);
DrawGraphics(font6x8[17],6,8,52,nenu_Y + 4);
DrawGraphics(font6x8[18],6,8,58,nenu_Y + 4);
}
void menuList13(unsigned char nenu_Y)
{
DrawGraphics(Hzk[4],12,12,16,nenu_Y);
DrawGraphics(Hzk[0],12,12,28,nenu_Y);
DrawGraphics(Hzk[1],12,12,40,nenu_Y);
DrawGraphics(font6x8[17],6,8,52,nenu_Y + 4);
DrawGraphics(font6x8[19],6,8,58,nenu_Y + 4);
}
void menuList14(unsigned char nenu_Y)
{
DrawGraphics(Hzk[4],12,12,16,nenu_Y);
DrawGraphics(Hzk[0],12,12,28,nenu_Y);
DrawGraphics(Hzk[1],12,12,40,nenu_Y);
DrawGraphics(font6x8[17],6,8,52,nenu_Y + 4);
DrawGraphics(font6x8[20],6,8,58,nenu_Y + 4);
}
void menuList15(unsigned char nenu_Y)
{
DrawGraphics(Hzk[4],12,12,16,nenu_Y);
DrawGraphics(Hzk[0],12,12,28,nenu_Y);
DrawGraphics(Hzk[1],12,12,40,nenu_Y);
DrawGraphics(font6x8[17],6,8,52,nenu_Y + 4);
DrawGraphics(font6x8[21],6,8,58,nenu_Y + 4);
}
void menuList16(unsigned char nenu_Y)
{
DrawGraphics(Hzk[4],12,12,16,nenu_Y);
DrawGraphics(Hzk[0],12,12,28,nenu_Y);
DrawGraphics(Hzk[1],12,12,40,nenu_Y);
DrawGraphics(font6x8[17],6,8,52,nenu_Y + 4);
DrawGraphics(font6x8[22],6,8,58,nenu_Y + 4);
}
void menuList17(unsigned char nenu_Y)
{
DrawGraphics(Hzk[4],12,12,16,nenu_Y);
DrawGraphics(Hzk[0],12,12,28,nenu_Y);
DrawGraphics(Hzk[1],12,12,40,nenu_Y);
DrawGraphics(font6x8[17],6,8,52,nenu_Y + 4);
DrawGraphics(font6x8[23],6,8,58,nenu_Y + 4);
}
void menuList18(unsigned char nenu_Y)
{
DrawGraphics(Hzk[4],12,12,16,nenu_Y);
DrawGraphics(Hzk[0],12,12,28,nenu_Y);
DrawGraphics(Hzk[1],12,12,40,nenu_Y);
DrawGraphics(font6x8[17],6,8,52,nenu_Y + 4);
DrawGraphics(font6x8[24],6,8,58,nenu_Y + 4);
}
void menuList19(unsigned char nenu_Y)
{
DrawGraphics(Hzk[4],12,12,16,nenu_Y);
DrawGraphics(Hzk[0],12,12,28,nenu_Y);
DrawGraphics(Hzk[1],12,12,40,nenu_Y);
DrawGraphics(font6x8[17],6,8,52,nenu_Y + 4);
DrawGraphics(font6x8[25],6,8,58,nenu_Y + 4);
}
void menuList20(unsigned char nenu_Y)
{
DrawGraphics(Hzk[4],12,12,16,nenu_Y);
DrawGraphics(Hzk[0],12,12,28,nenu_Y);
DrawGraphics(Hzk[1],12,12,40,nenu_Y);
DrawGraphics(font6x8[18],6,8,52,nenu_Y + 4);
DrawGraphics(font6x8[16],6,8,58,nenu_Y + 4);
}
void menuList21(unsigned char nenu_Y)
{
DrawGraphics(Hzk[4],12,12,16,nenu_Y);
DrawGraphics(Hzk[0],12,12,28,nenu_Y);
DrawGraphics(Hzk[1],12,12,40,nenu_Y);
DrawGraphics(font6x8[18],6,8,52,nenu_Y + 4);
DrawGraphics(font6x8[17],6,8,58,nenu_Y + 4);
}
void menuList22(unsigned char nenu_Y)
{
ClearArea((flagPoint_X + 11),(nenu_Y - 1),52,(menu_Y2 - menu_Y1 - 1));
}
void scrollAction(unsigned char Direction)
{
if(Direction == 0)
{
if(scrollLocation < (menuNum - 1))
{
ClearArea(scroll_X,(scroll_Y + scrollAdd * scrollLocation),11,scroll_Height);
scrollLocation ++;
DrawArea(scroll_X,(scroll_Y + scrollAdd * scrollLocation),11,scroll_Height);
}
}
else if(Direction == 1)
{
if(scrollLocation > 0)
{
ClearArea(scroll_X,(scroll_Y + scrollAdd * scrollLocation),11,scroll_Height);
scrollLocation --;
DrawArea(scroll_X,(scroll_Y + scrollAdd * scrollLocation),11,scroll_Height);
}
}
}
void secleteMenu(void)
{
unsigned char start_Y;
if((scrollLocation%2) == 0)
{
start_Y = menu_Y1 - 1;
}
else
{
start_Y = menu_Y2 - 1;
}
GetFanBit((flagPoint_X - 1),start_Y,64,(menu_Y2 - menu_Y1 - 1));
}
void flagPoint(void)
{
if((scrollLocation%2) == 0)
{
ClearArea(flagPoint_X,(flagPoint_Y + flagPointAdd),12,12);
DrawGraphics(Hzk[5],12,12,flagPoint_X,flagPoint_Y);
}
else
{
ClearArea(flagPoint_X,flagPoint_Y,12,12);
DrawGraphics(Hzk[5],12,12,flagPoint_X,(flagPoint_Y + flagPointAdd));
}
}
void updateMenuList(void)
{
unsigned char menuListLocation;
menuListLocation = (((scrollLocation+1)/2)+((scrollLocation+1)%2));
ClearArea((flagPoint_X + 11),(menu_Y1 - 1),52,(menu_Y2 - menu_Y1 - 1));
ClearArea((flagPoint_X + 11),(menu_Y2 - 1),52,(menu_Y2 - menu_Y1 - 1));
(*nemuListTable[menuListLocation - 1][0])(menu_Y1);
(*nemuListTable[menuListLocation - 1][1])(menu_Y2);
} |
|