您的位置 首页 基础

IIC OLED驱动

/*文件名:oled.c版本号:v1.0最近修改:功能描述:LED128x64OLED显示屏底层驱动修改历史:**************************…

  1. /*
  2. 文 件 名 : oled.c
  3. 版 本 号 : v1.0
  4. 最近修正 :
  5. 功用描绘 : LED128x64OLED显现屏底层驱动
  6. 修正前史 :
  7. ******************************************************************************/
  8. /*—————————————————————————-*
  9. * 包括头文件 *
  10. *—————————————————————————-*/
  11. #include
  12. #include”oled.h”
  13. /*—————————————————————————-*
  14. * 宏界说 *
  15. *—————————————————————————-*/
  16. /*—————————————————————————-*
  17. * 全局变量 *
  18. *—————————————————————————-*/
  19. sbit LED_SCL=P1^0;
  20. sbit LED_SDA=P1^1;
  21. sbit LED_RST=P1^2;
  22. sbit LED_DC=P1^3;
  23. constUCHAR8 code F6x8[][6]=
  24. {
  25. {0x00,0x00,0x00,0x00,0x00,0x00},//sp0
  26. {0x00,0x00,0x00,0x2f,0x00,0x00},// !1
  27. {0x00,0x00,0x07,0x00,0x07,0x00},// “2
  28. {0x00,0x14,0x7f,0x14,0x7f,0x14},// #3
  29. {0x00,0x24,0x2a,0x7f,0x2a,0x12},// $4
  30. {0x00,0x62,0x64,0x08,0x13,0x23},// %5
  31. {0x00,0x36,0x49,0x55,0x22,0x50},// &6
  32. {0x00,0x00,0x05,0x03,0x00,0x00},// 7
  33. {0x00,0x00,0x1c,0x22,0x41,0x00},// (8
  34. {0x00,0x00,0x41,0x22,0x1c,0x00},// )9
  35. {0x00,0x14,0x08,0x3E,0x08,0x14},// *10
  36. {0x00,0x08,0x08,0x3E,0x08,0x08},// +11
  37. {0x00,0x00,0x00,0xA0,0x60,0x00},// ,12
  38. {0x00,0x08,0x08,0x08,0x08,0x08},// -13
  39. {0x00,0x00,0x60,0x60,0x00,0x00},// .14
  40. {0x00,0x20,0x10,0x08,0x04,0x02},// /15
  41. {0x00,0x3E,0x51,0x49,0x45,0x3E},// 016
  42. {0x00,0x00,0x42,0x7F,0x40,0x00},// 117
  43. {0x00,0x42,0x61,0x51,0x49,0x46},// 218
  44. {0x00,0x21,0x41,0x45,0x4B,0x31},// 319
  45. {0x00,0x18,0x14,0x12,0x7F,0x10},// 420
  46. {0x00,0x27,0x45,0x45,0x45,0x39},// 521
  47. {0x00,0x3C,0x4A,0x49,0x49,0x30},// 622
  48. {0x00,0x01,0x71,0x09,0x05,0x03},// 723
  49. {0x00,0x36,0x49,0x49,0x49,0x36},// 824
  50. {0x00,0x06,0x49,0x49,0x29,0x1E},// 925
  51. {0x00,0x00,0x36,0x36,0x00,0x00},// :26
  52. {0x00,0x00,0x56,0x36,0x00,0x00},// ;27
  53. {0x00,0x08,0x14,0x22,0x41,0x00},// <28
  54. {0x00,0x14,0x14,0x14,0x14,0x14},// =29
  55. {0x00,0x00,0x41,0x22,0x14,0x08},// >30
  56. {0x00,0x02,0x01,0x51,0x09,0x06},// ?31
  57. {0x00,0x32,0x49,0x59,0x51,0x3E},// @32
  58. {0x00,0x7C,0x12,0x11,0x12,0x7C},// A33
  59. {0x00,0x7F,0x49,0x49,0x49,0x36},// B34
  60. {0x00,0x3E,0x41,0x41,0x41,0x22},// C35
  61. {0x00,0x7F,0x41,0x41,0x22,0x1C},// D36
  62. {0x00,0x7F,0x49,0x49,0x49,0x41},// E37
  63. {0x00,0x7F,0x09,0x09,0x09,0x01},// F38
  64. {0x00,0x3E,0x41,0x49,0x49,0x7A},// G39
  65. {0x00,0x7F,0x08,0x08,0x08,0x7F},// H40
  66. {0x00,0x00,0x41,0x7F,0x41,0x00},// I41
  67. {0x00,0x20,0x40,0x41,0x3F,0x01},// J42
  68. {0x00,0x7F,0x08,0x14,0x22,0x41},// K43
  69. {0x00,0x7F,0x40,0x40,0x40,0x40},// L44
  70. {0x00,0x7F,0x02,0x0C,0x02,0x7F},// M45
  71. {0x00,0x7F,0x04,0x08,0x10,0x7F},// N46
  72. {0x00,0x3E,0x41,0x41,0x41,0x3E},// O47
  73. {0x00,0x7F,0x09,0x09,0x09,0x06},// P48
  74. {0x00,0x3E,0x41,0x51,0x21,0x5E},// Q49
  75. {0x00,0x7F,0x09,0x19,0x29,0x46},// R50
  76. {0x00,0x46,0x49,0x49,0x49,0x31},// S51
  77. {0x00,0x01,0x01,0x7F,0x01,0x01},// T52
  78. {0x00,0x3F,0x40,0x40,0x40,0x3F},// U53
  79. {0x00,0x1F,0x20,0x40,0x20,0x1F},// V54
  80. {0x00,0x3F,0x40,0x38,0x40,0x3F},// W55
  81. {0x00,0x63,0x14,0x08,0x14,0x63},// X56
  82. {0x00,0x07,0x08,0x70,0x08,0x07},// Y57
  83. {0x00,0x61,0x51,0x49,0x45,0x43},// Z58
  84. {0x00,0x00,0x7F,0x41,0x41,0x00},// [59
  85. {0x00,0x02,0x04,0x08,0x10,0x20},// \60
  86. {0x00,0x00,0x41,0x41,0x7F,0x00},// ]61
  87. {0x00,0x04,0x02,0x01,0x02,0x04},// ^62
  88. {0x00,0x40,0x40,0x40,0x40,0x40},// _63
  89. {0x00,0x00,0x01,0x02,0x04,0x00},// 64
  90. {0x00,0x20,0x54,0x54,0x54,0x78},// a65
  91. {0x00,0x7F,0x48,0x44,0x44,0x38},// b66
  92. {0x00,0x38,0x44,0x44,0x44,0x20},// c67
  93. {0x00,0x38,0x44,0x44,0x48,0x7F},// d68
  94. {0x00,0x38,0x54,0x54,0x54,0x18},// e69
  95. {0x00,0x08,0x7E,0x09,0x01,0x02},// f70
  96. {0x00,0x18,0xA4,0xA4,0xA4,0x7C},// g71
  97. {0x00,0x7F,0x08,0x04,0x04,0x78},// h72
  98. {0x00,0x00,0x44,0x7D,0x40,0x00},// i73
  99. {0x00,0x40,0x80,0x84,0x7D,0x00},// j74
  100. {0x00,0x7F,0x10,0x28,0x44,0x00},// k75
  101. {0x00,0x00,0x41,0x7F,0x40,0x00},// l76
  102. {0x00,0x7C,0x04,0x18,0x04,0x78},// m77
  103. {0x00,0x7C,0x08,0x04,0x04,0x78},// n78
  104. {0x00,0x38,0x44,0x44,0x44,0x38},// o79
  105. {0x00,0xFC,0x24,0x24,0x24,0x18},// p80
  106. {0x00,0x18,0x24,0x24,0x18,0xFC},// q81
  107. {0x00,0x7C,0x08,0x04,0x04,0x08},// r82
  108. {0x00,0x48,0x54,0x54,0x54,0x20},// s83
  109. {0x00,0x04,0x3F,0x44,0x40,0x20},// t84
  110. {0x00,0x3C,0x40,0x40,0x20,0x7C},// u85
  111. {0x00,0x1C,0x20,0x40,0x20,0x1C},// v86
  112. {0x00,0x3C,0x40,0x30,0x40,0x3C},// w87
  113. {0x00,0x44,0x28,0x10,0x28,0x44},// x88
  114. {0x00,0x1C,0xA0,0xA0,0xA0,0x7C},// y89
  115. {0x00,0x44,0x64,0x54,0x4C,0x44},// z90
  116. {0x14,0x14,0x14,0x14,0x14,0x14}// horiz lines91
  117. };
  118. //中文字符串原字
  119. constUCHAR8 code F14x16_Idx[]=
  120. {
  121. “科技屏幕测验”
  122. };
  123. //中文字符串编码
  124. constUCHAR8 code F14x16[]=
  125. {
  126. 0x00,0x00,0x48,0xFC,0x44,0x42,0x00,0x88,0x30,0x00,0xFE,0x02,0x00,0x00,
  127. 0x00,0x0C,0x02,0x7F,0x01,0x01,0x08,0x08,0x05,0x04,0xFF,0x04,0x02,0x00,/*”科”,4*/
  128. 0x00,0x00,0x20,0xFE,0x20,0x90,0x20,0x20,0x20,0xFE,0x20,0xA0,0x10,0x00,
  129. 0x00,0x02,0x41,0x7F,0x81,0x80,0x41,0x47,0x29,0x18,0x27,0x41,0x40,0x00,/*”技”,5*/
  130. 0x00,0x00,0xFE,0x14,0x14,0x34,0x54,0x14,0x94,0x74,0x14,0x9C,0x00,0x00,
  131. 0x00,0x30,0x0F,0x88,0x48,0x39,0x0F,0x09,0x08,0x7F,0x09,0x04,0x04,0x00,/*”屏”,6*/
  132. 0x00,0x04,0x04,0xF4,0x54,0xCE,0x54,0x54,0x4E,0x4C,0xF4,0x04,0x04,0x00,
  133. 0x00,0x08,0x0A,0x3E,0x0A,0x09,0x7E,0x0A,0x0A,0x7A,0x0E,0x0A,0x09,0x00,/*”幕”,7*/
  134. 0x00,0x20,0x04,0x80,0xFC,0x04,0xF4,0x04,0xFC,0x00,0xF0,0xFC,0x00,0x00,
  135. 0x00,0x00,0x7F,0x40,0x27,0x18,0x07,0x10,0x67,0x00,0x4F,0xFF,0x00,0x00,/*”测”,8*/
  136. 0x00,0x80,0x88,0x98,0x20,0x20,0x20,0x20,0xA0,0xFE,0x24,0x2C,0x10,0x00,
  137. 0x00,0x00,0x1F,0x60,0x10,0x28,0x21,0x1F,0x10,0x13,0x1C,0x20,0x70,0x00,/*”试”,9*/
  138. };
  139. //======================================================
  140. // 128X64OLED液晶底层驱动[8X16]字体库
  141. // 设计者: Guokaiyi
  142. // 描 述: [8X16]西文字符的字模数据 (纵向取模,字节倒序)
  143. // !”#$%&()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
  144. //======================================================
  145. constUCHAR8 code F8X16[]=
  146. {
  147. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0
  148. 0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x30,0x00,0x00,0x00,//!1
  149. 0x00,0x10,0x0C,0x06,0x10,0x0C,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//”2
  150. 0x40,0xC0,0x78,0x40,0xC0,0x78,0x40,0x00,0x04,0x3F,0x04,0x04,0x3F,0x04,0x04,0x00,//#3
  151. 0x00,0x70,0x88,0xFC,0x08,0x30,0x00,0x00,0x00,0x18,0x20,0xFF,0x21,0x1E,0x00,0x00,//$4
  152. 0xF0,0x08,0xF0,0x00,0xE0,0x18,0x00,0x00,0x00,0x21,0x1C,0x03,0x1E,0x21,0x1E,0x00,//%5
  153. 0x00,0xF0,0x08,0x88,0x70,0x00,0x00,0x00,0x1E,0x21,0x23,0x24,0x19,0x27,0x21,0x10,//&6
  154. 0x10,0x16,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//7
  155. 0x00,0x00,0x00,0xE0,0x18,0x04,0x02,0x00,0x00,0x00,0x00,0x07,0x18,0x20,0x40,0x00,//(8
  156. 0x00,0x02,0x04,0x18,0xE0,0x00,0x00,0x00,0x00,0x40,0x20,0x18,0x07,0x00,0x00,0x00,//)9
  157. 0x40,0x40,0x80,0xF0,0x80,0x40,0x40,0x00,0x02,0x02,0x01,0x0F,0x01,0x02,0x02,0x00,//*10
  158. 0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x1F,0x01,0x01,0x01,0x00,//+11
  159. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xB0,0x70,0x00,0x00,0x00,0x00,0x00,//,12
  160. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,//-13
  161. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,//.14
  162. 0x00,0x00,0x00,0x00,0x80,0x60,0x18,0x04,0x00,0x60,0x18,0x06,0x01,0x00,0x00,0x00,///15
  163. 0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,//016
  164. 0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//117
  165. 0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,//218
  166. 0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,//319
  167. 0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,//420
  168. 0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,//521
  169. 0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,//622
  170. 0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,//723
  171. 0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,//824
  172. 0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,//925
  173. 0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,//:26
  174. 0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x60,0x00,0x00,0x00,0x00,//;27
  175. 0x00,0x00,0x80,0x40,0x20,0x10,0x08,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x00,//<28
  176. 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00,//=29
  177. 0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x20,0x10,0x08,0x04,0x02,0x01,0x00,//>30
  178. 0x00,0x70,0x48,0x08,0x08,0x08,0xF0,0x00,0x00,0x00,0x00,0x30,0x36,0x01,0x00,0x00,//?31
  179. 0xC0,0x30,0xC8,0x28,0xE8,0x10,0xE0,0x00,0x07,0x18,0x27,0x24,0x23,0x14,0x0B,0x00,//@32
  180. 0x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20,//A33
  181. 0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00,//B34
  182. 0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00,//C35
  183. 0x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,0x20,0x3F,0x20,0x20,0x20,0x10,0x0F,0x00,//D36
  184. 0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x20,0x23,0x20,0x18,0x00,//E37
  185. 0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x00,0x03,0x00,0x00,0x00,//F38
  186. 0xC0,0x30,0x08,0x08,0x08,0x38,0x00,0x00,0x07,0x18,0x20,0x20,0x22,0x1E,0x02,0x00,//G39
  187. 0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x20,0x3F,0x21,0x01,0x01,0x21,0x3F,0x20,//H40
  188. 0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//I41
  189. 0x00,0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,0x00,//J42
  190. 0x08,0xF8,0x88,0xC0,0x28,0x18,0x08,0x00,0x20,0x3F,0x20,0x01,0x26,0x38,0x20,0x00,//K43
  191. 0x08,0xF8,0x08,0x00,0x00,0x00,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x20,0x30,0x00,//L44
  192. 0x08,0xF8,0xF8,0x00,0xF8,0xF8,0x08,0x00,0x20,0x3F,0x00,0x3F,0x00,0x3F,0x20,0x00,//M45
  193. 0x08,0xF8,0x30,0xC0,0x00,0x08,0xF8,0x08,0x20,0x3F,0x20,0x00,0x07,0x18,0x3F,0x00,//N46
  194. 0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x10,0x20,0x20,0x20,0x10,0x0F,0x00,//O47
  195. 0x08,0xF8,0x08,0x08,0x08,0x08,0xF0,0x00,0x20,0x3F,0x21,0x01,0x01,0x01,0x00,0x00,//P48
  196. 0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x18,0x24,0x24,0x38,0x50,0x4F,0x00,//Q49
  197. 0x08,0xF8,0x88,0x88,0x88,0x88,0x70,0x00,0x20,0x3F,0x20,0x00,0x03,0x0C,0x30,0x20,//R50
  198. 0x00,0x70,0x88,0x08,0x08,0x08,0x38,0x00,0x00,0x38,0x20,0x21,0x21,0x22,0x1C,0x00,//S51
  199. 0x18,0x08,0x08,0xF8,0x08,0x08,0x18,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//T52
  200. 0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//U53
  201. 0x08,0x78,0x88,0x00,0x00,0xC8,0x38,0x08,0x00,0x00,0x07,0x38,0x0E,0x01,0x00,0x00,//V54
  202. 0xF8,0x08,0x00,0xF8,0x00,0x08,0xF8,0x00,0x03,0x3C,0x07,0x00,0x07,0x3C,0x03,0x00,//W55
  203. 0x08,0x18,0x68,0x80,0x80,0x68,0x18,0x08,0x20,0x30,0x2C,0x03,0x03,0x2C,0x30,0x20,//X56
  204. 0x08,0x38,0xC8,0x00,0xC8,0x38,0x08,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//Y57
  205. 0x10,0x08,0x08,0x08,0xC8,0x38,0x08,0x00,0x20,0x38,0x26,0x21,0x20,0x20,0x18,0x00,//Z58
  206. 0x00,0x00,0x00,0xFE,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x7F,0x40,0x40,0x40,0x00,//[59
  207. 0x00,0x0C,0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x06,0x38,0xC0,0x00,//\60
  208. 0x00,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x7F,0x00,0x00,0x00,//]61
  209. 0x00,0x00,0x04,0x02,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//^62
  210. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,//_63
  211. 0x00,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//`64
  212. 0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x19,0x24,0x22,0x22,0x22,0x3F,0x20,//a65
  213. 0x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00,//b66
  214. 0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00,//c67
  215. 0x00,0x00,0x00,0x80,0x80,0x88,0xF8,0x00,0x00,0x0E,0x11,0x20,0x20,0x10,0x3F,0x20,//d68
  216. 0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x22,0x22,0x22,0x22,0x13,0x00,//e69
  217. 0x00,0x80,0x80,0xF0,0x88,0x88,0x88,0x18,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//f70
  218. 0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x6B,0x94,0x94,0x94,0x93,0x60,0x00,//g71
  219. 0x08,0xF8,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//h72
  220. 0x00,0x80,0x98,0x98,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//i73
  221. 0x00,0x00,0x00,0x80,0x98,0x98,0x00,0x00,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,//j74
  222. 0x08,0xF8,0x00,0x00,0x80,0x80,0x80,0x00,0x20,0x3F,0x24,0x02,0x2D,0x30,0x20,0x00,//k75
  223. 0x00,0x08,0x08,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//l76
  224. 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F,//m77
  225. 0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//n78
  226. 0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//o79
  227. 0x80,0x80,0x00,0x80,0x80,0x00,0x00,0x00,0x80,0xFF,0xA1,0x20,0x20,0x11,0x0E,0x00,//p80
  228. 0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x0E,0x11,0x20,0x20,0xA0,0xFF,0x80,//q81
  229. 0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x20,0x20,0x3F,0x21,0x20,0x00,0x01,0x00,//r82
  230. 0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x33,0x24,0x24,0x24,0x24,0x19,0x00,//s83
  231. 0x00,0x80,0x80,0xE0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x1F,0x20,0x20,0x00,0x00,//t84
  232. 0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x1F,0x20,0x20,0x20,0x10,0x3F,0x20,//u85
  233. 0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x00,0x01,0x0E,0x30,0x08,0x06,0x01,0x00,//v86
  234. 0x80,0x80,0x00,0x80,0x00,0x80,0x80,0x80,0x0F,0x30,0x0C,0x03,0x0C,0x30,0x0F,0x00,//w87
  235. 0x00,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x31,0x2E,0x0E,0x31,0x20,0x00,//x88
  236. 0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x80,0x81,0x8E,0x70,0x18,0x06,0x01,0x00,//y89
  237. 0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x21,0x30,0x2C,0x22,0x21,0x30,0x00,//z90
  238. 0x00,0x00,0x00,0x00,0x80,0x7C,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x3F,0x40,0x40,//{91
  239. 0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,//|92
  240. 0x00,0x02,0x02,0x7C,0x80,0x00,0x00,0x00,0x00,0x40,0x40,0x3F,0x00,0x00,0x00,0x00,//}93
  241. 0x00,0x06,0x01,0x01,0x02,0x02,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//~94
  242. };
  243. /*—————————————————————————-*
  244. * 内部函数原型 *
  245. *—————————————————————————-*/
  246. VOIDLED_WrDat(UCHAR8 ucData);
  247. VOIDLED_WrCmd(UCHAR8 ucCmd);
  248. VOIDLED_SetPos(UCHAR8 ucIdxX,UCHAR8 ucIdxY);
  249. VOIDSetStartColumn(UCHAR8 ucData);
  250. VOIDSetAddressingMode(UCHAR8 ucData);
  251. VOIDSetColumnAddress(UCHAR8 a,UCHAR8 b);
  252. VOIDSetPageAddress(UCHAR8 a,UCHAR8 b);
  253. VOIDSetStartLine(UCHAR8 d);
  254. VOIDSetContrastControl(UCHAR8 d);
  255. VOIDSetChargePump(UCHAR8 d);
  256. VOIDSetSegmentRemap(UCHAR8 d);
  257. VOIDSetEntireDisplay(UCHAR8 d);
  258. VOIDSetInverseDisplay(UCHAR8 d);
  259. VOIDSetMultiplexRatio(UCHAR8 d);
  260. VOIDSetDisplayOnOff(UCHAR8 d);
  261. VOIDSetStartPage(UCHAR8 d);
  262. VOIDSetCommonRemap(UCHAR8 d);
  263. VOIDSetDisplayOffset(UCHAR8 d);
  264. VOIDSetDisplayClock(UCHAR8 d);
  265. VOIDSetPrechargePeriod(UCHAR8 d);
  266. VOIDSetCommonConfig(UCHAR8 d);
  267. VOIDSetVCOMH(UCHAR8 d);
  268. VOIDSetNop(VOID);
  269. /*—————————————————————————-*
  270. * 外部函数原型 *
  271. *—————————————————————————-*/
  272. /**********************************************
  273. //IIC Start
  274. **********************************************/
  275. voidIIC_Start()
  276. {
  277. LED_SCL=1;
  278. //Delay_us(1);
  279. LED_SDA=1;
  280. //Delay_us(1);
  281. LED_SDA=0;
  282. // Delay_us(1);
  283. LED_SCL=0;
  284. // Delay_us(1);
  285. }
  286. /**********************************************
  287. //IIC Stop
  288. **********************************************/
  289. voidIIC_Stop()
  290. {
  291. LED_SCL=0;
  292. //Delay_us(1);
  293. LED_SDA=0;
  294. //Delay_us(1);
  295. LED_SCL=1;
  296. //Delay_us(1);
  297. LED_SDA=1;
  298. //Delay_us(1);
  299. }
  300. /**********************************************
  301. // IIC Write byte
  302. **********************************************/
  303. voidWrite_IIC_Byte(unsignedcharIIC_Byte)
  304. {
  305. unsignedchari;
  306. for(i=0;i<8;i++)
  307. {
  308. if(IIC_Byte&0x80)//1?0?
  309. LED_SDA=1;
  310. else
  311. LED_SDA=0;
  312. //Delay_us(1);
  313. LED_SCL=1;
  314. //Delay_us(1);
  315. LED_SCL=0;
  316. //Delay_us(1);
  317. IIC_Byte<<=1;//loop
  318. }
  319. LED_SDA=1;
  320. //Delay_us(1);
  321. LED_SCL=1;
  322. //Delay_us(1);
  323. LED_SCL=0;
  324. //Delay_us(1);
  325. }
  326. /*****************************************************************************
  327. 函 数 名 : LED_WrDat
  328. 功用描绘 : 向OLED写数据
  329. 输入参数 : UCHAR8 ucData
  330. 输出参数 : NONE
  331. 返 回 值 : NONE
  332. *****************************************************************************/
  333. VOIDLED_WrDat(UCHAR8 ucData)
  334. {
  335. IIC_Start();
  336. Write_IIC_Byte(0x78);
  337. Write_IIC_Byte(0x40);//write data
  338. Write_IIC_Byte(ucData);
  339. IIC_Stop();
  340. }
  341. /*****************************************************************************
  342. 函 数 名 : LED_WrCmd
  343. 功用描绘 : 向OLED写指令
  344. 输入参数 : UCHAR8 ucCmd
  345. 输出参数 : NONE
  346. 返 回 值 : NONE
  347. *****************************************************************************/
  348. VOIDLED_WrCmd(UCHAR8 ucCmd)
  349. {
  350. IIC_Start();
  351. Write_IIC_Byte(0x78);//Slave address,SA0=0
  352. Write_IIC_Byte(0x00);//write command
  353. Write_IIC_Byte(ucCmd);
  354. IIC_Stop();
  355. }
  356. /*****************************************************************************
  357. 函 数 名 : LED_SetPos
  358. 功用描绘 : 设置坐标
  359. 输入参数 : UCHAR8 ucIdxX
  360. UCHAR8 ucIdxY
  361. 输出参数 : NONE
  362. 返 回 值 : NONE
  363. *****************************************************************************/
  364. VOIDLED_SetPos(UCHAR8 ucIdxX,UCHAR8 ucIdxY)
  365. {
  366. LED_WrCmd(0xb0+ucIdxY);
  367. LED_WrCmd(((ucIdxX&0xf0)>>4)|0x10);
  368. LED_WrCmd((ucIdxX&0x0f)|0x00);
  369. }
  370. /*****************************************************************************
  371. 函 数 名 : LED_Fill
  372. 功用描绘 : 对全屏写入同一个字符函数
  373. 如 LED_Fill(0x01); 关于某一位0为不亮 1为亮
  374. ——————————————————
  375. 共128列
  376. 1 1 1
  377. 共 0 0 0
  378. 8 0 0 0
  379. 组 0 ……0 ………… 0
  380. 字 0 0 0
  381. 符 0 0 0
  382. 即 0 0 0
  383. 8 0 0 0
  384. 页 1 1 1
  385. 64 0 0 0
  386. 行 . . .
  387. . . ………… .
  388. . . .
  389. . . .
  390. 0 0 0
  391. ——————————————————
  392. 输入参数 : UCHAR8 ucData
  393. 输出参数 : NONE
  394. 返 回 值 : NONE
  395. *****************************************************************************/
  396. VOIDLED_Fill(UCHAR8 ucData)
  397. {
  398. UCHAR8 ucPage,ucColumn;
  399. for(ucPage=0;ucPage<8;ucPage++)
  400. {
  401. LED_WrCmd(0xb0+ucPage);//0xb0+0~7表明页0~7
  402. LED_WrCmd(0x00);//0x00+0~16表明将128列分红16组其地址在某组中的第几列
  403. LED_WrCmd(0x10);//0x10+0~16表明将128列分红16组其地址地点第几组
  404. for(ucColumn=0;ucColumn<128;ucColumn++)
  405. {
  406. LED_WrDat(ucData);
  407. }
  408. }
  409. }
  410. VOIDSetStartColumn(UCHAR8 ucData)
  411. {
  412. LED_WrCmd(0x00+ucData%16);// Set Lower Column Start Address for Page Addressing Mode
  413. // Default => 0x00
  414. LED_WrCmd(0x10+ucData/16);// Set Higher Column Start Address for Page Addressing Mode
  415. // Default => 0x10
  416. }
  417. VOIDSetAddressingMode(UCHAR8 ucData)
  418. {
  419. LED_WrCmd(0x20);// Set Memory Addressing Mode
  420. LED_WrCmd(ucData);// Default => 0x02
  421. // 0x00 => Horizontal Addressing Mode
  422. // 0x01 => Vertical Addressing Mode
  423. // 0x02 => Page Addressing Mode
  424. }
  425. VOIDSetColumnAddress(UCHAR8 a,UCHAR8 b)
  426. {
  427. LED_WrCmd(0x21);// Set Column Address
  428. LED_WrCmd(a);// Default => 0x00 (Column Start Address)
  429. LED_WrCmd(b);// Default => 0x7F (Column End Address)
  430. }
  431. VOIDSetPageAddress(UCHAR8 a,UCHAR8 b)
  432. {
  433. LED_WrCmd(0x22);// Set Page Address
  434. LED_WrCmd(a);// Default => 0x00 (Page Start Address)
  435. LED_WrCmd(b);// Default => 0x07 (Page End Address)
  436. }
  437. VOIDSetStartLine(UCHAR8 ucData)
  438. {
  439. LED_WrCmd(0x40|ucData);// Set Display Start Line
  440. // Default => 0x40 (0x00)
  441. }
  442. VOIDSetContrastControl(UCHAR8 ucData)
  443. {
  444. LED_WrCmd(0x81);// Set Contrast Control
  445. LED_WrCmd(ucData);// Default => 0x7F
  446. }
  447. VOIDSetChargePump(UCHAR8 ucData)
  448. {
  449. LED_WrCmd(0x8D);// Set Charge Pump
  450. LED_WrCmd(0x10|ucData);// Default => 0x10
  451. // 0x10 (0x00) => Disable Charge Pump
  452. // 0x14 (0x04) => Enable Charge Pump
  453. }
  454. VOIDSetSegmentRemap(UCHAR8 ucData)
  455. {
  456. LED_WrCmd(0xA0|ucData);// Set Segment Re-Map
  457. // Default => 0xA0
  458. // 0xA0 (0x00) => Column Address 0 Mapped to SEG0
  459. // 0xA1 (0x01) => Column Address 0 Mapped to SEG127
  460. }
  461. VOIDSetEntireDisplay(UCHAR8 ucData)
  462. {
  463. LED_WrCmd(0xA4|ucData);// Set Entire Display On / Off
  464. // Default => 0xA4
  465. // 0xA4 (0x00) => Normal Display
  466. // 0xA5 (0x01) => Entire Display On
  467. }
  468. VOIDSetInverseDisplay(UCHAR8 ucData)
  469. {
  470. LED_WrCmd(0xA6|ucData);// Set Inverse Display On/Off
  471. // Default => 0xA6
  472. // 0xA6 (0x00) => Normal Display
  473. // 0xA7 (0x01) => Inverse Display On
  474. }
  475. VOIDSetMultiplexRatio(UCHAR8 ucData)
  476. {
  477. LED_WrCmd(0xA8);// Set Multiplex Ratio
  478. LED_WrCmd(ucData);// Default => 0x3F (1/64 Duty)
  479. }
  480. VOIDSetDisplayOnOff(UCHAR8 ucData)
  481. {
  482. LED_WrCmd(0xAE|ucData);// Set Display On/Off
  483. // Default => 0xAE
  484. // 0xAE (0x00) => Display Off
  485. // 0xAF (0x01) => Display On
  486. }
  487. VOIDSetStartPage(UCHAR8 ucData)
  488. {
  489. LED_WrCmd(0xB0|ucData);// Set Page Start Address for Page Addressing Mode
  490. // Default => 0xB0 (0x00)
  491. }
  492. VOIDSetCommonRemap(UCHAR8 ucData)
  493. {
  494. LED_WrCmd(0xC0|ucData);// Set COM Output Scan Direction
  495. // Default => 0xC0
  496. // 0xC0 (0x00) => Scan from COM0 to 63
  497. // 0xC8 (0x08) => Scan from COM63 to 0
  498. }
  499. VOIDSetDisplayOffset(UCHAR8 ucData)
  500. {
  501. LED_WrCmd(0xD3);// Set Display Offset
  502. LED_WrCmd(ucData);// Default => 0x00
  503. }
  504. VOIDSetDisplayClock(UCHAR8 ucData)
  505. {
  506. LED_WrCmd(0xD5);// Set Display Clock Divide Ratio / Oscillator Frequency
  507. LED_WrCmd(ucData);// Default => 0x80
  508. // D[3:0] => Display Clock Divider
  509. // D[7:4] => Oscillator Frequency
  510. }
  511. VOIDSetPrechargePeriod(UCHAR8 ucData)
  512. {
  513. LED_WrCmd(0xD9);// Set Pre-Charge Period
  514. LED_WrCmd(ucData);// Default => 0x22 (2 Display Clocks [Phase 2] / 2 Display Clocks [Phase 1])
  515. // D[3:0] => Phase 1 Period in 1~15 Display Clocks
  516. // D[7:4] => Phase 2 Period in 1~15 Display Clocks
  517. }
  518. VOIDSetCommonConfig(UCHAR8 ucData)
  519. {
  520. LED_WrCmd(0xDA);// Set COM Pins Hardware Configuration
  521. LED_WrCmd(0x02|ucData);// Default => 0x12 (0x10)
  522. // Alternative COM Pin Configuration
  523. // Disable COM Left/Right Re-Map
  524. }
  525. VOIDSetVCOMH(UCHAR8 ucData)
  526. {
  527. LED_WrCmd(0xDB);// Set VCOMH Deselect Level
  528. LED_WrCmd(ucData);// Default => 0x20 (0.77*VCC)
  529. }
  530. VOIDSetNop(VOID)
  531. {
  532. LED_WrCmd(0xE3);// Command for No Operation
  533. }
  534. /*****************************************************************************
  535. 函 数 名 : LED_Init
  536. 功用描绘 : OLED初始化
  537. 输入参数 : VOID
  538. 输出参数 : NONE
  539. 返 回 值 : NONE
  540. *****************************************************************************/
  541. VOIDLED_Init(VOID)
  542. {
  543. UCHAR8 i;
  544. LED_SCL=1;
  545. LED_RST=0;
  546. for(i=0;i<100;i++)
  547. {
  548. _nop_();//从上电到下面开端初始化要有满足的时刻,即等候RC复位结束
  549. }
  550. LED_RST=1;
  551. SetDisplayOnOff(0x00);// Display Off (0x00/0x01)
  552. SetDisplayClock(0x80);// Set Clock as 100 Frames/Sec
  553. SetMultiplexRatio(0x3F);// 1/64 Duty (0x0F~0x3F)
  554. SetDisplayOffset(0x00);// Shift Mapping RAM Counter (0x00~0x3F)
  555. SetStartLine(0x00);// Set Mapping RAM Display Start Line (0x00~0x3F)
  556. SetChargePump(0x04);// Enable Embedded DC/DC Converter (0x00/0x04)
  557. SetAddressingMode(0x02);// Set Page Addressing Mode (0x00/0x01/0x02)
  558. SetSegmentRemap(0x01);// Set SEG/Column Mapping 0x00左右反置 0x01正常
  559. SetCommonRemap(0x08);// Set COM/Row Scan Direction 0x00上下反置 0x08正常
  560. SetCommonConfig(0x10);// Set Sequential Configuration (0x00/0x10)
  561. SetContrastControl(0xCF);// Set SEG Output Current
  562. SetPrechargePeriod(0xF1);// Set Pre-Charge as 15 Clocks & Discharge as 1 Clock
  563. SetVCOMH(0x40);// Set VCOM Deselect Level
  564. SetEntireDisplay(0x00);// Disable Entire Display On (0x00/0x01)
  565. SetInverseDisplay(0x00);// Disable Inverse Display On (0x00/0x01)
  566. SetDisplayOnOff(0x01);// Display On (0x00/0x01)
  567. LED_Fill(0x00);// 初始清屏
  568. LED_SetPos(0,0);
  569. return;
  570. }
  571. /*****************************************************************************
  572. 函 数 名 : LED_P6x8Char
  573. 功用描绘 : 显现一个6×8规范ASCII字符
  574. 输入参数 : UCHAR8 ucIdxX 显现的横坐标0~122
  575. UCHAR8 ucIdxY 页规模0~7
  576. UCHAR8 ucData 显现的字符
  577. 输出参数 : NONE
  578. 返 回 值 : NONE
  579. *****************************************************************************/
  580. VOIDLED_P6x8Char(UCHAR8 ucIdxX,UCHAR8 ucIdxY,UCHAR8 ucData)
  581. {
  582. UCHAR8 i,ucDataTmp;
  583. ucDataTmp=ucData-32;
  584. if(ucIdxX>122)
  585. {
  586. ucIdxX=0;
  587. ucIdxY++;
  588. }
  589. LED_SetPos(ucIdxX,ucIdxY);
  590. for(i=0;i<6;i++)
  591. {
  592. LED_WrDat(F6x8[ucDataTmp][i]);
  593. }
  594. }
  595. /*****************************************************************************
  596. 函 数 名 : LED_P6x8Str
  597. 功用描绘 : 写入一组6×8规范ASCII字符串
  598. 输入参数 : UCHAR8 ucIdxX 显现的横坐标0~122
  599. UCHAR8 ucIdxY 页规模0~7
  600. UCHAR8 ucDataStr[] 显现的字符串
  601. 输出参数 : NONE
  602. 返 回 值 : NONE
  603. *****************************************************************************/
  604. VOIDLED_P6x8Str(UCHAR8 ucIdxX,UCHAR8 ucIdxY,UCHAR8 ucDataStr[])
  605. {
  606. UCHAR8 i,j,ucDataTmp;
  607. for(j=0;ucDataStr[j]!=\0;j++)
  608. {
  609. ucDataTmp=ucDataStr[j]-32;
  610. if(ucIdxX>122)
  611. {
  612. ucIdxX=0;
  613. ucIdxY++;
  614. }
  615. LED_SetPos(ucIdxX,ucIdxY);
  616. for(i=0;i<6;i++)
  617. {
  618. LED_WrDat(F6x8[ucDataTmp][i]);
  619. }
  620. ucIdxX+=6;
  621. }
  622. return;
  623. }
  624. /*****************************************************************************
  625. 函 数 名 : LED_P8x16Str
  626. 功用描绘 : 写入一组8×16规范ASCII字符串
  627. 输入参数 : UCHAR8 ucIdxX 为显现的横坐标0~120
  628. UCHAR8 ucIdxY 为页规模0~3
  629. UCHAR8 ucDataStr[] 要显现的字符串
  630. 输出参数 : NONE
  631. 返 回 值 : NONE
  632. *****************************************************************************/
  633. VOIDLED_P8x16Str(UCHAR8 ucIdxX,UCHAR8 ucIdxY,UCHAR8 ucDataStr[])
  634. {
  635. UCHAR8 i,j,ucDataTmp;
  636. ucIdxY<<=1;
  637. for(j=0;ucDataStr[j]!=\0;j++)
  638. {
  639. ucDataTmp=ucDataStr[j]-32;
  640. if(ucIdxX>120)
  641. {
  642. ucIdxX=0;
  643. ucIdxY+=2;
  644. }
  645. LED_SetPos(ucIdxX,ucIdxY);
  646. for(i=0;i<8;i++)
  647. {
  648. LED_WrDat(F8X16[(ucDataTmp<<4)+i]);
  649. }
  650. LED_SetPos(ucIdxX,ucIdxY+1);
  651. for(i=0;i<8;i++)
  652. {
  653. LED_WrDat(F8X16[(ucDataTmp<<4)+i+8]);
  654. }
  655. ucIdxX+=8;
  656. }
  657. return;
  658. }
  659. /*****************************************************************************
  660. 函 数 名 : LED_P14x16Str
  661. 功用描绘 : 写入一组14×16的中文字符串(字符串表格中需含有此字)
  662. 输入参数 : UCHAR8 ucIdxX 为显现的横坐标0~114
  663. UCHAR8 ucIdxY 为页规模0~3
  664. UCHAR8 ucDataStr[] 要显现的中文字符串
  665. 输出参数 : NONE
  666. 返 回 值 : NONE
  667. *****************************************************************************/
  668. VOIDLED_P14x16Str(UCHAR8 ucIdxX,UCHAR8 ucIdxY,UCHAR8 ucDataStr[])
  669. {
  670. UCHAR8 i,j;
  671. USHORT16 usAddress;
  672. ucIdxY<<=1;
  673. j=0;
  674. while(ucDataStr[j]!=\0)
  675. {
  676. i=0;
  677. usAddress=1;
  678. while(F14x16_Idx[i]>127)
  679. {
  680. if(F14x16_Idx[i]==ucDataStr[j])
  681. {
  682. if(F14x16_Idx[i+1]==ucDataStr[j+1])
  683. {
  684. usAddress=i*14;
  685. break;
  686. }
  687. }
  688. i+=2;
  689. }
  690. if(ucIdxX>114)
  691. {
  692. ucIdxX=0;
  693. ucIdxY+=2;
  694. }
  695. if(usAddress!=1)// 显现汉字
  696. {
  697. LED_SetPos(ucIdxX,ucIdxY);
  698. for(i=0;i<14;i++)
  699. {
  700. LED_WrDat(F14x16[usAddress]);
  701. usAddress++;
  702. }
  703. LED_SetPos(ucIdxX,ucIdxY+1);
  704. for(i=0;i<14;i++)
  705. {
  706. LED_WrDat(F14x16[usAddress]);
  707. usAddress++;
  708. }
  709. j+=2;
  710. }
  711. else//显现空白字符
  712. {
  713. LED_SetPos(ucIdxX,ucIdxY);
  714. for(i=0;i<14;i++)
  715. {
  716. LED_WrDat(0);
  717. }
  718. LED_SetPos(ucIdxX,ucIdxY+1);
  719. for(i=0;i<14;i++)
  720. {
  721. LED_WrDat(0);
  722. }
  723. j++;
  724. }
  725. ucIdxX+=14;
  726. }
  727. return;
  728. }
  729. /*****************************************************************************
  730. 函 数 名 : LED_PXx16MixStr
  731. 功用描绘 : 输出14×16汉字和字符混合字符串 (字符串表格中需含有此字)
  732. 输入参数 : UCHAR8 ucIdxX 为显现的横坐标0~114
  733. UCHAR8 ucIdxY 为页规模0~3
  734. UCHAR8 ucDataStr[] 要显现的中文字符串
  735. 输出参数 : NONE
  736. 返 回 值 : NONE
  737. *****************************************************************************/
  738. VOIDLED_PXx16MixStr(UCHAR8 ucIdxX,UCHAR8 ucIdxY,UCHAR8 ucDataStr[])
  739. {
  740. UCHAR8 ucTmpStr[3];
  741. UCHAR8 i=0;
  742. while(ucDataStr[i]!=\0)
  743. {
  744. if(ucDataStr[i]>127)
  745. {
  746. ucTmpStr[0]=ucDataStr[i];
  747. ucTmpStr[1]=ucDataStr[i+1];
  748. ucTmpStr[2]=\0;//汉字为两个字节
  749. LED_P14x16Str(ucIdxX,ucIdxY,ucTmpStr);//显现汉字
  750. ucIdxX+=14;
  751. i+=2;
  752. }
  753. else
  754. {
  755. ucTmpStr[0]=ucDataStr[i];
  756. ucTmpStr[1]=\0;//字母占一个字节
  757. LED_P8x16Str(ucIdxX,ucIdxY,ucTmpStr);//显现字母
  758. ucIdxX+=8;
  759. i+=1;
  760. }
  761. }
  762. return;
  763. }
  764. /*****************************************************************************
  765. 函 数 名 : LED_PrintChar
  766. 功用描绘 : 将一个Char型数转换成3位数进行显现
  767. 输入参数 : UCHAR8 ucIdxX ucIdxX的规模为0~122
  768. UCHAR8 ucIdxY ucIdxY的规模为0~7
  769. CHAR8 cData cData为需求转化显现的数值 -128~127
  770. 输出参数 : none
  771. 返 回 值 : none
  772. *****************************************************************************/
  773. VOIDLED_PrintChar(UCHAR8 ucIdxX,UCHAR8 ucIdxY,CHAR8 cData)
  774. {
  775. USHORT16 i,j,k,usData;
  776. if(cData<0)
  777. {
  778. LED_P6x8Char(ucIdxX,ucIdxY,-);
  779. usData=(USHORT16)(-cData);
  780. }
  781. else
  782. {
  783. LED_P6x8Char(ucIdxX,ucIdxY,+);
  784. usData=(USHORT16)cData;
  785. }
  786. i=usData/100;
  787. j=(usData%100)/10;
  788. k=usData%10;
  789. LED_P6x8Char(ucIdxX+6,ucIdxY,i+48);
  790. LED_P6x8Char(ucIdxX+12,ucIdxY,j+48);
  791. LED_P6x8Char(ucIdxX+18,ucIdxY,k+48);
  792. return;
  793. }
  794. /*****************************************************************************
  795. 函 数 名 : LED_PrintShort
  796. 功用描绘 : 将一个Short型数转换成5位数进行显现
  797. 输入参数 : UCHAR8 ucIdxX ucIdxX的规模为0~120
  798. UCHAR8 ucIdxY ucIdxY为页的规模0~7
  799. SHORT16 sData sData为需求转化显现的数值
  800. 输出参数 : none
  801. 返 回 值 : none
  802. *****************************************************************************/
  803. VOIDLED_PrintShort(UCHAR8 ucIdxX,UCHAR8 ucIdxY,SHORT16 sData)
  804. {
  805. USHORT16 i,j,k,l,m,usData;
  806. if(sData<0)
  807. {
  808. LED_P6x8Char(ucIdxX,ucIdxY,-);
  809. usData=(USHORT16)(-sData);
  810. }
  811. else
  812. {
  813. LED_P6x8Char(ucIdxX,ucIdxY,+);
  814. usData=(USHORT16)sData;
  815. }
  816. l=usData/10000;
  817. m=(usData%10000)/1000;
  818. i=(usData%1000)/100;
  819. j=(usData%100)/10;
  820. k=usData%10;
  821. LED_P6x8Char(ucIdxX+6,ucIdxY,l+48);
  822. LED_P6x8Char(ucIdxX+12,ucIdxY,m+48);
  823. LED_P6x8Char(ucIdxX+18,ucIdxY,i+48);
  824. LED_P6x8Char(ucIdxX+24,ucIdxY,j+48);
  825. LED_P6x8Char(ucIdxX+30,ucIdxY,k+48);
  826. return;
  827. }
  828. /*****************************************************************************
  829. 函 数 名 : LED_PrintImage
  830. 功用描绘 : 将图画显现出来
  831. 输入参数 : UCHAR8 *pucTable 二维图画数组的地址
  832. USHORT16 usRowNum 二维图画的行数1~64
  833. USHORT16 usColumnNum 二维图画的列数1~128
  834. 输出参数 : none
  835. 返 回 值 : none
  836. *****************************************************************************/
  837. VOIDLED_PrintImage(UCHAR8*pucTable,USHORT16 usRowNum,USHORT16 usColumnNum)
  838. {
  839. UCHAR8 ucData;
  840. USHORT16 i,j,k,m,n;
  841. USHORT16 usRowTmp;
  842. m=usRowNum>>3;//核算图片行数以8位为一组完好的组数
  843. n=usRowNum%8;//核算分完组后剩余的行数
  844. for(i=0;i
  845. {
  846. LED_SetPos(0,(UCHAR8)i);
  847. usRowTmp=i<<3;//核算当时地点行的下标
  848. for(j=0;j
  849. {
  850. ucData=0;
  851. for(k=0;k<8;k++)//在i组中对这8行扫描
  852. {
  853. ucData=ucData>>1;
  854. if((pucTable+(usRowTmp+k)*usColumnNum)[j]==LED_IMAGE_WHITE)
  855. {
  856. ucData=ucData|0x80;
  857. }
  858. }
  859. LED_WrDat(ucData);
  860. }
  861. }
  862. LED_SetPos(0,(UCHAR8)i);//设置剩余的行显现的开始坐标
  863. usRowTmp=i<<3;//核算当时地点行的下标
  864. for(j=0;j
  865. {
  866. ucData=0;
  867. for(k=0;k
  868. {
  869. ucData=ucData>>1;
  870. if((pucTable+(usRowTmp+k)*usColumnNum)[j]==LED_IMAGE_WHITE)
  871. {
  872. ucData=ucData|0x80;
  873. }
  874. }
  875. ucData=ucData>>(8-n);
  876. LED_WrDat(ucData);
  877. }
  878. return;
  879. }

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/zhishi/jichu/275291.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部