-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdigitalclock.bsc
225 lines (168 loc) · 3.67 KB
/
digitalclock.bsc
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
uconfig 115200
buffer=alloc(500) :buflen=0
Dim digits$(11,5)
digits$(0,0) = "OOO"
digits$(0,1) = "O O"
digits$(0,2) = "O O"
digits$(0,3) = "O O"
digits$(0,4) = "OOO"
digits$(1,0) = "OO "
digits$(1,1) = " O "
digits$(1,2) = " O "
digits$(1,3) = " O "
digits$(1,4) = "OOO"
digits$(2,0) = "OOO"
digits$(2,1) = " O"
digits$(2,2) = "OOO"
digits$(2,3) = "O "
digits$(2,4) = "OOO"
digits$(3,0) = "OOO"
digits$(3,1) = " O"
digits$(3,2) = "OOO"
digits$(3,3) = " O"
digits$(3,4) = "OOO"
digits$(4,0) = "O O"
digits$(4,1) = "O O"
digits$(4,2) = "OOO"
digits$(4,3) = " O"
digits$(4,4) = " O"
digits$(5,0) = "OOO"
digits$(5,1) = "O "
digits$(5,2) = "OOO"
digits$(5,3) = " O"
digits$(5,4) = "OOO"
digits$(6,0) = "OOO"
digits$(6,1) = "O "
digits$(6,2) = "OOO"
digits$(6,3) = "O O"
digits$(6,4) = "OOO"
digits$(7,0) = "OOO"
digits$(7,1) = " O"
digits$(7,2) = " O"
digits$(7,3) = " O"
digits$(7,4) = " O"
digits$(8,0) = "OOO"
digits$(8,1) = "O O"
digits$(8,2) = "OOO"
digits$(8,3) = "O O"
digits$(8,4) = "OOO"
digits$(9,0) = "OOO"
digits$(9,1) = "O O"
digits$(9,2) = "OOO"
digits$(9,3) = " O"
digits$(9,4) = "OOO"
digits$(10,0) = " "
digits$(10,1) = " O "
digits$(10,2) = " "
digits$(10,3) = " O "
digits$(10,4) = " "
day$=""
mon$=""
daynum$=""
time$=""
year$=""
hours$=""
mins$=""
secs$=""
call serialsend("AT+CIPSNTPCFG=1,0,"+chr$(34)+"0.pool.ntp.org"+chr$(34))
call serialread( )
cls
while 1
call gettime()
call showtime()
wend
end
proc waitkey()
k$=""
while k$=""
k$=inkey$()
wend
endproc
proc serialread( )
while uhasdata( ) = 0
wait 1
wend
while uhasdata( ) = -1
ureceive buffer+buflen,1
buflen=buflen+1
wend
endproc
proc serialsend(st$ )
usend st$ +chr$(13) +chr$(10)
wait 50
endproc
proc gettime()
call serialsend( "AT+CIPSNTPTIME?")
call serialread( )
response$ = ""
for c = 0 to buflen
ch = peek(buffer+c)
response$ = response$ + chr$(ch)
next
firstcolon = instr(response$,":")+1
datestamp$ = mid$(response$,firstcolon)
cr = instr(datestamp$,chr$(13))
dateplustime$=mid$(datestamp$,1,cr)
sp = instr(dateplustime$,chr$(32))
day$=mid$(dateplustime$,1,sp-1)
remainder$=mid$(dateplustime$,sp+1)
sp = instr(remainder$,chr$(32))
mon$=mid$(remainder$,1,sp-1)
remainder$=mid$(remainder$,sp+1)
sp = instr(remainder$,chr$(32))
daynum$=mid$(remainder$,1,sp-1)
remainder$=mid$(remainder$,sp+1)
sp = instr(remainder$,chr$(32))
time$=mid$(remainder$,1,sp-1)
remainder$=mid$(remainder$,sp)
sp = instr(remainder$,chr$(32))
year$=mid$(remainder$,2,len(remainder$)-2)
hours$=mid$(time$,1,2)
mins$=mid$(time$,4,2)
secs$=mid$(time$,7,2)
buflen = 0
endproc
proc prdigit(digit, x, y)
cursor x,y
line$ = digits$(digit,0)
print line$;
cursor x,y+1
line$ = digits$(digit,1)
print line$;
cursor x,y+2
line$ = digits$(digit,2)
print line$;
cursor x,y+3
line$ = digits$(digit,3)
print line$;
cursor x,y+4
line$ = digits$(digit,4)
print line$;
endproc
proc showtime()
cursor 10,8
print day$ + " " + daynum$ + " " + mon$ + ", " + year$
y=10
x=10
digit = val(mid$(hours$,1,1))
call prdigit(digit,x,y)
x=x+4
digit = val(mid$(hours$,2,1))
call prdigit(digit,x,y)
x=x+4
call prdigit(10,x,y)
x=x+4
digit = val(mid$(mins$,1,1))
call prdigit(digit,x,y)
x=x+4
digit = val(mid$(mins$,2,1))
call prdigit(digit,x,y)
x=x+4
call prdigit(10,x,y)
x=x+4
digit = val(mid$(secs$,1,1))
call prdigit(digit,x,y)
x=x+4
digit = val(mid$(secs$,2,1))
call prdigit(digit,x,y)
endproc