找回密码
 注册

QQ登录

只需一步,快速开始

搜索

OLED 0.97 STM8 STVD 菜单源码

[复制链接]
路漫漫 发表于 2020-5-24 02:05:29 | 显示全部楼层 |阅读模式

  1. /* MAIN.C file
  2. *
  3. * Copyright (c) 2002-2005 STMicroelectronics
  4. */
  5. #include "stm8s105k4.h"
  6.       
  7. #define u8   unsigned char
  8. #define u16  unsigned short
  9. #define u32  unsigned long
  10. #define uint unsigned int
  11. /*--------------------引脚定义--------------------------*/
  12. #define   OLED_SCLK_Set() (PB_ODR |= 0x01) //PB0(SCL)输出高
  13. #define   OLED_SCLK_Clr() (PB_ODR &= 0xfe) //PB0(SCL)输出低
  14. #define   OLED_SDIN_Set() (PB_ODR |= 0x02) //PB1(SDA)输出高
  15. #define   OLED_SDIN_Clr() (PB_ODR &= 0xfd) //PB1(SDA)输出高
  16. #define   OLED_READ_SDIN() (PB_IDR & 0x02)        //读取PB4(SDA)电平  

  17. //#define   OLED_KEY1()       (PD_IDR
  18. /*definition--------------------------------------------*/
  19. #define OLED_CMD  0 //写命令
  20. #define OLED_DATA 1 //写数据
  21. #define SIZE   16  //显示字符的大小
  22. #define Max_Column 128  //最大列数
  23. #define Max_Row  64  //最大行数
  24. #define X_WIDTH  128  //X轴的宽度
  25. #define Y_WIDTH  64     //Y轴的宽度              
  26. #define IIC_ACK  0  //应答
  27. #define IIC_NO_ACK 1  //不应答


  28. void OLED_GPIO_Init(void);
  29. void delay (u8 num);
  30. void delay_ms(uint ms);
  31. void OLED_IIC_Start(void);
  32. void OLED_IIC_Stop(void);
  33. u8 IIC_Wait_Ack(void);
  34. void Write_IIC_Byte(u8 IIC_Byte);
  35. void Write_IIC_Command(u8 IIC_Command);
  36. void Write_IIC_Data(u8 IIC_Data);
  37. uint OLED_Pow(u8 m,u8 n);
  38. void OLED_WR_Byte(u8 dat,u8 cmd);   //OLED写字节函数
  39. void OLED_Display_On(void); //开显示函数
  40. void OLED_Display_Off(void);//关显示函数
  41. void OLED_Init(void); //OLED初始化函数
  42. void OLED_Clear(void);  //清屏函数
  43. void OLED_ShowChar(u8 x,u8 y,u8 chr); //显示字符函数
  44. void OLED_ShowNum(u8 x,u8 y,uint num,u8 len,u8 size2); //在指定的位置,显示一个指定数的长度大小函数
  45. void OLED_ShowString(u8 x,u8 y, u8 *chr);  //在指定位置开始显示字符串函数
  46. void OLED_Set_Pos(u8 x, u8 y);  //画点函数
  47. void OLED_ShowChinese(u8 x,u8 y,u8 no); //声明在指定位置显示汉字函数
  48. void OLED_DrawBMP(u8 x0, u8 y0,u8 x1, u8 y1,u8 BMP[]); //显示图片函数
  49. void OLED_Scroll(void);//滚动函数
  50. void OLED_menu(u8 cur);
  51. void key_Init(void);
  52.   u8 key1_scan(void);
  53.   u8 key2_scan(void);
  54. void KeyPressed(u8 cur);
  55.   u8 key_scan(void);
  56. const u8 table[]={2,4,6};
  57. const u8 F6x8[][6];
  58. const u8 F8X16[];
  59. const u8 Hzk[][16];
  60. //const u8 BMP1[];

  61. main()
  62. {
  63. CLK_CKDIVR = 0x00;//f_HSI = f_HSI RC 输出    f_CPU = f_MASTER    16M
  64. OLED_Init();//OLED初始化
  65. key_Init();
  66.                 KeyPressed(1);



  67.         while (1);
  68.    
  69. }

  70. void delay(u8 num)
  71. {
  72. while(num--);
  73. }

  74. void delay_ms(uint ms)//延迟函数,MS级别
  75. {
  76. uint x,y;
  77. for(x = ms;x>0;x--)
  78. {
  79.   for(y = 1300;y>0;y--);
  80. }
  81. }

  82. void OLED_GPIO_Init(void)
  83. {
  84. PB_DDR |= 0x03; //将 PB0 PB1 口设为输出
  85. PB_CR1 &= 0xfc; //将 PB0 PB1 口设为开漏
  86. PB_CR2 &= 0xfc;//将 PB0 PB1 口设为开漏
  87. OLED_SCLK_Set(); //将PB4(SCL)设为高
  88. OLED_SDIN_Set(); //将PB5(SDA)设为高
  89. }

  90. void OLED_IIC_Start(void)
  91. {
  92. OLED_SCLK_Set(); //时钟线置高
  93. OLED_SDIN_Set(); //信号线置高
  94. delay(1); //延迟1us
  95. OLED_SDIN_Clr(); //信号线置低
  96. delay(1); //延迟1us
  97. OLED_SCLK_Clr(); //时钟线置低
  98. delay(1); //延迟1us
  99. }

  100. void OLED_IIC_Stop(void)
  101. {
  102. OLED_SDIN_Clr(); //信号线置低
  103. delay(1); //延迟1us
  104. OLED_SCLK_Set(); //时钟线置高
  105. delay(1); //延迟1us
  106. OLED_SDIN_Set(); //信号线置高
  107. delay(1); //延迟1us
  108. }
  109. u8 IIC_Wait_Ack(void)
  110. {
  111. u8 ack;
  112. OLED_SCLK_Clr(); //时钟线置低
  113. delay(1); //延迟1us
  114. OLED_SDIN_Set(); //信号线置高
  115. delay(1); //延迟1us
  116. OLED_SCLK_Set(); //时钟线置高
  117. delay(1); //延迟1us
  118. if(OLED_READ_SDIN()) //读取SDA的电平
  119.   ack = IIC_NO_ACK; //如果为1,则从机没有应答
  120. else
  121.   ack = IIC_ACK;  //如果为0,则从机应答
  122. OLED_SCLK_Clr();//时钟线置低
  123. delay(1); //延迟1us
  124. return ack; //返回读取到的应答信息
  125. }


  126. void Write_IIC_Byte(u8 IIC_Byte)
  127. {
  128. u8 i;  //定义变量
  129. for(i=0;i<8;i++) //for循环8次
  130. {
  131.   OLED_SCLK_Clr(); //时钟线置低,为传输数据做准备
  132.   delay(1); //延迟1us
  133.   if(IIC_Byte & 0x80) //读取最高位
  134.      OLED_SDIN_Set(); //最高位为1
  135.   else
  136.    OLED_SDIN_Clr(); //最高位为0
  137.   IIC_Byte <<= 1;  //数据左移1位
  138.   delay(1); //延迟1us
  139.   OLED_SCLK_Set(); //时钟线置高,产生上升沿,把数据发送出去
  140.   delay(1); //延迟1us
  141. }
  142. OLED_SCLK_Clr(); //时钟线置低
  143. delay(1); //延迟1us
  144. while(IIC_Wait_Ack()); //从机应答
  145. }


  146. void Write_IIC_Command(u8 IIC_Command)
  147. {
  148.    OLED_IIC_Start();
  149.    Write_IIC_Byte(0x78);//写入从机地址,SD0 = 0
  150.    Write_IIC_Byte(0x00);//写入命令
  151.    Write_IIC_Byte(IIC_Command);//数据
  152.    OLED_IIC_Stop();  //发送停止信号
  153. }

  154. void Write_IIC_Data(u8 IIC_Data)
  155. {
  156.    OLED_IIC_Start();
  157.    Write_IIC_Byte(0x78); //写入从机地址,SD0 = 0
  158.    Write_IIC_Byte(0x40); //写入数据
  159.    Write_IIC_Byte(IIC_Data);//数据
  160.    OLED_IIC_Stop();  //发送停止信号
  161. }

  162. void OLED_WR_Byte(u8 dat,u8 cmd)
  163. {
  164. if(cmd)
  165.    {
  166.        Write_IIC_Data(dat); //写入数据
  167.    }
  168. else {
  169.        Write_IIC_Command(dat); //写入命令
  170. }
  171. }

  172. void OLED_Set_Pos(u8 x,u8 y)
  173. {
  174. OLED_WR_Byte(0xb0+y,OLED_CMD);//写入页地址
  175. OLED_WR_Byte((x&0x0f),OLED_CMD);  //写入列的地址  低半字节
  176. OLED_WR_Byte(((x&0xf0)>>4)|0x10,OLED_CMD);//写入列的地址 高半字节
  177. }      

  178. void OLED_Display_On(void)
  179. {
  180. OLED_WR_Byte(0X8D,OLED_CMD);  //设置OLED电荷泵
  181. OLED_WR_Byte(0X14,OLED_CMD);  //使能,开
  182. OLED_WR_Byte(0XAF,OLED_CMD);  //开显示
  183. }

  184. void OLED_Display_Off(void)
  185. {
  186. OLED_WR_Byte(0XAE,OLED_CMD);  //关显示
  187. OLED_WR_Byte(0X8D,OLED_CMD);  //设置OLED电荷泵
  188. OLED_WR_Byte(0X10,OLED_CMD);  //失能,关
  189. }         

  190.    
  191. void OLED_Clear(void)  
  192. {  
  193. u8 i,n;      //定义变量
  194. for(i=0;i<8;i++)  
  195. {  
  196.   OLED_WR_Byte (0xb0+i,OLED_CMD);    //从0~7页依次写入
  197.   OLED_WR_Byte (0x00,OLED_CMD);      //列低地址
  198.   OLED_WR_Byte (0x10,OLED_CMD);      //列高地址  
  199.   for(n=0;n<128;n++)OLED_WR_Byte(0,OLED_DATA); //写入 0 清屏
  200. }
  201. }

  202. void OLED_ShowChar(u8 x,u8 y,u8 chr)
  203. {      
  204. u8 c=0,i=0;
  205.   c=chr-' '; //获取字符的偏移量
  206.   if(x>Max_Column-1){x=0;y=y+2;} //如果列数超出了范围,就从下2页的第0列开始
  207.   if(SIZE ==16) //字符大小如果为 16 = 8*16
  208.    {
  209.     OLED_Set_Pos(x,y); //从x y 开始画点
  210.     for(i=0;i<8;i++)  //循环8次 占8列
  211.     OLED_WR_Byte(F8X16[c*16+i],OLED_DATA); //找出字符 c 的数组位置,先在第一页把列画完
  212.     OLED_Set_Pos(x,y+1); //页数加1
  213.     for(i=0;i<8;i++)  //循环8次
  214.     OLED_WR_Byte(F8X16[c*16+i+8],OLED_DATA); //把第二页的列数画完
  215.    }
  216.   else  //字符大小为 6 = 6*8
  217.    {
  218.     OLED_Set_Pos(x,y+1); //一页就可以画完
  219.     for(i=0;i<6;i++) //循环6次 ,占6列
  220.     OLED_WR_Byte(F6x8[c][i],OLED_DATA); //把字符画完
  221.    }
  222. }

  223. uint OLED_Pow(u8 m,u8 n)
  224. {
  225. uint result=1;  
  226. while(n--)result*=m;   
  227. return result;
  228. }      

  229.    
  230. void OLED_ShowNum(u8 x,u8 y,uint num,u8 len,u8 size)
  231. {         
  232. u8 t,temp;  //定义变量
  233. u8 enshow=0;  //定义变量
  234. for(t=0;t<len;t++)
  235. {
  236.   temp=(num/OLED_Pow(10,len-t-1))%10;//取出输入数的每个位,由高到低
  237.   if(enshow==0&&t<(len-1)) //enshow:是否为第一个数;t<(len-1):判断是否为最后一个数
  238.   {
  239.    if(temp==0) //如果该数为0
  240.    {
  241.     OLED_ShowChar(x+(size/2)*t,y,' ');//显示 0 ;x+(size2/2)*t根据字体大小偏移的列数(8)
  242.     continue; //跳过剩下语句,继续重复循环(避免重复显示)
  243.    }else enshow=1;
  244.   }
  245.    OLED_ShowChar(x+(size/2)*t,y,temp+'0'); //显示一个位;x+(size2/2)*t根据字体大小偏移的列数(8)
  246. }
  247. }

  248. void OLED_ShowString(u8 x,u8 y,u8 *chr)
  249. {
  250. u8 j=0; //定义变量
  251. while (chr[j]!='\0') //如果不是最后一个字符
  252. {  
  253.   OLED_ShowChar(x,y,chr[j]); //显示字符
  254.   x+=8; //列数加8 ,一个字符的列数占8
  255.   if(x>=128){x=0;y+=2;} //如果x大于等于128,切换页,从该页的第一列显示
  256.   j++; //下一个字符
  257. }
  258. }


  259. void OLED_ShowChinese(u8 x,u8 y,u8 no)
  260. {            
  261. u8 t; //定义变量
  262. OLED_Set_Pos(x,y); //从 x y 开始画点,先画第一页
  263.     for(t=0;t<16;t++) //循环16次,画第一页的16列
  264.   {
  265.    OLED_WR_Byte(Hzk[no*2][t],OLED_DATA);//画no在数组位2*no
  266.       }
  267.   OLED_Set_Pos(x,y+1); //画第二页
  268.     for(t=0;t<16;t++)//循环16次,画第二页的16列
  269.   {
  270.    OLED_WR_Byte(Hzk[2*no+1][t],OLED_DATA);//画no在数组位置的第二页16列的点
  271.         }     
  272. }

  273. void OLED_DrawBMP(u8 x0, u8 y0,u8 x1, u8 y1,u8 BMP[])
  274. {  
  275.   uint j=0; //定义变量
  276.   u8 x,y; //定义变量
  277.   
  278.   if(y1%8==0) y=y1/8;   //判断终止页是否为8的整数倍
  279.    else y=y1/8+1;
  280.   for(y=y0;y<y1;y++) //从起始页开始,画到终止页
  281.   {
  282.    OLED_Set_Pos(x0,y); //在页的起始列开始画
  283.       for(x=x0;x<x1;x++) //画x1 - x0 列
  284.        {
  285.         OLED_WR_Byte(BMP[j++],OLED_DATA); //画图片的点     
  286.        }
  287.   }
  288. }

  289.         
  290. void OLED_Init(void)
  291. {
  292. OLED_GPIO_Init(); //GPIO口初始化

  293. delay_ms(200); //延迟,由于单片机上电初始化比OLED快,所以必须加上延迟,等待OLED上复位完成
  294. OLED_WR_Byte(0xAE,OLED_CMD); //关闭显示
  295. OLED_WR_Byte(0x00,OLED_CMD); //设置低列地址
  296. OLED_WR_Byte(0x10,OLED_CMD); //设置高列地址
  297. OLED_WR_Byte(0x40,OLED_CMD); //设置起始行地址
  298. OLED_WR_Byte(0xB0,OLED_CMD); //设置页地址
  299. OLED_WR_Byte(0x81,OLED_CMD);  // 对比度设置,可设置亮度
  300. OLED_WR_Byte(0xFF,OLED_CMD); //  265  
  301. OLED_WR_Byte(0xA1,OLED_CMD); //设置段(SEG)的起始映射地址;column的127地址是SEG0的地址
  302. OLED_WR_Byte(0xA6,OLED_CMD); //正常显示;0xa7逆显示
  303. OLED_WR_Byte(0xA8,OLED_CMD); //设置驱动路数(16~64)
  304. OLED_WR_Byte(0x3F,OLED_CMD); //64duty

  305. OLED_WR_Byte(0xC8,OLED_CMD); //重映射模式,COM[N-1]~COM0扫描
  306. OLED_WR_Byte(0xD3,OLED_CMD); //设置显示偏移
  307. OLED_WR_Byte(0x00,OLED_CMD); //无偏移

  308. OLED_WR_Byte(0xD5,OLED_CMD); //设置震荡器分频
  309. OLED_WR_Byte(0x80,OLED_CMD); //使用默认值

  310. OLED_WR_Byte(0xD9,OLED_CMD); //设置 Pre-Charge Period
  311. OLED_WR_Byte(0xF1,OLED_CMD); //使用官方推荐值

  312. OLED_WR_Byte(0xDA,OLED_CMD); //设置 com pin configuartion
  313. OLED_WR_Byte(0x12,OLED_CMD); //使用默认值

  314. OLED_WR_Byte(0xDB,OLED_CMD); //设置 Vcomh,可调节亮度(默认)
  315. OLED_WR_Byte(0x40,OLED_CMD); ////使用官方推荐值

  316. OLED_WR_Byte(0x8D,OLED_CMD); //设置OLED电荷泵
  317. OLED_WR_Byte(0x14,OLED_CMD); //开显示

  318. OLED_WR_Byte(0xAF,OLED_CMD); //开启OLED面板显示
  319. OLED_Clear();        //清屏
  320. OLED_Set_Pos(0,0);   //设置数据写入的起始行、列
  321. }  

  322. void OLED_Scroll(void)
  323. {
  324. OLED_WR_Byte(0x2E,OLED_CMD); //关闭滚动
  325. OLED_WR_Byte(0x27,OLED_CMD); //水平向左滚动
  326. OLED_WR_Byte(0x00,OLED_CMD); //虚拟字节
  327. OLED_WR_Byte(0x00,OLED_CMD); //起始页 0
  328. OLED_WR_Byte(0x00,OLED_CMD); //滚动时间间隔
  329. OLED_WR_Byte(0x01,OLED_CMD); //终止页 1
  330. OLED_WR_Byte(0x00,OLED_CMD); //虚拟字节
  331. OLED_WR_Byte(0xFF,OLED_CMD); //虚拟字节
  332. OLED_WR_Byte(0x2F,OLED_CMD); //开启滚动
  333. }


  334. const u8  F6x8[][6] =  
  335. {
  336. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,// sp
  337. 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00,// !
  338. 0x00, 0x00, 0x07, 0x00, 0x07, 0x00,// "
  339. 0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14,// #
  340. 0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12,// $
  341. 0x00, 0x62, 0x64, 0x08, 0x13, 0x23,// %
  342. 0x00, 0x36, 0x49, 0x55, 0x22, 0x50,// &
  343. 0x00, 0x00, 0x05, 0x03, 0x00, 0x00,// '
  344. 0x00, 0x00, 0x1c, 0x22, 0x41, 0x00,// (
  345. 0x00, 0x00, 0x41, 0x22, 0x1c, 0x00,// )
  346. 0x00, 0x14, 0x08, 0x3E, 0x08, 0x14,// *
  347. 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08,// +
  348. 0x00, 0x00, 0x00, 0xA0, 0x60, 0x00,// ,
  349. 0x00, 0x08, 0x08, 0x08, 0x08, 0x08,// -
  350. 0x00, 0x00, 0x60, 0x60, 0x00, 0x00,// .
  351. 0x00, 0x20, 0x10, 0x08, 0x04, 0x02,// /
  352. 0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E,// 0
  353. 0x00, 0x00, 0x42, 0x7F, 0x40, 0x00,// 1
  354. 0x00, 0x42, 0x61, 0x51, 0x49, 0x46,// 2
  355. 0x00, 0x21, 0x41, 0x45, 0x4B, 0x31,// 3
  356. 0x00, 0x18, 0x14, 0x12, 0x7F, 0x10,// 4
  357. 0x00, 0x27, 0x45, 0x45, 0x45, 0x39,// 5
  358. 0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30,// 6
  359. 0x00, 0x01, 0x71, 0x09, 0x05, 0x03,// 7
  360. 0x00, 0x36, 0x49, 0x49, 0x49, 0x36,// 8
  361. 0x00, 0x06, 0x49, 0x49, 0x29, 0x1E,// 9
  362. 0x00, 0x00, 0x36, 0x36, 0x00, 0x00,// :
  363. 0x00, 0x00, 0x56, 0x36, 0x00, 0x00,// ;
  364. 0x00, 0x08, 0x14, 0x22, 0x41, 0x00,// <
  365. 0x00, 0x14, 0x14, 0x14, 0x14, 0x14,// =
  366. 0x00, 0x00, 0x41, 0x22, 0x14, 0x08,// >
  367. 0x00, 0x02, 0x01, 0x51, 0x09, 0x06,// ?
  368. 0x00, 0x32, 0x49, 0x59, 0x51, 0x3E,// @
  369. 0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C,// A
  370. 0x00, 0x7F, 0x49, 0x49, 0x49, 0x36,// B
  371. 0x00, 0x3E, 0x41, 0x41, 0x41, 0x22,// C
  372. 0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C,// D
  373. 0x00, 0x7F, 0x49, 0x49, 0x49, 0x41,// E
  374. 0x00, 0x7F, 0x09, 0x09, 0x09, 0x01,// F
  375. 0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A,// G
  376. 0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F,// H
  377. 0x00, 0x00, 0x41, 0x7F, 0x41, 0x00,// I
  378. 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01,// J
  379. 0x00, 0x7F, 0x08, 0x14, 0x22, 0x41,// K
  380. 0x00, 0x7F, 0x40, 0x40, 0x40, 0x40,// L
  381. 0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F,// M
  382. 0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F,// N
  383. 0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E,// O
  384. 0x00, 0x7F, 0x09, 0x09, 0x09, 0x06,// P
  385. 0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E,// Q
  386. 0x00, 0x7F, 0x09, 0x19, 0x29, 0x46,// R
  387. 0x00, 0x46, 0x49, 0x49, 0x49, 0x31,// S
  388. 0x00, 0x01, 0x01, 0x7F, 0x01, 0x01,// T
  389. 0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F,// U
  390. 0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F,// V
  391. 0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F,// W
  392. 0x00, 0x63, 0x14, 0x08, 0x14, 0x63,// X
  393. 0x00, 0x07, 0x08, 0x70, 0x08, 0x07,// Y
  394. 0x00, 0x61, 0x51, 0x49, 0x45, 0x43,// Z
  395. 0x00, 0x00, 0x7F, 0x41, 0x41, 0x00,// [
  396. 0x00, 0x55, 0x2A, 0x55, 0x2A, 0x55,// 55
  397. 0x00, 0x00, 0x41, 0x41, 0x7F, 0x00,// ]
  398. 0x00, 0x04, 0x02, 0x01, 0x02, 0x04,// ^
  399. 0x00, 0x40, 0x40, 0x40, 0x40, 0x40,// _
  400. 0x00, 0x00, 0x01, 0x02, 0x04, 0x00,// '
  401. 0x00, 0x20, 0x54, 0x54, 0x54, 0x78,// a
  402. 0x00, 0x7F, 0x48, 0x44, 0x44, 0x38,// b
  403. 0x00, 0x38, 0x44, 0x44, 0x44, 0x20,// c
  404. 0x00, 0x38, 0x44, 0x44, 0x48, 0x7F,// d
  405. 0x00, 0x38, 0x54, 0x54, 0x54, 0x18,// e
  406. 0x00, 0x08, 0x7E, 0x09, 0x01, 0x02,// f
  407. 0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C,// g
  408. 0x00, 0x7F, 0x08, 0x04, 0x04, 0x78,// h
  409. 0x00, 0x00, 0x44, 0x7D, 0x40, 0x00,// i
  410. 0x00, 0x40, 0x80, 0x84, 0x7D, 0x00,// j
  411. 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00,// k
  412. 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00,// l
  413. 0x00, 0x7C, 0x04, 0x18, 0x04, 0x78,// m
  414. 0x00, 0x7C, 0x08, 0x04, 0x04, 0x78,// n
  415. 0x00, 0x38, 0x44, 0x44, 0x44, 0x38,// o
  416. 0x00, 0xFC, 0x24, 0x24, 0x24, 0x18,// p
  417. 0x00, 0x18, 0x24, 0x24, 0x18, 0xFC,// q
  418. 0x00, 0x7C, 0x08, 0x04, 0x04, 0x08,// r
  419. 0x00, 0x48, 0x54, 0x54, 0x54, 0x20,// s
  420. 0x00, 0x04, 0x3F, 0x44, 0x40, 0x20,// t
  421. 0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C,// u
  422. 0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C,// v
  423. 0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C,// w
  424. 0x00, 0x44, 0x28, 0x10, 0x28, 0x44,// x
  425. 0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C,// y
  426. 0x00, 0x44, 0x64, 0x54, 0x4C, 0x44,// z
  427. 0x14, 0x14, 0x14, 0x14, 0x14, 0x14,// horiz lines
  428. };
  429. /****************************************8*16的点阵************************************/
  430. const u8  F8X16[]=   
  431. {
  432.   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0
  433.   0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x30,0x00,0x00,0x00,//! 1
  434.   0x00,0x10,0x0C,0x06,0x10,0x0C,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//" 2
  435.   0x40,0xC0,0x78,0x40,0xC0,0x78,0x40,0x00,0x04,0x3F,0x04,0x04,0x3F,0x04,0x04,0x00,//# 3
  436.   0x00,0x70,0x88,0xFC,0x08,0x30,0x00,0x00,0x00,0x18,0x20,0xFF,0x21,0x1E,0x00,0x00,//$ 4
  437.   0xF0,0x08,0xF0,0x00,0xE0,0x18,0x00,0x00,0x00,0x21,0x1C,0x03,0x1E,0x21,0x1E,0x00,//% 5
  438.   0x00,0xF0,0x08,0x88,0x70,0x00,0x00,0x00,0x1E,0x21,0x23,0x24,0x19,0x27,0x21,0x10,//& 6
  439.   0x10,0x16,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//' 7
  440.   0x00,0x00,0x00,0xE0,0x18,0x04,0x02,0x00,0x00,0x00,0x00,0x07,0x18,0x20,0x40,0x00,//( 8
  441.   0x00,0x02,0x04,0x18,0xE0,0x00,0x00,0x00,0x00,0x40,0x20,0x18,0x07,0x00,0x00,0x00,//) 9
  442.   0x40,0x40,0x80,0xF0,0x80,0x40,0x40,0x00,0x02,0x02,0x01,0x0F,0x01,0x02,0x02,0x00,//* 10
  443.   0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x1F,0x01,0x01,0x01,0x00,//+ 11
  444.   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xB0,0x70,0x00,0x00,0x00,0x00,0x00,//, 12
  445.   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,//- 13
  446.   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,//. 14
  447.   0x00,0x00,0x00,0x00,0x80,0x60,0x18,0x04,0x00,0x60,0x18,0x06,0x01,0x00,0x00,0x00,/// 15
  448.   0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,//0 16
  449.   0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//1 17
  450.   0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,//2 18
  451.   0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,//3 19
  452.   0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,//4 20
  453.   0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,//5 21
  454.   0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,//6 22
  455.   0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,//7 23
  456.   0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,//8 24
  457.   0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,//9 25
  458.   0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,//: 26
  459.   0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x60,0x00,0x00,0x00,0x00,//; 27
  460.   0x00,0x00,0x80,0x40,0x20,0x10,0x08,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x00,//< 28
  461.   0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00,//= 29
  462.   0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x20,0x10,0x08,0x04,0x02,0x01,0x00,//> 30
  463.   0x00,0x70,0x48,0x08,0x08,0x08,0xF0,0x00,0x00,0x00,0x00,0x30,0x36,0x01,0x00,0x00,//? 31
  464.   0xC0,0x30,0xC8,0x28,0xE8,0x10,0xE0,0x00,0x07,0x18,0x27,0x24,0x23,0x14,0x0B,0x00,//@ 32
  465.   0x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20,//A 33
  466.   0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00,//B 34
  467.   0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00,//C 35
  468.   0x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,0x20,0x3F,0x20,0x20,0x20,0x10,0x0F,0x00,//D 36
  469.   0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x20,0x23,0x20,0x18,0x00,//E 37
  470.   0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x00,0x03,0x00,0x00,0x00,//F 38
  471.   0xC0,0x30,0x08,0x08,0x08,0x38,0x00,0x00,0x07,0x18,0x20,0x20,0x22,0x1E,0x02,0x00,//G 39
  472.   0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x20,0x3F,0x21,0x01,0x01,0x21,0x3F,0x20,//H 40
  473.   0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//I 41
  474.   0x00,0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,0x00,//J 42
  475.   0x08,0xF8,0x88,0xC0,0x28,0x18,0x08,0x00,0x20,0x3F,0x20,0x01,0x26,0x38,0x20,0x00,//K 43
  476.   0x08,0xF8,0x08,0x00,0x00,0x00,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x20,0x30,0x00,//L 44
  477.   0x08,0xF8,0xF8,0x00,0xF8,0xF8,0x08,0x00,0x20,0x3F,0x00,0x3F,0x00,0x3F,0x20,0x00,//M 45
  478.   0x08,0xF8,0x30,0xC0,0x00,0x08,0xF8,0x08,0x20,0x3F,0x20,0x00,0x07,0x18,0x3F,0x00,//N 46
  479.   0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x10,0x20,0x20,0x20,0x10,0x0F,0x00,//O 47
  480.   0x08,0xF8,0x08,0x08,0x08,0x08,0xF0,0x00,0x20,0x3F,0x21,0x01,0x01,0x01,0x00,0x00,//P 48
  481.   0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x18,0x24,0x24,0x38,0x50,0x4F,0x00,//Q 49
  482.   0x08,0xF8,0x88,0x88,0x88,0x88,0x70,0x00,0x20,0x3F,0x20,0x00,0x03,0x0C,0x30,0x20,//R 50
  483.   0x00,0x70,0x88,0x08,0x08,0x08,0x38,0x00,0x00,0x38,0x20,0x21,0x21,0x22,0x1C,0x00,//S 51
  484.   0x18,0x08,0x08,0xF8,0x08,0x08,0x18,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//T 52
  485.   0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//U 53
  486.   0x08,0x78,0x88,0x00,0x00,0xC8,0x38,0x08,0x00,0x00,0x07,0x38,0x0E,0x01,0x00,0x00,//V 54
  487.   0xF8,0x08,0x00,0xF8,0x00,0x08,0xF8,0x00,0x03,0x3C,0x07,0x00,0x07,0x3C,0x03,0x00,//W 55
  488.   0x08,0x18,0x68,0x80,0x80,0x68,0x18,0x08,0x20,0x30,0x2C,0x03,0x03,0x2C,0x30,0x20,//X 56
  489.   0x08,0x38,0xC8,0x00,0xC8,0x38,0x08,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//Y 57
  490.   0x10,0x08,0x08,0x08,0xC8,0x38,0x08,0x00,0x20,0x38,0x26,0x21,0x20,0x20,0x18,0x00,//Z 58
  491.   0x00,0x00,0x00,0xFE,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x7F,0x40,0x40,0x40,0x00,//[ 59
  492.   0x00,0x0C,0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x06,0x38,0xC0,0x00,//\ 60
  493.   0x00,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x7F,0x00,0x00,0x00,//] 61
  494.   0x00,0x00,0x04,0x02,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//^ 62
  495.   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,//_ 63
  496.   0x00,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//` 64
  497.   0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x19,0x24,0x22,0x22,0x22,0x3F,0x20,//a 65
  498.   0x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00,//b 66
  499.   0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00,//c 67
  500.   0x00,0x00,0x00,0x80,0x80,0x88,0xF8,0x00,0x00,0x0E,0x11,0x20,0x20,0x10,0x3F,0x20,//d 68
  501.   0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x22,0x22,0x22,0x22,0x13,0x00,//e 69
  502.   0x00,0x80,0x80,0xF0,0x88,0x88,0x88,0x18,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//f 70
  503.   0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x6B,0x94,0x94,0x94,0x93,0x60,0x00,//g 71
  504.   0x08,0xF8,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//h 72
  505.   0x00,0x80,0x98,0x98,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//i 73
  506.   0x00,0x00,0x00,0x80,0x98,0x98,0x00,0x00,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,//j 74
  507.   0x08,0xF8,0x00,0x00,0x80,0x80,0x80,0x00,0x20,0x3F,0x24,0x02,0x2D,0x30,0x20,0x00,//k 75
  508.   0x00,0x08,0x08,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//l 76
  509.   0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F,//m 77
  510.   0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//n 78
  511.   0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//o 79
  512.   0x80,0x80,0x00,0x80,0x80,0x00,0x00,0x00,0x80,0xFF,0xA1,0x20,0x20,0x11,0x0E,0x00,//p 80
  513.   0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x0E,0x11,0x20,0x20,0xA0,0xFF,0x80,//q 81
  514.   0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x20,0x20,0x3F,0x21,0x20,0x00,0x01,0x00,//r 82
  515.   0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x33,0x24,0x24,0x24,0x24,0x19,0x00,//s 83
  516.   0x00,0x80,0x80,0xE0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x1F,0x20,0x20,0x00,0x00,//t 84
  517.   0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x1F,0x20,0x20,0x20,0x10,0x3F,0x20,//u 85
  518.   0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x00,0x01,0x0E,0x30,0x08,0x06,0x01,0x00,//v 86
  519.   0x80,0x80,0x00,0x80,0x00,0x80,0x80,0x80,0x0F,0x30,0x0C,0x03,0x0C,0x30,0x0F,0x00,//w 87
  520.   0x00,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x31,0x2E,0x0E,0x31,0x20,0x00,//x 88
  521.   0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x80,0x81,0x8E,0x70,0x18,0x06,0x01,0x00,//y 89
  522.   0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x21,0x30,0x2C,0x22,0x21,0x30,0x00,//z 90
  523.   0x00,0x00,0x00,0x00,0x80,0x7C,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x3F,0x40,0x40,//{ 91
  524.   0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,//| 92
  525.   0x00,0x02,0x02,0x7C,0x80,0x00,0x00,0x00,0x00,0x40,0x40,0x3F,0x00,0x00,0x00,0x00,//} 93
  526.   0x00,0x06,0x01,0x01,0x02,0x02,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//~ 94
  527. };
  528. const u8  Hzk[][16]={        
  529. {0x04,0x04,0x44,0xC4,0x4F,0x44,0x44,0xC4,0x24,0x24,0x2F,0xB4,0x24,0x04,0x04,0x00},
  530. {0x40,0x44,0x24,0x24,0x15,0x0C,0x04,0xFE,0x04,0x0C,0x15,0x24,0x24,0x44,0x40,0x00},/*"菜",0*/
  531. {0x00,0x00,0xF8,0x49,0x4A,0x4C,0x48,0xF8,0x48,0x4C,0x4A,0x49,0xF8,0x00,0x00,0x00},
  532. {0x10,0x10,0x13,0x12,0x12,0x12,0x12,0xFF,0x12,0x12,0x12,0x12,0x13,0x10,0x10,0x00},/*"单",1*/
  533. {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
  534. {0x00,0x00,0x36,0x36,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*":",2*/

  535. {0x10,0x10,0x10,0xFF,0x90,0x20,0x98,0x88,0x88,0xE9,0x8E,0x88,0x88,0xA8,0x98,0x00},
  536. {0x02,0x42,0x81,0x7F,0x00,0x00,0x80,0x84,0x4B,0x28,0x10,0x28,0x47,0x80,0x00,0x00},/*"按",3*/
  537. {0x40,0x30,0xEF,0x24,0x24,0x80,0xE4,0x9C,0x10,0x54,0x54,0xFF,0x54,0x7C,0x10,0x00},
  538. {0x01,0x01,0x7F,0x21,0x51,0x26,0x18,0x27,0x44,0x45,0x45,0x5F,0x45,0x45,0x44,0x00},/*"键",4*/
  539. {0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00},
  540. {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"一",5*/

  541. {0x10,0x10,0x10,0xFF,0x90,0x20,0x98,0x88,0x88,0xE9,0x8E,0x88,0x88,0xA8,0x98,0x00},
  542. {0x02,0x42,0x81,0x7F,0x00,0x00,0x80,0x84,0x4B,0x28,0x10,0x28,0x47,0x80,0x00,0x00},/*"按",6*/
  543. {0x40,0x30,0xEF,0x24,0x24,0x80,0xE4,0x9C,0x10,0x54,0x54,0xFF,0x54,0x7C,0x10,0x00},
  544. {0x01,0x01,0x7F,0x21,0x51,0x26,0x18,0x27,0x44,0x45,0x45,0x5F,0x45,0x45,0x44,0x00},/*"键",7*/
  545. {0x00,0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x00,0x00},
  546. {0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00},/*"二",8*/

  547. {0x04,0x34,0xC4,0x04,0xC4,0x3C,0x00,0x04,0xFC,0x04,0x04,0x04,0xC4,0x3C,0x00,0x00},
  548. {0x40,0x30,0x0C,0x03,0x0C,0x30,0x80,0x40,0x20,0x13,0x0C,0x13,0x20,0x40,0x80,0x00},/*"双",9*/
  549. {0x10,0x10,0x10,0xFF,0x90,0x20,0x98,0x88,0x88,0xE9,0x8E,0x88,0x88,0xA8,0x98,0x00},
  550. {0x02,0x42,0x81,0x7F,0x00,0x00,0x80,0x84,0x4B,0x28,0x10,0x28,0x47,0x80,0x00,0x00},/*"按",10*/
  551. {0x40,0x30,0xEF,0x24,0x24,0x80,0xE4,0x9C,0x10,0x54,0x54,0xFF,0x54,0x7C,0x10,0x00},
  552. {0x01,0x01,0x7F,0x21,0x51,0x26,0x18,0x27,0x44,0x45,0x45,0x5F,0x45,0x45,0x44,0x00},/*"键",11*/
  553. };
  554. void key_Init(void)
  555. {
  556.   PD_DDR&=0X00;
  557.   PD_CR1=0X18;//PD3,PD4带上拉的输入模式
  558.   PD_CR2&=0X00;
  559. }

  560. u8 key1_scan(void)           //PD3
  561. {
  562.              static u8 key1_up=0;
  563.               u8 num;
  564.               num=PD_IDR;
  565.               num=PD_IDR&0x18;
  566.               if(num==0x10)
  567.                   delay_ms(30);
  568.   if(num==0x10)
  569.   {
  570.           key1_up=0;
  571.   }
  572.   else
  573. {
  574.    key1_up=1;
  575.    return 1;
  576. }
  577.      return 0;
  578. }      
  579.         
  580.         
  581. u8 key2_scan(void)           //PD4
  582. {  
  583.     static u8 key2_up=0;
  584.     u8 num;
  585.     num=PD_IDR;
  586.     num=PD_IDR&0x18;
  587.      if(num==0x08)
  588.          delay_ms(30);
  589.              if(num==0x08)
  590. {
  591.                      key2_up=0;
  592.   }
  593.   else
  594. {
  595.       key2_up=1;
  596.       return 1;
  597.                  }
  598.      return 0;
  599. }      

  600. u8 key_scan(void)
  601. {
  602.   u8 key_code;
  603.   if(key1_scan()==1)key_code=2;
  604.   else if(key2_scan()==1)key_code=3;
  605.   else key_code=0;
  606.   return key_code;
  607. }

  608. void KeyPressed(u8 cur)
  609. {
  610.   u8 flag=0;
  611. OLED_menu(cur);
  612.       while(1)
  613.                          {
  614.   if(flag)
  615.   {
  616.    OLED_menu(cur);
  617.    flag=2;
  618.            }
  619.   switch(key_scan())
  620.   {
  621.       case 0: flag = 0;
  622.       break;
  623.   
  624.       
  625.                      case 3: flag = 1;
  626.                  if(cur==3)
  627.                  cur=1;
  628.                else
  629.                                                cur++;
  630.                 OLED_Clear();
  631.                break;
  632.   }
  633.            }
  634. }
  635. void OLED_menu(u8 cur)
  636.   {      
  637.       void   OLED_String(u8 x,u8 y,u8 *chr);
  638.       void   OLED_ShowChinese(u8 x,u8 y,u8  no);
  639.        switch(cur)
  640. {
  641.       
  642.         
  643. case 1:  
  644.                         OLED_ShowString(16,2,"=>");
  645.                         OLED_ShowChinese(0,0,0);//OLED显示      菜
  646.                                        OLED_ShowChinese(16,0,1);//OLED显示    单
  647.                         OLED_ShowChinese(32,0,2);//OLED显示     :
  648.                         OLED_ShowChinese(32,2,3);//OLED显示    按
  649.          OLED_ShowChinese(48,2,4);//OLED显示    键
  650.          OLED_ShowChinese(64,2,5);//OLED显示    一
  651.                         OLED_ShowChinese(32,4,6);//OLED显示    按
  652.          OLED_ShowChinese(48,4,7);//OLED显示    键
  653.                         OLED_ShowChinese(64,4,8);//OLED显示    二
  654.                         OLED_ShowChinese(32,6,9);//OLED显示    双
  655.          OLED_ShowChinese(48,6,10);//OLED显示  按
  656.          OLED_ShowChinese(64,6,11);//OLED显示  键               
  657.                                        break;
  658.             
  659. case 2:
  660.                  
  661.                         OLED_ShowString(16,4,"=>");
  662.                         OLED_ShowChinese(0,0,0);//OLED显示     菜
  663.                                        OLED_ShowChinese(16,0,1);//OLED显示   单
  664.                         OLED_ShowChinese(32,0,2);//OLED显示    :
  665.                         OLED_ShowChinese(32,2,3);//OLED显示   按
  666.          OLED_ShowChinese(48,2,4);//OLED显示   键
  667.          OLED_ShowChinese(64,2,5);//OLED显示   一
  668.                         OLED_ShowChinese(32,4,6);//OLED显示   按
  669.          OLED_ShowChinese(48,4,7);//OLED显示   键
  670.                         OLED_ShowChinese(64,4,8);//OLED显示   二
  671.                         OLED_ShowChinese(32,6,9);//OLED显示   双
  672.          OLED_ShowChinese(48,6,10);//OLED显示 按
  673.                                        OLED_ShowChinese(64,6,11);//OLED显示 键
  674.          break;
  675.             
  676.                  case 3:
  677.                       OLED_ShowString(16,6,"=>");
  678.                         OLED_ShowChinese(0,0,0);//OLED显示          菜
  679.                                        OLED_ShowChinese(16,0,1);//OLED显示        单
  680.                         OLED_ShowChinese(32,0,2);//OLED显示         :
  681.                         OLED_ShowChinese(32,2,3);//OLED显示        按
  682.                         OLED_ShowChinese(48,2,4);//OLED显示        键
  683.                                        OLED_ShowChinese(64,2,5);//OLED显示        一
  684.                         OLED_ShowChinese(32,4,6);//OLED显示        按
  685.          OLED_ShowChinese(48,4,7);//OLED显示        键
  686.                         OLED_ShowChinese(64,4,8);//OLED显示        二
  687.                         OLED_ShowChinese(32,6,9);//OLED显示        双
  688.          OLED_ShowChinese(48,6,10);//OLED显示      按
  689.          OLED_ShowChinese(64,6,11);//OLED显示      键
  690.                          break;     
  691.             
  692.    }
  693.   }
复制代码


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

本版积分规则

QQ|手机版|小黑屋|ELEOK |网站地图

GMT+8, 2024-11-21 18:35

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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