0.95-inch RGB OLED Display library
0.5
Library for the 0.95-inch RGB OLED Display library (Parallax Part #28087)
|
#include <propeller.h>
Go to the source code of this file.
Macros | |
Text Sizes | |
#define | SMALL 1 |
#define | MEDIUM 2 |
#define | LARGE 3 |
Named Colors | |
#define | WHITE 0xFFFF |
#define | PINK 0xFD59 |
#define | MAGENTA 0xF319 |
#define | RED 0xC082 |
#define | DARKRED 0xA162 |
#define | REDORANGE 0xD261 |
#define | LIGHTORANGE 0xFEB6 |
#define | ORANGE 0xFC00 |
#define | YELLOWORANGE 0xFCC0 |
#define | GOLD 0xF704 |
#define | YELLOW 0xF744 |
#define | LEMON 0xF7D3 |
#define | YELLOWGREEN 0x5600 |
#define | GREEN 0x1C62 |
#define | DARKGREEN 0x03CE |
#define | GREENBLUE 0x0C75 |
#define | CYAN 0x5E97 |
#define | LIGHTBLUE 0x857B |
#define | SKYBLUE 0x0E3E |
#define | BLUE 0x2B16 |
#define | NAVYBLUE 0x0007 |
#define | VIOLET 0x7A37 |
#define | PURPLE 0x7A37 |
#define | RASPBERRY 0xA82E |
#define | TAN 0xCC2A |
#define | LIGHTBROWN 0xBB44 |
#define | BRONZE 0xA440 |
#define | BROWN 0x9201 |
#define | DARKBROWN 0x7269 |
#define | LIGHTGRAY 0xBDD7 |
#define | GRAY 0x8410 |
#define | DARKGRAY 0x3186 |
#define | BLACK 0x0000 |
Functions | |
void | oledc_init (char CS, char RS, char SID, char SCLK, char RST, char screen_rotation) |
Initializes the OLED screen by setting up it's SPI and control pins. More... | |
unsigned int | oledc_color565 (char r, char g, char b) |
Generates a 2-byte (16-bit) color code (RRRRRGGGGGGBBBBB format) for use with the OLED screen. More... | |
Drawing Functions | |
void | oledc_drawPixel (int x, int y, unsigned int color) |
Draws a single pixel on the screen in the specified color. More... | |
void | oledc_drawLine (int x0, int y0, int x1, int y1, unsigned int color) |
Draws a line on the screen in the specified color. More... | |
void | oledc_drawFastVLine (int x, int y, int h, unsigned int color) |
Draws a vertical line on the screen in the specified color. More... | |
void | oledc_drawFastHLine (int x, int y, int w, unsigned int color) |
Draws a horizontal line on the screen in the specified color. More... | |
void | oledc_drawCircle (int x0, int y0, int r, unsigned int color) |
Draws a circle on the screen in the specified color. More... | |
void | oledc_fillCircle (int x0, int y0, int r, unsigned int color) |
Draws a filled circle on the screen in the specified color. More... | |
void | oledc_drawRect (int x, int y, int w, int h, unsigned int color) |
Draws a rectangle on the screen in the specified color. More... | |
void | oledc_fillRect (int x, int y, int w, int h, unsigned int color) |
Draws a filled rectangle on the screen in the specified color. More... | |
void | oledc_drawRoundRect (int x, int y, int w, int h, int r, unsigned int color) |
Draws a rectangle with rounded corners on the screen in the specified color. More... | |
void | oledc_fillRoundRect (int x, int y, int w, int h, int r, unsigned int color) |
Draws a filled rectangle with rounded corners on the screen in the specified color. More... | |
void | oledc_drawTriangle (int x0, int y0, int x1, int y1, int x2, int y2, unsigned int color) |
Draws a triangle with on the screen in the specified color. More... | |
void | oledc_fillTriangle (int x0, int y0, int x1, int y1, int x2, int y2, unsigned int color) |
Draws a filled triangle with on the screen in the specified color. More... | |
void | oledc_bitmap (char *imgdir, int x0, int y0) |
Displays a properly formatted bitmap (.BMP) image on the screen. The image must be saved as a Device Independant Bitmap with r5g6b5 (16-bit), normal row-order encoding. More... | |
Text Functions | |
void | oledc_setTextSize (char s) |
Sets the size of the font to be used. Range is from 1 to 3. Size (1) is 5x7 (6x8 spacing) pixels, size (2) is 11x15 (12x16 spacing) pixels and size (3) is 15x23 (16x24 spacing) pixels. More... | |
void | oledc_setTextColor (unsigned int c, unsigned int b) |
Sets the color of the font and the color of the background (highlighting) to be used. Setting the text color and text background to the same color will make the background color transparent. More... | |
void | oledc_setTextWrap (char w) |
Toggles automatic wrapping of text printed to the screen. (0) turns wrapping off, (1) turning wrapping on. More... | |
void | oledc_setCursor (int x, int y, char size) |
Sets the cursor position based on the size parameter. More... | |
int | oledc_print (const char *fmt,...) |
Print format "..." args to the screen. The output is limited to 128 bytes. More... | |
int | oledc_getCursorX () |
Returns the current horizontal position of the cursor, measured from the left side of the screen in pixels. More... | |
int | oledc_getCursorY () |
Returns the current vertical position of the cursor, measured from the top of the screen in pixels. More... | |
Screen Manipulation Functions | |
void | oledc_clear (int x0, int y0, int w, int h) |
Clears (sets to black) a rectangular area of the screen. More... | |
void | oledc_copy (int x0, int y0, int w, int h, int x2, int y2) |
Creates a copy a rectangular area of the screen at another position on the screen. More... | |
char | oledc_getRotation () |
Returns the screen's orientation. (0) means the pins are pointed upwards, (1) means the pins are pointed to the left, (2) means the pins are pointed down and (3) means the pins are pointed to the right. More... | |
void | oledc_setRotation (char x) |
Low-level function used by the begin function to set up the screen's orientation. More... | |
int | oledc_getWidth () |
Returns the width of the screen per the screen's current orientation. More... | |
int | oledc_getHeight () |
Returns the height of the screen per the screen's current orientation. More... | |
void | oledc_invertDisplay () |
Inverts the screen. More... | |
void | oledc_scrollStart (char h, char v) |
Starts scrolling the entire image on the screen horizontally, vertically, or both. More... | |
void | oledc_scrollStop () |
Stops scrolling the screen. More... | |
int | oledc_isScrolling () |
Returns (1) if the screen is currently scrolling and (0) if it is not. More... | |
#define SMALL 1 |
#define MEDIUM 2 |
#define LARGE 3 |
#define BLACK 0x0000 |
#define BLUE 0x2B16 |
#define BRONZE 0xA440 |
#define BROWN 0x9201 |
#define CYAN 0x5E97 |
#define DARKBROWN 0x7269 |
#define DARKGRAY 0x3186 |
#define DARKGREEN 0x03CE |
#define DARKRED 0xA162 |
#define GOLD 0xF704 |
#define GRAY 0x8410 |
#define GREEN 0x1C62 |
#define GREENBLUE 0x0C75 |
#define LEMON 0xF7D3 |
#define LIGHTBLUE 0x857B |
#define LIGHTBROWN 0xBB44 |
#define LIGHTGRAY 0xBDD7 |
#define LIGHTORANGE 0xFEB6 |
#define MAGENTA 0xF319 |
#define NAVYBLUE 0x0007 |
#define ORANGE 0xFC00 |
#define PINK 0xFD59 |
#define PURPLE 0x7A37 |
#define RASPBERRY 0xA82E |
#define RED 0xC082 |
#define REDORANGE 0xD261 |
#define SKYBLUE 0x0E3E |
#define TAN 0xCC2A |
#define TFTHEIGHT 64 |
#define TFTWIDTH 96 |
#define VIOLET 0x7A37 |
#define WHITE 0xFFFF |
#define YELLOW 0xF744 |
#define YELLOWGREEN 0x5600 |
#define YELLOWORANGE 0xFCC0 |
void oledc_bitmap | ( | char * | imgdir, |
int | x0, | ||
int | y0 | ||
) |
Displays a properly formatted bitmap (.BMP) image on the screen. The image must be saved as a Device Independant Bitmap with r5g6b5 (16-bit), normal row-order encoding.
*imgdir | Filename of the image saved to the SD card to be displayed. |
x0 | Horizontal position of the top-left corner of the bitmap image to be displayed, counted from the left side of the screen. |
y0 | Vertical position of the top-left corner of the bitmap image to be displayed, counted down from the top of the screen. |
void oledc_clear | ( | int | x0, |
int | y0, | ||
int | w, | ||
int | h | ||
) |
Clears (sets to black) a rectangular area of the screen.
x0 | Starting horizontal coordinate of the box to be cleared, counted from the left side of the screen. |
y0 | Starting vertical coordinate of the box to be cleared, counted down from the top of the screen. |
w | Width of the box to be cleared. |
h | height of the box to be cleared. |
unsigned int oledc_color565 | ( | char | r, |
char | g, | ||
char | b | ||
) |
Generates a 2-byte (16-bit) color code (RRRRRGGGGGGBBBBB format) for use with the OLED screen.
r | Amount of Red in the color, range is from 0-255. |
g | Amount of Green in the color, range is from 0-255. |
b | Amount of Blue in the color, range is from 0-255. |
void oledc_copy | ( | int | x0, |
int | y0, | ||
int | w, | ||
int | h, | ||
int | x2, | ||
int | y2 | ||
) |
Creates a copy a rectangular area of the screen at another position on the screen.
x0 | Starting horizontal coordinate of the box to be copied, counted from the left side of the screen. |
y0 | Starting vertical coordinate of the box to be copied, counted down from the top of the screen. |
w | Width of the box to be copied. |
h | height of the box to be copied. |
x2 | Horizontal coordinate where the copied box is to be pasted. |
y2 | Vertical coordinate where the copied box is to be pasted. |
void oledc_drawCircle | ( | int | x0, |
int | y0, | ||
int | r, | ||
unsigned int | color | ||
) |
Draws a circle on the screen in the specified color.
x0 | Horizontal coordinate of the center of the circle, counted from the left side of the screen. |
y0 | Vertical coordinate of the center of the circle, counted down from the top of the screen. |
r | Radius of the circle. |
color | Color of the pixel, in r5g6b5 format. |
void oledc_drawFastHLine | ( | int | x, |
int | y, | ||
int | w, | ||
unsigned int | color | ||
) |
Draws a horizontal line on the screen in the specified color.
x | Starting horizontal coordinate of the line, counted from the left side of the screen. |
y | Starting vertical coordinate of the line, counted down from the top of the screen. |
w | Length of the line. |
color | Color of the line, in r5g6b5 format. |
void oledc_drawFastVLine | ( | int | x, |
int | y, | ||
int | h, | ||
unsigned int | color | ||
) |
Draws a vertical line on the screen in the specified color.
x | Starting horizontal coordinate of the line, counted from the left side of the screen. |
y | Starting vertical coordinate of the line, counted down from the top of the screen. |
h | Length of the line. |
color | Color of the line, in r5g6b5 format. |
void oledc_drawLine | ( | int | x0, |
int | y0, | ||
int | x1, | ||
int | y1, | ||
unsigned int | color | ||
) |
Draws a line on the screen in the specified color.
x0 | Starting horizontal coordinate of the line, counted from the left side of the screen. |
y0 | Starting vertical coordinate of the line, counted down from the top of the screen. |
x1 | Ending horizontal coordinate of the line. |
y1 | Ending vertical coordinate of the line. |
color | Color of the pixel, in r5g6b5 format. |
void oledc_drawPixel | ( | int | x, |
int | y, | ||
unsigned int | color | ||
) |
Draws a single pixel on the screen in the specified color.
x | Horizontal coordinate of the pixel, counted from the left side of the screen. |
y | Vertical coordinate of the pixel, counted down from the top of the screen. |
color | Color of the pixel, in r5g6b5 format. |
void oledc_drawRect | ( | int | x, |
int | y, | ||
int | w, | ||
int | h, | ||
unsigned int | color | ||
) |
Draws a rectangle on the screen in the specified color.
x | Starting horizontal coordinate of the rectangle, counted from the left side of the screen. |
y | Starting vertical coordinate of the rectangle, counted down from the top of the screen. |
w | Width of the rectangle. |
h | Height of the rectangle. |
color | Color of the rectangle, in r5g6b5 format. |
void oledc_drawRoundRect | ( | int | x, |
int | y, | ||
int | w, | ||
int | h, | ||
int | r, | ||
unsigned int | color | ||
) |
Draws a rectangle with rounded corners on the screen in the specified color.
x | Starting horizontal coordinate of the rectangle, counted from the left side of the screen. |
y | Starting vertical coordinate of the rectangle, counted down from the top of the screen. |
w | Width of the rectangle. |
h | Height of the rectangle. |
r | Radius of the rounded corners. |
color | Color of the rectangle, in r5g6b5 format. |
void oledc_drawTriangle | ( | int | x0, |
int | y0, | ||
int | x1, | ||
int | y1, | ||
int | x2, | ||
int | y2, | ||
unsigned int | color | ||
) |
Draws a triangle with on the screen in the specified color.
x0 | Horizontal coordinate of the first vertex (corner) of the triangle, counted from the left side of the screen. |
y0 | Vertical coordinate of the first vertex (corner) of the triangle, counted down from the top of the screen. |
x1 | Horizontal coordinate of the second vertex of the triangle. |
y1 | Vertical coordinate of the first vertex of the triangle. |
x2 | Horizontal coordinate of the third vertex of the triangle. |
y2 | Vertical coordinate of the third vertex of the triangle. |
color | Color of the triangle, in r5g6b5 format. |
void oledc_fillCircle | ( | int | x0, |
int | y0, | ||
int | r, | ||
unsigned int | color | ||
) |
Draws a filled circle on the screen in the specified color.
x0 | Horizontal coordinate of the center of the circle, counted from the left side of the screen. |
y0 | Vertical coordinate of the center of the circle, counted down from the top of the screen. |
r | Radius of the circle. |
color | Color of the pixel, in r5g6b5 format. |
void oledc_fillRect | ( | int | x, |
int | y, | ||
int | w, | ||
int | h, | ||
unsigned int | color | ||
) |
Draws a filled rectangle on the screen in the specified color.
x | Starting horizontal coordinate of the rectangle, counted from the left side of the screen. |
y | Starting vertical coordinate of the rectangle, counted down from the top of the screen. |
w | Width of the rectangle. |
h | Height of the rectangle. |
color | Color of the rectangle, in r5g6b5 format. |
void oledc_fillRoundRect | ( | int | x, |
int | y, | ||
int | w, | ||
int | h, | ||
int | r, | ||
unsigned int | color | ||
) |
Draws a filled rectangle with rounded corners on the screen in the specified color.
x | Starting horizontal coordinate of the rectangle, counted from the left side of the screen. |
y | Starting vertical coordinate of the rectangle, counted down from the top of the screen. |
w | Width of the rectangle. |
h | Height of the rectangle. |
r | Radius of the rounded corners. |
color | Color of the rectangle, in r5g6b5 format. |
void oledc_fillTriangle | ( | int | x0, |
int | y0, | ||
int | x1, | ||
int | y1, | ||
int | x2, | ||
int | y2, | ||
unsigned int | color | ||
) |
Draws a filled triangle with on the screen in the specified color.
x0 | Horizontal coordinate of the first vertex (corner) of the triangle, counted from the left side of the screen. |
y0 | Vertical coordinate of the first vertex (corner) of the triangle, counted down from the top of the screen. |
x1 | Horizontal coordinate of the second vertex of the triangle. |
y1 | Vertical coordinate of the first vertex of the triangle. |
x2 | Horizontal coordinate of the third vertex of the triangle. |
y2 | Vertical coordinate of the third vertex of the triangle. |
color | Color of the triangle, in r5g6b5 format. |
int oledc_getCursorX | ( | ) |
Returns the current horizontal position of the cursor, measured from the left side of the screen in pixels.
int oledc_getCursorY | ( | ) |
Returns the current vertical position of the cursor, measured from the top of the screen in pixels.
int oledc_getHeight | ( | ) |
Returns the height of the screen per the screen's current orientation.
char oledc_getRotation | ( | ) |
Returns the screen's orientation. (0) means the pins are pointed upwards, (1) means the pins are pointed to the left, (2) means the pins are pointed down and (3) means the pins are pointed to the right.
int oledc_getWidth | ( | ) |
Returns the width of the screen per the screen's current orientation.
void oledc_init | ( | char | CS, |
char | RS, | ||
char | SID, | ||
char | SCLK, | ||
char | RST, | ||
char | screen_rotation | ||
) |
Initializes the OLED screen by setting up it's SPI and control pins.
CS | which pin is connected to the Chip Select pin, marked "CS". |
RS | which pin is connected to the Read Status pin, marked "D/C". |
SID | which pin is connected to the Serial Data In pin, marked "DIN". |
SCLK | which pin is connected to the Serial Clock pin, marked "CLK". |
RST | which pin is connected to the Reset pin, marked "RST". |
screen_rotation | Sets up the OLED screen and establishes its orientation. (0) means the pins are pointed upwards, (1) means the pins are pointed to the left, (2) means the pins are pointed down and (3) means the pins are pointed to the right. |
void oledc_invertDisplay | ( | ) |
Inverts the screen.
int oledc_isScrolling | ( | ) |
Returns (1) if the screen is currently scrolling and (0) if it is not.
int oledc_print | ( | const char * | fmt, |
... | |||
) |
Print format "..." args to the screen. The output is limited to 128 bytes.
void oledc_scrollStart | ( | char | h, |
char | v | ||
) |
Starts scrolling the entire image on the screen horizontally, vertically, or both.
h | Horizontal scrolling in rows per interval. (0) turns off horizontal scrolling, negative integers scroll to the left and positive integers scroll to the right. |
v | Vertical scrolling columns per interval. (0) turns off vertical scrolling, negative integers scroll down and positive integers scroll up. |
void oledc_scrollStop | ( | ) |
Stops scrolling the screen.
void oledc_setCursor | ( | int | x, |
int | y, | ||
char | size | ||
) |
Sets the cursor position based on the size parameter.
x | Horizontal position of the cursor, counted from the left side of the screen. |
y | Vertical position of the cursor, counted down from the top of the screen. |
size | The size of the cursor. Correlated to font size: (0) moves the cursor in 1 pixel increments, (1) moves the cursor in font size 1 character increments, (2) moves the cursor in font size 2 increments and (3) moves the cursor in font size 3 increments |
void oledc_setTextColor | ( | unsigned int | c, |
unsigned int | b | ||
) |
Sets the color of the font and the color of the background (highlighting) to be used. Setting the text color and text background to the same color will make the background color transparent.
c | Color of the font, in r5g6b5 format. |
b | Color of the font's background, in r5g6b5 format. To make the background transparent, set to the same color as the font itself. |
void oledc_setTextSize | ( | char | s | ) |
Sets the size of the font to be used. Range is from 1 to 3. Size (1) is 5x7 (6x8 spacing) pixels, size (2) is 11x15 (12x16 spacing) pixels and size (3) is 15x23 (16x24 spacing) pixels.
void oledc_setTextWrap | ( | char | w | ) |
Toggles automatic wrapping of text printed to the screen. (0) turns wrapping off, (1) turning wrapping on.