please choosego to mobile | Continue to access the PC version
View: 11640|Reply: 1

oled ssd1306 I2C OK --- U8glib OK

[Copy link]

12

threads

30

posts

150

credits

Registered member

Rank: 2

credits
150
Published in 2016-1-1 15:51:58 | Show all floors |Read mode
these little oled display have a two-wire (SDA-SCL) interface (pa11 and pa12 on orange pi PC)
I used the loboris kernel which has I2C support compiled into it (no need to adapt script.bin)

I came across this link - it is the u8-library for the arduino, which can be patched for the raspberry pi.
I works out of the box for the orange pi PC (install the wiringOP library)

I modified the example (logo) so it can display text and does not stay in a loop.


https://code.google.com/p/u8glib/issues/detail?id=171
Make sure you've got wiringPi (wiringOP) 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

I used this setting in my example program - which can be adapted to other displays
-> U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE);

I could not attach my zip, so here's my example program and Makefile:

int main(void) {
char apa[10]="Orange ";
char apb[10]="Pi PC ";
printf("begin console\r\n");
u8g.setFont(u8g_font_gdr25r);
//u8g.setFont(u8g_font_6x13);
//  while(true) {
    u8g.firstPage();
    do {
//      draw();
    u8g.setColorIndex(1);
u8g.drawStr(1, 25, apa);
u8g.drawStr(1, 64, apb);
    } while( u8g.nextPage() );

  //  usleep(10*1000);
// }
  return 0;
}

--Makefile---
PROGRAMS = console
SOURCES = ${PROGRAMS:=.cpp}

CC=g++
INCLUDE=/opt/include
LIBRARY=/usr/lib
LIBS=-lwiringPi -lU8glib

PREPROCESSOR=-DU8G_RASPBERRY_PI
CCFLAGS=-Ofast -mfpu=vfp

all: ${PROGRAMS}

${PROGRAMS}: ${SOURCES}
        ${CC} ${PREPROCESSOR} ${CCFLAGS} -Wall -I${INCLUDE} -L${LIBRARY} $@.cpp -o $@ ${LIBS}

clean:
        rm $(PROGRAMS)






7

threads

81

posts

317

credits

Intermediate member

Rank: 3Rank: 3

credits
317
Published in 2016-2-9 06:11:01 | Show all floors
@snowbody

Thank you for the information. I have successfully used ssd1306 oleds in Arduino projects and am anxious to try them out on
the OPI ONEs I just ordered ( hoping the Chinese New Year will fade off in a foreseeable future ). The cheap and low power
ssd1306 oleds are great for visual feedback in battery-driven setups.

Have a nice day and keep up the good work.



You need to log in before you can reply login | Register

Points Rule

Quick reply Top Return list