Nokia_5110显示屏STM32F103x开发
2021-11-22 来源:eefocus
一、显示屏模块选型
1.1 Nokia 5110 LCD(蓝屏) 液晶屏模块
1.2 简介:
1.3 显示屏 显示分成 5 行
二、程序开发
这里有两个,关于 显示 数据的 数组,我把放在两个不同的 头文件 中,一个为了方便显示英文,一个为了方便显示中文。英文操作简单一点。
2.1 main函数
程序链接:
https://download.csdn.net/download/qq_37788383/11887775
#include 'stm32f10x.h'
#include 'delay.h'
#include 'sys.h'
#include 'usart.h'
#include 'nokia_5110.h'
char juli[8]='-----.-';
double temp = 23563.7;
int main(void)
{
delay_init(); //延时函数初始化
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //设置NVIC中断分组2:2位抢占优先级,2位响应优先级
LCD_init();
//显示有三种方式 x为0-83,y为0-5
// 1) LCD_write_english_string(0,0,'LOCATION OK '); 显示 英文 字母
// 2) LCD_write_string(0,2,juli,7); 显示 数字,阿拉伯字母
// 3) LCD_write_chinese_string(X, Y,ch_with,num,line,row); 显示 汉字 (不大好用啊)
/*******************************************
*目的:在LCD上显示汉字
*参数:X、Y -- 显示汉字的起始X、Y坐标
* ch_with -- 汉字点阵的宽度
* num -- 显示汉字的个数
* line -- 汉字点阵数组中的起始行数
* row -- 汉字显示的行间距
*******************************************/
while(1)
{
juli[0]=(int)temp%100000/10000+0x30;
juli[1]=(int)temp%10000/1000+0x30;
juli[2]=(int)temp%1000/100+0x30;
juli[3]=(int)temp%100/10+0x30;
juli[4]=(int)temp%10+0x30;
juli[6]=(int)(temp*10)%10+0x30;
LCD_write_string(0,2,juli,7); //显示 数字,阿拉伯字母
LCD_write_english_string(0,0,'LOCATION OK '); //显示 英文 字母
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
2.2 模块.h文件
#ifndef __NOKIA5110_H_
#define __NOKIA5110_H_
#include 'sys.h'
#define SCLK PBout(1) //串行时钟线
#define SDIN PBout(12) //串行数据线
#define LCD_DC PBout(13) //模式选择: 1 写数据,0 写指令
#define LCD_CE PBout(14) //芯片使能
#define LCD_RST PBout(15) //复位,低电平有效
#define LCD_BL PBout(0) //背光
void LCD_init(void);
void LCD_clear(void);
void LCD_write_english_string(unsigned char X,unsigned char Y,char *s);
void LCD_write_string(unsigned char X,unsigned char Y,char *s,char length);
void LCD_write_chinese_string(unsigned char X, unsigned char Y,
unsigned char ch_with,unsigned char num,
unsigned char line,unsigned char row);
void LCD_draw_bmp_pixel(unsigned char X,unsigned char Y,unsigned char *map,
unsigned char Pix_x,unsigned char Pix_y);
#endif
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
2.3 英文显示头文件
// 6 x 8 font
// 1 pixel space at left and bottom
// index = ASCII - 32
const unsigned char font6x8[][6] =
{
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // sp
{ 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00 }, // !
{ 0x00, 0x00, 0x07, 0x00, 0x07, 0x00 }, // '
{ 0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14 }, // #
{ 0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12 }, // $
{ 0x00, 0x62, 0x64, 0x08, 0x13, 0x23 }, // %
{ 0x00, 0x36, 0x49, 0x55, 0x22, 0x50 }, // &
{ 0x00, 0x00, 0x05, 0x03, 0x00, 0x00 }, // '
{ 0x00, 0x00, 0x1c, 0x22, 0x41, 0x00 }, // (
{ 0x00, 0x00, 0x41, 0x22, 0x1c, 0x00 }, // )
{ 0x00, 0x14, 0x08, 0x3E, 0x08, 0x14 }, // *
{ 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08 }, // +
{ 0x00, 0x00, 0x00, 0xA0, 0x60, 0x00 }, // ,
{ 0x00, 0x08, 0x08, 0x08, 0x08, 0x08 }, // -
{ 0x00, 0x00, 0x60, 0x60, 0x00, 0x00 }, // .
{ 0x00, 0x20, 0x10, 0x08, 0x04, 0x02 }, // /
{ 0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E }, // 0
{ 0x00, 0x00, 0x42, 0x7F, 0x40, 0x00 }, // 1
{ 0x00, 0x42, 0x61, 0x51, 0x49, 0x46 }, // 2
{ 0x00, 0x21, 0x41, 0x45, 0x4B, 0x31 }, // 3
{ 0x00, 0x18, 0x14, 0x12, 0x7F, 0x10 }, // 4
{ 0x00, 0x27, 0x45, 0x45, 0x45, 0x39 }, // 5
{ 0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30 }, // 6
{ 0x00, 0x01, 0x71, 0x09, 0x05, 0x03 }, // 7
{ 0x00, 0x36, 0x49, 0x49, 0x49, 0x36 }, // 8
{ 0x00, 0x06, 0x49, 0x49, 0x29, 0x1E }, // 9
{ 0x00, 0x00, 0x36, 0x36, 0x00, 0x00 }, // :
{ 0x00, 0x00, 0x56, 0x36, 0x00, 0x00 }, // ;
{ 0x00, 0x08, 0x14, 0x22, 0x41, 0x00 }, // <
{ 0x00, 0x14, 0x14, 0x14, 0x14, 0x14 }, // =
{ 0x00, 0x00, 0x41, 0x22, 0x14, 0x08 }, // >
{ 0x00, 0x02, 0x01, 0x51, 0x09, 0x06 }, // ?
{ 0x00, 0x32, 0x49, 0x59, 0x51, 0x3E }, // @
{ 0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C }, // A
{ 0x00, 0x7F, 0x49, 0x49, 0x49, 0x36 }, // B
{ 0x00, 0x3E, 0x41, 0x41, 0x41, 0x22 }, // C
{ 0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C }, // D
{ 0x00, 0x7F, 0x49, 0x49, 0x49, 0x41 }, // E
{ 0x00, 0x7F, 0x09, 0x09, 0x09, 0x01 }, // F
{ 0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A }, // G
{ 0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F }, // H
{ 0x00, 0x00, 0x41, 0x7F, 0x41, 0x00 }, // I
{ 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01 }, // J
{ 0x00, 0x7F, 0x08, 0x14, 0x22, 0x41 }, // K
{ 0x00, 0x7F, 0x40, 0x40, 0x40, 0x40 }, // L
{ 0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F }, // M
{ 0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F }, // N
{ 0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E }, // O
{ 0x00, 0x7F, 0x09, 0x09, 0x09, 0x06 }, // P
{ 0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E }, // Q
{ 0x00, 0x7F, 0x09, 0x19, 0x29, 0x46 }, // R
{ 0x00, 0x46, 0x49, 0x49, 0x49, 0x31 }, // S
{ 0x00, 0x01, 0x01, 0x7F, 0x01, 0x01 }, // T
{ 0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F }, // U
{ 0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F }, // V
{ 0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F }, // W
{ 0x00, 0x63, 0x14, 0x08, 0x14, 0x63 }, // X
{ 0x00, 0x07, 0x08, 0x70, 0x08, 0x07 }, // Y
{ 0x00, 0x61, 0x51, 0x49, 0x45, 0x43 }, // Z
{ 0x00, 0x00, 0x7F, 0x41, 0x41, 0x00 }, // [
{ 0x00, 0x55, 0x2A, 0x55, 0x2A, 0x55 }, // 55
{ 0x00, 0x00, 0x41, 0x41, 0x7F, 0x00 }, // ]
{ 0x00, 0x04, 0x02, 0x01, 0x02, 0x04 }, // ^
{ 0x00, 0x40, 0x40, 0x40, 0x40, 0x40 }, // _
{ 0x00, 0x00, 0x01, 0x02, 0x04, 0x00 }, // '
{ 0x00, 0x20, 0x54, 0x54, 0x54, 0x78 }, // a
{ 0x00, 0x7F, 0x48, 0x44, 0x44, 0x38 }, // b
{ 0x00, 0x38, 0x44, 0x44, 0x44, 0x20 }, // c
{ 0x00, 0x38, 0x44, 0x44, 0x48, 0x7F }, // d
{ 0x00, 0x38, 0x54, 0x54, 0x54, 0x18 }, // e
{ 0x00, 0x08, 0x7E, 0x09, 0x01, 0x02 }, // f
{ 0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C }, // g
{ 0x00, 0x7F, 0x08, 0x04, 0x04, 0x78 }, // h
{ 0x00, 0x00, 0x44, 0x7D, 0x40, 0x00 }, // i
{ 0x00, 0x40, 0x80, 0x84, 0x7D, 0x00 }, // j
{ 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00 }, // k
{ 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00 }, // l
{ 0x00, 0x7C, 0x04, 0x18, 0x04, 0x78 }, // m
{ 0x00, 0x7C, 0x08, 0x04, 0x04, 0x78 }, // n
{ 0x00, 0x38, 0x44, 0x44, 0x44, 0x38 }, // o
{ 0x00, 0xFC, 0x24, 0x24, 0x24, 0x18 }, // p
{ 0x00, 0x18, 0x24, 0x24, 0x18, 0xFC }, // q
{ 0x00, 0x7C, 0x08, 0x04, 0x04, 0x08 }, // r
{ 0x00, 0x48, 0x54, 0x54, 0x54, 0x20 }, // s
{ 0x00, 0x04, 0x3F, 0x44, 0x40, 0x20 }, // t
{ 0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C }, // u
{ 0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C }, // v
{ 0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C }, // w
{ 0x00, 0x44, 0x28, 0x10, 0x28, 0x44 }, // x
{ 0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C }, // y
{ 0x00, 0x44, 0x64, 0x54, 0x4C, 0x44 }, // z
{ 0x14, 0x14, 0x14, 0x14, 0x14, 0x14 } // horiz lines
};
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
2.4 中文显示 头文件
const unsigned char write_chinese[][24]={
//测
{0x89,0xF2,0x00,0xFF,0x01,0xF9,0xFF,0x00,0xFC,0x00,0xFF,0x00,0x00,0x07,0x04,0x04,0x02,0x01,0x02,0x04,0x01,0x04,0x07,0x00},
//试
{0x11,0xF6,0x00,0x04,0x24,0xE4,0x24,0x24,0xFF,0x05,0x06,0x00,0x00,0x07,0x02,0x01,0x02,0x03,0x01,0x01,0x01,0x02,0x07,0x00},
//程
{0x8A,0x6A,0xFF,0x49,0x20,0xAF,0xA9,0xE9,0xA9,0xAF,0x20,0x00,0x01,0x00,0x07,0x00,0x04,0x04,0x04,0x07,0x04,0x04,0x04,0x00},
//序
{0x00,0xFE,0x42,0x4A,0x4A,0x5B,0xEA,0x5A,0x4A,0xC2,0x42,0x00,0x06,0x01,0x00,0x00,0x04,0x04,0x07,0x00,0x00,0x00,0x00,0x00},
//电
{0x00,0xFC,0x94,0x94,0x94,0xFF,0x94,0x94,0x94,0xFE,0x04,0x00,0x00,0x01,0x00,0x00,0x00,0x03,0x04,0x04,0x04,0x04,0x06,0x00},
//子
{0x20,0x21,0x21,0x21,0x21,0xF9,0x29,0x25,0x23,0x31,0x20,0x00,0x00,0x00,0x00,0x04,0x04,0x07,0x00,0x00,0x00,0x00,0x00,0x00},
//制
{0x18,0xD6,0x54,0xFF,0x54,0x56,0xD4,0x00,0xFC,0x00,0xFF,0x00,0x00,0x03,0x00,0x07,0x00,0x02,0x03,0x00,0x04,0x04,0x07,0x00},
//作
{0x10,0x08,0xFC,0x13,0x08,0x04,0xFF,0x24,0x24,0x24,0x04,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x07,0x01,0x01,0x01,0x01,0x00},
//杂
{0x40,0x62,0x52,0xCA,0x47,0xE2,0x42,0xDE,0x50,0x50,0x58,0x00,0x04,0x02,0x01,0x04,0x04,0x07,0x00,0x00,0x01,0x02,0x04,0x00},
//志
{0x04,0xA4,0x24,0xA4,0x24,0xBF,0x24,0x24,0x24,0xA6,0x04,0x00,0x02,0x01,0x00,0x07,0x04,0x04,0x05,0x04,0x06,0x00,0x03,0x00},
//社
{0x84,0x44,0xF5,0x2E,0x40,0x10,0x10,0xFF,0x10,0x10,0x10,0x00,0x00,0x00,0x07,0x00,0x04,0x04,0x04,0x07,0x04,0x04,0x04,0x00},
};
————————————————
版权声明:本文为CSDN博主「Bruce_lp」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_37788383/article/details/90576756
- LG Display 成功开发出全球首款可扩展 50% 的可拉伸显示屏
- 分析采用GD32 MCU设计LCD显示屏背光驱动方案的实用性和应用
- 车载显示屏技术架构升级!Local dimming技术应用加速,TDDI需求上涨
- 触摸式OLED显示屏有望重新定义汽车用户界面
- LED屏幕/显示屏常见故障处理手段
- 彩色LED旋转显示屏的设计
- 电动汽车充电器新标配:触摸显示屏,可靠耐用是关键
- 汽车挡风玻璃的神奇变身:3D 显示屏黑科技来袭
- 哈曼车载显示屏产品(Ready Display, Ready Vision QVUE)
- LG Display 宣布业界率先量产串联 OLED 笔记本显示屏:寿命翻倍、厚度减少四成