A simple yet powerful library for controlling graphical displays. Multiple display controllers are supported using inheritance.
Dependents: mbed_rifletool Hexi_Bubble_Game Hexi_Catch-the-dot_Game Hexi_Acceleromagnetic_Synth
SSD1306_I2C Class Reference
SSD1306_I2C class. More...
#include <SSD1306_I2C.h>
Inherits Display.
Public Types | |
enum | Address { ADDRESS_0 = (0x3C << 1), ADDRESS_1 = (0x3D << 1) } |
Represents the different I2C address possibilities for the SSD1306. More... | |
enum | State { NOT_INITIALIZED, DISPLAY_OFF, DISPLAY_ON } |
Represents the state of the Display. More... | |
Public Member Functions | |
SSD1306_I2C (PinName sda, PinName scl, Address addr) | |
Create an SSD1306 object connected to the specified I2C pins with the specified I2C slave address. | |
virtual bool | open () |
Create an SSD1306 object connected to the specified SPI pins with the specified /CS and DC pins. | |
virtual void | flush () |
Send the buffer to the SSD1306. | |
virtual Display::State | state () |
Get the current state of the SSD1306. | |
virtual void | state (State s) |
Set the state of the SSD1306. | |
virtual void | drawPixel (int x, int y, unsigned int c) |
Draw a single pixel at the specified coordinates. | |
virtual void | clear (unsigned int c=0xFF000000) |
Fill the entire canvas with the specified color using a filled rectangle. | |
virtual void | drawLine (int x0, int y0, int x1, int y1, unsigned int c) |
Draw a line between the specified coordinates using Bresenham's line algorithm. | |
virtual void | drawHLine (int x, int y, int w, unsigned int c) |
Draw a fast horizontal line of the specified width, at the specified coordinates. | |
virtual void | drawVLine (int x, int y, int h, unsigned int c) |
Draw a fast vertical line of the specified height, at the specified coordinates. | |
virtual void | drawRect (int x, int y, int w, int h, unsigned int c) |
Draw an unfilled rectangle of the specified width and height, at the specified coordinates using fast lines. | |
virtual void | fillRect (int x, int y, int w, int h, unsigned int c) |
Draw a filled rectangle of the specified width and height, at the specified coordinates using fast lines. | |
void | drawTriangle (int x0, int y0, int x1, int y1, int x2, int y2, unsigned int c) |
Draw an unfilled triangle with the specified vertices using lines. | |
void | fillTriangle (int x0, int y0, int x1, int y1, int x2, int y2, unsigned int c) |
Draw a filled triangle with the specified vertices using Adafruit's algorithm. | |
void | drawCircle (int x, int y, int r, unsigned int c) |
Draw an unfilled circle of the specified radius, at the specified coordinates using the midpoint circle algorithm. | |
void | fillCircle (int x, int y, int r, unsigned int c) |
Draw a filled circle of the specified radius, at the specified coordinates using Adafruit's modified midpoint circle algorithm. | |
void | drawRoundRect (int x, int y, int w, int h, int r, unsigned int c) |
Draw an unfilled rounded rectangle of the specified width, height, and corner radius, at the specified coordinates using Adafruit's algorithm. | |
void | fillRoundRect (int x, int y, int w, int h, int r, unsigned int c) |
Draw a filled rounded rectangle of the specified width, height, and corner radius, at the specified coordinates using Adafruit's algorithm. | |
void | drawImage (Image *img, int x, int y) |
Draw an Image object at the specified coordinates. | |
int | drawChar (char c, Font *fnt, int x, int y) |
Draw a character at the specified coordinates without wrapping. | |
void | drawString (const char *str, Font *fnt, int x, int y) |
Draw a string at the specified coordinates without wrapping. | |
void | drawString (const char *str, Font *fnt, int x, int y, int w, int h) |
Draw a string within the specified rectangle with wrapping. | |
int | width () |
Get the width of the canvas. | |
int | height () |
Get the height of the canvas. |
Detailed Description
SSD1306_I2C class.
Used for controlling an SSD1306-based OLED display connected to i2c.
Definition at line 26 of file SSD1306_I2C.h.
Member Enumeration Documentation
enum Address |
Represents the different I2C address possibilities for the SSD1306.
Definition at line 31 of file SSD1306_I2C.h.
enum State [inherited] |
Constructor & Destructor Documentation
SSD1306_I2C | ( | PinName | sda, |
PinName | scl, | ||
Address | addr | ||
) |
Create an SSD1306 object connected to the specified I2C pins with the specified I2C slave address.
- Parameters:
-
sda The I2C data pin. scl The I2C clock pin. addr The I2C slave address.
Definition at line 19 of file SSD1306_I2C.cpp.
Member Function Documentation
void clear | ( | unsigned int | c = 0xFF000000 ) |
[virtual, inherited] |
Fill the entire canvas with the specified color using a filled rectangle.
- Parameters:
-
c The color to fill with as a 32-bit ARGB value (black by default).
Definition at line 25 of file Canvas.cpp.
int drawChar | ( | char | c, |
Font * | fnt, | ||
int | x, | ||
int | y | ||
) | [inherited] |
Draw a character at the specified coordinates without wrapping.
- Parameters:
-
c The character to draw. fnt Pointer to the font to draw with. x The starting X coordinate. y The starting Y coordinate.
- Returns:
- The width of the drawn character.
Definition at line 288 of file Canvas.cpp.
void drawCircle | ( | int | x, |
int | y, | ||
int | r, | ||
unsigned int | c | ||
) | [inherited] |
Draw an unfilled circle of the specified radius, at the specified coordinates using the midpoint circle algorithm.
- Parameters:
-
x The center X coordinate. y The center Y coordinate. r The radius of the circle. c The color of the circle as a 32-bit ARGB value.
Definition at line 215 of file Canvas.cpp.
void drawHLine | ( | int | x, |
int | y, | ||
int | w, | ||
unsigned int | c | ||
) | [virtual, inherited] |
Draw a fast horizontal line of the specified width, at the specified coordinates.
- Parameters:
-
x The starting X coordinate. y The starting Y coordinate. w The width of the line. c The color of the line as a 32-bit ARGB value.
Definition at line 80 of file Canvas.cpp.
void drawImage | ( | Image * | img, |
int | x, | ||
int | y | ||
) | [inherited] |
Draw an Image object at the specified coordinates.
- Parameters:
-
img Pointer to the image to draw. x The starting X coordinate. y The starting Y coordinate.
Definition at line 279 of file Canvas.cpp.
void drawLine | ( | int | x0, |
int | y0, | ||
int | x1, | ||
int | y1, | ||
unsigned int | c | ||
) | [virtual, inherited] |
Draw a line between the specified coordinates using Bresenham's line algorithm.
- Parameters:
-
x0 The starting X coordinate. y0 The starting Y coordinate. x1 The ending X coordinate. y1 The ending Y coordinate. c The color of the line as a 32-bit ARGB value.
Definition at line 30 of file Canvas.cpp.
void drawPixel | ( | int | x, |
int | y, | ||
unsigned int | c | ||
) | [virtual] |
Draw a single pixel at the specified coordinates.
- Parameters:
-
x The X coordinate. y The Y coordinate. c The color of the pixel as a 32-bit ARGB value.
Implements Canvas.
Definition at line 98 of file SSD1306_I2C.cpp.
void drawRect | ( | int | x, |
int | y, | ||
int | w, | ||
int | h, | ||
unsigned int | c | ||
) | [virtual, inherited] |
Draw an unfilled rectangle of the specified width and height, at the specified coordinates using fast lines.
- Parameters:
-
x The starting X coordinate. y The starting Y coordinate. w The width of the rectangle. h The height of the rectangle. c The color of the rectangle as a 32-bit ARGB value.
Definition at line 90 of file Canvas.cpp.
void drawRoundRect | ( | int | x, |
int | y, | ||
int | w, | ||
int | h, | ||
int | r, | ||
unsigned int | c | ||
) | [inherited] |
Draw an unfilled rounded rectangle of the specified width, height, and corner radius, at the specified coordinates using Adafruit's algorithm.
- Parameters:
-
x The starting X coordinate. y The starting Y coordinate. w The width of the rectangle. h The height of the rectangle. r The radius of the corners. c The color of the rectangle as a 32-bit ARGB value.
Definition at line 254 of file Canvas.cpp.
void drawString | ( | const char * | str, |
Font * | fnt, | ||
int | x, | ||
int | y, | ||
int | w, | ||
int | h | ||
) | [inherited] |
Draw a string within the specified rectangle with wrapping.
- Parameters:
-
str Pointer to the string to draw. fnt Pointer to the font to draw with. x The starting X coordinate. y The starting Y coordinate. w The width of the bounding rectangle. h The height of the bounding rectangle.
Definition at line 329 of file Canvas.cpp.
void drawString | ( | const char * | str, |
Font * | fnt, | ||
int | x, | ||
int | y | ||
) | [inherited] |
Draw a string at the specified coordinates without wrapping.
- Parameters:
-
str Pointer to the string to draw. fnt Pointer to the font to draw with. x The starting X coordinate. y The starting Y coordinate.
Definition at line 300 of file Canvas.cpp.
void drawTriangle | ( | int | x0, |
int | y0, | ||
int | x1, | ||
int | y1, | ||
int | x2, | ||
int | y2, | ||
unsigned int | c | ||
) | [inherited] |
Draw an unfilled triangle with the specified vertices using lines.
- Parameters:
-
x0 The first vertex X coordinate. y0 The first vertex Y coordinate. x1 The second vertex X coordinate. y1 The second vertex Y coordinate. x2 The third vertex X coordinate. y2 The third vertex Y coordinate. c The color of the triangle as a 32-bit ARGB value.
Definition at line 105 of file Canvas.cpp.
void drawVLine | ( | int | x, |
int | y, | ||
int | h, | ||
unsigned int | c | ||
) | [virtual, inherited] |
Draw a fast vertical line of the specified height, at the specified coordinates.
- Parameters:
-
x The starting X coordinate. y The starting Y coordinate. h The height of the line. c The color of the line as a 32-bit ARGB value.
Definition at line 85 of file Canvas.cpp.
void fillCircle | ( | int | x, |
int | y, | ||
int | r, | ||
unsigned int | c | ||
) | [inherited] |
Draw a filled circle of the specified radius, at the specified coordinates using Adafruit's modified midpoint circle algorithm.
- Parameters:
-
x The center X coordinate. y The center Y coordinate. r The radius of the circle. c The color of the circle as a 32-bit ARGB value.
Definition at line 248 of file Canvas.cpp.
void fillRect | ( | int | x, |
int | y, | ||
int | w, | ||
int | h, | ||
unsigned int | c | ||
) | [virtual, inherited] |
Draw a filled rectangle of the specified width and height, at the specified coordinates using fast lines.
- Parameters:
-
x The starting X coordinate. y The starting Y coordinate. w The width of the rectangle. h The height of the rectangle. c The color of the rectangle as a 32-bit ARGB value.
Definition at line 98 of file Canvas.cpp.
void fillRoundRect | ( | int | x, |
int | y, | ||
int | w, | ||
int | h, | ||
int | r, | ||
unsigned int | c | ||
) | [inherited] |
Draw a filled rounded rectangle of the specified width, height, and corner radius, at the specified coordinates using Adafruit's algorithm.
- Parameters:
-
x The starting X coordinate. y The starting Y coordinate. w The width of the rectangle. h The height of the rectangle. r The radius of the corners. c The color of the rectangle as a 32-bit ARGB value.
Definition at line 269 of file Canvas.cpp.
void fillTriangle | ( | int | x0, |
int | y0, | ||
int | x1, | ||
int | y1, | ||
int | x2, | ||
int | y2, | ||
unsigned int | c | ||
) | [inherited] |
Draw a filled triangle with the specified vertices using Adafruit's algorithm.
- Parameters:
-
x0 The first vertex X coordinate. y0 The first vertex Y coordinate. x1 The second vertex X coordinate. y1 The second vertex Y coordinate. x2 The third vertex X coordinate. y2 The third vertex Y coordinate. c The color of the triangle as a 32-bit ARGB value.
Definition at line 112 of file Canvas.cpp.
void flush | ( | ) | [virtual] |
Send the buffer to the SSD1306.
Reimplemented from Display.
Definition at line 63 of file SSD1306_I2C.cpp.
int height | ( | ) | [inherited] |
Get the height of the canvas.
- Returns:
- The height of the canvas.
Definition at line 427 of file Canvas.cpp.
bool open | ( | ) | [virtual] |
Create an SSD1306 object connected to the specified SPI pins with the specified /CS and DC pins.
- Parameters:
-
mosi The SPI data out pin. miso The SPI data in pin. sclk The SPI clock pin. sclk The SPI chip select pin. sclk The data/command pin. Probe for the SSD1306 and initialize it if present
- Returns:
- 'true' if the device exists on the bus, 'false' if the device doesn't exist on the bus.
Implements Display.
Definition at line 25 of file SSD1306_I2C.cpp.
void state | ( | State | s ) | [virtual] |
Set the state of the SSD1306.
- Parameters:
-
mode The new state as a Display::State enum.
Reimplemented from Display.
Definition at line 83 of file SSD1306_I2C.cpp.
Display::State state | ( | ) | [virtual] |
Get the current state of the SSD1306.
- Returns:
- The current state as a Display::State enum.
Reimplemented from Display.
Definition at line 77 of file SSD1306_I2C.cpp.
int width | ( | ) | [inherited] |
Get the width of the canvas.
- Returns:
- The width of the canvas.
Definition at line 422 of file Canvas.cpp.
Generated on Tue Jul 12 2022 20:26:18 by 1.7.2