Jump to content

Recommended Posts

Posted

Today I swapped my old Neo2 against a Neo2 LTS 1GB in my NAS case - so I had a old Neo2 512MB free for the black Aluminum-OLED-case which I got in a drawer.

 

Now I did try to activate the OLED in 

ARMBIAN 5.67 user-built Debian GNU/Linux 9 (stretch) 4.19.4-sunxi64
Linux npi-neo2-27 4.19.4-sunxi64 #6 SMP Fri Nov 30 14:02:43 +03 2018 aarch64 GNU/Linux


First (like on a i2c-clock" I activated i2c0 in armbian-config:
 

root@npi-neo2-27(192.168.6.27):~# armbian-config
System --> Hardware --> [*] i2c0

After the reboot I checked for the i2c-OLED-device and got:
 

root@npi-neo2-27(192.168.6.27):~# apt install i2c-tools
root@npi-neo2-27(192.168.6.27):~# 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: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 

After some trial and error(-messages) I did found the following dependencies for compiling/installing the software for the OLED-Board:

apt-get install python-setuptools libjpeg-dev
Quote

https://pillow.readthedocs.io/en/latest/installation.html
There are scripts to install the dependencies for some operating systems included in the depends directory.
libjpeg provides JPEG functionality.
Starting with Pillow 3.0.0, libjpeg is required by default

 

After that I did the normal "5 Enable NanoHat-OLED manually" from
http://wiki.friendlyarm.com/wiki/index.php/NanoHat_OLED
with
 

root@npi-neo2-27(192.168.6.27):~# cd /home/guido
root@npi-neo2-27(192.168.6.27):~# git clone https://github.com/friendlyarm/NanoHatOLED.git
root@npi-neo2-27(192.168.6.27):~# cd NanoHatOLED
root@npi-neo2-27(192.168.6.27):~# ./install.sh

And after the next reboot the OLED-Display did work :)

Posted

Works perfect - sorting the dependency for pillow was the key....

 

Works fine with 5.65 stable for Neo2

 

:) 

 

Plays well with NanoPI NEO (the H3 version) as well.

 

Thx!

Posted

Here's a patch borrowed from WlanProfessionals - who distribute a custom Armbian build for the Neo2 kit that has some more focused wifi oriented tools

 

The patch enables a sleep timer for the OLED to keep it from burning in...

 

Note - you can change the splash screen image from the default friendlyelec.png to newlogo.png and comment/uncomment the lines in the python file...

 

--- bakebit_nanohat_oled.py	2018-12-20 14:25:03.604667813 -0800
+++ bakebit_nanohat_oled.py.orig	2018-12-20 12:33:59.592899367 -0800
@@ -54,20 +54,15 @@
 global pageCount
 pageCount=2
 global pageIndex
-pageIndex=1
+pageIndex=0
 global showPageIndicator
 showPageIndicator=False
 
-global pageSleep
-pageSleep=300
-global pageSleepCountdown
-pageSleepCountdown=pageSleep
-
 oled.init()  #initialze SEEED OLED display
 oled.setNormalDisplay()      #Set display to normal mode (i.e non-inverse mode)
 oled.setHorizontalMode()
 
-global drawing
+global drawing 
 drawing = False
 
 global image
@@ -76,7 +71,7 @@
 draw = ImageDraw.Draw(image)
 global fontb24
 fontb24 = ImageFont.truetype('DejaVuSansMono-Bold.ttf', 24);
-global font14
+global font14 
 font14 = ImageFont.truetype('DejaVuSansMono.ttf', 14);
 global smartFont
 smartFont = ImageFont.truetype('DejaVuSansMono-Bold.ttf', 10);
@@ -116,7 +111,6 @@
     global width
     global height
     global lock
-    global pageSleepCountdown
 
     lock.acquire()
     is_drawing = drawing
@@ -126,18 +120,11 @@
     if is_drawing:
         return
 
-    #if the countdown is zero we should be sleeping (blank the display to reduce screenburn)
-    if pageSleepCountdown == 0:
-        oled.clearDisplay()
-        return
-
-    pageSleepCountdown = pageSleepCountdown - 1
-
     lock.acquire()
     drawing = True
     lock.release()
-
-    # Draw a black filled box to clear the image.
+    
+    # Draw a black filled box to clear the image.            
     draw.rectangle((0,0,width,height), outline=0, fill=0)
     # Draw current page indicator
     if showPageIndicator:
@@ -231,10 +218,6 @@
 
 def receive_signal(signum, stack):
     global pageIndex
-    global pageSleepCountdown
-    global pageSleep
-
-    pageSleepCountdown = pageSleep #user pressed a button, reset the sleep counter
 
     lock.acquire()
     page_index = pageIndex
@@ -261,7 +244,7 @@
             if page_index==4:
                 update_page_index(5)
                 draw_page()
-
+ 
             else:
                 update_page_index(0)
                 draw_page()
@@ -280,7 +263,6 @@
 
 
 image0 = Image.open('friendllyelec.png').convert('1')
-#image0 = Image.open('newlogo.png').convert('1')
 oled.drawImage(image0)
 time.sleep(2)
 
@@ -315,7 +297,7 @@
             os.system('systemctl poweroff')
             break
         time.sleep(1)
-    except KeyboardInterrupt:
-        break
-    except IOError:
+    except KeyboardInterrupt:                                                                                                          
+        break                     
+    except IOError:                                                                              
         print ("Error")

 

Posted
10 hours ago, sfx2000 said:

The patch enables a sleep timer for the OLED to keep it from burning in...

Note -

you can change the splash screen image from the default friendlyelec.png to newlogo.png and comment/uncomment the lines in the python file...

How can I apply this patch? (or can you attach both versions of the file?)

 

My bakebit_nanohat_oled.py has the following filesize:

ls -l /home/guido/NanoHatOLED/BakeBit/Software/Python/bakebit_nanohat_oled.py
-rw-r--r-- 1 root root 9170 Dec 20 21:38 /home/guido/NanoHatOLED/BakeBit/Software/Python/bakebit_nanohat_oled.py

and they misspelled the .png with double "l"  :(

 

root@npi-neo2-27(192.168.6.27):/# find /home/guido/NanoHatOLED/ -name friendlly*
/home/guido/NanoHatOLED/BakeBit/Software/Python/friendllyelec.png

root@npi-neo2-27(192.168.6.27):/# find /home/guido/NanoHatOLED/ -name friendly*
root@npi-neo2-27(192.168.6.27):/#

 

As attachment I did try to create a armbian-logo for the OLED :)

 

 

armbian_oled.png

Posted
10 hours ago, guidol said:

How can I apply this patch? (or can you attach both versions of the file?)

 

Save the diff I posted about as bakebit_nanohat_oled.patch - then using patch, patch your corresponding file like this...

 

patch -b < bakebit_nanohat_oled.patch

 

This will patch the existing file, and create a back up of the original...

 

That should do it - then for your logo file - you'll see where to put the name of the logo file, and keep the logo in the same dir...

 

Then just run the install script, which will pick everything up and rebuild the nanohat oled

Posted
13 hours ago, sfx2000 said:

Save the diff I posted about as bakebit_nanohat_oled.patch - then using patch, patch your corresponding file like this...

patch -b < bakebit_nanohat_oled.patch

This will patch the existing file, and create a back up of the original...

Thanks for the information :)

Additionally I did found "this" patch also in the dietpi-forum:

[Tutorial] How to get your NanoHatOLED to work


For dietpi there are much more dependencies, because it claims to be smaller than armbian in the basic-configuration ;)

 

There are also the .zip files of the complete patch - in 2 versions - written by the user Phillski (see inside the spoiler)

Spoiler

[Tutorial] How to get your NanoHatOLED to work
https://dietpi.com/phpbb/viewtopic.php?t=3077

v1:

by Phillski » Tue Apr 17, 2018 12:33 pm

After running mine 24x7 for about a month I discovered that my little OLED screen had developed a nasty case of "screen burn" :shock: 
This inspired me to do a little hacking and make a few fixes.

Executing the following code will do two things:
1. Replace the default script with one that turns off the screen after five(ish) minutes (as soon as you click a button it will turn back on for another five minutes).
2. Replaces the boot image with a muuuch better one. <cough>dietpi logo</cough>

wget -O NanoHatOLED_v1.zip http://dietpi.com/phpbb/download/file.php?id=1033 && sudo unzip -o NanoHatOLED_v1.zip -d NanoHatOLED/BakeBit/Software/Python


v2:

Re: [Tutorial] How to get your NanoHatOLED to work
Post  by Phillski » Thu Aug 30, 2018 12:12 am

It will indeed work with the Neo2! (I'm using the 1st gen Neo2, looks like you will be using the 3rd gen with the silver case)

If you want to use my custom script that will avoid screen burn I've uploaded a new version that has a few changes
- retains the FriendlyElec logo on bootup (shows the DietPi logo after)
- turns off the screen after two minutes (old version was set to five minutes)
- has a better way of working out the IP (makes sure it grabs eth0 and not tun0 when using a VPN)
- uses 0% CPU when it has turned the screen off (the old script would use between 2-5%)

wget -O NanoHatOLED_v2.zip http://dietpi.com/phpbb/download/file.php?id=1101 && sudo unzip -o NanoHatOLED_v2.zip -d NanoHatOLED/BakeBit/Software/Python

 

for backup-reasons I will attach the 2 versions also here :)

 

I had only to extract the .zip above the NanHatOLED-Directory and reboot - no need for an additinally installation ;)

 

 

NanoHatOLED_v2_2Minutes_DietPi.zip

NanoHatOLED_v1_5Minutes_DietPi.zip

Posted
15 hours ago, guidol said:

Thanks for the information :)

Additionally I did found "this" patch also in the dietpi-forum:

[Tutorial] How to get your NanoHatOLED to work


For dietpi there are much more dependencies, because it claims to be smaller than armbian in the basic-configuration

 

Cool - now we possibly know who to attribute the actual script changes to - it was not attributed over at the WLAN PI distro...

 

I'm not on DietPI's group - but someone should encourage the author to do a pull request on FE's github, as it's obviously a good thing to include.

 

FWIW - on the stats screen, you can change the padding from "2" to "0", which brings the bottom line back onto the screen... (it prints a couple of pixels down)

 

    elif page_index==1:
        # Draw some shapes.
        # First define some constants to allow easy resizing of shapes.
        # padding = 2
        # FE's script draws off canvas here, so we remove the pad for this screen
        padding = 0
        top = padding
        bottom = height-padding
        # Move left to right keeping track of the current x position for drawing shapes.

 

Posted
4 hours ago, sfx2000 said:

FWIW - on the stats screen, you can change the padding from "2" to "0", which brings the bottom line back onto the screen... (it prints a couple of pixels down)

 

See below.... bump up two pixels on the canvas - so everything shows up - putting a bit of a load on things... openssl speed -multi 4

 

Next steps for me - move shutdown to reboot - as I have more than a couple of these in the field...

 

neo2_oled_tweaks.thumb.jpg.92beaf7777762992a5a9d2afe9afd95c.jpg

Posted
On 12/22/2018 at 6:52 PM, sfx2000 said:

Next steps for me - move shutdown to reboot - as I have more than a couple of these in the field...

 

easy enough for the script - I just changed shutdown to reboot... which the UI still shows "Shutdown Yes/No" for now, but I'll take care of that later...

#            os.system('systemctl poweroff')
            os.system('systemctl reboot')

Anyways - @guidol - here's my updated script, it's based on the V2 script you posted from the DietPI folks... fixed the padding, and the provision for the second logo/splash screen...

 

 

bakebit_nanohat_oled.py

Posted

Been a bit busy with other things - but I noted with more recent armbian updates that things stopped working on the OLED hat...

 

On my list of things to check out, but less than critical....

Posted

I did buy a 3th silver Neo2 NAScase, so I wouldnt use the black OLEDcase anymore.

OLED also has burnin from the time before the screensaver.

So OLED isnt critical for me anymore.

Posted
18 hours ago, stm said:

I've compiled a kernel with pretty much all i2c stuff enabled, don't think thats the issue. The deamon is running but the display is not working. 

Did you use the armbian-build-system for generating the image/kernel? :  https://github.com/armbian/build

This can be done in a VirtualBox or a unused real PC.
I think there you havent to activate much i2c stuff, but after booting activating i2c through the armbian-config and reboot.

 

For myself I disconnected the OLED-Screen and did put the Neo2 now in the silver NAS-Case from FriendlyARM ;)
and connected a LCD2USB-Display which can be used with LCD4Linux e.g. like 
USB port 1602 LCD Module for Pi (LCD2USB)
https://www.friendlyarm.com/index.php?route=product/product&amp;product_id=136

 

LCD2USB_front.jpg

LCD2USB_back.jpg

Posted

You could download & update the actual download: https://dl.armbian.com/nanopineo2/archive/Armbian_5.75_Nanopineo2_Debian_stretch_next_4.19.20.7z

I thin the i2c devices would be active after armbian-config for i2c0

 

before trying to compile the App for the hat check with

i2cdetect -y 0

if there is any i2c hardware displayed (see first message of this thread) then you could try to compile for the hat.
Did you read/use my first message in this thread and the information there?

 

Network-Manger is no problem....create the right configs in /etc/network/interfaces and /etc/resolv.conf - after that you could uninstall the Network-Manager and reboot

I did make for me a little documentation with some commands  (will add them later here) - the last will only work after a reboot because of the running services.

 

Manually check & configure these files:
/etc/network/interfaces
/etc/resolv.conf

sudo service network-manager stop
sudo update-rc.d NetworkManager remove
sudo apt remove network-manager -y
rm /etc/init.d/network-manager

reboot

after reboot:
find / -name NetworkManager* -exec rm -rf {} \;

 

So far every armbian-driven sbc at my home is now running without network-manager because - for me - the configuration via files is safer (copy&paste) and uses less memory.

I also didnt use these predictable network-interface-names... I like my interfaces named eth0 and wlan0 ;) but that is mostly on non armbian linux devices.

 

Binary & Percent-of-Day-Clock ;)

LCD2USB.jpg

Posted

On the current master I have some problems with python being killed. It says it ran out of memory but monitoring on another console with htop shows thats false, there's also something about writing to swap. But even with swap disabled it gets killed.

 

Anyone got an idea why python is being killed? It gets killed at the same point  99% every time. Tried different board and different sd card. No issues on my previous build using default kernel configuration. 

 

https://pastebin.com/raw/Fyg6BU1T

Posted
2 hours ago, sfx2000 said:

OMG - do I see a RasPi there?

LOL...

No :) do you see the heatsink? Its a NanoPi K1 Plus in a "original" RPI-case.
The NanoPi fits well and I got the case in the cupboard ;)
BUT from years ago (before armbian-useage) I also got some RPI's here (Pi1, Pi2, Pi3, Zero and ZeroW and a 1A+)

Posted

This stopped working a few builds back on Armbian...

 

I really have not had time to investigate, because work is keeping me fairly busy.

Posted
17 hours ago, sfx2000 said:

This stopped working a few builds back on Armbian...

 

I really have not had time to investigate, because work is keeping me fairly busy.


4.19.y or 5.3.y ?

Posted
16 hours ago, Igor said:

 

Spent some time to sort out things... not a kernel issue...

 

ended up being that systemctl rc.local.service was exiting based on a bad entry in rc.local that was calling dnsmasq as a systemd resource, and it failed.

 

Since the rc.local.service fails, oled-start doesn't run

 

Don't ask me how dnsmasq service ever got into my rc.local, along with an iptables-restore entry - as I don't recall...

 

Might have been when I was trying to help one of our forum members out with AP mode stuff...

 

I've never been the biggest fan of systemd - it is things like this where one can get nested items that make it hard to troubleshoot. 

 

 

Posted

If anybody is interested, I've got a single python script that works without needing to install any of the FriendlyElec software. Just enabled i2c0, python and a few dependencies.

 

You can find the code on: https://github.com/crouchingtigerhiddenadam/nano-hat-oled-armbian
The screen turns off after 15 seconds of inactivity to reduce burn-in, variable update rates, splash screen, date/time screen, computer stats screen and a shutdown screen.

Posted
On 4/13/2020 at 4:04 PM, crouchingtigerhiddenadam said:

If anybody is interested, I've got a single python script that works without needing to install any of the FriendlyElec software. Just enabled i2c0, python and a few dependencies.

 

You can find the code on: https://github.com/crouchingtigerhiddenadam/nano-hat-oled-armbian
The screen turns off after 15 seconds of inactivity to reduce burn-in, variable update rates, splash screen, date/time screen, computer stats screen and a shutdown screen.

Thank you for this!  Works great on my NanoPi NEO Black.  Will be updating a couple of Nano Pi NEO and NEO2 from FriendlyARM to Armbian using this also!

 

Ray

 

Posted

 

On 4/13/2020 at 11:04 PM, crouchingtigerhiddenadam said:

If anybody is interested, I've got a single python script that works without needing to install any of the FriendlyElec software. Just enabled i2c0, python and a few dependencies.

 

You can find the code on: https://github.com/crouchingtigerhiddenadam/nano-hat-oled-armbian
The screen turns off after 15 seconds of inactivity to reduce burn-in, variable update rates, splash screen, date/time screen, computer stats screen and a shutdown screen.

Thanks for your work !

I am using your script, slightly modified because the new Python 3.8 does not compile into pyo files anymore.

Also, I am using a systemd service instead.

Posted (edited)

Thank you for the feedback! Python 3 is a bit different. You can compile to pyc (which goes in the __pycache__  folder). I use a systemd service file on a C version of this program. I can upload a service file if you think it would help. What are your thoughts on Cython?

Edited by crouchingtigerhiddenadam

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines