函数前没有类型定义,想问下这个是正确的么

[复制链接]
 楼主| 渔夫的烟斗 发表于 2017-1-12 09:39 | 显示全部楼层 |阅读模式
  1. //תÕß×¢£ºÔ­ÌùÔÚ£ºhttp://www.crystalradio.cn/bbs/thread-161639-1-1.html£¬×÷Õߣºsharkzyn £¬°æ±¾ÈÕÆÚ£º2011-6-26
  2. //LCDÓ¦¸ÃÊÇST7920оƬ´ø×Ö¿âµÄ12864

  3. #include <STC12C5A60S2.H>
  4. //#include <STC12c5a32s2.H>
  5. #include<intrins.h>
  6. sbit RS=P0^0; //²¢ÐеÄÖ¸Áî/Êý¾ÝÑ¡ÔñÐźÅ, HÊý¾Ý, LÃüÁî
  7. sbit RW=P0^1; //²¢ÐжÁдѡÔñÐźÅ, H¶Á, Lд
  8. sbit E=P0^2; //²¢ÐÐʹÄܶË, HÓÐЧ, LÎÞЧ
  9. sbit PSB=P0^3; //²¢/´®½Ó¿ÚÑ¡Ôñ, H²¢,L´®
  10. sbit led=P0^4;
  11. sbit fkey=P1^0;
  12. sbit vkey=P1^1;
  13. sbit ledkey=P1^2;
  14. #define  LcdData P2
  15. unsigned char dati=0;
  16. unsigned char dat[101];
  17. unsigned char dat0[101];
  18. unsigned char over=0;
  19. unsigned int temp=0;
  20. unsigned char mode=0;
  21. unsigned char vmode=0;
  22. unsigned int delnop=0;
  23. unsigned char vd=4;
  24. unsigned char cha=0;
  25. //////////////////////////////////////
  26. unsigned char Lcd_CheckBusy(void)
  27. {
  28.     unsigned char Busy;
  29.          LcdData=0xff;
  30.     RS=0;
  31.     RW=1;
  32.     E=1;
  33.     _nop_();
  34.     Busy=LcdData&0x80;
  35.     E=0;
  36.     return Busy;
  37. }
  38. /*********************************
  39. ÏòLCDдÈë×Ö½ÚÊý¾Ý
  40. **********************************/
  41. void Lcd_WriteData(unsigned char Data)
  42. {  
  43.         while(Lcd_CheckBusy());
  44.         RS=1;
  45.         RW=0;
  46.         E=0;
  47.         _nop_();  
  48.         _nop_();
  49.         LcdData=Data;
  50.         E=1;
  51.         _nop_();
  52.         _nop_();
  53.         E=0;
  54. }
  55. /***********************************
  56. ´ÓLCDÖжÁ³öÊý¾Ý
  57. ************************************/
  58. unsigned char Lcd_ReadData(void)
  59. {
  60.         unsigned char Temp;
  61.         while(Lcd_CheckBusy());
  62.         LcdData=0xff;
  63.         RS=1;
  64.         RW=1;
  65.         E=1;
  66.         _nop_();
  67.            Temp=LcdData;
  68.            E=0;
  69.            return Temp;
  70. }
  71. /*************************************
  72. ÏëLCDÖÐдÈëÖ¸Áî´úÂë
  73. **************************************/
  74. void Lcd_WriteCmd(unsigned char CmdCode)
  75. {  
  76.         while(Lcd_CheckBusy());
  77.            RS=0;
  78.            RW=0;
  79.            E=0;
  80.            _nop_();  
  81.         _nop_();
  82.            LcdData=CmdCode;
  83.            _nop_();
  84.         _nop_();
  85.            E=1;
  86.            _nop_();  
  87.         _nop_();
  88.            E=0;
  89. }
  90. /**************************************
  91. Ϊ¼ÓËÙÂß¼­ÔËËã¶øÉèÖõÄÑÚÂë±í£¬ÕâÊÇÒÔÎþÉü¿Õ¼ä¶ø»»È¡Ê±¼äµÄ°ì·¨
  92. ***************************************/
  93. code unsigned int LcdMaskTab[]={0x0001,0x0002,0x0004,0x0008,0x0010,0x0020,0x0040,0x0080,0x0100,0x0200,0x0400,0x0800,0x1000,0x2000,0x4000,0x8000};
  94. /***************************************
  95. ÏòLCDÖ¸¶¨×ø±êдÈëÒ»¸öÏóËØ,ÏóËØÑÕÉ«ÓÐÁ½ÖÖ£¬0´ú±í°×£¨ÎÞÏÔʾ£©£¬1´ú±íºÚ£¨ÓÐÏÔʾ£©
  96. ****************************************/
  97. void Lcd_PutPixel(unsigned char x,unsigned char y,unsigned char Color)
  98. {
  99.         unsigned char z,w;
  100.         unsigned int Temp;
  101.         if(x>=128||y>=64)
  102.                 return;
  103.         Color=Color%2;
  104.         w=15-x%16;//È·¶¨¶ÔÕâ¸ö×ֵĵڶàÉÙλ½øÐвÙ×÷
  105.         x=x/16;//È·¶¨ÎªÒ»ÐÐÉϵĵڼ¸×Ö

  106.         if(y<32) //Èç¹ûΪÉÏÒ³
  107.                 z=0x80;
  108.         else     //·ñÔòÈç¹ûΪÏÂÒ³
  109.                 z=0x88;

  110.         y=y%32;
  111.         //EA=0;
  112.         Lcd_WriteCmd(0x36);
  113.         Lcd_WriteCmd(y+0x80);        //ÐеØÖ·
  114.         Lcd_WriteCmd(x+z);     //ÁеØÖ·
  115.         Temp=Lcd_ReadData();//ÏȿնÁÒ»´Î
  116.         Temp=(unsigned int)Lcd_ReadData()<<8;//ÔÙ¶Á³ö¸ß8λ
  117.         Temp|=(unsigned int)Lcd_ReadData();//ÔÙ¶Á³öµÍ8λ
  118.         //EA=1;
  119.         if(Color==1) //Èç¹ûдÈëÑÕɫΪ1
  120.                 Temp|=LcdMaskTab[w];//ÔÚ´Ë´¦²é±íʵÏÖ¼ÓËÙ
  121.         else         //Èç¹ûдÈëÑÕɫΪ0
  122.                 Temp&=~LcdMaskTab[w];//ÔÚ´Ë´¦²é±íʵÏÖ¼ÓËÙ
  123.         //EA=0;
  124.         Lcd_WriteCmd(y+0x80);        //ÐеØÖ·
  125.         Lcd_WriteCmd(x+z);     //ÁеØÖ·
  126.    Lcd_WriteData(Temp>>8);//ÏÈдÈë¸ß8룬ÔÙдÈëµÍ8λ
  127.    Lcd_WriteData(Temp&0x00ff);
  128.         Lcd_WriteCmd(0x30);
  129.         //EA=1;
  130. }
  131. /*****************************************
  132. Çå³ýLcdÈ«ÆÁ£¬Èç¹ûÇå³ýģʽModeΪ0£¬ÔòΪȫÆÁÇå³ýΪÑÕÉ«0£¨ÎÞÈκÎÏÔʾ£©
  133. ·ñÔòΪȫÆÁÇå³ýΪÑÕÉ«1(È«ÆÁÌî³äÏÔʾ)
  134. ******************************************/
  135. void Lcd_Clear(unsigned char Mode)
  136. {
  137.         unsigned char x,y,ii;
  138.         unsigned char Temp;
  139.         if(Mode%2==0)
  140.                 Temp=0x00;
  141.         else
  142.                 Temp=0xff;
  143.         Lcd_WriteCmd(0x36);//À©³äÖ¸Áî »æÍ¼ÏÔʾ
  144.         for(ii=0;ii<9;ii+=8)   
  145.                 for(y=0;y<0x20;y++)     
  146.                         for(x=0;x<8;x++)
  147.                         {        
  148.                                 //EA=0;
  149.                                 Lcd_WriteCmd(y+0x80);        //ÐеØÖ·
  150.                                 Lcd_WriteCmd(x+0x80+ii);     //ÁеØÖ·     
  151.                                 Lcd_WriteData(Temp); //дÊý¾Ý D15£­D8
  152.                                 Lcd_WriteData(Temp); //дÊý¾Ý D7£­D0
  153.                                 //EA=1;
  154.                         }
  155.         Lcd_WriteCmd(0x30);
  156. }
  157. /****************************************
  158. LCD³õʼ»¯
  159. *****************************************/
  160. void Lcd_Reset()
  161. {  
  162.         PSB=1;
  163.         Lcd_WriteCmd(0x30);       //Ñ¡Ôñ»ù±¾Ö¸Á
  164.         Lcd_WriteCmd(0x0c);       //¿ªÏÔʾ(ÎÞÓαꡢ²»·´°×)
  165.         Lcd_WriteCmd(0x01);       //Çå³ýÏÔʾ£¬²¢ÇÒÉ趨µØÖ·Ö¸ÕëΪ00H
  166.         Lcd_WriteCmd(0x06);       //Ö¸¶¨ÔÚ×ÊÁϵĶÁÈ¡¼°Ð´Èëʱ£¬É趨ÓαêµÄÒÆ¶¯·½Ïò¼°Ö¸¶¨ÏÔʾµÄÒÆÎ»
  167. }
  168. //////////////////////////////////////
  169. void InitADC()
  170. {
  171. P1ASF=0X80;
  172. ADC_RES=0;
  173. ADC_CONTR=0xef;
  174. EADC=1;
  175. }
  176. void adc_isr() interrupt 5 using 1
  177. {
  178. ADC_CONTR=0xef;
  179. if(over==0)
  180. {
  181.         temp=delnop;
  182.         while(temp)
  183.         {
  184.         temp--;
  185.         }
  186.         dat[dati]=ADC_RES;
  187.         dati++;
  188.         if(dati>101)
  189.         {
  190.         dati=0;
  191.         over=1;
  192.         }
  193. }
  194. }
  195. //////////////////////////////////////
  196. void disp_0(unsigned char x,unsigned char y)
  197. {
  198. Lcd_PutPixel(x+0,y+1,1);
  199. Lcd_PutPixel(x+0,y+2,1);
  200. Lcd_PutPixel(x+0,y+3,1);
  201. Lcd_PutPixel(x+1,y+0,1);
  202. Lcd_PutPixel(x+1,y+4,1);
  203. Lcd_PutPixel(x+2,y+1,1);
  204. Lcd_PutPixel(x+2,y+2,1);
  205. Lcd_PutPixel(x+2,y+3,1);
  206. }
  207. void disp_1(unsigned char x,unsigned char y)
  208. {
  209. Lcd_PutPixel(x+0,y+1,1);
  210. Lcd_PutPixel(x+0,y+4,1);
  211. Lcd_PutPixel(x+1,y+0,1);
  212. Lcd_PutPixel(x+1,y+1,1);
  213. Lcd_PutPixel(x+1,y+2,1);
  214. Lcd_PutPixel(x+1,y+3,1);
  215. Lcd_PutPixel(x+1,y+4,1);
  216. Lcd_PutPixel(x+2,y+4,1);
  217. }
  218. void disp_2(unsigned char x,unsigned char y)
  219. {
  220. Lcd_PutPixel(x+0,y+0,1);
  221. Lcd_PutPixel(x+0,y+2,1);
  222. Lcd_PutPixel(x+0,y+3,1);
  223. Lcd_PutPixel(x+0,y+4,1);
  224. Lcd_PutPixel(x+1,y+0,1);
  225. Lcd_PutPixel(x+1,y+2,1);
  226. Lcd_PutPixel(x+1,y+4,1);
  227. Lcd_PutPixel(x+2,y+0,1);
  228. Lcd_PutPixel(x+2,y+1,1);
  229. Lcd_PutPixel(x+2,y+2,1);
  230. Lcd_PutPixel(x+2,y+4,1);
  231. }
  232. void disp_4(unsigned char x,unsigned char y)
  233. {
  234. Lcd_PutPixel(x+0,y+0,1);
  235. Lcd_PutPixel(x+0,y+1,1);
  236. Lcd_PutPixel(x+0,y+2,1);
  237. Lcd_PutPixel(x+1,y+2,1);
  238. Lcd_PutPixel(x+2,y+0,1);
  239. Lcd_PutPixel(x+2,y+1,1);
  240. Lcd_PutPixel(x+2,y+2,1);
  241. Lcd_PutPixel(x+2,y+3,1);
  242. Lcd_PutPixel(x+2,y+4,1);
  243. }
  244. void disp_5(unsigned char x,unsigned char y)
  245. {
  246. Lcd_PutPixel(x+0,y+0,1);
  247. Lcd_PutPixel(x+0,y+1,1);
  248. Lcd_PutPixel(x+0,y+2,1);
  249. Lcd_PutPixel(x+0,y+4,1);
  250. Lcd_PutPixel(x+1,y+0,1);
  251. Lcd_PutPixel(x+1,y+2,1);
  252. Lcd_PutPixel(x+1,y+4,1);
  253. Lcd_PutPixel(x+2,y+0,1);
  254. Lcd_PutPixel(x+2,y+2,1);
  255. Lcd_PutPixel(x+2,y+3,1);
  256. Lcd_PutPixel(x+2,y+4,1);
  257. }
  258. disp_dian(unsigned char x,unsigned char y)
  259. {
  260. Lcd_PutPixel(x+0,y+4,1);
  261. }
  262. disp_k(unsigned char x,unsigned char y)
  263. {
  264. Lcd_PutPixel(x+0,y+0,1);
  265. Lcd_PutPixel(x+0,y+1,1);
  266. Lcd_PutPixel(x+0,y+2,1);
  267. Lcd_PutPixel(x+0,y+3,1);
  268. Lcd_PutPixel(x+0,y+4,1);
  269. Lcd_PutPixel(x+1,y+2,1);
  270. Lcd_PutPixel(x+2,y+1,1);
  271. Lcd_PutPixel(x+2,y+3,1);
  272. Lcd_PutPixel(x+3,y+0,1);
  273. Lcd_PutPixel(x+3,y+4,1);
  274. }
  275. void disp_hz(unsigned char x,unsigned char y)
  276. {
  277. Lcd_PutPixel(x+0,y+0,1);
  278. Lcd_PutPixel(x+0,y+1,1);
  279. Lcd_PutPixel(x+0,y+2,1);
  280. Lcd_PutPixel(x+0,y+3,1);
  281. Lcd_PutPixel(x+0,y+4,1);
  282. Lcd_PutPixel(x+1,y+2,1);
  283. Lcd_PutPixel(x+2,y+2,1);
  284. Lcd_PutPixel(x+3,y+0,1);
  285. Lcd_PutPixel(x+3,y+1,1);
  286. Lcd_PutPixel(x+3,y+2,1);
  287. Lcd_PutPixel(x+3,y+3,1);
  288. Lcd_PutPixel(x+3,y+4,1);
  289. Lcd_PutPixel(x+5,y+1,1);
  290. Lcd_PutPixel(x+5,y+3,1);
  291. Lcd_PutPixel(x+5,y+4,1);
  292. Lcd_PutPixel(x+6,y+1,1);
  293. Lcd_PutPixel(x+6,y+2,1);
  294. Lcd_PutPixel(x+6,y+4,1);
  295. }
  296. void disp_vd(unsigned char x,unsigned char y)
  297. {
  298. Lcd_PutPixel(x+0,y+0,1);
  299. Lcd_PutPixel(x+0,y+1,1);
  300. Lcd_PutPixel(x+1,y+2,1);
  301. Lcd_PutPixel(x+1,y+3,1);
  302. Lcd_PutPixel(x+2,y+4,1);
  303. Lcd_PutPixel(x+3,y+2,1);
  304. Lcd_PutPixel(x+3,y+3,1);
  305. Lcd_PutPixel(x+4,y+0,1);
  306. Lcd_PutPixel(x+4,y+1,1);
  307. Lcd_PutPixel(x+5,y+3,1);
  308. Lcd_PutPixel(x+5,y+4,1);
  309. Lcd_PutPixel(x+6,y+2,1);
  310. Lcd_PutPixel(x+7,y+0,1);
  311. Lcd_PutPixel(x+7,y+1,1);
  312. Lcd_PutPixel(x+8,y+2,1);
  313. Lcd_PutPixel(x+8,y+3,1);
  314. Lcd_PutPixel(x+8,y+4,1);
  315. Lcd_PutPixel(x+9,y+2,1);
  316. Lcd_PutPixel(x+9,y+4,1);
  317. Lcd_PutPixel(x+10,y+0,1);
  318. Lcd_PutPixel(x+10,y+1,1);
  319. Lcd_PutPixel(x+10,y+2,1);
  320. Lcd_PutPixel(x+10,y+3,1);
  321. Lcd_PutPixel(x+10,y+4,1);
  322. }
  323. void disp_ledon(unsigned char x,unsigned char y)
  324. {
  325. Lcd_PutPixel(x+0,y+0,1);
  326. Lcd_PutPixel(x+0,y+1,1);
  327. Lcd_PutPixel(x+0,y+2,1);
  328. Lcd_PutPixel(x+0,y+3,1);
  329. Lcd_PutPixel(x+0,y+4,1);
  330. Lcd_PutPixel(x+1,y+1,1);
  331. Lcd_PutPixel(x+1,y+2,1);
  332. Lcd_PutPixel(x+1,y+3,1);
  333. Lcd_PutPixel(x+2,y+0,1);
  334. Lcd_PutPixel(x+2,y+4,1);
  335. Lcd_PutPixel(x+3,y+2,1);
  336. }
  337. void disp_ledoff(unsigned char x,unsigned char y)
  338. {
  339. Lcd_PutPixel(x+0,y+0,1);
  340. Lcd_PutPixel(x+0,y+1,1);
  341. Lcd_PutPixel(x+0,y+2,1);
  342. Lcd_PutPixel(x+0,y+3,1);
  343. Lcd_PutPixel(x+0,y+4,1);
  344. Lcd_PutPixel(x+1,y+1,1);
  345. Lcd_PutPixel(x+1,y+2,1);
  346. Lcd_PutPixel(x+1,y+3,1);
  347. }
  348. void clr(unsigned char starx,unsigned char stary,unsigned char endx,unsigned char endy)
  349. {
  350. char x=0;
  351. char y=0;
  352. for(x=starx;x<endx;x++)
  353. {
  354.         for(y=stary;y<endy;y++)
  355.         {
  356.                 Lcd_PutPixel(x,y,0);
  357.         }
  358. }
  359. }
  360. void disp_bj(void)
  361. {
  362. unsigned char x=0;
  363. unsigned char y=0;
  364. for(y=0;y<63;y=y+2)
  365. {
  366. Lcd_PutPixel(51,y,1);
  367. }
  368. for(y=0;y<63;y=y+2)
  369. {
  370. Lcd_PutPixel(77,y,1);
  371. }
  372. for(y=0;y<63;y=y+2)
  373. {
  374. Lcd_PutPixel(101,y,1);
  375. }
  376. for(x=27;x<127;x=x+2)
  377. {
  378. Lcd_PutPixel(x,0,1);
  379. }
  380. for(x=27;x<127;x=x+2)
  381. {
  382. Lcd_PutPixel(x,15,1);
  383. }
  384. for(x=27;x<127;x=x+2)
  385. {
  386. Lcd_PutPixel(x,31,1);
  387. }
  388. for(x=27;x<127;x=x+2)
  389. {
  390. Lcd_PutPixel(x,47,1);
  391. }
  392. for(x=27;x<127;x=x+2)
  393. {
  394. Lcd_PutPixel(x,63,1);
  395. }
  396. for(y=0;y<64;y++)
  397. {
  398. Lcd_PutPixel(26,y,1);
  399. Lcd_PutPixel(127,y,1);
  400. }
  401. }
  402. line(unsigned char x0,unsigned char y0,unsigned char x1,unsigned char y1,unsigned char color)
  403. {
  404. int i,dx,dy,e,x,y;
  405. Lcd_PutPixel(x0,y0,color);
  406. Lcd_PutPixel(x1,y1,color);
  407. dx=x1-x0;
  408. dy=y1-y0;
  409. x=x0;
  410. y=y0;
  411. if(dx>0&&dy>0)
  412. {
  413. if(dx>dy)
  414. {
  415. e=-dx;
  416. for(i=0;i<dx;i++)
  417.         {
  418.         Lcd_PutPixel(x,y,color);
  419.         x++;
  420.         e=e+2*dy;
  421.         if(e>=0)
  422.                 {
  423.                 y++;
  424.                 e=e-2*dx;
  425.                 }
  426.         }
  427. }
  428. else
  429. {
  430. e=-dy;
  431. x=x0;
  432. y=y0;
  433. for(i=0;i<dy;i++)
  434.         {
  435.         Lcd_PutPixel(x,y,color);
  436.         y++;
  437.         e=e+2*dx;
  438.         if(e>=0)
  439.                 {
  440.                 x++;
  441.                 e=e-2*dy;
  442.                 }
  443.         }
  444. }
  445. }
  446. if(dx<0&&dy<0)
  447. {
  448. dx=x0-x1;
  449. dy=y0-y1;
  450. if(dx>dy)
  451. {
  452. e=-dx;
  453. for(i=0;i<dx;i++)
  454.         {
  455.         Lcd_PutPixel(x,y,color);
  456.         x--;
  457.         e=e+2*dy;
  458.         if(e>=0)
  459.                 {
  460.                 y--;
  461.                 e=e-2*dx;
  462.                 }
  463.         }
  464. }
  465. else
  466. {
  467. e=-dy;
  468. for(i=0;i<dy;i++)
  469.         {
  470.         Lcd_PutPixel(x,y,color);
  471.         y--;
  472.         e=e+2*dx;
  473.         if(e>=0)
  474.                 {
  475.                 x--;
  476.                 e=e-2*dy;
  477.                 }
  478.         }
  479. }
  480. }
  481. if(dx>0&&dy<0)
  482. {
  483. dy=y0-y1;
  484. if(dx>dy)
  485. {
  486. e=-dx;
  487. for(i=0;i<dx;i++)
  488.         {
  489.         Lcd_PutPixel(x,y,color);
  490.         x++;
  491.         e=e+2*dy;
  492.         if(e>=0)
  493.                 {
  494.                 y--;
  495.                 e=e-2*dx;
  496.                 }
  497.         }
  498. }
  499. else
  500. {
  501. e=-dy;
  502. for(i=0;i<dy;i++)
  503.         {
  504.         Lcd_PutPixel(x,y,color);
  505.         y--;
  506.         e=e+2*dx;
  507.         if(e>=0)
  508.                 {
  509.                 x++;
  510.                 e=e-2*dy;
  511.                 }
  512.         }
  513. }
  514. }
  515. if(dx<0&&dy>0)
  516. {
  517. dx=x0-x1;
  518. if(dx>dy)
  519. {
  520. e=-dx;
  521. for(i=0;i<dx;i++)
  522.         {
  523.         Lcd_PutPixel(x,y,color);
  524.         x--;
  525.         e=e+2*dy;
  526.         if(e>=0)
  527.                 {
  528.                 y++;
  529.                 e=e-2*dx;
  530.                 }
  531.         }
  532. }
  533. else
  534. {
  535. e=-dy;
  536. for(i=0;i<dy;i++)
  537.         {
  538.         Lcd_PutPixel(x,y,color);
  539.         y++;
  540.         e=e+2*dx;
  541.         if(e>=0)
  542.                 {
  543.                 x--;
  544.                 e=e-2*dy;
  545.                 }
  546.         }
  547. }
  548. }
  549. if(dx!=0&&dy==0)
  550. {
  551. if(dx>0)
  552. {
  553. for(i=0;i<dx;i++)
  554.         {
  555.         Lcd_PutPixel(x,y,color);
  556.         x++;
  557.         }
  558. }
  559. else
  560. {
  561. dx=x0-x1;
  562. for(i=0;i<dx;i++)
  563.         {
  564.         Lcd_PutPixel(x,y,color);
  565.         x--;
  566.         }
  567. }
  568. }
  569. if(dx==0&&dy!=0)
  570. {
  571. if(dy>0)
  572. {
  573. for(i=0;i<dy;i++)
  574.         {
  575.         Lcd_PutPixel(x,y,color);
  576.         y++;
  577.         }
  578. }
  579. else
  580. {
  581. dy=y0-y1;
  582. for(i=0;i<dy;i++)
  583.         {
  584.         Lcd_PutPixel(x,y,color);
  585.         y--;
  586.         }
  587. }
  588. }
  589. }
  590. disp_ware()
  591. {
  592. unsigned char x;
  593. for(x=0;x<100;x++)
  594. {
  595. line(x+27,(dat0[x]/vd)-cha,x+1+27,(dat0[x+1]/vd)-cha,0);
  596. line(x+27,(dat[x]/vd)-cha,x+1+27,(dat[x+1]/vd)-cha,1);
  597. dat0[x]=dat[x];
  598. }
  599. dat0[101]=dat[101];
  600. disp_bj();
  601. }
  602. disp_ware50()
  603. {
  604. unsigned char x;
  605. for(x=0;x<50;x++)
  606. {
  607. line(x*2+27,(dat0[x]/vd)-cha,(x+1)*2+27,(dat0[x+1]/vd)-cha,0);
  608. line(x*2+27,(dat[x]/vd)-cha,(x+1)*2+27,(dat[x+1]/vd)-cha,1);
  609. dat0[x]=dat[x];
  610. }
  611. disp_bj();
  612. }
  613. //////////////////////////////////////
  614. main()
  615. {
  616. Lcd_Reset();
  617. Lcd_Clear(0);
  618. InitADC();

  619. disp_4(0,10);
  620. disp_k(4,10);
  621. disp_hz(9,10);

  622. disp_1(0,30);
  623. disp_vd(4,30);

  624. disp_ledon(0,50);

  625. EA=1;
  626. while(1)
  627. {
  628. if(over)
  629.         {
  630.                 if(mode==0)
  631.                 {
  632.                 disp_ware50();
  633.                 }
  634.                 else
  635.                 {
  636.                 disp_ware();
  637.                 }
  638.                 if(ledkey==0)
  639.                 {
  640.                 led=~led;
  641.                 if(led)
  642.                 {
  643.                         clr(0,50,5,55);
  644.                         disp_ledon(0,50);
  645.                 }
  646.                 else
  647.                 {
  648.                         clr(0,50,5,55);
  649.                         disp_ledoff(0,50);
  650.                 }
  651.                 }
  652.                 if(fkey==0)
  653.                 {
  654.                 if(mode<4)
  655.                         {
  656.                         mode++;
  657.                         }
  658.                 else
  659.                         {
  660.                         mode=0;
  661.                         }
  662.                 switch(mode)
  663.                         {
  664.                 case 0://4khz
  665.                         delnop=1;
  666.                         Lcd_Clear(0);
  667.                         disp_bj();
  668.                         clr(0,10,20,15);
  669.                         disp_4(0,10);
  670.                         disp_k(4,10);
  671.                         disp_hz(9,10);
  672.                         break;
  673.                 case 1://2khz
  674.                         delnop=1;
  675.                         clr(0,10,20,15);
  676.                         disp_2(0,10);
  677.                         disp_k(4,10);
  678.                         disp_hz(9,10);
  679.                         break;
  680.                 case 2://200hz
  681.                         delnop=40;
  682.                         clr(0,10,20,15);
  683.                         disp_2(0,10);
  684.                         disp_0(4,10);
  685.                         disp_0(8,10);
  686.                         disp_hz(12,10);
  687.                         break;
  688.                 case 3://20hz
  689.                         delnop=440;
  690.                         clr(0,10,20,15);
  691.                         disp_2(0,10);
  692.                         disp_0(4,10);
  693.                         disp_hz(8,10);
  694.                         break;
  695.                 case 4://2hz
  696.                         delnop=4440;
  697.                         clr(0,10,20,15);
  698.                         disp_2(0,10);
  699.                         disp_hz(4,10);
  700.                         break;
  701.                 default:
  702.                         break;
  703.                 }
  704.                 }
  705.                 if(vkey==0)
  706.                 {
  707.                 if(vmode<2)
  708.                         {
  709.                         vmode++;
  710.                         }
  711.                 else
  712.                         {
  713.                         vmode=0;
  714.                         }
  715.                 switch(vmode)
  716.                         {
  717.                 case 0://1v/d
  718.                         vd=4;
  719.                         cha=0;
  720.                         clr(0,30,26,35);
  721.                         disp_1(0,30);
  722.                         disp_vd(4,30);
  723.                         break;
  724.                 case 1://0.5v/d
  725.                         vd=2;
  726.                         cha=32;
  727.                         clr(0,30,26,35);
  728.                         disp_0(0,30);
  729.                         disp_dian(4,30);
  730.                         disp_5(6,30);
  731.                         disp_vd(10,30);
  732.                         break;
  733.                 case 2://0.25v/d
  734.                         vd=1;
  735.                         cha=96;
  736.                         clr(0,30,26,35);
  737.                         disp_0(0,30);
  738.                         disp_dian(4,30);
  739.                         disp_2(6,30);
  740.                         disp_5(10,30);
  741.                         disp_vd(14,30);
  742.                         break;
  743.                 default:
  744.                         break;
  745.                 }
  746.                 }
  747.         over=0;
  748.         }
  749. }
  750. }

这个程序可以编译成功
line(unsigned char x0,unsigned char y0,unsigned char x1,unsigned char y1,unsigned char color)
  1. disp_ware()
  2. {
  3. unsigned char x;
  4. for(x=0;x<100;x++)
  5. {
  6. line(x+27,(dat0[x]/vd)-cha,x+1+27,(dat0[x+1]/vd)-cha,0);
  7. line(x+27,(dat[x]/vd)-cha,x+1+27,(dat[x+1]/vd)-cha,1);
  8. dat0[x]=dat[x];
  9. }
  10. dat0[101]=dat[101];
  11. disp_bj();
  12. }

 楼主| 渔夫的烟斗 发表于 2017-1-12 09:40 | 显示全部楼层
第405 line的函数定义。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

37

主题

185

帖子

2

粉丝
快速回复 在线客服 返回列表 返回顶部