Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port U8glib to Raspberry Pi #171

Open
olikraus opened this issue Jun 23, 2015 · 52 comments
Open

Port U8glib to Raspberry Pi #171

olikraus opened this issue Jun 23, 2015 · 52 comments

Comments

@olikraus
Copy link
Owner

Originally reported on Google Code with ID 171

GPIO Programming: http://elinux.org/RPi_Low-level_peripherals

There seem to be two options:
Low level gpio programming (mmap/linux)

Other option would be to use this lib:
https://projects.drogon.net/raspberry-pi/wiringpi/


Reported by olikraus on 2013-05-26 05:52:58

@olikraus
Copy link
Owner Author

U8glib runs well on the Raspberry Pi - well, I've only used it on the PCD8544 but I
don't see why any SPI type LCD display wouldn't work equally as well.  I ported it
over so I could have some easy to use routines for a project that I'm working on.

For ease of porting I used wiringPi.  The question is, other people will find what
I've done useful, but how could it be released?  I could send it on up to something
like github, but it would be better to work with the find chaps that continuously work
on U8glib to keep it updated.

Reported by aaron.j.blanchard on 2013-09-02 14:21:04

@olikraus
Copy link
Owner Author

maybe you can attach your work to this issue. Once i find time, i can include it into
the repository.

Reported by olikraus on 2013-09-03 11:16:26

@olikraus
Copy link
Owner Author

How would you like it - a patch-set against a known release?

Reported by aaron.j.blanchard on 2013-09-03 15:28:44

@olikraus
Copy link
Owner Author

patch set would be ok (against which version?)

Reported by olikraus on 2013-09-03 16:40:04

@olikraus
Copy link
Owner Author


I've attached the files, an example file and a picture to show that it works.

Also, the instructions (below) are more detailed than I'm sure you'll need, but may
help other people with this if they want to do it before you've released it.


You'll obviously need to install wiringPi on your RPi


$ wget https://u8glib.googlecode.com/files/u8glib_arduino_v1.13.zip
$ unzip u8glib_arduino_v1.13.zip
$ cd U8glib
And depending on where your patch is:
$ patch -p1 < ../rpi_u8glib.patch 
$ make

$ g++ U8gLogo.cpp -o U8gLogo -l wiringPi -l U8glib -I include -L .
$ sudo ./U8gLogo


I use this with M2tklib (https://code.google.com/p/m2tklib/ - also ported) to have
nice menus.

Limitations:
1. It's hard coded to use CS0 for the SPI (as mentioned in U8gLogo.cpp).
2. I've only tested it with the PCD8554 LCD display.
3. There is an include directory with a couple of random header files from the Arduino
camp which I've put in to make it compile.  I've not bothered to look into these more
as as it stands the library does all I want it to do.
4. There is a printf tucked away I forgot to remove in a layer I wasn't sure what to
do with.  

Any questions - please ask!

Reported by aaron.j.blanchard on 2013-09-04 08:19:03


- _Attachment: [rpi_u8glib.patch](https://storage.googleapis.com/google-code-attachments/u8glib/issue-171/comment-6/rpi_u8glib.patch)_ - _Attachment: [U8gLogo.cpp](https://storage.googleapis.com/google-code-attachments/u8glib/issue-171/comment-6/U8gLogo.cpp)_ - _Attachment: [20130904_094959_n.jpg](https://storage.googleapis.com/google-code-attachments/u8glib/issue-171/comment-6/20130904_094959_n.jpg)_

@olikraus
Copy link
Owner Author

Thanks for providing the patch. 

Reported by olikraus on 2013-09-04 08:28:18

@olikraus
Copy link
Owner Author

Has this been added to the main code base yet? Or do I still need to download the patch
and apply it separately?

Reported by mecworks on 2013-12-03 19:14:14

@olikraus
Copy link
Owner Author

Unfortunately i still do not own a Raspberry Pi. So testing is not possible for me.

Reported by olikraus on 2013-12-03 19:37:59

@olikraus
Copy link
Owner Author

olikr...: I'd like to buy you a Raspberry Pi so you can add official support for it
:) Where do you live?

Reported by gezuru on 2013-12-05 15:05:43

@olikraus
Copy link
Owner Author

It is not only that i do not own a Pi, but currently i do not have time to add support
for a complete new system. Additionally my hope is, that the new "arm" release of u8glib
can be ported easily to the Raspberry Pi.
Still you are free to contact me through e-mail (see source code)


Reported by olikraus on 2013-12-05 18:55:53

@olikraus
Copy link
Owner Author

still pending...

Reported by olikraus on 2014-01-22 19:08:19

@olikraus
Copy link
Owner Author

Hi I have a ST7920 12864 lcd, i followed your steps above but changed the constructor
call in the .cpp from 

//U8GLIB_PCD8544 u8g(10, 3, 11);        // SPI Com: CS = 10, A0 = 3, Reset = 11

to 

U8GLIB_ST7920_128X64_1X u8g(13, 11, 10);    // SPI Com: SCK = en = 18, MOSI = rw = 16,
CS = di = 17

Unfortunately running the program does not display anything. Any comments?

Reported by larry1chan on 2014-05-03 17:37:20

@olikraus
Copy link
Owner Author

from my side, i did not yet worked on the pi, so i also do not know how to support here.

Reported by olikraus on 2014-05-03 20:54:19

@olikraus
Copy link
Owner Author

hi, i am new to this and expirimenting with a OLED and Pi. I bought the 4-pin model.
i am curious if it is possible to attach it direct to the Pi using u8glib ? Problem
with this display is that i cannot get it to live, don't even know if it's broken,
is there some method to test ?

Reported by richardtepas on 2014-08-30 10:43:50


- _Attachment: [20140830_123737.jpg](https://storage.googleapis.com/google-code-attachments/u8glib/issue-171/comment-15/20140830_123737.jpg)_ - _Attachment: [20140830_123713.jpg](https://storage.googleapis.com/google-code-attachments/u8glib/issue-171/comment-15/20140830_123713.jpg)_

@olikraus
Copy link
Owner Author

There is still no official support for the Pi. In fact, i do not own this hardware.

Reported by olikraus on 2014-09-03 19:31:15

@olikraus
Copy link
Owner Author

@richardtepas: I am sorry for deleting your last comment. I can not validate the link
and also the answer is very specific to one display type. Probably it is better to
place the link on an Ras-Pi forum.

Reported by olikraus on 2014-09-07 13:00:07

@olikraus
Copy link
Owner Author

@richardtepas:  It IS possible to get the 4-pin I2C OLED module to work with the Pi.
 I had to do some additions and modifications but got it working.  I'll see what I
can do to create a patch file(s) 

Reported by vernonm on 2014-09-30 16:18:44


- _Attachment: [IMAG0141.jpg](https://storage.googleapis.com/google-code-attachments/u8glib/issue-171/comment-19/IMAG0141.jpg)_

@olikraus
Copy link
Owner Author

that would be great! cannot see it exactly on the photo. how did you wire it up ?
thanks a lot !

Reported by camera7007 on 2014-10-01 07:25:22

@olikraus
Copy link
Owner Author

这个可以驱动ks108吗?

Reported by yangkkokk on 2014-10-01 21:37:45

@olikraus
Copy link
Owner Author

unfortunately my chinese is not as good as at was these days..............

Reported by camera7007 on 2014-10-02 04:21:41

@olikraus
Copy link
Owner Author

In that photo I had used external pull-ups.  But they aren't needed if you use the internal
pull-ups for the RPi.  Since that photo I've wired it up directly using the following
pins:

I2C Display   Raspberry Pi
--------------------------
VCC           1 
GND           9
SDA           3 (wiringPi Pin 8)
SCL           5 (wiringPi Pin 9)

Need to get a diff from the standard 1.16 so I can upload a patch.  

Reported by vernonm on 2014-10-07 03:41:37

@olikraus
Copy link
Owner Author

So even though I'm using U8glib on an ARM (Raspberry Pi), I've opted to use the "Arduino"
libraries because I'm using C++ and was use to using U8glib with AVR.

Make sure you've got wiringPi installed.

$ wget http://dl.bintray.com/olikraus/u8glib/u8glib_arduino_v1.16.zip
$ unzip u8glib_arduino_v1.16.zip
$ cd U8glib
$ patch -p1 < /tmp/u8glib_1.16.RaspberryPi.patch
$ make

I installed the library
$ cp libU8glib.a /usr/lib
$ cp U8blib.h /usr/include


To compile the logo:
$ cd examples/U8gLogo
$ make                   // Edit Makefile for U8glib/include directory.  I uncompressed
U8glib 1.16 in /opt/U8glib
$ ./logo

Reported by vernonm on 2014-10-07 04:10:49


- _Attachment: [u8glib_1.16.RaspberryPi.patch](https://storage.googleapis.com/google-code-attachments/u8glib/issue-171/comment-24/u8glib_1.16.RaspberryPi.patch)_

@olikraus
Copy link
Owner Author

nice patch. I try to add this to the repository.

Reported by olikraus on 2014-10-07 05:07:38

  • Labels added: Milestone-1.17
  • Labels removed: Milestone-Future

@olikraus
Copy link
Owner Author

U8G_I2C_OPT_NO_ACK is not supported for the i2c port, right?

Reported by olikraus on 2014-10-07 05:17:27

@olikraus
Copy link
Owner Author

ToDo (u8glib project)
- checkin patched files
- test ssd1306 (modified, but not clear what has changed)
- create release folder for raspberry pi, create release construction script
- create install instructions, is WiringPi required? Check copyright issues.
- update device wiki page, support only for spi and i2c with ssd130x
- create bintry folder, check for suitable icon (copyright?) http://www.raspberrypi.org/trademark-rules/

Reported by olikraus on 2014-10-07 06:06:07

@olikraus
Copy link
Owner Author

U8G_I2C_OPT_NO_ACK should be supported.  Actually though it didn't seem to make any
difference with mine.  Perhaps because it was ignored?  But I did have to modify the
include files so I could initialize with U8G_I2C_OPT_NO_ACK.

I'm glad it was helpful.  It seems as if there are quite a few of these OLED displays
out in the wild now.  Thanks so much for making this wonderful library!

Reported by vernonm on 2014-10-07 13:33:26

@olikraus
Copy link
Owner Author

i guess i need to check whether the modification to the init strings will still work
with my displays.

Reported by olikraus on 2014-10-07 18:05:49

@olikraus
Copy link
Owner Author

The change happend to U8glib.h is not clear to me. The virtual function has changed
from 0022 to 1.0. Is there an issue with wiringPi?

Reported by olikraus on 2014-10-07 18:11:26

@olikraus
Copy link
Owner Author

hmm.. some files are distributed under LGPL, which is not as flexible as BSD license.
This needs to be documented.
All in all, this is the new todo list for this project:

ToDo (u8glib project)
- checkin patched files, except for the c++ classes (because they will not be backward
compatible)
- C++ files need to be analysed together with wiringPi. Maybe ADURINO define is not
correct or some extra #ifdef is required inside U8glib.h
- test ssd1306 (init sequence modified, must be checked against the existing hardware)
- create release folder for raspberry pi, create release construction script
- create install instructions, WiringPi probably required. 
- Extend copyright documentation: Some files are under LGPL
- update device wiki page, support only for spi and i2c with ssd130x
- create bintry folder, check for suitable icon (copyright?) http://www.raspberrypi.org/trademark-rules/
- analyse U8G_I2C_OPT_NO_ACK topic. I still think it is not supported (actually it
is violation of the I2C specification)

Reported by olikraus on 2014-10-07 18:21:14

@olikraus
Copy link
Owner Author

Yeah, actually I don't think I did this correctly. Instead of
modifying u8g_dev_ssd1306_128x64_adafruit3_init_seq, I should have created
something like u8g_dev_ssd1306_128x64_adafruit4_init_seq and then used a
#ifdef for raspberry pi and set it to the adafruit4 init sequence.

Thoughts?

Reported by vernonm on 2014-10-07 19:08:18

@olikraus
Copy link
Owner Author

Well I made this change because the additional include files wouldn't work
unless I made those changes.  You're talking about these, right?

#define ARDUINO 200

and

-    void write(uint8_t c) { tx += u8g_DrawGlyph(&u8g, tx, ty, c); }
+    size_t write(uint8_t c) { tx += u8g_DrawGlyph(&u8g, tx, ty, c); return
1;}

I believe those are the only changes I made.  Actually the diff had a few
other lines, but they just joined lines.  Should have cleaned that up
first.

Reported by vernonm on 2014-10-07 19:12:19

@olikraus
Copy link
Owner Author

lot of activity !, nice ! hope i have some time next week to see if i can make my OLED
work with this information. What is the meaning of the wiringPi pin
do u use another pin in combination with wiringPi ?

I2C Display   Raspberry Pi
--------------------------
VCC           1 
GND           9
SDA           3 (wiringPi Pin 8)
SCL           5 (wiringPi Pin 9)

Reported by camera7007 on 2014-10-07 19:23:03

@olikraus
Copy link
Owner Author

No.  I suppose I shouldn't have put the wiringPi pin's in there.  It's the same pin,
but wiringPi library has a different pin definition (pin name vs physical pin).  Ignore
those and you'll be ok.  :)

I2C Display   Raspberry Pi
--------------------------
VCC           1 
GND           9
SDA           3 
SCL           5 

Reported by vernonm on 2014-10-07 20:35:45

@olikraus
Copy link
Owner Author

If you can get past the blur cam (tried to focus on the RPi pins) then this is the pinout
I used.

Reported by vernonm on 2014-10-07 20:46:27


- _Attachment: [IMAG0158.jpg](https://storage.googleapis.com/google-code-attachments/u8glib/issue-171/comment-38/IMAG0158.jpg)_

@olikraus
Copy link
Owner Author

Also, thanks a lot from my side for the information and activity here. It makes me confident,
that there is some need for the Pi Port.

Reported by olikraus on 2014-10-07 22:15:21

@olikraus
Copy link
Owner Author

small update, i took over the following files


patching file U8glib.cpp                minor change, no problem    copied
patching file U8glib.h              strange, seems that wiringPi.h  copied
        Does wiringPi.h define the ARDUINO constant correctly?
patching file utility/u8g_com_i2c.c         modified, ok
patching file utility/u8g_com_io.c          modified, ok
patching file utility/u8g_com_raspberrypi_hw_spi.c  ok
patching file utility/u8g_com_raspberrypi_ssd_i2c.c ok
patching file utility/u8g_delay.c               modified, ok
patching file utility/u8g.h                     copied
patching file utility/u8g_state.c                   copied


i did not took over this until now:
patching file utility/u8g_dev_ssd1306_128x32.c  ???, not transfered
patching file utility/u8g_dev_ssd1306_128x64.c  ???, not transfered

Reported by olikraus on 2014-10-12 10:59:19

@olikraus
Copy link
Owner Author

这个怎么移植ks108

Reported by yangkkokk on 2014-10-13 02:25:39

@olikraus
Copy link
Owner Author

我不知道关于ks108。但如果是SPI或I2C我想它会正常工作。

Pi

Reported by vernonm on 2014-10-13 02:57:30

@olikraus
Copy link
Owner Author

i move this t 1.18. Still i do not own the Pi

Reported by olikraus on 2014-12-13 16:56:14

  • Status changed: Started
  • Labels added: Milestone-1.18
  • Labels removed: Milestone-1.17

@olikraus
Copy link
Owner Author

I too have one of the cheap four pin 128x64.
I'd tried the Adafruits drivers for the Pi (Python)
which did not work.
I then installed wringPi and 1.16 as per post #24
getting the logo program to compile was fun. I needed to add two libraries in the Makefile
and the syntax on gcc only allows one (I think) this worked...
  INCLUDE=/home/pi/U8glib/include -I/home/pi/U8glib
however sudo ./logo did not work either.
At no time did I have a /dev/i2c-1 (or 0)
I have SPI and IC2 enabled (not blacklisted) via raspbi-config.
I'm used to linux adding devices at boot time so expected the device to be created
if the unit was not DOA. I wondered if this was normal because of the lack of ACK thingy.
I Googled for the missing device and hit Gordon's site.
I simply needed to run `gpio load i2c` to load the device.
With this in place both adafruits and U8glib's logo sprang into life.

At least now I know I can patch four wires correctly and my unit is not dead.

Many thanks for your work here.

Reported by SimonMay88 on 2014-12-24 16:33:30

@olikraus
Copy link
Owner Author

I was able to get the Adafruit python drivers working for the pi, but I would really
prefer to use the U8Glib if possible. I've been using U8Glib on arduino for a few months
now and with the font support I would like to continue using U8Glib on the Raspberry
Pi. Hopefully 1.18 is released very soon!

Reported by chad.hedstrom on 2015-01-03 10:13:16

@olikraus
Copy link
Owner Author

Actually i may not be able to do anything for v1.18.
It alread has been shifted to the next release and probably shifting might be continued.
Main reason is: I do not own the Pi and i am not able to test or debug anything. This
makes development almost impossible. I tried to add any of the modifications from above
to U8glb, but without having them tested, it is difficult to say  whether they work
or not.

So the situation is this: As long as there is no software developer & test engineer
joining this project, there probably will be no release for the pi.

From my perspective the following things should be done:
- Make a full and good description how to install u8glib for Pi (wiki page here in
this project)
- Apply all required changes to u8glib, check in everything
- Test the U8glibinstallation and test some examples
- Ensure that there are no conflicts with other variants of u8glib. It should still
run with the Arduino Environment.

Still a lot of work is done, but i do not have the time or budget to do this.

Reported by olikraus on 2015-01-03 10:53:48

@olikraus
Copy link
Owner Author

st7920无法工作

Reported by yangkkokk on 2015-01-17 19:22:12

@olikraus
Copy link
Owner Author

After entering the make command my wifi dies. I tested this 3 times on a fresh install
of Raspian Debian Wheezy. When I check the wpa_gui it tells me "could not get status
from wpa_supplicant". Anyone else have this problem?

Reported by metincelik88 on 2015-02-06 22:52:35

@olikraus
Copy link
Owner Author

I'd just like to report that I managed to get DOGXL160 working using 4 wire SPI and
the patch from #24 (thanks!) I've used two-parameter constructor to make it use hardware
SPI.

I'm currently trying to make it draw whole screen in one sweep (it currently does 13
or, when using X2 driver -- 7 sweeps) since Raspberry has plenty of RAM and we don't
need it to draw everything multiple times. I hope it will make it faster since it's
not really fast right now.

Reported by gshegosh on 2015-03-17 23:02:48

@olikraus
Copy link
Owner Author

#50, that'd be great.  I am using 4-wire SPI and got much better refresh rates by changing
the bus speed.  What worked well for me was to change from 500 kHz to 3.2 MHz.  Check
utility/u8g_com_raspberrypi_hw_spi.c on or near line #77

Reported by vernonm on 2015-03-17 23:16:46

@gatuno1
Copy link

gatuno1 commented Dec 17, 2015

I would like to report I was successful to compile the library and few examples from github code on Raspberry Pi, and also they work on my SSD1306 SPI connected!!

I did this procedure:

  • Install some prerequisites:
$ sudo apt-get install build-essential autoconf libtool libsdl1.2-dev

I had a lot of trouble to identify the need of packages autoconf and libtool, but after that the build was easy.

  • Get the lastest code from Github

Currently I tested with v.1.18.1.

$ sudo git clone https://github.com/olikraus/u8glib.git
$ cd u8glib/

For the following examples I had to select the corresponding LCD, editing the following files:

$ sudo nano sys/arduino/Chess/Chess.cpp
$ sudo nano sys/arduino/U8gLogo/U8gLogo.cpp
$ sudo nano sys/arduino/GraphicsTest/GraphicsTest.cpp

changing the corresponding line of my lcd (SSD1306_128X64):

    //U8GLIB_SSD1306_128X64 u8g(10, 9);             // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)

changed to:

    U8GLIB_SSD1306_128X64 u8g(10, 5, 6);             // HW SPI Com: CS = 10 @wiringpi (8 @BCM_GPIO), A0 = 5 @wiringpi (24 @BCM_GPIO), RESET = 6 @wiringpi (25 @BCM_GPIO) (Hardware Pins are SCK = 14 @wiringpi (11 @BCM_GPIO) and MOSI = 12 @wiringpi (10 @BCM_GPIO))

My setup was using hardware SPI in Raspberry Pi and two addtional pins with the following connections (using WiringPi numbering from http://wiringpi.com/pins/ ):

OLED Module pin RPi Function / BCM Numbering pin RPi header pin WiringPi numbering Pin u8glib pin
1-VCC +3.3V pin 17 - -
2-GND GND pin 20 - -
3-NC not connected - - -
4-DIN (data input) MOSI / GPIO10 pin19 12 MOSI
5-CLK (clock) SCLK / GPIO11 pin23 14 SCK
6-CS (select) CE0# / GPIO8 pin24 10 CS
7-D/C (data/command) GPIO24 pin18 5 A0
8-RES (reset) GPIO25 pin22 6 RESET
  • Configuring and compile:
$ sudo ./autogen.sh
$ sudo ./configure
$ sudo make
$ sudo make install
  • Runing logo example:
    $ sudo ./u8gwpi_logo

20151217_001448
20151217_001402

@olikraus
Copy link
Owner Author

Thanks for the report.

@gshegosh
Copy link

So I've finally managed to implement single sweep drawing for DOGXL160 on Raspberry pi. I've created a pull request against current master if someone needs it.

@olikraus
Copy link
Owner Author

I have similar plans also for all other devices. I will implement this for the next major release.

@girs1982
Copy link

girs1982 commented May 6, 2021

I would like to report I was successful to compile the library and few examples from github code on Raspberry Pi, and also they work on my SSD1306 SPI connected!!

I did this procedure:

  • Install some prerequisites:
$ sudo apt-get install build-essential autoconf libtool libsdl1.2-dev

I had a lot of trouble to identify the need of packages autoconf and libtool, but after that the build was easy.

  • Get the lastest code from Github

Currently I tested with v.1.18.1.

$ sudo git clone https://github.com/olikraus/u8glib.git
$ cd u8glib/

For the following examples I had to select the corresponding LCD, editing the following files:

$ sudo nano sys/arduino/Chess/Chess.cpp
$ sudo nano sys/arduino/U8gLogo/U8gLogo.cpp
$ sudo nano sys/arduino/GraphicsTest/GraphicsTest.cpp

changing the corresponding line of my lcd (SSD1306_128X64):

    //U8GLIB_SSD1306_128X64 u8g(10, 9);             // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)

changed to:

    U8GLIB_SSD1306_128X64 u8g(10, 5, 6);             // HW SPI Com: CS = 10 @wiringpi (8 @BCM_GPIO), A0 = 5 @wiringpi (24 @BCM_GPIO), RESET = 6 @wiringpi (25 @BCM_GPIO) (Hardware Pins are SCK = 14 @wiringpi (11 @BCM_GPIO) and MOSI = 12 @wiringpi (10 @BCM_GPIO))

My setup was using hardware SPI in Raspberry Pi and two addtional pins with the following connections (using WiringPi numbering from http://wiringpi.com/pins/ ):

OLED Module pin RPi Function / BCM Numbering pin RPi header pin WiringPi numbering Pin u8glib pin
1-VCC +3.3V pin 17 - -
2-GND GND pin 20 - -
3-NC not connected - - -
4-DIN (data input) MOSI / GPIO10 pin19 12 MOSI
5-CLK (clock) SCLK / GPIO11 pin23 14 SCK
6-CS (select) CE0# / GPIO8 pin24 10 CS
7-D/C (data/command) GPIO24 pin18 5 A0
8-RES (reset) GPIO25 pin22 6 RESET

  • Configuring and compile:
$ sudo ./autogen.sh
$ sudo ./configure
$ sudo make
$ sudo make install
  • Runing logo example:
    $ sudo ./u8gwpi_logo

20151217_001448
20151217_001402

its very cool but now, it cant compile , errors , please create git repo and put files
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants