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 putted in a script 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.
Code extra explanation:
DISPL="bw_tool -I -D /dev/i2c-1 -a 94"
This code is made so you don't have a big mess of a code. The codes with $DISPL reference to this code. So instead of always typing bw_tool -I -D /dev/i2c-1 -a 94, he directly knows he has to use the one form DISPL, which is the same.
$DISPL -W 10:0:b
The -W 10:00 removes the previous text, and the :b is for doing it in bytes. This is not really needed but, with it you know for sure every command is going fine.
$DISPL -W 11:00:b
-W -11:00 is for defining on which line you want your text. That is for 11:00 the first line and with 11:20 the second line.
To make script you have to do: nano Clock ( You can change the name Clock also with something else. )
In the script you have to copy paste the code from above. ( Note: If you don't have a i2c-1 you of course have to use something else )
./Clock or sh Clock
To run it. This gave a error.
You have to add
chmod +x timer
To make your command for running Clock.
To look which commands are executable:
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 Clock drwxr-xr-x 9 pi pi 4096 Aug 31 14:04 wiringPi
If the x's are visible in your line you can use it.
./Clock or sh Clock
With my raspberry I 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
To Give the current date: month-day-hours-minutes – year . seconds
( Always add a zero before a number than is under 10! so 8 = 08 )
Example of time: 12:13:14 7 september 2015 becomes: 090712132015.14
To use it add date for it:
The terminal will print out: 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.
The Raspberry Pi will remember the time you gave it so don't be scared to turn off or reboot your Raspberry Pi!
On Blog 05 I will print the temperature on the display.