用单片机和点阵图型LCD显示屏制作流动图像(发布).c
上传用户:sophiecyc
上传日期:2007-10-14
资源大小:14856k
文件大小:18k
源码类别:

单片机开发

开发平台:

C/C++

  1. //================用单片机和点阵图型LCD显示屏制作流动图像====================
  2. //============================作者:陈燕春===================================
  3. //声 明:                                                                   //
  4. //        以下代码仅免费提供给学习用途,但引用或修改后必须在文件中声明出处. //
  5. //        如用于商业用途请与作者联系.    E-mail:flying_swallow_@163.com     //
  6. //        有问题请mailto: flying_swallow_@163.com   欢迎与我交流!           //
  7. #include<AT89X51.H>
  8. //晶振12MHZ
  9. //***************************************
  10. //RM-F电视遥控器代码表
  11. //对应C语言程序(C51单片机)
  12. #define d_quiet  0x48b7
  13. #define d_on_off 0x18e7
  14. #define d_1  0x807f
  15. #define d_2  0x40bf
  16. #define d_3  0xc03f
  17. #define d_4  0x20df
  18. #define d_5  0xa05f
  19. #define d_6  0x609f
  20. #define d_7  0xe01f
  21. #define d_8  0x10ef
  22. #define d_9  0x906f
  23. #define d_0  0x00ff
  24. #define d__  0x50af
  25. #define d_circle  0x30cf
  26. #define d_SLEEP  0x9867
  27. #define d_BLUE  0x28d7
  28. #define d_SYS  0xa857
  29. #define d_TV_AV  0xd02f
  30. #define d_DISP  0x8877
  31. #define d__P  0xc837
  32. #define d_SCAN  0xb04f
  33. #define d_FUNC  0x708f
  34. #define d_LDL  0x8f7    //亮度,对比度
  35. #define d_V_add  0xd827
  36. #define d_P_add  0xe817
  37. #define d_PRESET  0xf00f
  38. #define d_V_sum  0x58a7
  39. #define d_P_sum  0x6897
  40. //***************************************
  41. #define LCD_data  P0//定义LCD数据指令输入输出端
  42. #define _code_length 42//遥控代码长度(固定)
  43. unsigned char code_length=_code_length ;  //遥控代码位长度
  44. unsigned int code_t=0;       //保存遥控代码(临时)
  45. unsigned int code_tt=0;       //保存遥控代码
  46. bit bdata code_right=0;      //接收代码是否正确
  47. bit bdata light_FD=0;//0 前半部,1后部分
  48. sbit D_I=P2^7;
  49. sbit R_W=P2^6;
  50. sbit E=P2^5;
  51. sbit CS1=P2^4;
  52. sbit CS2=P2^3;
  53. sbit RST=P2^2;
  54. sbit LCD_light=P2^1;//背光
  55. //设置X,Y轴
  56. unsigned char LCD_x=0;
  57. unsigned char LCD_y=0;
  58. unsigned char time_count=5;//记录移动延时
  59. unsigned char time_count2=0;//移动延时计数
  60. signed  int LCD_move=0;//记录移动字节数
  61. unsigned char LCD_move_little=0;//记录移动位
  62. unsigned int LCD_light_head;//数组头地址
  63. unsigned int LCD_light_trail;//数组尾地址
  64. unsigned char code light_data_h=15;//图象高度
  65. unsigned char code light_data[]={
  66. /*--  调入了一幅图像:D:Documents and Settingsghost桌面新建文件夹无线电.bmp  --*/
  67. /*--  宽度x高度=128x116  --*/
  68. /*--  宽度不是8的倍数,现调整为:宽度x高度=128x120  --*/
  69. 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  70. 0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x3F,0x1F,0x0F,0x07,0x07,0x07,0x07,0x8F,0xFF,0xFF,
  71. 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  72. 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x3F,0x1F,0x1F,0x1F,0x1F,0x01,0x01,0x21,
  73. 0xC7,0x8F,0x1F,0x1F,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  74. 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  75. 0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x0F,0xC3,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  76. 0xFF,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F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFE,0x8A,0x00,0x00,0x00,
  102. 0x80,0xC0,0xE0,0xFC,0xFF,0xC0,0x80,0x00,0x78,0x7F,0x7F,0x7F,0x7F,0x7F,0x3F,0x3F,
  103. 0x1F,0x1F,0x1F,0x80,0x80,0xC0,0xC0,0xC1,0xE3,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  104. 0xFF,0xFF,0xFF,0xFF,0xE2,0xE0,0xE0,0xFC,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xCF,0xC7,
  105. 0xF3,0xF1,0xF8,0xFE,0xFE,0xF8,0xE0,0x03,0x2F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  106. 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  107. 0x80,0x18,0x3F,0x3F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x3F,0x3F,0x1F,0x9F,
  108. 0x9F,0xCF,0xCF,0xC0,0xE0,0xE0,0xE0,0xE1,0xF3,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  109. 0xFF,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x87,0x87,0x86,0x86,0x86,
  110. 0x87,0x87,0x87,0x87,0x07,0x07,0x07,0x07,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
  111. 0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x87,0x87,0x87,0x07,0x07,0x87,0x87,0x87,0x07,
  112. 0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,
  113. 0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,
  114. 0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,
  115. 0x07,0x07,0x06,0x06,0x06,0x04,0x04,0x04,0x04,0x04,0x04,0x06,0x06,0x07,0x07,0x07,
  116. 0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0xFF,
  117. 0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0x73,0x73,
  118. 0xF3,0xF3,0xF3,0xBF,0x3F,0x1E,0x00,0x00,0x10,0x98,0xCC,0xCC,0x6C,0xFC,0xFC,0xF8,
  119. 0x00,0xF0,0xF8,0xFC,0x1C,0x0C,0x18,0xFF,0xFF,0xFF,0x00,0x00,0xFD,0xFD,0xFD,0x00,
  120. 0x00,0xF0,0xF8,0xFC,0x1C,0x0C,0x1C,0xFC,0xF8,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,
  121. 0xF0,0x38,0x18,0x18,0x38,0x30,0x00,0x00,0xE0,0xF0,0x38,0x18,0x18,0x38,0xF0,0xE0,
  122. 0x00,0x00,0xF8,0xF8,0x30,0x18,0x18,0xF8,0xF0,0x30,0x18,0x18,0xF8,0xF0,0x00,0x00,
  123. 0x00,0x00,0x00,0xE0,0xF0,0x38,0x18,0x18,0x38,0x30,0x00,0x00,0xF8,0xF8,0x30,0x18,
  124. 0x18,0x18,0xF8,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,
  125. 0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x0F,0x0F,0x00,0x00,
  126. 0x00,0x01,0x07,0x0F,0x0F,0x0C,0x08,0x00,0x07,0x0F,0x0F,0x0C,0x0C,0x07,0x0F,0x0F,
  127. 0x00,0x03,0x07,0x0F,0x0E,0x0C,0x06,0x0F,0x0F,0x0F,0x00,0x00,0x0F,0x0F,0x0F,0x00,
  128. 0x00,0x03,0x07,0x0F,0x0E,0x0C,0x0E,0x0F,0x07,0x03,0x00,0x00,0x0C,0x0C,0x00,0x00,
  129. 0x07,0x0E,0x0C,0x0C,0x0E,0x06,0x00,0x00,0x03,0x07,0x0E,0x0C,0x0C,0x0E,0x07,0x03,
  130. 0x00,0x00,0x0F,0x0F,0x00,0x00,0x00,0x0F,0x0F,0x00,0x00,0x00,0x0F,0x0F,0x00,0x00,
  131. 0x0C,0x00,0x00,0x03,0x07,0x0E,0x0C,0x0C,0x0E,0x06,0x00,0x00,0x0F,0x0F,0x00,0x00,
  132. 0x00,0x00,0x0F,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,
  133. 0x01,0x21,0xF9,0xA1,0xA1,0xA1,0xF9,0x21,0xE1,0x01,0x01,0x01,0x01,0xD1,0xF1,0xB1,
  134. 0xB1,0xF1,0x01,0xF1,0x01,0xF9,0x01,0x01,0xF1,0xF1,0x91,0x91,0x99,0xF9,0x91,0x91,
  135. 0x91,0x81,0x01,0x01,0x21,0xB9,0xF1,0x21,0xF1,0x91,0x91,0x91,0xF1,0x01,0x01,0x01,
  136. 0x01,0x01,0x01,0x01,0x01,0x81,0xE1,0x79,0x19,0x01,0x01,0x11,0x11,0x11,0x11,0xF1,
  137. 0x11,0x11,0x11,0x11,0x01,0x01,0x81,0xE1,0xD9,0x61,0x41,0x41,0xF9,0x21,0xA9,0xB1,
  138. 0x81,0x01,0xE1,0xE1,0xA1,0xA1,0xF9,0xA1,0xA1,0xE1,0x01,0x01,0x01,0x01,0x19,0x79,
  139. 0xE1,0x81,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x81,0x91,0xD1,0x79,0x99,0x11,
  140. 0xF1,0x81,0xC1,0x01,0x01,0x21,0xA1,0xA1,0xA1,0xF9,0xA9,0xA1,0xA1,0x21,0x21,0x01,
  141. 0x20,0x1D,0x17,0x00,0x1C,0x06,0x13,0x19,0x03,0x1D,0x12,0x00,0x11,0x1C,0x0E,0x03,
  142. 0x19,0x00,0x08,0x19,0x04,0x1F,0x10,0x10,0x1F,0x10,0x10,0x18,0x0E,0x03,0x06,0x08,
  143. 0x10,0x10,0x00,0x02,0x03,0x1F,0xC1,0xD3,0x18,0x0F,0x80,0x1F,0xD0,0x10,0x00,0x80,
  144. 0x80,0x80,0x80,0x80,0x00,0x83,0x0F,0xFC,0x30,0x00,0x80,0x91,0x91,0x89,0x0F,0x03,
  145. 0x1F,0x91,0x91,0x99,0x08,0x00,0x12,0x0B,0xCA,0x4E,0x51,0x51,0x4B,0x4F,0x5C,0xD2,
  146. 0x18,0x00,0x07,0x07,0x82,0xC2,0x9F,0x92,0x92,0x97,0x98,0x88,0x00,0x00,0x30,0x3C,
  147. 0x0F,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x12,0x0A,0x0E,0x12,0x1F,0x02,
  148. 0x06,0x0A,0x1A,0x00,0x10,0x1E,0x04,0x1E,0x12,0x12,0x16,0x18,0x06,0x1C,0x10,0x00,
  149. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  150. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  151. 0x00,0x00,0x00,0x04,0x02,0xFF,0x84,0xA4,0xBD,0xC1,0x1F,0x80,0xFF,0x00,0x04,0x04,
  152. 0x04,0xFF,0x04,0x04,0x04,0x3F,0x80,0xFF,0x00,0x20,0x6F,0x47,0x44,0x7C,0x38,0x00,
  153. 0x3F,0x7F,0x40,0x7F,0x3F,0x00,0x00,0xE0,0x3F,0x04,0x7A,0x57,0x5A,0x7A,0x84,0xFF,
  154. 0x00,0x00,0x24,0x12,0x1D,0x14,0x14,0xFF,0x94,0x14,0x14,0x10,0x00,0x00,0x00,0x00,
  155. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  156. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  157. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  158. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  159. 0x00,0x00,0x00,0x00,0x08,0xFE,0xFE,0x00,0x00,0x00,0x1C,0x3E,0x22,0xFE,0xFC,0x00,
  160. 0x80,0xBE,0x1E,0x12,0xF2,0xE0,0x00,0x80,0xBE,0x1E,0x12,0xF2,0xE0,0x00,0x60,0x60,
  161. 0x60,0x00,0x84,0xC6,0x62,0x3E,0x1D,0x00,0x00,0xFC,0xFE,0x02,0xFE,0xFC,0x00,0x00,
  162. 0xFC,0xFE,0x02,0xFE,0xFC,0x00,0x80,0xBE,0x1E,0x12,0xF2,0xE0,0x00,0x00,0x00,0x00,
  163. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  164. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  165. 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,
  166. 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0xC0,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,
  167. 0x40,0x40,0x40,0x40,0x40,0x41,0x41,0x40,0x40,0x40,0x41,0x41,0x41,0x41,0x40,0x40,
  168. 0x40,0x41,0x41,0x41,0x41,0x40,0x40,0x40,0x41,0x41,0x41,0x41,0x40,0x40,0x40,0x40,
  169. 0x40,0x40,0x41,0x41,0xC1,0x41,0x41,0x40,0x40,0x40,0x41,0x41,0x41,0x40,0x40,0x40,
  170. 0x40,0x41,0xC1,0x41,0x40,0x40,0x40,0x41,0x41,0x41,0x41,0x40,0x40,0x40,0x40,0xC0,
  171. 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0xC0,0x40,0x40,0x40,0xC0,0x40,0x40,
  172. 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,
  173. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  174. 0x00,0x00,0x00,0x00,0x00,0x08,0x36,0xC1,0x1C,0x63,0x00,0x00,0x00,0x08,0x89,0x69,
  175. 0x1F,0xF9,0x09,0x09,0x08,0x08,0xC0,0x00,0x08,0x6E,0x59,0x24,0x94,0x13,0x3C,0xD5,
  176. 0x54,0x20,0x80,0x00,0x00,0x7E,0x4A,0x4A,0xFF,0x4A,0x4A,0x4A,0x7E,0x00,0x80,0x00,
  177. 0x00,0x00,0x63,0x1C,0xC1,0x36,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x90,
  178. 0x55,0x33,0x11,0xF9,0x11,0x37,0x48,0x84,0x00,0x00,0x80,0x64,0x05,0xF5,0x8D,0xB7,
  179. 0x85,0x85,0x15,0x64,0x00,0x00,0x10,0x09,0xFD,0x07,0x8C,0x84,0x84,0xFF,0x84,0x80,
  180. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  181. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  182. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,
  183. 0x00,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x01,0x01,0x01,0x00,0x01,0x01,0x00,
  184. 0x01,0x02,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x00,0x00,
  185. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  186. 0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  187. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  188. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
  189. };
  190. //**************************************************************************
  191. //写代码(命令)指令
  192. void LCD_wcode(unsigned char c,unsigned char cs1,unsigned char cs2);
  193. //写数据子程序
  194. void LCD_wdata(unsigned char c,unsigned char cs1,unsigned char cs2);
  195. //**************************************************************************
  196. //延时子程序
  197. void delay(unsigned int v)
  198. {
  199. while(v!=0)
  200. v--;
  201. }
  202. void LCD_reset()//复位信号子程序
  203. {
  204. RST=0;
  205. delay(100);
  206. E=0;
  207. RST=1;
  208. delay(20);
  209. D_I=0;R_W=1;
  210. CS1=1;CS2=1;
  211. LCD_data=0xff;
  212. while(1)
  213. {
  214. E=1;
  215. delay(1);
  216. if((LCD_data&0x10)==0)   break;
  217. E=0;
  218. if((LCD_data&0x10)==0)   break;
  219. }
  220. E=0;
  221. }
  222. /*忙判别*/
  223. void LCD_busy(void) 
  224. {
  225. D_I=0;R_W=1;
  226. CS1=1;CS2=1;
  227. LCD_data=0xff;
  228. while (1) 
  229. {
  230. E=1;
  231. if ((LCD_data&0x90)==0) break;
  232. E=0;
  233. E=0;
  234. }
  235. //显示ON/OFF子程序(1显示,0不显示)
  236. void LCD_dison_off(unsigned char o)
  237. {
  238. o=o+0x3e;
  239. LCD_busy();
  240. LCD_wcode(o,1,1);
  241. }
  242. //写代码(命令)指令
  243. void LCD_wcode(unsigned char c,unsigned char cs1,unsigned char cs2)
  244. {
  245. CS1=cs1;
  246. CS2=cs2;
  247. R_W=0;
  248. D_I=0;
  249. LCD_data=c;
  250. // delay(1);
  251. E=1;
  252. E=0;
  253. }
  254. //写数据子程序
  255. void LCD_wdata(unsigned char c,unsigned char cs1,unsigned char cs2)
  256. {
  257. CS1=cs1;
  258. CS2=cs2;
  259. R_W=0;
  260. D_I=1;
  261. LCD_data=c;
  262. // delay(1);
  263. E=1;
  264. E=0;
  265. }
  266. //设置显示开始行子程序
  267. void LCD_set_startline(unsigned char i)
  268. {
  269. i=0xc0+i;
  270. // LCD_busy();
  271. LCD_wcode(i,1,1);
  272. }
  273. //设置显示具体位置子程序
  274. void LCD_set_adr(unsigned char x,unsigned char y)
  275. {
  276. x=x+0xb8;
  277. // LCD_busy();
  278. LCD_wcode(x,1,1);
  279. y=y+0x40;
  280. // LCD_busy();
  281. LCD_wcode(y,1,1);
  282. }
  283. //判断X,Y轴并写入一位数据,k=1反显
  284. void LCD_writeAword(unsigned char LCD_store,unsigned char *y,unsigned char k)
  285. {
  286. if(*y==64 || *y==LCD_y)//判断是否要写X,Y轴
  287. {
  288. if(*y>=64)
  289. {
  290. LCD_set_adr(LCD_x,*y-64);
  291. }
  292. else
  293. {
  294. LCD_set_adr(LCD_x,*y);
  295. }
  296. }
  297. if(*y>=64)
  298. {
  299. if(k==0)
  300. {
  301. LCD_wdata(LCD_store,0,1);
  302. }
  303. else
  304. {
  305. LCD_wdata(~LCD_store,0,1);
  306. }
  307. }
  308. else
  309. {
  310. if(k==0)
  311. {
  312. LCD_wdata(LCD_store,1,0);
  313. }
  314. else
  315. {
  316. LCD_wdata(~LCD_store,1,0);
  317. }
  318. }
  319. (*y)++;
  320. }
  321. //a[]数据指针,w宽,h高,move 字节移动,move_little 位移(0-7),head 数据开头指针地址trail 数据最后指针地址,k=1反显
  322. void LCD_write(unsigned char a[],unsigned char w,unsigned char h,signed int move,unsigned char move_little,unsigned int head,unsigned int trail,unsigned char k)
  323. {
  324. unsigned char loop,loop2,y;
  325. unsigned int LCD_store;//临时保存小移数据
  326. signed long word_p;//计数指针
  327. y=LCD_y;
  328. word_p=move*w;
  329. for(loop2=0;loop2<h;loop2++)
  330. {
  331. for (loop=0;loop<w;loop++)
  332. {
  333. if((word_p<0) || word_p>(trail-head+w))
  334. {
  335. LCD_store=0x00;//前面和后面填充
  336. }
  337. else
  338. {
  339. if(move_little==0)
  340. {
  341. LCD_store=a[word_p];
  342. if(word_p>(trail-head))
  343. {
  344. LCD_store=0x00;
  345. }
  346. }
  347. else
  348. {
  349. if(word_p<w)//开头第一行
  350. {
  351. LCD_store=a[word_p]<<move_little;
  352. }
  353. else
  354. {
  355. if(word_p>trail-head)//最后一行
  356. {
  357. LCD_store=a[word_p-w]>>(8-move_little);
  358. }
  359. else
  360. {
  361. LCD_store=a[word_p];//中间
  362. LCD_store=((LCD_store<<8)+a[word_p-w])>>(8-move_little);
  363. }
  364. }
  365. }
  366. }
  367. LCD_writeAword(LCD_store,&y,k);
  368. word_p++;
  369. }
  370. LCD_x++;y=LCD_y;
  371. }
  372. }
  373. //填充子程序
  374. void LCD_write_full(unsigned char d,unsigned char w,unsigned char h)
  375. {
  376. unsigned char loop,loop2,y;
  377. y=LCD_y;
  378. for(loop2=0;loop2<h;loop2++)
  379. {
  380. for(loop=0;loop<w;loop++)
  381. {
  382. if(y==64 || y==LCD_y)//判断是否要写X,Y轴
  383. {
  384. if(y>=64)
  385. {
  386. LCD_set_adr(LCD_x,y-64);
  387. }
  388. else
  389. {
  390. LCD_set_adr(LCD_x,y);
  391. }
  392. }
  393. if(y>=64)
  394. {
  395. LCD_wdata(d,0,1);
  396. }
  397. else
  398. {
  399. LCD_wdata(d,1,0);
  400. }
  401. y++;
  402. }
  403. LCD_x++;y=LCD_y;
  404. }
  405. }
  406. void light_view(void)//LCD扫描
  407. {
  408. LCD_x=0;LCD_y=0;//设光标
  409. if(LCD_move_little>0)
  410. {
  411. LCD_move_little--;
  412. }
  413. else
  414. {
  415. LCD_move_little=7;
  416. if(LCD_move>=(light_data_h))
  417. {
  418. LCD_move=(-8);
  419. }
  420. else
  421. {
  422. LCD_move++;
  423. }
  424. }
  425. LCD_write(light_data,128,8,LCD_move,LCD_move_little,LCD_light_head,LCD_light_trail,0);
  426. }
  427. void code_judge(void)//判断遥控代码
  428. {
  429. code_right=0;
  430. switch(code_tt)
  431. {
  432. case d_on_off:
  433. TR1=~TR1;break;//自动移动
  434. case d_P_sum:
  435. if(time_count<20)
  436. {
  437. time_count++;
  438. }
  439. else
  440. {
  441. time_count=1;
  442. };
  443. break;
  444. case d_P_add:
  445. if(time_count>1)
  446. {
  447. time_count--;
  448. }
  449. else
  450. {
  451. time_count=20;
  452. }
  453. break;
  454. case d_quiet:
  455. LCD_light=~LCD_light;//背光
  456. case d_V_add:
  457. if(LCD_move>=(light_data_h))//移动字幕
  458. {
  459. LCD_move=(-8);
  460. }
  461. else
  462. {
  463. LCD_move++;
  464. }
  465. light_view();
  466. break;
  467. case d_V_sum:
  468. if(LCD_move<=(-8))
  469. {
  470. LCD_move=light_data_h;
  471. }
  472. else
  473. {
  474. LCD_move--;
  475. }
  476. light_view();
  477. break;
  478. }
  479. }
  480. //**********判断代码子程序************
  481. unsigned char d_code(unsigned int t)
  482. {
  483. if(t<=0x480 && t>=0x300)
  484. return 0;
  485. else
  486. {
  487. if(t<=0x8ee && t>=0x700)
  488. return 1;
  489. else
  490. return 0xff;
  491. }
  492. }
  493. //*********** 接收代码中断  ************
  494. void receive_code() interrupt 0 using 1
  495. {
  496. unsigned int temp;
  497. unsigned char dd_code;
  498. if(TR0==0)
  499. {
  500. TH0=TL0=0;
  501. TR0=1;
  502. }
  503. else
  504. {
  505. TR0=0;
  506. temp=(TH0<<8)+TL0;
  507. TH0=TL0=0;
  508. TR0=1;
  509. dd_code=d_code(temp);
  510. if((dd_code==0||dd_code==1) && (code_length!=0))
  511. {
  512. code_t=(code_t<<1)+dd_code;
  513. code_length--;
  514. }
  515. else
  516. code_length=_code_length;
  517. if(code_length==0)
  518. {
  519. code_length=_code_length;
  520. if(code_right==0)
  521. {
  522. code_tt=code_t;
  523. code_right=1;
  524. }
  525. }
  526. }
  527. }
  528. //定时器1,中断,定时
  529. void time1() interrupt 3 using 2
  530. {
  531. time_count2++;
  532. }
  533. void main(void)
  534. {
  535. //********************************
  536. TMOD=0x11; //T0定时方式1,T1定时方式1
  537. IT0=1;   //INT0边沿触发
  538. EX0=1;  //外部中断0允许
  539. TR0=0;    //定时器0计数开关
  540. TR1=1;    //定时器1开
  541. ET1=1;    //定时器1中断开
  542. EA=1;         //打开CPU总中断请求
  543. //*********************************
  544. LCD_reset();//初始化
  545. LCD_light=0;//开背光
  546. LCD_dison_off(1);//开显示
  547. LCD_set_startline(0);//设Z坐标
  548. LCD_x=0;LCD_y=0;//设光标
  549. LCD_write_full(0x00,128,8);
  550. LCD_light_head=&light_data[0];
  551. LCD_light_trail=&light_data[128*light_data_h-1];
  552. while(1)
  553. {
  554. if(code_right==1)
  555. {
  556. EX0=0;
  557. code_judge();
  558. EX0=1;
  559. }
  560. if(time_count2>=time_count)
  561. {
  562. time_count2=0;//延时记录清零
  563. light_view();//扫描
  564. }
  565. }
  566. }