找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 4174|回复: 1
打印 上一主题 下一主题
收起左侧

微芯VLS5573显示屏应用测试源程序

[复制链接]
跳转到指定楼层
楼主
ID:152503 发表于 2016-12-6 11:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
名称: 微芯VLS5573显示屏驱动测试
说明: 本例运行时,按下K1按键可分别在VLS5573LCD屏上完成模数转换,温度显示,  时钟运行三种演示效果.在演示时钟运行时,K2,K3按键可用于时钟调节.

下载:
微芯VLS5573显示屏应用测试.zip (337.9 KB, 下载次数: 18)

主程序:
  1. #include <xc.h>
  2. #include "LCD_8490.h"
  3. #include <delays.h>
  4. #define INT8U  unsigned char
  5. #define INT16U unsigned int
  6. #pragma config OSC   = INTIO67
  7. #pragma config FCMEN = OFF
  8. #pragma config IESO  = OFF
  9. #pragma config PWRT  = OFF
  10. #pragma config BOREN = OFF
  11. #pragma config WDT   = OFF
  12. #pragma config DEBUG = ON
  13. #pragma config XINST = OFF
  14. //-----------------------------------------------------------------
  15. // 本例相关函数声明
  16. //-----------------------------------------------------------------
  17. void LCD_CONFIG(void);
  18. void DisplayOn(void);
  19. void DisplayOff(void);
  20. void BarGraph(INT8U);
  21. void CirGraph(INT8U);
  22. void S1Num(INT8U);
  23. void S2Num(INT8U);
  24. void S3Num(INT8U);
  25. void S4Num(INT8U);
  26. void S5Num(INT8U);
  27. void S6Num(INT8U);
  28. void S7Num(INT8U);
  29. void S8Num(INT8U);
  30. void Voltmeter(void);
  31. void Volt_Display(INT8U dat);
  32. void BatteryIndic(INT8U i);
  33. void Thermometer(void);
  34. void Temp_Display_C(INT16U dat);
  35. void Temp_Display_F(INT16U dat);
  36. void TempIndic(INT8U i);
  37. void RTC_Display(void);
  38. //-----------------------------------------------------------------
  39. // 相关符号等定义
  40. //-----------------------------------------------------------------
  41. //10以上的十六进制数位定义(A-F)及本例其他所用字符定义(H,L,P)
  42. #define A  10
  43. #define B  11
  44. #define C  12
  45. #define D  13
  46. #define E  14
  47. #define F  15
  48. #define H  17
  49. #define L  21
  50. #define P  25
  51. //无显示
  52. #define NoDisp     0xFF               
  53. #define K1         PORTBbits.RB5   //模式选择键(F1~F3)
  54. #define K2         PORTBbits.RB6   //按键K2调节HR
  55. #define K3         PORTBbits.RB7   //按键K3调节MIN
  56. //-----------------------------------------------------------------
  57. // 变量声明
  58. //-----------------------------------------------------------------
  59. INT16U an0_voltage, an1_voltage, Reading;//AN0,AN1两路模拟电压
  60. INT8U BGCNT;                    //条形图条数
  61. volatile INT8U DemoCode = 0;    //演示功能代号
  62. volatile INT8U SEC, MIN, HR;    //秒,分,时
  63. //-----------------------------------------------------------------
  64. // 主程序
  65. //-----------------------------------------------------------------
  66. void main()
  67. {
  68.     OSCCON  = 0B01000000;      //1MHZ
  69.     OSCTUNE = 0B01100000;
  70.     BGCNT = 0;                 //条形图当前显示的竖条数(bar graph count)
  71.     LCD_CONFIG();              //配置LCD模块使用内部升压电路
  72.     ADCON1 = 0x0D;            //RA0-RA2设为模拟输入
  73.     TRISBbits.TRISB5 = 1;      //K1按键输入
  74.     TRISBbits.TRISB6 = 1;      //K2按键输入
  75.     TRISBbits.TRISB7 = 1;      //K3按键输入
  76.     DisplayOn();               //全屏开演示
  77.     Delay10KTCYx(10);          //延时
  78.     DisplayOff();              //全屏关演示
  79.     MCHPON;                    //显示微芯标志
  80.     S1Num(H);S2Num(E);S3Num(L);//显示"HELLO"(字母O用数字0代替)
  81.     S4Num(L);S5Num(0);
  82.     //外部中断控制
  83.     INTCONbits.RBIE = 1;       //使PB端口中断
  84.     INTCONbits.PEIE = 1;       //使能所有未屏蔽的外部中断
  85.     INTCONbits.GIE  = 1;       //开全局中断
  86.     Sleep();                   //低功耗模式
  87.     DisplayOff();              //显示屏关闭
  88.     //定时器TMR1初始化
  89.     TMR1H = 0x80;               //TMR1L默认为0x00,0x8000=32768,定时1s
  90.     T1CONbits.T1RUN = 1;      //时钟取自TIMER1振荡器(内部:32768)
  91.     T1CONbits.T1CKPS1 = 0;    //T1CKPS1:0=00,1:1预分频
  92.     T1CONbits.T1CKPS0 = 0;
  93.     T1CONbits.T1OSCEN = 1;    //使能TIMER1振荡器
  94.     T1CONbits.T1SYNC = 1;     //不同步外部时钟输入
  95.     T1CONbits.TMR1CS = 1;     //选择32KHz时钟
  96.     T1CONbits.TMR1ON = 1;     //使能TIMER1
  97.     PIE1bits.TMR1IE = 0;      //暂时禁止TIMER1中断
  98.     while(1)
  99.     {   //F1按键演示-----------------------------------------------
  100.         if (DemoCode == 1)
  101.         {   F1ON;                     //显示F1
  102.             TRISAbits.TRISA0 = 1;     //AN0设为输入
  103.             ADCON0bits.CHS3 = 0;      //0000:选择模拟通道AN0
  104.             ADCON0bits.CHS2 = 0;
  105.             ADCON0bits.CHS1 = 0;
  106.             ADCON0bits.CHS0 = 0;            
  107.             //转换结果左对齐,ACQT2:ACQT0:111,AD获取时钟选择位设置:20TAD
  108.             //ADCS2:ADCS0:111,时钟来自AD RC振荡器
  109.             ADCON2 = 0xBF;            //该行可展开为如下7行代码
  110.             //ADCON2bits.ADFM = 1;    //右对齐            
  111.             //ADCON2bits.ACQT2 = 1;   //AD获取时钟选择位设置:20TAD
  112.             //ADCON2bits.ACQT1 = 1;
  113.             //ADCON2bits.ACQT0 = 1;            
  114.             //ADCON2bits.ADCS2 = 1;   //AD时钟来自AD RC振荡器
  115.             //ADCON2bits.ADCS1 = 1;
  116.             //ADCON2bits.ADCS0 = 1;                  
  117.             ADCON0bits.ADON = 1;      //启动ADC            
  118.             while (DemoCode == 1)
  119.             {   PIR1bits.ADIF = 0; PIE1bits.ADIE = 1; ADCON0bits.GO_DONE = 1;
  120.                 Sleep();
  121.                 Reading = an0_voltage;
  122.                 Voltmeter();
  123.             }
  124.             ADCON0bits.ADON = 0;      //ADC关闭
  125.             DisplayOff();             //关闭所有显示
  126.         }
  127.         //F2按键演示-----------------------------------------------
  128.         else if (DemoCode == 2)
  129.         {   F2ON;                     //显示F2
  130.             TRISAbits.TRISA1 = 1;     //AN1设为输入
  131.             ADCON0bits.CHS3 = 0;      //0001:选择模拟通道AN1
  132.             ADCON0bits.CHS2 = 0;
  133.             ADCON0bits.CHS1 = 0;
  134.             ADCON0bits.CHS0 = 1;
  135.             ADCON2 = 0xBF;
  136.             ADCON0bits.ADON = 1;      //ADC启动
  137.             while (DemoCode == 2)
  138.             {   PIR1bits.ADIF = 0;  PIE1bits.ADIE = 1;  ADCON0bits.GO_DONE = 1;
  139.                 Sleep();  Reading = an1_voltage;
  140.                 Thermometer();        //温度计显示
  141.             }
  142.             ADCON0bits.ADON = 0;      //ADC关闭
  143.             DisplayOff();             //关闭所有显示
  144.         }
  145.         //F3按键演示-----------------------------------------------
  146.         else if (DemoCode == 3)
  147.         {   F3ON;                     //显示F3
  148.             PIE1bits.TMR1IE = 1;      //运行定时器
  149.             HR = MIN = SEC = 0;     //初始化时分秒
  150.             while (PIE1bits.TMR1IE);//定时中断未禁止则等待(定时中断持续触发)
  151.             DisplayOff();             //关闭所有显示
  152.         }
  153.     }
  154. }
  155. //-----------------------------------------------------------------
  156. // LCD配置寄存器设置
  157. //-----------------------------------------------------------------
  158. void LCD_CONFIG(void)
  159. {
  160.      LCDPSbits.WFT    = 0;   //波形类型选择位(0:A类,1:B类)
  161.      LCDPSbits.BIASMD = 0;  //偏压模式(本例LMUX1:0为11,BIASMD为0: 1/3偏压)
  162.      //选择帧时钟预分频0100->1:5
  163.      LCDPSbits.LP3 = 0;    LCDPSbits.LP2 = 1;
  164.      LCDPSbits.LP1 = 0;    LCDPSbits.LP0 = 0;
  165.      //设置LCDSEx寄存器,使相应的引脚(SEGx)作为数码管段驱动
  166.      LCDSE0 = 0xFF;     LCDSE1 = 0xFF;
  167.      LCDSE2 = 0xFF;     LCDSE3 = 0xFF;
  168.      LCDSE4 = 0xFF;     LCDSE5 = 0xFF;
  169.      //通过LCDCON寄存器配置LCD模块
  170.      //CS1:0为时钟源选择位,11表示:INTRC(31.25 kHz)/32
  171.      LCDCONbits.CS1   = 1;  LCDCONbits.CS0   = 1;
  172.      //LMUX1:0设为11,将PORTE4-PORTE6设为COM1-COM3,占空比:1/4
  173.      LCDCONbits.LMUX1 = 1;  LCDCONbits.LMUX0 = 1;
  174.      LCDCONbits.LCDEN = 1;  //使能LCD模块
  175. }
  176. //-----------------------------------------------------------------
  177. // 中断例程
  178. //-----------------------------------------------------------------
  179. void interrupt InterruptHandlerHigh()
  180. {
  181.     //定时器TMR1溢出中断
  182.     if (PIR1bits.TMR1IF == 1)
  183.     {   //处理秒,分,时递增及进位操作
  184.         if (++SEC > 59)
  185.         {  SEC = 0; if (++MIN > 59) { MIN = 0; if (++HR  > 23 ) HR = 0; } }
  186.         if (DemoCode == 3) RTC_Display(); else PIE1bits.TMR1IE = 0;
  187.         TMR1H = 0x80; TMR1L = 0x00;
  188.         PIR1bits.TMR1IF = 0;
  189.     }
  190.     //模数转换中断
  191.     if (PIR1bits.ADIF == 1)
  192.     {   PIR1bits.ADIF = 0;
  193.         if (DemoCode == 1) { an0_voltage =((INT16U)(ADRESH) << 8) + ADRESL;}
  194.         if (DemoCode == 2) { an1_voltage =((INT16U)(ADRESH) << 8) + ADRESL;}
  195.     }  
  196.     //INT中断(按键K1/K2/K3触发)
  197.     if (INTCONbits.RBIF == 1)
  198.     {   //K1控制演示功能号在1~3之间循环
  199.         if (K1 == 0) { while (K1 == 0); if (++DemoCode > 3 ) DemoCode  = 1; }
  200.         //K2,K3调节时/分
  201.         if (K2 == 0) { if (HR  < 23) HR++; }
  202.         if (K3 == 0) { if (MIN < 59) MIN++; }
  203.         INTCONbits.RBIF = 0;
  204.     }
  205. }
  206. //-----------------------------------------------------------------
  207. // 温度计程序
  208. //-----------------------------------------------------------------
  209. void Thermometer(void)
  210. {
  211.     Temp_Display_C(2 *(Reading - 392));  //摄氏温度显示
  212.     Temp_Display_F(36 *(Reading - 303)); //华氏温度显示
  213. }
  214. //-----------------------------------------------------------------
  215. // 摄氏温度显示
  216. // (显示在下行数字6,7,8位,加小数点,开摄氏度标志,并显示温度指示器)
  217. //-----------------------------------------------------------------
  218. void Temp_Display_C(INT16U dat)
  219. {
  220.     S6Num(dat / 100); S7Num(dat / 10 % 10); S8Num(dat % 10);
  221.     DP2ON; X25ON;
  222.     TempIndic(dat / 100);
  223. }
  224. //-----------------------------------------------------------------
  225. // 华氏温度显示(显示在上行数字2,3,4,5位,加小数点,开华氏度标志)
  226. //-----------------------------------------------------------------
  227. void Temp_Display_F(INT16U dat)
  228. {
  229.     S2Num(dat / 1000); S3Num(dat / 100 % 10); S4Num(dat % 100 / 10);
  230.     S5Num(dat % 10);
  231.     DP1ON; X26ON;
  232. }
  233. //-----------------------------------------------------------------
  234. // 电压表显示
  235. //-----------------------------------------------------------------
  236. void Voltmeter(void)
  237. {
  238.     //电压值显示0.0V~5.0V (VR调到顶端时本例为1022,此处用+1调整误差)
  239.     Volt_Display( (an0_voltage + 1) * 50 / 1023);
  240.     //刷新条形图显示(0-20条)
  241.     BarGraph( (an0_voltage + 1) * 20 / 1023);
  242.     //电量指示器显示(3段电量指示)
  243.     BatteryIndic((an0_voltage + 1) * 3 / 1023);
  244. }
  245. //-----------------------------------------------------------------
  246. // 电压值显示
  247. //-----------------------------------------------------------------
  248. void Volt_Display(INT8U d)
  249. {
  250.     //在上行第4,5两位显示电压,并加小数点
  251.     S4Num(d / 10); S5Num(d % 10); DP1ON;
  252. }
  253. //-----------------------------------------------------------------
  254. // 温度指示器指示
  255. //-----------------------------------------------------------------
  256. void TempIndic(INT8U i)
  257. {
  258.     S5ON; //固定显示温度指示器外框
  259.     //内部高度显示(3段,S6/S7/S8)
  260.     if (i >= 5)       { S6ON; S7ON; S8ON;}   //三段显示
  261.     else if (i >= 2) { S6OFF; S7ON; S8ON;}   //两段显示
  262.     else if (i >= 1) { S6OFF; S7OFF; S8ON;}  //一段显示
  263. }
  264. //-----------------------------------------------------------------
  265. // 电量指示器显示
  266. //-----------------------------------------------------------------
  267. void BatteryIndic(INT8U i)
  268. {
  269.     S9ON; //固定显示电量指示器外框
  270.     if (i >= 3) { S10ON;  S12ON; S11ON; }     //三段显示
  271.     if (i == 2) { S10OFF; S12ON; S11ON; }     //两段显示
  272.     if (i == 1) { S10OFF; S12OFF; S11ON;}     //一段显示
  273. }
  274. //-----------------------------------------------------------------
  275. // 实时时钟显示
  276. //-----------------------------------------------------------------
  277. void RTC_Display(void)
  278. {   
  279.     S1Num(HR / 10);   S2Num(HR % 10); COLON;//小时显示,后面加冒号显示
  280.     S3Num(MIN / 10);  S4Num(MIN % 10);//分钟显示
  281.     S6Num(SEC / 10);  S7Num(SEC % 10);//秒显示
  282.     CirGraph(SEC % 10);             //环形图显示(用于模拟秒循环)
  283. }
  284. //-----------------------------------------------------------------
  285. // 环形进程图显示
  286. //-----------------------------------------------------------------
  287. void CirGraph(INT8U Count)
  288. {
  289.     CGOFF; //先清除环形图显示
  290.     //根据Count值决定显示扇形范围,为0时仅显示环形的圆心点
  291.     switch(Count)
  292.     {   case 9: X28ON;  case 8: X29ON;  case 7: X30ON;
  293.         case 6: X31ON;  case 5: X32ON;  case 4: X33ON;
  294.         case 3: X34ON;  case 2: X35ON;  case 1: X36ON;
  295.         case 0: X27ON;
  296.     }
  297. }
  298. //-----------------------------------------------------------------
  299. // 数位1显示
  300. //-----------------------------------------------------------------
  301. void S1Num(INT8U d)
  302. {
  303.     switch(d)
  304.     {   case 0: S1AON; S1BON; S1CON; S1DON; S1EON; S1FON; S1GOFF;break;
  305.         case 1: S1AOFF;S1BON; S1CON; S1DOFF;S1EOFF;S1FOFF;S1GOFF;break;
  306.         case 2: S1AON; S1BON; S1COFF;S1DON; S1EON; S1FOFF;S1GON; break;
  307.         case 3: S1AON; S1BON; S1CON; S1DON; S1EOFF;S1FOFF;S1GON; break;
  308.         case 4: S1AOFF;S1BON; S1CON; S1DOFF;S1EOFF;S1FON; S1GON; break;
  309.         case 5: S1AON; S1BOFF;S1CON; S1DON; S1EOFF;S1FON; S1GON; break;
  310.         case 6: S1AON; S1BOFF;S1CON; S1DON; S1EON; S1FON; S1GON; break;
  311.         case 7: S1AON; S1BON; S1CON; S1DOFF;S1EOFF;S1FOFF;S1GOFF;break;
  312.         case 8: S1AON; S1BON; S1CON; S1DON; S1EON; S1FON; S1GON; break;
  313.         case 9: S1AON; S1BON; S1CON; S1DON; S1EOFF;S1FON; S1GON; break;
  314.         case A: S1AON; S1BON; S1CON; S1DOFF;S1EON; S1FON; S1GON; break;
  315.         case B: S1AOFF;S1BOFF;S1CON; S1DON; S1EON; S1FON; S1GON; break;   
  316.         case C: S1AON; S1BOFF;S1COFF;S1DON; S1EON; S1FON; S1GOFF;break;
  317.         case D: S1AOFF;S1BON; S1CON; S1DON; S1EON; S1FOFF;S1GON; break;  
  318.         case E: S1AON; S1BOFF;S1COFF;S1DON; S1EON; S1FON; S1GON; break;
  319.         case F: S1AON; S1BOFF;S1COFF;S1DOFF;S1EON; S1FON; S1GON; break;
  320.         case H: S1AOFF;S1BON; S1CON; S1DOFF;S1EON; S1FON; S1GON; break;
  321.         case L: S1AOFF;S1BOFF;S1COFF;S1DON; S1EON; S1FON; S1GOFF;break;
  322.         case P: S1AON; S1BON; S1COFF;S1DOFF;S1EON; S1FON; S1GON; break;
  323.         case NoDisp: S1NumOFF;
  324.     }
  325. }
  326. //-----------------------------------------------------------------
  327. // 数位2显示
  328. //-----------------------------------------------------------------
  329. void S2Num(INT8U d)
  330. {
  331.     switch(d)
  332.     {
  333.         case 0: S2AON; S2BON; S2CON; S2DON; S2EON; S2FON; S2GOFF;break;
  334.         case 1: S2AOFF;S2BON; S2CON; S2DOFF;S2EOFF;S2FOFF;S2GOFF;break;
  335.         case 2: S2AON; S2BON; S2COFF;S2DON; S2EON; S2FOFF;S2GON; break;
  336.         case 3: S2AON; S2BON; S2CON; S2DON; S2EOFF;S2FOFF;S2GON; break;
  337.         case 4: S2AOFF;S2BON; S2CON; S2DOFF;S2EOFF;S2FON; S2GON; break;
  338.         case 5: S2AON; S2BOFF;S2CON; S2DON; S2EOFF;S2FON; S2GON; break;
  339.         case 6: S2AON; S2BOFF;S2CON; S2DON; S2EON; S2FON; S2GON; break;
  340.         case 7: S2AON; S2BON; S2CON; S2DOFF;S2EOFF;S2FOFF;S2GOFF;break;
  341.         case 8: S2AON; S2BON; S2CON; S2DON; S2EON; S2FON; S2GON; break;
  342.         case 9: S2AON; S2BON; S2CON; S2DON; S2EOFF;S2FON; S2GON; break;
  343.         case A: S2AON; S2BON; S2CON; S2DOFF;S2EON; S2FON; S2GON; break;
  344.         case B: S2AOFF;S2BOFF;S2CON; S2DON; S2EON; S2FON; S2GON; break;  
  345.         case C: S2AON; S2BOFF;S2COFF;S2DON; S2EON; S2FON; S2GOFF;break;
  346.         case D: S2AOFF;S2BON; S2CON; S2DON; S2EON; S2FOFF;S2GON; break;
  347.         case E: S2AON; S2BOFF;S2COFF;S2DON; S2EON; S2FON; S2GON; break;
  348.         case F: S2AON; S2BOFF;S2COFF;S2DOFF;S2EON; S2FON; S2GON; break;
  349.         case H: S2AOFF;S2BON; S2CON; S2DOFF;S2EON; S2FON; S2GON; break;
  350.         case L: S2AOFF;S2BOFF;S2COFF;S2DON; S2EON; S2FON; S2GOFF;break;
  351.         case P: S2AON; S2BON; S2COFF;S2DOFF;S2EON; S2FON; S2GON; break;
  352.         case NoDisp: S2NumOFF;
  353.     }
  354. }
  355. //-----------------------------------------------------------------
  356. // 数位3显示
  357. //-----------------------------------------------------------------
  358. void S3Num(INT8U d)
  359. {
  360.     switch(d)
  361.     {
  362.         case 0: S3AON; S3BON; S3CON; S3DON; S3EON; S3FON; S3GOFF;break;
  363.         case 1: S3AOFF;S3BON; S3CON; S3DOFF;S3EOFF;S3FOFF;S3GOFF;break;
  364.         case 2: S3AON; S3BON; S3COFF;S3DON; S3EON; S3FOFF;S3GON; break;
  365.         case 3: S3AON; S3BON; S3CON; S3DON; S3EOFF;S3FOFF;S3GON; break;
  366.         case 4: S3AOFF;S3BON; S3CON; S3DOFF;S3EOFF;S3FON; S3GON; break;
  367.         case 5: S3AON; S3BOFF;S3CON; S3DON; S3EOFF;S3FON; S3GON; break;
  368.         case 6: S3AON; S3BOFF;S3CON; S3DON; S3EON; S3FON; S3GON; break;
  369.         case 7: S3AON; S3BON; S3CON; S3DOFF;S3EOFF;S3FOFF;S3GOFF;break;
  370.         case 8: S3AON; S3BON; S3CON; S3DON; S3EON; S3FON; S3GON; break;
  371.         case 9: S3AON; S3BON; S3CON; S3DON; S3EOFF;S3FON; S3GON; break;
  372.         case A: S3AON; S3BON; S3CON; S3DOFF;S3EON; S3FON; S3GON; break;
  373.         case B: S3AOFF;S3BOFF;S3CON; S3DON; S3EON; S3FON; S3GON; break;  
  374.         case C: S3AON; S3BOFF;S3COFF;S3DON; S3EON; S3FON; S3GOFF;break;
  375.         case D: S3AOFF;S3BON; S3CON; S3DON; S3EON; S3FOFF;S3GON; break;  
  376.         case E: S3AON; S3BOFF;S3COFF;S3DON; S3EON; S3FON; S3GON; break;
  377.         case F: S3AON; S3BOFF;S3COFF;S3DOFF;S3EON; S3FON; S3GON; break;
  378.         case H: S3AOFF;S3BON; S3CON; S3DOFF;S3EON; S3FON; S3GON; break;
  379.         case L: S3AOFF;S3BOFF;S3COFF;S3DON; S3EON; S3FON; S3GOFF;break;
  380.         case P: S3AON; S3BON; S3COFF;S3DOFF;S3EON; S3FON; S3GON; break;
  381.         case NoDisp: S3NumOFF;
  382.     }
  383. }
  384. //-----------------------------------------------------------------
  385. // 数位4显示
  386. //-----------------------------------------------------------------
  387. void S4Num(INT8U d)
  388. {
  389.     switch(d)
  390.     {
  391.         case 0: S4AON; S4BON; S4CON; S4DON; S4EON; S4FON; S4GOFF;break;
  392.         case 1: S4AOFF;S4BON; S4CON; S4DOFF;S4EOFF;S4FOFF;S4GOFF;break;
  393.         case 2: S4AON; S4BON; S4COFF;S4DON; S4EON; S4FOFF;S4GON; break;
  394.         case 3: S4AON; S4BON; S4CON; S4DON; S4EOFF;S4FOFF;S4GON; break;
  395.         case 4: S4AOFF;S4BON; S4CON; S4DOFF;S4EOFF;S4FON; S4GON; break;
  396.         case 5: S4AON; S4BOFF;S4CON; S4DON; S4EOFF;S4FON; S4GON; break;
  397.         case 6: S4AON; S4BOFF;S4CON; S4DON; S4EON; S4FON; S4GON; break;
  398.         case 7: S4AON; S4BON; S4CON; S4DOFF;S4EOFF;S4FOFF;S4GOFF;break;
  399.         case 8: S4AON; S4BON; S4CON; S4DON; S4EON; S4FON; S4GON; break;
  400.         case 9: S4AON; S4BON; S4CON; S4DON; S4EOFF;S4FON; S4GON; break;
  401.         case A: S4AON; S4BON; S4CON; S4DOFF;S4EON; S4FON; S4GON; break;
  402.         case B: S4AOFF;S4BOFF;S4CON; S4DON; S4EON; S4FON; S4GON; break;   
  403.         case C: S4AON; S4BOFF;S4COFF;S4DON; S4EON; S4FON; S4GOFF;break;
  404.         case D: S4AOFF;S4BON; S4CON; S4DON; S4EON; S4FOFF;S4GON; break;  
  405.         case E: S4AON; S4BOFF;S4COFF;S4DON; S4EON; S4FON; S4GON; break;
  406.         case F: S4AON; S4BOFF;S4COFF;S4DOFF;S4EON; S4FON; S4GON; break;
  407.         case H: S4AOFF;S4BON; S4CON; S4DOFF;S4EON; S4FON; S4GON; break;
  408.         case L: S4AOFF;S4BOFF;S4COFF;S4DON; S4EON; S4FON; S4GOFF;break;
  409.         case P: S4AON; S4BON; S4COFF;S4DOFF;S4EON; S4FON; S4GON; break;
  410.         case NoDisp: S4NumOFF;
  411.     }
  412. }
  413. //-----------------------------------------------------------------
  414. // 数位5显示
  415. //-----------------------------------------------------------------
  416. void S5Num(INT8U d)
  417. {
  418.     switch(d)
  419.     {
  420.         case 0: S5AON; S5BON; S5CON; S5DON; S5EON; S5FON; S5GOFF;break;
  421.         case 1: S5AOFF;S5BON; S5CON; S5DOFF;S5EOFF;S5FOFF;S5GOFF;break;
  422.         case 2: S5AON; S5BON; S5COFF;S5DON; S5EON; S5FOFF;S5GON; break;
  423.         case 3: S5AON; S5BON; S5CON; S5DON; S5EOFF;S5FOFF;S5GON; break;
  424.         case 4: S5AOFF;S5BON; S5CON; S5DOFF;S5EOFF;S5FON; S5GON; break;
  425.         case 5: S5AON; S5BOFF;S5CON; S5DON; S5EOFF;S5FON; S5GON; break;
  426.         case 6: S5AON; S5BOFF;S5CON; S5DON; S5EON; S5FON; S5GON; break;
  427.         case 7: S5AON; S5BON; S5CON; S5DOFF;S5EOFF;S5FOFF;S5GOFF;break;
  428.         case 8: S5AON; S5BON; S5CON; S5DON; S5EON; S5FON; S5GON; break;
  429.         case 9: S5AON; S5BON; S5CON; S5DON; S5EOFF;S5FON; S5GON; break;
  430.         case A: S5AON; S5BON; S5CON; S5DOFF;S5EON; S5FON; S5GON; break;
  431.         case B: S5AOFF;S5BOFF;S5CON; S5DON; S5EON; S5FON; S5GON; break;
  432.         case C: S5AON; S5BOFF;S5COFF;S5DON; S5EON; S5FON; S5GOFF;break;
  433.         case D: S5AOFF;S5BON; S5CON; S5DON; S5EON; S5FOFF;S5GON; break;
  434.         case E: S5AON; S5BOFF;S5COFF;S5DON; S5EON; S5FON; S5GON; break;
  435.         case F: S5AON; S5BOFF;S5COFF;S5DOFF;S5EON; S5FON; S5GON; break;
  436.         case H: S5AOFF;S5BON; S5CON; S5DOFF;S5EON; S5FON; S5GON; break;
  437.         case L: S5AOFF;S5BOFF;S5COFF;S5DON; S5EON; S5FON; S5GOFF;break;
  438.         case P: S5AON; S5BON; S5COFF;S5DOFF;S5EON; S5FON; S5GON; break;
  439.         case NoDisp: S5NumOFF;
  440.     }
  441. }
  442. //-----------------------------------------------------------------
  443. // 数位6显示
  444. //-----------------------------------------------------------------
  445. void S6Num(INT8U d)
  446. {
  447.     switch(d)
  448.     {
  449.         case 0: S6AON; S6BON; S6CON; S6DON; S6EON; S6FON; S6GOFF;break;
  450.         case 1: S6AOFF;S6BON; S6CON; S6DOFF;S6EOFF;S6FOFF;S6GOFF;break;
  451.         case 2: S6AON; S6BON; S6COFF;S6DON; S6EON; S6FOFF;S6GON; break;
  452.         case 3: S6AON; S6BON; S6CON; S6DON; S6EOFF;S6FOFF;S6GON; break;
  453.         case 4: S6AOFF;S6BON; S6CON; S6DOFF;S6EOFF;S6FON; S6GON; break;
  454.         case 5: S6AON; S6BOFF;S6CON; S6DON; S6EOFF;S6FON; S6GON; break;
  455.         case 6: S6AON; S6BOFF;S6CON; S6DON; S6EON; S6FON; S6GON; break;
  456.         case 7: S6AON; S6BON; S6CON; S6DOFF;S6EOFF;S6FOFF;S6GOFF;break;
  457.         case 8: S6AON; S6BON; S6CON; S6DON; S6EON; S6FON; S6GON; break;
  458.         case 9: S6AON; S6BON; S6CON; S6DON; S6EOFF;S6FON; S6GON; break;
  459.         case A: S6AON; S6BON; S6CON; S6DOFF;S6EON; S6FON; S6GON; break;
  460.         case B: S6AOFF;S6BOFF;S6CON; S6DON; S6EON; S6FON; S6GON; break;
  461.         case C: S6AON; S6BOFF;S6COFF;S6DON; S6EON; S6FON; S6GOFF;break;
  462.         case D: S6AOFF;S6BON; S6CON; S6DON; S6EON; S6FOFF;S6GON; break;
  463.         case E: S6AON; S6BOFF;S6COFF;S6DON; S6EON; S6FON; S6GON; break;
  464.         case F: S6AON; S6BOFF;S6COFF;S6DOFF;S6EON; S6FON; S6GON; break;
  465.         case H: S6AOFF;S6BON; S6CON; S6DOFF;S6EON; S6FON; S6GON; break;
  466.         case L: S6AOFF;S6BOFF;S6COFF;S6DON; S6EON; S6FON; S6GOFF;break;
  467.         case P: S6AON; S6BON; S6COFF;S6DOFF;S6EON; S6FON; S6GON; break;
  468.         case NoDisp: S6NumOFF;
  469.     }
  470. }
  471. //-----------------------------------------------------------------
  472. // 数位7显示
  473. //-----------------------------------------------------------------
  474. void S7Num(INT8U d)
  475. {
  476.     switch(d)
  477.     {
  478.         case 0: S7AON; S7BON; S7CON; S7DON; S7EON; S7FON; S7GOFF;break;
  479.         case 1: S7AOFF;S7BON; S7CON; S7DOFF;S7EOFF;S7FOFF;S7GOFF;break;
  480.         case 2: S7AON; S7BON; S7COFF;S7DON; S7EON; S7FOFF;S7GON; break;
  481.         case 3: S7AON; S7BON; S7CON; S7DON; S7EOFF;S7FOFF;S7GON; break;
  482.         case 4: S7AOFF;S7BON; S7CON; S7DOFF;S7EOFF;S7FON; S7GON; break;
  483.         case 5: S7AON; S7BOFF;S7CON; S7DON; S7EOFF;S7FON; S7GON; break;
  484.         case 6: S7AON; S7BOFF;S7CON; S7DON; S7EON; S7FON; S7GON; break;
  485.         case 7: S7AON; S7BON; S7CON; S7DOFF;S7EOFF;S7FOFF;S7GOFF;break;
  486.         case 8: S7AON; S7BON; S7CON; S7DON; S7EON; S7FON; S7GON; break;
  487.         case 9: S7AON; S7BON; S7CON; S7DON; S7EOFF;S7FON; S7GON; break;
  488.         case A: S7AON; S7BON; S7CON; S7DOFF;S7EON; S7FON; S7GON; break;
  489.         case B: S7AOFF;S7BOFF;S7CON; S7DON; S7EON; S7FON; S7GON; break;
  490.         case C: S7AON; S7BOFF;S7COFF;S7DON; S7EON; S7FON; S7GOFF;break;
  491.         case D: S7AOFF;S7BON; S7CON; S7DON; S7EON; S7FOFF;S7GON; break;
  492.         case E: S7AON; S7BOFF;S7COFF;S7DON; S7EON; S7FON; S7GON; break;
  493.         case F: S7AON; S7BOFF;S7COFF;S7DOFF;S7EON; S7FON; S7GON; break;
  494.         case H: S7AOFF;S7BON; S7CON; S7DOFF;S7EON; S7FON; S7GON; break;
  495.         case L: S7AOFF;S7BOFF;S7COFF;S7DON; S7EON; S7FON; S7GOFF;break;
  496.         case P: S7AON; S7BON; S7COFF;S7DOFF;S7EON; S7FON; S7GON; break;
  497.         case NoDisp: S7NumOFF;
  498.     }
  499. }
  500. //-----------------------------------------------------------------
  501. // 数位8显示
  502. //-----------------------------------------------------------------
  503. void S8Num(INT8U d)
  504. {
  505.     switch(d)
  506.     {
  507.         case 0: S8AON; S8BON; S8CON; S8DON; S8EON; S8FON; S8GOFF;break;
  508.         case 1: S8AOFF;S8BON; S8CON; S8DOFF;S8EOFF;S8FOFF;S8GOFF;break;
  509.         case 2: S8AON; S8BON; S8COFF;S8DON; S8EON; S8FOFF;S8GON; break;
  510.         case 3: S8AON; S8BON; S8CON; S8DON; S8EOFF;S8FOFF;S8GON; break;
  511.         case 4: S8AOFF;S8BON; S8CON; S8DOFF;S8EOFF;S8FON; S8GON; break;
  512.         case 5: S8AON; S8BOFF;S8CON; S8DON; S8EOFF;S8FON; S8GON; break;
  513.         case 6: S8AON; S8BOFF;S8CON; S8DON; S8EON; S8FON; S8GON; break;
  514.         case 7: S8AON; S8BON; S8CON; S8DOFF;S8EOFF;S8FOFF;S8GOFF;break;
  515.         case 8: S8AON; S8BON; S8CON; S8DON; S8EON; S8FON; S8GON; break;
  516.         case 9: S8AON; S8BON; S8CON; S8DON; S8EOFF;S8FON; S8GON; break;
  517.         case A: S8AON; S8BON; S8CON; S8DOFF;S8EON; S8FON; S8GON; break;
  518.         case B: S8AOFF;S8BOFF;S8CON; S8DON; S8EON; S8FON; S8GON; break;
  519.         case C: S8AON; S8BOFF;S8COFF;S8DON; S8EON; S8FON; S8GOFF;break;
  520.         case D: S8AOFF;S8BON; S8CON; S8DON; S8EON; S8FOFF;S8GON; break;
  521.         case E: S8AON; S8BOFF;S8COFF;S8DON; S8EON; S8FON; S8GON; break;
  522.         case F: S8AON; S8BOFF;S8COFF;S8DOFF;S8EON; S8FON; S8GON; break;
  523.         case H: S8AOFF;S8BON; S8CON; S8DOFF;S8EON; S8FON; S8GON; break;
  524.         case L: S8AOFF;S8BOFF;S8COFF;S8DON; S8EON; S8FON; S8GOFF;break;
  525.         case P: S8AON; S8BON; S8COFF;S8DOFF;S8EON; S8FON; S8GON; break;
  526.         case NoDisp: S8NumOFF;
  527.     }
  528. }
  529. //-----------------------------------------------------------------
  530. // 条形图显示
  531. //-----------------------------------------------------------------
  532. void BarGraph(INT8U Count)
  533. {
  534.     //Count小于当前值时,灭掉到Count之后的条形块(OFF)
  535.     if (Count < BGCNT)
  536.     {
  537.         switch (Count)
  538.         {
  539.             case  1: X2OFF;  case  2: X3OFF;  case  3: X4OFF;
  540.             case  4: X5OFF;  case  5: X6OFF;  case  6: X7OFF;
  541.             case  7: X8OFF;  case  8: X9OFF;  case  9: X10OFF;
  542.             case 10: X11OFF; case 11: X12OFF; case 12: X13OFF;
  543.             case 13: X14OFF; case 14: X15OFF; case 15: X16OFF;
  544.             case 16: X17OFF; case 17: X18OFF; case 18: X19OFF;
  545.             case 19: X20OFF;
  546.         }
  547.     }
  548.     //Count大于等于当前值时,点亮Count值之前的所有条形块(ON)
  549.     if (Count >= BGCNT)
  550.     {   switch (Count)
  551.         {
  552.             case 20: X20ON;  case 19: X19ON;  case 18: X18ON;
  553.             case 17: X17ON;  case 16: X16ON;  case 15: X15ON;
  554.             case 14: X14ON;  case 13: X13ON;  case 12: X12ON;
  555.             case 11: X11ON;  case 10: X10ON;  case  9: X9ON;
  556.             case  8: X8ON;   case  7: X7ON;   case  6: X6ON;
  557.             case  5: X5ON;   case  4: X4ON;   case  3: X3ON;
  558.             case  2: X2ON;   case  1: X1ON;
  559.          }
  560.     }
  561.     //保存当前Count值
  562.     BGCNT = Count;
  563. }
  564. //-----------------------------------------------------------------
  565. // 全屏开显示
  566. //-----------------------------------------------------------------
  567. void DisplayOn(void)
  568. {
  569.     S1ON;  S2ON;  S3ON;  S4ON;  S5ON;  S6ON;  S7ON;  S8ON;  S9ON;  S10ON;
  570.     S11ON; S12ON; S13ON; X26ON; X25ON; X24ON; X23ON; X22ON; X21ON;
  571.     X20ON; X19ON; X18ON; X17ON; X16ON; X15ON; X14ON; X13ON; X12ON;
  572.     X11ON; X10ON; X9ON;  X8ON;  X7ON;  X6ON;  X5ON;  X4ON;  X3ON;  X2ON;
  573.     X1ON;  F1ON;  F2ON;  F3ON;  F4ON;  X27ON; X28ON; X29ON; X30ON; X31ON;
  574.     X32ON; X33ON; X34ON; X35ON; X36ON; S1AON; S1BON; S1CON; S1DON;
  575.     S1EON; S1FON; S1GON; S2AON; S2BON; S2CON; S2DON; S2EON; S2FON;
  576.     S2GON; COLON; S3AON; S3BON; S3CON; S3DON; S3EON; S3FON; S3GON;
  577.     S4AON; S4BON; S4CON; S4DON; S4EON; S4FON; S4GON; DP1ON; S5AON;
  578.     S5BON; S5CON; S5DON; S5EON; S5FON; S5GON; S6AON; S6BON; S6CON;
  579.     S6DON; S6EON; S6FON; S6GON; S7AON; S7BON; S7CON; S7DON; S7EON;
  580.     S7FON; S7GON; DP2ON; S8AON; S8BON; S8CON; S8DON; S8EON; S8FON;
  581.     S8GON;
  582. }
  583. //-----------------------------------------------------------------
  584. // 全屏关显示
  585. //-----------------------------------------------------------------
  586. void DisplayOff(void)
  587. {
  588.     S1OFF;  S13OFF;
  589.     S2OFF;  S3OFF; S4OFF;  S5OFF;   S6OFF;  S7OFF;  S8OFF;  S9OFF;  S10OFF;
  590.     S11OFF; S12OFF; X26OFF; X25OFF; X24OFF; X23OFF; X22OFF; X21OFF;
  591.     X20OFF; X19OFF; X18OFF; X17OFF; X16OFF; X15OFF; X14OFF; X13OFF;
  592.     X12OFF; X11OFF; X10OFF; X9OFF;  X8OFF;  X7OFF;  X6OFF;  X5OFF;  X4OFF;
  593.     X3OFF;  X2OFF;  X1OFF;  F1OFF;  F2OFF;  F3OFF;  F4OFF;  X27OFF; X28OFF;
  594.     X29OFF; X30OFF; X31OFF; X32OFF; X33OFF; X34OFF; X35OFF; X36OFF;
  595.     S1AOFF; S1BOFF; S1COFF; S1DOFF; S1EOFF; S1FOFF; S1GOFF; S2AOFF;
  596.     S2BOFF; S2COFF; S2DOFF; S2EOFF; S2FOFF; S2GOFF; COLOFF; S3AOFF;
  597.     S3BOFF; S3COFF; S3DOFF; S3EOFF; S3FOFF; S3GOFF; S4AOFF; S4BOFF;
  598.     S4COFF; S4DOFF; S4EOFF; S4FOFF; S4GOFF; DP1OFF; S5AOFF; S5BOFF;
  599.     S5COFF; S5DOFF; S5EOFF; S5FOFF; S5GOFF; S6AOFF; S6BOFF; S6COFF;
  600.     S6DOFF; S6EOFF; S6FOFF; S6GOFF; S7AOFF; S7BOFF; S7COFF; S7DOFF;
  601.     S7EOFF; S7FOFF; S7GOFF; DP2OFF; S8AOFF; S8BOFF; S8COFF; S8DOFF;
  602.     S8EOFF; S8FOFF; S8GOFF;
  603. }
复制代码

评分

参与人数 1黑币 +100 收起 理由
admin + 100 共享资料的黑币奖励!

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:256110 发表于 2024-11-13 11:05 | 只看该作者
VLS5573手册有吗?
回复

使用道具 举报

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

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

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