-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patholed.h
More file actions
553 lines (495 loc) · 15.3 KB
/
oled.h
File metadata and controls
553 lines (495 loc) · 15.3 KB
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
/********************************************************************
File Information:
FileName: oled.h
Dependencies: See INCLUDES section
Processor: PIC18F46J50
Hardware: PIC18F Starter Kit
Complier: Microchip C18 (for PIC18)
Company: Microchip Technology, Inc.
Software License Agreement:
The software supplied herewith by Microchip Technology Incorporated
(the “Company”) for its PIC® Microcontroller is intended and
supplied to you, the Company’s customer, for use solely and
exclusively on Microchip PIC Microcontroller products. The
software is owned by the Company and/or its supplier, and is
protected under applicable copyright laws. All rights are reserved.
Any use in violation of the foregoing restrictions may subject the
user to criminal sanctions under applicable laws, as well as to
civil liability for the breach of the terms and conditions of this
license.
THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
File Description:
Change History:
Rev Date Description
1.0 Initial release
********************************************************************/
#ifndef OLED_H
#define OLED_H
/******** Include files **********************/
#include "Compiler.h"
#include "GenericTypeDefs.h"
/*********************************************/
#define Oled_Clear() Oled_FillDisplay(0)
void Oled_FillDisplay(unsigned char data);
void Oled_PutString(unsigned char *ptr,unsigned char line, unsigned char col, BOOL inverse);
void Oled_PutROMString(rom unsigned char *ptr,unsigned char linepage, unsigned char col);
void Oled_PutImage(rom unsigned char *ptr, unsigned char sizex, unsigned char sizey, unsigned char startx, unsigned char starty);
/*********************************************************************
* Function: void Oled_Init()
*
* Overview: Initializes LCD module.
*
* PreCondition: none
*
* Input: none
*
* Output: none
*
* Side Effects: none
*
********************************************************************/
void Oled_Init(void);
typedef enum {
Words,
Aliens
}Emode;
/************************************************************************/
void SetMode(Emode mode);
/*********************************************************************
* Function: void Oled_DelayMs(WORD time)
*
* Overview: Delays execution on time specified in milliseconds.
* The delay is correct only for 16MIPS.
*
* PreCondition: none
*
* Input: time - Delay in milliseconds.
*
* Output: none
*
* Side Effects: none
*
********************************************************************/
void Oled_DelayMs(WORD time);
/*********************************************/
extern ROM BYTE g_pucFont[95][5];
extern ROM BYTE g_AlienFont[95][5];
/*********************************************/
// Define this to implement ClearDevice function in the driver.
#define USE_DRV_CLEARDEVICE
/*********************************************************************
* Overview: Horizontal and vertical screen size.
*********************************************************************/
#ifdef USE_PORTRAIT
#error THE DRIVER DOES SUPPORT PORTRAIT MODE
#else
// Defines the display offset in x direction. Dependent on the display
// used and how it is connected.
#define OFFSET 2
// Defines the horizontal screen size. Dependent on the display glass used.
#define SCREEN_HOR_SIZE 128
// Defines the vertical screen size. Dependent on the display glass used.
#define SCREEN_VER_SIZE 64
#endif
/*********************************************************************
* Overview: Clipping region control codes to be used with SetClip(...)
* function.
*********************************************************************/
#define CLIP_DISABLE 0 // Disables clipping.
#define CLIP_ENABLE 1 // Enables clipping.
/*********************************************************************
* Overview: Screen Saver parameters.
* - SSON - Means that screen saver will be enabled when
* ScreenSaver(SSON) function is called with SSON as
* parameter.
* - SSOFF - Means that screen saver will be disbled when
* ScreenSaver(SSOFF) function is called with SSOFF as
* parameter.
*
*********************************************************************/
#define SSON 1 // screen saver is turned on
#define SSOFF 0 // screen saver is turned off
/*********************************************************************
* Overview: Color definitions.
*********************************************************************/
#define BLACK (WORD)0b00000000
#define WHITE (WORD)0b11111111
/*********************************************************************
* Overview: Emboss size set for 3-D effect
*********************************************************************/
#define GOL_EMBOSS_SIZE 1
// Memory pitch for line
#define LINE_MEM_PITCH 0x100
// Definitions for reset pin
#define RST_TRIS_BIT TRISDbits.TRISD2
#define RST_LAT_BIT LATDbits.LATD2
// Color
extern BYTE _color;
/*********************************************************************
* Overview: Clipping region control and border settings.
*
*********************************************************************/
// Clipping region enable control
extern SHORT _clipRgn;
// Left clipping region border
extern SHORT _clipLeft;
// Top clipping region border
extern SHORT _clipTop;
// Right clipping region border
extern SHORT _clipRight;
// Bottom clipping region border
extern SHORT _clipBottom;
/*********************************************************************
* Macros: PMPDelay()
*
* Overview: Delays execution for PMP cycle time. This is dependent on
* processor clock.
*
* PreCondition: none
*
* Input: none
*
* Output: none
*
* Side Effects: none
*
********************************************************************/
//#if (GetSystemClock() == 32000000)
// at 32 MHZ 1 nop is at 32.25 ns. Controller needs 300 ns minimum delay from
// last CS valid to next CS valid. Thus we have the 7 nops (227.5 ns).
// PMP access at this clock frequency is 3 cycles (97.5 ns).
// therefore: 227.5 + 97.5 > 300
// verify: 300 - 97.5 = 202.5
// 202.5/32.5 = 6.23 thus we can use 7 nops.
#define PMPDelay() Nop(); Nop(); Nop(); Nop(); Nop(); Nop(); Nop();
//#else
//
//#define PMPDelay() Nop();
//
//#endif
/*********************************************************************
* Macros: PMPWaitBusy()
*
* Overview: Delays execution for PMP cycle time.
*
* PreCondition: none
*
* Input: none
*
* Output: none
*
* Side Effects: none
*
********************************************************************/
//#ifdef __PIC24F__
#define PMPWaitBusy() Nop();
//#else
//#error CONTROLLER IS NOT SUPPORTED
//#endif
/*********************************************************************
* Macros: WriteData(writeByte)
*
* Overview: Writes data.
*
* PreCondition: none
*
* Input: writeByte - Data byte to be written.
*
* Output: none
*
* Side Effects: none
*
********************************************************************/
//#define WriteData(writeByte) PMADDR=0x4001;PMPWaitBusy();PMDIN1=writeByte;PMPDelay();
/*********************************************************************
* Macros: ReadData(readByte)
*
* Overview: Reads a byte from the display buffer. This assumes that the
* page value, lower and higher column address pointers are already set.
*
* PreCondition: Page, lower and higher column address pointers are already set.
*
* Input: none.
*
* Output: ReadByte - data read from the display buffer.
*
* Side Effects: none
*
********************************************************************/
#define ReadData(readByte) TRISD = 0xFF;oledD_C = 1;Nop();oledRD = 0;Nop();oledRD = 1;Nop();oledRD = 0;Nop();readByte = PORTD;
/*********************************************************************
* Macros: SetAddress(lowerAddr,higherAddr)
*
* Overview: Sets the page and the lower and higher address pointer
* of the display buffer. All parameters should be pre-calculated.
*
* PreCondition: none
*
* Input: page - Page value for the address.
* lowerAddr - Lower column address.
* higherAddr - Higher column address.
*
* Output: none
*
* Side Effects: none
*
********************************************************************/
#define SetAddress(page,lowerAddr,higherAddr)\
WriteCommand(page);\
WriteCommand(lowerAddr);\
WriteCommand(higherAddr);
/*********************************************************************
* Macros: GetMaxX()
*
* Overview: Returns maximum horizontal coordinate.
*
* PreCondition: none
*
* Input: none
*
* Output: Maximum horizontal coordinate.
*
* Side Effects: none
*
********************************************************************/
#define GetMaxX() (SCREEN_HOR_SIZE-1)
/*********************************************************************
* Macros: GetMaxY()
*
* Overview: Returns maximum vertical coordinate.
*
* PreCondition: none
*
* Input: none
*
* Output: Maximum vertical coordinate.
*
* Side Effects: none
*
********************************************************************/
#define GetMaxY() (SCREEN_VER_SIZE-1)
/*********************************************************************
* Macros: SetColor(color)
*
* Overview: Sets current drawing color.
*
* PreCondition: none
*
* Input: color - Color coded in 5:6:5 RGB format.
*
* Output: none
*
* Side Effects: none
*
********************************************************************/
#define SetColor(color) _color = color;
/*********************************************************************
* Macros: GetColor()
*
* Overview: Returns current drawing color.
*
* PreCondition: none
*
* Input: none
*
* Output: Color coded in 5:6:5 RGB format.
*
* Side Effects: none
*
********************************************************************/
#define GetColor() _color
/*********************************************************************
* Macros: SetActivePage(page)
*
* Overview: Sets active graphic page.
*
* PreCondition: none
*
* Input: page - Graphic page number.
*
* Output: none
*
* Side Effects: none
*
********************************************************************/
#define SetActivePage(page)
/*********************************************************************
* Macros: SetVisualPage(page)
*
* Overview: Sets graphic page to display.
*
* PreCondition: none
*
* Input: page - Graphic page number
*
* Output: none
*
* Side Effects: none
*
********************************************************************/
#define SetVisualPage(page)
/*********************************************************************
* Function: void PutPixel(SHORT x, SHORT y)
*
* Overview: Puts pixel with the given x,y coordinate position.
*
* PreCondition: none
*
* Input: x - x position of the pixel.
* y - y position of the pixel.
*
* Output: none
*
* Side Effects: none
*
********************************************************************/
void PutPixel(SHORT x, SHORT y);
/*********************************************************************
* Function: WORD GetPixel(SHORT x, SHORT y)
*
* Overview: Returns pixel color at the given x,y coordinate position.
*
* PreCondition: none
*
* Input: x - x position of the pixel.
* y - y position of the pixel.
*
* Output: pixel color
*
* Side Effects: none
*
********************************************************************/
BYTE GetPixel(SHORT x, SHORT y);
/*********************************************************************
* Macros: SetClipRgn(left, top, right, bottom)
*
* Overview: Sets clipping region.
*
* PreCondition: none
*
* Input: left - Defines the left clipping region border.
* top - Defines the top clipping region border.
* right - Defines the right clipping region border.
* bottom - Defines the bottom clipping region border.
*
* Output: none
*
* Side Effects: none
*
********************************************************************/
#define SetClipRgn(left,top,right,bottom) _clipLeft=left; _clipTop=top; _clipRight=right; _clipBottom=bottom;
/*********************************************************************
* Macros: GetClipLeft()
*
* Overview: Returns left clipping border.
*
* PreCondition: none
*
* Input: none
*
* Output: Left clipping border.
*
* Side Effects: none
*
********************************************************************/
#define GetClipLeft() _clipLeft
/*********************************************************************
* Macros: GetClipRight()
*
* Overview: Returns right clipping border.
*
* PreCondition: none
*
* Input: none
*
* Output: Right clipping border.
*
* Side Effects: none
*
********************************************************************/
#define GetClipRight() _clipRight
/*********************************************************************
* Macros: GetClipTop()
*
* Overview: Returns top clipping border.
*
* PreCondition: none
*
* Input: none
*
* Output: Top clipping border.
*
* Side Effects: none
*
********************************************************************/
#define GetClipTop() _clipTop
/*********************************************************************
* Macros: GetClipBottom()
*
* Overview: Returns bottom clipping border.
*
* PreCondition: none
*
* Input: none
*
* Output: Bottom clipping border.
*
* Side Effects: none
*
********************************************************************/
#define GetClipBottom() _clipBottom
/*********************************************************************
* Macros: SetClip(control)
*
* Overview: Enables/disables clipping.
*
* PreCondition: none
*
* Input: control - Enables or disables the clipping.
* - 0: Disable clipping
* - 1: Enable clipping
*
* Output: none
*
* Side Effects: none
*
********************************************************************/
#define SetClip(control) _clipRgn=control;
/*********************************************************************
* Macros: IsDeviceBusy()
*
* Overview: Returns non-zero if LCD controller is busy
* (previous drawing operation is not completed).
*
* PreCondition: none
*
* Input: none
*
* Output: Busy status.
*
* Side Effects: none
*
********************************************************************/
#define IsDeviceBusy() 0
/*********************************************************************
* Macros: SetPalette(colorNum, color)
*
* Overview: Sets palette register.
*
* PreCondition: none
*
* Input: colorNum - Register number.
* color - Color.
*
* Output: none
*
* Side Effects: none
*
********************************************************************/
#define SetPalette(colorNum, color)
#endif // OLED_H