Wrote a program for Raspberry Pi 4 to drive small 128x64 pixels OLEDs, any interests? (2023 Update)

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:

formatting link

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

Reply to
Jan Panteltje
Loading thread data ...

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,

Reply to
Don

On a sunny day (Sun, 30 Jan 2022 14:46:16 -0000 (UTC)) it happened "Don" snipped-for-privacy@crcomp.net wrote in snipped-for-privacy@crcomp.net:

It is on the website now:

formatting link
use wget
formatting link
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:

formatting link
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.

Reply to
Jan Panteltje

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

Reply to
Chris

Thanks !

We use a small OLED display on our Orange Pi.

Probably similar

boB

Reply to
boB

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,

Reply to
Don

On a sunny day (Fri, 6 Jan 2023 08:51:21 -0500) it happened Bob Engelhardt snipped-for-privacy@comcast.net wrote in <sHVtL.190678$ snipped-for-privacy@fx10.iad:

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.

Reply to
Jan Panteltje

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.