PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Simple Libraries
Display
liboledc
oledc.h
1
/*
2
* @file oledc_.h
3
*
4
* @author Matthew Matz
5
*
6
* @version 0.9
7
*
8
* @copyright Copyright (C) Parallax, Inc. 2016. See end of file for
9
* terms of use (MIT License).
10
*
11
* @brief This is a driver that allows the Propeller Multicore Microcontroller to
12
* draw text, shapes, and bitmap files on the 0.96-inch RGB OLED (Parallax Part #28087).
13
*
14
* @detail This high-speed driver allows the Propeller Multicore Microcontroller to
15
* draw pixels, lines, circles, recatngles, rounded rectagles, triangles, formatted text
16
* in multiple fonts, bitmap images stored on an SD card on a 0.95-inch OLED screen.
17
* At Parallax, we would like to thank Adafruit Industries as parts of this library
18
* were dervied from the Adafruit GFX library for Arduino. Please submit bug reports,
19
* suggestions, and improvements to this code to editor@parallax.com.
20
*
21
* @note This library uses one cog. If fonts are installed, they occupy EEPROM addresses
22
* 40576 to 63359.
23
*/
24
25
#ifndef OLEDC_H // Prevents duplicate
26
#define OLEDC_H // declarations
27
28
#if defined(__cplusplus) // If compiling for C++
29
extern
"C"
{
// Compile for C
30
#endif
31
32
33
#include <propeller.h>
34
#include <stdlib.h>
35
36
// Named Colors
37
#define WHITE 0xFFFF
38
#define PINK 0xFD59
39
#define MAGENTA 0xC9D4
40
#define RED 0xC082
41
#define DARKRED 0xA000
42
#define REDORANGE 0xD261
43
#define LIGHTORANGE 0xDDB2
44
#define ORANGE 0xFC00
45
#define YELLOWORANGE 0xFCE0
46
#define GOLD 0xF704
47
#define YELLOW 0xF744
48
#define LEMON 0xD6CF
49
#define YELLOWGREEN 0x5600
50
#define GREEN 0x1C62
51
#define DARKGREEN 0x02C0
52
#define GREENBLUE 0x0C75
53
#define CYAN 0x5E97
54
#define LIGHTBLUE 0x857B
55
#define SKYBLUE 0x0E3E
56
#define BLUE 0x2B16
57
#define NAVYBLUE 0x0009
58
#define VIOLET 0x7817
59
#define PURPLE 0xA017
60
#define RASPBERRY 0x902A
61
#define TAN 0xCC2A
62
#define LIGHTBROWN 0xBB44
63
#define BRONZE 0xA440
64
#define BROWN 0x9201
65
#define DARKBROWN 0x51E7
66
#define LIGHTGRAY 0xBDD7
67
#define GRAY 0x8410
68
#define DARKGRAY 0x3186
69
#define BLACK 0x0000
70
71
// Font size and face
72
#define SMALL 1
73
#define MEDIUM 2
74
#define LARGE 3
75
76
#define FONT_SANS 0
77
#define FONT_SERIF 1
78
#define FONT_SCRIPT 2
79
#define FONT_BUBBLE 3
80
81
82
83
101
void
oledc_init(
char
SID,
char
SCLK,
char
CS,
char
RS,
char
RST,
char
screen_rotation);
102
112
unsigned
int
oledc_color565(
char
r,
char
g,
char
b);
113
114
//
115
// @name Individual setup calls
116
// @{
117
//
118
119
//
120
// @}
121
//
122
// @name Drawing Functions
123
// @{
124
134
void
oledc_drawPixel(
int
x
,
int
y,
unsigned
int
color);
135
149
void
oledc_drawLine(
int
x0,
int
y0,
int
x1,
int
y1,
unsigned
int
color);
150
162
void
oledc_drawFastVLine(
int
x
,
int
y,
int
h,
unsigned
int
color);
163
175
void
oledc_drawFastHLine(
int
x
,
int
y,
int
w,
unsigned
int
color);
176
188
void
oledc_drawCircle(
int
x0,
int
y0,
int
r,
unsigned
int
color);
189
201
void
oledc_fillCircle(
int
x0,
int
y0,
int
r,
unsigned
int
color);
202
216
void
oledc_drawRect(
int
x
,
int
y,
int
w,
int
h,
unsigned
int
color);
217
231
void
oledc_fillRect(
int
x
,
int
y,
int
w,
int
h,
unsigned
int
color);
232
248
void
oledc_drawRoundRect(
int
x
,
int
y,
int
w,
int
h,
int
r,
unsigned
int
color);
249
265
void
oledc_fillRoundRect(
int
x
,
int
y,
int
w,
int
h,
int
r,
unsigned
int
color);
266
284
void
oledc_drawTriangle(
int
x0,
int
y0,
int
x1,
int
y1,
int
x2,
int
y2,
unsigned
int
color);
285
303
void
oledc_fillTriangle(
int
x0,
int
y0,
int
x1,
int
y1,
int
x2,
int
y2,
unsigned
int
color);
304
317
void
oledc_bitmap(
char
*imgdir,
int
x0,
int
y0);
318
319
// @}
320
//
321
// @name Text Functions
322
// @{
323
329
void
oledc_setTextSize(
char
s);
330
337
void
oledc_setTextFont(
char
f);
338
348
void
oledc_setTextColor(
unsigned
int
c,
unsigned
int
b);
349
353
void
oledc_setTextWrap(
char
w);
354
367
void
oledc_setCursor(
int
x
,
int
y,
char
size);
368
372
int
oledc_print(
const
char
*fmt, ...);
373
383
void
oledc_drawNumber(
float
d,
int
r);
384
390
void
oledc_drawText(
char
*myString);
391
395
int
oledc_getCursorX();
396
400
int
oledc_getCursorY();
401
402
// @}
403
//
404
// @name Screen Manipulation Functions
405
// @{
406
418
void
oledc_clear(
int
x0,
int
y0,
int
w,
int
h);
419
435
void
oledc_copy(
int
x0,
int
y0,
int
w,
int
h,
int
x2,
int
y2);
436
440
void
oledc_sleep();
441
446
void
oledc_wake();
447
453
char
oledc_getRotation();
454
458
void
oledc_setRotation(
char
x
);
459
463
int
oledc_getWidth();
464
468
int
oledc_getHeight();
469
473
void
oledc_invertDisplay();
474
488
void
oledc_scrollStart(
char
h,
char
v);
489
493
void
oledc_scrollStop();
494
498
int
oledc_isScrolling();
499
500
// @}
501
502
503
504
#ifndef DOXYGEN_SHOULD_SKIP_THIS
505
506
/* =========================================================================== */
507
// PRIVATE FUNCTIONS/MACROS
508
/* =========================================================================== */
509
515
#define gfx_swap(a, b) { unsigned int t = a; a = b; b = t; }
516
#define absv(x) ((x)<0 ? -(x) : (x))
517
518
// Timing Delays
519
//#define SSD1331_DELAYS_HWFILL 25
520
//#define SSD1331_DELAYS_HWLINE 10
521
//#define SSD1331_DELAYS_HWPIXEL 10
522
523
// Radix Constants
524
#define HEX -16
525
#define OCT -8
526
#define BIN -2
527
#define DEC -10
528
529
// SSD1331 Commands
530
#define SSD1331_CMD_DRAWLINE 0x21
531
#define SSD1331_CMD_DRAWRECT 0x22
532
#define SSD1331_CMD_COPY 0x23
533
#define SSD1331_CMD_CLEAR 0x25
534
#define SSD1331_CMD_FILL 0x26
535
#define SSD1331_CMD_SCROLLSETUP 0x27
536
#define SSD1331_CMD_SCROLLSTOP 0x2E
537
#define SSD1331_CMD_SCROLLSTART 0x2F
538
#define SSD1331_CMD_SETCOLUMN 0x15
539
#define SSD1331_CMD_SETROW 0x75
540
#define SSD1331_CMD_CONTRASTA 0x81
541
#define SSD1331_CMD_CONTRASTB 0x82
542
#define SSD1331_CMD_CONTRASTC 0x83
543
#define SSD1331_CMD_MASTERCURRENT 0x87
544
#define SSD1331_CMD_SETREMAP 0xA0
545
#define SSD1331_CMD_STARTLINE 0xA1
546
#define SSD1331_CMD_DISPLAYOFFSET 0xA2
547
#define SSD1331_CMD_NORMALDISPLAY 0xA4
548
#define SSD1331_CMD_DISPLAYALLON 0xA5
549
#define SSD1331_CMD_DISPLAYALLOFF 0xA6
550
#define SSD1331_CMD_INVERTDISPLAY 0xA7
551
#define SSD1331_CMD_SETMULTIPLEX 0xA8
552
#define SSD1331_CMD_SETMASTER 0xAD
553
#define SSD1331_CMD_DISPLAYOFF 0xAE
554
#define SSD1331_CMD_DISPLAYON 0xAF
555
#define SSD1331_CMD_POWERMODE 0xB0
556
#define SSD1331_CMD_PRECHARGE 0xB1
557
#define SSD1331_CMD_CLOCKDIV 0xB3
558
#define SSD1331_CMD_PRECHARGEA 0x8A
559
#define SSD1331_CMD_PRECHARGEB 0x8B
560
#define SSD1331_CMD_PRECHARGEC 0x8C
561
#define SSD1331_CMD_PRECHARGELEVEL 0xBB
562
#define SSD1331_CMD_VCOMH 0xBE
563
564
#define TFTWIDTH 96
565
#define TFTHEIGHT 64
566
567
//extern char font_lg_index[95];
568
//extern char font_lg_zeroMap[658];
569
//extern char oled_font_lg[3000];
570
//extern char oled_font_med[2090];
571
575
void
oledc_spiWrite(
char
c,
char
dc);
576
580
void
oledc_startup();
581
589
void
oledc_writeCommand(
char
c,
char
dc);
590
594
char
oledc_screenLock();
595
599
void
oledc_screenLockSet();
600
604
void
oledc_screenLockClr();
605
609
void
oledc_write(
char
c);
610
625
void
oledc_drawCharSmall(
int
x
,
int
y,
unsigned
char
c,
unsigned
int
color,
unsigned
int
bg);
626
641
void
oledc_drawCharMedium(
int
x
,
int
y,
unsigned
char
c,
unsigned
int
color,
unsigned
int
bg);
642
657
void
oledc_drawCharLarge(
int
x
,
int
y,
unsigned
char
c,
unsigned
int
color,
unsigned
int
bg);
658
664
char
oledc_goTo(
int
x
,
int
y);
665
670
void
oledc_drawCircleHelper(
int
x0,
int
y0,
int
r,
char
cornername,
unsigned
int
color);
671
675
void
oledc_fillCircleHelper(
int
x0,
int
y0,
int
r,
char
cornername,
int
delta,
unsigned
int
color);
676
686
void
oledc_drawPixelPrimative(
int
x
,
int
y,
unsigned
int
color);
687
701
void
oledc_drawLinePrimative(
int
x0,
int
y0,
int
x1,
int
y1,
unsigned
int
color);
702
716
void
oledc_fillRectPrimative(
int
x
,
int
y,
int
w,
int
h,
unsigned
int
color);
717
722
#endif // DOXYGEN_SHOULD_SKIP_THIS
723
724
725
#if defined(__cplusplus)
726
}
// End compile for C block
727
#endif
728
/* __cplusplus */
729
730
#endif // End prevent duplicate forward
731
/* OLEDC_H */
// declarations block
732
733
734
735
// Parts of this file are from the Adafruit GFX arduino library
736
737
/***************************************************
738
This is a library for the 0.96" 16-bit Color OLED with SSD1331 driver chip
739
Pick one up today in the adafruit shop!
740
------> http://www.adafruit.com/products/684
741
These displays use SPI to communicate, 4 or 5 pins are required to
742
interface
743
Adafruit invests time and resources providing this open source code,
744
please support Adafruit and open-source hardware by purchasing
745
products from Adafruit!
746
Written by Limor Fried/Ladyada for Adafruit Industries.
747
BSD license, all text above must be included in any redistribution
748
****************************************************/
x
int x
Definition:
07 Box and Lines.c:13
Generated on Fri May 20 2022 16:48:04 for PropWare by
1.8.17