Difference between revisions of "Blog 04"

From BitWizard Wiki
Jump to navigation Jump to search
(in this text harry explains how to get the raspberry user interface show how late it is.)
(No difference)

Revision as of 13:40, 11 September 2015

!BETA!

Clock visible on machine:

#!/bin/bash

# What display to use: 
DISPL="bw_tool -I -D /dev/i2c-1 -a 94"
# e.g. for SPI use: 
#DISPL="bw_tool -D /dev/spidev1.0 -a 94"

#clean the display
$DISPL -W 10:0:b

while true; do
       #get cpu loads
       load=`cut -d' ' -f-3 /proc/loadavg`
   
       #print the current time 
       $DISPL -W 11:00:b
       $DISPL -t `date +%H:%M:%S`

       #print the load averages
       $DISPL -W 11:20:b
       $DISPL -t $load

       #idle for 5 seconds
       sleep 5
done


Code used from the User Interface page.


( Reference to which display to use

$DISPL -W 10:0:b bytes

load ) ( use ctrl c to get out of the code ) ( ctrl z to let the code continue )


nano timer 
sh timer 
echo $PATH 
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin 

sh mods.x^C 
chmod +x timer 
ls -l 
total 56 
-rw-r--r-- 1 root root     0 Sep  3 14:10 _ 
drwxr-xr-x 5 pi   pi    4096 Sep  3 10:27 bw_rpi_tools 
drwxrwxr-x 2 pi   pi    4096 Jan 27  2015 python_games 
-rwxr-xr-x 1 root root   480 Sep  7 08:47 timer 
drwxr-xr-x 9 pi   pi    4096 Aug 31 14:04 wiringPi 
./timer 

With my raspberry I sadly had the problem that it was 2 hours earlier in time. So, I had to change it to the correct current time.

I changed the time manually: to see the current time:

uname -a 

Linux seniorservix 3.18.11-v7+ #781 SMP PREEMPT Tue Apr 21 18:07:59 BST 2015 armv7l GNU/Linux

Give the current date: month-day-hours-minutes – year . seconds

( always add a zero before a number than is under 10! so 8 = 08 ) So 12:13:14 7 september 2015 becomes: 090712132015.14

date 090711002015.00 

Mon Sep 7 11:00:00 UTC 2015

At this point the original time was still visible on the screen. So I removed it from the screen and printed it out again.

bw_tool -I -D /dev/i2c-1 -a 94 -w 10:00 
./timer 

It directly printed the correct time that I gave.

RaspberryPiClock.png














( when you turn it off and of by ctrl x and z it will also just come back to the right time. )