Wrote a program for Raspberry Pi 4 to drive small 128x64 pixels OLEDs, any interests?...

J

Jan Panteltje

Guest
Wrote a program for Raspberry Pi 4 to drive small 128x64 pixels OLEDs
this uses GPIO pins and Linux kernel i2c.

The C code does _not_ depend on other libraries, and just compiles with gcc.
It can put small, big and huge text anywhere on the 128x64 OLED,
and even display 128x64 bitmaps.
+3.3V, SDA SCL and ground from GPIO.

If there is any interest here let me know in the group,
then I can make a release,

Can be used from a script (many command line options see below) or cslled from some program.

Looks like this:
http://panteltje.com/pub/raspi4_oled_IXIMG_0774.JPG
http://panteltje.com/pub/raspi4_oled_IXIMG_0775.JPG
http://panteltje.com/pub/raspi4_oled_IXIMG_0776.JPG


Was just test code for me for the kernel i2c interface,
but creates many application options.

raspi99: ~/compile/pantel/oled # ./lm096_oled_raspi -h
Panteltje lm096_oled_raspi-0.1
Usage:
lm096_oled_raspi [-a int] [-b int] [-c] [-d] [-f int] [-g] [-h] [-i] [-l buffer x1 y1 x2 y2 pixel_value] [-m filename] [-p buffer x y pixel_value] [-s] [-r] [-t text] [-v int] [-w] [-x int] [-y int] [-z]

-a int pixel value for plot, 0 or 1, default 1.
-b int filler byte for cls, 0-255, default 0.
-c cls, clear screen.
-d double height characters, use together with -g for double size characters.
-f int font, 0 = txtfont, 1 = s14font, default 0.
-g double width characters, use together with -d for double size characters.
-h help (this help).
-i inverse display.
-j int display display buffer int, range 0-1.
-k int set contrast, range 0-255.
-l buf x1 y1 x2 y2 p draw a line in buffer buf from x1,y1 to x2,y2 with pixel value p, p is 1 for white and 0 for black, default white.
-m filename load and display bitmap filename made with \'bitmap -size 128x64\'.
-p buf x y p plot pixel value p at x, y in buffer buf.
//-s do a scan for all i2c addresses from 0-255, report the ones that do an ack, then exit OK.
-t text text to display.
-r do not reset and initialize OLED.
-v int verbose level, 1-3, default 0 = off.
//-w power off and exit OK.
-x int text x position in pixels, 0-127, default 0.
-x int text y position in rows, 0-7, default 0.
-z hardware zoom, sort of double height characters, use together with -g for double size characters, y is always 1, better use -d -g.

Examples
Do a cls, then put a specific text on the display at x positon 16 (pixels) y position 4 (row) using font 1 and background filler black:
lm096_oled -x 16 -y 4 -c -f 1 -b 0 -t \"Hello world\"

Display a bitmap made with the bitmap program:
lm096_oled -c -m hdp_speed.bmap

Simple animation of files made with the bitmap program:
lm096_oled -x 20 -y 3 -t \"Animation\" -c ; lm096_oled -x 32 -y 5 -t \"demo\" ; sleep 1 ;while [ 1 ] ; do lm096_oled -m d1.bmap -r ; lm096_oled -m d2.bmap -r ; done

Add text to an existing bitmap (no clear screen):
lm096_oled -t -x 10 -y 7 -t \"Extra text\"

Plot a pixel in buffer 0, at x, y = 3,10, with pixel value 1, 0,0 is top left, this uses the display buffer, and the whole buffer is send to the OLED:
lm096_oled -p \"0 3 10 1\"

Draw a line in buffer 0, from x1,y1 = 0,0 to x2,y2 = 127,63, pixel value 1, 0,0 is top left, this uses the display buffer, and the whole buffer is send to the OLED:
lm096_oled -k 255 -l \"0 0 0 127 63 1\"

Double size characters, multiple x, y positions, accumulated text:
lm096_oled -c -t \"Hello\" -k 255 -x 16 -y 0 -g -d; lm096_oled -r -t \"World\" -k 255 -x 16 -y 2 -g -d ; lm096_oled -r -t \"Here\" -k 255 -x 20 -y 4 -g -d ; lm096_oled -r -t \"I am\" -k 255 -x 16 -y 6 -g -d
 
Jan Panteltje <pNaonStpealmtje@yahoo.com> wrote:
Wrote a program for Raspberry Pi 4 to drive small 128x64 pixels OLEDs
this uses GPIO pins and Linux kernel i2c.

The C code does _not_ depend on other libraries, and just compiles with gcc.
It can put small, big and huge text anywhere on the 128x64 OLED,
and even display 128x64 bitmaps.
+3.3V, SDA SCL and ground from GPIO.

If there is any interest here let me know in the group,
then I can make a release,

Please release your source. (An apropos URL embedded in your usenet
post was sorely missed in the first place, truth be known.) Although my
own Pis are loaded with FreeBSD, it ought to be possible to port your
Linux code to them.

On a related note, as you probably know, there\'s a lot of I2C out in the
wild. One of my current projects entails the creation of a gcc I2C
library for an MCU. And ARM actually achieves my goals better than PIC.
Microchip supposedly built its bloatware on top of GNU\'s toolchain.
But, it\'s too much work for me to free PIC development software from its
corporate chains. And I2C\'s too intricate for me to use MPASM.

Danke,

--
Don, KB7RPU, https://www.qsl.net/kb7rpu
There was a young lady named Bright Whose speed was far faster than light;
She set out one day In a relative way And returned on the previous night.
 
On a sunny day (Sun, 30 Jan 2022 14:46:16 -0000 (UTC)) it happened \"Don\"
<g@crcomp.net> wrote in <20220130a@crcomp.net>:

Jan Panteltje <pNaonStpealmtje@yahoo.com> wrote:
Wrote a program for Raspberry Pi 4 to drive small 128x64 pixels OLEDs
this uses GPIO pins and Linux kernel i2c.

The C code does _not_ depend on other libraries, and just compiles with gcc.
It can put small, big and huge text anywhere on the 128x64 OLED,
and even display 128x64 bitmaps.
+3.3V, SDA SCL and ground from GPIO.

If there is any interest here let me know in the group,
then I can make a release,

Please release your source. (An apropos URL embedded in your usenet
post was sorely missed in the first place, truth be known.) Although my
own Pis are loaded with FreeBSD, it ought to be possible to port your
Linux code to them.

On a related note, as you probably know, there\'s a lot of I2C out in the
wild. One of my current projects entails the creation of a gcc I2C
library for an MCU. And ARM actually achieves my goals better than PIC.
Microchip supposedly built its bloatware on top of GNU\'s toolchain.
But, it\'s too much work for me to free PIC development software from its
corporate chains. And I2C\'s too intricate for me to use MPASM.

Danke,

It is on the website now:
http://panteltje.com/pub/lm06_oled_raspi-0.1.tgz
or use
wget http://panteltje.com/pub/lm06_oled_raspi-0.1.tgz

to unpack use
tar -zxvf lm06_oled_raspi-0.1.tgz
cd lm096_oled_raspi-0.1/

make

make install

Try running the date_to_oled script:
http://panteltje.com/pub/lm096_oled_raspi_date_to_oled_IXIMG_0777.JPG

This is a blue yellow LM096 OLED, in those the first 2 lines are always yellow.
There exist also all blue, all white and white-yellow ones (ebay, local shop here has those too at 2 x price).

Note the _controller-chip_ for the display is the SSD1306-1.2.pdf
the LM096 datasheet itself is not very helpfull.

I have put support for German umlauts in txtfont.h

Code is not simple
You can make bitmaps with
bitmap -size 128x64

Not sure all Linux distros still have that \'bitmap\' program, but my old Slackware on the laptop has it.

Bugs:
The \'line\' function works but clears any previous content.
Have to write a new one using the bitmap code some day..

Program was just for testing the kernel i2c driver on Raspberry Pi4
I have done the OLED thing after that in asm bit banging sda scl in many Microchip PIC projects.


To enable kernel i2c to GPIO in Raspberry Pi4 you need to use the raspiconfig menu:
raspiconfig -> interfacing options -> enable disable automatic loading of kernel i2c_module -> yes -> ESC
reboot

then
i2cdetect -y 1
shows 0x3c if the OLED is detected .
slave adresses are shifted.. in the Linux driver...
I did read the driver docs a hack ;-)
Thing did absolutely nothing
Had a good night sleep
next morning ?hack? lemme try .. and Yes it works.
 
On Sunday, 30 January 2022 at 21:44:28 UTC+11, Jan Panteltje wrote:
Wrote a program for Raspberry Pi 4 to drive small 128x64 pixels OLEDs
this uses GPIO pins and Linux kernel i2c.

The C code does _not_ depend on other libraries, and just compiles with gcc.
It can put small, big and huge text anywhere on the 128x64 OLED,
and even display 128x64 bitmaps.
+3.3V, SDA SCL and ground from GPIO.

If there is any interest here let me know in the group,
then I can make a release,

Can be used from a script (many command line options see below) or cslled from some program.

Looks like this:
http://panteltje.com/pub/raspi4_oled_IXIMG_0774.JPG
http://panteltje.com/pub/raspi4_oled_IXIMG_0775.JPG
http://panteltje.com/pub/raspi4_oled_IXIMG_0776.JPG


Was just test code for me for the kernel i2c interface,
but creates many application options.

raspi99: ~/compile/pantel/oled # ./lm096_oled_raspi -h
Panteltje lm096_oled_raspi-0.1
Usage:
lm096_oled_raspi [-a int] [-b int] [-c] [-d] [-f int] [-g] [-h] [-i] [-l buffer x1 y1 x2 y2 pixel_value] [-m filename] [-p buffer x y pixel_value] [-s] [-r] [-t text] [-v int] [-w] [-x int] [-y int] [-z]

-a int pixel value for plot, 0 or 1, default 1.
-b int filler byte for cls, 0-255, default 0.
-c cls, clear screen.
-d double height characters, use together with -g for double size characters.
-f int font, 0 = txtfont, 1 = s14font, default 0.
-g double width characters, use together with -d for double size characters.
-h help (this help).
-i inverse display.
-j int display display buffer int, range 0-1.
-k int set contrast, range 0-255.
-l buf x1 y1 x2 y2 p draw a line in buffer buf from x1,y1 to x2,y2 with pixel value p, p is 1 for white and 0 for black, default white.
-m filename load and display bitmap filename made with \'bitmap -size 128x64\'.
-p buf x y p plot pixel value p at x, y in buffer buf.
//-s do a scan for all i2c addresses from 0-255, report the ones that do an ack, then exit OK.
-t text text to display.
-r do not reset and initialize OLED.
-v int verbose level, 1-3, default 0 = off.
//-w power off and exit OK.
-x int text x position in pixels, 0-127, default 0.
-x int text y position in rows, 0-7, default 0.
-z hardware zoom, sort of double height characters, use together with -g for double size characters, y is always 1, better use -d -g.

Examples
Do a cls, then put a specific text on the display at x positon 16 (pixels) y position 4 (row) using font 1 and background filler black:
lm096_oled -x 16 -y 4 -c -f 1 -b 0 -t \"Hello world\"

Display a bitmap made with the bitmap program:
lm096_oled -c -m hdp_speed.bmap

Simple animation of files made with the bitmap program:
lm096_oled -x 20 -y 3 -t \"Animation\" -c ; lm096_oled -x 32 -y 5 -t \"demo\" ; sleep 1 ;while [ 1 ] ; do lm096_oled -m d1.bmap -r ; lm096_oled -m d2.bmap -r ; done

Add text to an existing bitmap (no clear screen):
lm096_oled -t -x 10 -y 7 -t \"Extra text\"

Plot a pixel in buffer 0, at x, y = 3,10, with pixel value 1, 0,0 is top left, this uses the display buffer, and the whole buffer is send to the OLED:
lm096_oled -p \"0 3 10 1\"

Draw a line in buffer 0, from x1,y1 = 0,0 to x2,y2 = 127,63, pixel value 1, 0,0 is top left, this uses the display buffer, and the whole buffer is send to the OLED:
lm096_oled -k 255 -l \"0 0 0 127 63 1\"

Double size characters, multiple x, y positions, accumulated text:
lm096_oled -c -t \"Hello\" -k 255 -x 16 -y 0 -g -d; lm096_oled -r -t \"World\" -k 255 -x 16 -y 2 -g -d ; lm096_oled -r -t \"Here\" -k 255 -x 20 -y 4 -g -d ; lm096_oled -r -t \"I am\" -k 255 -x 16 -y 6 -g -d

Maybe post in comp.sys.raspberry-pi also?

--
Cheers,
Chris.
 
On Sun, 30 Jan 2022 16:23:04 GMT, Jan Panteltje
<pNaonStpealmtje@yahoo.com> wrote:

On a sunny day (Sun, 30 Jan 2022 14:46:16 -0000 (UTC)) it happened \"Don\"
g@crcomp.net> wrote in <20220130a@crcomp.net>:

Jan Panteltje <pNaonStpealmtje@yahoo.com> wrote:
Wrote a program for Raspberry Pi 4 to drive small 128x64 pixels OLEDs
this uses GPIO pins and Linux kernel i2c.

The C code does _not_ depend on other libraries, and just compiles with gcc.
It can put small, big and huge text anywhere on the 128x64 OLED,
and even display 128x64 bitmaps.
+3.3V, SDA SCL and ground from GPIO.

If there is any interest here let me know in the group,
then I can make a release,

Please release your source. (An apropos URL embedded in your usenet
post was sorely missed in the first place, truth be known.) Although my
own Pis are loaded with FreeBSD, it ought to be possible to port your
Linux code to them.

On a related note, as you probably know, there\'s a lot of I2C out in the
wild. One of my current projects entails the creation of a gcc I2C
library for an MCU. And ARM actually achieves my goals better than PIC.
Microchip supposedly built its bloatware on top of GNU\'s toolchain.
But, it\'s too much work for me to free PIC development software from its
corporate chains. And I2C\'s too intricate for me to use MPASM.

Danke,

It is on the website now:
http://panteltje.com/pub/lm06_oled_raspi-0.1.tgz
or use
wget http://panteltje.com/pub/lm06_oled_raspi-0.1.tgz

to unpack use
tar -zxvf lm06_oled_raspi-0.1.tgz
cd lm096_oled_raspi-0.1/

make

make install

Try running the date_to_oled script:
http://panteltje.com/pub/lm096_oled_raspi_date_to_oled_IXIMG_0777.JPG

This is a blue yellow LM096 OLED, in those the first 2 lines are always yellow.
There exist also all blue, all white and white-yellow ones (ebay, local shop here has those too at 2 x price).

Note the _controller-chip_ for the display is the SSD1306-1.2.pdf
the LM096 datasheet itself is not very helpfull.

I have put support for German umlauts in txtfont.h

Code is not simple
You can make bitmaps with
bitmap -size 128x64

Not sure all Linux distros still have that \'bitmap\' program, but my old Slackware on the laptop has it.

Bugs:
The \'line\' function works but clears any previous content.
Have to write a new one using the bitmap code some day..

Program was just for testing the kernel i2c driver on Raspberry Pi4
I have done the OLED thing after that in asm bit banging sda scl in many Microchip PIC projects.


To enable kernel i2c to GPIO in Raspberry Pi4 you need to use the raspiconfig menu:
raspiconfig -> interfacing options -> enable disable automatic loading of kernel i2c_module -> yes -> ESC
reboot

then
i2cdetect -y 1
shows 0x3c if the OLED is detected .
slave adresses are shifted.. in the Linux driver...
I did read the driver docs a hack ;-)
Thing did absolutely nothing
Had a good night sleep
next morning ?hack? lemme try .. and Yes it works.

Thanks !

We use a small OLED display on our Orange Pi.

Probably similar

boB
 
boB wrote:
Jan Panteltje wrote:
\"Don\" wrote:
Jan Panteltje wrote:
Wrote a program for Raspberry Pi 4 to drive small 128x64 pixels OLEDs
this uses GPIO pins and Linux kernel i2c.

The C code does _not_ depend on other libraries, and just compiles with gcc.
It can put small, big and huge text anywhere on the 128x64 OLED,
and even display 128x64 bitmaps.
+3.3V, SDA SCL and ground from GPIO.

If there is any interest here let me know in the group,
then I can make a release,

Please release your source. (An apropos URL embedded in your usenet
post was sorely missed in the first place, truth be known.) Although my
own Pis are loaded with FreeBSD, it ought to be possible to port your
Linux code to them.

On a related note, as you probably know, there\'s a lot of I2C out in the
wild. One of my current projects entails the creation of a gcc I2C
library for an MCU. And ARM actually achieves my goals better than PIC.
Microchip supposedly built its bloatware on top of GNU\'s toolchain.
But, it\'s too much work for me to free PIC development software from its
corporate chains. And I2C\'s too intricate for me to use MPASM.

It is on the website now:
http://panteltje.com/pub/lm06_oled_raspi-0.1.tgz
or use
wget http://panteltje.com/pub/lm06_oled_raspi-0.1.tgz

to unpack use
tar -zxvf lm06_oled_raspi-0.1.tgz
cd lm096_oled_raspi-0.1/

make

make install

Try running the date_to_oled script:
http://panteltje.com/pub/lm096_oled_raspi_date_to_oled_IXIMG_0777.JPG

This is a blue yellow LM096 OLED, in those the first 2 lines are always yellow.
There exist also all blue, all white and white-yellow ones (ebay, local
shop here has those too at 2 x price).

Note the _controller-chip_ for the display is the SSD1306-1.2.pdf
the LM096 datasheet itself is not very helpfull.

I have put support for German umlauts in txtfont.h

Code is not simple
You can make bitmaps with
bitmap -size 128x64

Not sure all Linux distros still have that \'bitmap\' program, but my old
Slackware on the laptop has it.

Bugs:
The \'line\' function works but clears any previous content.
Have to write a new one using the bitmap code some day..

Program was just for testing the kernel i2c driver on Raspberry Pi4
I have done the OLED thing after that in asm bit banging sda scl in
many Microchip PIC projects.


To enable kernel i2c to GPIO in Raspberry Pi4 you need to use the
raspiconfig menu:
raspiconfig -> interfacing options -> enable disable automatic
loading of kernel i2c_module -> yes -> ESC
reboot

then
i2cdetect -y 1
shows 0x3c if the OLED is detected .
slave adresses are shifted.. in the Linux driver...
I did read the driver docs a hack ;-)
Thing did absolutely nothing
Had a good night sleep
next morning ?hack? lemme try .. and Yes it works.

Thanks !

We use a small OLED display on our Orange Pi.

Probably similar

This turned into a rather deep rabbit hole for me. It all started with
the old FreeBSD 11v2 ARM originally loaded on my Raspberry Pi2 - without
the optional gmake or gcc packages installed. Retroactive installation
of the two soon devolved into Mission Impossible.
So the OS was upgraded to FreeBSD 14v0. It then became trivial to
install both gmake and gcc. Unfortunately, BSD\'s implementation of I2C
on a RPi2 is a little different.
At any rate, my \"Hello World\" program is now able to use a PCF8574A
to drive eight LEDs. God willing, the remainder of my RPi2 I2C OLED
project ought to fall into place shortly. Links to apropos webpages on
my site will be posted as this project wraps up.

Danke,

--
Don, KB7RPU, https://www.qsl.net/kb7rpu
There was a young lady named Bright Whose speed was far faster than light;
She set out one day In a relative way And returned on the previous night.
 
On a sunny day (Fri, 6 Jan 2023 08:51:21 -0500) it happened Bob Engelhardt
<BobEngelhardt@comcast.net> wrote in <sHVtL.190678$Tcw8.123845@fx10.iad>:

On 1/6/2023 2:21 AM, Jan Panteltje wrote:
[...] petahertz per second
There goes their credibility.

Yea, sciencedaily does at times make funny errors in reporting.
Last week they were talking about 100 Hz in a GHz or so system IIRC.
But you can follow the links at the end of the articles if it is not asking for
like 35 dollars to view the pdf...
A fast tunable laser over the whole visible spectrum would allow for a great
simple color laser projector for example.
I have now one with 3 lasers for R, G and B, used it to project things at new
years eve in stead of explosive fireworks.
 
On a sunny day (Fri, 6 Jan 2023 08:51:21 -0500) it happened Bob Engelhardt
<BobEngelhardt@comcast.net> wrote in <sHVtL.190678$Tcw8.123845@fx10.iad>:

On 1/6/2023 2:21 AM, Jan Panteltje wrote:
[...] petahertz per second
There goes their credibility.

Yea, sciencedaily does at times make funny errors in reporting.
Last week they were talking about 100 Hz in a GHz or so system IIRC.
But you can follow the links at the end of the articles if it is not asking for
like 35 dollars to view the pdf...
A fast tunable laser over the whole visible spectrum would allow for a great
simple color laser projector for example.
I have now one with 3 lasers for R, G and B, used it to project things at new
years eve in stead of explosive fireworks.
 
On a sunny day (Fri, 6 Jan 2023 08:51:21 -0500) it happened Bob Engelhardt
<BobEngelhardt@comcast.net> wrote in <sHVtL.190678$Tcw8.123845@fx10.iad>:

On 1/6/2023 2:21 AM, Jan Panteltje wrote:
[...] petahertz per second
There goes their credibility.

Yea, sciencedaily does at times make funny errors in reporting.
Last week they were talking about 100 Hz in a GHz or so system IIRC.
But you can follow the links at the end of the articles if it is not asking for
like 35 dollars to view the pdf...
A fast tunable laser over the whole visible spectrum would allow for a great
simple color laser projector for example.
I have now one with 3 lasers for R, G and B, used it to project things at new
years eve in stead of explosive fireworks.
 

Welcome to EDABoard.com

Sponsor

Back
Top