LCD点阵液晶多级菜单设计

it2022-05-05  442

设计思路:

LCD的显示分为有按键触发的信息区显示和无需按键触发固定栏显示。利用静态链表数据结构,制作成一张数组形式的表,配置好所有的菜单。LCD软件层次图如下所示: LCD层次图

数据结构

LCD显示结构体:

typedef struct { uint8 aContent[CONTENT_LEN]; /* display content */ uint8 nLen; /* content length */ uint8 columST; /* the start address in column direction (0--154) */ uint8 lineST; /* the start address in line direction (0--152) */ uint8 size; /* the size of word (16 or 12) */ uint8 type; /* the display type (0: in new screen other:in old screen) */ } lcd_word_t; typedef struct { uint8 aItem[MAX_MENU_ITEMS][MAX_SHOW_LEN + 1]; uint8 nItemNum; uint8 nCurrAddr; uint8 nLastAddr; uint8 nInvertAddr; /* means in one screen (1 -- MAX_ITEMS_SCRN) */ uint8 nMoveFlag; /* whether the Item has moved */ uint8 nSize; } lcd_menu_item_t; LCD菜单结构体: typedef struct { uint8 nCurrIndex; /* current menu Index */ uint8 noKeyIndex; /* press "cancel" key and its operate */ uint8 okKeyIndex; /* press "enter" key and its operate */ uint16 Numbers; uint16 LastItem; uint16 CurrItem; uint8 InverItem; /* note the current Item in the screen */ uint8 space; uint8SonOperate; uint8 nBottomFlag; /* 2--new type, 用于翻屏*/ uint8 nInitFlag; void (*menuFunction)(); /* current function */ } lcd_menu_lsit_t;

LCD所有的菜单内容显示,通过lcd_menu_lsit_t结构体配置成一张静态链表:

lcd_menu_lsit_t lcd_menu[100] = { //Main Menu {MENU_MAIN, MENU_MAIN, MENU_MAIN, 1, 1, 1, 1, 1, 1, 0, 0, menu_MainMenu}, };

2.3.4.接口 按键接口: 接口函数 函数说明

static uint8 key_read(void); 读取按键值 static void key_init(void); 按键处理模块初始化

LCD通用接口 : 接口函数 函数说明

void LCD_DrawFrame(uint8 LnST, uint8 LnEND, uint8 ClmST, uint8 ClmEND) 画矩形图 void LCD_ShowPictures(uint8 *picture, uint8 LnSize, uint8 ClumSize,uint8 LineST, uint8 ColumST, uint8 opt); 显示图片 uint8 LCD_DisplayWord(lcd_word_t lcd_word,uint8 opt); 显示字符串 uint16 LCD_DisplayData(uint8 *aData, uint16 nLen, uint8 nSize, uint8 nIntvl, uint8 InvtFlag, uint8 opt); 显示任意长度内容 void LCD_DisplayMenu(lcd_menu_item_t *Item); 显示菜单 void LCD_InvertDisplay(uint8 LnST, uint8 LnEND, uint8 ClmST, uint8 ClmEND); 反显 uint8LCD_GetContent(uint8 *aBuf, uint8 type, uint8 size, uint8 *aContent); 从字符库获取数据显示 void LCD_DisplayLayer(uint8 opt); 显示刷新

菜单操作接口: 接口函数 函数说明

void menu_MenuContrl(uint8 key) 菜单操作,根据输入按键显示对应菜单内容。

最新回复(0)