0

OLED display C++ library?
Moderators: adafruit_support_bill, adafruit

Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Please be positive and constructive with your questions and comments.

OLED display C++ library?

by gambiting on Mon Feb 12, 2018 4:05 pm

Hi.

So basically, I just bought the PiOled and the OLED Bonnet screens for my raspberry PIs - and I am wondering, is there a C/C++ library to draw to those screens at all? Cheers,

gambiting
 
Posts: 4
Joined: Mon Feb 12, 2018 4:02 pm

Re: OLED display C++ library?

by adafruit_support_carter on Mon Feb 12, 2018 4:12 pm


adafruit_support_carter
 
Posts: 5856
Joined: Tue Nov 29, 2016 2:45 pm

Re: OLED display C++ library?

by gambiting on Mon Feb 12, 2018 4:29 pm

I see, fair enough :-) Thanks for the reply.

gambiting
 
Posts: 4
Joined: Mon Feb 12, 2018 4:02 pm

Re: OLED display C++ library?

by gambiting on Tue Feb 13, 2018 4:25 am

Actually, coming back to this question today - how does the Python library communicate with the screen? Does it just write to the I2C pins directly, or is there a driver-like implementation somewhere? With an interface perhaps?

I'm a C++ programmer so I'd find it a lot easier to just code my apps in that language, it would be awesome if there was at least an interface for the python-based driver so I could talk to it - if that is not available I could try writing my own perhaps.

gambiting
 
Posts: 4
Joined: Mon Feb 12, 2018 4:02 pm

Re: OLED display C++ library?

by adafruit_support_carter on Tue Feb 13, 2018 12:43 pm

how does the Python library communicate with the screen? Does it just write to the I2C pins directly, or is there a driver-like implementation somewhere? With an interface perhaps?

Through I2C. What actually handles the I2C transaction is platform dependent. The details can be found here:
https://github.com/adafruit/Adafruit_Py ... PIO/I2C.py
Raspberry Pi uses smbus. This then gets used in the SSD1306 driver library, which you use to control the PiOLED:
https://github.com/adafruit/Adafruit_Py ... SSD1306.py

I'm a C++ programmer

The closest we have to C++ would be the Arduino library version. But given that Arduino does a lot of boiler plate automation, the code is not straight C++.
https://github.com/adafruit/Adafruit_SS ... SD1306.cpp

adafruit_support_carter
 
Posts: 5856
Joined: Tue Nov 29, 2016 2:45 pm

Re: OLED display C++ library?

by gambiting on Wed Feb 14, 2018 4:42 am

All of this is excellent - I will definitely have a look. Thank you!

gambiting
 
Posts: 4
Joined: Mon Feb 12, 2018 4:02 pm

Re: OLED display C++ library?

by rpidmx512 on Sun Feb 18, 2018 2:30 pm

I have an open source library C++ : https://github.com/vanvught/rpidmx512/tree/master/lib-display
Examples are provided. It is text only, but it can be a good base.

Code: Select all | TOGGLE FULL SIZE
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;
}

rpidmx512
 
Posts: 9
Joined: Thu Feb 08, 2018 3:30 pm

Please be positive and constructive with your questions and comments.