SSD1306 OLED display driver  1.3.2
This library is developed to control SSD1306 i2c/spi OLED display
Public Member Functions | List of all members
TinySSD1306 Class Reference

#include <tiny_ssd1306.h>

Inheritance diagram for TinySSD1306:

Public Member Functions

 TinySSD1306 (InitFunction lcd)
 
void begin ()
 
void beginI2C (int8_t scl=-1, int8_t sda=-1, uint8_t addr=0)
 
void beginSPI (int8_t csPin=-1, int8_t dcPin=-1)
 Initializes default custom spi interface and lcd display. More...
 
void off ()
 
void on ()
 
void invertMode ()
 
void normalMode ()
 
uint8_t height ()
 
uint8_t width ()
 
void setCursor (uint8_t x, uint8_t y)
 
void fill (uint8_t fill_Data)
 
void clear ()
 
void negativeMode ()
 
void positiveMode ()
 
uint8_t charF6x8 (uint8_t x, uint8_t y, const char ch[], EFontStyle style=STYLE_NORMAL)
 
uint8_t charF12x16 (uint8_t xpos, uint8_t y, const char ch[], EFontStyle style=STYLE_NORMAL)
 
uint8_t charF6x8_eol (uint8_t left, uint8_t y, const char ch[], EFontStyle style, uint8_t right)
 
void putPixel (uint8_t x, uint8_t y)
 
void putPixels (uint8_t x, uint8_t y, uint8_t pixels)
 
void drawRect (uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2)
 
void drawHLine (uint8_t x1, uint8_t y1, uint8_t x2)
 
void drawVLine (uint8_t x1, uint8_t y1, uint8_t y2)
 
void drawBuffer (uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *buf)
 
void drawBitmap (uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *buf)
 
void clearBlock (uint8_t x, uint8_t y, uint8_t w, uint8_t h)
 
virtual size_t write (uint8_t ch)
 

Detailed Description

TinySSD1306 represents object to work with LCD display. Easy to use:

void setup()
{
lcd.beginI2C();
lcd.clear();
lcd.charF6x8(0,0,"Hello");
}

Definition at line 55 of file tiny_ssd1306.h.

Constructor & Destructor Documentation

◆ TinySSD1306()

TinySSD1306::TinySSD1306 ( InitFunction  lcd)
inlineexplicit

Creates object for communicating with LCD display.

Parameters
lcd- initialization callback for LCD
See also
SSD1306_128x64
SSD1306_128x32

Definition at line 64 of file tiny_ssd1306.h.

Member Function Documentation

◆ begin()

void TinySSD1306::begin ( )
inline

Initializes lcd display. SPI or i2c interface should be initializes prior to calling this method.

Definition at line 70 of file tiny_ssd1306.h.

◆ beginI2C()

void TinySSD1306::beginI2C ( int8_t  scl = -1,
int8_t  sda = -1,
uint8_t  addr = 0 
)
inline

Initializes default custom i2c interface and lcd display.

Parameters
scl- i2c clock pin. Use -1 if you don't need to change default pin number
sda- i2c data pin. Use -1 if you don't need to change default pin number
addr- i2c address of lcd display. Use 0 to leave default

Definition at line 79 of file tiny_ssd1306.h.

◆ beginSPI()

void TinySSD1306::beginSPI ( int8_t  csPin = -1,
int8_t  dcPin = -1 
)
inline

Initializes default custom spi interface and lcd display.

Initializes default custom i2c interface and lcd display.

Parameters
csPin- chip enable pin to LCD slave (-1 if not used)
dcPin- data/command pin to control LCD dc (required)

Definition at line 88 of file tiny_ssd1306.h.

◆ charF12x16()

uint8_t TinySSD1306::charF12x16 ( uint8_t  xpos,
uint8_t  y,
const char  ch[],
EFontStyle  style = STYLE_NORMAL 
)
inline

Prints text to screen using double size font 12x16.

Parameters
xpos- horizontal position in pixels
y- vertical position in blocks (pixels/8)
ch- NULL-terminated string to print
style- font style (EFontStyle).
Returns
number of chars in string

Definition at line 172 of file tiny_ssd1306.h.

◆ charF6x8()

uint8_t TinySSD1306::charF6x8 ( uint8_t  x,
uint8_t  y,
const char  ch[],
EFontStyle  style = STYLE_NORMAL 
)
inline

Prints text to screen using font 6x8.

Parameters
x- horizontal position in pixels
y- vertical position in blocks (pixels/8)
ch- NULL-terminated string to print
style- font style (EFontStyle), normal by default.
Returns
number of chars in string

Definition at line 159 of file tiny_ssd1306.h.

◆ charF6x8_eol()

uint8_t TinySSD1306::charF6x8_eol ( uint8_t  left,
uint8_t  y,
const char  ch[],
EFontStyle  style,
uint8_t  right 
)
inline

Prints text to screen using set font. If real text ends before right boundary, the remaining part on the display will be erased till right boundary.

Parameters
left- horizontal position in pixels
y- vertical position in blocks (pixels/8)
ch- NULL-terminated string to print
style- font style (EFontStyle), normal by default.
right- right boundary of the text to output
Returns
number of chars in string

Definition at line 190 of file tiny_ssd1306.h.

◆ clear()

void TinySSD1306::clear ( )
inline

Fills screen with zero-byte

Definition at line 137 of file tiny_ssd1306.h.

◆ clearBlock()

void TinySSD1306::clearBlock ( uint8_t  x,
uint8_t  y,
uint8_t  w,
uint8_t  h 
)
inline

Fills block with black pixels

Parameters
x- horizontal position in pixels
y- vertical position in blocks (pixels/8)
w- width of block in pixels
h- height of block in pixels (must be divided by 8)
Note
usually this method is used to erase bitmap on the screen.

Definition at line 288 of file tiny_ssd1306.h.

◆ drawBitmap()

void TinySSD1306::drawBitmap ( uint8_t  x,
uint8_t  y,
uint8_t  w,
uint8_t  h,
const uint8_t *  buf 
)
inline

Draws bitmap, located in Flash, on the display

Parameters
x- horizontal position in pixels
y- vertical position in blocks (pixels/8)
w- width of bitmap in pixels
h- height of bitmap in pixels (must be divided by 8)
buf- pointer to data, located in Flash: each byte represents 8 vertical pixels.

Definition at line 278 of file tiny_ssd1306.h.

◆ drawBuffer()

void TinySSD1306::drawBuffer ( uint8_t  x,
uint8_t  y,
uint8_t  w,
uint8_t  h,
const uint8_t *  buf 
)
inline

Draws bitmap, located in SRAM, on the display Each byte represents 8 vertical pixels.

// Draw small rectangle 3x8 at position 10,8
uint8_t buffer[3] = { 0xFF, 0x81, 0xFF };
lcd.drawBuffer(10, 1, 3, 8, buffer);
Parameters
x- horizontal position in pixels
y- vertical position in blocks (pixels/8)
w- width of bitmap in pixels
h- height of bitmap in pixels (must be divided by 8)
buf- pointer to data, located in SRAM: each byte represents 8 vertical pixels.

Definition at line 267 of file tiny_ssd1306.h.

◆ drawHLine()

void TinySSD1306::drawHLine ( uint8_t  x1,
uint8_t  y1,
uint8_t  x2 
)
inline

Draws horizontal line

Parameters
x1- left boundary in pixels
y1- position Y in pixels
x2- right boundary in pixels

Definition at line 241 of file tiny_ssd1306.h.

◆ drawRect()

void TinySSD1306::drawRect ( uint8_t  x1,
uint8_t  y1,
uint8_t  x2,
uint8_t  y2 
)
inline

Draws rectangle

Parameters
x1- left boundary in pixel units
y1- top boundary in pixel units
x2- right boundary in pixel units
y2- bottom boundary int pixel units

Definition at line 233 of file tiny_ssd1306.h.

◆ drawVLine()

void TinySSD1306::drawVLine ( uint8_t  x1,
uint8_t  y1,
uint8_t  y2 
)
inline

Draws vertical line

Parameters
x1- position X in pixels
y1- top boundary in pixels
y2- bottom boundary in pixels

Definition at line 249 of file tiny_ssd1306.h.

◆ fill()

void TinySSD1306::fill ( uint8_t  fill_Data)
inline

Fills screen with pattern byte.

Parameters
fill_Data- pattern to fill display with.

Definition at line 132 of file tiny_ssd1306.h.

◆ height()

uint8_t TinySSD1306::height ( )
inline

Returns display height in pixels

Definition at line 114 of file tiny_ssd1306.h.

◆ invertMode()

void TinySSD1306::invertMode ( )
inline

Switches display to inverse mode. LCD will display 0-pixels as white, and 1-pixels as black.

Definition at line 104 of file tiny_ssd1306.h.

◆ negativeMode()

void TinySSD1306::negativeMode ( )
inline

All drawing functions start to work in negative mode. Old picture on the display remains unchanged.

Definition at line 143 of file tiny_ssd1306.h.

◆ normalMode()

void TinySSD1306::normalMode ( )
inline

Switches display to normal mode.

Definition at line 109 of file tiny_ssd1306.h.

◆ off()

void TinySSD1306::off ( )
inline

Turns off display

Definition at line 93 of file tiny_ssd1306.h.

◆ on()

void TinySSD1306::on ( )
inline

Turns on display

Definition at line 98 of file tiny_ssd1306.h.

◆ positiveMode()

void TinySSD1306::positiveMode ( )
inline

All drawing functions start to work in positive (default) mode. Old picture on the display remains unchanged.

Definition at line 149 of file tiny_ssd1306.h.

◆ putPixel()

void TinySSD1306::putPixel ( uint8_t  x,
uint8_t  y 
)
inline

Put single pixel on the LCD.

Warning
Please, take into account that there is no way to read data from ssd1306, thus since each byte contains 8 pixels, all other pixels in the same byte will be cleared on the display. Use TinySSD1306::putPixels() instead. If you need to have buffered output, please, refer to NanoCanvas.
Parameters
x- horizontal position in pixels
y- vertical position in pixels

Definition at line 208 of file tiny_ssd1306.h.

◆ putPixels()

void TinySSD1306::putPixels ( uint8_t  x,
uint8_t  y,
uint8_t  pixels 
)
inline

Puts eight vertical pixels on the LCD at once.

// Draw 8 vertical pixels, starting at [10,16] position
lcd.putPixels(10,2,0xFF);
// Draw 4 vertical pixels, starting at [32,28] position
lcd.putPixels(32,3,0x0F);
Parameters
x- horizontal position in pixels
y- vertical position in blocks (pixels/8)
pixels- bit-pixels to draw on display

Definition at line 224 of file tiny_ssd1306.h.

◆ setCursor()

void TinySSD1306::setCursor ( uint8_t  x,
uint8_t  y 
)
inline

Sets position in terms of display for text output (Print class).

Parameters
x- horizontal position in pixels
y- vertical position in blocks (pixels/8)

Definition at line 126 of file tiny_ssd1306.h.

◆ width()

uint8_t TinySSD1306::width ( )
inline

Returns display width in pixels

Definition at line 119 of file tiny_ssd1306.h.

◆ write()

size_t TinySSD1306::write ( uint8_t  ch)
virtual

Writes single character to the display

Parameters
ch- character to write

Definition at line 22 of file tiny_ssd1306.cpp.


The documentation for this class was generated from the following files: