https://github.com/nopnop2002/raspberry-ssd1306
ssd1306 Command Line Tool for Raspberry Pi
https://github.com/nopnop2002/raspberry-ssd1306
i2c oled raspberrypi sh1106 spi ssd1306
Last synced: 2 months ago
JSON representation
ssd1306 Command Line Tool for Raspberry Pi
- Host: GitHub
- URL: https://github.com/nopnop2002/raspberry-ssd1306
- Owner: nopnop2002
- Created: 2017-03-21T13:41:36.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-08-14T05:42:03.000Z (11 months ago)
- Last Synced: 2024-11-09T22:51:30.827Z (8 months ago)
- Topics: i2c, oled, raspberrypi, sh1106, spi, ssd1306
- Language: C
- Homepage:
- Size: 3.18 MB
- Stars: 47
- Watchers: 5
- Forks: 15
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Raspberry-ssd1306
ssd1306 Command Line Tool for RaspberryPi.
This may works with other boards like OrangePi/NanoPi.You can operate from command line.
You can choose Hardware-SPI/Software-SPI/I2C Interface.# Software requirement
- 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# Command line parameters
+1 String : String for #1 line(Use External Font)
+2 String : String for #2 line(Use External Font)
+3 String : String for #3 line(Use External Font)
+4 String : String for #4 line(Use External Font)
+a String : String for #1 line(Use Internal Font)
+b String : String for #2 line(Use Internal Font)
+c String : String for #3 line(Use Internal Font)
+d String : String for #4 line(Use 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 displayYou can use within script.
#!/bin/bash
./oled r
./oled +1 "ABCDEFG"
./oled +2 "abcdefg"
./oled +3 "1234567"
./oled +4 "Hello World!!"
sudo ./oled s---
# Wire connection for Hardware SPI
|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---
# Wire connection for Software SPI
|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---
# Wire connection for I2C
|OLED||RPi|Pin#|
|:-:|:-:|:-:|:-:|
|Gnd|--|Gnd||
|VCC|--|3.3V||
|SCK|--|SCL|#5|
|SDA|--|SDA|#3|---
# Install SSD1306 for Hardware SPI (128x64)
```
git clone https://github.com/nopnop2002/Raspberry-ssd1306
cd Raspberry-ssd1306
cc -o oled oled.c fontx.c -lwiringPi -lpthread -DSPI
bash ./test.sh
```
---
# Install SSD1306 for Hardware SPI (128x32)
```
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.
---
# Install SH1106 for Hardware SPI (128x64)
```
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
---
# Install SSD1306 for Software SPI (128x64)
```
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
```---
# Install SSD1306 for Software SPI (128x32)
```
git clone https://github.com/nopnop2002/Raspberry-ssd1306
cd Raspberry-ssd1306
cc -o oled oled.c fontx.c -lwiringPi -lpthread -DSOFT_SPI -DX32
```---
# Install SH1106 for Software SPI (128x64)
```
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
```---
# Install SSD1306 for I2C (128x64)
```
git clone https://github.com/nopnop2002/Raspberry-ssd1306
cd Raspberry-ssd1306
cc -o oled oled.c fontx.c -lwiringPi -lpthread -DI2C
bash ./test.sh
```
---
# Install SSD1306 for I2C (128x32)
```
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.
---
# Install SH1106 for I2C (128x64)
```
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
# Font File
This tool uses the following as default fonts:
- fontx/ILGH16XB.FNT // 8x16Dot Gothic
- fontx/ILMH16XB.FNT // 8x16Dot MincyoChanging this file will change the font.
```
// 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](http://elm-chan.org/docs/dosv/fontx_e.html) page about FONTX format.
# Font File Editor(FONTX Editor)
[There](http://elm-chan.org/fsw/fontxedit.zip) is a font file editor.
This can be done on Windows 10.
Developer page is [here](http://elm-chan.org/fsw_e.html).
# Convert from TTF font to FONTX font
step1)
Download WFONTX64.exe from [here](https://github.com/nemuisan/WFONTX64/releases).
Developer page is [here](https://github.com/nemuisan/WFONTX64).step2)
Select ttf font.
___Please note that if you select a proportional font, some fonts may not convert correctly.___
If you select a proportional font, some fonts will need to be modified using fontxedit.exe.
Monospaced fonts can be converted correctly.
step3)
Enter Height, Width, FontX2 name.
Specify half of Height for Width.
Specify your favorite font name in the FontX2 name field using up to 8 characters.
step4)
Specify the file name to save.
step5)
Specify the font style as required.
step6)
Press the RUN button to convert TTF fonts to FONTX format.
step7)
upload your font file to $HOME/Raspberry-ssd1306/fontx directory.step8)
add font to use
```
// 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
Fontx_init(fx,"./fontx/Algerian16.FNT",""); // 16Dot Algerian
```
---
Left : OrangePi + SPI Module
Right : RaspberryPi + I2C Module
---


Line1-2 : External Font
Line3-4 : Internal Font
Underline and Invert
Set start colum

---
RaspberryPi ZERO HAT + OLED
OrangePi ZERO HAT + OLED
