名称: 微芯VLS5573显示屏驱动测试
说明: 本例运行时,按下K1按键可分别在VLS5573LCD屏上完成模数转换,温度显示, 时钟运行三种演示效果.在演示时钟运行时,K2,K3按键可用于时钟调节.
下载:
微芯VLS5573显示屏应用测试.zip
(337.9 KB, 下载次数: 18)
主程序:
- #include <xc.h>
- #include "LCD_8490.h"
- #include <delays.h>
- #define INT8U unsigned char
- #define INT16U unsigned int
- #pragma config OSC = INTIO67
- #pragma config FCMEN = OFF
- #pragma config IESO = OFF
- #pragma config PWRT = OFF
- #pragma config BOREN = OFF
- #pragma config WDT = OFF
- #pragma config DEBUG = ON
- #pragma config XINST = OFF
- //-----------------------------------------------------------------
- // 本例相关函数声明
- //-----------------------------------------------------------------
- void LCD_CONFIG(void);
- void DisplayOn(void);
- void DisplayOff(void);
- void BarGraph(INT8U);
- void CirGraph(INT8U);
- void S1Num(INT8U);
- void S2Num(INT8U);
- void S3Num(INT8U);
- void S4Num(INT8U);
- void S5Num(INT8U);
- void S6Num(INT8U);
- void S7Num(INT8U);
- void S8Num(INT8U);
- void Voltmeter(void);
- void Volt_Display(INT8U dat);
- void BatteryIndic(INT8U i);
- void Thermometer(void);
- void Temp_Display_C(INT16U dat);
- void Temp_Display_F(INT16U dat);
- void TempIndic(INT8U i);
- void RTC_Display(void);
- //-----------------------------------------------------------------
- // 相关符号等定义
- //-----------------------------------------------------------------
- //10以上的十六进制数位定义(A-F)及本例其他所用字符定义(H,L,P)
- #define A 10
- #define B 11
- #define C 12
- #define D 13
- #define E 14
- #define F 15
- #define H 17
- #define L 21
- #define P 25
- //无显示
- #define NoDisp 0xFF
- #define K1 PORTBbits.RB5 //模式选择键(F1~F3)
- #define K2 PORTBbits.RB6 //按键K2调节HR
- #define K3 PORTBbits.RB7 //按键K3调节MIN
- //-----------------------------------------------------------------
- // 变量声明
- //-----------------------------------------------------------------
- INT16U an0_voltage, an1_voltage, Reading;//AN0,AN1两路模拟电压
- INT8U BGCNT; //条形图条数
- volatile INT8U DemoCode = 0; //演示功能代号
- volatile INT8U SEC, MIN, HR; //秒,分,时
- //-----------------------------------------------------------------
- // 主程序
- //-----------------------------------------------------------------
- void main()
- {
- OSCCON = 0B01000000; //1MHZ
- OSCTUNE = 0B01100000;
- BGCNT = 0; //条形图当前显示的竖条数(bar graph count)
- LCD_CONFIG(); //配置LCD模块使用内部升压电路
- ADCON1 = 0x0D; //RA0-RA2设为模拟输入
- TRISBbits.TRISB5 = 1; //K1按键输入
- TRISBbits.TRISB6 = 1; //K2按键输入
- TRISBbits.TRISB7 = 1; //K3按键输入
- DisplayOn(); //全屏开演示
- Delay10KTCYx(10); //延时
- DisplayOff(); //全屏关演示
- MCHPON; //显示微芯标志
- S1Num(H);S2Num(E);S3Num(L);//显示"HELLO"(字母O用数字0代替)
- S4Num(L);S5Num(0);
- //外部中断控制
- INTCONbits.RBIE = 1; //使PB端口中断
- INTCONbits.PEIE = 1; //使能所有未屏蔽的外部中断
- INTCONbits.GIE = 1; //开全局中断
- Sleep(); //低功耗模式
- DisplayOff(); //显示屏关闭
- //定时器TMR1初始化
- TMR1H = 0x80; //TMR1L默认为0x00,0x8000=32768,定时1s
- T1CONbits.T1RUN = 1; //时钟取自TIMER1振荡器(内部:32768)
- T1CONbits.T1CKPS1 = 0; //T1CKPS1:0=00,1:1预分频
- T1CONbits.T1CKPS0 = 0;
- T1CONbits.T1OSCEN = 1; //使能TIMER1振荡器
- T1CONbits.T1SYNC = 1; //不同步外部时钟输入
- T1CONbits.TMR1CS = 1; //选择32KHz时钟
- T1CONbits.TMR1ON = 1; //使能TIMER1
- PIE1bits.TMR1IE = 0; //暂时禁止TIMER1中断
- while(1)
- { //F1按键演示-----------------------------------------------
- if (DemoCode == 1)
- { F1ON; //显示F1
- TRISAbits.TRISA0 = 1; //AN0设为输入
- ADCON0bits.CHS3 = 0; //0000:选择模拟通道AN0
- ADCON0bits.CHS2 = 0;
- ADCON0bits.CHS1 = 0;
- ADCON0bits.CHS0 = 0;
- //转换结果左对齐,ACQT2:ACQT0:111,AD获取时钟选择位设置:20TAD
- //ADCS2:ADCS0:111,时钟来自AD RC振荡器
- ADCON2 = 0xBF; //该行可展开为如下7行代码
- //ADCON2bits.ADFM = 1; //右对齐
- //ADCON2bits.ACQT2 = 1; //AD获取时钟选择位设置:20TAD
- //ADCON2bits.ACQT1 = 1;
- //ADCON2bits.ACQT0 = 1;
- //ADCON2bits.ADCS2 = 1; //AD时钟来自AD RC振荡器
- //ADCON2bits.ADCS1 = 1;
- //ADCON2bits.ADCS0 = 1;
- ADCON0bits.ADON = 1; //启动ADC
- while (DemoCode == 1)
- { PIR1bits.ADIF = 0; PIE1bits.ADIE = 1; ADCON0bits.GO_DONE = 1;
- Sleep();
- Reading = an0_voltage;
- Voltmeter();
- }
- ADCON0bits.ADON = 0; //ADC关闭
- DisplayOff(); //关闭所有显示
- }
- //F2按键演示-----------------------------------------------
- else if (DemoCode == 2)
- { F2ON; //显示F2
- TRISAbits.TRISA1 = 1; //AN1设为输入
- ADCON0bits.CHS3 = 0; //0001:选择模拟通道AN1
- ADCON0bits.CHS2 = 0;
- ADCON0bits.CHS1 = 0;
- ADCON0bits.CHS0 = 1;
- ADCON2 = 0xBF;
- ADCON0bits.ADON = 1; //ADC启动
- while (DemoCode == 2)
- { PIR1bits.ADIF = 0; PIE1bits.ADIE = 1; ADCON0bits.GO_DONE = 1;
- Sleep(); Reading = an1_voltage;
- Thermometer(); //温度计显示
- }
- ADCON0bits.ADON = 0; //ADC关闭
- DisplayOff(); //关闭所有显示
- }
- //F3按键演示-----------------------------------------------
- else if (DemoCode == 3)
- { F3ON; //显示F3
- PIE1bits.TMR1IE = 1; //运行定时器
- HR = MIN = SEC = 0; //初始化时分秒
- while (PIE1bits.TMR1IE);//定时中断未禁止则等待(定时中断持续触发)
- DisplayOff(); //关闭所有显示
- }
- }
- }
- //-----------------------------------------------------------------
- // LCD配置寄存器设置
- //-----------------------------------------------------------------
- void LCD_CONFIG(void)
- {
- LCDPSbits.WFT = 0; //波形类型选择位(0:A类,1:B类)
- LCDPSbits.BIASMD = 0; //偏压模式(本例LMUX1:0为11,BIASMD为0: 1/3偏压)
- //选择帧时钟预分频0100->1:5
- LCDPSbits.LP3 = 0; LCDPSbits.LP2 = 1;
- LCDPSbits.LP1 = 0; LCDPSbits.LP0 = 0;
- //设置LCDSEx寄存器,使相应的引脚(SEGx)作为数码管段驱动
- LCDSE0 = 0xFF; LCDSE1 = 0xFF;
- LCDSE2 = 0xFF; LCDSE3 = 0xFF;
- LCDSE4 = 0xFF; LCDSE5 = 0xFF;
- //通过LCDCON寄存器配置LCD模块
- //CS1:0为时钟源选择位,11表示:INTRC(31.25 kHz)/32
- LCDCONbits.CS1 = 1; LCDCONbits.CS0 = 1;
- //LMUX1:0设为11,将PORTE4-PORTE6设为COM1-COM3,占空比:1/4
- LCDCONbits.LMUX1 = 1; LCDCONbits.LMUX0 = 1;
- LCDCONbits.LCDEN = 1; //使能LCD模块
- }
- //-----------------------------------------------------------------
- // 中断例程
- //-----------------------------------------------------------------
- void interrupt InterruptHandlerHigh()
- {
- //定时器TMR1溢出中断
- if (PIR1bits.TMR1IF == 1)
- { //处理秒,分,时递增及进位操作
- if (++SEC > 59)
- { SEC = 0; if (++MIN > 59) { MIN = 0; if (++HR > 23 ) HR = 0; } }
- if (DemoCode == 3) RTC_Display(); else PIE1bits.TMR1IE = 0;
- TMR1H = 0x80; TMR1L = 0x00;
- PIR1bits.TMR1IF = 0;
- }
- //模数转换中断
- if (PIR1bits.ADIF == 1)
- { PIR1bits.ADIF = 0;
- if (DemoCode == 1) { an0_voltage =((INT16U)(ADRESH) << 8) + ADRESL;}
- if (DemoCode == 2) { an1_voltage =((INT16U)(ADRESH) << 8) + ADRESL;}
- }
- //INT中断(按键K1/K2/K3触发)
- if (INTCONbits.RBIF == 1)
- { //K1控制演示功能号在1~3之间循环
- if (K1 == 0) { while (K1 == 0); if (++DemoCode > 3 ) DemoCode = 1; }
- //K2,K3调节时/分
- if (K2 == 0) { if (HR < 23) HR++; }
- if (K3 == 0) { if (MIN < 59) MIN++; }
- INTCONbits.RBIF = 0;
- }
- }
- //-----------------------------------------------------------------
- // 温度计程序
- //-----------------------------------------------------------------
- void Thermometer(void)
- {
- Temp_Display_C(2 *(Reading - 392)); //摄氏温度显示
- Temp_Display_F(36 *(Reading - 303)); //华氏温度显示
- }
- //-----------------------------------------------------------------
- // 摄氏温度显示
- // (显示在下行数字6,7,8位,加小数点,开摄氏度标志,并显示温度指示器)
- //-----------------------------------------------------------------
- void Temp_Display_C(INT16U dat)
- {
- S6Num(dat / 100); S7Num(dat / 10 % 10); S8Num(dat % 10);
- DP2ON; X25ON;
- TempIndic(dat / 100);
- }
- //-----------------------------------------------------------------
- // 华氏温度显示(显示在上行数字2,3,4,5位,加小数点,开华氏度标志)
- //-----------------------------------------------------------------
- void Temp_Display_F(INT16U dat)
- {
- S2Num(dat / 1000); S3Num(dat / 100 % 10); S4Num(dat % 100 / 10);
- S5Num(dat % 10);
- DP1ON; X26ON;
- }
- //-----------------------------------------------------------------
- // 电压表显示
- //-----------------------------------------------------------------
- void Voltmeter(void)
- {
- //电压值显示0.0V~5.0V (VR调到顶端时本例为1022,此处用+1调整误差)
- Volt_Display( (an0_voltage + 1) * 50 / 1023);
- //刷新条形图显示(0-20条)
- BarGraph( (an0_voltage + 1) * 20 / 1023);
- //电量指示器显示(3段电量指示)
- BatteryIndic((an0_voltage + 1) * 3 / 1023);
- }
- //-----------------------------------------------------------------
- // 电压值显示
- //-----------------------------------------------------------------
- void Volt_Display(INT8U d)
- {
- //在上行第4,5两位显示电压,并加小数点
- S4Num(d / 10); S5Num(d % 10); DP1ON;
- }
- //-----------------------------------------------------------------
- // 温度指示器指示
- //-----------------------------------------------------------------
- void TempIndic(INT8U i)
- {
- S5ON; //固定显示温度指示器外框
- //内部高度显示(3段,S6/S7/S8)
- if (i >= 5) { S6ON; S7ON; S8ON;} //三段显示
- else if (i >= 2) { S6OFF; S7ON; S8ON;} //两段显示
- else if (i >= 1) { S6OFF; S7OFF; S8ON;} //一段显示
- }
- //-----------------------------------------------------------------
- // 电量指示器显示
- //-----------------------------------------------------------------
- void BatteryIndic(INT8U i)
- {
- S9ON; //固定显示电量指示器外框
- if (i >= 3) { S10ON; S12ON; S11ON; } //三段显示
- if (i == 2) { S10OFF; S12ON; S11ON; } //两段显示
- if (i == 1) { S10OFF; S12OFF; S11ON;} //一段显示
- }
- //-----------------------------------------------------------------
- // 实时时钟显示
- //-----------------------------------------------------------------
- void RTC_Display(void)
- {
- S1Num(HR / 10); S2Num(HR % 10); COLON;//小时显示,后面加冒号显示
- S3Num(MIN / 10); S4Num(MIN % 10);//分钟显示
- S6Num(SEC / 10); S7Num(SEC % 10);//秒显示
- CirGraph(SEC % 10); //环形图显示(用于模拟秒循环)
- }
- //-----------------------------------------------------------------
- // 环形进程图显示
- //-----------------------------------------------------------------
- void CirGraph(INT8U Count)
- {
- CGOFF; //先清除环形图显示
- //根据Count值决定显示扇形范围,为0时仅显示环形的圆心点
- switch(Count)
- { case 9: X28ON; case 8: X29ON; case 7: X30ON;
- case 6: X31ON; case 5: X32ON; case 4: X33ON;
- case 3: X34ON; case 2: X35ON; case 1: X36ON;
- case 0: X27ON;
- }
- }
- //-----------------------------------------------------------------
- // 数位1显示
- //-----------------------------------------------------------------
- void S1Num(INT8U d)
- {
- switch(d)
- { case 0: S1AON; S1BON; S1CON; S1DON; S1EON; S1FON; S1GOFF;break;
- case 1: S1AOFF;S1BON; S1CON; S1DOFF;S1EOFF;S1FOFF;S1GOFF;break;
- case 2: S1AON; S1BON; S1COFF;S1DON; S1EON; S1FOFF;S1GON; break;
- case 3: S1AON; S1BON; S1CON; S1DON; S1EOFF;S1FOFF;S1GON; break;
- case 4: S1AOFF;S1BON; S1CON; S1DOFF;S1EOFF;S1FON; S1GON; break;
- case 5: S1AON; S1BOFF;S1CON; S1DON; S1EOFF;S1FON; S1GON; break;
- case 6: S1AON; S1BOFF;S1CON; S1DON; S1EON; S1FON; S1GON; break;
- case 7: S1AON; S1BON; S1CON; S1DOFF;S1EOFF;S1FOFF;S1GOFF;break;
- case 8: S1AON; S1BON; S1CON; S1DON; S1EON; S1FON; S1GON; break;
- case 9: S1AON; S1BON; S1CON; S1DON; S1EOFF;S1FON; S1GON; break;
- case A: S1AON; S1BON; S1CON; S1DOFF;S1EON; S1FON; S1GON; break;
- case B: S1AOFF;S1BOFF;S1CON; S1DON; S1EON; S1FON; S1GON; break;
- case C: S1AON; S1BOFF;S1COFF;S1DON; S1EON; S1FON; S1GOFF;break;
- case D: S1AOFF;S1BON; S1CON; S1DON; S1EON; S1FOFF;S1GON; break;
- case E: S1AON; S1BOFF;S1COFF;S1DON; S1EON; S1FON; S1GON; break;
- case F: S1AON; S1BOFF;S1COFF;S1DOFF;S1EON; S1FON; S1GON; break;
- case H: S1AOFF;S1BON; S1CON; S1DOFF;S1EON; S1FON; S1GON; break;
- case L: S1AOFF;S1BOFF;S1COFF;S1DON; S1EON; S1FON; S1GOFF;break;
- case P: S1AON; S1BON; S1COFF;S1DOFF;S1EON; S1FON; S1GON; break;
- case NoDisp: S1NumOFF;
- }
- }
- //-----------------------------------------------------------------
- // 数位2显示
- //-----------------------------------------------------------------
- void S2Num(INT8U d)
- {
- switch(d)
- {
- case 0: S2AON; S2BON; S2CON; S2DON; S2EON; S2FON; S2GOFF;break;
- case 1: S2AOFF;S2BON; S2CON; S2DOFF;S2EOFF;S2FOFF;S2GOFF;break;
- case 2: S2AON; S2BON; S2COFF;S2DON; S2EON; S2FOFF;S2GON; break;
- case 3: S2AON; S2BON; S2CON; S2DON; S2EOFF;S2FOFF;S2GON; break;
- case 4: S2AOFF;S2BON; S2CON; S2DOFF;S2EOFF;S2FON; S2GON; break;
- case 5: S2AON; S2BOFF;S2CON; S2DON; S2EOFF;S2FON; S2GON; break;
- case 6: S2AON; S2BOFF;S2CON; S2DON; S2EON; S2FON; S2GON; break;
- case 7: S2AON; S2BON; S2CON; S2DOFF;S2EOFF;S2FOFF;S2GOFF;break;
- case 8: S2AON; S2BON; S2CON; S2DON; S2EON; S2FON; S2GON; break;
- case 9: S2AON; S2BON; S2CON; S2DON; S2EOFF;S2FON; S2GON; break;
- case A: S2AON; S2BON; S2CON; S2DOFF;S2EON; S2FON; S2GON; break;
- case B: S2AOFF;S2BOFF;S2CON; S2DON; S2EON; S2FON; S2GON; break;
- case C: S2AON; S2BOFF;S2COFF;S2DON; S2EON; S2FON; S2GOFF;break;
- case D: S2AOFF;S2BON; S2CON; S2DON; S2EON; S2FOFF;S2GON; break;
- case E: S2AON; S2BOFF;S2COFF;S2DON; S2EON; S2FON; S2GON; break;
- case F: S2AON; S2BOFF;S2COFF;S2DOFF;S2EON; S2FON; S2GON; break;
- case H: S2AOFF;S2BON; S2CON; S2DOFF;S2EON; S2FON; S2GON; break;
- case L: S2AOFF;S2BOFF;S2COFF;S2DON; S2EON; S2FON; S2GOFF;break;
- case P: S2AON; S2BON; S2COFF;S2DOFF;S2EON; S2FON; S2GON; break;
- case NoDisp: S2NumOFF;
- }
- }
- //-----------------------------------------------------------------
- // 数位3显示
- //-----------------------------------------------------------------
- void S3Num(INT8U d)
- {
- switch(d)
- {
- case 0: S3AON; S3BON; S3CON; S3DON; S3EON; S3FON; S3GOFF;break;
- case 1: S3AOFF;S3BON; S3CON; S3DOFF;S3EOFF;S3FOFF;S3GOFF;break;
- case 2: S3AON; S3BON; S3COFF;S3DON; S3EON; S3FOFF;S3GON; break;
- case 3: S3AON; S3BON; S3CON; S3DON; S3EOFF;S3FOFF;S3GON; break;
- case 4: S3AOFF;S3BON; S3CON; S3DOFF;S3EOFF;S3FON; S3GON; break;
- case 5: S3AON; S3BOFF;S3CON; S3DON; S3EOFF;S3FON; S3GON; break;
- case 6: S3AON; S3BOFF;S3CON; S3DON; S3EON; S3FON; S3GON; break;
- case 7: S3AON; S3BON; S3CON; S3DOFF;S3EOFF;S3FOFF;S3GOFF;break;
- case 8: S3AON; S3BON; S3CON; S3DON; S3EON; S3FON; S3GON; break;
- case 9: S3AON; S3BON; S3CON; S3DON; S3EOFF;S3FON; S3GON; break;
- case A: S3AON; S3BON; S3CON; S3DOFF;S3EON; S3FON; S3GON; break;
- case B: S3AOFF;S3BOFF;S3CON; S3DON; S3EON; S3FON; S3GON; break;
- case C: S3AON; S3BOFF;S3COFF;S3DON; S3EON; S3FON; S3GOFF;break;
- case D: S3AOFF;S3BON; S3CON; S3DON; S3EON; S3FOFF;S3GON; break;
- case E: S3AON; S3BOFF;S3COFF;S3DON; S3EON; S3FON; S3GON; break;
- case F: S3AON; S3BOFF;S3COFF;S3DOFF;S3EON; S3FON; S3GON; break;
- case H: S3AOFF;S3BON; S3CON; S3DOFF;S3EON; S3FON; S3GON; break;
- case L: S3AOFF;S3BOFF;S3COFF;S3DON; S3EON; S3FON; S3GOFF;break;
- case P: S3AON; S3BON; S3COFF;S3DOFF;S3EON; S3FON; S3GON; break;
- case NoDisp: S3NumOFF;
- }
- }
- //-----------------------------------------------------------------
- // 数位4显示
- //-----------------------------------------------------------------
- void S4Num(INT8U d)
- {
- switch(d)
- {
- case 0: S4AON; S4BON; S4CON; S4DON; S4EON; S4FON; S4GOFF;break;
- case 1: S4AOFF;S4BON; S4CON; S4DOFF;S4EOFF;S4FOFF;S4GOFF;break;
- case 2: S4AON; S4BON; S4COFF;S4DON; S4EON; S4FOFF;S4GON; break;
- case 3: S4AON; S4BON; S4CON; S4DON; S4EOFF;S4FOFF;S4GON; break;
- case 4: S4AOFF;S4BON; S4CON; S4DOFF;S4EOFF;S4FON; S4GON; break;
- case 5: S4AON; S4BOFF;S4CON; S4DON; S4EOFF;S4FON; S4GON; break;
- case 6: S4AON; S4BOFF;S4CON; S4DON; S4EON; S4FON; S4GON; break;
- case 7: S4AON; S4BON; S4CON; S4DOFF;S4EOFF;S4FOFF;S4GOFF;break;
- case 8: S4AON; S4BON; S4CON; S4DON; S4EON; S4FON; S4GON; break;
- case 9: S4AON; S4BON; S4CON; S4DON; S4EOFF;S4FON; S4GON; break;
- case A: S4AON; S4BON; S4CON; S4DOFF;S4EON; S4FON; S4GON; break;
- case B: S4AOFF;S4BOFF;S4CON; S4DON; S4EON; S4FON; S4GON; break;
- case C: S4AON; S4BOFF;S4COFF;S4DON; S4EON; S4FON; S4GOFF;break;
- case D: S4AOFF;S4BON; S4CON; S4DON; S4EON; S4FOFF;S4GON; break;
- case E: S4AON; S4BOFF;S4COFF;S4DON; S4EON; S4FON; S4GON; break;
- case F: S4AON; S4BOFF;S4COFF;S4DOFF;S4EON; S4FON; S4GON; break;
- case H: S4AOFF;S4BON; S4CON; S4DOFF;S4EON; S4FON; S4GON; break;
- case L: S4AOFF;S4BOFF;S4COFF;S4DON; S4EON; S4FON; S4GOFF;break;
- case P: S4AON; S4BON; S4COFF;S4DOFF;S4EON; S4FON; S4GON; break;
- case NoDisp: S4NumOFF;
- }
- }
- //-----------------------------------------------------------------
- // 数位5显示
- //-----------------------------------------------------------------
- void S5Num(INT8U d)
- {
- switch(d)
- {
- case 0: S5AON; S5BON; S5CON; S5DON; S5EON; S5FON; S5GOFF;break;
- case 1: S5AOFF;S5BON; S5CON; S5DOFF;S5EOFF;S5FOFF;S5GOFF;break;
- case 2: S5AON; S5BON; S5COFF;S5DON; S5EON; S5FOFF;S5GON; break;
- case 3: S5AON; S5BON; S5CON; S5DON; S5EOFF;S5FOFF;S5GON; break;
- case 4: S5AOFF;S5BON; S5CON; S5DOFF;S5EOFF;S5FON; S5GON; break;
- case 5: S5AON; S5BOFF;S5CON; S5DON; S5EOFF;S5FON; S5GON; break;
- case 6: S5AON; S5BOFF;S5CON; S5DON; S5EON; S5FON; S5GON; break;
- case 7: S5AON; S5BON; S5CON; S5DOFF;S5EOFF;S5FOFF;S5GOFF;break;
- case 8: S5AON; S5BON; S5CON; S5DON; S5EON; S5FON; S5GON; break;
- case 9: S5AON; S5BON; S5CON; S5DON; S5EOFF;S5FON; S5GON; break;
- case A: S5AON; S5BON; S5CON; S5DOFF;S5EON; S5FON; S5GON; break;
- case B: S5AOFF;S5BOFF;S5CON; S5DON; S5EON; S5FON; S5GON; break;
- case C: S5AON; S5BOFF;S5COFF;S5DON; S5EON; S5FON; S5GOFF;break;
- case D: S5AOFF;S5BON; S5CON; S5DON; S5EON; S5FOFF;S5GON; break;
- case E: S5AON; S5BOFF;S5COFF;S5DON; S5EON; S5FON; S5GON; break;
- case F: S5AON; S5BOFF;S5COFF;S5DOFF;S5EON; S5FON; S5GON; break;
- case H: S5AOFF;S5BON; S5CON; S5DOFF;S5EON; S5FON; S5GON; break;
- case L: S5AOFF;S5BOFF;S5COFF;S5DON; S5EON; S5FON; S5GOFF;break;
- case P: S5AON; S5BON; S5COFF;S5DOFF;S5EON; S5FON; S5GON; break;
- case NoDisp: S5NumOFF;
- }
- }
- //-----------------------------------------------------------------
- // 数位6显示
- //-----------------------------------------------------------------
- void S6Num(INT8U d)
- {
- switch(d)
- {
- case 0: S6AON; S6BON; S6CON; S6DON; S6EON; S6FON; S6GOFF;break;
- case 1: S6AOFF;S6BON; S6CON; S6DOFF;S6EOFF;S6FOFF;S6GOFF;break;
- case 2: S6AON; S6BON; S6COFF;S6DON; S6EON; S6FOFF;S6GON; break;
- case 3: S6AON; S6BON; S6CON; S6DON; S6EOFF;S6FOFF;S6GON; break;
- case 4: S6AOFF;S6BON; S6CON; S6DOFF;S6EOFF;S6FON; S6GON; break;
- case 5: S6AON; S6BOFF;S6CON; S6DON; S6EOFF;S6FON; S6GON; break;
- case 6: S6AON; S6BOFF;S6CON; S6DON; S6EON; S6FON; S6GON; break;
- case 7: S6AON; S6BON; S6CON; S6DOFF;S6EOFF;S6FOFF;S6GOFF;break;
- case 8: S6AON; S6BON; S6CON; S6DON; S6EON; S6FON; S6GON; break;
- case 9: S6AON; S6BON; S6CON; S6DON; S6EOFF;S6FON; S6GON; break;
- case A: S6AON; S6BON; S6CON; S6DOFF;S6EON; S6FON; S6GON; break;
- case B: S6AOFF;S6BOFF;S6CON; S6DON; S6EON; S6FON; S6GON; break;
- case C: S6AON; S6BOFF;S6COFF;S6DON; S6EON; S6FON; S6GOFF;break;
- case D: S6AOFF;S6BON; S6CON; S6DON; S6EON; S6FOFF;S6GON; break;
- case E: S6AON; S6BOFF;S6COFF;S6DON; S6EON; S6FON; S6GON; break;
- case F: S6AON; S6BOFF;S6COFF;S6DOFF;S6EON; S6FON; S6GON; break;
- case H: S6AOFF;S6BON; S6CON; S6DOFF;S6EON; S6FON; S6GON; break;
- case L: S6AOFF;S6BOFF;S6COFF;S6DON; S6EON; S6FON; S6GOFF;break;
- case P: S6AON; S6BON; S6COFF;S6DOFF;S6EON; S6FON; S6GON; break;
- case NoDisp: S6NumOFF;
- }
- }
- //-----------------------------------------------------------------
- // 数位7显示
- //-----------------------------------------------------------------
- void S7Num(INT8U d)
- {
- switch(d)
- {
- case 0: S7AON; S7BON; S7CON; S7DON; S7EON; S7FON; S7GOFF;break;
- case 1: S7AOFF;S7BON; S7CON; S7DOFF;S7EOFF;S7FOFF;S7GOFF;break;
- case 2: S7AON; S7BON; S7COFF;S7DON; S7EON; S7FOFF;S7GON; break;
- case 3: S7AON; S7BON; S7CON; S7DON; S7EOFF;S7FOFF;S7GON; break;
- case 4: S7AOFF;S7BON; S7CON; S7DOFF;S7EOFF;S7FON; S7GON; break;
- case 5: S7AON; S7BOFF;S7CON; S7DON; S7EOFF;S7FON; S7GON; break;
- case 6: S7AON; S7BOFF;S7CON; S7DON; S7EON; S7FON; S7GON; break;
- case 7: S7AON; S7BON; S7CON; S7DOFF;S7EOFF;S7FOFF;S7GOFF;break;
- case 8: S7AON; S7BON; S7CON; S7DON; S7EON; S7FON; S7GON; break;
- case 9: S7AON; S7BON; S7CON; S7DON; S7EOFF;S7FON; S7GON; break;
- case A: S7AON; S7BON; S7CON; S7DOFF;S7EON; S7FON; S7GON; break;
- case B: S7AOFF;S7BOFF;S7CON; S7DON; S7EON; S7FON; S7GON; break;
- case C: S7AON; S7BOFF;S7COFF;S7DON; S7EON; S7FON; S7GOFF;break;
- case D: S7AOFF;S7BON; S7CON; S7DON; S7EON; S7FOFF;S7GON; break;
- case E: S7AON; S7BOFF;S7COFF;S7DON; S7EON; S7FON; S7GON; break;
- case F: S7AON; S7BOFF;S7COFF;S7DOFF;S7EON; S7FON; S7GON; break;
- case H: S7AOFF;S7BON; S7CON; S7DOFF;S7EON; S7FON; S7GON; break;
- case L: S7AOFF;S7BOFF;S7COFF;S7DON; S7EON; S7FON; S7GOFF;break;
- case P: S7AON; S7BON; S7COFF;S7DOFF;S7EON; S7FON; S7GON; break;
- case NoDisp: S7NumOFF;
- }
- }
- //-----------------------------------------------------------------
- // 数位8显示
- //-----------------------------------------------------------------
- void S8Num(INT8U d)
- {
- switch(d)
- {
- case 0: S8AON; S8BON; S8CON; S8DON; S8EON; S8FON; S8GOFF;break;
- case 1: S8AOFF;S8BON; S8CON; S8DOFF;S8EOFF;S8FOFF;S8GOFF;break;
- case 2: S8AON; S8BON; S8COFF;S8DON; S8EON; S8FOFF;S8GON; break;
- case 3: S8AON; S8BON; S8CON; S8DON; S8EOFF;S8FOFF;S8GON; break;
- case 4: S8AOFF;S8BON; S8CON; S8DOFF;S8EOFF;S8FON; S8GON; break;
- case 5: S8AON; S8BOFF;S8CON; S8DON; S8EOFF;S8FON; S8GON; break;
- case 6: S8AON; S8BOFF;S8CON; S8DON; S8EON; S8FON; S8GON; break;
- case 7: S8AON; S8BON; S8CON; S8DOFF;S8EOFF;S8FOFF;S8GOFF;break;
- case 8: S8AON; S8BON; S8CON; S8DON; S8EON; S8FON; S8GON; break;
- case 9: S8AON; S8BON; S8CON; S8DON; S8EOFF;S8FON; S8GON; break;
- case A: S8AON; S8BON; S8CON; S8DOFF;S8EON; S8FON; S8GON; break;
- case B: S8AOFF;S8BOFF;S8CON; S8DON; S8EON; S8FON; S8GON; break;
- case C: S8AON; S8BOFF;S8COFF;S8DON; S8EON; S8FON; S8GOFF;break;
- case D: S8AOFF;S8BON; S8CON; S8DON; S8EON; S8FOFF;S8GON; break;
- case E: S8AON; S8BOFF;S8COFF;S8DON; S8EON; S8FON; S8GON; break;
- case F: S8AON; S8BOFF;S8COFF;S8DOFF;S8EON; S8FON; S8GON; break;
- case H: S8AOFF;S8BON; S8CON; S8DOFF;S8EON; S8FON; S8GON; break;
- case L: S8AOFF;S8BOFF;S8COFF;S8DON; S8EON; S8FON; S8GOFF;break;
- case P: S8AON; S8BON; S8COFF;S8DOFF;S8EON; S8FON; S8GON; break;
- case NoDisp: S8NumOFF;
- }
- }
- //-----------------------------------------------------------------
- // 条形图显示
- //-----------------------------------------------------------------
- void BarGraph(INT8U Count)
- {
- //Count小于当前值时,灭掉到Count之后的条形块(OFF)
- if (Count < BGCNT)
- {
- switch (Count)
- {
- case 1: X2OFF; case 2: X3OFF; case 3: X4OFF;
- case 4: X5OFF; case 5: X6OFF; case 6: X7OFF;
- case 7: X8OFF; case 8: X9OFF; case 9: X10OFF;
- case 10: X11OFF; case 11: X12OFF; case 12: X13OFF;
- case 13: X14OFF; case 14: X15OFF; case 15: X16OFF;
- case 16: X17OFF; case 17: X18OFF; case 18: X19OFF;
- case 19: X20OFF;
- }
- }
- //Count大于等于当前值时,点亮Count值之前的所有条形块(ON)
- if (Count >= BGCNT)
- { switch (Count)
- {
- case 20: X20ON; case 19: X19ON; case 18: X18ON;
- case 17: X17ON; case 16: X16ON; case 15: X15ON;
- case 14: X14ON; case 13: X13ON; case 12: X12ON;
- case 11: X11ON; case 10: X10ON; case 9: X9ON;
- case 8: X8ON; case 7: X7ON; case 6: X6ON;
- case 5: X5ON; case 4: X4ON; case 3: X3ON;
- case 2: X2ON; case 1: X1ON;
- }
- }
- //保存当前Count值
- BGCNT = Count;
- }
- //-----------------------------------------------------------------
- // 全屏开显示
- //-----------------------------------------------------------------
- void DisplayOn(void)
- {
- S1ON; S2ON; S3ON; S4ON; S5ON; S6ON; S7ON; S8ON; S9ON; S10ON;
- S11ON; S12ON; S13ON; X26ON; X25ON; X24ON; X23ON; X22ON; X21ON;
- X20ON; X19ON; X18ON; X17ON; X16ON; X15ON; X14ON; X13ON; X12ON;
- X11ON; X10ON; X9ON; X8ON; X7ON; X6ON; X5ON; X4ON; X3ON; X2ON;
- X1ON; F1ON; F2ON; F3ON; F4ON; X27ON; X28ON; X29ON; X30ON; X31ON;
- X32ON; X33ON; X34ON; X35ON; X36ON; S1AON; S1BON; S1CON; S1DON;
- S1EON; S1FON; S1GON; S2AON; S2BON; S2CON; S2DON; S2EON; S2FON;
- S2GON; COLON; S3AON; S3BON; S3CON; S3DON; S3EON; S3FON; S3GON;
- S4AON; S4BON; S4CON; S4DON; S4EON; S4FON; S4GON; DP1ON; S5AON;
- S5BON; S5CON; S5DON; S5EON; S5FON; S5GON; S6AON; S6BON; S6CON;
- S6DON; S6EON; S6FON; S6GON; S7AON; S7BON; S7CON; S7DON; S7EON;
- S7FON; S7GON; DP2ON; S8AON; S8BON; S8CON; S8DON; S8EON; S8FON;
- S8GON;
- }
- //-----------------------------------------------------------------
- // 全屏关显示
- //-----------------------------------------------------------------
- void DisplayOff(void)
- {
- S1OFF; S13OFF;
- S2OFF; S3OFF; S4OFF; S5OFF; S6OFF; S7OFF; S8OFF; S9OFF; S10OFF;
- S11OFF; S12OFF; X26OFF; X25OFF; X24OFF; X23OFF; X22OFF; X21OFF;
- X20OFF; X19OFF; X18OFF; X17OFF; X16OFF; X15OFF; X14OFF; X13OFF;
- X12OFF; X11OFF; X10OFF; X9OFF; X8OFF; X7OFF; X6OFF; X5OFF; X4OFF;
- X3OFF; X2OFF; X1OFF; F1OFF; F2OFF; F3OFF; F4OFF; X27OFF; X28OFF;
- X29OFF; X30OFF; X31OFF; X32OFF; X33OFF; X34OFF; X35OFF; X36OFF;
- S1AOFF; S1BOFF; S1COFF; S1DOFF; S1EOFF; S1FOFF; S1GOFF; S2AOFF;
- S2BOFF; S2COFF; S2DOFF; S2EOFF; S2FOFF; S2GOFF; COLOFF; S3AOFF;
- S3BOFF; S3COFF; S3DOFF; S3EOFF; S3FOFF; S3GOFF; S4AOFF; S4BOFF;
- S4COFF; S4DOFF; S4EOFF; S4FOFF; S4GOFF; DP1OFF; S5AOFF; S5BOFF;
- S5COFF; S5DOFF; S5EOFF; S5FOFF; S5GOFF; S6AOFF; S6BOFF; S6COFF;
- S6DOFF; S6EOFF; S6FOFF; S6GOFF; S7AOFF; S7BOFF; S7COFF; S7DOFF;
- S7EOFF; S7FOFF; S7GOFF; DP2OFF; S8AOFF; S8BOFF; S8COFF; S8DOFF;
- S8EOFF; S8FOFF; S8GOFF;
- }
复制代码
|