C++ and OLED Screens

Hi! So I’ve been working on moving my project over to C++ just to give myself some more headroom speed-wise (especially considering I plan on adding streaming from SD Cards eventually) but I am having some troubles finding a solid solution for getting my OLED screen to work. I am aware that libDaisy has some OLED support, which is HEAVILY appreciated, but I worry that the library that is included isn’t comprehensive enough for my graphics-rendering needs. I also have the issue that as my screen is placed upside-down, everything draws upside down.

I previously had solved this problem by using the library u8g2, a library that directly supports a crazy number of monochrome OLED screens with the ability to flip the screen and draw bitmaps (easily) to boot. As far as I can tell, this library is also compatible with C++/C as that’s what it was written in, but most people still largely use it for Arduino.

I am curious how one would go about importing the library into VSCode/my project for use as a library. I’ve tried just adding the folders with the files to the include path but so far I haven’t had much luck. I imagine this is partially just cause it involves stuff that I don’t really understand at the moment. Maybe I need to build the library before I use it?? I really don’t know. Some technical help on this would really be appreciated to help get me up off the ground so I can start properly learning C++. Thanks all so much in advance!

EDIT: I should mention I’m just using a regular Daisy Seed for this hooked up via hardware SPI.

1 Like

Hello @Northalicious. I’m going to try and give you some answers-information - however I do not know much about u8g2 beyond what you’ve said in your post. So someone who actually knows u8g2 or an alternative library-solution may give you a better answer.

You probably do need to ‘build’ the library, meaning to (at least) compile it, in order to use it. Hopefully the u8g2 maintainers provide some kind of make file or script to compile the whole thing and set some options such as where to allocate data and whether the calling program is C or C++, etc. If you can’t find a make file you’d have to treat it like your own C/C++ code and compile it.

IF the u8g2 people have done some extra work and distribute it as object code for an ARM processor and VSCode cross-compile then you might not have to, and if they’ve done that they’d probably provide some kind of install script as well.

Linker, object code, library would be good search terms for info about this.

Good luck, maybe see what other answers come your way, and may the force be with you.

Thank you SO much. This process has been very confusing but I’m glad that I’m slowly making headway on it. I actually discovered what you were talking about late last night, as there is a folder under “tools” labeled “codebuild”, which seems to be a newer version of an older folder called “buildcpp”, which seems to be exactly what I want. The problem is when I try to run make on it, I get a very specific and very confusing error:

cc -Wall -g  codebuild.c -o codebuild
process_begin: CreateProcess(NULL, cc -Wall -g codebuild.c -o codebuild, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [Makefile:13: codebuild] Error 2

Thank you so much again for all your help! I genuinely appreciate it!

Lol I just watched episode one last night

UPDATE:
I ended up just jamming all the files for u8g2 (header files, specifically) into the dev/ folder in libDaisy, as it seems like that’s where libDaisy references a lot of external libraries. It ended up working, and now I am just trying to get to know how the library itself works in a C++ environment.

2 Likes

I’m sorry I couldn’t get to your question earlier, but I’m glad to hear that things are happening! Looking forward to more updates and feel free to let us know any questions as well. Good luck!

Edit: By the way, this might be a good reference as you dive in further: GitHub - eziya/STM32_HAL_U8G2_OLED: Port of U8G2 Library for STM32 HAL

The Daisy is an STM32-based board unlike the Arduinos just FYI.

Far out! And a post must be at least 20 characters long. sigh

1 Like

I am trying to get the u8g2 to work in VS CODE (not in daisyduino) as I would like access to its more advanced oled features.

however the OP said she just copied the files into /dev/ I am not sure if she meant the files which were included with daisyduino, the ones in the u8g2 github OR the ones Takumi posted (which are all the more confusing as they involve HAL files etc and I was not sure if i copied all the write files

so far just copying those files from the stm32 port into dev has not worked.

has anyone here gotten the u8g2 working with the daisy in vscode?
thanks

According OP’s posts on Discord, I think she ended up using DaisyDuino for OLED eventually if I remember correctly.
So I don’t know if there are community members out there who ported the u8g2 to work on .cpp.
Possibly a new forum thread titled “Anyone ported u8g2 for .cpp?” could summon them.