You might recall some time ago I wrote about using Python on the Orange Pi Zero etc to run the little SSD1306-based displays.
Despite that being successful I did have a nagging doubt about the LUMA library because later on – when doing some apt-get upgrades I got a segmentation error which I’d originally attributed to using a hard disk with the device. I now think it might be something to do with that library. Well, when my NEO PLUS2 arrived I thought I’d try again..
WELL!!! This version works and also works with the NanoPi AIR AND the NEO2 using the standard Ubuntu image (and has solved my problem with the hard drive on the NEO2)...
I followed the instructions for loading up the Luma code… but missed out the line about installing LUMA as it had caused me problems on NEO2 boards in the past - segmentation errors and now just a point blank refusal to load up.
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 luma.oled
I replaced that last line with this – which also conveniently loads some other needed stuff like Pillow
sudo pip install --upgrade ssd1306
I'm reliably informed that the LUMA library is later than this - but for me right now - I've had no joy with it.
At this point I noted a comment about something being left around and so..
sudo apt-get autoremove
Of course my original example would fail as the luma libraries were not present - but amazingly all I had to do was replace three lines…
from oled.serial import i2c
from oled.device import ssd1306
from oled.render import canvas
These lines previously referred to the Luma library. with those changes everything worked for my little SSD1306 display other than the core temperature of the processor showing as being hotter than the sun… I put a suitable division into the code and I was up and running. I’ll put the full code below as apples now to the NEO PLUS2
I recalled I was using some font material from the LUMA examples – but as it turns out – all I needed was the one font which you’ll see I put in my /home/pi folder under fonts – I just grabbed the lot from the examples folder (NOT to be confused with the LUMA examples.
I ran the code- did an apt-get update and apt-get upgrade – no problems at all – so this is now part of my standard setup I’m using for the Neo Plus2. The code came from here (thank you) and there are a ton of examples to play with.
My little test program works as…
sudo python test2.py
if you want to leave it running and get on with something else… stick an ampersand on the end! You will see a number appear and you can use that with “sudo kill” to kill the process (probably not cleanly).
I have since ALSO tested this exact setup on the NANO AIR – with exactly the same successful results.
Update: you CAN install LUMA on a NEO2 which only has 512MB RAM by doing this...
sudo -H pip install --no-cache-dir --upgrade luma.oled
sudo -H pip install --upgrade pip setuptools
git clone https://github.com/rm-hull/luma.examples.git
sudo -H pip install -e .
An error referring to SDL-config appeared at the end of this... but seemed to have no ill effect.. I took my usual system display example, made sure the font referred to path /home/pi/luma.examples/examples/fonts - and ran it - no problem at all. If someone knows the meaning of that SDL stuff - and a fix? Let me know.
I did see this - https://stackoverflow.com/questions/19579528/pygame-installation-sdl-config-command-not-found and tried the compile there but that griped that it could not guess build type - and stopped! Oh, well.
You should know that LUMA is later than the SSD1306 code.. you were warned if you use the older (simpler) setup... I have the LUMA code running on a NEO2 but not tested it long enough to verify it won't cause the old segmentation issue I experienced in the past.
Incidentally for those who don't use Linux a lot - my little test program runs as "sudo python test2.py" - if you add a space then an ampersand to the end of that - it'll keep running in the background and return to the prompt to let you do other stuff.
I've also tested that latest version LUMA on a NEO PLUS2 successfully. Between this and the new Node-Red node for handling I2c... things are moving along nicely.