some basic ascii-art
pwr rst 2 4...
| | [:::::::::::...]
/1\ 3...
[wan][lan0][lan1]...
arrow is where the 1 stands here
some basic ascii-art
pwr rst 2 4...
| | [:::::::::::...]
/1\ 3...
[wan][lan0][lan1]...
arrow is where the 1 stands here
Thanks for helping a blind person!
EDIT: Got it working for me, too! Thanks!
Great! Which ic2 bus are you using? What infos displays your screen?
VCC is on pin 1, GCC is on pin 9, SDA on pin 27 and SCL on pin 28. I’m customizing my display to show the statuses in stats.py using pure Python (no shell calls), plus icons on whether certain services are up…
I wrote the script, then the router rebooted during a file write and lost it. In the progress of rewriting the script… Can publish on GitHub when ready…
UPDATE: My code is available at my GitHub repository. Hope this helps somebody…
UPDATE 2: Updated code and picture used. No real documentation yet…
I’ve just downloaded! Great job, thanks for sharing!
UPDATE: I’ve added a README to the repo, primarily to add install directions to the repo. After all, what good is a repo if nobody knows how to install it? Also gonna see about making a Docker container for this repo, as adding compilation tools into an image probably isn’t the brightest of ideas…
Thanks some little notes:
libwebp-dev tcl8.6-dev tk8.6-dev python-tk
? Last3 imho are gui-libs,first is a -dev usally used for compiling own appsSource: Pillow Installation Instructions
I just posted why I was told was needed to build the Python Pillow package. I’ll see if I can trim the package “requirements” down a bit later today…
does it need building (then i guess gcc/cpp ais also needed)? is there no binary package? building-tools on router is a huge security hole
Maybe this is the right way:
Most major Linux distributions, including Fedora, Debian/Ubuntu and ArchLinux also include Pillow in packages that previously contained PIL e.g.
python-imaging
https://pillow.readthedocs.io/en/stable/installation.html
For python3 this needs to be installed. https://packages.debian.org/buster/python3-pil
Tested with basic-script from https://zetcode.com/python/pillow/
I guess Adafruit_GPIO is also not needed as it is only imported for spi as far as i see
in your call to getIP-Address you use “wan” instead of the variable wan_interface. so in case wan_interface is set to anything else, either an exception is thrown (if interface does not exist like on my laptop) or the wrong ip is printed (if there is any)
get_ip_address(wan_interface)
i change the script locally a bit, to generate text (for printing it out) instead of printing to display…so i can catch the data, print it to cli for external debugging…if display is enabled the image is generated (not finished yet)
forked your repo and change these 2 little things: https://github.com/frank-w/bpi-r2-ssd1306-display
have also uploaded reworked version, works without display…still waiting for my display to arrive
Wow… These changes are quite interesting! Care to create a Pull request?
Cannot test on real display and currently disabled icons (to make it easier to run code without icons).i guess furumc and i need smaller icons because we have (i have ordered) 2 color displays. And it looks like yellow is ~16px top and blue 3/4 below
Try here for monochrome icons: flaticon.com. I’ve already selected icons and black-filled filters to aid your process. All you have to do is find the icon(s) you want. They will allow you to select the size of icon you want to download.
is there an easy way to reduce colors (1 bit) and invert them (make black to white)?
you have already white icons, but all i’ve found are black…
icons16.zip (3,0 KB)
i think i got it solved using pillow based on https://note.nkmk.me/en/python-pillow-invert/:
def loadinvert(f):
iconpath = os.path.dirname(__file__)
im = Image.open(iconpath+"/"+f).convert('RGB')
return ImageOps.invert(im).convert('1')
globe = loadinvert('earth16.png')
this works for my earth-icon but not for wifi/phone
wifi works if i first convert to 1bit, then to rgb, then invert, but phone still shows only a white square. Seems like i need to change it manually
Maybe this page has an answer: How to invert colors of image with PIL (Python-Imaging)?
Personally, I used GIMP to invert the colors before saving them to PNG. Having that functionality in Python would be great… My router image doesn’t have the script installed, so I can’t test at the moment.
EDIT: I don’t think that you should convert to RGB at any point during this process… I could be mistaken, though…
i had problems with the phone-icon also in other editors (e.g. gnome-paint). have now also used gimp (need to redraw the globe completely)
icons-white.zip (7,8 KB)
Btw. Convert to rgb was necessary for the invert…see link above
i have uploaded my last version, maybe you can try on your display as i still waiting for it
simply uncomment
use_disp=True
currently working on voip-detection which is a bit tricky because r2 only moves traffic from ppp-interface to a external Voip-adapter. so i need to count sip-packets with an iptables rule, log it every 5 min to a file, read last 2 values from this file and calc difference…if this (packets in last full 5min block) is >0 (or maybe more) then i expect, the voip-adapter is logged in
i do this check after some basic checks like
ip link sh ppp9 | grep ,UP, >/dev/null;echo $? #check state of voip-interface
ping -c 1 192.168.0.8 >/dev/null;echo $? #check if voip-adapter is reachable
ip rule show | grep voip >/dev/null;echo $? #check if rule is set
ip route show | grep ppp9 >/dev/null;echo $? #check routing table for voip interface
slightly modified:
ip link sh ppp9 | grep ,UP, >/dev/null;u=$?
ping -c 1 192.168.0.8 >/dev/null;p=$?
ip rule show | grep voip >/dev/null;ru=$?
ip route show | grep ppp9 >/dev/null;ro=$?
res=$(($u + $p<<8 + $ru<<16 + $ro<<24)) #shifting each result 8bits (return value can be 255 max)
if [[ $res -eq 0 ]];then echo "all ok";fi
traffic-monitoring (in case anyone will do something similar):
#rules to monitor traffic
${ipt} -N voip1
${ipt} -N voip2
${ipt} -A FORWARD -s 192.168.0.8 -p udp --dport 5160 -j voip1
${ipt} -A FORWARD -d 192.168.0.8 -p udp --dport 5160 -j voip1
${ipt} -A FORWARD -s 192.168.0.8 -p udp --sport 5161 -j voip2
${ipt} -A FORWARD -d 192.168.0.8 -p udp --dport 5161 -j voip2
${ipt} -A voip1 -j ACCEPT
${ipt} -A voip2 -j ACCEPT
#read out (cronjob every 5 min)
iptables-legacy -L voip1 -v -nx | grep 'ACCEPT' | awk '{print $1}' >>$logdir/voip1.log
iptables-legacy -L voip2 -v -nx | grep 'ACCEPT' | awk '{print $1}' >>$logdir/voip2.log
#calculate difference (actually i have 40 packets on voip1 and 20packets on voip2, don't know why it is the half...)
bash -c 'str=$(tail -2 /var/log/voip1.log);ar=($str);res=$(( ${ar[1]} - ${ar[0]} ));echo $res'
I tried to rebase my changes on your latest state (i hope i have not break anything) and created pull request.
@furumc can you retest with pr branch in my repo?
I will do it! Which pr branch do you mean?
Strange it is not shown in dropdown on github…