This is small C++ library for monochrome displays based on ssd1306 controller. Library is written for the STM32 MCU, but may be ported to any other MCU by modifying low-level part of it.
- Connect multiple displays simultaneously
- Update entire display or any part of it independenly - create display segments
- Draw primitives (pixels, lines, squares, circles)
- Draw text (Windows 1251 fonts included: 5px, 8px & 16px font height)
- Draw GUI primitives (items, progressbars, charts & plots)
- Select menu items (draw arrow near selected item or inverse item color)
- Draw bitmap pictures
- Optional transfer through DMA (see ssd1306_ll_interface.hpp)
- Simple Terminal
This library focuses on:
- updating only the necessary parts of the display, rather than the entire display
- having basic GUI primitives (menu items, progressbars, charts, plots) out of the box
Library supposes "Display Segment" architecture.
Each display is described by a "Display" class and can be assoshiated with any number of "Display Segments" instances.
"Display Segment" is graphic part of display. It can be any width, but it must be aligned in height to the display pages. Each "Display Segment" is associated with its own memory area. Different instances of "Display Segment" can share same memory.
All draw functions are called throught "Display Segment" class functions. This allows independly use segments, update and redraw them.
Every display have default Display Segment describes full screen area. This allows to call graphic functions using only "Display" class.
- ssd1306_config.hpp - contains defines that connect various library modules (to reduce memory consumption)
- ssd1306.cpp (.hpp) - contains display object and display settings (display size and used interface)
- ssd1306_ll_interface.cpp (.hpp) - low level part, implements I2C interface to ssd1306. Uses STM32 HAL library
- ssd1306_display.cpp (.hpp) - main part, implements all draw features
- ssd1306_fonts.cpp (.hpp) - contains embedded fonts
- ssd1306_bitmaps.cpp (.hpp) - contains class definition for bitmap pictures
- ssd1306_charts.cpp (.hpp) - contains graphics charts (bar charts and simple plots)
- ssd1306_terminal.cpp (.hpp) - contains simple terminal implementation (aka cmd)
- ssd1306_tests.cpp (.hpp) - contains tests and use-cases
-
In
ssd1306_config.hppset up HAL Library#inludefor your controller (#include <stm32f4xx.h>for example). Also use#defineto connect the necessary modules. -
In
ssd1306.cppedit display settings or add new display object. -
In your source file:
#include "ssd1306.hpp" display.init(SSD1306_MIRROR_VERT::SSD1306_MIRROR_VERT_ON, SSD1306_MIRROR_HORIZ::SSD1306_MIRROR_HORIZ_ON); display.clear(); ssd1306_run_tests(display); // To run tests, enable tests module in ssd1306_config.hpp -
Use library
- You can use it without calling any "Display Segments", for example:
display.write_string(0, ROW1, "Hello World", font16); display.update();- Or you can create new "Display Segment" and work with it independently:
DispSegment test_terminal_title = DispSegment(10, display, SSD1306_ADDR_MODE::HORIZONTAL, 0, 0, 127, 0, display.GRAM_PTR); DispSegment test_terminal_screen = DispSegment(12, display, SSD1306_ADDR_MODE::HORIZONTAL, 0, 1, 127, 7, test_terminal_title.gram_next); Terminal test_terminal = Terminal(test_terminal_screen); test_terminal_title.write_string_now(45, ROW1, "Терминал", font8); test_terminal.out("Test messsage"); -
See
ssd1306_tests.cppfor usage examples.
Warning
The library was developed to simplify the prototyping of electronic devices. It is not fully tested and may contain errors
Fonts
Primitives
Parameters
Parameters
Menu
Menu
Charts
Plot
Layout
Bitmap









