Skip to content

VsTimf/ssd1306_display

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SSD1306 Display STM32 I2C C++ Library

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.

MAIN FEATURES:

  • 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

SHORT DESCRIPTION:

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

DETAILED DESCRIPTION:

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.

CONTENT:

  • 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

HOW TO USE:

  1. In ssd1306_config.hpp set up HAL Library #inlude for your controller (#include <stm32f4xx.h> for example). Also use #define to connect the necessary modules.

  2. In ssd1306.cpp edit display settings or add new display object.

  3. 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
    
    
  4. 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");
    
  5. See ssd1306_tests.cpp for usage examples.

 

Warning

The library was developed to simplify the prototyping of electronic devices. It is not fully tested and may contain errors

 

SCREEN EXAMPLES

Fonts

alt text

Primitives

alt text

Parameters

alt text

Parameters

alt text

Menu

alt text

Menu

alt text

Charts

alt text

Plot

alt text

Layout

alt text

Bitmap

alt text

About

SSD1306 Display STM32 I2C C++ Library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages