Open source Raspberry Pi C++ library for I2C displays (OLED / LCD)

1,802 views
Skip to first unread message

Arjan van Vught

unread,
Nov 4, 2017, 12:09:01 PM11/4/17
to bcm2835
https://github.com/vanvught/rpidmx512/tree/master/lib-display

Supported I2C displays:
  • BitWizard LCD Interface with 16x2 LCD
  • BitWizard User Interface with 16x2 LCD
  • LCD Module TC1602A / PCF8574T I2C
  • LCD Module 2004 / PCF8574T I2C
  • OLED display 128x32 SSD1306 I2C
  • OLED display 128x64 SSD1306 I2C
Supported platforms :

Examples are available:

detect.cpp
int main(int argc, char **argv) {
   
Display display(0, 8);

   
bool isDetected = display.isDetected();

    printf
("Display is detected : %s\n", isDetected ? "Yes" : "No");

   
if (isDetected) {
        printf
("Display type : %d\n", (int) display.GetDetectedType());
        display
.Printf(2, "Line 2");
   
}

   
return 0;
}

oled128x32.cpp

int main(int argc, char **argv) {
   
Ssd1306 ssd1306(OLED_PANEL_128x32_4ROWS);

   
bool isDetected = ssd1306.Start();

    printf
("Display is detected : %s\n", isDetected ? "Yes" : "No");

   
if (isDetected) {
       
for (int i = 1; i <= 4; i++) {
            ssd1306
.TextLine(i, line, sizeof(line) - 1);
            ssd1306
.PutChar((int) '0' + i);
       
}
   
}

   
return 0;
}

ssd1306.cpp
int main(int argc, char **argv) {
   
Display display(DISPLAY_SSD1306);

   
bool isDetected = display.isDetected();

    printf
("Display is detected : %s\n", isDetected ? "Yes" : "No");

   
if (isDetected) {
        printf
("Display type : %d\n", (int) display.GetDetectedType());
       
for (int i = 1; i <= 8; i++) {    // We assume OLED_PANEL_128x64_8ROWS
            display
.Printf(i, "Line %d", (int) i);
       
}
   
}

   
return 0;
}


Reply all
Reply to author
Forward
0 new messages