Arduino mirror image, orientation problem with display MAX7219

How to use MAX7219 LED Matrix with Arduino

Good Libraries to use with the MAX7219 LED are:
https://github.com/MajicDesigns/MD_MAX72XX LED
https://github.com/MajicDesigns/MD_Parola Scrolling

You’ll find lot’s of examples after you install the libraries in the Arduino IDE.

Arduino mirror image, orientation problem with display MAX7219

How to solve problem with the LED matrix MAX7219 and the MD_MAX72xx.h Library

If you have problems with mirroring and/or orientation find following line and try following solutions:

#define HARDWARE_TYPE MD_MAX72XX::FC16_HW

or

#define HARDWARE_TYPE MD_MAX72XX::PAROLA_HW

or

#define HARDWARE_TYPE MD_MAX72XX::GENERIC_HW

or

#define HARDWARE_TYPE MD_MAX72XX::ICSTATION_HW

Raspberry pi & waveshare 2.7 e-ink Display & python

Here’s some example python code for drawing text horizontal on the waveshare e-ink display. You’ll find also a example where to find the length of text where to break lines. This examples reads some small text from a web site and looks up a rss feed for the weather.

Install the fonts https://www.raspberrypi.org/forums/viewtopic.php?t=133772

Install libraries https://www.waveshare.com/wiki/Pioneer600#Libraries_Installation_for_RPi


# coding: utf8
##
 #  width 176
 #  height 264
 ##

import epd2in7
from PIL import Image
import ImageFont
from PIL import ImageDraw
import time
import urllib2
import feedparser
import datetime

def getLengthText(myTextInput, myFont, pixels):
    #font = ImageFont.truetype('/usr/share/fonts/truetype/freefont/msttcorefonts/comic.ttf', 28)
    #font = ImageFont.truetype("arial", 20)
    myText = myTextInput
    mlen = 0
    mlen = len(myText)
    w, h = myFont.getsize(myText)
    while pixels < w:
        myText = myText[0:mlen-2]
        mlen = len(myText)
        w, h = myFont.getsize(myText)
    return mlen

def addText(myImage,myText, myFont, xx,yy):
    #font = ImageFont.truetype('/usr/share/fonts/truetype/freefont/msttcorefonts/comic.ttf', 28)
    #font = ImageFont.truetype("arial", 20)
    w, h = myFont.getsize(myText)
    mask = Image.new('1', (w, h), 255)
    draw2 = ImageDraw.Draw(mask)
    draw2.text((0, 0), myText, font = myFont, fill = 0)
    mask = mask.rotate(90, expand=True)
    myImage.paste(mask, (xx,epd2in7.EPD_HEIGHT - w - yy ))

def main():
    epd = epd2in7.EPD()
    epd.init()

    image = Image.new('1', (epd2in7.EPD_WIDTH, epd2in7.EPD_HEIGHT), 255)    # 255: clear the image with white
    draw = ImageDraw.Draw(image)
    
    font = ImageFont.truetype("arial", 20)
    font2 = ImageFont.truetype("comic", 24)
    font3 = ImageFont.truetype("arial", 28)

    # get text from a feed
    #d = feedparser.parse('http://www.reddit.com/r/news/.rss')
    d = feedparser.parse('https://www.br.de/wetter/action/feeds/bayernwetter.do')
    dnr = 0
    dlen = len(d['entries'])
    #test
    oberbayern = 0
    for n in range(dlen):
        actentry = d['entries'][n]['title'].encode('utf-8').strip()
        print str(n) + " " + actentry[0:8]
        if actentry[0:8] == "Oberbaye":
            oberbayern = n
        #münchen
        if actentry[0:8] == "München":
            muenchen = n
    
    
    print d['entries'][oberbayern]['title'].encode('utf-8').strip()
    print d['entries'][muenchen]['title'].encode('utf-8').strip()
    nb = d['entries'][oberbayern]['title'].strip()
    
    # get text from a website
    ttext = "ghjk"
    try:
            response = urllib2.urlopen('http://4johannes.de/weather/lowest.txt')
            ttext = response.read().strip()
            print(ttext)
    except:
            print("fehler2")

    # add to display

    # first Line
    grad = u'°'
    #entlang umgerechnet oben 1,1 nach 1,264/2
    draw.line((0, 264, 0, 0), fill = 0)
    draw.line((1, 264, 1, 0), fill = 0)
    addText(image, datetime.datetime.now().strftime("%H:%M %d.%m."), font3, 5, 6)
    addText(image, ttext + grad, font3, 5, 182)
    draw.line((42, 264, 42, 0), fill = 0)
    draw.line((43, 264, 43, 0), fill = 0)
    # senkrechte Linien, wenn quer gesehen
    draw.line((0, 264-180+5, 43, 264-180+5), fill = 0)
    draw.line((0, 264-180+4, 43, 264-180+4), fill = 0)
    draw.line((0, 263, 43, 263), fill = 0)
    draw.line((0, 262, 43, 262), fill = 0)

    draw.line((0, 0, 43, 0), fill = 0)
    draw.line((0, 1, 43, 1), fill = 0)


    muc = "München"
    mstr = d['entries'][muenchen]['title'].strip()
    mstr2 = mstr[mstr.find("):")+3:]
    addText(image, mstr2, font, 50, 0)
    #addText(image, "012345678901234567890123456789", font, 120, 0)
    print(nb.encode('utf-8'))
    xlen = 0
    xlen = getLengthText(nb,font, 264)
    nb1 = nb[0:xlen]
    nbRest = nb[xlen:]
    xlen = getLengthText(nbRest,font, 264)
    nb2 = nbRest[0:xlen]
    nbRest = nbRest[xlen:]
    xlen = getLengthText(nbRest,font, 264)
    nb3 = nbRest[0:xlen]
    nbRest = nbRest[xlen:]
    xlen = getLengthText(nbRest,font, 264)
    nb4 = nbRest[0:xlen]
    nbRest = nbRest[xlen:]
    xlen = getLengthText(nbRest,font, 264)
    nb5 = nbRest[0:xlen]
    
    print(nb1.encode('utf-8'))
    print(nb2.encode('utf-8'))
    print(nb3.encode('utf-8'))
    print(nb4.encode('utf-8'))
    print(nb5.encode('utf-8'))
    addText(image, nb1, font, 80, 0)
    addText(image, nb2, font, 100, 0)
    addText(image, nb3, font, 120, 0)
    addText(image, nb4, font, 140, 0)
    addText(image, nb5, font, 140, 0)


    epd.display_frame(epd.get_frame_buffer(image))
    # display images
    #epd.display_frame(epd.get_frame_buffer(Image.open('demopill2.bmp')))

if __name__ == '__main__':
    main()



Raspberry Pi as NAS with OpenMediaVault and Wifi

Be warned, the Raspberry Pi with wlan is a slow nas. But I wanted to build one and there are no full instructions for it. So here are the steps to follow.

I used this instruction, but some things are missing and so I put everything down in short form:

Download the OMV Image here.

Use Etcher to flash it on SD card.

Insert card into raspberry, connect network cable. Wait (!) not only wait for the first time login, wait.. Raspberry upgrades in the background. Just do nothing(!) and wait more. About 10 to 40 min till the raspberry reboots again!

Now, login for the first time as root. Change Password.
Change Keyboard Layout if you don’t use english one:

dpkg-reconfigure keyboard-configurationcheck if your Wifi works:

ifconfig -aDo you see your wlan? If not, start at top.

Add your wifi with:

nmtui-connectagain:
ifconfig -aNow it could be a good idea to tell the router to fix the ip addresses.
sudo shutdown now
remove power
connect USB-Sticks, Harddisks, whatever. Be aware to use HD (also the 2,5) with their own Power(!).

Repower your raspberry.

And now first time to go to the OMV Web Interface.
Point your browser to one of the ip addresses.
Login admin/openmediavault

“System”
Change Password and Hostname in “System”

“Storage”
Format (Physical disks) then add Disk (file systems) in “Storage”
Select and Mount your Disk (file systems).

“Access Right Management”
Add a user in “Access Right Management”.
Add folder(s) in “Access Right Management”.
In “shared folders” mark folder and “give privileges” to your user.

“Services”
“Settings” -> Enable in “SMB/CIFS”
“Shares” -> add your folder


OK, now it’s the time to test your new nas. Go to your PC or Mac (smb://…your..ip…) and give it a try.

Raspberry Pi, OpenMediaVault, NAS, Wifi, WLAN, error

Pokémon GO Plus, Verbindung verloren

Dein Pokémon GO Plus funktioniert nicht mehr bzw. hat die Verbindung verloren? Das musste ich selber rausbekommen: Wenn man das Pokémon GO Plus zum ersten mal verbunden hat, findet man das Symbol im Kartenbildschirm. Was ich nirgends beschrieben fand: Ist das Symbol rot, ist alles ok. Ist es grau, wurde die Verbindung verloren. Was ist zu tun: Einfach auf das Symbol tippen und der Anleitung folgen, d.h nach dem Tippen den Knopf auf dem Pokémon GO Plus drücken. Danach solte es wieder verbinden. Bei mir tritt das öfters auf ..


Pokémon GO Plus, funktioniert nicht, Ärger, wie man wiederverbindet

Pokémon GO Plus, lost connection

Your Pokémon GO Plus doesn’t work anymore or lost connection? Had to figure this out by myself: After connection (found in instructions) you’ll find the Pokémon GO Plus Symbol in the map screen. Now: If it’s red, your Pokémon GO Plus is connected and works. If it is like greyed out, you lost connection. What to do? Tap on the Pokémon GO Plus Symbol in the map screen. You’ll receive instruction to push button on the Pokémon GO Plus. Voilà, it’s working again.


Pokémon GO Plus, not working, trouble, how to reconnect

Vodafone Kabel Receiver – kein Ton

Mein Vodafone Kabel Sagem Modem liefert keinen Ton mehr. Reboot half nicht. Was letztendlich half: Im Receiver-Menu, Ton, HDMI Dolby ausschalten.

Beim nächsten Auftreten half: Im obigen Menu hin und her, dann aus schalten. Und dann ein Reboot (vom Strom trennen).

Update: Tritt immer mal wieder auf. Zurzeit hilft, ausschalten, vom Strom trennen, und dann wieder vonv orne.

Suchbegriffe: Vodafone Kabel Ton geht nicht

A Dockerfile for Oracle and perl

I didn’f find a dockerfile for oracle and perl. So I did one by myself.

Quick Instructions: Create dir; Create Dockerfile (above); create oracle_test.pl (above), download the oracle files.

Build it:

docker build -t perl-oracle .

Run it:

docker run -it --rm perl-oracle

I took http://www.ecliptik.com/Containerizing-a-Perl-Script/ as the base and added the information from here: http://www.aboutmonitoring.com/install-dbd-oracle-perl-modules-in-linux/ . To get the 3 Oracle files, you need an Oracle Account and download manualy and put it in your directory.

Your directory should look like this is:

$ ls
Dockerfile
oracle-instantclient12.2-basic-12.2.0.1.0-1.x86_64.rpm
oracle-instantclient12.2-devel-12.2.0.1.0-1.x86_64.rpm
oracle-instantclient12.2-sqlplus-12.2.0.1.0-1.x86_64.rpm
oracle_test.pl*

with the Dockerfile:

FROM ubuntu:14.04
MAINTAINER Micheal Waltz <ecliptik@gmail.com>
# see http://www.ecliptik.com/Containerizing-a-Perl-Script/

# Dockerfile by Johannes Eiseler 6/2017
# 
# How to build:
# docker build -t perl-oracle .

# How to run:
# docker run -it --rm perl-oracle
# docker run -v /c/Users/myuser/directory/you/like/to/share:/host/directory -it --rm perl-oracle

ENV DEBIAN_FRONTEND=noninteractive LANG=en_US.UTF-8 LC_ALL=C.UTF-8 LANGUAGE=en_US.UTF-8

RUN [ "apt-get", "-q", "update" ]
RUN [ "apt-get", "-qy", "--force-yes", "upgrade" ]
RUN [ "apt-get", "-qy", "--force-yes", "dist-upgrade" ]
RUN [ "apt-get", "install", "-qy", "--force-yes", \
      "perl", \
      "build-essential", \
      "cpanminus" ]
RUN [ "apt-get", "clean" ]
RUN [ "rm", "-rf", "/var/lib/apt/lists/*", "/tmp/*", "/var/tmp/*" ]

#RUN ["cpanm", "Proc::ProcessTable", "Data::Dumper" ]

COPY [ "./oracle_test.pl", "/app/oracle_test.pl" ]
RUN [ "chmod", "+x",  "/app/oracle_test.pl" ]

# now Oracle
# see http://www.aboutmonitoring.com/install-dbd-oracle-perl-modules-in-linux/

COPY [ "./*.rpm", "/app/" ]

WORKDIR /app
RUN ["apt-get", "update"]
RUN ["apt-get", "install", "libaio-dev", "libaio1" ]
RUN ["apt-get", "install", "-qy", "--force-yes", "alien" ]

RUN alien --scripts /app/oracle-instantclient12.2-basic-12.2.0.1.0-1.x86_64.rpm
RUN alien --scripts /app/oracle-instantclient12.2-devel-12.2.0.1.0-1.x86_64.rpm
RUN alien --scripts /app/oracle-instantclient12.2-sqlplus-12.2.0.1.0-1.x86_64.rpm

RUN dpkg -i /app/oracle-instantclient12.2-basic_12.2.0.1.0-2_amd64.deb
RUN dpkg -i /app/oracle-instantclient12.2-devel_12.2.0.1.0-2_amd64.deb
RUN dpkg -i /app/oracle-instantclient12.2-sqlplus_12.2.0.1.0-2_amd64.deb

ENV PATH $PATH:$HOME/bin:/usr/lib/oracle/12.2/client64/bin
ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/usr/lib/oracle/12.2/client64/lib
ENV ORACLE_HOME /usr/lib/oracle/12.2/client64/lib
ENV TNS_ADMIN $ORACLE_HOME/network/admin

# now perl oracle
RUN ["apt-get", "install", "-qy", "--force-yes", "libdbi-perl" ]
RUN ["cpan", "DBD::Oracle"]

# if you wan't to use it interactivly comment the next line
ENTRYPOINT [ "/app/oracle_test.pl" ]

And the perl script oracle_test.pl:

#!/usr/bin/perl

use strict;
use DBI;

#Take Env Variable
my $workdir = $ENV{'MYWORKINGDIR'};  #Takes the variables

print "Hello World\n";

#database

my $db = DBI->connect("dbi:Oracle:host=your.database.host;sid=yoursid;port=yourport","youruser/yourpassword", "") || die( $DBI::errstr . "\n" );

$db->{AutoCommit}    = 0;
$db->{RaiseError}    = 1;
$db->{ora_check_sql} = 0;
$db->{RowCacheSize}  = 16;

my $SEL = "SELECT * FROM dual";
my $sth = $db->prepare($SEL);
$sth->execute();
 
while ( my @row = $sth->fetchrow_array() ) {
    foreach (@row) {
        $_ = "\t" if !defined($_);
        print "$_\t";
    }
    print "\n";
}
 
END {
    $db->disconnect if defined($db);
}


print "----- End of perl file ------\n"

Keywords: Dockerfile, Oracle, Perl, Running perl script connect to oracle

Aluminum Bike Phone Holder – short Test

I recently bought Banggood: GUB G-86 CNC Aluminum Alloy Bicycle Bike Phone Holder Handbar…. (Or see below for Amazon). I had 3 rides since I mounted it on my cross bike, and my opinion till now is, that it is the best phone holder, which I ever had. Had a few problems by mounting it on my handle bar, but fixed that after 3 tries (see photo). I own a iPhone 6, having placed it in a case. The claws (don’t forget to use adhesive patches) hold it perfect, and it takes really just a part of the time to fix it than with the other holders before. – I recommend it

 

Wie man den Nivea Sun Kids Schutz und Pflege Roller nachfüllt

Wie man den Nivea Sun Kids Schutz und Pflege Roller nachfüllt.
Das Eincremen von Kindern (und einem selbst) ist eine notwendige Pflicht, die zumindest ich so einfach wie möglich machen will. Letztes Jahr entdeckte ich den Nivea Sonnencrème Roller. Ich war angetan, allerdings nicht vom Preis. Da just einer leer wurde, versuchte ich mich im Nachfüllen, wie schon bei den Seifenspendern. Um es kurz machen: Es war relativ mühsam, da ich zuerst ein Schraubgewinde erwartete. Es ist aber so, dass der “Kopf” auf den Behälter gesteckt ist. Letztendlich ging es folgendermaßen: Flasche in den Schraubstock, etwas Küchenpapier zum Schutz. Dann mit meiner größten Rohrzange den Kopf abziehen. Nachgefüllt habe ich mit der Rossmann Eigenmarke. Ob der Schmierkoeffizient passt und der Roller dicht bleibt, werde ich einem Update berichten.

Update: Von den Kindern heute getestet: “Works like a charm”