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:
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