Jump to content

Recommended Posts

Posted

The Luma library allows you to display text, graphics, animation, etc. on multiple display types. Here I will describe the easiest one to configure which is Luma.OLED and the I2C version of the SSD1306. You can find these displays on EBay and Amazon for less than $10 US each (you can get them for less than $3 US if you order from China, but it might not show up). I've configured Luma on many SBCs and it's my go to library if I need a small display for projects.

 

duo.png.c4eb79e471d2445cd358f5d371d912fb.png

 

Requirements

  • NanoPi Duo (I used V1.0 board with 512 MB RAM) flashed with Armbian image. This will work with or without the mini shield.
  • Small nylon nuts, bolts and standoffs if you want to mount display
  • I2C OLED display (check http://luma-oled.readthedocs.io/en/latest/hardware.html)
  • 4 female to female jumper wires

If you want to configure wifi the easy way just edit the following file on the SD sudo nano /media/username/43296f0d-fc9e-4cec-b3bf-f335fc72f371/etc/network/interfaces and add:

allow-hotplug wlan0
iface wlan0 inet static
address 192.168.1.69
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 192.168.1.1
wpa-ssid your_ssid
wpa-psk your_password

Comment out the eth0 stuff. You can do it the hard way with the debug serial interface though if you want :) When I ordered my Duos I forgot to order the USB dongle, so I would have been out of luck otherwise. Boot up and configure the Duo the way you like, power off and wire up the display as follows:

VCC to either 5Vin or 3V3
GND to GND
SCL to SCL
SDA to SDA

Power up Duo and configure I2C:

  • sudo nano /boot/armbianEnv.txt and add i2c0 to overlays=
  • sudo apt-get install i2c-tools
  • sudo usermod -a -G i2c username (non-root user you created)
  • sudo i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- 3c -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

If you see the 3c on i2c0 then you are in business. Let's install Luma.OLED:

  • sudo apt-get install python-dev python-pip libfreetype6-dev libjpeg-dev
  • sudo -H pip install --upgrade pip
  • sudo apt-get purge python-pip
  • sudo -H pip install --upgrade pip setuptools
  • sudo -H pip install --upgrade luma.oled
  • sudo -H pip uninstall RPi.GPIO (this will not work on Duo and is not needed for I2C)

OK, let's create a simple demo program to make sure things are working nano i2chello.py:

import time
from luma.core.interface.serial import i2c
from luma.core.render import canvas
from luma.oled.device import ssd1306

serial = i2c(port=0, address=0x3C)
device = ssd1306(serial)

with canvas(device) as draw:
    draw.rectangle(device.bounding_box, outline="white")
    draw.text((3, 3), "Hello", fill="white")

time.sleep(10)

And you should see (screen shot from the Luma emulator):

 

5a4844734fa16_Screenshotfrom2017-12-3020-57-52.png.837f0fd1c591efd26931942379338cfc.png

 

Now we can install the Luma examples:

Let's run an example: sudo python examples/invaders.py -d ssd1306 --i2c-port 0 --i2c-address 0x3c

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines