forked from garretlab/GOLDELOX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GOLDELOX.h
211 lines (184 loc) · 7.82 KB
/
GOLDELOX.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
#ifndef GOLDELOX_H
#define GOLDELOX_H
#include <stdint.h>
class Stream;
#define GOLDELOX_CMD_MOVE_CURSOR 0xffe4
#define GOLDELOX_CMD_PUT_CHARACTER 0xfffe
#define GOLDELOX_CMD_PUT_STRING 0x0006
#define GOLDELOX_CMD_CHARACTER_WIDTH 0x0002
#define GOLDELOX_CMD_CHARACTER_HEIGHT 0x0001
#define GOLDELOX_CMD_TEXT_FOREGROUND_COLOR 0xff7f
#define GOLDELOX_CMD_TEXT_BACKGROUND_COLOR 0xff7e
#define GOLDELOX_CMD_SET_FONT 0xff7d
#define GOLDELOX_CMD_TEXT_WIDTH 0xff7c
#define GOLDELOX_CMD_TEXT_HEIGHT 0xff7b
#define GOLDELOX_CMD_TEXT_X_GAP 0xff7a
#define GOLDELOX_CMD_TEXT_Y_GAP 0xff79
#define GOLDELOX_CMD_TEXT_BOLD 0xff76
#define GOLDELOX_CMD_TEXT_INVERSE 0xff74
#define GOLDELOX_CMD_TEXT_ITALIC 0xff75
#define GOLDELOX_CMD_TEXT_OPACITY 0xff77
#define GOLDELOX_CMD_TEXT_UNDERLINE 0xff73
#define GOLDELOX_CMD_TEXT_ATTRIBUTES 0xff72
#define GOLDELOC_CMD_SET_TEXT_PARAMETERS 0xffe3
#define GOLDELOX_CMD_CLEAR_SCREEN 0xffd7
#define GOLDELOX_CMD_CHANGE_COLOR 0xffbe
#define GOLDELOX_CMD_DRAW_CIRCLE 0xffcd
#define GOLDELOX_CMD_DRAW_FILLED_CIRCLE 0xffcc
#define GOLDELOX_CMD_DRAW_LINE 0xffd2
#define GOLDELOX_CMD_DRAW_RECTANGLE 0xffcf
#define GOLDELOX_CMD_DRAW_FILLED_RECTANGLE 0xffce
#define GOLDELOX_CMD_DRAW_POLYLINE 0x0005
#define GOLDELOX_CMD_DRAW_POLYGON 0x0004
#define GOLDELOX_CMD_DRAW_TRIANGLE 0xffc9
#define GOLDELOX_CMD_CALCULATE_ORBIT 0x0003
#define GOLDELOX_CMD_PUT_PIXEL 0xffcb
#define GOLDELOX_CMD_READ_PIXEL 0xffca
#define GOLDELOX_CMD_MOVE_ORIGIN 0xffd6
#define GOLDELOX_CMD_DRAW_LINE_AND_MOVE_ORIGIN 0xffd4
#define GOLDELOX_CMD_CLIPPING 0xff6c
#define GOLDELOX_CMD_SET_CLIP_WINDOW 0xffbf
#define GOLDELOX_CMD_EXTEND_CLIP_REGION 0xffbc
#define GOLDELOX_CMD_BACKGROUND_COLOR 0xff6e
#define GOLDELOX_CMD_OUTLINE_COLOR 0xff67
#define GOLDELOX_CMD_CONTRAST 0xff66
#define GOLDELOX_CMD_FRAME_DELAY 0xff69
#define GOLDELOX_CMD_LINE_PATTERN 0xff65
#define GOLDELOX_CMD_SCREEN_MODE 0xff68
#define GOLDELOX_CMD_SET_GRAPHICS_PARAMETERS 0xffd8
#define GOLDELOX_CMD_MEDIA_INIT 0xffb1
#define GOLDELOX_CMD_SET_BYTE_ADDRESS 0xffb9
#define GOLDELOX_CMD_SET_SECTOR_ADDRESS 0xffb8
#define GOLDELOX_CMD_READ_BYTE 0xffb7
#define GOLDELOX_CMD_READ_WORD 0xffb6
#define GOLDELOX_CMD_WRITE_BYTE 0xffb5
#define GOLDELOX_CMD_WRITE_WORD 0xffb4
#define GOLDELOX_CMD_FLUSH_MEDIA 0xffb2
#define GOLDELOX_CMD_DISPLAY_IMAGE_RAW 0xffb3
#define GOLDELOX_CMD_DISPLAY_VIDEO_RAW 0xffbb
#define GOLDELOX_CMD_DISPLAY_VIDEO_FRAME_RAW 0xffba
#define GOLDELOX_CMD_BEEP 0xffda
#define GOLDELOX_CMD_GET_DISPLAY_MODEL 0x0007
#define GOLDELOX_CMD_SCREEN_SAVER_TIMEOUT 0x000c
#define GOLDELOX_CMD_SCREEN_SAVER_SPEED 0x000d
#define GOLDELOX_RESPONSE_ACK 0x06
#define GOLDELOX_SYSTEM_FONT 0x00
#define GOLDELOX_MEDIA_FONT 0x07
#define GOLDELOX_TEXT_BOLD 0x10
#define GOLDELOX_TEXT_ITALIC 0x20
#define GOLDELOX_TEXT_INVERSE 0x40
#define GOLDELOX_TEXT_UNDERLINED 0x80
#define GOLDELOX_TEXT_PRINT_DELAY 0x07
#define GOLDELOX_CLIPPING_DISABLED 0x00
#define GOLDELOX_CLIPPING_ENABLED 0x01
#define GOLDELOX_LANDSCAPE 0x01
#define GOLDELOX_LANDSCAPE_REVERSE 0x02
#define GOLDELOX_PORTRAIT 0x03
#define GOLDELOX_PORTRAIT_REVERSE 0x04
#define GOLDELOX_PEN_SIZE 0x00
#define GOLDELOX_SOLID 0x00
#define GOLDELOX_OUTLINE 0x01
#define GOLDELOX_OBJECT_COLOR 0x02
class GOLDELOX {
public:
/*
* Constructor
*/
GOLDELOX(Stream *port);
char displayModel[20];
/*
* Public methods
*/
void begin();
/*
* Text Commands
*/
int moveCursor(uint16_t x, uint16_t y);
int putCharacter(char character);
int putString(char *string);
int characterWidth(char character, uint16_t *width);
int characterHeight(char character, uint16_t *height);
int textForegroundColor(uint16_t color);
int textBackgroundColor(uint16_t color);
int textWidth(uint16_t multiplier);
int textHeight(uint16_t multiplier);
int textXGap(uint16_t pixelcount);
int textYGap(uint16_t pixelcount);
int textBold(uint16_t mode);
int textInverse(uint16_t mode);
int textItalic(uint16_t mode);
int textOpacity(uint16_t mode);
int textUnderline(uint16_t mode);
int textAttributes(uint16_t value);
int setTextParameters(uint16_t function, uint16_t value);
/*
* Graphics Commands
*/
int clearScreen();
int changeColor(uint16_t oldColor, uint16_t newColor);
int drawCircle(uint16_t x, uint16_t y, uint16_t rad, uint16_t color);
int drawFilledCircle(uint16_t x, uint16_t y, uint16_t rad, uint16_t color);
int drawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color);
int drawRectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color);
int drawFilledRectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color);
int drawPolyline(uint16_t n, uint16_t *xArray, uint16_t *yArray, uint16_t color);
int drawPolygon(uint16_t n, uint16_t *xArray, uint16_t *yArray, uint16_t color);
int drawTriangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t x3, uint16_t y3, uint16_t color);
int calculateOrbit(uint16_t angle, uint16_t distance, uint16_t *dist);
int putPixel(uint16_t x, uint16_t y, uint16_t color);
int readPixel(uint16_t x, uint16_t y, uint16_t *color);
int moveOrigin(uint16_t xpos, uint16_t ypos);
int drawLineAndMoveOrigin(uint16_t xpos, uint16_t ypos);
int clipping(uint16_t value);
int setClipWindow(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
int extendClipRegion();
int backgroundColor(uint16_t color);
int outlineColor(uint16_t color);
int contrast(uint16_t contrast);
int frameDelay(uint16_t msec);
int linePattern(uint16_t pattern);
int screenMode(uint16_t mode);
int setGraphicsParameters(uint16_t function, uint16_t value);
/*
* Media Commands(SD/SDHC Memory Cards)
*/
int mediaInit(uint16_t *value);
int setByteAddress(uint32_t address);
int setSectorAddress(uint32_t address);
int readByte(uint8_t *value);
int readWord(uint16_t *value);
int writeByte(uint8_t value, uint16_t *status);
int writeWord(uint16_t value, uint16_t *status);
int flushMedia(uint16_t *status);
int displayImageRaw(uint16_t x, uint16_t y);
int displayVideoRaw(uint16_t x, uint16_t y);
int displayVideoFrameRaw(uint16_t x, uint16_t y, uint16_t frameNumber);
/*
* Sound and Tune Commands
*/
int beep(uint16_t note, uint16_t duration);
/*
* System Commands
*/
int getDisplayModel(char *string);
int screenSaverTimeout(uint16_t timeout);
int screenSaverSpeed(uint16_t speed);
/*
* Utility Commands
*/
int rgbToColor(uint8_t red, uint8_t green, uint8_t blue);
private:
Stream *serialPort;
/*
* Private methods
*/
int getResponse(uint8_t response);
int getResponseByte(uint8_t response, uint8_t *value);
int getResponseWord(uint8_t response, uint16_t *value);
int getResponseWords(uint8_t response, uint16_t n, uint16_t *value);
int getResponseString(uint8_t response, char *string);
int sendByte(uint8_t command);
int sendWord(uint16_t command);
int setDisplayModel();
};
#endif /* GOLDELOX_H */