Difference between revisions of "Blog 04"
|Line 1:||Line 1:|
== !BETA! ==
== !BETA! ==
Revision as of 12:44, 16 September 2015
In this blog, I am going to show how to make a clock including load averages visible on your RPi_UI board's display. The code I used is:
#!/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
/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
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:
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
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.
( when you turn it off and of by ctrl x and z it will also just come back to the right time. )
On Blog 05 I will print the temperature on the display.