ssd1306 Command Line Tool for RaspberryPi.
It also works with OrangePi / NanoPi.
You can operate from command line.
You can choose Hardware-SPI/Software-SPI/I2C Interface.
- WiringPi Library
This project uses the wiringPiSetup() function to initialize GPIOs.
If you use it on a board other than the RPI board, you may need to change the WiringPi number.
As far as I know, there are these libraries.- WiringPi for OrangePi
- WiringPi for BananaPi
- WiringPi for NanoPi
- WiringPi for Pine-64
+1 String : String for #1 line(with External Font)
+2 String : String for #2 line(with External Font)
+3 String : String for #3 line(with External Font)
+4 String : String for #4 line(with External Font)
+a String : String for #1 line(with Internal Font)
+b String : String for #2 line(with Internal Font)
+c String : String for #3 line(with Internal Font)
+d String : String for #4 line(with Internal Font)
-1 : delete #1 line
-2 : delete #2 line
-3 : delete #3 line
-4 : delete #4 line
+R n : Set inverse mode #n Line
-R n : Unset inverse mode #n Line
+U n : Set underline mode #n Line
-U n : Unset underline mode #n Line
+L : Scroll Up 1Line
-L : Scroll Down 1Line
P1 n : Set start colum n to line#1
P2 n : Set start colum n to line#2
P3 n : Set start colum n to line#3
P4 n : Set start colum n to line#4
r : remove all string
s : show display
You can use within script.
#!/bin/bash
./oled r
./oled +1 "ABCDEFG"
./oled +2 "abcdefg"
./oled +3 "1234567"
./oled +4 "Hello World!!"
sudo ./oled s
OLED | RPi | Pin# | WiringPi# | |
---|---|---|---|---|
Gnd | -- | Gnd | ||
VCC | -- | 3.3V | ||
D0 | -- | SCLK | #23 | |
D1 | -- | MOSI | #19 | |
RES | -- | GPIO18 | #12 | 1(*) |
DC | -- | GPIO17 | #11 | 0(*) |
CS | -- | CS0 | #24 |
(*)You can change to another pin.
#define RST 1 // You can change
#define DC 0 // You can change
OLED | RPi | Pin# | WiringPi# | |
---|---|---|---|---|
Gnd | -- | Gnd | ||
VCC | -- | 3.3V | ||
D0 | -- | SCLK | #23 | 14(*) |
D1 | -- | MOSI | #19 | 12(*) |
RES | -- | GPIO18 | #12 | 1(*) |
DC | -- | GPIO17 | #11 | 0(*) |
CS | -- | CS0 | #24 | 10(*) |
(*)You can change to another pin.
#define MOSI 12 // You can change
#define SCLK 14 // You can change
#define RST 1 // You can change
#define DC 0 // You can change
#define CS 10 // You can change
OLED | RPi | Pin# | |
---|---|---|---|
Gnd | -- | Gnd | |
VCC | -- | 3.3V | |
SCK | -- | SCL | #5 |
SDA | -- | SDA | #3 |
WiringPi Library
git clone https://github.com/nopnop2002/Raspberry-ssd1306
cd Raspberry-ssd1306
cc -o oled oled.c fontx.c -lwiringPi -lpthread -DSPI
bash ./test.sh
git clone https://github.com/nopnop2002/Raspberry-ssd1306
cd Raspberry-ssd1306
cc -o oled oled.c fontx.c -lwiringPi -lpthread -DSPI -DX32
The number of lines which can be indicated is only 2 lines.
git clone https://github.com/nopnop2002/Raspberry-ssd1306
cd Raspberry-ssd1306
cc -o oled oled.c fontx.c -lwiringPi -lpthread -DSPI -DOFFSET=2
bash ./test.sh
Left:1.3 inch SH1106
Right:0.96 inch SSD1306
git clone https://github.com/nopnop2002/Raspberry-ssd1306
cd Raspberry-ssd1306
cc -o oled oled.c fontx.c -lwiringPi -lpthread -DSOFT_SPI
bash ./test.sh
git clone https://github.com/nopnop2002/Raspberry-ssd1306
cd Raspberry-ssd1306
cc -o oled oled.c fontx.c -lwiringPi -lpthread -DSOFT_SPI -DX32
git clone https://github.com/nopnop2002/Raspberry-ssd1306
cd Raspberry-ssd1306
cc -o oled oled.c fontx.c -lwiringPi -lpthread -DSOFT_SPI -DOFFSET=2
bash ./test.sh
git clone https://github.com/nopnop2002/Raspberry-ssd1306
cd Raspberry-ssd1306
cc -o oled oled.c fontx.c -lwiringPi -lpthread -DI2C
bash ./test.sh
git clone https://github.com/nopnop2002/Raspberry-ssd1306
cd Raspberry-ssd1306
cc -o oled oled.c fontx.c -lwiringPi -lpthread -DI2C -DX32
The number of lines which can be indicated is only 2 lines.
git clone https://github.com/nopnop2002/Raspberry-ssd1306
cd Raspberry-ssd1306
cc -o oled oled.c fontx.c -lwiringPi -lpthread -DI2C -DOFFSET=2
bash ./test.sh
Left:1.3 inch SH1106
Right:0.96 inch SSD1306
You can choose the font style.
Please change here.
// You can change font file
Fontx_init(fx,"./fontx/ILGH16XB.FNT","./fontx/ILGZ16XB.FNT"); // 16Dot Gothic
// Fontx_init(fx,"./fontx/ILMH16XB.FNT","./fontx/ILMZ16XB.FNT"); // 16Dot Mincyo
You can add your original fonts.
The format of the font file is the FONTX format.
Your font file is put in fontx directory.
Please refer this page about FONTX format.
There is a font file editor.
This can be done on Windows 10.
Developer page is here.
This tool uses the following as default fonts:
- fontx/ILGH16XB.FNT // 8x16Dot Gothic
- fontx/ILMH16XB.FNT // 8x16Dot Mincyo
Changing this file will change the font.
Left : OrangePi + SPI Module
Right : RaspberryPi + I2C Module
Line1-2 : External Font
Line3-4 : Internal Font