找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 862|回复: 3
打印 上一主题 下一主题
收起左侧

关于单片机字模及OLED显示问题,求指导

[复制链接]
跳转到指定楼层
楼主
这是我的设计,现在做的差不多了,但是有个问题想请各位帮一下。
我在oledfont.h把我要显示的"自动化"加进去了(如第一段代码),但是烧进实物后,显示不了这三个字(图2)。
主函数这边也写了(如第三段代码)
有什么办法吗,求各位指导了
  1. "自",0x01,0x00,0x02,0x00,0x04,0x00,0x1F,0xF0,0x10,0x10,0x10,0x10,0x10,0x10,0x1F,0xF0,0x10,0x10,0x10,0x10,0x1F,0xF0,0x10,0x10,0x10,0x10,0x10,0x10,0x1F,0xF0,0x10,0x10,/*"自",6*/
  2. "动",0x00,0x40,0x00,0x40,0x7C,0x40,0x00,0x40,0x01,0xFC,0x00,0x44,0xFE,0x44,0x20,0x44,0x20,0x44,0x20,0x84,0x48,0x84,0x44,0x84,0xFD,0x04,0x45,0x04,0x02,0x28,0x04,0x10,/*"动",7*/
  3. "化",0x08,0x80,0x08,0x80,0x08,0x84,0x10,0x88,0x10,0x90,0x30,0xA0,0x30,0xC0,0x50,0x80,0x91,0x80,0x12,0x80,0x14,0x80,0x10,0x82,0x10,0x82,0x10,0x82,0x10,0x7E,0x10,0x00,/*"化",8*/
复制代码
  1. Show_Str(0,26,128,12,"自动化",12,0);
复制代码

1651035478091.jpg (4.76 MB, 下载次数: 25)

图2

图2
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:390416 发表于 2022-4-27 14:41 | 只看该作者
OLED12864源代码分享 IIC协议 http://www.51hei.com/bbs/dpj-204281-1.html
回复

使用道具 举报

板凳
ID:123289 发表于 2022-4-27 17:45 | 只看该作者
1、读通12864手册
2、读通Show_Str的定义
3、读通硬件图
回复

使用道具 举报

地板
ID:688692 发表于 2022-4-27 23:25 | 只看该作者
  1. #include "REG51.h"
  2. //本程序在标准8052单片机(STC89C52)以12MHz运行。底层已优化到最快。
  3. //如果使用STC15,STC8系列单片机,请将单片机主频降低10倍先试。也就是用1.3824MHz先试试。
  4. //因为是追求速度,所以如果你的单片机IO速度太快,需要自己在Write_IIC_Byte加点延时进去。
  5. sbit SCL = P1^0;
  6. sbit SDA = P1^1;
  7. code unsigned char Hzk[]={
  8. /*--  文字:  柳  --*/
  9. /*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
  10. 0x08,0x88,0x68,0xFF,0x28,0x48,0xFC,0x04,0x02,0xF2,0x00,0xFC,0x04,0x04,0xFC,0x00,
  11. 0x02,0x01,0x00,0xFF,0x00,0x40,0x47,0x22,0x19,0x07,0x00,0xFF,0x02,0x04,0x03,0x00,

  12. ///*--  文字:  州  --*/
  13. ///*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
  14. //0x00,0xE0,0x00,0x00,0xFF,0x20,0xC0,0x00,0xFE,0x10,0x60,0x80,0x00,0xFF,0x00,0x00,
  15. //0x01,0x80,0x60,0x18,0x07,0x00,0x00,0x00,0x7F,0x00,0x00,0x01,0x00,0xFF,0x00,0x00,

  16. ///*--  文字:  双  --*/
  17. ///*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
  18. //0x00,0x12,0x22,0x42,0x82,0x62,0x1E,0x00,0x1E,0xE2,0x02,0x02,0xE2,0x1E,0x00,0x00,
  19. //0x20,0x10,0x08,0x06,0x01,0x03,0x4E,0x24,0x10,0x09,0x06,0x09,0x10,0x60,0x20,0x00,

  20. ///*--  文字:  虹  --*/
  21. ///*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
  22. //0xF8,0x08,0x08,0xFF,0x08,0x08,0xF8,0x04,0x04,0x04,0xFC,0x04,0x04,0x04,0x04,0x00,
  23. //0x43,0x41,0x41,0x3F,0x21,0x29,0x73,0x40,0x40,0x40,0x7F,0x40,0x40,0x40,0x40,0x00,

  24. ///*--  文字:  农  --*/
  25. ///*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
  26. //0x00,0x20,0x18,0x08,0x88,0xE8,0x1F,0x6A,0x88,0x08,0x88,0xC8,0xA8,0x1C,0x08,0x00,
  27. //0x08,0x04,0x02,0x41,0xFF,0x40,0x20,0x10,0x01,0x02,0x0D,0x18,0x70,0x20,0x20,0x00,

  28. ///*--  文字:  业  --*/
  29. ///*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
  30. //0x00,0x10,0x60,0x80,0x00,0xFF,0x00,0x00,0x00,0xFF,0x00,0x80,0x60,0x38,0x10,0x00,
  31. //0x20,0x20,0x20,0x23,0x21,0x3F,0x20,0x20,0x20,0x3F,0x22,0x21,0x20,0x30,0x20,0x00,

  32. ///*--  文字:  科  --*/
  33. ///*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
  34. //0x10,0x12,0x92,0x72,0xFE,0x51,0x91,0x00,0x22,0xCC,0x00,0x00,0xFF,0x00,0x00,0x00,
  35. //0x04,0x02,0x01,0x00,0xFF,0x00,0x04,0x04,0x04,0x02,0x02,0x02,0xFF,0x01,0x01,0x00,

  36. ///*--  文字:  技  --*/
  37. ///*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
  38. //0x08,0x08,0x88,0xFF,0x48,0x28,0x00,0xC8,0x48,0x48,0x7F,0x48,0xC8,0x48,0x08,0x00,
  39. //0x01,0x41,0x80,0x7F,0x00,0x40,0x40,0x20,0x13,0x0C,0x0C,0x12,0x21,0x60,0x20,0x00,
  40. ///*--  文字:  企  --*/
  41. ///*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
  42. //0x80,0x80,0x40,0x40,0x20,0x10,0x08,0xC7,0x8A,0x10,0x20,0x60,0x40,0xC0,0x40,0x00,
  43. //0x40,0x40,0x40,0x7F,0x42,0x40,0x40,0x7F,0x42,0x42,0x42,0x43,0x42,0x60,0x40,0x00,

  44. ///*--  文字:  鹅  --*/
  45. ///*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
  46. //0x24,0x24,0xFC,0x22,0xFF,0x24,0x28,0x00,0xFC,0x0C,0x36,0x05,0x44,0x7C,0x00,0x00,
  47. //0x24,0x42,0x3F,0x09,0x05,0x0E,0x31,0x78,0x09,0x09,0x09,0x09,0x49,0x81,0x7F,0x00,

  48. ///*--  文字:  电  --*/
  49. ///*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
  50. //0x00,0x00,0xF8,0x48,0x48,0x48,0x48,0xFF,0x48,0x48,0x48,0x48,0xF8,0x00,0x00,0x00,
  51. //0x00,0x00,0x0F,0x04,0x04,0x04,0x04,0x3F,0x44,0x44,0x44,0x44,0x4F,0x40,0x70,0x00,

  52. ///*--  文字:  路  --*/
  53. ///*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
  54. //0x00,0x7E,0x22,0xE2,0x3E,0x20,0x10,0x08,0x0F,0xB4,0x44,0xA4,0x9C,0x04,0x00,0x00,
  55. //0x20,0x3F,0x20,0x1F,0x11,0x11,0x02,0x7F,0x23,0x22,0x22,0x22,0x7E,0x03,0x01,0x00,

  56. ///*--  文字:  个  --*/
  57. ///*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
  58. //0x00,0x80,0x80,0x40,0x20,0x10,0x0C,0xE3,0x04,0x08,0x10,0x20,0x60,0xC0,0x40,0x00,
  59. //0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

  60. };
  61. code unsigned char hz_suoyin[]="柳州双虹农业科技企鹅电路个";
  62. code unsigned char num[]={
  63. /*--  文字:  ?  --*/
  64. /*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  65. 0x00,0x70,0x48,0x08,0x08,0x08,0xF0,0x00,0x00,0x00,0x00,0x30,0x36,0x01,0x00,0x00,

  66.         /*--  文字:  0  --*/
  67. /*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  68. 0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,

  69. /*--  文字:  1  --*/
  70. /*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  71. 0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,

  72. /*--  文字:  2  --*/
  73. /*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  74. 0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,

  75. /*--  文字:  3  --*/
  76. /*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  77. 0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,

  78. /*--  文字:  4  --*/
  79. /*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  80. 0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,

  81. /*--  文字:  5  --*/
  82. /*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  83. 0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,

  84. /*--  文字:  6  --*/
  85. /*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  86. 0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,

  87. /*--  文字:  7  --*/
  88. /*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  89. 0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,

  90. /*--  文字:  8  --*/
  91. /*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  92. 0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,

  93. /*--  文字:  9  --*/
  94. /*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  95. 0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,

  96. ///*--  文字:  a  --*/
  97. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  98. //0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x19,0x24,0x22,0x22,0x22,0x3F,0x20,

  99. ///*--  文字:  b  --*/
  100. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  101. //0x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00,

  102. ///*--  文字:  c  --*/
  103. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  104. //0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00,

  105. ///*--  文字:  d  --*/
  106. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  107. //0x00,0x00,0x00,0x80,0x80,0x88,0xF8,0x00,0x00,0x0E,0x11,0x20,0x20,0x10,0x3F,0x20,

  108. ///*--  文字:  e  --*/
  109. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  110. //0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x22,0x22,0x22,0x22,0x13,0x00,

  111. ///*--  文字:  f  --*/
  112. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  113. //0x00,0x80,0x80,0xF0,0x88,0x88,0x88,0x18,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,

  114. ///*--  文字:  g  --*/
  115. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  116. //0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x6B,0x94,0x94,0x94,0x93,0x60,0x00,

  117. ///*--  文字:  h  --*/
  118. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  119. //0x08,0xF8,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,

  120. ///*--  文字:  i  --*/
  121. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  122. //0x00,0x80,0x98,0x98,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,

  123. ///*--  文字:  j  --*/
  124. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  125. //0x00,0x00,0x00,0x80,0x98,0x98,0x00,0x00,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,

  126. ///*--  文字:  k  --*/
  127. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  128. //0x08,0xF8,0x00,0x00,0x80,0x80,0x80,0x00,0x20,0x3F,0x24,0x02,0x2D,0x30,0x20,0x00,

  129. ///*--  文字:  l  --*/
  130. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  131. //0x00,0x08,0x08,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,

  132. ///*--  文字:  m  --*/
  133. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  134. //0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F,

  135. ///*--  文字:  n  --*/
  136. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  137. //0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,

  138. ///*--  文字:  o  --*/
  139. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  140. //0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,

  141. ///*--  文字:  p  --*/
  142. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  143. //0x80,0x80,0x00,0x80,0x80,0x00,0x00,0x00,0x80,0xFF,0xA1,0x20,0x20,0x11,0x0E,0x00,

  144. ///*--  文字:  q  --*/
  145. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  146. //0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x0E,0x11,0x20,0x20,0xA0,0xFF,0x80,

  147. ///*--  文字:  r  --*/
  148. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  149. //0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x20,0x20,0x3F,0x21,0x20,0x00,0x01,0x00,

  150. ///*--  文字:  s  --*/
  151. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  152. //0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x33,0x24,0x24,0x24,0x24,0x19,0x00,

  153. ///*--  文字:  t  --*/
  154. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  155. //0x00,0x80,0x80,0xE0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x1F,0x20,0x20,0x00,0x00,

  156. ///*--  文字:  u  --*/
  157. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  158. //0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x1F,0x20,0x20,0x20,0x10,0x3F,0x20,

  159. ///*--  文字:  v  --*/
  160. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  161. //0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x00,0x01,0x0E,0x30,0x08,0x06,0x01,0x00,

  162. ///*--  文字:  w  --*/
  163. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  164. //0x80,0x80,0x00,0x80,0x00,0x80,0x80,0x80,0x0F,0x30,0x0C,0x03,0x0C,0x30,0x0F,0x00,

  165. ///*--  文字:  x  --*/
  166. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  167. //0x00,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x31,0x2E,0x0E,0x31,0x20,0x00,

  168. ///*--  文字:  y  --*/
  169. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  170. //0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x80,0x81,0x8E,0x70,0x18,0x06,0x01,0x00,

  171. ///*--  文字:  z  --*/
  172. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  173. //0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x21,0x30,0x2C,0x22,0x21,0x30,0x00,

  174. ///*--  文字:  A  --*/
  175. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  176. //0x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20,

  177. ///*--  文字:  B  --*/
  178. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  179. //0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00,

  180. ///*--  文字:  C  --*/
  181. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  182. //0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00,

  183. ///*--  文字:  D  --*/
  184. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  185. //0x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,0x20,0x3F,0x20,0x20,0x20,0x10,0x0F,0x00,

  186. ///*--  文字:  E  --*/
  187. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  188. //0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x20,0x23,0x20,0x18,0x00,

  189. ///*--  文字:  F  --*/
  190. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  191. //0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x00,0x03,0x00,0x00,0x00,

  192. ///*--  文字:  G  --*/
  193. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  194. //0xC0,0x30,0x08,0x08,0x08,0x38,0x00,0x00,0x07,0x18,0x20,0x20,0x22,0x1E,0x02,0x00,

  195. ///*--  文字:  H  --*/
  196. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  197. //0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x20,0x3F,0x21,0x01,0x01,0x21,0x3F,0x20,

  198. ///*--  文字:  I  --*/
  199. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  200. //0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,

  201. ///*--  文字:  J  --*/
  202. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  203. //0x00,0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,0x00,

  204. ///*--  文字:  K  --*/
  205. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  206. //0x08,0xF8,0x88,0xC0,0x28,0x18,0x08,0x00,0x20,0x3F,0x20,0x01,0x26,0x38,0x20,0x00,

  207. ///*--  文字:  L  --*/
  208. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  209. //0x08,0xF8,0x08,0x00,0x00,0x00,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x20,0x30,0x00,

  210. ///*--  文字:  M  --*/
  211. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  212. //0x08,0xF8,0xF8,0x00,0xF8,0xF8,0x08,0x00,0x20,0x3F,0x00,0x3F,0x00,0x3F,0x20,0x00,

  213. ///*--  文字:  N  --*/
  214. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  215. //0x08,0xF8,0x30,0xC0,0x00,0x08,0xF8,0x08,0x20,0x3F,0x20,0x00,0x07,0x18,0x3F,0x00,

  216. ///*--  文字:  O  --*/
  217. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  218. //0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x10,0x20,0x20,0x20,0x10,0x0F,0x00,

  219. ///*--  文字:  P  --*/
  220. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  221. //0x08,0xF8,0x08,0x08,0x08,0x08,0xF0,0x00,0x20,0x3F,0x21,0x01,0x01,0x01,0x00,0x00,

  222. ///*--  文字:  Q  --*/
  223. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  224. //0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x18,0x24,0x24,0x38,0x50,0x4F,0x00,

  225. ///*--  文字:  R  --*/
  226. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  227. //0x08,0xF8,0x88,0x88,0x88,0x88,0x70,0x00,0x20,0x3F,0x20,0x00,0x03,0x0C,0x30,0x20,

  228. ///*--  文字:  S  --*/
  229. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  230. //0x00,0x70,0x88,0x08,0x08,0x08,0x38,0x00,0x00,0x38,0x20,0x21,0x21,0x22,0x1C,0x00,

  231. ///*--  文字:  T  --*/
  232. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  233. //0x18,0x08,0x08,0xF8,0x08,0x08,0x18,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,

  234. ///*--  文字:  U  --*/
  235. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  236. //0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,

  237. ///*--  文字:  V  --*/
  238. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  239. //0x08,0x78,0x88,0x00,0x00,0xC8,0x38,0x08,0x00,0x00,0x07,0x38,0x0E,0x01,0x00,0x00,

  240. ///*--  文字:  W  --*/
  241. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  242. //0xF8,0x08,0x00,0xF8,0x00,0x08,0xF8,0x00,0x03,0x3C,0x07,0x00,0x07,0x3C,0x03,0x00,

  243. ///*--  文字:  X  --*/
  244. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  245. //0x08,0x18,0x68,0x80,0x80,0x68,0x18,0x08,0x20,0x30,0x2C,0x03,0x03,0x2C,0x30,0x20,

  246. ///*--  文字:  Y  --*/
  247. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  248. //0x08,0x38,0xC8,0x00,0xC8,0x38,0x08,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,

  249. ///*--  文字:  Z  --*/
  250. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  251. //0x10,0x08,0x08,0x08,0xC8,0x38,0x08,0x00,0x20,0x38,0x26,0x21,0x20,0x20,0x18,0x00,

  252. ///*--  文字:  `  --*/
  253. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  254. //0x00,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

  255. ///*--  文字:  !  --*/
  256. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  257. //0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x30,0x00,0x00,0x00,

  258. ///*--  文字:  @  --*/
  259. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  260. //0xC0,0x30,0xC8,0x28,0xE8,0x10,0xE0,0x00,0x07,0x18,0x27,0x24,0x23,0x14,0x0B,0x00,

  261. ///*--  文字:  #  --*/
  262. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  263. //0x40,0xC0,0x78,0x40,0xC0,0x78,0x40,0x00,0x04,0x3F,0x04,0x04,0x3F,0x04,0x04,0x00,

  264. ///*--  文字:  $  --*/
  265. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  266. //0x00,0x70,0x88,0xFC,0x08,0x30,0x00,0x00,0x00,0x18,0x20,0xFF,0x21,0x1E,0x00,0x00,

  267. ///*--  文字:  %  --*/
  268. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  269. //0xF0,0x08,0xF0,0x00,0xE0,0x18,0x00,0x00,0x00,0x21,0x1C,0x03,0x1E,0x21,0x1E,0x00,

  270. ///*--  文字:  ^  --*/
  271. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  272. //0x00,0x00,0x04,0x02,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

  273. ///*--  文字:  &  --*/
  274. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  275. //0x00,0xF0,0x08,0x88,0x70,0x00,0x00,0x00,0x1E,0x21,0x23,0x24,0x19,0x27,0x21,0x10,

  276. ///*--  文字:  *  --*/
  277. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  278. //0x40,0x40,0x80,0xF0,0x80,0x40,0x40,0x00,0x02,0x02,0x01,0x0F,0x01,0x02,0x02,0x00,

  279. ///*--  文字:  (  --*/
  280. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  281. //0x00,0x00,0x00,0xE0,0x18,0x04,0x02,0x00,0x00,0x00,0x00,0x07,0x18,0x20,0x40,0x00,

  282. ///*--  文字:  )  --*/
  283. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  284. //0x00,0x02,0x04,0x18,0xE0,0x00,0x00,0x00,0x00,0x40,0x20,0x18,0x07,0x00,0x00,0x00,

  285. ///*--  文字:  -  --*/
  286. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  287. //0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,

  288. ///*--  文字:  =  --*/
  289. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  290. //0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00,

  291. ///*--  文字:  _  --*/
  292. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  293. //0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,

  294. ///*--  文字:  +  --*/
  295. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  296. //0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x1F,0x01,0x01,0x01,0x00,

  297. ///*--  文字:  [  --*/
  298. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  299. //0x00,0x00,0x00,0xFE,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x7F,0x40,0x40,0x40,0x00,

  300. ///*--  文字:  ]  --*/
  301. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  302. //0x00,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x7F,0x00,0x00,0x00,

  303. ///*--  文字:  ;  --*/
  304. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  305. //0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x60,0x00,0x00,0x00,0x00,

  306. ///*--  文字:  '  --*/
  307. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  308. //0x10,0x16,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

  309. ///*--  文字:  ,  --*/
  310. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  311. //0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xB0,0x70,0x00,0x00,0x00,0x00,0x00,

  312. ///*--  文字:  .  --*/
  313. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  314. //0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,

  315. ///*--  文字:  /  --*/
  316. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  317. //0x00,0x00,0x00,0x00,0x80,0x60,0x18,0x04,0x00,0x60,0x18,0x06,0x01,0x00,0x00,0x00,

  318. ///*--  文字:  {  --*/
  319. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  320. //0x00,0x00,0x00,0x00,0x80,0x7C,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x3F,0x40,0x40,

  321. ///*--  文字:  }  --*/
  322. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  323. //0x00,0x02,0x02,0x7C,0x80,0x00,0x00,0x00,0x00,0x40,0x40,0x3F,0x00,0x00,0x00,0x00,

  324. ///*--  文字:  :  --*/
  325. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  326. //0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,


  327. ///*--  文字:  <  --*/
  328. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  329. //0x00,0x00,0x80,0x40,0x20,0x10,0x08,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x00,

  330. ///*--  文字:  >  --*/
  331. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  332. //0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x20,0x10,0x08,0x04,0x02,0x01,0x00,

  333. ///*--  文字:  \  --*/
  334. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  335. //0x00,0x0C,0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x06,0x38,0xC0,0x00,

  336. ///*--  文字:  "  --*/
  337. ///*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
  338. //0x00,0x10,0x0C,0x06,0x10,0x0C,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

  339. //0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  340. };
  341. code unsigned char zm_suoyin[]="?0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`!@#$%^&*()-=_+[];',./{}:<>\x5c\34 ";
  342. void Write_IIC_Byte(unsigned char IIC_Byte)
  343. {
  344.         SCL=0;

  345.           SDA=IIC_Byte&0x80;
  346.                 SCL=1;
  347.                 SCL=0;

  348.           SDA=IIC_Byte&0x40;
  349.                 SCL=1;
  350.                 SCL=0;

  351.           SDA=IIC_Byte&0x20;
  352.                 SCL=1;
  353.                 SCL=0;

  354.           SDA=IIC_Byte&0x10;
  355.                 SCL=1;
  356.                 SCL=0;

  357.           SDA=IIC_Byte&0x08;
  358.                 SCL=1;
  359.                 SCL=0;

  360.           SDA=IIC_Byte&0x04;
  361.                 SCL=1;
  362.                 SCL=0;

  363.           SDA=IIC_Byte&0x02;
  364.                 SCL=1;
  365.                 SCL=0;

  366.           SDA=IIC_Byte&0x01;
  367.                 SCL=1;
  368.                 SCL=0;


  369.         SCL=1;
  370.         SCL=0;
  371. }
  372. void Write_IIC_Command(unsigned char IIC_Command)
  373. {
  374.         SCL=1;
  375.         SDA=1;
  376.         SDA=0;
  377.    Write_IIC_Byte(0x78);            //Slave address,SA0=0
  378.    Write_IIC_Byte(0x00);                        //write command
  379.    Write_IIC_Byte(IIC_Command);
  380.         SDA=0;
  381.   SCL=1;
  382.         SDA=1;
  383. }
  384. void Write_IIC_Data(unsigned char IIC_Data)
  385. {
  386.         SCL=1;
  387.         SDA=1;
  388.         SDA=0;
  389.    Write_IIC_Byte(0x78);                        //D/C#=0; R/W#=0
  390.    Write_IIC_Byte(0x40);                        //write data
  391.    Write_IIC_Byte(IIC_Data);
  392.         SDA=0;
  393.   SCL=1;
  394.         SDA=1;
  395. }

  396. void OLED_Clear(void)  
  397. {  
  398.         unsigned char i,n;                    
  399.         for(i=0;i<4;i++)  
  400.         {  
  401.                 Write_IIC_Command (0xb0+i);    //设置页地址(0~7)
  402.                 Write_IIC_Command (0x00);      //设置显示位置—列低地址
  403.                 Write_IIC_Command (0x10);      //设置显示位置—列高地址
  404.           SCL=1;
  405.           SDA=1;
  406.           SDA=0;
  407.     Write_IIC_Byte(0x78);                        //D/C#=0; R/W#=0
  408.     Write_IIC_Byte(0x40);                        //write data

  409.                 for(n=0;n<128;n++)Write_IIC_Byte(0X00);
  410.           SDA=0;
  411.     SCL=1;
  412.           SDA=1;
  413.                
  414.         } //更新显示
  415. }
  416. void Delay100ms()                //@11.0592MHz
  417. {
  418.         unsigned char i, j, k;

  419.         i = 5;
  420.         j = 52;
  421.         k = 195;
  422.         do
  423.         {
  424.                 do
  425.                 {
  426.                         while (--k);
  427.                 } while (--j);
  428.         } while (--i);
  429. }
  430. void OLED_Init(void)
  431. {        
  432.         Delay100ms();
  433.         Write_IIC_Command(0xAE);//关闭显示
  434.        
  435.         Write_IIC_Command(0x40);//---set low column address
  436.         Write_IIC_Command(0xB0);//---set high column address

  437.         Write_IIC_Command(0xC8);//-not offset

  438.         Write_IIC_Command(0x81);//设置对比度
  439.         Write_IIC_Command(0xff);

  440.         Write_IIC_Command(0xa1);//段重定向设置

  441.         Write_IIC_Command(0xa6);//
  442.        
  443.         Write_IIC_Command(0xa8);//设置驱动路数
  444.         Write_IIC_Command(0x1f);
  445.        
  446.         Write_IIC_Command(0xd3);
  447.         Write_IIC_Command(0x00);
  448.        
  449.         Write_IIC_Command(0xd5);
  450.         Write_IIC_Command(0xf0);
  451.        
  452.         Write_IIC_Command(0xd9);
  453.         Write_IIC_Command(0x22);
  454.        
  455.         Write_IIC_Command(0xda);
  456.         Write_IIC_Command(0x02);
  457.        
  458.         Write_IIC_Command(0xdb);
  459.         Write_IIC_Command(0x49);
  460.        
  461.         Write_IIC_Command(0x8d);
  462.         Write_IIC_Command(0x14);
  463.        
  464.         Write_IIC_Command(0xaf);
  465.         OLED_Clear();
  466. }
  467. void OLED_Set_Pos(unsigned char x, unsigned char y)
  468. {
  469.         SCL=1;
  470.         SDA=1;
  471.         SDA=0;
  472.   Write_IIC_Byte(0x78);            //Slave address,SA0=0
  473.   Write_IIC_Byte(0x00);                        //write command

  474.         Write_IIC_Byte(0xb0+y);
  475.         Write_IIC_Byte(((x&0xf0)>>4)|0x10);
  476.         Write_IIC_Byte((x&0x0f));
  477.         SDA=0;
  478.   SCL=1;
  479.         SDA=1;
  480. }  
  481. void OLED_ShowHz(unsigned char x,y,no)
  482. {
  483.         unsigned char i;
  484.         OLED_Set_Pos(x,y);
  485.         no=no*32;
  486.   for(i=0;i<16;i++)
  487.         {
  488.                 Write_IIC_Data(Hzk[no++]);
  489.         }
  490.         OLED_Set_Pos(x,y+1);
  491.         for(i=16;i<32;i++)
  492.         {
  493.                 Write_IIC_Data(Hzk[no++]);
  494.         }                                       
  495. }
  496. void OLED_ShowNum(unsigned char x,y,val)
  497. {
  498.         unsigned char i;
  499.         OLED_Set_Pos(x,y);
  500.         val=val*16;
  501.         SCL=1;
  502.         SDA=1;
  503.         SDA=0;
  504.    Write_IIC_Byte(0x78);                        //D/C#=0; R/W#=0
  505.    Write_IIC_Byte(0x40);                        //write data
  506.   for(i=0;i<8;i++)
  507.         {
  508.                 Write_IIC_Byte(num[val++]);
  509.         }
  510.         SDA=0;
  511.   SCL=1;
  512.         SDA=1;
  513.         OLED_Set_Pos(x,y+1);
  514.         SCL=1;
  515.         SDA=1;
  516.         SDA=0;
  517.    Write_IIC_Byte(0x78);                        //D/C#=0; R/W#=0
  518.    Write_IIC_Byte(0x40);                        //write data
  519.         for(i=8;i<16;i++)
  520.         {
  521.                 Write_IIC_Byte(num[val++]);
  522.         }                                       
  523.         SDA=0;
  524.   SCL=1;
  525.         SDA=1;
  526. }
  527. void OLED_Show_Zfc(unsigned char x,y,unsigned char code * Zfc)
  528. {
  529.         unsigned char i;
  530.         while(*Zfc!=0)
  531.         {
  532.                 if(*Zfc>127)
  533.                 {
  534.                         for(i=0;i<=sizeof(hz_suoyin);i++)
  535.                         {
  536.                                 if(Zfc[0]==hz_suoyin[i] && Zfc[1]==hz_suoyin[i+1])
  537.                                 {
  538.                                         if(x>112){y+=2;x=0;}
  539.                                         OLED_ShowHz(x,y,i/2);
  540.                                         x=x+16;
  541.                                         Zfc+=2;
  542.                                 }
  543.                         }
  544.                 }
  545.                 else
  546.                 {
  547.                                 for(i=0;i<=sizeof(zm_suoyin);i++)
  548.                                 {
  549.                                         if(Zfc[0]==zm_suoyin[i])
  550.                                         {
  551.                                                 if(x>120){y+=2;x=0;}
  552.                                                 OLED_ShowNum(x,y,i);
  553.                                                 x=x+8;
  554.                                         }
  555.                                 }
  556.                         Zfc++;
  557.                 }
  558.         }
  559. }
  560. int main(void)
  561. {
  562.          unsigned char i;
  563.         OLED_Init();                        //初始化OLED  
  564.         OLED_Clear();
  565.         OLED_Show_Zfc(0,0,"柳 18077219186");
  566.         while(1)
  567.         {
  568. //                OLED_ShowNum(0,2,i/100);
  569. //                OLED_ShowNum(8,2,i%100/10);
  570. //                OLED_ShowNum(16,2,i%10);
  571.                 i++;
  572.         }
  573. }
复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表