/
newhaven.h
740 lines (638 loc) · 14.1 KB
/
newhaven.h
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
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
/**
* @file newhaven.h
* @brief Interface New Haven Display
* @author Michael Burmeister
* @date July 30, 2018
* @version 1.2
*
*/
#include "libnewhaven/newhavenreg.h"
/**
* @details Set Display pins used
* @param CS - chip select
* @param MOSI - master out slave in
* @param MISO - master in slave out
* @param SCLK - slave clock
* @param POWER - power down
* @return value
*/
unsigned char openNewHaven(char CS, char MOSI, char MISO, char SCLK, char POWER) __fromfile("libnewhaven/newhaven.c");
/**
*@details read display panel id 7C
*@return ID
*/
unsigned char readID(void);
/**
*@details get command free space
*@return bytes free
*/
int cmdFree(void);
/**
*@details make display list active
*/
void DoList(void);
/**
*@brief setup display values
*@param horizontal 800
*@param vertical 480
*/
void setDisplay(int horizontal, int vertical);
/**
*@brief set GPIO direction
*@param GPIO
*@param DIRECTION
*/
void GPIODir(unsigned char GPIO, unsigned char DIRECTION);
/**
*@brief set GPIO state
*@param GPIO
*@param STATE
*/
void setGPIO(unsigned char GPIO, unsigned char STATE);
/**
*@brief get GPIO state
*@param GPIO
*@return state pin state
*/
unsigned char getGPIO(unsigned char GPIO);
/**
*@brief set background light value 0 - 128
*@param intensity
*/
void setBrightness(unsigned char intensity);
/**
*@brief set display rotation
*@param orientation
*/
void setRotation(unsigned char orientation);
/**
*@brief send coprocessor instructions
*@param instruction for coprocessor
*/
int cmd(unsigned int instruction);
/**
*@brief send clear coprocessor instruction
*@param color clear color if 1
*@param stencil clear stencil if 1
*@param tag clear tag buffer if 1
*@return instruction
*/
unsigned int CLEAR(char color, char stencil, char tag);
/**
*@brief send display coprocessor instruction
*@return display instruction code
*/
unsigned int DISPLAY(void);
/**
*@brief send clear color coprocessor instruction
*@param Red color value
*@param Green color value
*@param Blue color value
*@return clear color instruction code
*/
unsigned int CLEAR_COLOR_RGB(unsigned char Red, unsigned char Green, unsigned char Blue);
/**
*@brief build begin co-processor instruction
*@param graphics primitive
*@return begin instruction code
*/
unsigned int BEGIN(unsigned char graphics);
/**
*@brief build color coprocessor instruction
*@param Red
*@param Green
*@param Blue
*@return Color instruction code
*/
unsigned int COLOR_RGB(unsigned char Red, unsigned char Green, unsigned char Blue);
/**
*@brief build point size coprocessor instruction
*@param point size in 16ths
*@return point size instruction code
*/
unsigned int POINT_SIZE(short point);
/**
*@brief build vertex2ii coprocessor instruction
*@param x axis value
*@param y axis value
*@param bit map handle
*@param cell number
*@return vertex2ii instruction code
*/
unsigned int VERTEX2II(short x, short y, unsigned char bit, unsigned char cell);
/**
*@brief set x vertex offset
*@param offset value in 16ths
*@return offset instruction code
*/
unsigned int VERTEX_TRANSLATE_X(short offset);
/**
*@brief set y vertex offset
*@param offset value in 16ths
*@return offset instruction code
*/
unsigned int VERTEX_TRANSLATE_Y(short offset);
/**
*@brief build end coprocessor instruction
*@return end instruction code
*/
unsigned int END(void);
/**
*@brief build vertex2f coprocessor instruction
*@param x axis
*@param y axis
*@return vertex2f instruction code
*/
unsigned int VERTEX2F(short x, short y);
/**
*@brief set line width for drawing
*@param width of line
*@return line width instruction code
*/
unsigned int LINE_WIDTH(short width);
/**
*@brief set palette source
*@param source address
*@return palette source instruction code
*/
unsigned int PALETTE_SOURCE(int source);
/**
*@brief restore context
*@return restore context instruction code
*/
unsigned int RESTORE_CONTEXT(void);
/**
*@brief return from call
*@return return instruction code
*/
unsigned int RETURN(void);
/**
*@brief save current context
*@return save context instruction code
*/
unsigned int SAVE_CONTEXT(void);
/**
*@brief set scissor size
*@param width
*@param height
*@return scissor size instruction code
*/
unsigned int SCISSOR_SIZE(int width, int height);
/**
*@brief set scissor location
*@param x
*@param y
*@return scissor x y instruction code
*/
unsigned int SCISSOR_XY(int x, int y);
/**
*@brief alpha test function
*@param function value
*@param reference value
*@return alpha function instruction code
*/
unsigned int ALPHA_FUNC(short function, short reference);
/**
*@brief bitmap handle
*@param handle
*@return bitmap handle instruction code
*/
unsigned int BITMAP_HANDLE(short handle);
/**
*@brief bitmap layout
*@param format
*@param linestride
*@param height
*@return bitmap handle instructin code
*/
unsigned int BITMAP_LAYOUT(short format, short linestride, short height);
/**
*@brief bitmap layout h
*@param linestride
*@param height
*@return bitmap layout h instruction code
*/
unsigned int BITMAP_LAYOUT_H(unsigned char linestride, unsigned char height);
/**
*@brief bitmap size
*@param filter
*@param wrapx
*@param wrapy
*@param width
*@param height
*@return bitmap size instruction code
*/
unsigned int BITMAP_SIZE(unsigned char filter, unsigned char wrapx, unsigned char wrapy, short width, short height);
/**
*@brief bitmap size h
*@param width
*@param height
*@return bitmap size h instruction code
*/
unsigned int BITMAP_SIZE_H(unsigned char width, unsigned char height);
/**
*@brief bitmap source
*@param address
*@return bitmap source instruction code
*/
unsigned int BITMAP_SOURCE(int address);
/**
*@brief bitmap transform a coefficient
*@param coefficient
*@return bitmap transform a instruction code
*/
unsigned int BITMAP_TRANSFORM_A(unsigned short coefficient);
/**
*@brief bitmap transform b coefficient
*@param coefficient
*@return bitmap transform b instruction code
*/
unsigned int BITMAP_TRANSFORM_B(unsigned short coefficient);
/**
*@brief bitmap transform c coefficient
*@param coefficient
*@return bitmap transform c instruction code
*/
unsigned int BITMAP_TRANSFORM_C(unsigned int coefficient);
/**
*@brief bitmap transform d coefficient
*@param coefficient
*@return bitmap transform d instruction code
*/
unsigned int BITMAP_TRANSFORM_D(unsigned short coefficient);
/**
*@brief bitmap transform e coefficient
*@param coefficient
*@return bitmap transform e instruction code
*/
unsigned int BITMAP_TRANSFORM_E(unsigned short coefficient);
/**
*@brief bitmap transform f coefficient
*@param coefficient
*@return bitmap transform f instruction code
*/
unsigned int BITMAP_TRANSFORM_F(unsigned int coefficient);
/**
*@brief blend function
*@param source
*@param destination
*@return blend function instruction code
*/
unsigned int BLEND_FUNC(unsigned char source, unsigned char destination);
/**
*@brief call
*@param address
*@return call instruction code
*/
unsigned int CALL(unsigned short address);
/**
*@brief cell
*@param cell
*@return cell instruction code
*/
unsigned int CELL(unsigned char cell);
/**
*@brief clear color alpha
*@param alpha
*@return clear color alpha instruction code
*/
unsigned int CLEAR_COLOR_A(unsigned char alpha);
/**
*@brief clear stencil buffer value
*@param stencil
*@return clear stencil instruction code
*/
unsigned int CLEAR_STENCIL(unsigned char stencil);
/**
*@brief clear tag buffer value
*@param tag
*@return clear tag instruction code
*/
unsigned int CLEAR_TAG(unsigned char tag);
/**
*@brief color alpha value
*@param color
*@return color alpha instruction code
*/
unsigned int COLOR_A(unsigned char color);
/**
*@brief color mask
*@param red
*@param green
*@param blue
*@param alpha
*@return color mask instruction code
*/
unsigned int COLOR_MASK(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha);
/**
*@brief jump
*@param address
*@return jump instruction code
*/
unsigned int JUMP(unsigned short address);
/**
*@brief macro register
*@param register
*@return macro instruction code
*/
unsigned int MACRO(unsigned char register);
/**
*@brief nop
*@return nop instruction code
*/
unsigned int NOP(void);
/**
*@brief stencil function
*@param function
*@param reference
*@param mask
*@return stencil instruction code
*/
unsigned int STENCIL_FUNC(unsigned char function, unsigned char reference, unsigned char mask);
/**
*@brief stencil mask
*@param mask
*@return stencil mask instruction code
*/
unsigned int STENCIL_MASK(unsigned char mask);
/**
*@brief stencil opperation
*@param fail
*@param pass
*@return stencil op instruction code
*/
unsigned int STENCIL_OP(unsigned char fail, unsigned char pass);
/**
*@brief tag mask
*@param mask
*@return tag mask instruction code
*/
unsigned int TAG_MASK(unsigned char mask);
/**
*@brief vertex format
*@param fraction
*@return vertex format instruction code
*/
unsigned int VERTEX_FORMAT(unsigned char fraction);
/**
*@brief macro 0
*@param instruction code
*/
void MACRO_0(unsigned int instruction);
/**
*@brief macro 1
*@param instruction code
*/
void MACRO_1(unsigned int instruction);
/**
*@brief build Button object
*@param x
*@param y
*@param width
*@param height
*@param font
*@param option
*@param string
*/
void CMD_BUTTON(short x, short y, short width, short height, short font, short option, char *string);
/**
*@brief write Text string
*param x
*param y
*param font
*param option
*param string
*/
void CMD_TEXT(short x, short y, short font, short option, char *string);
/**
*@brief draw clock face
*@param x
*@param y
*@param radius
*@param options
*@param hours
*@param minutes
*@param seconds
*@param miliseconds
*/
void CMD_CLOCK(short x, short y, short radius, short options, short hours, short minutes, short seconds, short miliseconds);
/**
*@brief set background color
*@param color rgb color value
*/
void CMD_BGCOLOR(int color);
/**
*@brief set foreground color
*@param color
*/
void CMD_FGCOLOR(int color);
/**
*@brief load rom font
*@param font
*@param romslot
*/
void CMD_ROMFONT(unsigned char font, unsigned char romslot);
/**
*@brief draw gauge
*@param x
*@param y
*@param radius
*@param options
*@param major
*@param minor
*@param val
*@param range
*/
void CMD_GAUGE(short x, short y, short radius, short options, short major, short minor, short val, short range);
/**
*@brief gradent color
*@param color
*/
void CMD_GRADCOLOR(short color);
/**
*@brief wait for co-processor
*@return
*/
void Wait(void);
/**
*@brief draw prograss bar
*@param x
*@param y
*@param width
*@param height
*@param options
*@param value
*@param range
*/
void CMD_PROGRESS(short x, short y, short width, short height, short options, short value, short range);
/**
*@brief draw scroll bar
*@param x
*@param y
*@param width
*@param height
*@param options
*@param value
*@param size
*@param range
*/
void CMD_SCROLLBAR(short x, short y, short width, short height, short options, short value, short size, short range);
/**
*@brief draw slider
*@param x
*@param y
*@param width
*@param height
*@param options
*@param value
*@param range
*/
void CMD_SLIDER(short x, short y, short width, short height, short options, short value, short range);
/**
*@brief draw dial control
*@param x
*@param y
*@param radius
*@param option
*@param value
*/
void CMD_DIAL(short x, short y, short radius, short option, short value);
/**
*@brief draw toggle control
*@param x
*@param y
*@param width
*@param font
*@param options
*@param state
*@param string text to display
*/
void CMD_TOGGLE(short x, short y, short width, short font, short options, short state, char* string);
/**
*@brief set number base
*@param base number base 10, 16, 8
*/
void CMD_SETBASE(int base);
/**
*@brief display number
*@param x
*@param y
*@param font
*@param options
*@param value
*/
void CMD_NUMBER(short x, short y, short font, short options, int value);
/**
*@brief draw command keys
*@param x
*@param y
*@param width of keys
*@param height of keys
*@param font number
*@param options key pressed
*@param keys string
*/
void CMD_KEYS(short x, short y, short width, short height, short font, short options, char *keys);
/**
*@brief draw spinner
*@param x
*@param y
*@param style
*@param scale
*/
void CMD_SPINNER(short x, short y, short style, short scale);
/**
*@brief sketch input
*@param x
*@param y
*@param width
*@param height
*@param pointer
*@param format
*/
void CMD_SKETCH(short x, short y, short width, short height, int pointer, short format);
/**
*@brief touch screen cordinates
*@return xy cordinates
*/
int TouchScreen(void);
/**
*@brief touch tag
*@return tag value
*/
unsigned char TouchTag(void);
/**
*@brief set tag value
*@param tag object tag value
*/
unsigned int TAG(unsigned char tag);
/**
*@brief get tracker value
*@return value
*/
unsigned int Tracker(void);
/**
*@brief start tracking area
*@param x
*@param y
*@param width
*@param height
*@param tag
*/
void CMD_TRACK(short x, short y, short width, short height, short tag);
/**
*@brief dump commands
*/
void DumpCmd(void);
/**
*@brief dump display screen instruction codes
*/
void DumpDL(void);
/**
*@brief send host commands
*@param function value
*/
void HostCommand(unsigned char function);
/**
*@brief write dl instruction using _Dl offset
*@param instruction
*@return next address
*/
short dl(unsigned int instruction);
/**
*@brief clear Dl pointer
*/
void ClearDL(void);
/**
*@brief read byte from memory area
*@param address
*@return data
*/
unsigned char readMemory(unsigned int address);
/**
*@brief read 4 bytes from memory area
*@param address
*@return data
*/
unsigned int readMemory32(unsigned int address);
/**
*@brief write byte to memory area
*@param address
*@param data
*/
void writeMemory(unsigned int address, unsigned char data);
/**
*@brief write 4 bytes to memory area
*@param address
*@param data
*/
void writeMemory32(unsigned int address, unsigned int data);
/**
*@brief SPI Read Write Functions
*/
unsigned char _read8(unsigned int);
void _write8(int, unsigned char);
short _read16(unsigned int);
void _write16(int, int);
int _read32(unsigned int);
void _write32(int, int);