標題:
STM32單片機LCD12864結構體菜單程序
[打印本頁]
作者:
sr861126
時間:
2022-5-11 14:27
標題:
STM32單片機LCD12864結構體菜單程序
12864結構體菜單
51hei.png
(69.7 KB, 下載次數(shù): 45)
下載附件
2022-5-11 17:59 上傳
單片機源程序如下:
#include "stm32f10x.h"
#include"stm32f10x_conf.h"
extern u8 stm[]; //外部定義nova logo
extern u8 lan[],ya[],cai[],ji1[],zhong[],duan[];
extern u8 qing[],dian[],zi[];
u16 count=0;
u8 func_index=0;
u8 buffer[15]={'
,'N','O','V','A',0x00}; //發(fā)送buffer
u8 BUFFER[8]={0};//接收buffer
u8 bf_number; //接收字節(jié)指示
void (*current_operation_index)(); //執(zhí)行當前顯示函數(shù)
typedef struct
{
u8 current; //當前狀態(tài)號
u8 up;//向上翻索引號
u8 down;//向下翻索引號
u8 enter;//確認索引號
u8 num_ent;//編碼器確認鍵
void (*current_operation)(); //要執(zhí)行的函數(shù)
} key_table;
key_table table[32]=
{
{0,0,1,3,0,(*fun1)},
{1,0,2,7,1,(*fun2)}, //菜單元素列表
{2,1,2,11,2,(*fun3)},
{3,3,4,0,3,(*fun4)},
{4,3,5,0,4,(*fun5)},
{5,4,6,0,5,(*fun6)},
{6,5,6,0,6,(*fun7)},
{7,7,8,15,7,(*fun8)},
{8,7,9,19,8,(*fun9)},
{9,8,10,23,9,(*fun10)},
{10,9,10,1,10,(*fun11)},
{11,11,12,28,11,(*fun12)},
{12,11,13,31,12,(*fun13)},
{13,12,14,13,13,(*fun14)},
{14,13,14,2,14,(*fun15)},
{15,15,16,15,25,(*fun16)},
{16,15,17,16,25,(*fun17)},
{17,16,18,17,25,(*fun18)},
{18,17,18,7,18,(*fun19)},
{19,19,20,19,26,(*fun20)},
{20,19,21,20,26,(*fun21)},
{21,20,22,21,26,(*fun22)},
{22,21,22,8,22,(*fun23)},
{23,23,24,23,27,(*fun24)},
{24,23,24,9,24,(*fun25)},
{25,7,7,7,7,(*fun26)},
{26,8,8,8,8,(*fun27)},
{27,9,9,9,9,(*fun28)},
{28,28,29,30,28,(*fun29)},
{29,28,29,30,29,(*fun30)},
{30,11,11,11,11,(*fun31)},
{31,12,12,12,12,(*fun32)}
};
int main(void)
{ u8 num;
//SystemInit(); // 初始系統(tǒng)時鐘,3.5版本庫在啟動文件里已經(jīng)把時鐘初始為72MHZ ,不需要自己初始化了。
//LED_Init(); //led 初始化
key_Init(); //按鍵初始化
delay_init(36); //延時初始化
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //中斷分組
SPI_GPIO_Config(); //SPI端口初始化
//EXTIX_Init(); //外部中斷初始化
spi_init(); // SPI初始化
usart_init();
/* config the led */
ENC_Init(); //定時器4編碼器模式初始化
//Timerx_Init( 0,0);
// WKUP_Init(); // 待機模式初始化 ,不注釋掉,得按WAKP來開機
delay_ms(5);
initial_lcd();//液晶初始化
clear_screen(); //clear all dots
Lcdwritecom(0xb0); //設置頁地址
//GPIO_ResetBits(GPIOB,GPIO_Pin_1);
while(1)
{
blue_init();
// BL_PW_OFF ; //高電平關斷藍牙模塊電壓
Lcdwritecom(0xaf); /*開顯示*/
clear_screen();
delay_ms(20);
display_128x64(stm);
delay_ms(1000);
delay_ms(1000);
delay_ms(1000);
delay_ms(1000);
clear_screen(); //clear all dots
display_graphic_16x16(4,32,qing);
display_graphic_16x16(4,48,qing);
display_graphic_16x16(4,64,dian);
display_graphic_16x16(4,80,zi);
delay_ms(1000);
delay_ms(1000);
delay_ms(1000);
delay_ms(1000);
clear_screen(); //clear all dots
display_graphic_16x16(4,80,zhong);
display_graphic_16x16(4,16,lan);
display_graphic_16x16(4,32,ya);
display_graphic_16x16(4,48,cai);
display_graphic_16x16(4,64,ji1);
display_graphic_16x16(4,80,zhong);
display_graphic_16x16(4,96,duan);
delay_ms(1000);
delay_ms(1000);
clear_screen(); //clear all dots
while(1)
{
num=KEY_Scan();//得到鍵值
if(num)
{
switch(num)
{
case 1:
func_index=table[func_index].up; break; //向上翻
case 2:
func_index=table[func_index].down; break; //向下翻
case 3:
func_index=table[func_index].enter; break; //確認
case 4:
func_index=table[func_index].num_ent; break;
}
clear_screen(); //clear all dots
}
current_operation_index=table[func_index].current_operation;
(*current_operation_index)();//執(zhí)行當前操作函數(shù)
}
}
}
復制代碼
Keil代碼下載(僅供參考):
液晶菜單.7z
(647.55 KB, 下載次數(shù): 145)
2022-5-11 14:26 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
作者:
REESE_LGH
時間:
2022-12-14 21:42
謝謝分享,正需要這個屏幕資料,在這個論壇真的能學到很多東西
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1