当前位置:   article > 正文

STM32——0.96寸OLED显示屏模块(1)_oled显示屏模块介绍

oled显示屏模块介绍

前言

       在学习stm32f103c8t6的工程中,0.96寸OLED显示屏是基本绕不开的学习内容,在这里给大家分享我常用的代码,因为确实发现csdn上有很多半截的代码,所以在这里开源所有程序,同时后续我也会继续更新取模等教程,帮助大家更好的使用。希望我的分享能够帮到大家!

一、模块介绍

       我采用的0.96寸OLED模块,分辨率为128*64,采用SSD1306芯片,4针脚IIC通信,支持3.3V和5V的工作电压,如果大家不放心,我这里附上淘宝链接。其余介绍甚至原理网上一搜一大把,大家可以根据需要去学习。
       链接:【淘宝】https://m.tb.cn/h.5yEz3Pr?tk=T7pjWL0iVXI ZH4920 「0.96寸oled屏12864液晶显示屏模块ssd1306串口并口i2c接口4针模组」点击链接直接打开 或者 淘宝搜索直接打开

二、硬件设计

1.硬件清单

0.96寸OLED显示屏模块、stm32f103c8t6最小系统板、杜邦线、STlink烧录器

2.硬件接线

PS:我的程序采用软件模拟IIC,所以基本除了PB3、PB4、PA15(他们用作SWI)之外的引脚都可以使用,此处以PB8、PB9为例。

OLEDstm32
GNDGND
VCC3.3V
SCLPB8
SDAPB9

3.硬件实物图

三、软件设计

1.OLED.c

此文件无需修改,所有的初始化配置在对应的.h文件中修改即可
如需添加其他功能的函数,从网上寻找加入.c和.h文件即可

  1. /*
  2. 0.96寸OLED
  3. 1306驱动 软件IIC
  4. 1.c8t6一般用不了PA15、PB3、PB4(用作SW)
  5. 2.3.3V-5V供电
  6. 3.使用:引用oled.h
  7. 初始化OLED_Init();
  8. */
  9. #include "stm32f10x.h"
  10. #include "OLED_Font.h"
  11. #include "OLED.h"
  12. /*引脚配置*/
  13. #define OLED_W_SCL(x) GPIO_WriteBit(SCL_GPIO_Port, SCL_GPIO_Pin, (BitAction)(x))
  14. #define OLED_W_SDA(x) GPIO_WriteBit(SDA_GPIO_Port, SDA_GPIO_Pin, (BitAction)(x))
  15. /*引脚初始化*/
  16. void OLED_I2C_Init(void)
  17. {
  18. GPIO_InitTypeDef GPIO_InitStructure;
  19. RCC_APB2PeriphClockCmd(SDA_GPIO_CLK|SCL_GPIO_CLK, ENABLE);
  20. GPIO_InitStructure.GPIO_Mode = OLED_GPIO_Mode;
  21. GPIO_InitStructure.GPIO_Speed = OLED_GPIO_Speed;
  22. GPIO_InitStructure.GPIO_Pin = SCL_GPIO_Pin;
  23. GPIO_Init(SCL_GPIO_Port, &GPIO_InitStructure);
  24. GPIO_InitStructure.GPIO_Pin = SDA_GPIO_Pin;
  25. GPIO_Init(SDA_GPIO_Port, &GPIO_InitStructure);
  26. OLED_W_SCL(1);
  27. OLED_W_SDA(1);
  28. }
  29. /**
  30. * @brief I2C开始
  31. * @param 无
  32. * @retval 无
  33. */
  34. void OLED_I2C_Start(void)
  35. {
  36. OLED_W_SDA(1);
  37. OLED_W_SCL(1);
  38. OLED_W_SDA(0);
  39. OLED_W_SCL(0);
  40. }
  41. /**
  42. * @brief I2C停止
  43. * @param 无
  44. * @retval 无
  45. */
  46. void OLED_I2C_Stop(void)
  47. {
  48. OLED_W_SDA(0);
  49. OLED_W_SCL(1);
  50. OLED_W_SDA(1);
  51. }
  52. /**
  53. * @brief I2C发送一个字节
  54. * @param Byte 要发送的一个字节
  55. * @retval 无
  56. */
  57. void OLED_I2C_SendByte(uint8_t Byte)
  58. {
  59. uint8_t i;
  60. for (i = 0; i < 8; i++)
  61. {
  62. OLED_W_SDA(Byte & (0x80 >> i));
  63. OLED_W_SCL(1);
  64. OLED_W_SCL(0);
  65. }
  66. OLED_W_SCL(1); //额外的一个时钟,不处理应答信号
  67. OLED_W_SCL(0);
  68. }
  69. /**
  70. * @brief OLED写命令
  71. * @param Command 要写入的命令
  72. * @retval 无
  73. */
  74. void OLED_WriteCommand(uint8_t Command)
  75. {
  76. OLED_I2C_Start();
  77. OLED_I2C_SendByte(0x78); //从机地址
  78. OLED_I2C_SendByte(0x00); //写命令
  79. OLED_I2C_SendByte(Command);
  80. OLED_I2C_Stop();
  81. }
  82. /**
  83. * @brief OLED写数据
  84. * @param Data 要写入的数据
  85. * @retval 无
  86. */
  87. void OLED_WriteData(uint8_t Data)
  88. {
  89. OLED_I2C_Start();
  90. OLED_I2C_SendByte(0x78); //从机地址
  91. OLED_I2C_SendByte(0x40); //写数据
  92. OLED_I2C_SendByte(Data);
  93. OLED_I2C_Stop();
  94. }
  95. /**
  96. * @brief OLED设置光标位置
  97. * @param Y 以左上角为原点,向下方向的坐标,范围:0~7
  98. * @param X 以左上角为原点,向右方向的坐标,范围:0~127
  99. * @retval 无
  100. */
  101. void OLED_SetCursor(uint8_t Y, uint8_t X)
  102. {
  103. OLED_WriteCommand(0xB0 | Y); //设置Y位置
  104. OLED_WriteCommand(0x10 | ((X & 0xF0) >> 4)); //设置X位置低4位
  105. OLED_WriteCommand(0x00 | (X & 0x0F)); //设置X位置高4位
  106. }
  107. /**
  108. * @brief OLED清屏
  109. * @param 无
  110. * @retval 无
  111. */
  112. void OLED_Clear(void)
  113. {
  114. uint8_t i, j;
  115. for (j = 0; j < 8; j++)
  116. {
  117. OLED_SetCursor(j, 0);
  118. for(i = 0; i < 128; i++)
  119. {
  120. OLED_WriteData(0x00);
  121. }
  122. }
  123. }
  124. /**
  125. * @brief OLED显示一个文字
  126. * @param Line 行位置,范围:1~4
  127. * @param Column 列位置,范围:1~16
  128. * @param no 要显示的一个文字,文字在数组HZK
  129. * @retval 无
  130. */
  131. void OLED_ShowCHinese(uint8_t Line, uint8_t Column, uint8_t no)
  132. {
  133. u8 t,adder=0;
  134. OLED_SetCursor((Line - 1) * 2, (Column - 1) * 8);
  135. for(t=0;t<16;t++)
  136. {
  137. OLED_WriteData(Hzk[2*no][t]);
  138. adder+=1;
  139. }
  140. OLED_SetCursor((Line - 1) * 2 + 1, (Column - 1) * 8);
  141. for(t=0;t<16;t++)
  142. {
  143. OLED_WriteData(Hzk[2*no+1][t]);
  144. adder+=1;
  145. }
  146. }
  147. /**
  148. * @brief OLED显示一个字符
  149. * @param Line 行位置,范围:1~4
  150. * @param Column 列位置,范围:1~16
  151. * @param Char 要显示的一个字符,范围:ASCII可见字符
  152. * @retval 无
  153. */
  154. void OLED_ShowChar(uint8_t Line, uint8_t Column, char Char)
  155. {
  156. uint8_t i;
  157. OLED_SetCursor((Line - 1) * 2, (Column - 1) * 8); //设置光标位置在上半部分
  158. for (i = 0; i < 8; i++)
  159. {
  160. OLED_WriteData(OLED_F8x16[Char - ' '][i]); //显示上半部分内容
  161. }
  162. OLED_SetCursor((Line - 1) * 2 + 1, (Column - 1) * 8); //设置光标位置在下半部分
  163. for (i = 0; i < 8; i++)
  164. {
  165. OLED_WriteData(OLED_F8x16[Char - ' '][i + 8]); //显示下半部分内容
  166. }
  167. }
  168. /**
  169. * @brief OLED显示字符串
  170. * @param Line 起始行位置,范围:1~4
  171. * @param Column 起始列位置,范围:1~16
  172. * @param String 要显示的字符串,范围:ASCII可见字符
  173. * @retval 无
  174. */
  175. void OLED_ShowString(uint8_t Line, uint8_t Column, char *String)
  176. {
  177. uint8_t i;
  178. for (i = 0; String[i] != '\0'; i++)
  179. {
  180. OLED_ShowChar(Line, Column + i, String[i]);
  181. }
  182. }
  183. /**
  184. * @brief OLED次方函数
  185. * @retval 返回值等于X的Y次方
  186. */
  187. uint32_t OLED_Pow(uint32_t X, uint32_t Y)
  188. {
  189. uint32_t Result = 1;
  190. while (Y--)
  191. {
  192. Result *= X;
  193. }
  194. return Result;
  195. }
  196. /**
  197. * @brief OLED显示数字(十进制,正数)
  198. * @param Line 起始行位置,范围:1~4
  199. * @param Column 起始列位置,范围:1~16
  200. * @param Number 要显示的数字,范围:0~4294967295
  201. * @param Length 要显示数字的长度,范围:1~10
  202. * @retval 无
  203. */
  204. void OLED_ShowNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length)
  205. {
  206. uint8_t i;
  207. for (i = 0; i < Length; i++)
  208. {
  209. OLED_ShowChar(Line, Column + i, Number / OLED_Pow(10, Length - i - 1) % 10 + '0');
  210. }
  211. }
  212. /**
  213. * @brief OLED显示数字(十进制,带符号数)
  214. * @param Line 起始行位置,范围:1~4
  215. * @param Column 起始列位置,范围:1~16
  216. * @param Number 要显示的数字,范围:-2147483648~2147483647
  217. * @param Length 要显示数字的长度,范围:1~10
  218. * @retval 无
  219. */
  220. void OLED_ShowSignedNum(uint8_t Line, uint8_t Column, int32_t Number, uint8_t Length)
  221. {
  222. uint8_t i;
  223. uint32_t Number1;
  224. if (Number >= 0)
  225. {
  226. OLED_ShowChar(Line, Column, '+');
  227. Number1 = Number;
  228. }
  229. else
  230. {
  231. OLED_ShowChar(Line, Column, '-');
  232. Number1 = -Number;
  233. }
  234. for (i = 0; i < Length; i++)
  235. {
  236. OLED_ShowChar(Line, Column + i + 1, Number1 / OLED_Pow(10, Length - i - 1) % 10 + '0');
  237. }
  238. }
  239. /**
  240. * @brief OLED显示数字(十六进制,正数)
  241. * @param Line 起始行位置,范围:1~4
  242. * @param Column 起始列位置,范围:1~16
  243. * @param Number 要显示的数字,范围:0~0xFFFFFFFF
  244. * @param Length 要显示数字的长度,范围:1~8
  245. * @retval 无
  246. */
  247. void OLED_ShowHexNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length)
  248. {
  249. uint8_t i, SingleNumber;
  250. for (i = 0; i < Length; i++)
  251. {
  252. SingleNumber = Number / OLED_Pow(16, Length - i - 1) % 16;
  253. if (SingleNumber < 10)
  254. {
  255. OLED_ShowChar(Line, Column + i, SingleNumber + '0');
  256. }
  257. else
  258. {
  259. OLED_ShowChar(Line, Column + i, SingleNumber - 10 + 'A');
  260. }
  261. }
  262. }
  263. /**
  264. * @brief OLED显示数字(二进制,正数)
  265. * @param Line 起始行位置,范围:1~4
  266. * @param Column 起始列位置,范围:1~16
  267. * @param Number 要显示的数字,范围:0~1111 1111 1111 1111
  268. * @param Length 要显示数字的长度,范围:1~16
  269. * @retval 无
  270. */
  271. void OLED_ShowBinNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length)
  272. {
  273. uint8_t i;
  274. for (i = 0; i < Length; i++)
  275. {
  276. OLED_ShowChar(Line, Column + i, Number / OLED_Pow(2, Length - i - 1) % 2 + '0');
  277. }
  278. }
  279. /**
  280. * @brief OLED初始化
  281. * @param 无
  282. * @retval 无
  283. */
  284. void OLED_Init(void)
  285. {
  286. uint32_t i, j;
  287. for (i = 0; i < 1000; i++) //上电延时
  288. {
  289. for (j = 0; j < 1000; j++);
  290. }
  291. OLED_I2C_Init(); //端口初始化
  292. OLED_WriteCommand(0xAE); //关闭显示
  293. OLED_WriteCommand(0xD5); //设置显示时钟分频比/振荡器频率
  294. OLED_WriteCommand(0x80);
  295. OLED_WriteCommand(0xA8); //设置多路复用率
  296. OLED_WriteCommand(0x3F);
  297. OLED_WriteCommand(0xD3); //设置显示偏移
  298. OLED_WriteCommand(0x00);
  299. OLED_WriteCommand(0x40); //设置显示开始行
  300. OLED_WriteCommand(0xA1); //设置左右方向,0xA1正常 0xA0左右反置
  301. OLED_WriteCommand(0xC8); //设置上下方向,0xC8正常 0xC0上下反置
  302. OLED_WriteCommand(0xDA); //设置COM引脚硬件配置
  303. OLED_WriteCommand(0x12);
  304. OLED_WriteCommand(0x81); //设置对比度控制
  305. OLED_WriteCommand(0xCF);
  306. OLED_WriteCommand(0xD9); //设置预充电周期
  307. OLED_WriteCommand(0xF1);
  308. OLED_WriteCommand(0xDB); //设置VCOMH取消选择级别
  309. OLED_WriteCommand(0x30);
  310. OLED_WriteCommand(0xA4); //设置整个显示打开/关闭
  311. OLED_WriteCommand(0xA6); //设置正常/倒转显示
  312. OLED_WriteCommand(0x8D); //设置充电泵
  313. OLED_WriteCommand(0x14);
  314. OLED_WriteCommand(0xAF); //开启显示
  315. OLED_Clear(); //OLED清屏
  316. }

2.OLED.h

修改引脚及对应时钟即可

  1. #ifndef __OLED_H
  2. #define __OLED_H
  3. #include "sys.h"
  4. #define OLED_GPIO_Speed GPIO_Speed_50MHz
  5. #define OLED_GPIO_Mode GPIO_Mode_Out_OD
  6. #define SDA_GPIO_Pin GPIO_Pin_9
  7. #define SCL_GPIO_Pin GPIO_Pin_8
  8. #define SDA_GPIO_Port GPIOB
  9. #define SCL_GPIO_Port GPIOB
  10. #define SDA_GPIO_CLK RCC_APB2Periph_GPIOB
  11. #define SCL_GPIO_CLK RCC_APB2Periph_GPIOB
  12. void OLED_Init(void);
  13. void OLED_Clear(void);
  14. void OLED_ShowChar(uint8_t Line, uint8_t Column, char Char);
  15. void OLED_ShowString(uint8_t Line, uint8_t Column, char *String);
  16. void OLED_ShowNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length);
  17. void OLED_ShowSignedNum(uint8_t Line, uint8_t Column, int32_t Number, uint8_t Length);
  18. void OLED_ShowHexNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length);
  19. void OLED_ShowBinNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length);
  20. void OLED_ShowCHinese(u8 x,u8 y,u8 no);
  21. #endif

3.OLED_Font.h

本程序里有一些汉字和符号的取模,大家可以根据自己的需要去取模,后续我也会继续出教程哒

  1. #ifndef __OLED_FONT_H
  2. #define __OLED_FONT_H
  3. #include "sys.h"
  4. /*OLED字模库,宽8像素,高16像素*/
  5. const uint8_t OLED_F8x16[][16]=
  6. {
  7. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  8. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0
  9. 0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,
  10. 0x00,0x00,0x00,0x33,0x30,0x00,0x00,0x00,//! 1
  11. 0x00,0x10,0x0C,0x06,0x10,0x0C,0x06,0x00,
  12. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//" 2
  13. 0x40,0xC0,0x78,0x40,0xC0,0x78,0x40,0x00,
  14. 0x04,0x3F,0x04,0x04,0x3F,0x04,0x04,0x00,//# 3
  15. 0x00,0x70,0x88,0xFC,0x08,0x30,0x00,0x00,
  16. 0x00,0x18,0x20,0xFF,0x21,0x1E,0x00,0x00,//$ 4
  17. 0xF0,0x08,0xF0,0x00,0xE0,0x18,0x00,0x00,
  18. 0x00,0x21,0x1C,0x03,0x1E,0x21,0x1E,0x00,//% 5
  19. 0x00,0xF0,0x08,0x88,0x70,0x00,0x00,0x00,
  20. 0x1E,0x21,0x23,0x24,0x19,0x27,0x21,0x10,//& 6
  21. 0x10,0x16,0x0E,0x00,0x00,0x00,0x00,0x00,
  22. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//' 7
  23. 0x00,0x00,0x00,0xE0,0x18,0x04,0x02,0x00,
  24. 0x00,0x00,0x00,0x07,0x18,0x20,0x40,0x00,//( 8
  25. 0x00,0x02,0x04,0x18,0xE0,0x00,0x00,0x00,
  26. 0x00,0x40,0x20,0x18,0x07,0x00,0x00,0x00,//) 9
  27. 0x40,0x40,0x80,0xF0,0x80,0x40,0x40,0x00,
  28. 0x02,0x02,0x01,0x0F,0x01,0x02,0x02,0x00,//* 10
  29. 0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,
  30. 0x01,0x01,0x01,0x1F,0x01,0x01,0x01,0x00,//+ 11
  31. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  32. 0x80,0xB0,0x70,0x00,0x00,0x00,0x00,0x00,//, 12
  33. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  34. 0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,//- 13
  35. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  36. 0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,//. 14
  37. 0x00,0x00,0x00,0x00,0x80,0x60,0x18,0x04,
  38. 0x00,0x60,0x18,0x06,0x01,0x00,0x00,0x00,/// 15
  39. 0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,
  40. 0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,//0 16
  41. 0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,
  42. 0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//1 17
  43. 0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,
  44. 0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,//2 18
  45. 0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,
  46. 0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,//3 19
  47. 0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,
  48. 0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,//4 20
  49. 0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,
  50. 0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,//5 21
  51. 0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,
  52. 0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,//6 22
  53. 0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,
  54. 0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,//7 23
  55. 0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,
  56. 0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,//8 24
  57. 0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,
  58. 0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,//9 25
  59. 0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,
  60. 0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,//: 26
  61. 0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,
  62. 0x00,0x00,0x80,0x60,0x00,0x00,0x00,0x00,//; 27
  63. 0x00,0x00,0x80,0x40,0x20,0x10,0x08,0x00,
  64. 0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x00,//< 28
  65. 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,
  66. 0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00,//= 29
  67. 0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,
  68. 0x00,0x20,0x10,0x08,0x04,0x02,0x01,0x00,//> 30
  69. 0x00,0x70,0x48,0x08,0x08,0x08,0xF0,0x00,
  70. 0x00,0x00,0x00,0x30,0x36,0x01,0x00,0x00,//? 31
  71. 0xC0,0x30,0xC8,0x28,0xE8,0x10,0xE0,0x00,
  72. 0x07,0x18,0x27,0x24,0x23,0x14,0x0B,0x00,//@ 32
  73. 0x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,
  74. 0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20,//A 33
  75. 0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,
  76. 0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00,//B 34
  77. 0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,
  78. 0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00,//C 35
  79. 0x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,
  80. 0x20,0x3F,0x20,0x20,0x20,0x10,0x0F,0x00,//D 36
  81. 0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,
  82. 0x20,0x3F,0x20,0x20,0x23,0x20,0x18,0x00,//E 37
  83. 0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,
  84. 0x20,0x3F,0x20,0x00,0x03,0x00,0x00,0x00,//F 38
  85. 0xC0,0x30,0x08,0x08,0x08,0x38,0x00,0x00,
  86. 0x07,0x18,0x20,0x20,0x22,0x1E,0x02,0x00,//G 39
  87. 0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,
  88. 0x20,0x3F,0x21,0x01,0x01,0x21,0x3F,0x20,//H 40
  89. 0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0x00,
  90. 0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//I 41
  91. 0x00,0x00,0x08,0x08,0xF8,0x08,0x08,0x00,
  92. 0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,0x00,//J 42
  93. 0x08,0xF8,0x88,0xC0,0x28,0x18,0x08,0x00,
  94. 0x20,0x3F,0x20,0x01,0x26,0x38,0x20,0x00,//K 43
  95. 0x08,0xF8,0x08,0x00,0x00,0x00,0x00,0x00,
  96. 0x20,0x3F,0x20,0x20,0x20,0x20,0x30,0x00,//L 44
  97. 0x08,0xF8,0xF8,0x00,0xF8,0xF8,0x08,0x00,
  98. 0x20,0x3F,0x00,0x3F,0x00,0x3F,0x20,0x00,//M 45
  99. 0x08,0xF8,0x30,0xC0,0x00,0x08,0xF8,0x08,
  100. 0x20,0x3F,0x20,0x00,0x07,0x18,0x3F,0x00,//N 46
  101. 0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,
  102. 0x0F,0x10,0x20,0x20,0x20,0x10,0x0F,0x00,//O 47
  103. 0x08,0xF8,0x08,0x08,0x08,0x08,0xF0,0x00,
  104. 0x20,0x3F,0x21,0x01,0x01,0x01,0x00,0x00,//P 48
  105. 0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,
  106. 0x0F,0x18,0x24,0x24,0x38,0x50,0x4F,0x00,//Q 49
  107. 0x08,0xF8,0x88,0x88,0x88,0x88,0x70,0x00,
  108. 0x20,0x3F,0x20,0x00,0x03,0x0C,0x30,0x20,//R 50
  109. 0x00,0x70,0x88,0x08,0x08,0x08,0x38,0x00,
  110. 0x00,0x38,0x20,0x21,0x21,0x22,0x1C,0x00,//S 51
  111. 0x18,0x08,0x08,0xF8,0x08,0x08,0x18,0x00,
  112. 0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//T 52
  113. 0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,
  114. 0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//U 53
  115. 0x08,0x78,0x88,0x00,0x00,0xC8,0x38,0x08,
  116. 0x00,0x00,0x07,0x38,0x0E,0x01,0x00,0x00,//V 54
  117. 0xF8,0x08,0x00,0xF8,0x00,0x08,0xF8,0x00,
  118. 0x03,0x3C,0x07,0x00,0x07,0x3C,0x03,0x00,//W 55
  119. 0x08,0x18,0x68,0x80,0x80,0x68,0x18,0x08,
  120. 0x20,0x30,0x2C,0x03,0x03,0x2C,0x30,0x20,//X 56
  121. 0x08,0x38,0xC8,0x00,0xC8,0x38,0x08,0x00,
  122. 0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//Y 57
  123. 0x10,0x08,0x08,0x08,0xC8,0x38,0x08,0x00,
  124. 0x20,0x38,0x26,0x21,0x20,0x20,0x18,0x00,//Z 58
  125. 0x00,0x00,0x00,0xFE,0x02,0x02,0x02,0x00,
  126. 0x00,0x00,0x00,0x7F,0x40,0x40,0x40,0x00,//[ 59
  127. 0x00,0x0C,0x30,0xC0,0x00,0x00,0x00,0x00,
  128. 0x00,0x00,0x00,0x01,0x06,0x38,0xC0,0x00,//\ 60
  129. 0x00,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,
  130. 0x00,0x40,0x40,0x40,0x7F,0x00,0x00,0x00,//] 61
  131. 0x00,0x00,0x04,0x02,0x02,0x02,0x04,0x00,
  132. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//^ 62
  133. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  134. 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,//_ 63
  135. 0x00,0x02,0x02,0x04,0x00,0x00,0x00,0x00,
  136. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//` 64
  137. 0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,
  138. 0x00,0x19,0x24,0x22,0x22,0x22,0x3F,0x20,//a 65
  139. 0x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,
  140. 0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00,//b 66
  141. 0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,
  142. 0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00,//c 67
  143. 0x00,0x00,0x00,0x80,0x80,0x88,0xF8,0x00,
  144. 0x00,0x0E,0x11,0x20,0x20,0x10,0x3F,0x20,//d 68
  145. 0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,
  146. 0x00,0x1F,0x22,0x22,0x22,0x22,0x13,0x00,//e 69
  147. 0x00,0x80,0x80,0xF0,0x88,0x88,0x88,0x18,
  148. 0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//f 70
  149. 0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,
  150. 0x00,0x6B,0x94,0x94,0x94,0x93,0x60,0x00,//g 71
  151. 0x08,0xF8,0x00,0x80,0x80,0x80,0x00,0x00,
  152. 0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//h 72
  153. 0x00,0x80,0x98,0x98,0x00,0x00,0x00,0x00,
  154. 0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//i 73
  155. 0x00,0x00,0x00,0x80,0x98,0x98,0x00,0x00,
  156. 0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,//j 74
  157. 0x08,0xF8,0x00,0x00,0x80,0x80,0x80,0x00,
  158. 0x20,0x3F,0x24,0x02,0x2D,0x30,0x20,0x00,//k 75
  159. 0x00,0x08,0x08,0xF8,0x00,0x00,0x00,0x00,
  160. 0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//l 76
  161. 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,
  162. 0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F,//m 77
  163. 0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,
  164. 0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//n 78
  165. 0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,
  166. 0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//o 79
  167. 0x80,0x80,0x00,0x80,0x80,0x00,0x00,0x00,
  168. 0x80,0xFF,0xA1,0x20,0x20,0x11,0x0E,0x00,//p 80
  169. 0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,
  170. 0x00,0x0E,0x11,0x20,0x20,0xA0,0xFF,0x80,//q 81
  171. 0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,
  172. 0x20,0x20,0x3F,0x21,0x20,0x00,0x01,0x00,//r 82
  173. 0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,
  174. 0x00,0x33,0x24,0x24,0x24,0x24,0x19,0x00,//s 83
  175. 0x00,0x80,0x80,0xE0,0x80,0x80,0x00,0x00,
  176. 0x00,0x00,0x00,0x1F,0x20,0x20,0x00,0x00,//t 84
  177. 0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x00,
  178. 0x00,0x1F,0x20,0x20,0x20,0x10,0x3F,0x20,//u 85
  179. 0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,
  180. 0x00,0x01,0x0E,0x30,0x08,0x06,0x01,0x00,//v 86
  181. 0x80,0x80,0x00,0x80,0x00,0x80,0x80,0x80,
  182. 0x0F,0x30,0x0C,0x03,0x0C,0x30,0x0F,0x00,//w 87
  183. 0x00,0x80,0x80,0x00,0x80,0x80,0x80,0x00,
  184. 0x00,0x20,0x31,0x2E,0x0E,0x31,0x20,0x00,//x 88
  185. 0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,
  186. 0x80,0x81,0x8E,0x70,0x18,0x06,0x01,0x00,//y 89
  187. 0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,
  188. 0x00,0x21,0x30,0x2C,0x22,0x21,0x30,0x00,//z 90
  189. 0x00,0x00,0x00,0x00,0x80,0x7C,0x02,0x02,
  190. 0x00,0x00,0x00,0x00,0x00,0x3F,0x40,0x40,//{ 91
  191. 0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,
  192. 0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,//| 92
  193. 0x00,0x02,0x02,0x7C,0x80,0x00,0x00,0x00,
  194. 0x00,0x40,0x40,0x3F,0x00,0x00,0x00,0x00,//} 93
  195. 0x00,0x06,0x01,0x01,0x02,0x02,0x04,0x04,
  196. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//~ 94
  197. };
  198. char Hzk[][32]={
  199. {0x10,0x60,0x02,0x8C,0x00,0xFE,0x92,0x92,0x92,0x92,0x92,0x92,0xFE,0x00,0x00,0x00},
  200. {0x04,0x04,0x7E,0x01,0x44,0x48,0x50,0x7F,0x40,0x40,0x7F,0x50,0x48,0x44,0x40,0x00},/*"湿",0*/
  201. /* (16 X 16 , 宋体 )*/
  202. {0x00,0x00,0xFC,0x24,0x24,0x24,0xFC,0x25,0x26,0x24,0xFC,0x24,0x24,0x24,0x04,0x00},
  203. {0x40,0x30,0x8F,0x80,0x84,0x4C,0x55,0x25,0x25,0x25,0x55,0x4C,0x80,0x80,0x80,0x00},/*"度",1*/
  204. /* (16 X 16 , 宋体 )*/
  205. {0x10,0x60,0x02,0x8C,0x00,0x00,0xFE,0x92,0x92,0x92,0x92,0x92,0xFE,0x00,0x00,0x00},
  206. {0x04,0x04,0x7E,0x01,0x40,0x7E,0x42,0x42,0x7E,0x42,0x7E,0x42,0x42,0x7E,0x40,0x00},/*"温",2*/
  207. /* (16 X 16 , 宋体 )*/
  208. {0x00,0x00,0xFC,0x24,0x24,0x24,0xFC,0x25,0x26,0x24,0xFC,0x24,0x24,0x24,0x04,0x00},
  209. {0x40,0x30,0x8F,0x80,0x84,0x4C,0x55,0x25,0x25,0x25,0x55,0x4C,0x80,0x80,0x80,0x00},/*"度",3*/
  210. /* (16 X 16 , 宋体 )*/
  211. {0x10,0x0C,0x44,0x24,0x14,0x04,0x05,0x06,0x04,0x04,0x14,0x24,0x44,0x14,0x0C,0x00},
  212. {0x00,0x40,0x40,0x41,0x41,0x41,0x41,0x7F,0x41,0x41,0x41,0x41,0x40,0x40,0x00,0x00},/*"空",4*/
  213. /* (16 X 16 , 宋体 )*/
  214. {0x20,0x10,0x4C,0x47,0x54,0x54,0x54,0x54,0x54,0x54,0x54,0xD4,0x04,0x04,0x00,0x00},
  215. {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x30,0x40,0xF0,0x00},/*"气",5*/
  216. /* (16 X 16 , 宋体 )*/
  217. {0x00,0x00,0xFE,0x12,0x12,0x92,0x92,0x92,0x92,0xFF,0x91,0x91,0x91,0x91,0x10,0x00},
  218. {0x80,0x60,0x1F,0x80,0x80,0x5F,0x40,0x20,0x10,0x0E,0x10,0x10,0x20,0x5F,0x80,0x00},/*"质",6*/
  219. /* (16 X 16 , 宋体 )*/
  220. {0x20,0x20,0x20,0xBE,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xBE,0x20,0x20,0x20,0x00},
  221. {0x00,0x80,0x80,0xAF,0xAA,0xAA,0xAA,0xFF,0xAA,0xAA,0xAA,0xAF,0x80,0x80,0x00,0x00},/*"量",7*/
  222. /* (16 X 16 , 宋体 )*/
  223. {0x02,0x02,0xE2,0x22,0x22,0x32,0x2A,0x26,0x22,0x22,0x22,0x22,0xE2,0x02,0x02,0x00},
  224. {0x00,0x00,0xFF,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0xFF,0x00,0x00,0x00},/*"百",8*/
  225. /* (16 X 16 , 宋体 )*/
  226. {0x80,0x40,0x20,0x90,0x88,0x86,0x80,0x80,0x80,0x83,0x8C,0x10,0x20,0x40,0x80,0x00},
  227. {0x00,0x80,0x40,0x20,0x18,0x07,0x00,0x40,0x80,0x40,0x3F,0x00,0x00,0x00,0x00,0x00},/*"分",9*/
  228. /* (16 X 16 , 宋体 )*/
  229. {0x00,0x10,0x10,0x10,0x10,0x10,0x11,0x16,0x10,0x90,0x50,0x30,0x10,0x00,0x00,0x00},
  230. {0x00,0x40,0x20,0x10,0x10,0x28,0x44,0x42,0x41,0x40,0x40,0x40,0x40,0x40,0x40,0x00},/*"之",10*/
  231. /* (16 X 16 , 宋体 )*/
  232. };
  233. #endif

4.main.c

  1. #include "stm32f10x.h"
  2. #include "OLED.h"
  3. int main(void)
  4. {
  5. OLED_Init();
  6. while(1)
  7. {
  8. OLED_ShowString(1,1,"hhh");
  9. }
  10. }

四、完整工程

实测能直接运行,放心下载,希望我的文章能帮助到大家!
链接:https://pan.baidu.com/s/1ul5BjKH7s2qTCsM4xPvafQ?pwd=1234 提取码:1234

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/598766
推荐阅读
相关标签
  

闽ICP备14008679号