Viking Skull Lamp  V1.0.1
Loading...
Searching...
No Matches
ssd1306 Class Reference

Display driver object. More...

#include <oled.hpp>

Public Member Functions

 ssd1306 (uint8_t address_p)
 Constructor. More...
 
bool begin ()
 Init function for the display. More...
 
void displayOn ()
 Turn on the oled panel. More...
 
void displayOff ()
 Turn off the oled panel. More...
 
void update ()
 Update the content of the panel. More...
 
void setPixel (uint8_t x, uint8_t y)
 Set a pixel by location. More...
 
void clearPixel (uint8_t x, uint8_t y)
 Clear a pixel by location. More...
 
void fillRect (uint8_t x, uint8_t y, uint8_t w, uint8_t h)
 Create a filled rectangle. More...
 
void clearRect (uint8_t x, uint8_t y, uint8_t w, uint8_t h)
 Create a cleared rectangle. More...
 
void writeCharacter (uint8_t c)
 Write a character to the display. More...
 
void clear ()
 Clear the display. More...
 
void print (char *str)
 Print a c-string tho the display. More...
 
void print (int d)
 Print number to the display. More...
 
void line (uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2)
 Print line to the display. More...
 

Public Attributes

bool inverted = false
 If this flag is set, the draw logic will be inverted. More...
 
uint8_t cursorX = 0
 X-coordinate of the cursor. More...
 
uint8_t cursorY = 0
 Y-coordinate of the cursor. More...
 

Private Member Functions

void writeData (uint8_t *data, uint16_t dataSize)
 Write data to the display. More...
 
void writeCommand (uint8_t c)
 Write command to the display. More...
 

Private Attributes

uint8_t buffer [SSD1306_WIDTH *SSD1306_HEIGHT/8] = { 0 }
 Pixel buffer. More...
 
uint8_t address = 0
 Address of the display. More...
 

Detailed Description

Display driver object.

This is a very optimized driver for the SSD1306 oled display driver. It uses ideas from lot other libraries, but it has been optimized to fit in this project.

Definition at line 156 of file oled.hpp.

Constructor & Destructor Documentation

◆ ssd1306()

ssd1306::ssd1306 ( uint8_t  address_p)

Constructor.

Parameters
address_pI2C address of the display.

Definition at line 32 of file oled.cpp.

Member Function Documentation

◆ begin()

bool ssd1306::begin ( )

Init function for the display.

Returns
Returns true if the init section succeeds.

Definition at line 38 of file oled.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clear()

void ssd1306::clear ( )

Clear the display.

Definition at line 134 of file oled.cpp.

Here is the caller graph for this function:

◆ clearPixel()

void ssd1306::clearPixel ( uint8_t  x,
uint8_t  y 
)

Clear a pixel by location.

Parameters
xX-coordinate of the pixel.
yY-coordinate of the pixel.

Definition at line 236 of file oled.cpp.

Here is the caller graph for this function:

◆ clearRect()

void ssd1306::clearRect ( uint8_t  x,
uint8_t  y,
uint8_t  w,
uint8_t  h 
)

Create a cleared rectangle.

Parameters
xX-coordinate of the start corner.
yY-coordinate of the start corner.
wWidth of the rectangle.
hHeight of the rectangle.

Definition at line 274 of file oled.cpp.

Here is the call graph for this function:

◆ displayOff()

void ssd1306::displayOff ( )

Turn off the oled panel.

Definition at line 210 of file oled.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ displayOn()

void ssd1306::displayOn ( )

Turn on the oled panel.

Definition at line 204 of file oled.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fillRect()

void ssd1306::fillRect ( uint8_t  x,
uint8_t  y,
uint8_t  w,
uint8_t  h 
)

Create a filled rectangle.

Parameters
xX-coordinate of the start corner.
yY-coordinate of the start corner.
wWidth of the rectangle.
hHeight of the rectangle.

Definition at line 256 of file oled.cpp.

Here is the call graph for this function:

◆ line()

void ssd1306::line ( uint8_t  x1,
uint8_t  y1,
uint8_t  x2,
uint8_t  y2 
)

Print line to the display.

Parameters
x1X-coordinate of the start point.
y1Y-coordinate of the start point.
x2X-coordinate of the end point.
y2Y-coordinate of the end point.

Definition at line 385 of file oled.cpp.

Here is the call graph for this function:

◆ print() [1/2]

void ssd1306::print ( char *  str)

Print a c-string tho the display.

Note
The cursor has to be set before this function.
Parameters
strC-like string, that will be printed on the display.

Definition at line 360 of file oled.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print() [2/2]

void ssd1306::print ( int  d)

Print number to the display.

Note
The cursor has to be set before this function.
Parameters
dThe number, that has o be printed on the display.

Definition at line 374 of file oled.cpp.

Here is the call graph for this function:

◆ setPixel()

void ssd1306::setPixel ( uint8_t  x,
uint8_t  y 
)

Set a pixel by location.

Parameters
xX-coordinate of the pixel.
yY-coordinate of the pixel.

Definition at line 216 of file oled.cpp.

Here is the caller graph for this function:

◆ update()

void ssd1306::update ( )

Update the content of the panel.

It writes the content of the buffer to the display.

Warning
Changes on the display will only be visible after calling this function.

Definition at line 141 of file oled.cpp.

Here is the call graph for this function:

◆ writeCharacter()

void ssd1306::writeCharacter ( uint8_t  c)

Write a character to the display.

Note
The cursor has to be set before this function.
Parameters
cCharacter to write.

Definition at line 292 of file oled.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeCommand()

void ssd1306::writeCommand ( uint8_t  c)
private

Write command to the display.

Parameters
cCommand byte

Definition at line 194 of file oled.cpp.

Here is the caller graph for this function:

◆ writeData()

void ssd1306::writeData ( uint8_t *  data,
uint16_t  dataSize 
)
private

Write data to the display.

Parameters
dataPointer to a byte array, that will be sent as data.
dataSizeSize of the byte array.

Definition at line 157 of file oled.cpp.

Here is the caller graph for this function:

Member Data Documentation

◆ address

uint8_t ssd1306::address = 0
private

Address of the display.

Definition at line 255 of file oled.hpp.

◆ buffer

uint8_t ssd1306::buffer[SSD1306_WIDTH *SSD1306_HEIGHT/8] = { 0 }
private

Pixel buffer.

Definition at line 243 of file oled.hpp.

◆ cursorX

uint8_t ssd1306::cursorX = 0

X-coordinate of the cursor.

Definition at line 234 of file oled.hpp.

◆ cursorY

uint8_t ssd1306::cursorY = 0

Y-coordinate of the cursor.

Definition at line 237 of file oled.hpp.

◆ inverted

bool ssd1306::inverted = false

If this flag is set, the draw logic will be inverted.

That means set is black pixel, clear is lit pixel.

Definition at line 231 of file oled.hpp.