Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926
  1. #include "LCD.h"
  2. u8 ucDispDT;
  3. static const u8 font816[38][16]=
  4. {
  5. {0xF8,0xFC,0x04,0xC4,0x24,0xFC,0xF8,0x00,0x07,0x0F,0x09,0x08,0x08,0x0F,0x07,0x00}, // -0-
  6. {0x00,0x10,0x18,0xFC,0xFC,0x00,0x00,0x00,0x00,0x08,0x08,0x0F,0x0F,0x08,0x08,0x00}, // -1-
  7. {0x08,0x0C,0x84,0xC4,0x64,0x3C,0x18,0x00,0x0E,0x0F,0x09,0x08,0x08,0x0C,0x0C,0x00}, // -2-
  8. {0x08,0x0C,0x44,0x44,0x44,0xFC,0xB8,0x00,0x04,0x0C,0x08,0x08,0x08,0x0F,0x07,0x00}, // -3-
  9. {0xC0,0xE0,0xB0,0x98,0xFC,0xFC,0x80,0x00,0x00,0x00,0x00,0x08,0x0F,0x0F,0x08,0x00}, // -4-
  10. {0x7C,0x7C,0x44,0x44,0xC4,0xC4,0x84,0x00,0x04,0x0C,0x08,0x08,0x08,0x0F,0x07,0x00}, // -5-
  11. {0xF0,0xF8,0x4C,0x44,0x44,0xC0,0x80,0x00,0x07,0x0F,0x08,0x08,0x08,0x0F,0x07,0x00}, // -6-
  12. {0x0C,0x0C,0x04,0x84,0xC4,0x7C,0x3C,0x00,0x00,0x00,0x0F,0x0F,0x00,0x00,0x00,0x00}, // -7-
  13. {0xB8,0xFC,0x44,0x44,0x44,0xFC,0xB8,0x00,0x07,0x0F,0x08,0x08,0x08,0x0F,0x07,0x00}, // -8-
  14. {0x38,0x7C,0x44,0x44,0x44,0xFC,0xF8,0x00,0x00,0x08,0x08,0x08,0x0C,0x07,0x03,0x00}, // -9-
  15. {0xE0,0xF0,0x98,0x8C,0x98,0xF0,0xE0,0x00,0x0F,0x0F,0x00,0x00,0x00,0x0F,0x0F,0x00}, // -A- 10
  16. {0x04,0xFC,0xFC,0x44,0x44,0xFC,0xB8,0x00,0x08,0x0F,0x0F,0x08,0x08,0x0F,0x07,0x00}, // -B- 11
  17. {0xF0,0xF8,0x0C,0x04,0x04,0x0C,0x18,0x00,0x03,0x07,0x0C,0x08,0x08,0x0C,0x06,0x00}, // -C- 12
  18. {0x04,0xFC,0xFC,0x04,0x0C,0xF8,0xF0,0x00,0x08,0x0F,0x0F,0x08,0x0C,0x07,0x03,0x00}, // -D- 13
  19. {0x04,0xFC,0xFC,0x44,0xE4,0x0C,0x1C,0x00,0x08,0x0F,0x0F,0x08,0x08,0x0C,0x0E,0x00}, // -E- 14
  20. {0x04,0xFC,0xFC,0x44,0xE4,0x0C,0x1C,0x00,0x08,0x0F,0x0F,0x08,0x00,0x00,0x00,0x00}, // -F- 15
  21. {0xF0,0xF8,0x0C,0x84,0x84,0x8C,0x98,0x00,0x03,0x07,0x0C,0x08,0x08,0x07,0x0F,0x00}, // -G- 16
  22. {0xFC,0xFC,0x40,0x40,0x40,0xFC,0xFC,0x00,0x0F,0x0F,0x00,0x00,0x00,0x0F,0x0F,0x00}, // -H- 17
  23. {0x00,0x00,0x04,0xFC,0xFC,0x04,0x00,0x00,0x00,0x00,0x08,0x0F,0x0F,0x08,0x00,0x00}, // -I- 18
  24. {0x00,0x00,0x00,0x04,0xFC,0xFC,0x04,0x00,0x07,0x0F,0x08,0x08,0x0F,0x07,0x00,0x00}, // -J- 19
  25. {0x04,0xFC,0xFC,0xC0,0xF0,0x3C,0x0C,0x00,0x08,0x0F,0x0F,0x00,0x01,0x0F,0x0E,0x00}, // -K- 20
  26. {0x04,0xFC,0xFC,0x04,0x00,0x00,0x00,0x00,0x08,0x0F,0x0F,0x08,0x08,0x0C,0x0E,0x00}, // -L- 21
  27. {0xFC,0xFC,0x38,0x70,0x38,0xFC,0xFC,0x00,0x0F,0x0F,0x00,0x00,0x00,0x0F,0x0F,0x00}, // -M- 22
  28. {0xFC,0xFC,0x38,0x70,0xE0,0xFC,0xFC,0x00,0x0F,0x0F,0x00,0x00,0x00,0x0F,0x0F,0x00}, // -N- 23
  29. {0xF0,0xF8,0x0C,0x04,0x0C,0xF8,0xF0,0x00,0x03,0x07,0x0C,0x08,0x0C,0x07,0x03,0x00}, // -O- 24
  30. {0x04,0xFC,0xFC,0x44,0x44,0x7C,0x38,0x00,0x08,0x0F,0x0F,0x08,0x00,0x00,0x00,0x00}, // -P- 25
  31. {0xF8,0xFC,0x04,0x04,0x04,0xFC,0xF8,0x00,0x07,0x0F,0x08,0x0E,0x3C,0x3F,0x27,0x00}, // -Q- 26
  32. {0x04,0xFC,0xFC,0x44,0xC4,0xFC,0x38,0x00,0x08,0x0F,0x0F,0x00,0x00,0x0F,0x0F,0x00}, // -R- 27
  33. {0x18,0x3C,0x64,0x44,0xC4,0x9C,0x18,0x00,0x06,0x0E,0x08,0x08,0x08,0x0F,0x07,0x00}, // -S- 28
  34. {0x00,0x1C,0x0C,0xFC,0xFC,0x0C,0x1C,0x00,0x00,0x00,0x08,0x0F,0x0F,0x08,0x00,0x00}, // -T- 29
  35. {0xFC,0xFC,0x00,0x00,0x00,0xFC,0xFC,0x00,0x07,0x0F,0x08,0x08,0x08,0x0F,0x07,0x00}, // -U- 30
  36. {0xFC,0xFC,0x00,0x00,0x00,0xFC,0xFC,0x00,0x01,0x03,0x06,0x0C,0x06,0x03,0x01,0x00}, // -V- 31
  37. {0xFC,0xFC,0x00,0x80,0x00,0xFC,0xFC,0x00,0x03,0x0F,0x0E,0x03,0x0E,0x0F,0x03,0x00}, // -W- 32
  38. {0x0C,0x3C,0xF0,0xC0,0xF0,0x3C,0x0C,0x00,0x0C,0x0F,0x03,0x00,0x03,0x0F,0x0C,0x00}, // -X- 33
  39. {0x00,0x3C,0x7C,0xC0,0xC0,0x7C,0x3C,0x00,0x00,0x00,0x08,0x0F,0x0F,0x08,0x00,0x00}, // -Y- 34
  40. {0x1C,0x0C,0x84,0xC4,0x64,0x3C,0x1C,0x00,0x0E,0x0F,0x09,0x08,0x08,0x0C,0x0E,0x00}, // -Z- 35
  41. {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x0C,0x00,0x00,0x00}, // -.- 36
  42. {0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0x00,0x00,0x00}, // -:- 37
  43. };
  44. void Get_8x16_Font(u16 character ,u8* backbuf)
  45. {
  46. if( (character>='0')&&(character<='9'))
  47. {
  48. character -= '0';
  49. }
  50. #if 1
  51. else if( (character>='A')&&(character<='Z'))
  52. {
  53. character = character - 'A' + 10;
  54. }
  55. #endif
  56. else if(character == ':')
  57. {
  58. character = 37;
  59. }
  60. else if(character == '.')
  61. {
  62. character = 36;
  63. }
  64. //backbuf = (uint8 *)(Num612[character]);
  65. memcpy(backbuf, (u8 *)(font816[character]),sizeof(font816[character]));
  66. }
  67. #if 1
  68. void HexToDec(u32 tempdata,u8* buf,unsigned char bufLen)
  69. {
  70. buf[0]=tempdata/1000000000;
  71. buf[1]=tempdata/100000000-(buf[0]*10);
  72. buf[2]=tempdata/10000000-(buf[0]*100)-(buf[1]*10);
  73. buf[3]=tempdata/1000000-buf[0]*1000-buf[1]*100-buf[2]*10;
  74. buf[4]=tempdata/100000-buf[0]*10000-buf[1]*1000-buf[2]*100-buf[3]*10;
  75. buf[5]=tempdata/10000-buf[0]*100000-buf[1]*10000-buf[2]*1000-buf[3]*100-buf[4]*10;
  76. buf[6]=tempdata/1000-buf[0]*1000000-buf[1]*100000-buf[2]*10000-buf[3]*1000-buf[4]*100-buf[5]*10;
  77. buf[7]=tempdata/100-buf[0]*10000000-buf[1]*1000000-buf[2]*100000-buf[3]*10000-buf[4]*1000-buf[5]*100-buf[6]*10;
  78. buf[8]=tempdata/10-buf[0]*100000000-buf[1]*10000000-buf[2]*1000000-buf[3]*100000-buf[4]*10000-buf[5]*1000-buf[6]*100-buf[7]*10;
  79. buf[9]=tempdata-buf[0]*1000000000-buf[1]*100000000-buf[2]*10000000-buf[3]*1000000-buf[4]*100000-buf[5]*10000-buf[6]*1000-buf[7]*100-buf[8]*10;
  80. }
  81. #endif
  82. void AttenuatorConfig(void)
  83. {
  84. GPIO_InitTypeDef GPIO_InitStructure;
  85. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8; //1A
  86. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  87. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //50MHz
  88. GPIO_Init(GPIOA, &GPIO_InitStructure);
  89. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8; //2A
  90. //GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  91. //GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //50MHz
  92. GPIO_Init(GPIOC, &GPIO_InitStructure);
  93. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4; //3A
  94. //GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  95. //GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //50MHz
  96. GPIO_Init(GPIOC, &GPIO_InitStructure);
  97. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5; //4A
  98. //GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  99. //GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //50MHz
  100. GPIO_Init(GPIOC, &GPIO_InitStructure);
  101. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_14; //5A
  102. //GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  103. //GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //50MHz
  104. GPIO_Init(GPIOC, &GPIO_InitStructure);
  105. #if 1 //˥Ч
  106. GPIO_SetBits(GPIOA,GPIO_Pin_8);
  107. GPIO_SetBits(GPIOC,GPIO_Pin_8);
  108. GPIO_SetBits(GPIOC,GPIO_Pin_4);
  109. GPIO_SetBits(GPIOC,GPIO_Pin_5);
  110. GPIO_SetBits(GPIOC,GPIO_Pin_14);
  111. #else
  112. GPIO_ResetBits(GPIOA,GPIO_Pin_8);
  113. GPIO_ResetBits(GPIOC,GPIO_Pin_8);
  114. GPIO_ResetBits(GPIOC,GPIO_Pin_4);
  115. GPIO_ResetBits(GPIOC,GPIO_Pin_5);
  116. GPIO_ResetBits(GPIOC,GPIO_Pin_14);
  117. #endif
  118. }
  119. void lcd_init(void)
  120. {
  121. GPIO_InitTypeDef GPIO_InitStructure;
  122. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; //LCD POWER
  123. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  124. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //50MHz
  125. GPIO_Init(GPIOC, &GPIO_InitStructure);
  126. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; //LCD CS
  127. //GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  128. //GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //50MHz
  129. GPIO_Init(GPIOC, &GPIO_InitStructure);
  130. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3; //LCD RES
  131. //GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  132. //GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //50MHz
  133. GPIO_Init(GPIOC, &GPIO_InitStructure);
  134. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; //LCD AO
  135. //GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  136. //GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //50MHz
  137. GPIO_Init(GPIOC, &GPIO_InitStructure);
  138. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11; //LCD SCK
  139. //GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  140. //GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //50MHz
  141. GPIO_Init(GPIOC, &GPIO_InitStructure);
  142. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12; //LCD SDA Ҫ
  143. //GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  144. //GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //50MHz
  145. GPIO_Init(GPIOC, &GPIO_InitStructure);
  146. GPIO_SetBits(GPIOC,GPIO_Pin_0);
  147. vDispInit(0,24);
  148. vDispClear();
  149. }
  150. void _vWriteIR_spi(u8 ucData);
  151. void _vWriteData_spi(void);
  152. void (* WriteIR)(u8); //20120502 hong ָ룬ָ _vWriteIR _vWriteIR_spi
  153. void (* WriteData)(void); //20120502 ָ룬ָ_vWriteData_vWriteData_spi
  154. #if 0
  155. __inline void IRQEnable(void)
  156. {
  157. int tmp;
  158. __asm
  159. {
  160. MRS tmp,CPSR ///ȡCPSRֵ
  161. BIC tmp,tmp,#0x80 //IRQжϽֹλI,IRQж
  162. MSR CPSR_c,tmp //CPSRֵ
  163. }
  164. }
  165. __inline void IRQDisable(void)
  166. {
  167. int tmp;
  168. __asm
  169. {
  170. MRS tmp,CPSR ///ȡCPSRֵ
  171. ORR tmp,tmp,#0x80 //IRQжϽֹλI,IRQж
  172. MSR CPSR_c,tmp //CPSRֵ
  173. }
  174. }
  175. #endif
  176. #if 0
  177. void SetDISPDATA( u8 DISPDATA )
  178. {
  179. IO2SET = IO2SET | DISPDATA;
  180. IO2CLR = (~IO2SET) | ((~DISPDATA) &0x000000ff);
  181. }
  182. #endif
  183. u32 vI2cHzkGetStart( u32 addr /*Int32 addr*/ )
  184. {
  185. //ulong HfcAdd;
  186. u32 HfcAdd;
  187. HfcAdd = addr >> 8;
  188. HfcAdd *= 264;
  189. HfcAdd += (addr & 0xff);
  190. return ( HfcAdd );
  191. }
  192. /**************************************************************
  193. Һд
  194. ucData--
  195. л첨
  196. 20080710xiehb
  197. *************************************************************/
  198. void _vWriteIR_spi(u8 ucData)
  199. {
  200. u8 i;
  201. // ж
  202. ucData = ucData;
  203. //IRQDisable();
  204. //SPI1_CE = 0;
  205. //P2WPin_HIGH(PIN_LCD_SDA);
  206. //LCD_SDA_OUTMODE_SET;
  207. GPIO_SetBits(GPIOC,GPIO_Pin_12);
  208. //WPin(P2, PIN_LCD_CS0, 0);
  209. //LCD_CS0_OUTMODE_CLEAR;
  210. GPIO_ResetBits(GPIOC,GPIO_Pin_2);
  211. //P2WPin_LOW(PIN_LCD_DC);
  212. //LCD_DC_OUTMODE_CLEAR;
  213. GPIO_ResetBits(GPIOC,GPIO_Pin_10);
  214. for ( i = 0; i < 8; i++ )
  215. {
  216. //P2WPin_LOW(PIN_LCD_SCL);
  217. //LCD_SCL_OUTMODE_CLEAR;
  218. GPIO_ResetBits(GPIOC,GPIO_Pin_11);
  219. if ( (ucData & 0x80) == 0 )
  220. {
  221. //P2WPin_LOW(PIN_LCD_SDA);
  222. //LCD_SDA_OUTMODE_CLEAR;
  223. GPIO_ResetBits(GPIOC,GPIO_Pin_12);
  224. }
  225. else
  226. {
  227. //P2WPin_HIGH(PIN_LCD_SDA);
  228. //LCD_SDA_OUTMODE_SET;
  229. GPIO_SetBits(GPIOC,GPIO_Pin_12);
  230. }
  231. ucData = ucData << 1;
  232. //P2WPin_HIGH(PIN_LCD_SCL);
  233. //LCD_SCL_OUTMODE_SET;
  234. GPIO_SetBits(GPIOC,GPIO_Pin_11);
  235. }
  236. //WPin(P2, PIN_LCD_CS0, 1);
  237. //LCD_CS0_OUTMODE_SET;
  238. GPIO_SetBits(GPIOC,GPIO_Pin_2);
  239. //P2WPin_HIGH(PIN_LCD_SDA);
  240. //LCD_SDA_OUTMODE_SET;
  241. GPIO_SetBits(GPIOC,GPIO_Pin_12);
  242. // ж
  243. //IRQEnable();
  244. //SPI1_CE = 1;
  245. }
  246. /**************************************************************
  247. Һдݺ
  248. ucDispDT--
  249. л첨
  250. 20080710xiehb
  251. *************************************************************/
  252. void _vWriteData_spi()
  253. {
  254. u8 i;
  255. // ж
  256. //IRQDisable();
  257. //SPI1_CE = 0;
  258. //P2WPin_HIGH(PIN_LCD_SDA);
  259. //LCD_SDA_OUTMODE_SET;
  260. GPIO_SetBits(GPIOC,GPIO_Pin_12);
  261. //WPin(P2, PIN_LCD_CS0, 0);
  262. //LCD_CS0_OUTMODE_CLEAR;
  263. GPIO_ResetBits(GPIOC,GPIO_Pin_2);
  264. //P2WPin_HIGH(PIN_LCD_DC);
  265. //LCD_DC_OUTMODE_SET;
  266. GPIO_SetBits(GPIOC,GPIO_Pin_10);
  267. for ( i = 0; i < 8; i++ )
  268. {
  269. //P2WPin_LOW(PIN_LCD_SCL);
  270. //LCD_SCL_OUTMODE_CLEAR;
  271. GPIO_ResetBits(GPIOC,GPIO_Pin_11);
  272. if ( (ucDispDT & 0x80) == 0 )
  273. {
  274. //P2WPin_LOW(PIN_LCD_SDA);
  275. //LCD_SDA_OUTMODE_CLEAR;
  276. GPIO_ResetBits(GPIOC,GPIO_Pin_12);
  277. }
  278. else
  279. {
  280. //P2WPin_HIGH(PIN_LCD_SDA);
  281. //LCD_SDA_OUTMODE_SET;
  282. GPIO_SetBits(GPIOC,GPIO_Pin_12);
  283. }
  284. ucDispDT = ucDispDT << 1;
  285. //P2WPin_HIGH(PIN_LCD_SCL);
  286. //LCD_SCL_OUTMODE_SET;
  287. GPIO_SetBits(GPIOC,GPIO_Pin_11);
  288. }
  289. //WPin(P2, PIN_LCD_CS0, 1);
  290. //LCD_CS0_OUTMODE_SET;
  291. GPIO_SetBits(GPIOC,GPIO_Pin_2);
  292. //P2WPin_HIGH(PIN_LCD_SDA);
  293. //LCD_SDA_OUTMODE_SET;
  294. GPIO_SetBits(GPIOC,GPIO_Pin_12);
  295. // ж
  296. //IRQEnable();
  297. //SPI1_CE = 1;
  298. }
  299. /////////////////////////////////////////////////////////////////////////////////////
  300. //******************************************************************
  301. // : void _vDispAddr(uchar ucPage,uchar ucCol)
  302. // : ʾַ
  303. // : ucPageҳַucColеַ
  304. // ֵ:
  305. //******************************************************************
  306. void _vDispAddr(u8 ucPage,u8 ucCol)
  307. {
  308. #if 0
  309. if ( GetMainBoardType () == MAINBOARD_TYPE_GENERAL )
  310. {
  311. ucCol += 1;
  312. }
  313. #endif
  314. (*WriteIR)(0xb0+ucPage); // ҳַ
  315. (*WriteIR)(0x10+(ucCol >> 4));//modify by ljc20071017 // ʾʼи4λ
  316. (*WriteIR)( ucCol & 0x0f);//modify by ljc20071017 // ʾʼе4λ
  317. }
  318. //******************************************************************
  319. // : void vDispOn()
  320. // : ʾ
  321. // :
  322. // ֵ:
  323. //******************************************************************
  324. void vDispOn(void)
  325. {
  326. //have adjust
  327. (*WriteIR)(0xaf); // ôʾ
  328. }
  329. //******************************************************************
  330. // : void vDispClear()
  331. // : ʾ
  332. // :
  333. // ֵ:
  334. //******************************************************************
  335. void vDispClear(void)
  336. {
  337. u8 i,j;
  338. //have adjust
  339. for ( i = 0; i < 8; i++ )
  340. {
  341. ucDispDT = 0;
  342. _vDispAddr(i, 0);
  343. for ( j = 0; j < 133; j++ )
  344. {
  345. // 128
  346. (*WriteData)();
  347. }
  348. }
  349. (*WriteIR)(0xaf); // ʾ
  350. (*WriteIR)(0x2f); // Power //20070913heq //20071108heq
  351. }
  352. //******************************************************************
  353. // : void vDispFull()
  354. // : ʾ
  355. // :
  356. // ֵ:
  357. //******************************************************************
  358. void vDispFull ( void )
  359. {
  360. u8 i,j;
  361. //have adjust
  362. for ( i = 0; i < 8; i++ )
  363. {
  364. _vDispAddr(i, 0);
  365. for ( j = 0; j < 133; j++ )
  366. {
  367. ucDispDT = 0xFF;
  368. (*WriteData)();
  369. }
  370. }
  371. (*WriteIR)(0xaf); // ʾ
  372. (*WriteIR)(0x2f); // Power //20070913heq //20071108heq
  373. }
  374. //#ifdef SPI_LCD_ENABLE //20110704 liugz
  375. /********************************************
  376. SPI ʼ
  377. 20080710xiehb
  378. *********************************************/
  379. void vDispInit_spi(u8 mode,u8 contrast)
  380. {
  381. if ( mode )
  382. {
  383. //LCD_SDA_OUTMODE_SET;
  384. GPIO_SetBits(GPIOC,GPIO_Pin_12);
  385. delay_5us(1);
  386. //LCD_RST_OUTMODE_SET;
  387. GPIO_SetBits(GPIOC,GPIO_Pin_3);
  388. //LCD_CS0_OUTMODE_CLEAR;
  389. GPIO_ResetBits(GPIOC,GPIO_Pin_2);
  390. //vDelayMS(5);
  391. delay_ms(5);
  392. //LCD_RST_OUTMODE_CLEAR;
  393. GPIO_ResetBits(GPIOC,GPIO_Pin_3);
  394. //vDelayMS(30);
  395. delay_ms(30);
  396. //LCD_RST_OUTMODE_SET;
  397. GPIO_SetBits(GPIOC,GPIO_Pin_3);
  398. //vDelayMS(19);
  399. delay_ms(19);
  400. }
  401. //LCD_CS0_OUTMODE_CLEAR;
  402. GPIO_ResetBits(GPIOC,GPIO_Pin_2);
  403. //LCD_SDA_OUTMODE_SET;
  404. GPIO_SetBits(GPIOC,GPIO_Pin_12);
  405. //LCD_RST_OUTMODE_SET;
  406. GPIO_SetBits(GPIOC,GPIO_Pin_3);
  407. (*WriteIR)(0xe2);
  408. delay_ms(10);
  409. (*WriteIR)(0xa2); /* 1/9bias */
  410. (*WriteIR)(0xa0); /* ADC select , Normal */
  411. (*WriteIR)(0xc8); /* Common output reverse */
  412. (*WriteIR)(0xa6); /* normal display 1=on */
  413. #if 0
  414. if ( GetMainBoardType () != MAINBOARD_TYPE_GENERAL )
  415. {
  416. (*WriteIR)(0x2C);
  417. DeyNop(10);
  418. (*WriteIR)(0x2E);
  419. DeyNop(10);
  420. }
  421. #endif
  422. (*WriteIR)(0x2F); /* V/C off, V/R off, V/F on */
  423. //DeyNop(10);
  424. delay_5us(2);
  425. (*WriteIR)(0xf8); /* Common output reverse */
  426. (*WriteIR)(0x01); /* normal display 1=on */
  427. //(*WriteIR)(0x2F); /* V/C off, V/R off, V/F on */
  428. (*WriteIR)(0x24); /* internal resistor ratio */
  429. #if 0
  430. if ( contrast > MAX_CONTRAST )
  431. {
  432. contrast = 0x24;
  433. }
  434. if ( contrast < MIN_CONTRAST )
  435. {
  436. contrast = 0x24;
  437. }
  438. #else
  439. contrast = 0x27; //24
  440. #endif
  441. (*WriteIR)(0x81); /* electronic volume mode set */
  442. (*WriteIR)(contrast); /*0x31*/
  443. (*WriteIR)(0xaf); /* display on */
  444. (*WriteIR)(0x40); /* Start line Set 40-7fh Ĭ40 */ //20110720 liugz //60
  445. }
  446. ///20120925 hong ʶ
  447. void vDispInit( u8 mode,u8 contrast )
  448. {
  449. WriteIR = _vWriteIR_spi;
  450. WriteData = _vWriteData_spi;
  451. vDispInit_spi(mode,contrast);
  452. }
  453. #if 1
  454. /*****************************************************************
  455. E_MAINBOARD_TYPE GetMainBoardType ( void )
  456. ܣ
  457. ע⣺
  458. ƣΰ
  459. ʱ䣺2014.06.28
  460. أ
  461. ******************************************************************/
  462. void SetLcdRow ( u8 * ucRow )
  463. {
  464. //if ( GetMainBoardType () != MAINBOARD_TYPE_GENERAL )
  465. {
  466. if ( *ucRow < 3 )
  467. {
  468. *ucRow += 2;
  469. }
  470. else
  471. {
  472. *ucRow -= 2;
  473. }
  474. }
  475. }
  476. #endif
  477. //******************************************************************
  478. // : void vDispClearLine(uchar ucRow)
  479. // : LCDһ
  480. // : ucRowк
  481. // ֵ:
  482. //******************************************************************
  483. void vDispClearLine(u8 ucRow)
  484. {
  485. u8 i,j;
  486. SetLcdRow(&ucRow);
  487. if ( --ucRow >= 4 )
  488. {
  489. return ;
  490. }
  491. ucRow += ucRow;
  492. for ( i = 0; i < 2; i++ )
  493. {
  494. _vDispAddr(ucRow, 0);
  495. ucDispDT = 0;
  496. for ( j = 0; j < 128; j++ )
  497. {
  498. (*WriteData)();
  499. }
  500. _vDispAddr(ucRow + 1, 0);
  501. ucDispDT = 0;
  502. for (j = 0; j < 128; j++)
  503. {
  504. (*WriteData)();
  505. }
  506. }
  507. }
  508. void Display_Icon16(u8 ucRow, u8 ucCol, unsigned char *icon)
  509. {
  510. u8 pZiMo;
  511. SetLcdRow(&ucRow);
  512. if ( --ucRow >= 4 )
  513. {
  514. return ;
  515. }
  516. if ( --ucCol > 16 )
  517. {
  518. return ;
  519. }
  520. ucRow += ucRow;
  521. ucCol <<= 3;
  522. _vDispAddr(ucRow, ucCol);
  523. ucDispDT = 0x00;
  524. for ( pZiMo = 0; pZiMo < 8; pZiMo++ )
  525. {
  526. if ( icon != 0 )
  527. {
  528. ucDispDT = icon[pZiMo];
  529. }
  530. (*WriteData)();
  531. }
  532. _vDispAddr(ucRow+1, ucCol);
  533. for ( ; pZiMo < 16; pZiMo++ )
  534. {
  535. if ( icon != 0 )
  536. {
  537. ucDispDT = icon[pZiMo];
  538. }
  539. (*WriteData)();
  540. }
  541. (*WriteIR)(0xaf); // ʾ//20070913heq
  542. (*WriteIR)(0x2f); // Power //20070913heq
  543. }
  544. void Display_Icon(u8 ucRow, u8 ucCol, unsigned char *icon,u8 size)
  545. {
  546. u8 pZiMo;
  547. SetLcdRow(&ucRow);
  548. if ( --ucRow >= 4 )
  549. {
  550. return ;
  551. }
  552. if ( --ucCol >= 16 )
  553. {
  554. return ;
  555. }
  556. ucRow += ucRow;
  557. ucCol <<= 3;
  558. _vDispAddr(ucRow, ucCol);
  559. ucDispDT = 0x00;
  560. //for ( pZiMo = 0; pZiMo < 16; pZiMo++ )
  561. for ( pZiMo = 0; pZiMo < size; pZiMo++ )
  562. {
  563. if ( icon != 0 )
  564. {
  565. ucDispDT = icon[pZiMo];
  566. }
  567. (*WriteData)();
  568. }
  569. _vDispAddr(ucRow + 1, ucCol);
  570. //for ( ; pZiMo < 32; pZiMo++ )
  571. for ( ; pZiMo < (2*size); pZiMo++ )
  572. {
  573. if ( icon != 0 )
  574. {
  575. ucDispDT = icon[pZiMo];
  576. }
  577. (*WriteData)();
  578. }
  579. (*WriteIR)(0xaf); // ʾ//20070913heq
  580. (*WriteIR)(0x2f); // Power //20070913heq
  581. }
  582. #if 0
  583. ///AntiColor = 1 ʽʾ
  584. ///AntiColor = 0 ʾ
  585. void vDispStr_light(u8 ucRow, u8 ucCol, char *szData, u8 AntiColor)
  586. {
  587. u8 ZiMo[32], pZiMo;
  588. u8 ucDispT1, ucDispT2, ucDispT4;
  589. u32 uiDispT;
  590. u32 uiDispT1;
  591. //SetMayWatchDog();
  592. IWDG_Feed();
  593. //SetLcdRow(&ucRow);
  594. if ( --ucRow >= 4 )
  595. {
  596. return ;
  597. }
  598. if ( --ucCol >= 16 )
  599. {
  600. return ;
  601. }
  602. ucRow += ucRow;
  603. ucCol <<= 3; // *8
  604. while ( (*szData != 0) && (ucCol < 128) )
  605. {
  606. ucDispT1 = *szData;
  607. szData++;
  608. if ( ucDispT1 == 0xff )
  609. {
  610. return ;
  611. }
  612. //û0XFFʼĺ
  613. if ( ucDispT1 < 0x80 )
  614. {
  615. //ASC
  616. uiDispT = ucDispT1 << 4;
  617. //uiDispT <<= 4;
  618. pZiMo = 0;
  619. vI2cRead(vI2cHzkGetStart( uiDispT + 222080l),16,(char *)ZiMo);
  620. _vDispAddr(ucRow, ucCol);
  621. if ( AntiColor )
  622. {
  623. for ( ucDispT4 = 0; ucDispT4 < 8; ucDispT4++ )
  624. {
  625. ucDispDT = ZiMo[pZiMo++] ^ 0xFF;
  626. (*WriteData)();
  627. }
  628. _vDispAddr(ucRow + 1, ucCol);
  629. for ( ucDispT4 = 8; ucDispT4 < 16; ucDispT4++ )
  630. {
  631. ucDispDT = ZiMo[pZiMo++] ^ 0xFF;
  632. (*WriteData)();
  633. }
  634. }
  635. else
  636. {
  637. for ( ucDispT4 = 0; ucDispT4 < 8; ucDispT4++ )
  638. {
  639. ucDispDT = ZiMo[pZiMo++];
  640. (*WriteData)();
  641. }
  642. _vDispAddr(ucRow + 1, ucCol);
  643. for ( ucDispT4 = 8; ucDispT4 < 16; ucDispT4++ )
  644. {
  645. ucDispDT = ZiMo[pZiMo++];
  646. (*WriteData)();
  647. }
  648. }
  649. ucCol += 8;
  650. }
  651. else
  652. {
  653. ucDispT2 = *szData;
  654. szData++;
  655. if ( ucCol > 112 )
  656. {
  657. break;
  658. }
  659. if ( ucDispT1 >= 0xB0 )
  660. {
  661. //B0A1~F7FF
  662. ucDispT1 -= 0xAE;
  663. }
  664. else if ( ucDispT1 == 0xA1 )
  665. {
  666. //A1A1~A1FF
  667. ucDispT1 = 0;
  668. }
  669. else if ( ucDispT1 == 0xA3 )
  670. {
  671. //A3A1~A3FF
  672. ucDispT1 = 1;
  673. }
  674. else
  675. {
  676. continue;
  677. }
  678. ucDispT2 -= 0xA1;
  679. ucDispT1 <<= 1; //*2; 47
  680. uiDispT = ucDispT1 << 4;
  681. uiDispT1 = uiDispT;
  682. uiDispT <<= 1;
  683. uiDispT += uiDispT1;
  684. uiDispT -= ucDispT1;
  685. uiDispT += ucDispT2;
  686. pZiMo = 0;
  687. vI2cRead(vI2cHzkGetStart(uiDispT<<5),32,(char *)ZiMo);
  688. _vDispAddr(ucRow, ucCol);
  689. if ( AntiColor )
  690. {
  691. for ( ucDispT4 = 0; ucDispT4 < 8; ucDispT4++ )
  692. {
  693. ucDispDT = ZiMo[pZiMo++] ^ 0xFF;
  694. (*WriteData)();
  695. }
  696. }
  697. else
  698. {
  699. for ( ucDispT4 = 0; ucDispT4 < 8; ucDispT4++ )
  700. {
  701. ucDispDT = ZiMo[pZiMo++];
  702. (*WriteData)();
  703. }
  704. }
  705. if ( ucCol < 56 )
  706. {
  707. if ( AntiColor )
  708. {
  709. for ( ucDispT4 = 8; ucDispT4 < 16; ucDispT4++ )
  710. {
  711. ucDispDT = ZiMo[pZiMo++] ^ 0xFF;
  712. (*WriteData)();
  713. }
  714. }
  715. else
  716. {
  717. for ( ucDispT4 = 8; ucDispT4 < 16; ucDispT4++ )
  718. {
  719. ucDispDT = ZiMo[pZiMo++];
  720. (*WriteData)();
  721. }
  722. }
  723. }
  724. else
  725. {
  726. if ( ucCol == 56 )
  727. {
  728. _vDispAddr(ucRow, 64);
  729. }
  730. if ( AntiColor )
  731. {
  732. for ( ucDispT4 = 8; ucDispT4 < 16; ucDispT4++ )
  733. {
  734. ucDispDT = ZiMo[pZiMo++] ^ 0xFF;
  735. (*WriteData)();
  736. }
  737. }
  738. else
  739. {
  740. for ( ucDispT4 = 8; ucDispT4 < 16; ucDispT4++ )
  741. {
  742. ucDispDT = ZiMo[pZiMo++];
  743. (*WriteData)();
  744. }
  745. }
  746. }
  747. _vDispAddr(ucRow + 1, ucCol);
  748. if ( AntiColor )
  749. {
  750. for ( ucDispT4 = 16; ucDispT4 < 24; ucDispT4++ )
  751. {
  752. ucDispDT = ZiMo[pZiMo++] ^ 0xFF;
  753. (*WriteData)();
  754. }
  755. }
  756. else
  757. {
  758. for ( ucDispT4 = 16; ucDispT4 < 24; ucDispT4++ )
  759. {
  760. ucDispDT = ZiMo[pZiMo++];
  761. (*WriteData)();
  762. }
  763. }
  764. if ( ucCol < 56 )
  765. {
  766. if ( AntiColor )
  767. {
  768. for ( ucDispT4 = 24; ucDispT4 < 32; ucDispT4++ )
  769. {
  770. ucDispDT = ZiMo[pZiMo++] ^ 0xFF;
  771. (*WriteData)();
  772. }
  773. }
  774. else
  775. {
  776. for ( ucDispT4 = 24; ucDispT4 < 32; ucDispT4++ )
  777. {
  778. ucDispDT = ZiMo[pZiMo++];
  779. (*WriteData)();
  780. }
  781. }
  782. }
  783. else
  784. {
  785. if ( ucCol == 56 )
  786. {
  787. _vDispAddr(ucRow + 1, 64);
  788. }
  789. if ( AntiColor )
  790. {
  791. for ( ucDispT4 = 24; ucDispT4 < 32; ucDispT4++ )
  792. {
  793. //vI2cGetHzk();
  794. ucDispDT = ZiMo[pZiMo++] ^ 0xFF;
  795. (*WriteData)();
  796. }
  797. }
  798. else
  799. {
  800. for ( ucDispT4 = 24; ucDispT4 < 32; ucDispT4++ )
  801. {
  802. //vI2cGetHzk();
  803. ucDispDT = ZiMo[pZiMo++];
  804. (*WriteData)();
  805. }
  806. }
  807. }
  808. ucCol += 16;
  809. }
  810. }
  811. (*WriteIR)(0xaf); // ʾ//20070913heq //20071108heq
  812. (*WriteIR)(0x2f); // Power //20070913heq //20071108heq
  813. }
  814. void vDispStr(u8 ucRow, u8 ucCol, char *szData)
  815. {
  816. vDispStr_light(ucRow,ucCol,szData,0);
  817. }
  818. #else
  819. void vDispStr(u8 ucRow, u8 ucCol, char *szData,unsigned char datalen)
  820. {
  821. u16 i;
  822. u16 temHz;
  823. u8 buf[16];
  824. if(datalen<=0)
  825. {
  826. return ;
  827. }
  828. for(i=0;i<datalen;)
  829. {
  830. temHz = *(szData+i);
  831. i +=1;
  832. Get_8x16_Font(temHz,buf);
  833. Display_Icon(ucRow,ucCol,buf,8);
  834. ucCol += 1;
  835. }
  836. }
  837. #endif