Giter Site home page Giter Site logo

raspberry-ssd1306's Introduction

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


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

OLED-128x64


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.
OLED-128x32


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
OLED-SH1106


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

OLED-1


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.
oled-3


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
OLED-SH1106


Change font style

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

Font File

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.


Font File Editor(FONTX Editor)

There is a font file editor.
This can be done on Windows 10.
Developer page is here.

FontxEditor

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
oled-2


OLED-1

OLED-2

Line1-2 : External Font
Line3-4 : Internal Font
OLED-4

Underline and Invert
OLED-5

Set start colum
OLED-6

OLED-7


RaspberryPi ZERO HAT + OLED
RaspberryPi-ZERO

OrangePi ZERO HAT + OLED
zero-hat-7

raspberry-ssd1306's People

Contributors

nopnop2002 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

raspberry-ssd1306's Issues

Screen Flickering

When attempting to make a scrollable menu, there are lots of flickering as the screen changes options. Where would I go about in the code to fix this problem?

OLED 1.3" displays with SH1106

Hi and thank you for creating such a great tool for working with 0.96 and 0.91 OLED displays with SSD1306. 0.96" OLED is probably the most widely used in any projects from all of the OLED screen sizes. 1.3" OLED's are also highly popular, less stressful to the eyes, with much better readability. However, many of 1.3" OLED's come with SH1106 chip instead of SSD1306. OLED's with SH1106 are nearly identical to SSD1306 and can be initialized in a similar way, but their geometry is slightly "offset". 1.3" OLED's SH1106 chip memory works with 132x64 pixels instead of 128x64 in SSD1306. Is there anything we can change in oled.c to try to support 1.3" OLED with SH1106? Currently the 1.3" displays will initialize, but the printing to screen will be very much offset. Running test.sh or trying to command the display to print text to any of the rows will show somewhere in the first row clearly broken. It would be great if both 0.96" and 1.3" OLED's could be supported? Regards,

Font size

Hi, Is there a way to increase the font size?

Adding text returns error code 1

Hi,

I tried using oled in /etc/rc.local to print a message like the IP address. it's not working, so I looked a bit into it.

The problem is, that the command:

./oled +a "Booting..."

Delivers Exit Code 1 which causes /etc/rc.local to terminate. So what's the reason for returning a none-zero exit code here?

SSD1306 128x32 SPI turning off alone

I'm testing the SSD1306 128x32 SPI, and the examples of python code I have tested all work fine. My issue is that the screen turns off just some seconds (1 or 2 seconds) after I test the code.
What might be causing this?

Scrolling Text

Hi there,
I have a question regarding scrolling text.At the moment I am scrolling it both horizontally and vertically but its not a smooth scroll like i can see a flicker or delay when text moves on the screen
is there a way we can do a smooth scrolling so that user wont notice a flicker or delay on the screen when the text moves.

Thanks
Nabeel
[email protected]

Error when running i2d example

I'm on the pizerow. As instructed on the readme, I clone the repo and run the command:

cc -o oled oled.c fontx.c -lwiringPi -lpthread -DI2C

The following error occurs:

oled.c:46:10: fatal error: wiringPi.h: No such file or directory
#include <wiringPi.h>
^~~~~~~~~~~~
compilation terminated.

What am I doing wrong?

Displaying a bitmap image

I have a bitmap of a picture as follow generated from: http://javl.github.io/image2cpp/

// 'IMG_0263', 128x32px
const unsigned char epd_bitmap_IMG_0263 [] PROGMEM = {
	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xff, 0xff, 0xff, 
	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0xff, 
	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x3f, 0xff, 0xff, 0xff, 0xff, 
	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0xff, 0xfc, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 
	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 
	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 
	0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 
	0xff, 0xe0, 0x07, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 
	0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 
	0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 
	0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 
	0xff, 0xff, 0xfc, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 
	0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 
	0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
	0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xfc, 0x03, 0xff, 0xff, 0xff, 
	0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0x00, 0x07, 0xff, 0xff, 
	0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xfe, 0x00, 0x07, 0xff, 
	0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0xf8, 0x00, 0xff, 
	0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff, 0x00, 
	0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
	0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x2f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
	0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x13, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
	0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x38, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
	0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x7c, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
	0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
	0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
	0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 
	0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 
	0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 
	0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};

// Array of all bitmaps for convenience. (Total bytes used to store images in PROGMEM = 528)
const int epd_bitmap_allArray_LEN = 1;
const unsigned char* epd_bitmap_allArray[1] = {
	epd_bitmap_IMG_0263
};

How would I go about displaying this on a 128x32 oled screen?

Nice work! some problem with Node Red

Hi, first of all, thanks for this tool. it looks very good and worked almost fine for me. I was looking for a way to display in my OLED screen when the raspberry boot and shutdown, so will be easily using a bash script. However, after I install your script and tested, it worked but does a conflict with the node red oled node. It looks that after I send the comand "/.oled s" it send the screen a comand that only allow to write to line 1 and this maybe is the cause of the conflict. Not sure, but i will like to use your script in conjunction with other libraries for the OLED. So i can maintan using node redd for capuring data and display it in the oled and also when I boot I want to use your script. Hope you cand give me some hints in how I can fix the issue. Im from Chile and looked into your web page. Lot of interesting projects that i will take a look. Thanks for publishing them. Attaches is a small video of what I get after I run your script and that node red is triyng to use the screen after yours.

Untitled.mov

Line positions are screwed up...

Okay, something is behaving strange here when it comes to line positioning:

When I run the test.sh

abcdefg 1234567 Hello World!! ABCDEFG

A little later down in test.sh it displays
Line 2 Line 1 Line 4 Line 3

If I write a text with the command
./oled +a "BLABLA"

It seems to be displayed in line 3. But I've also seen a text line sliced between the bottom of the screen and the top of it.

So not sure what is causing the problem...but something it wrong here when it's comes to positioning within the display.

The display is connected via I2C and works totally fine with the Python ssd1306 libraries and tools...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.