Difference between revisions of "Blog 04"

From BitWizard Wiki
Jump to navigation Jump to search
Line 34: Line 34:




Code extra explanation:
( Reference to which display to use
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.






$DISPL -W 10:0:b
bytes


load
load

Revision as of 12:23, 16 September 2015

!BETA!

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.


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.




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. )

On Blog 05 I will print the temperature on the display.