Sunday, February 26, 2012

Digital Picture Frame as a router status display

A 320x240 cheap (2,90€ by digital picture frame attached to a router is a very useful addition to show router's status information. The DPF display driver is already integrated into the lcd4linux project that makes it easy to use the frame. This for example is how it works for me:


Some details regarding DPF hacking can be found here (the page is in German)
Although lcd4linux is a powerful tool I'm still looking for a way to build complex dynamic menu structures to be able to control MPD from my remote, i.g to be able to navigate visually through the MPD database and select items into the playlist. And it seems like the lcd4linux is not powerful enough to do such things. I'll add some additional notes if I find a solution.

Update: my lcd4linux.conf for this layout is here
Update2: the digit's font is Impact, 48 points
Update3: I was asked to add some info about weather parsing

Well, first of all I have a script that is called when WAN interface goes up:

root@Buffalo:~# cat /mnt/sd/bin/ 

ifconfig "$WANIFACE" &>/dev/null || exit 1

[ "$(date +%F%H)" != "$(date -r $WETTERFILE +%F%H 2>&1)" ] && {
  /mnt/sd/bin/ > "${WETTERFILE}.tmp" && \

/mnt/sd/bin/ >/tmp/tmpMail && mv /tmp/tmpMail /tmp/newMail

This script is also called each 10 minutes by a cron job. There's no need to check weather conditions each 10 minutes because it's updated only once per hour on the site. This is why is inside of a conditional clause. As far as redirection (">") in bash means that the target file is locked until command is finished I have to use mv command. Otherwise syslog is filled by lcd4linux warnings that file does not exist if it tries to access it in the same time.

The weather parsing script looks like this:

root@Buffalo:~# cat /mnt/sd/bin/ 

CITYID=242242       # My City WOEID
TUNITS=c            # c for cilsius, f for fahrenheit

windDirection ()
  awk -v deg=$1 'BEGIN { exit int((deg+11.25)/22.5)}'
  case $? in
    0|16) echo "N" ;;
    1) echo "NNE" ;; 
    2) echo "NE" ;;
    3) echo "ENE" ;;
    4) echo "E" ;;
    5) echo "ESE" ;;
    6) echo "SE" ;;
    7) echo "SSE" ;;
    8) echo "S" ;;
    9) echo "SSW" ;;
    10) echo "SW" ;;
    11) echo "WSW" ;;
    12) echo "W" ;;
    13) echo "WNW" ;;
    14) echo "NW" ;;
    15) echo "NNW" ;;

parseWeather ()
  if [ -s "$DATAFILE" ]; then
    local TEMPER=`sed -nr 's/.*yweather:condition.*temp="([^"]*?).*/\1/p' $DATAFILE`
    local WCODE=`sed -nr 's/.*yweather:condition.*code="([^"]*?).*/\1/p' $DATAFILE`
    local HUMID=`sed -nr 's/.*yweather:atmosphere.*humidity="([^"]*?).*/\1/p' $DATAFILE`
    local PRESS=`sed -nr 's/.*yweather:atmosphere.*pressure="([^"]*?).*/\1/p' $DATAFILE | awk '{ printf("%.0f", 0.75*$0) }'`
    local PRESRISE=`sed -nr 's/.*yweather:atmosphere.*rising="([^"]*?).*/\1/p' $DATAFILE`
    local WINDDIR=`sed -nr 's/.*yweather:wind.*direction="([^"]*?).*/\1/p' $DATAFILE`
    local WINDSPD=`sed -nr 's/.*yweather:wind.*speed="([^"]*?).*/\1/p' $DATAFILE | awk '{ printf("%.0f",$0) }'`
    local FORCAST=`sed -nr 's/.*yweather:forecast.*high="([^"]*).*code="([^"]*).*/\1\n\2/p' $DATAFILE`
    case $PRESRISE in
      0) PRESRISE='-';;
      1) PRESRISE='R';;
      2) PRESRISE='F';;
    echo -e "$TEMPER\n$(windDirection $WINDDIR)\n$WINDDIR\n$WINDSPD"

[ -n "$1" ] && CITYID=$1

wget -q -O "$DATAFILE" "$URL" && parseWeather

It's not very efficient but it doesn't have to be as far as I start it only once per hour.


Ed said...

Very nice layout of the screen. Can you please explain how you created the large font used for the clock? And how you included the weather icons?

alex said...

these are images actually. If you know the bounding box then you can use any graphics editor to type text into it until the font you use suits the best. Weather icons are also images. I'm using yahoo weather service to get weather information and they encode weather condition as a number from 1 to 47. I've downloaded a long image strip with icons from their site and split them into separate images using ImageMagic. The trick was that icons in that image strip are placed according to the weather numbering scheme they use. So now for example if I get weather condition 24 I simply display an icon '24.png'

Ed said...

Ah, ok. Thank you for explaining. I like it: food for thought. Good for a few hours of puzzling with lcd4linux.conf and other stuff.

Bert said...


nice to see. I have downloaded the images from yahoo. But they are not so nice as the images i see in your screenshot ( Can you make the images (weather and font) public please? Can you provide a link to them.


alex said...

Digits are here
I'm afraid I'm not allowed to distribute yahoo weather icons but you may try the following link
Just iterate from 0 to 48 in the image name.

Bert said...


Anonymous said...

I am also experimenting with lcd4linux (with my Raspberry Pi). Thank you for sharing your configuration. Would you mind sharing how you scrape weather conditions into your wetterParsed file? I'm currently just extracting the (text) forcast for my location from and having them in a better parsable format like you would be nice.

alex said...

I've updated the page with my weather parsing script

Requestor/a raspi LCD4linux user said...

Thanks, the script works like a charm.