-
Notifications
You must be signed in to change notification settings - Fork 0
/
Edit.spin
151 lines (139 loc) · 3.5 KB
/
Edit.spin
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
CON
_clkmode=xtal1+pll16x
_xinfreq=5_000_000
right=1
left=0
obj
SC : "screen"
SN : "Simple_Numbers"
Rtc: "DS1302"
TC : "trackBallEx"
Conver: "Converter"
pub main | hour,minute, currentPosition,day,month,year,timeOk,datePOS
SC.Init
SC.clear
hour:=12
minute:=0
day:=1
month:=1
year:=0
timeOk:=false
SC.DrawTri($2F,$5A,$1F,$66,$3F,$66,$F8,$00)
currentPosition:=left
DrawTime(hour,minute)
waitcnt(clkfreq+cnt)
repeat until timeOk==true
TC.Run
if TC.isPressed ==true
timeOk:=true
repeat until TC.isPressed==false
TC.Run
if TC.isRight
'clear old Tri
SC.DrawTri($2F,$5A,$1F,$66,$3F,$66,$00,$00)
SC.DrawTri($6E,$5A,$5E,$66,$7E,$66,$F8,$00)
currentPosition:=right
if TC.isLeft
'clear old Tri
SC.DrawTri($2F,$5A,$1F,$66,$3F,$66,$F8,$00)
SC.DrawTri($6E,$5A,$5E,$66,$7E,$66,$00,$00)
currentPosition:=left
if TC.isUp ==true
case currentPosition
left: hour:=hour+1
right: minute:=minute+1
EnsureBoundries(@hour,@minute)
DrawTime(hour,minute)
if TC.isDown ==true
case currentPosition
left: hour:=hour-1
right: minute:=minute-1
EnsureBoundries(@hour,@minute)
DrawTime(hour,minute)
' waitcnt(clkfreq+cnt)
'Date set loop
SC.Clear
SC.DrawTri($28,$5A,$18,$66,$38,$66,$F8,$00)
datePOS:=0
DrawDate(day,month,year)
repeat until TC.isPressed==true
TC.Run
if TC.isRight ==true
case datePOS
0:
SC.DrawTri($28,$5A,$18,$66,$38,$66,$00,$00)
SC.DrawTri($50,$5A,$40,$66,$60,$66,$F8,$00)
datePOS:=1
1:
SC.DrawTri($50,$5A,$40,$66,$60,$66,$00,$00)
SC.DrawTri($7D,$5A,$6D,$66,$8D,$66,$F8,$00)
datePOS:=2
if TC.isLeft ==true
case datePOS
1:
SC.DrawTri($50,$5A,$40,$66,$60,$66,$00,$00)
SC.DrawTri($28,$5A,$18,$66,$38,$66,$F8,$00)
datePOS:=0
2:
SC.DrawTri($50,$5A,$40,$66,$60,$66,$F8,$00)
SC.DrawTri($7D,$5A,$6D,$66,$8D,$66,$00,$00)
datePOS:=1
if TC.isUp == true
case datePOS
0: month:=month+1
1: day:=day+1
2: year:=year+1
EnsureDateBoundries(@year,@day,@month)
DrawDate(day,month,year)
if TC.isDown ==true
case datePOS
0: month:=month-1
1: day:=day-1
2: year:=year-1
EnsureDateBoundries(@year,@day,@month)
DrawDate(day,month,year)
SetClock(month,day,year,hour,minute,0)
return 1
pri DrawTime(hour,minute)
SC.FontSize(0)
SC.TxtColor($FF,$E0)
SC.Position(7,4)
SC.FontSize(3)
SC.Print(SN.decx(hour,2))
SC.Print(string(":"))
SC.Print(SN.decx(minute,2))
pri EnsureBoundries(hour,minute)
if long[hour] > 24
long[hour]:=00
if long[hour] <0
long[hour]:=24
if long[minute] > 60
long[minute]:=00
if long[minute] <0
long[minute]:=60
pri EnsureDateBoundries(year,day,month)
if long[year] < 0
long[year]:=0
if long[day] > 31
long[day]:=1
if long[day]<1
long[day]:=31
if long[month] > 12
long[month]:=1
if long[month] < 1
long[month]:=12
pri DrawDate(day,month,year)
SC.FontSize(0)
' SC.TxtColor($FF,$E0)
SC.Position(7,4)
SC.FontSize(2)
SC.Print(SN.decx(month,2))
SC.Print(string("/"))
SC.Print(SN.decx(day,2))
SC.Print(string("/"))
SC.Print(SN.decx(year,2))
pri SetClock(month,day,year,hour,minute,second)| dow
rtc.init(17,16,18)
rtc.config
dow:=Conver.DateToDOW(month,day,year)
rtc.setDatetime(month,day,year,dow,hour,minute,second)