Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Adafruit_GFX by
MxSSD1306 Class Reference
The pure base class for the SSD1306 display driver. More...
#include <mx_ssd1306.h>
Inherits MxGfx.
Public Member Functions | |
| uint8_t | begin (uint8_t switchvcc=SSD1306_SWITCHCAPVCC) |
| Initialize. | |
| virtual void | drawPixel (int16_t x, int16_t y, uint16_t color) |
| Paint one BLACK or WHITE pixel in the display buffer. | |
| void | clearDisplay (void) |
| Clear the display buffer. | |
| virtual uint8_t | setContrast (uint8_t contrast) |
| Set display contrast. | |
| virtual uint8_t | displayOn (bool on) |
| Turn display on or off. | |
| virtual uint8_t | invertDisplay (bool i) |
| Invert Display. | |
| uint8_t | display () |
| Cause the display to be updated with the buffer content. | |
| virtual void | drawFastHLine (int16_t x, int16_t y, int16_t w, uint16_t color) |
| Draw a Horizontal Line. | |
| virtual void | drawRect (int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) |
| Draw a rectangle. | |
| virtual void | fillScreen (uint16_t color) |
| Fill the entire display. | |
| void | drawCircle (int16_t x0, int16_t y0, int16_t r, uint16_t color) |
| Draw a circle. | |
| void | fillCircle (int16_t x0, int16_t y0, int16_t r, uint16_t color) |
| Draw and fill a circle. | |
| void | drawTriangle (int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color) |
| Draw a triangle. | |
| void | fillTriangle (int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color) |
| Draw and fill a triangle. | |
| void | drawRoundRect (int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color) |
| Draw a rounded rectangle. | |
| void | fillRoundRect (int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color) |
| Draw and fill a rounded rectangle. | |
| void | drawBitmap (int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color) |
| Draw a bitmap. | |
| virtual void | drawLine (int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color) |
| Draw a line. | |
| virtual void | drawFastVLine (int16_t x, int16_t y, int16_t h, uint16_t color) |
| Draw a vertical line. | |
| virtual void | fillRect (int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) |
| Draw and fill a rectangle. | |
| void | drawChar (int16_t x, int16_t y, unsigned char c, uint16_t color, uint16_t bg, uint8_t size) |
| Draw a text character at a specified pixel location. | |
| size_t | writeChar (uint8_t) |
| Draw a text character at the text cursor location. | |
| int16_t | width (void) |
| Get the width of the display in pixels. | |
| int16_t | height (void) |
| Get the height of the display in pixels. | |
| void | setTextCursor (int16_t x, int16_t y) |
| Set the text cursor location, based on the size of the text. | |
| void | setTextSize (uint8_t s) |
| Set the size of the text to be drawn. | |
| void | setTextColor (uint16_t c) |
| Set the text foreground and background colors to be the same. | |
| void | setTextColor (uint16_t c, uint16_t b) |
| Set the text foreground and background colors independantly. | |
| void | setTextWrap (bool w) |
| Set text wraping mode true or false. | |
| void | setRotation (uint8_t r) |
| Set the display rotation, 1, 2, 3, or 4. | |
| uint8_t | getRotation (void) |
| Get the current rotation. | |
Protected Member Functions | |
| virtual uint8_t | sendDisplayBuffer ()=0 |
| Write contents of display buffer to OLED display. | |
| virtual uint8_t | sendDisplayBuffer (uint8_t rowBlock, uint8_t colBlock)=0 |
| Write a block of display data. | |
Detailed Description
The pure base class for the SSD1306 display driver.
You should derive from this for a new transport interface type, such as the SPI and I2C drivers.
Definition at line 53 of file mx_ssd1306.h.
Member Function Documentation
| uint8_t begin | ( | uint8_t | switchvcc = SSD1306_SWITCHCAPVCC ) |
Initialize.
- Returns:
- 0 if success, else I2C or SPI error code
Definition at line 64 of file mx_ssd1306.cpp.
| void clearDisplay | ( | void | ) |
Clear the display buffer.
Requires a display() call at some point afterwards. NOTE that this function will make the WHOLE display as dirty! The next display() call will update the entire display! This can be prevented by just clearing the required part of the display using fillRect()!
Definition at line 340 of file mx_ssd1306.cpp.
| uint8_t display | ( | void | ) |
Cause the display to be updated with the buffer content.
Send the display buffer out to the display.
- Returns:
- 0 if success, else I2C or SPI error code
Definition at line 220 of file mx_ssd1306.cpp.
| uint8_t displayOn | ( | bool | on ) | [virtual] |
Turn display on or off.
- Returns:
- 0 if success, else I2C or SPI error code
Definition at line 208 of file mx_ssd1306.cpp.
| void drawBitmap | ( | int16_t | x, |
| int16_t | y, | ||
| const uint8_t * | bitmap, | ||
| int16_t | w, | ||
| int16_t | h, | ||
| uint16_t | color | ||
| ) | [inherited] |
Draw a bitmap.
- Note:
- GFX_ENABLE_ABSTRACTS must be defined in im4oled_config.h
Definition at line 360 of file mx_gfx.cpp.
| void drawChar | ( | int16_t | x, |
| int16_t | y, | ||
| unsigned char | c, | ||
| uint16_t | color, | ||
| uint16_t | bg, | ||
| uint8_t | size | ||
| ) | [inherited] |
Draw a text character at a specified pixel location.
Definition at line 399 of file mx_gfx.cpp.
| void drawCircle | ( | int16_t | x0, |
| int16_t | y0, | ||
| int16_t | r, | ||
| uint16_t | color | ||
| ) | [inherited] |
Draw a circle.
- Note:
- GFX_ENABLE_ABSTRACTS must be defined in im4oled_config.h
Definition at line 25 of file mx_gfx.cpp.
| void drawFastHLine | ( | int16_t | x, |
| int16_t | y, | ||
| int16_t | w, | ||
| uint16_t | color | ||
| ) | [virtual, inherited] |
Draw a Horizontal Line.
- Note:
- GFX_ENABLE_ABSTRACTS must be defined in im4oled_config.h
Definition at line 228 of file mx_gfx.cpp.
| void drawFastVLine | ( | int16_t | x, |
| int16_t | y, | ||
| int16_t | h, | ||
| uint16_t | color | ||
| ) | [virtual, inherited] |
Draw a vertical line.
- Note:
- GFX_ENABLE_ABSTRACTS or GFX_SIZEABLE_TEXT must be defined in im4oled_config.h
Definition at line 195 of file mx_gfx.cpp.
| void drawLine | ( | int16_t | x0, |
| int16_t | y0, | ||
| int16_t | x1, | ||
| int16_t | y1, | ||
| uint16_t | color | ||
| ) | [virtual, inherited] |
Draw a line.
- Note:
- GFX_ENABLE_ABSTRACTS or GFX_SIZEABLE_TEXT must be defined in im4oled_config.h
Definition at line 151 of file mx_gfx.cpp.
| void drawPixel | ( | int16_t | x, |
| int16_t | y, | ||
| uint16_t | color | ||
| ) | [virtual] |
Paint one BLACK or WHITE pixel in the display buffer.
Implements MxGfx.
Definition at line 133 of file mx_ssd1306.cpp.
| void drawRect | ( | int16_t | x, |
| int16_t | y, | ||
| int16_t | w, | ||
| int16_t | h, | ||
| uint16_t | color | ||
| ) | [virtual, inherited] |
Draw a rectangle.
- Note:
- GFX_ENABLE_ABSTRACTS must be defined in im4oled_config.h
Definition at line 220 of file mx_gfx.cpp.
| void drawRoundRect | ( | int16_t | x0, |
| int16_t | y0, | ||
| int16_t | w, | ||
| int16_t | h, | ||
| int16_t | radius, | ||
| uint16_t | color | ||
| ) | [inherited] |
Draw a rounded rectangle.
- Note:
- GFX_ENABLE_ABSTRACTS must be defined in im4oled_config.h
Definition at line 240 of file mx_gfx.cpp.
| void drawTriangle | ( | int16_t | x0, |
| int16_t | y0, | ||
| int16_t | x1, | ||
| int16_t | y1, | ||
| int16_t | x2, | ||
| int16_t | y2, | ||
| uint16_t | color | ||
| ) | [inherited] |
Draw a triangle.
- Note:
- GFX_ENABLE_ABSTRACTS must be defined in im4oled_config.h
Definition at line 266 of file mx_gfx.cpp.
| void fillCircle | ( | int16_t | x0, |
| int16_t | y0, | ||
| int16_t | r, | ||
| uint16_t | color | ||
| ) | [inherited] |
Draw and fill a circle.
- Note:
- GFX_ENABLE_ABSTRACTS must be defined in im4oled_config.h
Definition at line 107 of file mx_gfx.cpp.
| void fillRect | ( | int16_t | x, |
| int16_t | y, | ||
| int16_t | w, | ||
| int16_t | h, | ||
| uint16_t | color | ||
| ) | [virtual, inherited] |
Draw and fill a rectangle.
The rectangle starts at given point, and extends DOWN(h) and RIGHTH(w)
- Note:
- GFX_ENABLE_ABSTRACTS or GFX_SIZEABLE_TEXT must be defined in im4oled_config.h
- Parameters:
-
x X coordinate, a value from 0 - (width-1) y Y coordinate, a value from 0 - (height-1) w Width from given x,y coordinate. Extends to the Right of given x,y h Height from given x,y coordinate. Extends Down of given x,y color For monochrome display, 0=off, 1=on
Definition at line 210 of file mx_gfx.cpp.
| void fillRoundRect | ( | int16_t | x0, |
| int16_t | y0, | ||
| int16_t | w, | ||
| int16_t | h, | ||
| int16_t | radius, | ||
| uint16_t | color | ||
| ) | [inherited] |
Draw and fill a rounded rectangle.
- Note:
- GFX_ENABLE_ABSTRACTS must be defined in im4oled_config.h
Definition at line 255 of file mx_gfx.cpp.
| void fillScreen | ( | uint16_t | color ) | [virtual, inherited] |
Fill the entire display.
- Note:
- GFX_ENABLE_ABSTRACTS must be defined in im4oled_config.h
Definition at line 234 of file mx_gfx.cpp.
| void fillTriangle | ( | int16_t | x0, |
| int16_t | y0, | ||
| int16_t | x1, | ||
| int16_t | y1, | ||
| int16_t | x2, | ||
| int16_t | y2, | ||
| uint16_t | color | ||
| ) | [inherited] |
Draw and fill a triangle.
- Note:
- GFX_ENABLE_ABSTRACTS must be defined in im4oled_config.h
Definition at line 274 of file mx_gfx.cpp.
| uint8_t getRotation | ( | void | ) | [inherited] |
| int16_t height | ( | void | ) | [inherited] |
| uint8_t invertDisplay | ( | bool | i ) | [virtual] |
Invert Display.
- Returns:
- 0 if success, else I2C or SPI error code
Reimplemented from MxGfx.
Definition at line 212 of file mx_ssd1306.cpp.
| virtual uint8_t sendDisplayBuffer | ( | ) | [protected, pure virtual] |
Write contents of display buffer to OLED display.
- Returns:
- 0 if success, else I2C or SPI error code
| virtual uint8_t sendDisplayBuffer | ( | uint8_t | rowBlock, |
| uint8_t | colBlock | ||
| ) | [protected, pure virtual] |
Write a block of display data.
The 128x64 pixels are divided into:
- 8 RowBlocks, each with 8 rows. This is 1 page of the SSD1206
- 8 ColBlocks, each with 16 columns.
- Parameters:
-
rowBlock Value 0-7 indicating what block of 8 rows to write. 0=0-7, 1=8-15, ...., 7=56-63 colBlock Value 0-7 indicating what block of 16 columns to write. 0=0-15, 1=16-31, ...., 7=112-127
- Returns:
- 0 if success, else I2C or SPI error code
| uint8_t setContrast | ( | uint8_t | contrast ) | [virtual] |
Set display contrast.
- Returns:
- 0 if success, else I2C or SPI error code
Definition at line 197 of file mx_ssd1306.cpp.
| void setRotation | ( | uint8_t | r ) | [inherited] |
Set the display rotation, 1, 2, 3, or 4.
Definition at line 447 of file mx_gfx.cpp.
| void setTextColor | ( | uint16_t | c ) | [inherited] |
| void setTextColor | ( | uint16_t | c, |
| uint16_t | b | ||
| ) | [inherited] |
| void setTextCursor | ( | int16_t | x, |
| int16_t | y | ||
| ) | [inherited] |
Set the text cursor location, based on the size of the text.
Following commands will write text to the RIGHT and BELOW this given x,y Coordinate. For example, use 0,0 to write text to top,left of display.
- Parameters:
-
x X coordinate, a value from 0 - (width-1) y Y coordinate, a value from 0 - (height-1)
| void setTextSize | ( | uint8_t | s ) | [inherited] |
| void setTextWrap | ( | bool | w ) | [inherited] |
| int16_t width | ( | void | ) | [inherited] |
| size_t writeChar | ( | uint8_t | c ) | [inherited] |
Draw a text character at the text cursor location.
Definition at line 376 of file mx_gfx.cpp.
Generated on Tue Jul 12 2022 19:44:12 by
1.7.2
