Skip to content

Adding new display

Aleksei edited this page Apr 17, 2018 · 3 revisions

HOW to add new oled display support to the library

Adding new LCD type to the library

The main requirements for LCD display to use it with this library are:

  • Each byte, sent to LCD, represents 8 vertical pixels
  • After sending each byte LCD controller shifts GDRAM pointer to the right by 1 pixel
  • LCD width should not exceed 128 pixels

To add new LCD type to the library, implement GDRAM address positioning functions and initialization function for you LCD:

#include "lcd/lcd_common.h"
#include "intf/ssd1306_interface.h"

void    myDisplayInit()
{
    // Use LCD_TYPE_CUSTOM constant
    g_lcd_type = LCD_TYPE_CUSTOM;
    // Set display size:
    //     Width should be less or equal to 128
    s_displayWidth = 128;
    //     Height should be less or equal to 128
    s_displayHeight = 64;
    // mySetRamBlockFunc should set region in GDRAM, limited by passed X, Y, WIDTH values.
    // HEIGHT is expected to be maximum
    ssd1306_setRamBlock      = &mySetRamBlockFunc;
    // myNextPageFunc is expected to switch to next page, this function can be empty for color displays
    ssd1306_nextRamPage      = &myNextPageFunc;
    // mySendPixels should send 8 monochrome pixels to display
    ssd1306_sendPixels       = &mySendPixels;
    // mySendPixels should send monochrome pixels, presented as N*8 rectangle, to display
    ssd1306_sendPixelsBuffer = &mysendPixelsBuffer;
    // mySendPixel8 is expected to send single 8-bit RGB pixel to display
    // This function is required only for 8/16-bit RGB oleds
    ssd1306_sendPixel8       = &mySendPixel8;

    # Put you LCD initialization code here
    ...
}

void setup()
{
    # Init the interface here
    ...
    # Call LCD initialization here
    myDisplayInit();
}

Refer to SH1106 intialization implementation as reference code.