lexus2k / lcdgfx

Driver for LCD displays running on Arduino/Avr/ESP32/Linux (including Rasperry) platforms
MIT License
389 stars 55 forks source link

Add support for LCD controller: SSD1306B #118

Open simon-77 opened 5 months ago

simon-77 commented 5 months ago

The SSD1306 is already implemented, but not fully compatible with the SSD1306B controller.

I am using the OLEDS102-6 display with the SSD1306B controller. I needed to modify the startup sequence slightly, in order to get the charge pump set up correctly.

I have copied the configuration (for the lcd_code_generator.py script) from the SSD1306 and modified the startup sequence.

This pull request contains the new json configuration files as well as the newly created source files.

And I have tested the new class successfully with my OLEDS102-6 display. Used testing code snippets:

#include <stdio.h>
#include "pico/stdlib.h"
#include "lcdgfx.h"

#define OLED_RST 3
#define OLED_DC 2
#define OLED_CS 5
#define OLED_SCK 18
#define OLED_MOSI 19
#define SPI_FREQ 0 // 0 means default frequency
DisplaySSD1306B_128x64_SPI oled(OLED_RST, {-1, OLED_CS, OLED_DC, SPI_FREQ, OLED_SCK, OLED_MOSI});

int main()
{
    stdio_init_all();

    oled.begin();

    oled.setFixedFont( ssd1306xled_font6x8 );
    oled.getInterface().flipHorizontal(true);
    oled.getInterface().flipVertical(true);
    oled.clear();

    oled.printFixed(12,  0, "Normal text", STYLE_NORMAL);
    oled.printFixed(12, 16, "Bold text", STYLE_BOLD);
    oled.printFixed(12, 24, "Italic text", STYLE_ITALIC);

    while (true);
}
simon-77 commented 5 months ago

The SSD1306 library has the following #define directive

               "128x64":
                {
                    "init":
                    [
                        "#ifdef SDL_EMULATION",
                        "    SDL_LCD_SSD1306, 0x00,",
                        "    0x00, 0x00,",
                        "#endif",

which I have modified for SSD1306B to SDL_LCD_SSD1306B, 0x00,",. I guess this is why the build test is failing.

I don't know what it is actually used for and if I should have deleted these 4 lines for the new implementation.

Nevertheless, building the library for a micro controller (raspberry pi pico in my case) without the SDL_EMULATION does work.

Maybe you can have a look and modify this line accordingly to what makes sense.

Cheers Simon