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.)
 
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
== !BETA! ==
== !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 putted in a script is:
Clock visible on machine:


#!/bin/bash
#!/bin/bash
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
$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.
bytes


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


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


nano timer
sh timer


To make script you have to do:
echo $PATH
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 )
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

./Clock
To run it. This gave a error.

You have to add
chmod +x timer
To make your command for running Clock.
Do:
sh mods.x^C
chmod +x timer
ls -l
ls -l
To look which commands are executable:


total 56
total 56
Line 59: Line 69:
drwxr-xr-x 5 pi pi 4096 Sep 3 10:27 bw_rpi_tools
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
drwxrwxr-x 2 pi pi 4096 Jan 27 2015 python_games
-rwxr-xr-x 1 root root 480 Sep 7 08:47 timer
-rwxr-xr-x 1 root root 480 Sep 7 08:47 Clock
drwxr-xr-x 9 pi pi 4096 Aug 31 14:04 wiringPi
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.
./timer

./Clock

[[File:RaspberryPiClock.png|400px|thumb|none|]]

If you also want the day, month and year to appear, you have to add %F:
date +%F:%H:%M:%S


== Change Time ==
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:
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.
to see the current time:

I changed the time manually.
To see the current time:
uname -a
uname -a
Linux seniorservix 3.18.11-v7+ #781 SMP PREEMPT Tue Apr 21 18:07:59 BST 2015 armv7l GNU/Linux
Linux seniorservix 3.18.11-v7+ #781 SMP PREEMPT Tue Apr 21 18:07:59 BST 2015 armv7l GNU/Linux


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


( always add a zero before a number than is under 10! so 8 = 08 )
( Always add a zero before a number than is under 10! so 8 = 08 )

So 12:13:14 7 september 2015 becomes:
Example of time:
12:13:14 7 september 2015 becomes:
090712132015.14
090712132015.14


To use it add date for it:
date 090711002015.00
date 090711002015.00
The terminal will print out:
Mon Sep 7 11:00:00 UTC 2015
Mon Sep 7 11:00:00 UTC 2015


Line 87: Line 111:
It directly printed the correct time that I gave.
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!
[[File:RaspberryPiClock.png|400px|thumb|left|]]




























On [[Blog 05]] I will print the temperature on the display.
( when you turn it off and of by ctrl x and z it will also just come back to the right time. )

Latest revision as of 16:52, 21 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 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 

To run it. This gave a error.

You have to add

chmod +x timer

To make your command for running Clock.

Do:

ls -l 

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
RaspberryPiClock.png

If you also want the day, month and year to appear, you have to add %F:

date +%F:%H:%M:%S

Change Time

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:

uname -a 

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:

date 090711002015.00 

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.