SSD1306 OLED display driver
1.6.99
This library is developed to control SSD1306/SSD1331/SSD1351/IL9163/PCD8554 RGB i2c/spi LED displays
|
LCD direct draw functions for all display types: color and monochrome. More...
Classes | |
struct | SAppMenu |
Macros | |
#define | ssd1306_drawCanvas(x, y, w, h, buf) ssd1306_drawBuffer(x, y, w, h, buf) |
Functions | |
void | ssd1306_setPos (uint8_t x, uint8_t y) |
void | ssd1306_fillScreen (uint8_t fill_Data) |
void | ssd1306_clearScreen (void) |
void | ssd1306_negativeMode (void) |
void | ssd1306_positiveMode (void) |
uint8_t | ssd1306_printFixed (uint8_t xpos, uint8_t y, const char *ch, EFontStyle style) |
uint8_t | ssd1306_printFixed2x (uint8_t xpos, uint8_t y, const char ch[], EFontStyle style) __attribute__((deprecated)) |
uint8_t | ssd1306_printFixedN (uint8_t xpos, uint8_t y, const char ch[], EFontStyle style, uint8_t factor) |
void | ssd1306_setCursor (lcdint_t x, lcdint_t y) |
Sets cursor position for text mode print functions. More... | |
size_t | ssd1306_write (uint8_t ch) |
Prints single character to display at current cursor position. More... | |
size_t | ssd1306_print (const char ch[]) |
Prints null-terminated string to display at current cursor position. More... | |
uint8_t | ssd1306_charF6x8 (uint8_t x, uint8_t y, const char ch[], EFontStyle style=STYLE_NORMAL) __attribute__((deprecated)) |
uint8_t | ssd1306_charF12x16 (uint8_t xpos, uint8_t y, const char ch[], EFontStyle style) __attribute__((deprecated)) |
uint8_t | ssd1306_charF6x8_eol (uint8_t left, uint8_t y, const char ch[], EFontStyle style, uint8_t right) __attribute__((deprecated)) |
void | ssd1306_setFixedFont (const uint8_t *progmemFont) |
void | ssd1306_setFont6x8 (const uint8_t *progmemFont) __attribute__((deprecated)) |
void | ssd1306_putPixel (uint8_t x, uint8_t y) |
void | ssd1306_putPixels (uint8_t x, uint8_t y, uint8_t pixels) |
void | ssd1306_drawRect (uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2) |
void | ssd1306_drawLine (uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2) |
void | ssd1306_drawHLine (uint8_t x1, uint8_t y1, uint8_t x2) |
void | ssd1306_drawVLine (uint8_t x1, uint8_t y1, uint8_t y2) |
void | ssd1306_drawBuffer (uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *buf) |
void | ssd1306_drawBufferFast (lcdint_t x, lcdint_t y, lcduint_t w, lcduint_t h, const uint8_t *buf) |
void | ssd1306_drawBitmap (uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *buf) |
void | gfx_drawMonoBitmap (lcdint_t x, lcdint_t y, lcduint_t w, lcduint_t h, const uint8_t *buf) |
void | ssd1306_clearBlock (uint8_t x, uint8_t y, uint8_t w, uint8_t h) |
void | ssd1306_drawSpriteEx (uint8_t x, uint8_t y, uint8_t w, const uint8_t *sprite) |
void | ssd1306_drawSprite (SPRITE *sprite) |
void | ssd1306_eraseSprite (SPRITE *sprite) |
void | ssd1306_eraseTrace (SPRITE *sprite) |
SPRITE | ssd1306_createSprite (uint8_t x, uint8_t y, uint8_t w, const uint8_t *data) |
void | ssd1306_replaceSprite (SPRITE *sprite, const uint8_t *data) |
void | ssd1306_createMenu (SAppMenu *menu, const char **items, uint8_t count) |
void | ssd1306_showMenu (SAppMenu *menu) |
void | ssd1331_showMenu8 (SAppMenu *menu) |
void | ssd1306_updateMenu (SAppMenu *menu) |
void | ssd1331_updateMenu8 (SAppMenu *menu) |
uint8_t | ssd1306_menuSelection (SAppMenu *menu) |
void | ssd1306_menuDown (SAppMenu *menu) |
void | ssd1306_menuUp (SAppMenu *menu) |
LCD direct draw functions for all display types: color and monochrome.
LCD direct draw functions are applicable for all display types. These functions will work both for monochrome and 8-bit/16-bit color OLED displays. You need remember, that for RGB oled displays these functions work only in special ssd1306 compatible mode. If you're going to combine NanoEngine capabilities with these functions, don't forget to switch addressing mode via ssd1306_setMode(). Direct draw functions draw directly in GDRAM and do not use any double-buffering.
#define ssd1306_drawCanvas | ( | x, | |
y, | |||
w, | |||
h, | |||
buf | |||
) | ssd1306_drawBuffer(x, y, w, h, buf) |
Draws bitmap, located in SRAM, on the display Each byte represents 8 vertical pixels.
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. |
Draws bitmap, located in Flash, on the display
x | - horizontal position in pixels |
y | - vertical position in pixels |
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 718 of file ssd1306_generic.c.
uint8_t ssd1306_charF12x16 | ( | uint8_t | xpos, |
uint8_t | y, | ||
const char | ch[], | ||
EFontStyle | style | ||
) |
Prints text to screen using double size font 12x16.
xpos | - horizontal position in pixels |
y | - vertical position in blocks (pixels/8) |
ch | - NULL-terminated string to print |
style | - font style (EFontStyle). |
Definition at line 448 of file ssd1306_generic.c.
uint8_t ssd1306_charF6x8 | ( | uint8_t | x, |
uint8_t | y, | ||
const char | ch[], | ||
EFontStyle | style = STYLE_NORMAL |
||
) |
Prints text to screen using font 6x8.
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. |
Definition at line 402 of file ssd1306_generic.c.
uint8_t ssd1306_charF6x8_eol | ( | uint8_t | left, |
uint8_t | y, | ||
const char | ch[], | ||
EFontStyle | style, | ||
uint8_t | right | ||
) |
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.
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 |
Definition at line 523 of file ssd1306_generic.c.
void ssd1306_clearBlock | ( | uint8_t | x, |
uint8_t | y, | ||
uint8_t | w, | ||
uint8_t | h | ||
) |
Fills block with black pixels
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) |
Definition at line 775 of file ssd1306_generic.c.
void ssd1306_clearScreen | ( | void | ) |
Fills screen with zero-byte
Definition at line 73 of file ssd1306_generic.c.
void ssd1306_createMenu | ( | SAppMenu * | menu, |
const char ** | items, | ||
uint8_t | count | ||
) |
Creates menu object with the provided list of menu items. List of menu items (strings) must exist all until menu object is no longer needed. Selection is set to the first item by default.
menu | - Pointer to SAppMenu structure |
items | - array of null-termintated strings (located in SRAM) |
count | - count of menu items in the array |
Definition at line 42 of file ssd1306_menu.c.
SPRITE ssd1306_createSprite | ( | uint8_t | x, |
uint8_t | y, | ||
uint8_t | w, | ||
const uint8_t * | data | ||
) |
Creates sprite object. Sprite height is fixed to 8 pixels
x | - horizontal position in pixels |
y | - vertical position in pixels |
w | - width of sprite in pixels |
data | - pointer to data, located in Flash: each byte represents 8 vertical pixels. |
Definition at line 888 of file ssd1306_generic.c.
void ssd1306_drawBitmap | ( | uint8_t | x, |
uint8_t | y, | ||
uint8_t | w, | ||
uint8_t | h, | ||
const uint8_t * | buf | ||
) |
Draws bitmap, located in Flash, on the display
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 700 of file ssd1306_generic.c.
void ssd1306_drawBuffer | ( | uint8_t | x, |
uint8_t | y, | ||
uint8_t | w, | ||
uint8_t | h, | ||
const uint8_t * | buf | ||
) |
Draws bitmap, located in SRAM, on the display Each byte represents 8 vertical pixels.
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 685 of file ssd1306_generic.c.
void ssd1306_drawBufferFast | ( | lcdint_t | x, |
lcdint_t | y, | ||
lcduint_t | w, | ||
lcduint_t | h, | ||
const uint8_t * | buf | ||
) |
Draws bitmap, located in SRAM, on the display Each byte represents 8 vertical pixels.
x | - horizontal position in pixels |
y | - vertical position in pixels (must be devided by 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 672 of file ssd1306_generic.c.
void ssd1306_drawHLine | ( | uint8_t | x1, |
uint8_t | y1, | ||
uint8_t | x2 | ||
) |
Draws horizontal line
x1 | - left boundary in pixels |
y1 | - position Y in pixels |
x2 | - right boundary in pixels |
Definition at line 630 of file ssd1306_generic.c.
void ssd1306_drawLine | ( | uint8_t | x1, |
uint8_t | y1, | ||
uint8_t | x2, | ||
uint8_t | y2 | ||
) |
Draws line
x1 | - x position in pixels of start point |
y1 | - y position in pixels of start point |
x2 | - x position in pixels of end point |
y2 | - y position in pixels of end point |
Definition at line 586 of file ssd1306_generic.c.
void ssd1306_drawRect | ( | uint8_t | x1, |
uint8_t | y1, | ||
uint8_t | x2, | ||
uint8_t | y2 | ||
) |
Draws rectangle
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 664 of file ssd1306_generic.c.
void ssd1306_drawSprite | ( | SPRITE * | sprite | ) |
Draws sprite on the display. Position can be changed by updating x and y fields of SPRITE structure.
sprite | - pointer to SPRITE structure |
Definition at line 803 of file ssd1306_generic.c.
void ssd1306_drawSpriteEx | ( | uint8_t | x, |
uint8_t | y, | ||
uint8_t | w, | ||
const uint8_t * | sprite | ||
) |
Draws bitmap, located in Flash, on the display. This sprite must have wx8 size
x | - horizontal position in pixels |
y | - vertical position in blocks (pixels/8) |
w | - width in pixels |
sprite | - pointer to data, located in Flash: each byte represents 8 vertical pixels. |
Definition at line 791 of file ssd1306_generic.c.
void ssd1306_drawVLine | ( | uint8_t | x1, |
uint8_t | y1, | ||
uint8_t | y2 | ||
) |
Draws vertical line
x1 | - position X in pixels |
y1 | - top boundary in pixels |
y2 | - bottom boundary in pixels |
Definition at line 640 of file ssd1306_generic.c.
void ssd1306_eraseSprite | ( | SPRITE * | sprite | ) |
Clears sprite from the display leaving black rectangle.
sprite | - pointer to SPRITE structure |
Definition at line 829 of file ssd1306_generic.c.
void ssd1306_eraseTrace | ( | SPRITE * | sprite | ) |
Clears some sprite parts in old position on the display.
sprite | - pointer to SPRITE structure |
Definition at line 851 of file ssd1306_generic.c.
void ssd1306_fillScreen | ( | uint8_t | fill_Data | ) |
Fills screen with pattern byte
Definition at line 58 of file ssd1306_generic.c.
void ssd1306_menuDown | ( | SAppMenu * | menu | ) |
Moves selection pointer down by 1 item. If there are no items below, it will set selection pointer to the first item. Use ssd1306_updateMenu() to refresh menu state on the display.
menu | - Pointer to SAppMenu structure |
Definition at line 157 of file ssd1306_menu.c.
uint8_t ssd1306_menuSelection | ( | SAppMenu * | menu | ) |
Returns currently selected menu item. First item has zero-index.
menu | - Pointer to SAppMenu structure |
Definition at line 152 of file ssd1306_menu.c.
void ssd1306_menuUp | ( | SAppMenu * | menu | ) |
Moves selection pointer up by 1 item. If selected item is the first one, then selection pointer will set to the last item in menu list. Use ssd1306_updateMenu() to refresh menu state on the display.
menu | - Pointer to SAppMenu structure |
Definition at line 169 of file ssd1306_menu.c.
void ssd1306_negativeMode | ( | void | ) |
All drawing functions start to work in negative mode. Old picture on the display remains unchanged.
Definition at line 930 of file ssd1306_generic.c.
void ssd1306_positiveMode | ( | void | ) |
All drawing functions start to work in positive (default) mode. Old picture on the display remains unchanged.
Definition at line 935 of file ssd1306_generic.c.
size_t ssd1306_print | ( | const char | ch[] | ) |
Prints null-terminated string to display at current cursor position.
Prints null-terminated string to display at current cursor position
ch | - string to print to the display. 'LF' and 'CR' are skipped |
Definition at line 391 of file ssd1306_generic.c.
uint8_t ssd1306_printFixed | ( | uint8_t | xpos, |
uint8_t | y, | ||
const char * | ch, | ||
EFontStyle | style | ||
) |
Prints text to screen using fixed font.
xpos | - horizontal position in pixels |
y | - vertical position in pixels |
ch | - NULL-terminated string to print |
style | - font style (EFontStyle), normal by default. |
Definition at line 107 of file ssd1306_generic.c.
uint8_t ssd1306_printFixed2x | ( | uint8_t | xpos, |
uint8_t | y, | ||
const char | ch[], | ||
EFontStyle | style | ||
) |
Prints text to screen using double size fixed font.
xpos | - horizontal position in pixels |
y | - vertical position in pixels |
ch | - NULL-terminated string to print |
style | - font style (EFontStyle), normal by default. |
Definition at line 181 of file ssd1306_generic.c.
uint8_t ssd1306_printFixedN | ( | uint8_t | xpos, |
uint8_t | y, | ||
const char | ch[], | ||
EFontStyle | style, | ||
uint8_t | factor | ||
) |
Prints text to screen using size fixed font, scaled by factor value.
Factor value 0 gives regular font size (6x8 for example)
Factor value 1 gives double font size (12x16 if 6x8 font is used)
Factor value 2 gives fourth font size (24x32 if 6x8 font is used)
Factor value 3 gives eighth font size (48x64 if 6x8 font is used)
xpos | - horizontal position in pixels |
y | - vertical position in pixels |
ch | - NULL-terminated string to print |
style | - font style (EFontStyle), normal by default. |
factor | - 0, 1, 2, 3. |
Definition at line 262 of file ssd1306_generic.c.
void ssd1306_putPixel | ( | uint8_t | x, |
uint8_t | y | ||
) |
Put single pixel on the LCD.
x | - horizontal position in pixels |
y | - vertical position in pixels |
Definition at line 552 of file ssd1306_generic.c.
void ssd1306_putPixels | ( | uint8_t | x, |
uint8_t | y, | ||
uint8_t | pixels | ||
) |
Puts eight vertical pixels on the LCD at once.
x | - horizontal position in pixels |
y | - vertical position pixels. Should be multiply of 8. |
pixels | - bit-pixels to draw on display |
Definition at line 559 of file ssd1306_generic.c.
void ssd1306_replaceSprite | ( | SPRITE * | sprite, |
const uint8_t * | data | ||
) |
Replaces image of the sprite with different data. The width must be the same as the width of original sprite image
sprite | - pointer to SPRITE structure |
data | - pointer to data, located in Flash: each byte represents 8 vertical pixels. |
Definition at line 893 of file ssd1306_generic.c.
Sets cursor position for text mode print functions.
Sets cursor position for text mode print functions.
x | xpos in pixels |
y | ypos in pixels |
Definition at line 354 of file ssd1306_generic.c.
void ssd1306_setFixedFont | ( | const uint8_t * | progmemFont | ) |
Function allows to set another fixed font for the library. By default, the font supports only first 128 - 32 ascii chars. First 32 chars of ascii table are non-printable, and removed from the font table to reduce flash memory consumption. Default font doesn't support russian characters. Using this function you can implement your own fonts. First font char must be started with <space> image. Font data should be in the following format: | 0x00 | 0xWW | 0xHH | 0xAA | FONT DATA |, where 0xWW - width in pixels, 0xHH - height in pixels, 0xAA - ascii offset (0x20).
For fixed font 6x8 each char is presented by 6 bytes:
COL0, COL1, COL2, COL3, COL4, COL5.
For fixed font 4x16 each char is presented by 4x16/8 = 8 bytes:
ROW0: COL0, COL1, COL2, COL3,
ROW1: COL0, COL1, COL2, COL3
progmemFont | - font to setup located in Flash area |
Definition at line 538 of file ssd1306_generic.c.
void ssd1306_setFont6x8 | ( | const uint8_t * | progmemFont | ) |
Function allows to set another font for the library. By default, the font supports only first 128 - 32 ascii chars. First 32 chars of ascii table are non-printable, and removed from the font table to reduce flash memory consumption. Default font doesn't support russian characters. Using this function you can implement your own fonts. First font char must be started with <space> image.
progmemFont | - font to setup located in Flash area |
Definition at line 547 of file ssd1306_generic.c.
void ssd1306_setPos | ( | uint8_t | x, |
uint8_t | y | ||
) |
Set position in terms of display.
x | - horizontal position in pixels |
y | - vertical position in blocks (pixels/8) |
void ssd1306_showMenu | ( | SAppMenu * | menu | ) |
Shows menu items on the display. If menu items cannot fit the display, the function provides scrolling.
menu | - Pointer to SAppMenu structure |
Definition at line 92 of file ssd1306_menu.c.
void ssd1306_updateMenu | ( | SAppMenu * | menu | ) |
Updates menu items on the display. That is if selection is changed, the function will update only those areas, affected by the change.
menu | - Pointer to SAppMenu structure |
Definition at line 114 of file ssd1306_menu.c.
size_t ssd1306_write | ( | uint8_t | ch | ) |
Prints single character to display at current cursor position.
Prints single character to display at current cursor position
ch | - character to print to the display. 'LF' and 'CR' are skipped |
Definition at line 360 of file ssd1306_generic.c.
void ssd1331_showMenu8 | ( | SAppMenu * | menu | ) |
Shows menu items on the display. If menu items cannot fit the display, the function provides scrolling.
menu | - Pointer to SAppMenu structure |
Definition at line 103 of file ssd1306_menu.c.
void ssd1331_updateMenu8 | ( | SAppMenu * | menu | ) |
Updates menu items on the display. That is if selection is changed, the function will update only those areas, affected by the change.
menu | - Pointer to SAppMenu structure |
Definition at line 133 of file ssd1306_menu.c.