$regfile = "m16def.dat" $crystal = 8000000 Config Graphlcd = 240 * 128 , Dataport = Porta , Controlport = Portc , Ce = 5 , Cd = 4 , Wr = 7 , Rd = 6 , Reset = 2 , Fs = 3 , Mode = 6 Config Scl = Portc.0 Config Sda = Portc.1 Const Ds1307w = &HD0 Const Ds1307r = &HD1 Const Aseconden = &H00 Const Aminuten = &H01 Const Auren = &H02 Const Control_addmap = &H07 Dim Uur As Byte Dim Mins As Byte Dim Secs As Byte Dim Sethour As Byte Dim Setmin As Byte Dim Setsecs As Byte Dim Uren As Byte Dim Minuten As Byte Dim Seconden As Byte Dim X As Integer , Y As Integer , V As Byte , Temp As Byte Dim Clockx As Byte , Clocky As Byte , Clockdiam As Byte Dim Xsecond As Single , Ysecond As Single Dim Cosangle As Single , Sinangle As Single , Angle_rad As Single Dim W As Single , Rad As Byte , Rad2 As Byte , Div As Byte , Colour As Byte On Int0 0int On Int1 1int Enable Int0 Enable Int1 Enable Interrupts I2cstart I2cwbyte Ds1307w I2cwbyte Aseconden I2cstop I2cstart I2cwbyte Ds1307r I2crbyte Seconden , Ack I2crbyte Minuten , Ack I2crbyte Uren , Nack I2cstop Uren = Uren And &B00111111 Uur = Makedec(uren) Mins = Makedec(minuten) Secs = Makedec(seconden) Setmin = Minuten Sethour = Uren Setsecs = Seconden Gosub Zetklok Setsecs = 0 Cursor Off Cls Wait 1 Clockdiam = 40 Clockx = 45 Clocky = 45 Circle(clockx , Clocky) , Clockdiam , 255 Do I2cstart I2cwbyte Ds1307w I2cwbyte Aseconden I2cstop I2cstart I2cwbyte Ds1307r I2crbyte Seconden , Ack I2crbyte Minuten , Ack I2crbyte Uren , Nack I2cstop Uren = Uren And &B00111111 Uur = Makedec(uren) Mins = Makedec(minuten) Secs = Makedec(seconden) Temp = Secs - 1 If Secs = 0 Then Temp = 59 Rad = Clockdiam - 2 Div = 6 Colour = 0 Gosub Drawsec Temp = Secs Colour = 1 Gosub Drawsec Temp = Mins - 1 If Mins = 0 Then Temp = 59 Rad = Clockdiam - 4 Div = 6 Colour = 0 Gosub Draw Temp = Mins Colour = 255 Gosub Draw Temp = Uur - 1 Rad = Clockdiam / 2 Div = 30 Colour = 0 Gosub Draw Temp = Uur Colour = 255 Gosub Draw Loop End 0int: Sethour = Uur + 1 Gosub Zetklok Waitms 75 Return 1int: Setmin = Mins + 1 Gosub Zetklok Waitms 75 Return Draw: W = Temp * Div Angle_rad = Deg2rad(w) Sinangle = Sin(angle_rad) : Cosangle = Cos(angle_rad) W = Rad * Sinangle ' X of hand Xsecond = Clockx + W W = Rad * Cosangle ' Y of the hand Ysecond = Clocky - W Xsecond = Round(xsecond) : Ysecond = Round(ysecond) X = Int(xsecond) : Y = Int(ysecond) Line(clockx , Clocky) -(x , Y) , Colour Return Drawsec: W = Temp * Div Angle_rad = Deg2rad(w) Sinangle = Sin(angle_rad) : Cosangle = Cos(angle_rad) W = Rad * Sinangle ' X of hand Xsecond = Clockx + W W = Rad * Cosangle ' Y of the hand Ysecond = Clocky - W Xsecond = Round(xsecond) : Ysecond = Round(ysecond) X = Int(xsecond) : Y = Int(ysecond) Pset X , Y , Colour Return Zetklok: Temp = Makebcd(setsecs) I2cstart I2cwbyte Ds1307w I2cwbyte Aseconden I2cwbyte Temp I2cstop Temp = Makebcd(setmin) I2cstart I2cwbyte Ds1307w I2cwbyte Aminuten I2cwbyte Temp I2cstop Temp = Makebcd(sethour) Reset Temp.6 I2cstart I2cwbyte Ds1307w I2cwbyte Auren I2cwbyte Temp I2cstop I2cstart I2cwbyte Ds1307w I2cwbyte Control_addmap I2cwbyte &B10010000 I2cstop Return