Home > other > Consult a great god, and I want to use the button control digital tube display different content, wh
Consult a great god, and I want to use the button control digital tube display different content, wh
Time:11-25
Teach a great god, and I want to use the button control digital tube display different content, why not achieve them, the same key, according to a display temperature, according to a show time, so cycle, buttons with time delay, according to go down after the digital tube can not switch will turn black, feel key deal with this problem, please help me to analyze,
U8 code smgduan [10]={x5b x3f 0, 0 x06, 0, 0 x4f, 0 x66, 0 x6d, 0 x7d, 0 x07, 0 x7f, 0 x6f};//show the value of 0 ~ 9 U8 DisData [8]. U8 DisplayData [8]. U8 Data [8].
U8 keypro ()//button handler { U8 I, flag=0, t=0; If (k1==0) { If (k1==0) { for(i=0; i<2; I++) { Delay2s (); Flag++; If (flag==2) flag=0; } } //while (! K1); } The switch (flag) { Case (0) : t=0; break; Case (1) : t=1; break; } return t;
}
Digital tube display function void dyna () \ \ { Unsigned int I; for(i=0; i<8; I++) { The switch (I) { Case (0) : SA=0; SB=0; SC=0; break; Case (1) : SA=1; SB=0; SC=0; break; Case (2) : SA=0; SB=1; SC=0; break; Case (3) : SA=1; SB=1; SC=0; break; Case (4) : SA=0; SB=0; SC=1; break; Case (5) : SA=1; SB=0; SC=1; break; Case (6) : SA=0; SB=1; SC=1; break; Case (7) : SA=1; SB=1; SC=1; break; } The switch (keypro ()) { Case 1: the Data [I]=DisplayData [I]; break; Case 0: Data [I]=DisData [I]; break; } GPIO_DIG=Data [I]; Delay (20); GPIO_DIG=0 x00;//blanking } }
CodePudding user response:
U8 keypro ()//button handler The returned to realize switching will have the same value? Very simple switch is set a Boolean variable bit k=0; Each time you press the button then invert, {char a=0; While (+ a + a==0 & amp; & ! K1); K=~ k; The return of k; } so logical thinking can be achieved, And then determine the logic of k value to carry out different events can,