olikraus / u8glib

Arduino Monochrom Graphics Library for LCDs and OLEDs
https://github.com/olikraus/u8glib/wiki
Other
1.25k stars 314 forks source link

Port U8glib to Raspberry Pi #171

Open olikraus opened 9 years ago

olikraus commented 9 years ago

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 commented 8 years ago

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

girs1982 commented 3 years ago

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