dsyleixa123
Posts: 1437
Joined: Mon Jun 11, 2018 11:22 am

OLED SSD1306: which C++ lib feat. multiple fixed and proportional fonts and graphics? (no sudo)

Thu Apr 15, 2021 10:36 am

as it's appearently quite messy to make an Arduino lib (by Adafruit) work for the Pi to control an OLED SSD1306 (Pi OS Stretch):
which C++ lib feat. multiple fixed and proportional fonts plus inverted color and graphics is most recommended?
Image

(possibly no sudo required to run it)
Last edited by dsyleixa123 on Fri May 28, 2021 8:05 am, edited 2 times in total.

dsyleixa123
Posts: 1437
Joined: Mon Jun 11, 2018 11:22 am

Re: OLED SSD1306: which C++ lib feat. multiple fixed and proportional fonts and graphics?

Sat Apr 17, 2021 8:23 am

no suggestions?
For Arduino there are millions of libs availible and recommended for arbitrary purposes, but for the PI noone can recommend a single one? :roll:
Last edited by dsyleixa123 on Sat Apr 17, 2021 9:54 am, edited 1 time in total.

User avatar
neilgl
Posts: 3247
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near The National Museum of Computing

Re: OLED SSD1306: which lib feat. multiple fixed and proportional fonts and graphics?

Sat Apr 17, 2021 9:43 am

I use luma.oiled for python on a raspberry pi zero.

dsyleixa123
Posts: 1437
Joined: Mon Jun 11, 2018 11:22 am

Re: OLED SSD1306: which C++ lib feat. multiple fixed and proportional fonts and graphics?

Sat Apr 17, 2021 9:53 am

you perhaps mean luma.oled (not .oiled ;) )
but is that also a C++ lib? how to install?
(of course Python makes no sense for C++)

User avatar
neilgl
Posts: 3247
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near The National Museum of Computing

Re: OLED SSD1306: which C++ lib feat. multiple fixed and proportional fonts and graphics?

Sat Apr 17, 2021 10:53 am

Yes oled - may be of use in testing things from python whilst looking for C lib.

dsyleixa123
Posts: 1437
Joined: Mon Jun 11, 2018 11:22 am

Re: OLED SSD1306: which C++ lib feat. multiple fixed and proportional fonts and graphics?

Sat Apr 17, 2021 10:55 am

ok, but I never program by Python, just C/++, so I definitely need a C++ lib.

User avatar
scruss
Posts: 4087
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: OLED SSD1306: which C++ lib feat. multiple fixed and proportional fonts and graphics?

Sat Apr 17, 2021 5:29 pm

It's not a C library, but there's the ssd1306 overlay that's supported by Raspberry Pi OS. What it does is give your system a very tiny framebuffer that is your OLED display.

Then you need to find a library to render into that framebuffer. Cairo would be overkill but give you all the features.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

dsyleixa123
Posts: 1437
Joined: Mon Jun 11, 2018 11:22 am

Re: OLED SSD1306: which C++ lib feat. multiple fixed and proportional fonts and graphics?

Sat Apr 17, 2021 5:49 pm

tbh, that sounds too complicated.
I need a library, (probably a C++ i2c lib), just to #include and then simply use all fonts and geometric graphs and bitmaps, like it's possible with Arduino API device libs.
OTOH, I want to use the OLED just as an extra display additionally to my HDMI screen, for simple extra print-outs or graphs.

dsyleixa123
Posts: 1437
Joined: Mon Jun 11, 2018 11:22 am

Re: OLED SSD1306: which C++ lib feat. multiple fixed and proportional fonts and graphics?

Wed May 05, 2021 11:10 am

scruss wrote:
Sat Apr 17, 2021 5:29 pm
Then you need to find a library
yes, a library is what I want to find...
Last edited by dsyleixa123 on Thu May 06, 2021 4:40 pm, edited 1 time in total.

User avatar
typematrix
Posts: 31
Joined: Sun Jul 02, 2017 3:55 pm
Location: Europe
Contact: Website

Re: OLED SSD1306: which C++ lib feat. multiple fixed and proportional fonts and graphics?

Wed May 05, 2021 6:26 pm

I just completed a RPI C++ OLED 128X64 library for the CH1115 controller, its similar but not same as ssd1306

1: it is SPI not I2C but that could be easily changed by changing the bcm2835 function calls.
2. It could be ported from CH1115 to ssd1306 fairly easily too.
3. It does have graphics and colour inversion but unfortunately it has a single scale-able font

Not sure if that's any good to you.
Last edited by typematrix on Sat May 29, 2021 7:14 pm, edited 1 time in total.

dsyleixa123
Posts: 1437
Joined: Mon Jun 11, 2018 11:22 am

Re: OLED SSD1306: which C++ lib feat. multiple fixed and proportional fonts and graphics?

Wed May 05, 2021 7:04 pm

thank you, but I only got a couple of SSD1306 and I only use i2c

different suggestions by anyone?

User avatar
typematrix
Posts: 31
Joined: Sun Jul 02, 2017 3:55 pm
Location: Europe
Contact: Website

Re: OLED SSD1306: which C++ lib feat. multiple fixed and proportional fonts and graphics?

Thu May 27, 2021 9:42 am

dsyleixa123 wrote:
Wed May 05, 2021 7:04 pm
thank you, but I only got a couple of SSD1306 and I only use i2c

different suggestions by anyone?
Hi

C++ Library to support the I2C 128X64 OLED Display Module driven by the SSD1306 controller for the Raspberry pi SBC eco-system at link.

https://github.com/gavinlyonsrepo/SSD1306_OLED_RPI

Regards

dsyleixa123
Posts: 1437
Joined: Mon Jun 11, 2018 11:22 am

Re: OLED SSD1306: which C++ lib feat. multiple fixed and proportional fonts and graphics?

Thu May 27, 2021 10:08 am

thank you, great!

IIUC, I will need the C library for Broadcom BCM 2835 additionally
I don't know if I already have it completely by all required settings or if I'll have to install it anew, and I also don't find the installtion command for it (I have a Pi 2 v1.1 and Stretch)
sudo apt install... (what exacty?)

User avatar
typematrix
Posts: 31
Joined: Sun Jul 02, 2017 3:55 pm
Location: Europe
Contact: Website

Re: OLED SSD1306: which C++ lib feat. multiple fixed and proportional fonts and graphics?

Thu May 27, 2021 10:47 am

dsyleixa123 wrote:
Thu May 27, 2021 10:08 am
thank you, great!

IIUC, I will need the C library for Broadcom BCM 2835 additionally
I don't know if I already have it completely by all required settings or if I'll have to install it anew, and I also don't find the installtion command for it (I have a Pi 2 v1.1 and Stretch)
sudo apt install... (what exacty?)
hi

install procedure is here http://www.airspayce.com/mikem/bcm2835/

You download the latest version from here http://www.airspayce.com/mikem/bcm2835/ ... .68.tar.gz

1.68 version

Then run following commands where you saved it

tar zxvf bcm2835-1.68.tar.gz
cd bcm2835-1.68
./configure
make
sudo make check
sudo make install

dsyleixa123
Posts: 1437
Joined: Mon Jun 11, 2018 11:22 am

Re: OLED SSD1306: which C++ lib feat. multiple fixed and proportional fonts and graphics?

Thu May 27, 2021 11:00 am

the install procedure I don't understand (too many words)....

how is the download command for the tar file?
into which target directory or path?
/home/pi/ ?

do I have the to copy anything into any /usr/ dir?

User avatar
typematrix
Posts: 31
Joined: Sun Jul 02, 2017 3:55 pm
Location: Europe
Contact: Website

Re: OLED SSD1306: which C++ lib feat. multiple fixed and proportional fonts and graphics?

Thu May 27, 2021 11:31 am

dsyleixa123 wrote:
Thu May 27, 2021 11:00 am
the install procedure I don't understand (too many words)....

how is the download command for the tar file?
into which target directory or path?
/home/pi/ ?

do I have the to copy anything into any /usr/ dir?
Hi

Click on the download link in last post then save it to your Downloads folder on pi.
that should create "bcm2835-1.68.tar.gz" in your Downloads folder

and then run the commands list from last post in that folder.
after it is installed you can delete it from the downloads folder.

dsyleixa123
Posts: 1437
Joined: Mon Jun 11, 2018 11:22 am

Re: OLED SSD1306: which C++ lib feat. multiple fixed and proportional fonts and graphics?

Thu May 27, 2021 11:52 am

click on the link from chrome ? I usually don't use internet on my Pi because it's incredibly lame.
For installation I only use "sudo apt install" or "gitclone" so far (if one provided the correct syntax for either one).

I also have no "downloads folder" IIRC.
Just /home/pi/ then?
or shall I create a folder /home/pi/downoads/ instead?

User avatar
typematrix
Posts: 31
Joined: Sun Jul 02, 2017 3:55 pm
Location: Europe
Contact: Website

Re: OLED SSD1306: which C++ lib feat. multiple fixed and proportional fonts and graphics?

Thu May 27, 2021 12:50 pm

dsyleixa123 wrote:
Thu May 27, 2021 11:52 am
click on the link from chrome ? I usually don't use internet on my Pi because it's incredibly lame.
For installation I only use "sudo apt install" or "gitclone" so far (if one provided the correct syntax for either one).

I also have no "downloads folder" IIRC.
Just /home/pi/ then?
or shall I create a folder /home/pi/downoads/ instead?
This command will download it and "untar" it

Code: Select all

 curl -sL http://www.airspayce.com/mikem/bcm2835/bcm2835-1.68.tar.gz | tar zxv
then run the command list in last post (skip the first tar one)

----

Put it in any folder in home.

dsyleixa123
Posts: 1437
Joined: Mon Jun 11, 2018 11:22 am

Re: OLED SSD1306: which C++ lib feat. multiple fixed and proportional fonts and graphics?

Thu May 27, 2021 3:21 pm

yes! Now I got it! thank you very much! the test program works from the download folder 8-)

reworked, edited:

But if I copy your example files (e.g., main.cpp from the hello_world folder) into my working dir, load it into Geany, and press F8 (compile) I get the errors:

Code: Select all

g++  -Wall -I/opt/vc/include -c "main.cpp"  -pthread -I/opt/vc/include -lshapes -lwiringPi -lpigpio -lrt $(pkg-config eigen3 --cflags) -lreadline  -lbcm2835 (im Verzeichnis: /home/pi/raspiProgs/I2Clibs/OLED_SSD1306_/HELLO_WORLD)
main.cpp:10:26: fatal error: SSD1306_OLED.h: Datei oder Verzeichnis nicht gefunden
 #include "SSD1306_OLED.h"
                          ^
compilation terminated.
Kompilierung fehlgeschlagen.

after pressing F9 (build) then I get:

Code: Select all

g++ -Wall -I/opt/vc/include -o  "main" "main.cpp" -pthread -I/opt/vc/include -lshapes -lwiringPi -lpigpio -lrt $(pkg-config eigen3 --cflags) -lreadline -lbcm2835 (im Verzeichnis: /home/pi/raspiProgs/I2Clibs/OLED_SSD1306_/HELLO_WORLD)
main.cpp:10:26: fatal error: SSD1306_OLED.h: Datei oder Verzeichnis nicht gefunden
 #include "SSD1306_OLED.h"
                          ^
compilation terminated.
Kompilierung fehlgeschlagen.
code:

Code: Select all

// Example file name : main.cpp
// Description:
// Test file for SSD1306_OLED library, showing  hello world
// URL: https://github.com/gavinlyonsrepo/SSD1306_OLED_RPI
// *****************************


#include <bcm2835.h>
#include "SSD1306_OLED.h"
#include <time.h>
#include <stdio.h>

#define myOLEDwidth  128
#define myOLEDheight 64

SSD1306 myOLED(myOLEDwidth ,myOLEDheight) ; // instantiate  an object 

// =============== Function prototype ================
void SetupTest(void);
void TestLoop(void);
void EndTest(void);

// ======================= Main ===================
int main(int argc, char **argv) 
{
	if(!bcm2835_init())
	{
		printf("Error 1201: init bcm2835 library\r\n");
		return -1;
	}
	
	SetupTest();
	TestLoop();
	EndTest();
	
	return 0;
}
// ======================= End of main  ===================

// ===================== Function Space =====================
void SetupTest() 
{
	bcm2835_delay(500);
	printf("OLED Begin\r\n");
	myOLED.OLEDbegin(); // initialize the OLED
	myOLED.OLEDFillScreen(0xF0, 0); // splash screen bars
	bcm2835_delay(1500);
}

void EndTest()
{
	myOLED.OLEDPowerDown(); //Switch off display
	bcm2835_close(); // Close the library
	printf("OLED End\r\n");
}

void TestLoop() 
{

	// Define a buffer to cover whole screen 
	uint8_t  screenBuffer[myOLEDwidth * (myOLEDheight/8)+1]; 
 	myOLED.buffer = (uint8_t*) &screenBuffer;  // set that to library buffer pointer

	myOLED.OLEDclearBuffer(); // Clear active buffer 
	myOLED.setTextColor(WHITE);
	myOLED.setCursor(0, 0);
	myOLED.print("Hello world");
	myOLED.OLEDupdate();  //write to active buffer
	delay(5000);

}

// ============== EOF =========

(edited:)


and why do I have to use
#include "SSD1306_OLED.h" and not #include <SSD1306_OLED.h> ? where to put or what to add to use the <...> brackets?

what is missing?
Last edited by dsyleixa123 on Thu May 27, 2021 6:14 pm, edited 3 times in total.

dsyleixa123
Posts: 1437
Joined: Mon Jun 11, 2018 11:22 am

Re: OLED SSD1306: which C++ lib feat. multiple fixed and proportional fonts and graphics?

Thu May 27, 2021 6:15 pm

again reworked the cmd line parameters, updated,
still compile/build errors, see above!

( I now added -lbcm2835 )

Code: Select all

g++ -Wall -I/opt/vc/include -o  "%e" "%f" -pthread -I/opt/vc/include -lshapes -lwiringPi -lpigpio -lrt $(pkg-config eigen3 --cflags) -lreadline -lbcm2835

User avatar
typematrix
Posts: 31
Joined: Sun Jul 02, 2017 3:55 pm
Location: Europe
Contact: Website

Re: OLED SSD1306: which C++ lib feat. multiple fixed and proportional fonts and graphics?

Thu May 27, 2021 8:42 pm

dsyleixa123 wrote:
Thu May 27, 2021 6:15 pm
again reworked the cmd line parameters, updated,
still compile/build errors, see above!

( I now added -lbcm2835 )

Code: Select all

g++ -Wall -I/opt/vc/include -o  "%e" "%f" -pthread -I/opt/vc/include -lshapes -lwiringPi -lpigpio -lrt $(pkg-config eigen3 --cflags) -lreadline -lbcm2835
Ok , so to be clear

1 . When you run my included makefile , it builds and works?
2. The problem is with Geany IDE, build( F8) and compile (F9) command?

If so I suggest (if you cannot "fix" your g++ issue)

1. running my makefile either from terminal, inside or outside of geany
or
2. use the geany (SHIFT+F9) command will run "make" directly from geany

dsyleixa123
Posts: 1437
Joined: Mon Jun 11, 2018 11:22 am

Re: OLED SSD1306: which C++ lib feat. multiple fixed and proportional fonts and graphics? (no sudo)

Fri May 28, 2021 7:05 am

yes, your installation test program from the (temp) downloads folder via your make and makefile works.
But from out of Geany nothings works, neither compile (F8) nor build (F9) (and of course then no run (F5) ).

OTOH, Geany currently works fine with all my other programs, both with gcc and g++ and .c and/or .cpp (I currently use wiringPi GPIO + I2C almost exclusively for my devices)

Admittedly I never use make or makefile by my own (too weird to me), and for me also having to use a terminal is no option at all, it all must work from out of Geany, as usual
- and actually in the future also has to work out of the qt5 creator GUI when I #include libs by my proprietary qt mainwindow.cpp and .pro files.

So why doesn't the compiler find your lib?

Code: Select all

fatal error: SSD1306_OLED.h: Datei oder Verzeichnis nicht gefunden
 #include "SSD1306_OLED.h"
                          ^
as one can see, there is currently only
-lbcm2835
as a linker command line option, but no link to your OLED lib - is that not needed?
But if, how does it look like? (Unfortunately I can't find required linker options in your github repo .)
So where is the OLED lib installed and to where has it perhaps to be moved (to which system folder, for general access) and perhaps also additional lib files too (.so? .cpp? .a?), so that they can be found?

Heater
Posts: 18204
Joined: Tue Jul 17, 2012 3:02 pm

Re: OLED SSD1306: which C++ lib feat. multiple fixed and proportional fonts and graphics? (no sudo)

Fri May 28, 2021 10:46 am

dsyleixa123 wrote:
Fri May 28, 2021 7:05 am
So why doesn't the compiler find your lib?

Code: Select all

fatal error: SSD1306_OLED.h: Datei oder Verzeichnis nicht gefunden
 #include "SSD1306_OLED.h"
                          ^
as one can see, there is currently only
-lbcm2835
as a linker command line option, but no link to your OLED lib - is that not needed?
But if, how does it look like? (Unfortunately I can't find required linker options in your github repo .)
So where is the OLED lib installed and to where has it perhaps to be moved (to which system folder, for general access) and perhaps also additional lib files too (.so? .cpp? .a?), so that they can be found?
That error is not about not finding the library while linking. It's about the header file "SSD1306_OLED.h"

Google translate tells me "Datei oder Verzeichnis nicht gefunden" means "Date or version not found" which I find a bit odd as I have never seen GCC produce such an error. I suspect it just means it cannot find the header file when compiling whatever .c or .cpp file contains that "include" statement.

When one has header files, ".h", in non-standard locations one can tell the compiler where to find them with the "-I". I presume that is taken care of by the makefile you have there.

My guess is you have to tell "Geany" the path to that header file in order for it to find it and build. I presume Geany has a dialog to set include paths some place.

Alternatively you have to drop that .h file into a directory where Geany/GCC is already looking.
Memory in C++ is a leaky abstraction .

dsyleixa123
Posts: 1437
Joined: Mon Jun 11, 2018 11:22 am

Re: OLED SSD1306: which C++ lib feat. multiple fixed and proportional fonts and graphics? (no sudo)

Fri May 28, 2021 11:06 am

jtm, "Datei oder Verzeichnis" means actually: "file or directory", but anyway, you're probably right, but in which dir does the linker search that .h file normally?
/usr/include...?

and what about all the other .h files in the OLED lib's temp download /include/ directory? there are even 10 more of them...? :o
(or have they already been installed correctly, accordingly? - I assumed that the install procedure already had moved all those files, tbh...)

dsyleixa123
Posts: 1437
Joined: Mon Jun 11, 2018 11:22 am

Re: OLED SSD1306: which C++ lib feat. multiple fixed and proportional fonts and graphics? (no sudo)

Fri May 28, 2021 12:09 pm

update:
the linker apperarently is missing also all the other .h files which are stored in the temp download directory -
how can I move them bundled in a subfolder to which new place (not seperately ) so that they all can be found in a whole though?

Return to “C/C++”