Difference between revisions of "Blog 10"

From BitWizard WIKI
Jump to: navigation, search
(Push menu)
(Push menu)
Line 1: Line 1:
  
 
== Push menu ==
 
== Push menu ==
 +
 +
Hello, this time I am finally going to put together what I wanted.
 +
I am going to use previous scripts:
  
 
  1. Temperature  (From [[blog 05]])
 
  1. Temperature  (From [[blog 05]])
Line 9: Line 12:
 
  6. Defining Temperature ( not visible on display! ) (From [[blog 05]])
 
  6. Defining Temperature ( not visible on display! ) (From [[blog 05]])
  
I used previous codes, but I copied them in a new version.  
+
And put them all together in a push button menu that is controlled with pushbutton from the Rp_UI_display.
 +
So, I can show the information from the script and use the pushbuttons to control it.
 +
 
 +
I still modified the previous codes, but I copied them in a new version.  
 
Example:  
 
Example:  
 
  cp timer > time_load  
 
  cp timer > time_load  
  
You have to make the script get to the basic, so that it only prints.
+
I had to make the script to get to the basics, so that it only prints the information.
 
So things like this has to be removed:
 
So things like this has to be removed:
 
  while true
 
  while true
Line 19: Line 25:
 
  echo  
 
  echo  
 
  10:00/11:00
 
  10:00/11:00
 +
sleep
  
 
Note!
 
Note!
Line 83: Line 90:
 
  1. Temperature
 
  1. Temperature
 
  2. Time  
 
  2. Time  
  3. CPU +GPU
+
  3. CPU + GPU
 
  4. Temperature at weather station
 
  4. Temperature at weather station
 
  5. Wind at weather station  
 
  5. Wind at weather station  
Line 106: Line 113:
 
Press the number you want to know and press the button.
 
Press the number you want to know and press the button.
  
At the end it says it has to place on the line 11:00  
+
At the end it says it has to place on the line 11:00  
 
and with ./$print he that finally print the every second the one information from the button pressed.  
 
and with ./$print he that finally print the every second the one information from the button pressed.  
  
 
Thanks to the sleep you now have to wait a second to recognize the different button you pressed. Because it has to go trough that list again in that 1 sec.
 
Thanks to the sleep you now have to wait a second to recognize the different button you pressed. Because it has to go trough that list again in that 1 sec.
 
  
 
I hope this can also be useful for your own use.
 
I hope this can also be useful for your own use.

Revision as of 14:17, 24 September 2015

Push menu

Hello, this time I am finally going to put together what I wanted. I am going to use previous scripts:

1. Temperature  (From blog 05)
2. Time with load averages (From blog 04)
3. CPU + GPU (From blog 08)
4. Temperature at weather station (From blog 09) 
5. Wind a weather station (From blog 09) 
6. Defining Temperature ( not visible on display! ) (From blog 05)

And put them all together in a push button menu that is controlled with pushbutton from the Rp_UI_display. So, I can show the information from the script and use the pushbuttons to control it.

I still modified the previous codes, but I copied them in a new version. Example:

cp timer > time_load 

I had to make the script to get to the basics, so that it only prints the information. So things like this has to be removed:

while true
done
echo 
10:00/11:00
sleep

Note! You shouldn't delete 11:20, because the script from pushmenu isn't made to to also remove the second line. It only cleans first row with 11:00.

Example from the 'Time with load averages':

#!/bin/bash

DISPL="bw_tool -I -D /dev/i2c-1 -a 94"

       load=`cut -d' ' -f-3 /proc/loadavg`
       $DISPL -t `date +%H:%M:%S`
       $DISPL -W 11:20:b
       $DISPL -t $load
#!/bin/bash 

#Print=showtemp2
#Print=time_load
#Print=DIAMoscow2
#Print=cgpu2
#Print=DIAMWind
Print=ui
bw_tool -I -D /dev/i2c-1 -a 94 -w 10:00 

while true; do
  Button=`bw_tool -I -D /dev/i2c-1 -a 94 -R 30:b`
  
  if [ $Button  != "00" ]; then 
    bw_tool -I -D /dev/i2c-1 -a 94 -w 10:00
  fi

  if [ $Button  = "20" ]; then 
    Print=showtemp2
  fi  

  if [ $Button  = "10" ]; then 
    Print=time_load
  fi 

  if [ $Button  = "08" ]; then 
    Print=cgpu2
  fi

  if [ $Button  = "04" ]; then 
    Print=DIAMoscow
  fi

  if [ $Button  = "02" ]; then 
    Print=DIAMWind
  fi

  if [ $Button  = "01" ]; then 
    Print=ui
  fi

  bw_tool -I -D /dev/i2c-1 -a 94 -w 11:00
  ./$Print

  sleep 1
done

All the 6 buttons reference to 6 scripts:

1. Temperature
2. Time 
3. CPU + GPU
4. Temperature at weather station
5. Wind at weather station 
6. ui

The first list can delete the and only turn on 1 of them. If you remove it, it wouldn't be a problem on the display but a error. I found out this later, but left the others there because I thought maybe some people would like to start with an other one. It directly removes everything from display. (10:00)

First it will look if there is a button pressed. If there is no button pressed it will be 00 and then it will be just refresh the last one. When pressed it will directly remove the previous text. Because at the beginning it wil if not 00 is pressed with !=. So, it will directly remove the previous text when pressed.

Then it will start the while loop. ( while true; do) When started it will first look if it detects which button is pressed.

After that I made 6 if statements to check of that button is pressed. ( to detect which button gives which number:

bw_tool -I -D /dev/i2c-1 -a 94 -R 30:b
01

) Press the number you want to know and press the button.

At the end it says it has to place on the line 11:00 and with ./$print he that finally print the every second the one information from the button pressed.

Thanks to the sleep you now have to wait a second to recognize the different button you pressed. Because it has to go trough that list again in that 1 sec.

I hope this can also be useful for your own use.