ILI9325驱动代码,可以测试
单片机源程序如下:
- /******************** STM32模板 ***************************
- * 文 件 名 : main.c
- * 作 者 : 伟哥
- * 创建日期 : 2012.8.3
- * 描 述 : 主文件
- * 版 本 : V1.0
- * 历史记录 : 暂无
- ***********************************************************/
- /*--------------------------- 头文件包含 --------------------------------------*/
- /********************************************************************************
- A_Item1 A_Item2
- / \ / \
- B_Item1 B_Item2(B1Item) B_Item3 B_Item4(B2Item)
- / \ | / \ |
- C_Item1 C_Item2 C_Item3 C_Item4 C_Item5 C_Item6
- (C1_Item) (C2_Item) (C3_Item) (C4_Item)
- ********************************************************************************/
- #include "systeminit.h"
- int main(void)
- {
-
- SystemInit(); //配置系统主频为72MHz
- ILI9325_Init(); //彩屏初始化
- ILI9325_Clear(WHITE); //将屏刷为白色
- ConfigExtInterrupt(); //配置中断
- ConfigKeyPort(); //配置按键端口
-
- DispCrtMenu(A_Item); //显示初级菜单
- while(1)
- {
- DelayMs(2000); //--演示效果
- }
- }
复制代码- #include "menu.h"
- /**********************************************
- struct MenuItem
- {
- char MenuDpth; //当前菜单深度
- unsigned char *str; //菜单字符串数组
- unsigned int x; //字符串显示的X轴坐标
- unsigned int y; //字符串显示的Y轴坐标
- char MenuCount; //当前菜单索引数目
- char MenuIdex; //当前菜单索引
- void(*Subs)(); //菜单确定时需要执行的功能的函数指针(可以为空)
- void(*Back)(); //菜单返回时需要执行的功能的函数指针(可以为空)
- // void(*Run)(); //在菜单的某层一直要运行的函数指针
- struct MenuItem *ChildrenMenus; //孩子指针(表明选择该菜单项后,跳转到哪个子菜单去)
- struct MenuItem *ParentMenus; //父指针(表明选择返回后,跳转到哪个菜单去)
- };
- **********************************************/
- /*全局变量声明*/
- char ListCount = 1;
- char br;
- struct MenuItem A_Item[] =
- {
- {1,"A_Item1",10,20,2,1,Go_MenuB1,NULL,B1_Item,NULL},
- {1,"A_Item2",10,60,2,1,Go_MenuB2,NULL,B2_Item,NULL}
- };
- struct MenuItem B1_Item[] =
- {
- {2,"B_Item1",10,20,2,1,Go_MenuC1,Go_MenuA,C1_Item,A_Item},
- {2,"B_Item2",10,60,2,1,Go_MenuC2,Go_MenuA,C2_Item,A_Item}
- };
- struct MenuItem B2_Item[] =
- {
- {2,"B_Item3",10,20,2,1,Go_MenuC3,Go_MenuA,C3_Item,A_Item},
- {2,"B_Item4",10,60,2,1,Go_MenuC4,Go_MenuA,C4_Item,A_Item}
- };
- struct MenuItem C1_Item[] =
- {
- {3,"C_Item1",10,20,2,1,NULL,Go_MenuB1,NULL,B1_Item},
- {3,"c_Item2",10,60,2,1,NULL,Go_MenuB1,NULL,B1_Item}
- };
- struct MenuItem C2_Item[] =
- {
- { 3,"C_Item3",10,20,1,1,NULL,Go_MenuB1,NULL,B1_Item}
- };
- struct MenuItem C3_Item[] =
- {
- { 3,"C_Item4",10,20,2,1,NULL,Go_MenuB2,NULL,B2_Item},
- { 3,"C_Item5",10,60,2,1,NULL,Go_MenuB2,NULL,B2_Item}
- };
- struct MenuItem C4_Item[] =
- {
- { 3,"C_Item6",10,20,1,1,NULL,Go_MenuB2,NULL,B2_Item}
- };
- void Go_MenuA(void)
- {
- LCD_DispStr(A_Item[0].str,A_Item[0].x,A_Item[0].y,LARGE,BLACK,WHITE);
- LCD_DispStr(A_Item[1].str,A_Item[1].x,A_Item[1].y,LARGE,BLACK,WHITE);
- }
- void Go_MenuB1(void)
- {
- LCD_DispStr(B1_Item[0].str,B1_Item[0].x,B1_Item[0].y,LARGE,BLACK,WHITE);
- LCD_DispStr(B1_Item[1].str,B1_Item[1].x,B1_Item[1].y,LARGE,BLACK,WHITE);
- }
- void Go_MenuB2(void)
- {
- LCD_DispStr(B2_Item[0].str,B2_Item[0].x,B2_Item[0].y,LARGE,BLACK,WHITE);
- LCD_DispStr(B2_Item[1].str,B2_Item[1].x,B2_Item[1].y,LARGE,BLACK,WHITE);
- }
- void Go_MenuC1(void)
- {
- LCD_DispStr(C1_Item[0].str,C1_Item[0].x,C1_Item[0].y,LARGE,BLACK,WHITE);
- LCD_DispStr(C1_Item[1].str,C1_Item[1].x,C1_Item[1].y,LARGE,BLACK,WHITE);
- }
- void Go_MenuC2(void)
- {
-
- LCD_DispStr(C2_Item[0].str,C2_Item[0].x,C2_Item[0].y,LARGE,BLACK,WHITE);
- }
- void Go_MenuC3(void)
- {
-
- LCD_DispStr(C3_Item[0].str,C3_Item[0].x,C3_Item[0].y,LARGE,BLACK,WHITE);
- LCD_DispStr(C3_Item[1].str,C3_Item[1].x,C3_Item[1].y,LARGE,BLACK,WHITE);
- }
- void Go_MenuC4(void)
- {
- LCD_DispStr(C4_Item[0].str,C4_Item[0].x,C4_Item[0].y,LARGE,BLACK,WHITE);
- }
- //显示当前菜单函数
- void DispCrtMenu(struct MenuItem* menu) //传递的是结构体指针
- {
- char i;
- unsigned int color = WHITE; //color初始化为白色
- br = (*menu).MenuCount;
- (*menu).MenuIndex = ListCount;
- ClearScreen(WHITE); //将屏刷为白色
- LCD_Fill_Rect(0, 12 + 32*((*menu).MenuIndex-1), 239, 44+32*((*menu).MenuIndex-1), BLUE);
-
- for(i=0;i<br;i++) //显示出所有菜单
- {
- if((*menu).MenuIndex == i+1)
- {
-
- color = BLUE; //颜色变为蓝色
- }
- LCD_DispStr((*(menu+i)).str,10,20+32*i,LARGE,BLACK,color);
- color = WHITE;
- }
-
- }
复制代码
Keil代码下载,仅供参考:
多级菜单.7z
(434.05 KB, 下载次数: 89)
|