oled.h
Go to the documentation of this file.
1 
9 #ifndef OLED_H
10 #define OLED_H
11 
13 #define CURRENT 1
14 
15 #define OLD 0
16 
18 #define MD_COMPASS 0
19 
20 #define MD_NAVIG 1
21 
22 #define MD_RECORD 2
23 
24 #define MD_SHUTDOWN 3
25 
27 #define NONE ""
28 
29 #define NORTH "N"
30 
31 #define NE "NE"
32 
33 #define EAST "E"
34 
35 #define SE "SE"
36 
37 #define SOUTH "S"
38 
39 #define SW "SO"
40 
41 #define WEST "O"
42 
43 #define NW "NO"
44 
46 #define OLED_ANSWER_ACK 6
47 
49 #define ALICEBLUE 0xF7DF
50 
51 #define ANTIQUEWHITE 0xFF5A
52 
53 #define AQUA 0x07FF
54 
55 #define AQUAMARINE 0x7FFA
56 
57 #define AZURE 0xF7FF
58 
59 #define BEIGE 0xF7BB
60 
61 #define BISQUE 0xFF38
62 
63 #define BLACK 0x0000
64 
65 #define BLANCHEDALMOND 0xFF59
66 
67 #define BLUE 0x001F
68 
69 #define BLUEVIOLET 0x895C
70 
71 #define BROWN 0xA145
72 
73 #define BURLYWOOD 0xDDD0
74 
75 #define CADETBLUE 0x5CF4
76 
77 #define CHARTREUSE 0x7FE0
78 
79 #define CHOCOLATE 0xD343
80 
81 #define CORAL 0xFBEA
82 
83 #define CORNFLOWERBLUE 0x64BD
84 
85 #define CORNSILK 0xFFDB
86 
87 #define CRIMSON 0xD8A7
88 
89 #define CYAN 0x07FF
90 
91 #define DARKBLUE 0x0011
92 
93 #define DARKCYAN 0x0451
94 
95 #define DARKGOLDENROD 0xBC21
96 
97 #define DARKGRAY 0xAD55
98 
99 #define DARKGREEN 0x0320
100 
101 #define DARKKHAKI 0xBDAD
102 
103 #define DARKMAGENTA 0x8811
104 
105 #define DARKOLIVEGREEN 0x5345
106 
107 #define DARKORANGE 0xFC60
108 
109 #define DARKORCHID 0x9999
110 
111 #define DARKRED 0x8800
112 
113 #define DARKSALMON 0xECAF
114 
115 #define DARKSEAGREEN 0x8DF1
116 
117 #define DARKSLATEBLUE 0x49F1
118 
119 #define DARKSLATEGRAY 0x2A69
120 
121 #define DARKTURQUOISE 0x067A
122 
123 #define DARKVIOLET 0x901A
124 
125 #define DEEPPINK 0xF8B2
126 
127 #define DEEPSKYBLUE 0x05FF
128 
129 #define DIMGRAY 0x6B4D
130 
131 #define DODGERBLUE 0x1C9F
132 
133 #define FIREBRICK 0xB104
134 
135 #define FLORALWHITE 0xFFDE
136 
137 #define FORESTGREEN 0x2444
138 
139 #define FUCHSIA 0xF81F
140 
141 #define GAINSBORO 0xDEFB
142 
143 #define GHOSTWHITE 0xFFDF
144 
145 #define GOLD 0xFEA0
146 
147 #define GOLDENROD 0xDD24
148 
149 #define GRAY 0x8410
150 
151 #define GREEN 0x0400
152 
153 #define GREENYELLOW 0xAFE5
154 
155 #define HONEYDEW 0xF7FE
156 
157 #define HOTPINK 0xFB56
158 
159 #define INDIANRED 0xCAEB
160 
161 #define INDIGO 0x4810
162 
163 #define IVORY 0xFFFE
164 
165 #define KHAKI 0xF731
166 
167 #define LAVENDER 0xE73F
168 
169 #define LAVENDERBLUSH 0xFF9E
170 
171 #define LAWNGREEN 0x7FE0
172 
173 #define LEMONCHIFFON 0xFFD9
174 
175 #define LIGHTBLUE 0xAEDC
176 
177 #define LIGHTCORAL 0xF410
178 
179 #define LIGHTCYAN 0xE7FF
180 
181 #define LIGHTGOLD 0xFFDA
182 
183 #define LIGHTGREEN 0x9772
184 
185 #define LIGHTGREY 0xD69A
186 
187 #define LIGHTPINK 0xFDB8
188 
189 #define LIGHTSALMON 0xFD0F
190 
191 #define LIGHTSEAGREEN 0x2595
192 
193 #define LIGHTSKYBLUE 0x867F
194 
195 #define LIGHTSLATEGRAY 0x7453
196 
197 #define LIGHTSTEELBLUE 0xB63B
198 
199 #define LIGHTYELLOW 0xFFFC
200 
201 #define LIME 0x07E0
202 
203 #define LIMEGREEN 0x3666
204 
205 #define LINEN 0xFF9C
206 
207 #define MAGENTA 0xF81F
208 
209 #define MAROON 0x8000
210 
211 #define MEDIUMAQUAMARINE 0x6675
212 
213 #define MEDIUMBLUE 0x0019
214 
215 #define MEDIUMORCHID 0xBABA
216 
217 #define MEDIUMPURPLE 0x939B
218 
219 #define MEDIUMSEAGREEN 0x3D8E
220 
221 #define MEDIUMSLATEBLUE 0x7B5D
222 
223 #define MEDIUMSPRINGGREEN 0x07D3
224 
225 #define MEDIUMTURQUOISE 0x4E99
226 
227 #define MEDIUMVIOLETRED 0xC0B0
228 
229 #define MIDNIGHTBLUE 0x18CE
230 
231 #define MINTCREAM 0xF7FF
232 
233 #define MISTYROSE 0xFF3C
234 
235 #define MOCCASIN 0xFF36
236 
237 #define NAVAJOWHITE 0xFEF5
238 
239 #define NAVY 0x0010
240 
241 #define OLDLACE 0xFFBC
242 
243 #define OLIVE 0x8400
244 
245 #define OLIVEDRAB 0x6C64
246 
247 #define ORANGE 0xFD20
248 
249 #define ORANGERED 0xFA20
250 
251 #define ORCHID 0xDB9A
252 
253 #define PALEGOLDENROD 0xEF55
254 
255 #define PALEGREEN 0x9FD3
256 
257 #define PALETURQUOISE 0xAF7D
258 
259 #define PALEVIOLETRED 0xDB92
260 
261 #define PAPAYAWHIP 0xFF7A
262 
263 #define PEACHPUFF 0xFED7
264 
265 #define PERU 0xCC27
266 
267 #define PINK 0xFE19
268 
269 #define PLUM 0xDD1B
270 
271 #define POWDERBLUE 0xB71C
272 
273 #define PURPLE 0x8010
274 
275 #define RED 0xF800
276 
277 #define ROSYBROWN 0xBC71
278 
279 #define ROYALBLUE 0x435C
280 
281 #define SADDLEBROWN 0x8A22
282 
283 #define SALMON 0xFC0E
284 
285 #define SANDYBROWN 0xF52C
286 
287 #define SEAGREEN 0x2C4A
288 
289 #define SEASHELL 0xFFBD
290 
291 #define SIENNA 0xA285
292 
293 #define SILVER 0xC618
294 
295 #define SKYBLUE 0x867D
296 
297 #define SLATEBLUE 0x6AD9
298 
299 #define SLATEGRAY 0x7412
300 
301 #define SNOW 0xFFDF
302 
303 #define SPRINGGREEN 0x07EF
304 
305 #define STEELBLUE 0x4416
306 
307 #define TAN 0xD5B1
308 
309 #define TEAL 0x0410
310 
311 #define THISTLE 0xDDFB
312 
313 #define TOMATO 0xFB08
314 
315 #define TURQUOISE 0x471A
316 
317 #define VIOLET 0xEC1D
318 
319 #define WHEAT 0xF6F6
320 
321 #define WHITE 0xFFFF
322 
323 #define WHITESMOKE 0xF7BE
324 
325 #define YELLOW 0xFFE0
326 
327 #define YELLOWGREEN 0x9E66
328 
332 extern unsigned int modeDisplay;
336 extern unsigned int oldModeDisplay;
340 extern int displayHasBeenUpdated;
341 
345 void enableUSARTforOLED();
346 
350 void resetOLED();
351 
358 void toggleOLEDInterrupt(unsigned int state);
359 
365 void sendChar(int c);
366 
371 void usart1_rx();
372 
376 void gfx_Clean();
377 
383 void gfx_BGcolour(int color);
384 
390 void gfx_PutString(char* string);
391 
401 void gfx_RectangleFilled(int x1, int y1, int x2, int y2, int color);
402 
408 void SSTimeout(int t);
409 
413 void setBaudRate();
414 
423 void gfx_CalculateOrbit(int angle, int distance, int* x, int* y);
424 
433 void gfx_DrawCircle(int x, int y, int radius, int color);
434 
444 void gfx_DrawLine(int x1, int y1, int x2, int y2, int color);
445 
451 void gfx_ScreenMode(int mode);
452 
459 void gfx_MoveOrigin(int x, int y);
460 
470 void gfx_Rectangle(int x1, int y1, int x2, int y2, int color);
471 
477 void txt_Width(int multi);
478 
484 void txt_FGColor(int color);
485 
491 void txt_BGColor(int color);
492 
496 void initOLED();
497 
501 void displayMainMenu();
502 
506 void updateMenu();
507 
513 void displayMessage(char* string);
514 
518 void displayCompass();
519 
523 void displayHeader();
524 
530 char* calculateDirection();
531 
538 void ftoa(char* p, float x);
539 
540 #endif
541 
void gfx_Rectangle(int x1, int y1, int x2, int y2, int color)
Draw a rectangle.
Definition: oled.c:281
void setBaudRate()
Set the baud rate.
Definition: oled.c:269
void displayMainMenu()
Display menu.
Definition: oled.c:320
void displayCompass()
Display the compass.
Definition: oled.c:418
void gfx_PutString(char *string)
Put a string on the screen.
Definition: oled.c:108
void gfx_Clean()
Clean the screen.
Definition: oled.c:87
void toggleOLEDInterrupt(unsigned int state)
Toggle OLED interrupt.
Definition: oled.c:71
void usart1_rx()
Receive function for OLED data (USART1, interrupt mode)
Definition: oled.c:82
void gfx_CalculateOrbit(int angle, int distance, int *x, int *y)
Calculate the (x,y) pos (orbit) from angle and distance.
Definition: oled.c:153
unsigned int modeDisplay
Definition: oled.c:19
int displayHasBeenUpdated
Definition: oled.c:18
void gfx_ScreenMode(int mode)
Screen mode (portrait/landscape)
Definition: oled.c:234
void enableUSARTforOLED()
Enable and config USART for OLED.
Definition: oled.c:27
void txt_Width(int multi)
Set the width of the text.
Definition: oled.c:301
void gfx_MoveOrigin(int x, int y)
Move to origin to a position.
Definition: oled.c:221
unsigned int oldModeDisplay
Definition: oled.c:20
void gfx_BGcolour(int color)
Set the background color.
Definition: oled.c:96
void gfx_RectangleFilled(int x1, int y1, int x2, int y2, int color)
Draw a rectangle filled with a color.
Definition: oled.c:121
char * calculateDirection()
Calculate the direction (N, S, NE, etc.)
Definition: oled.c:509
void gfx_DrawLine(int x1, int y1, int x2, int y2, int color)
Draw a line.
Definition: oled.c:201
void ftoa(char *p, float x)
Float to string conversion.
Definition: oled.c:481
void SSTimeout(int t)
Screensave mode.
Definition: oled.c:141
void initOLED()
Configure OLED for proper using.
Definition: oled.c:312
void sendChar(int c)
Send char.
Definition: oled.c:77
void gfx_DrawCircle(int x, int y, int radius, int color)
Draw a circle.
Definition: oled.c:183
void displayHeader()
Display message header.
Definition: oled.c:399
void txt_FGColor(int color)
Set the text color.
Definition: oled.c:245
void txt_BGColor(int color)
Set the text background color.
Definition: oled.c:257
void displayMessage(char *string)
Display a string in the center of the screen.
Definition: oled.c:407
void resetOLED()
Reset OLED.
Definition: oled.c:63
void updateMenu()
Update the menu with currently selected.
Definition: oled.c:345