-
Notifications
You must be signed in to change notification settings - Fork 0
/
screen.spin
336 lines (294 loc) · 6.13 KB
/
screen.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
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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
CON
_clkmode=xtal1+pll16x
_xinfreq=5_000_000
gpsDataCache=$2FAF0 '100 megs into the card
obj
serial : "Simple_Serial"
SN : "Simple_Numbers"
Str : "STRINGS2"
TC : "TrackBallEx"
conf :"Config"
'All of this could probably use a refactoring, but not sure if worth the effort. have a deadline
pub Init
serial.init(4,5,9600)
pub ShowVideo
MediaInit
serial.tx($FF)
serial.tx($BB)
serial.tx($00)
serial.tx($00)
serial.tx($00)
serial.tx($00)
WaitForComplete
pub MediaInit
serial.tx($FF)
serial.tx($B1)
WaitForComplete
pub Print(data)
serial.tx($00)
serial.tx($06)
serial.str(data)
'null terminate this bitch
serial.tx($00)
WaitForComplete
pub FadeOut| contrastNum
contrastNum:=15
repeat while contrastNum > -1
Contrast(contrastNum)
contrastNum:=contrastNum-1
waitcnt(clkfreq/8000+cnt)
pub FadeIn| contrastNum
contrastNum:=0
repeat while contrastNum < 16
Contrast(contrastNum)
contrastNum:=contrastNum+1
waitcnt(clkfreq/8000+cnt)
pub Off
Contrast(0)
pub On
Contrast(15)
pub Contrast(num)
serial.tx($FF)
serial.tx($66)
serial.tx(00)
serial.tx(num)
WaitForComplete
pub Clear
serial.tx($FF)
serial.tx($D7)
WaitForComplete
pub FontSize(size)
'any int from 1-16
if size <1 or size >16
size:=1
serial.tx($FF)
serial.tx($7B)
serial.tx(00)
serial.tx(size)
WaitForComplete
serial.tx($FF)
serial.tx($7C)
serial.tx($00)
serial.tx(size)
WaitForComplete
pub Position(line,col)
serial.tx($FF)
serial.tx($E4)
serial.tx(00)
serial.tx(line)
serial.tx(00)
serial.tx(col)
WaitForComplete
pub TxtColor(hexPart1,hexPart2)
serial.tx($FF)
serial.tx($7F)
serial.tx(hexPart1)
serial.tx(hexPart2)
WaitForComplete
pub ShowFrame(frameNum)
'MediaInit
serial.tx($FF)
serial.tx($BA)
'x
serial.tx(00)
serial.tx(00)
'y
serial.tx(00)
serial.tx(00)
'frame
serial.tx(00)
serial.tx(frameNum)
WaitForComplete
'disable txt background or not. must be 1 or 0
pub TxtTrans(bool)
serial.tx($FF)
serial.tx($77)
serial.tx(00)
serial.tx(bool)
WaitForComplete
pub DisplayImage
MediaInit
serial.tx($FF)
serial.tx($B3)
'x
serial.tx(00)
serial.tx(00)
'y
serial.tx(00)
serial.tx(00)
WaitForComplete
pub Beep|note1,note2,lastRun
note1:=$40
note2:=$13
lastRun:=2
repeat
serial.tx($FF)
serial.tx($DA)
'note
serial.tx(00)
case lastRun
1:
serial.tx(note2)
lastRun:=2
2:
serial.tx(note1)
lastRun:=1
'duration
serial.tx($03)
serial.tx($E8)'one sec
WaitForComplete
TC.Run
if TC.isPressed ==true
TC.WaitForBtnPress
return
pub Click
serial.tx($FF)
serial.tx($DA)
serial.tx($00)
serial.tx($00)'note
serial.tx($00)
serial.tx($0A)'10 mili sec
WaitForComplete
pub SoundNotifiy
serial.tx($FF)
serial.tx($DA)
serial.tx($00)
serial.tx($2D)'note
serial.tx($03)
serial.tx($E8)'10 mili sec
WaitForComplete
pub DrawRec(X1,Y1,X2,Y2,colorHex1,colorHex2)
serial.tx($FF)
serial.tx($CF)
'X1
serial.tx($00)
serial.tx(X1)
'Y1
serial.tx($00)
serial.tx(Y1)
'X2
serial.tx($00)
serial.tx(X2)
'Y2
serial.tx($00)
serial.tx(Y2)
'Color
serial.tx(colorHex1)
serial.tx(colorHex2)
WaitForComplete
pub ChangeColor(oldColor1,oldColor2,newColor1,newColor2)
serial.tx($FF)
serial.tx($BE)
serial.tx(oldColor1)
serial.tx(oldColor2)
serial.tx(newColor1)
serial.tx(newColor2)
WaitForComplete
pub SetByteAddr(High1,High2,Low1,Low2)
serial.tx($FF)
serial.tx($B9)
serial.tx(High1)
serial.tx(High2)
serial.tx(Low1)
serial.tx(Low2)
WaitForComplete
pub SetSectorAddr(High1,High2,Low1,Low2)
serial.tx($FF)
serial.tx($B8)
serial.tx(High1)
serial.tx(High2)
serial.tx(Low1)
serial.tx(Low2)
WaitForComplete
pub TxtBackColor(hex1,hex2)
serial.tx($FF)
serial.tx($7E)
serial.tx(hex1)
serial.tx(hex2)
WaitForComplete
pub DrawTri(X1,Y1,X2,Y2,X3,Y3,color1,color2)
serial.tx($FF)
serial.tx($C9)
serial.tx($00)
serial.tx(X1)
serial.tx($00)
serial.tx(Y1)
serial.tx($00)
serial.tx(X2)
serial.tx($00)
serial.tx(Y2)
serial.tx($00)
serial.tx(X3)
serial.tx($00)
serial.tx(Y3)
serial.tx(color1)
serial.tx(color2)
WaitForComplete
pub SetSectorGPS
SetByteAddr(conf.GPS(0),conf.GPS(1),conf.GPS(2),conf.GPS(3))
pub SetSectorGPSMap
SetByteAddr(conf.GPSMap(0),conf.GPSMap(1),conf.GPSMap(2),conf.GPSMap(3))
pub SetSectorCal0
SetByteAddr(conf.Cal0(0),conf.Cal0(1),conf.Cal0(2),conf.Cal0(3))
pub SetSectorCal1
SetByteAddr(conf.Cal1(0),conf.Cal1(1),conf.Cal1(2),conf.Cal1(3))
pub SetSectorCal2
SetByteAddr(conf.Cal2(0),conf.Cal2(1),conf.Cal2(2),conf.Cal2(3))
pub SetSectorCal3
SetByteAddr(conf.Cal3(0),conf.Cal3(1),conf.Cal3(2),conf.Cal3(3))
pub SetSectorCal4
SetByteAddr(conf.Cal4(0),conf.Cal4(1),conf.Cal4(2),conf.Cal4(3))
'ONLY CALL AFTER SET SECTOR COMMAND!
'for set, take size in bytes, pad with 512ish (leftover sector) add next item
'512 sector size
pub SaveStr(data)|count
repeat strsize(data)
WriteByte(byte[data++])
pub flush
serial.tx($FF)
serial.tx($B2)
WaitForComplete
WaitForComplete
WaitForComplete
pub ReadByteAsString
serial.tx($FF)
serial.tx($B7)
' Print(SN.hex(WaitForComplete,2))'general ok
' Print(SN.hex(WaitForComplete,2))'data1
' Print(SN.hex(WaitForComplete,2))'data2
if serial.rx ==$06
serial.rx
return SN.hex(serial.rx,2)
else
return string("IO Error")
pub ReadByte
serial.tx($FF)
serial.tx($B7)
' Print(SN.hex(WaitForComplete,2))'general ok
' Print(SN.hex(WaitForComplete,2))'data1
' Print(SN.hex(WaitForComplete,2))'data2
if serial.rx ==$06
serial.rx
return serial.rx
else
return string("IO Error")
pub WriteByte(char)| retval1,retval2,retval3
if char <> 0
serial.tx($FF)
serial.tx($B5)
serial.tx($00)
serial.tx(char)
'if serial.rx ==$06
'serial.rx
'Print(SN.hex(serial.rx,2))
retval1:=WaitForComplete
retval2:=WaitForComplete
retval3:=WaitForComplete
' Print(SN.hex(char,2))
' Print(SN.hex(retval1,2))
' Print(SN.hex(retval2,2))
' Print(SN.hex(retval3,2))
else
Print(string("nulled out"))
pri WaitForComplete
return serial.rx