LED188.c新版本解决以下问题1.减少占用内存仅需一个数组便可解决0-9的显示如果需要显示abcdef可以在数组后面增加元素且存放在ROM中。2.解决了亮度不均匀的问题逐段扫描所有段码点亮的时间是一致的如果再出现亮度不均必定是硬件问题了。3.残影问题和本程序没关系主要是MCU管脚翻转频率过慢导致管脚还有残留电压所以需要设置到最大频率另外尽可能提高扫描速度。4.这是最终版本也是量产产品的版本分享不易大家看后点赞收藏吧。#include LED188.h uc8 number_table[11]{ 0x77,//0 0x42,//1 0x6D,//2 0x6E,//3 0x5A,//4 0x3E,//5 0x3F,//6 0x46,//7 0x7F,//8 0x7E,//9 0x00//nop }; void Set_ALL_LED_IN(void) { LED1_IN();LED2_IN();LED3_IN();LED4_IN();LED5_IN(); } void Set_ALL_LED_Low(void) { LED1_L();LED2_L();LED3_L();LED4_L();LED5_L(); } DisplayData Disp_data; void Refresh_displaysram(void) { Disp_data.ESsram number_table[Disp_data.eshi]; Disp_data.EGsram number_table[Disp_data.ege]; } void Display_Tube(void)//放在定时器中断1ms运行 { static u8 case_cnt0x00; if(!Disp_data.B_EN) { Set_ALL_LED_Low(); return; } Set_ALL_LED_IN(); if(case_cnt4) {LED1_L();LED1_OUT();} else if(case_cnt8) {LED2_L();LED2_OUT();} else if(case_cnt12) {LED3_L();LED3_OUT();} else if(case_cnt16) {LED4_L();LED4_OUT();} else if(case_cnt18) {LED5_L();LED5_OUT();} else { case_cnt0; LED1_L();LED1_OUT(); } switch(case_cnt) { case 0x00:if(GetBit(Disp_data.EGsram,6))LED2_H(); break;//1 case 0x01:if(GetBit(Disp_data.EGsram,5))LED3_H(); break; case 0x02:if(GetBit(Disp_data.EGsram,4))LED4_H(); break; case 0x03:if(GetBit(Disp_data.EGsram,3))LED5_H(); break; case 0x04:if(GetBit(Disp_data.EGsram,2))LED1_H(); break; case 0x05:if(GetBit(Disp_data.ESsram,6))LED3_H(); break; case 0x06:if(GetBit(Disp_data.ESsram,5))LED4_H(); break; case 0x07:if(GetBit(Disp_data.ESsram,0))LED5_H(); break;//2 case 0x08:if(GetBit(Disp_data.EGsram,1))LED1_H(); break; case 0x09:if(GetBit(Disp_data.ESsram,2))LED2_H(); break; case 0x0A:if(GetBit(Disp_data.ESsram,1))LED4_H(); break; case 0x0B:if(GetBit(Disp_data.ESsram,4))LED5_H(); break; case 0x0C:if(GetBit(Disp_data.EGsram,0))LED1_H(); break; case 0x0D:if(Disp_data.B_EBAI) LED2_H(); break; case 0x0E:if(Disp_data.B_EBAI) LED3_H(); break; case 0x0F:if(GetBit(Disp_data.ESsram,3))LED5_H(); break; case 0x10:if(Disp_data.B_PER) LED2_H(); break; case 0x11:if(Disp_data.B_FCHG) LED3_H(); break; default:case_cnt0; break; } case_cnt; } void Dispdata_Init(void) { Disp_data.init_cnt 2;//开机全显2s Disp_data.B_EN 1;//0关屏 Set_ALL_LED_Low(); //熄灭所有管脚 } void Refresh_188Data(void) { if(!Disp_data.B_JC) return; Disp_data.B_JC0; Disp_data.B_PD0; Disp_data.B_LowV0; Disp_data.B_PER1; Disp_data.B_TOG!Disp_data.B_TOG; Disp_data.SOC88; //可以显示0-199的数字 Disp_data.B_CHGING0;//1充电个位闪烁 Disp_data.B_LowV0; //1低电个位闪烁 if(Disp_data.SOC99) { Disp_data.B_EBAI1; Disp_data.eshi(Disp_data.SOC-100)/10; Disp_data.egeDisp_data.SOC%10; } else { Disp_data.B_EBAI0; Disp_data.eshiDisp_data.SOC/10; Disp_data.egeDisp_data.SOC%10; if(!Disp_data.eshi) Disp_data.eshi0x0A; if(Disp_data.B_TOG (Disp_data.B_CHGING||Disp_data.B_LowV)) Disp_data.ege0x0A; } if(Disp_data.init_cnt)//修改此值实现开机全显错误全闪的时间和次数 { Disp_data.init_cnt--; if(Disp_data.init_cnt2) Disp_data.B_TOG1; if(Disp_data.B_TOG) { Disp_data.B_PER 1; Disp_data.B_PD 1; Disp_data.B_EBAI1; Disp_data.eshi 8; Disp_data.ege 8; } else { Disp_data.B_PER 0; Disp_data.B_PD 0; Disp_data.B_EBAI0; Disp_data.eshi 10; Disp_data.ege 10; } } Refresh_displaysram(); }