DaveJacko Senior Member
 Joined: 25/07/2019 Location: United KingdomPosts: 105 |
| Posted: 09:06pm 05 Jul 2024 |
|
|
|
I don't believe it needs accurate timing,
I've tried with a pause 0.1 after every every level change, ( clk and dat, up or down ), pico versions just light the wrong segments, same wrong segments every time.
Palcal.. I've attached my code (inspired by Peter) for the Micromite, works fine, no delays per se so probs way too fast..
' Clock demo 7 seg driver ' ok with pic pullup ' Dave J 2020
Option autorun on dat=18 'pinout clk=17 init
mnlp: Pause 500 colon=colon Xor &H80
start wrtb(&H40) 'comm1 stop
start wrtb(&HC0) 'comm2 wrtb(dgt%(Asc(Mid$(Time$,4,1))-48)) wrtb(dgt%(Asc(Mid$(Time$,5,1))-48)Or colon) wrtb(dgt%(Asc(Mid$(Time$,7,1))-48)) wrtb(dgt%(Asc(Mid$(Time$,8,1))-48)) stop
GoTo mnlp
'------------------- subs
Sub wrtb(b As integer) '--- write byte tb=b For i=0 To 7 SetPin clk,dout 'clk lo
If (tb And 1) Then 'set bit SetPin dat,din Else SetPin dat,dout EndIf
SetPin clk, din 'clk hi tb= tb >> 1 Next i
SetPin clk, dout 'clk lo SetPin dat, din 'release dat SetPin clk, din 'clk hi 'check ack here? SetPin clk, dout 'clk lo
End Sub
Sub start '-------- start SetPin dat,dout 'dat lo End Sub
Sub stop '--- stop SetPin dat, dout 'dat lo SetPin clk, din ' clk hi ' SetPin dat, din ' dat hi End Sub
Sub init '---- initialise TM1637
Pin(dat)=0 Pin(clk)=0 SetPin dat,din,pullup SetPin clk,din,pullup Dim dgt%(9)=(&H3F,&H06,&H5B,&H4F,&H66,&H6D,&H7D,&H07,&H7F,&H6F) ' ,&H77,&H7C,&H39,&H5E,&H79,&H71) 'A..F ' degree symbol is &H63, C is &H39 ' colon - or 2nd digit with &H80 start 'reset, enab(8)+brightness wrtb(&H80+8+7) '0=dim stop
End Sub
|