标题:
STM32单片机LCD12864结构体菜单程序
[打印本页]
作者:
sr861126
时间:
2022-5-11 14:27
标题:
STM32单片机LCD12864结构体菜单程序
12864结构体菜单
51hei.png
(69.7 KB, 下载次数: 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}; //发送buffer
u8 BUFFER[8]={0};//接收buffer
u8 bf_number; //接收字节指示
void (*current_operation_index)(); //执行当前显示函数
typedef struct
{
u8 current; //当前状态号
u8 up;//向上翻索引号
u8 down;//向下翻索引号
u8 enter;//确认索引号
u8 num_ent;//编码器确认键
void (*current_operation)(); //要执行的函数
} 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(); // 初始系统时钟,3.5版本库在启动文件里已经把时钟初始为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)();//执行当前操作函数
}
}
}
复制代码
Keil代码下载(仅供参考):
液晶菜单.7z
(647.55 KB, 下载次数: 145)
2022-5-11 14:26 上传
点击文件名下载附件
下载积分: 黑币 -5
作者:
REESE_LGH
时间:
2022-12-14 21:42
谢谢分享,正需要这个屏幕资料,在这个论坛真的能学到很多东西
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1