![]() |
Color OLED module library
v0.5
Library for the WaveShare 0.96-inch color OLED (SSD1331) module
|
#include "simplegfx.h"#include "simpletools.h"Go to the source code of this file.
Drawing, Text, and Bitmap Functions | |
| simplegfx Library | |
| This display driver calls and uses functions from the simplegfx library. | |
Functions | |
| screen_t * | ssd1331_init (char sdi, char sclk, char cs, char rs, char rst, int _width, int _height) |
| void | ssd1331_drawPixel (screen_t *dev, int x, int y, int color) |
| Draws a single pixel on the screen in the specified color. No checking. More... | |
| void | ssd1331_drawLine (screen_t *dev, int x0, int y0, int x1, int y1, int color) |
| Draws a line on the screen in the specified color. More... | |
| void | ssd1331_drawFastVLine (screen_t *dev, int x, int y, int w, int color) |
| Draws a vertical line on the screen in the specified color. No bounds checking (used by other functions that do the bounds checking first) More... | |
| void | ssd1331_drawFastHLine (screen_t *dev, int x, int y, int h, int color) |
| Draws a horizontal line on the screen in the specified color. No bounds checking (used by other functions that do the bounds checking first) More... | |
| void | ssd1331_fillRect (screen_t *dev, int x0, int y0, int x1, int y1, int color) |
| Draws a filled rectangle on the screen in the specified color. More... | |
| void | ssd1331_clearDisplay (screen_t *dev) |
| Clears the screen by setting the full area of the display to black. More... | |
| void | ssd1331_resetDisplay (screen_t *dev) |
| Resets the display. More... | |
| void | ssd1331_writeByte (int mask_cs, int mask_sdi, int mask_clk, int mask_dc, char c, char dc) |
| Low level function that transfers bytes to the screen. More... | |
| char | ssd1331_writeLock () |
| Returns the status of the SPI communication lockout so multiple cogs don't try to write to it at the same time. More... | |
| void | ssd1331_writeLockSet (char devId) |
| Sets the SPI communication lockout. More... | |
| void | ssd1331_writeLockClear (char devId) |
| Clears the SPI communication lockout. More... | |
| void | ssd1331_copy (screen_t *dev, 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... | |
| void | ssd1331_scrollDisplay (screen_t *dev, int h, int v) |
| Starts scrolling the entire image on the screen horizontally, vertically, or both. More... | |
| void | ssd1331_invertDisplay (screen_t *dev, char i) |
| Inverts the screen. More... | |
| void | ssd1331_sleepWakeDisplay (screen_t *dev, char i) |
| Sleeps or Wakes the display. More... | |
Macros | |
| #define | WHITE 0xFFFF |
| #define | PINK 0xFD59 |
| #define | MAGENTA 0xC9D4 |
| #define | RED 0xC082 |
| #define | DARKRED 0xA000 |
| #define | REDORANGE 0xD261 |
| #define | LIGHTORANGE 0xDDB2 |
| #define | ORANGE 0xFC00 |
| #define | YELLOWORANGE 0xFCE0 |
| #define | GOLD 0xF704 |
| #define | YELLOW 0xF744 |
| #define | LEMON 0xD6CF |
| #define | YELLOWGREEN 0x5600 |
| #define | GREEN 0x1C62 |
| #define | DARKGREEN 0x02C0 |
| #define | GREENBLUE 0x0C75 |
| #define | CYAN 0x5E97 |
| #define | LIGHTBLUE 0x857B |
| #define | SKYBLUE 0x0E3E |
| #define | BLUE 0x2B16 |
| #define | NAVYBLUE 0x0009 |
| #define | VIOLET 0x7817 |
| #define | PURPLE 0xA017 |
| #define | RASPBERRY 0x902A |
| #define | TAN 0xCC2A |
| #define | LIGHTBROWN 0xBB44 |
| #define | BRONZE 0xA440 |
| #define | BROWN 0x9201 |
| #define | DARKBROWN 0x51E7 |
| #define | LIGHTGRAY 0xBDD7 |
| #define | GRAY 0x8410 |
| #define | DARKGRAY 0x3186 |
| #define | BLACK 0x0000 |
| #define | SSD1331_CMD_DRAWLINE 0x21 |
| #define | SSD1331_CMD_DRAWRECT 0x22 |
| #define | SSD1331_CMD_COPY 0x23 |
| #define | SSD1331_CMD_CLEAR 0x25 |
| #define | SSD1331_CMD_FILL 0x26 |
| #define | SSD1331_CMD_SCROLLSETUP 0x27 |
| #define | SSD1331_CMD_SCROLLSTOP 0x2E |
| #define | SSD1331_CMD_SCROLLSTART 0x2F |
| #define | SSD1331_CMD_SETCOLUMN 0x15 |
| #define | SSD1331_CMD_SETROW 0x75 |
| #define | SSD1331_CMD_CONTRASTA 0x81 |
| #define | SSD1331_CMD_CONTRASTB 0x82 |
| #define | SSD1331_CMD_CONTRASTC 0x83 |
| #define | SSD1331_CMD_MASTERCURRENT 0x87 |
| #define | SSD1331_CMD_SETREMAP 0xA0 |
| #define | SSD1331_CMD_STARTLINE 0xA1 |
| #define | SSD1331_CMD_DISPLAYOFFSET 0xA2 |
| #define | SSD1331_CMD_NORMALDISPLAY 0xA4 |
| #define | SSD1331_CMD_DISPLAYALLON 0xA5 |
| #define | SSD1331_CMD_DISPLAYALLOFF 0xA6 |
| #define | SSD1331_CMD_INVERTDISPLAY 0xA7 |
| #define | SSD1331_CMD_SETMULTIPLEX 0xA8 |
| #define | SSD1331_CMD_SETMASTER 0xAD |
| #define | SSD1331_CMD_DISPLAYOFF 0xAE |
| #define | SSD1331_CMD_DISPLAYON 0xAF |
| #define | SSD1331_CMD_POWERMODE 0xB0 |
| #define | SSD1331_CMD_PRECHARGE 0xB1 |
| #define | SSD1331_CMD_CLOCKDIV 0xB3 |
| #define | SSD1331_CMD_PRECHARGEA 0x8A |
| #define | SSD1331_CMD_PRECHARGEB 0x8B |
| #define | SSD1331_CMD_PRECHARGEC 0x8C |
| #define | SSD1331_CMD_PRECHARGELEVEL 0xBB |
| #define | SSD1331_CMD_VCOMH 0xBE |
| void ssd1331_clearDisplay | ( | screen_t * | dev | ) |
Clears the screen by setting the full area of the display to black.
| dev | Pointer to the display's device structure returned by the initialization function. |
| void ssd1331_copy | ( | screen_t * | dev, |
| 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.
| dev | Pointer to the display's device structure returned by the initialization function. |
| 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 ssd1331_drawFastHLine | ( | screen_t * | dev, |
| int | x, | ||
| int | y, | ||
| int | h, | ||
| int | color | ||
| ) |
Draws a horizontal line on the screen in the specified color. No bounds checking (used by other functions that do the bounds checking first)
| dev | Pointer to the display's device structure returned by the initialization function. |
| x | Horizontal coordinate of the line, counted from the left side of the screen. |
| y | Vertical coordinate of the line. |
| h | Length of the line in pixels. |
| color | Color of the line. |
| void ssd1331_drawFastVLine | ( | screen_t * | dev, |
| int | x, | ||
| int | y, | ||
| int | w, | ||
| int | color | ||
| ) |
Draws a vertical line on the screen in the specified color. No bounds checking (used by other functions that do the bounds checking first)
| dev | Pointer to the display's device structure returned by the initialization function. |
| x | Horizontal coordinate of the line. |
| y | Vertical coordinate of the line, counted down from the top of the screen. |
| w | Length of the line in pixels. |
| color | Color of the line. |
| void ssd1331_drawLine | ( | screen_t * | dev, |
| int | x0, | ||
| int | y0, | ||
| int | x1, | ||
| int | y1, | ||
| int | color | ||
| ) |
Draws a line on the screen in the specified color.
| dev | Pointer to the display's device structure returned by the initialization function. |
| 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 ssd1331_drawPixel | ( | screen_t * | dev, |
| int | x, | ||
| int | y, | ||
| int | color | ||
| ) |
Draws a single pixel on the screen in the specified color. No checking.
| dev | Pointer to the display's device structure returned by the initialization function. |
| 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. |
| void ssd1331_fillRect | ( | screen_t * | dev, |
| int | x0, | ||
| int | y0, | ||
| int | x1, | ||
| int | y1, | ||
| int | color | ||
| ) |
Draws a filled rectangle on the screen in the specified color.
| dev | Pointer to the display's device structure returned by the initialization function. |
| x0 | Starting horizontal coordinate of the rectangle, counted from the left side of the screen. |
| y0 | Starting vertical coordinate of the rectangle, counted down from the top of the screen. |
| x1 | Ending horizontal coordinate of the rectangle, counted from the left side of the screen. |
| y1 | Ending vertical coordinate of the rectangle, counted down from the top of the screen. |
| color | Color of the rectangle, in r5g6b5 format. |
| screen_t* ssd1331_init | ( | char | sdi, |
| char | sclk, | ||
| char | cs, | ||
| char | rs, | ||
| char | rst, | ||
| int | _width, | ||
| int | _height | ||
| ) |
| void ssd1331_invertDisplay | ( | screen_t * | dev, |
| char | i | ||
| ) |
Inverts the screen.
| dev | Pointer to the display's device structure returned by the initialization function. |
| i | Mode to set the inversion to: (0) sets the display to normal and (1) inverts the colors of the display. |
| void ssd1331_resetDisplay | ( | screen_t * | dev | ) |
Resets the display.
| dev | Pointer to the display's device structure returned by the initialization function. |
| void ssd1331_scrollDisplay | ( | screen_t * | dev, |
| int | h, | ||
| int | v | ||
| ) |
Starts scrolling the entire image on the screen horizontally, vertically, or both.
| dev | Pointer to the display's device structure returned by the initialization function. |
| 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 ssd1331_sleepWakeDisplay | ( | screen_t * | dev, |
| char | i | ||
| ) |
Sleeps or Wakes the display.
| dev | Pointer to the display's device structure returned by the initialization function. |
| i | Mode to set the display to: (0) wakes the display (1) sleeps the display. |
| void ssd1331_writeByte | ( | int | mask_cs, |
| int | mask_sdi, | ||
| int | mask_clk, | ||
| int | mask_dc, | ||
| char | c, | ||
| char | dc | ||
| ) |
Low level function that transfers bytes to the screen.
| mask_cs | Pin mask for the display's chip select pin. |
| mask_sdi | Pin mask for the display's serial data in pin. |
| mask_clk | Pin mask for the display's clock pin. |
| mask_dc | Pin mask for the display's data/command pin. |
| c | Byte to be transferred. |
| dc | Toggle whether the byte is a command or data. |
| char ssd1331_writeLock | ( | ) |
Returns the status of the SPI communication lockout so multiple cogs don't try to write to it at the same time.
| void ssd1331_writeLockClear | ( | char | devId | ) |
Clears the SPI communication lockout.
| devId | The ID of the device (usually the chip select pin). |
| void ssd1331_writeLockSet | ( | char | devId | ) |
Sets the SPI communication lockout.
| devId | The ID of the device (usually the chip select pin). |
1.8.14