MAX7219 8-Digital Segment Digital sigue parpadeando con ESP8266. ¿Cómo podría eliminar esto?

0

** MAX7219 8-Segmento digital Pantalla LED digital conectada a NodeMCU (ESP-8266) La pantalla de segmento sigue parpadeando. enlace

¿Cómopararíaesto?Siayuda:aquíestámicódigo:**

#defineMAX7219_DIND1#defineMAX7219_CSD2#defineMAX7219_CLKD3#include<CountUpDownTimer.h>CountUpDownTimerT(UP,HIGH);//DefaultprecisionisHIGH,butyoucanchangeittoalsobeLOW//MAX7219registers,@seeMAX7219Datasheet,Table2.RegisterAddressMap#defineMAX7219_REG_DECODE0x09#defineMAX7219_REG_INTENSITY0x0A#defineMAX7219_REG_SCANLIMIT0x0B#defineMAX7219_REG_SHUTDOWN0x0C#defineMAX7219_REG_DISPTEST0x0F#defineDISPLAY_MAX_POSITIONS8constbytedisplay_segments_blank=0b00000000;constbytedisplay_segments_dp=0b10000000;constbytedisplay_segments_numeric[10]={0b01111110,0b00110000,0b01101101,0b01111001,0b00110011,0b01011011,0b01011111,0b01110000,0b01111111,0b01111011};bytedisplay_position[DISPLAY_MAX_POSITIONS]={display_segments_blank};intdisplay_precision=0;voiddisplay_set_precision(intp){display_precision=p;}voiddisplay_set_register(bytereg,bytevalue){digitalWrite(MAX7219_CS,LOW);shiftOut(MAX7219_DIN,MAX7219_CLK,MSBFIRST,reg);shiftOut(MAX7219_DIN,MAX7219_CLK,MSBFIRST,value);digitalWrite(MAX7219_CS,HIGH);}voiddisplay_set_blank(){for(inti=1;i<=DISPLAY_MAX_POSITIONS;i++){display_set_register(i,display_segments_blank);}}voiddisplay_set_number(StringnumbStr){display_set_blank();//TODO:lowerprecisionrelativetothelengthofthenumber//StringnumbStr=String(n,display_precision);charc=NULL;intr=1;//setdisplaydigitsfromright(r=1)toleft(r=DISPLAY_MAX_POSITIONS)//loopstringfromrighttoleftfor(inti=(numbStr.length()-1);i>=0;i--){if(r>DISPLAY_MAX_POSITIONS)break;c=c|display_segments_numeric[numbStr.charAt(i)-'0'];if(numbStr.charAt(i)=='.'){c=display_segments_dp;continue;}display_position[r]=c;r++;c=NULL;}}voiddisplay_setup(){T.StartTimer();pinMode(MAX7219_DIN,OUTPUT);pinMode(MAX7219_CS,OUTPUT);pinMode(MAX7219_CLK,OUTPUT);digitalWrite(MAX7219_CS,HIGH);//resetdisplaydisplay_set_register(MAX7219_REG_SHUTDOWN,1);display_set_register(MAX7219_REG_DISPTEST,0);display_set_register(MAX7219_REG_DECODE,0b00000000);display_set_register(MAX7219_REG_SCANLIMIT,0x07);display_set_register(MAX7219_REG_INTENSITY,0x0F);}voiddisplay_loop(){for(intr=1;r<=DISPLAY_MAX_POSITIONS;r++){display_set_register(r,display_position[r]);}}intduration=2;//2secondsintfps=3;floati=0;structPoint{floatx;floaty;};structPointcubic_bezier(floatp1x,floatp1y,floatp2x,floatp2y){//xistime,limitxto>=0or<=1if(p1x<0)p1x=0.0;if(p1x>1)p1x=1.0;if(p2x<0)p2x=0.0;if(p2x>1)p2x=1.0;//p0andp3arefixedpoints,p1andp2arethebezierhandlesfloatp0x=0.0;floatp0y=0.0;floatp3x=1.0;floatp3y=1.0;//@seehttps://stackoverflow.com/a/11435243/97433//@seehttp://cubic-bezier.com///@seehttp://www.shodor.org/interactivate/activities/SimplePlot///thegreenlinesfloatax=p0x+((p1x-p0x)*i);floatay=p0y+((p1y-p0y)*i);floatbx=p1x+((p2x-p1x)*i);floatby=p1y+((p2y-p1y)*i);floatcx=p2x+((p3x-p2x)*i);floatcy=p2y+((p3y-p2y)*i);//thebluelinefloatdx=ax+((bx-ax)*i);floatdy=ay+((by-ay)*i);floatex=bx+((cx-bx)*i);floatey=by+((cy-by)*i);//theblackdotstructPointp;p.x=dx+((ex-dx)*i);p.y=dy+((ey-dy)*i);returnp;}unsignedlongfirst_timeout=5000;unsignedlongtimeout=0;intframes=fps*duration;floatdur=duration*1000-0.0;voidwip_setup(){Serial.begin(115200);display_set_number("0000");
}
void setup() {
    display_setup();
    wip_setup();
}
static char mystr[8];
unsigned long  h =0;
unsigned long  m = 0;
unsigned long  s = 0;
void loop() {
  T.Timer(); // run the timer
    display_loop();
    T.ShowHours()+T.ShowMinutes()+T.ShowSeconds()+T.ShowMilliSeconds();  sprintf(mystr,"94.%02u.%02u.%02u",T.ShowHours(),T.ShowMinutes(),T.ShowSeconds());
         h = T.ShowHours();
         m = T.ShowMinutes();
         s = T.ShowSeconds();
         sprintf(mystr, "%01u.%02u.%02u", h, m, s);
 display_set_number(mystr);
}
    
pregunta JoeB

0 respuestas

Lea otras preguntas en las etiquetas