Difference between revisions of "Blog 13"

From BitWizard WIKI
Jump to: navigation, search
(Scroll Menu)
(Scroll Menu)
Line 30: Line 30:
 
For this I used 2 names of previous scripts and 10 other random names.  
 
For this I used 2 names of previous scripts and 10 other random names.  
  
  Barray=( "Temp Menu" "Alarm Menu" Settings "Board menu" "Fries Menu" "Banana Menu" "vega burger" "wc menu" Bananaphone "2001:ABC" "ghost server" "My  name is...")
+
  Narray=( "Temp Menu" "Alarm Menu" Settings "Board menu" "Fries Menu" "Banana Menu" "vega burger" "wc menu" Bananaphone "2001:ABC" "ghost server" "My  name is...")
 
  # Element 0          1          2        3            4            5            6            7        8            9          10            11
 
  # Element 0          1          2        3            4            5            6            7        8            9          10            11
  
This is the second script and I called it Barray. ( You can of course call it what ever you want )  
+
This is the second script and I called it Narray. (Names Array. You can of course call it what ever you want )  
 
This array I made to print this text out. As you can see some of them don't use quotation marks.  
 
This array I made to print this text out. As you can see some of them don't use quotation marks.  
 
I only did that to say that you only really need to put them if you want to print a text with a space in it.  
 
I only did that to say that you only really need to put them if you want to print a text with a space in it.  
 
And also here I gave the other 10 random names.  
 
And also here I gave the other 10 random names.  
  
  if [ $HENK = "20" ]; then
+
  if [ $BDetect = "20" ]; then
 
     ./${array[$Number]}
 
     ./${array[$Number]}
 
  fi
 
  fi
  
  if [ $HENK = "10" ]; then
+
  if [ $BDetect = "10" ]; then
 
   ./${array[$Numb2]}
 
   ./${array[$Numb2]}
 
  fi
 
  fi
Line 55: Line 55:
 
   
 
   
 
  while true; do
 
  while true; do
  HENK=`bw_tool -I -D /dev/i2c-1 -a 94 -R 30:b`
+
  BDetect=`bw_tool -I -D /dev/i2c-1 -a 94 -R 30:b`
 
   
 
   
 
  array=( pushmenu2 AlarmMenu Jaap Tim Martin Koos Willem Bas Luuk Richard Nick Alex)
 
  array=( pushmenu2 AlarmMenu Jaap Tim Martin Koos Willem Bas Luuk Richard Nick Alex)
 
  # Element 0      1        2    3  4      5    6      7  8    9      10  11
 
  # Element 0      1        2    3  4      5    6      7  8    9      10  11
 
   
 
   
  Barray=( "Temp Menu" "Alarm Menu" Settings "Board menu" "Fries Menu" "Banana Menu" "vega burger" "wc menu" Bananaphone "2001:ABC" "ghost server" "My  name is...")
+
  Narray=( "Temp Menu" "Alarm Menu" Settings "Board menu" "Fries Menu" "Banana Menu" "vega burger" "wc menu" Bananaphone "2001:ABC" "ghost server" "My  name is...")
 
  # Element 0          1          2        3            4            5            6            7        8            9          10            11
 
  # Element 0          1          2        3            4            5            6            7        8            9          10            11
 
   
 
   
   if [ $HENK != "00" ]; then
+
   if [ $BDetect != "00" ]; then
 
     bw_tool -I -D /dev/i2c-1 -a 94 -W 10:00
 
     bw_tool -I -D /dev/i2c-1 -a 94 -W 10:00
 
   fi
 
   fi
 
   
 
   
   if [ $HENK = "20" ]; then
+
   if [ $BDetect = "20" ]; then
 
     ./${array[$Number]}
 
     ./${array[$Number]}
 
   fi
 
   fi
 
   
 
   
   if [ $HENK = "10" ]; then
+
   if [ $BDetect = "10" ]; then
 
     ./${array[$Numb2]}
 
     ./${array[$Numb2]}
 
   fi
 
   fi
 
   
 
   
   if [ $HENK = "08" ]; then
+
   if [ $BDetect = "08" ]; then
 
     Number=0
 
     Number=0
 
   fi
 
   fi
 
   
 
   
   if [ $HENK = "04" ]; then
+
   if [ $BDetect = "04" ]; then
 
     Number=10
 
     Number=10
 
   fi
 
   fi
 
   
 
   
   if [ $HENK = "02" ]; then
+
   if [ $BDetect = "02" ]; then
 
     Number=$(((Number + 10) % 12 )) # can be changed to 11 if you want it to get 1 down
 
     Number=$(((Number + 10) % 12 )) # can be changed to 11 if you want it to get 1 down
 
   fi
 
   fi
 
   
 
   
   if [ $HENK = "01" ]; then
+
   if [ $BDetect = "01" ]; then
     Number=$(((Number + 2) % 12 )) #can be changed to 1 if you want to get it up by 1 / I did 2 because speed
+
     Number=$(((Number + 2) % 12 )) #can be changed to 1 if you want to get it up by 1 / I did 2 because I think that is more functional.
 
   fi
 
   fi
 
   
 
   
Line 95: Line 95:
 
   
 
   
 
  bw_tool -I -D /dev/i2c-1 -a 94 -W 11:00
 
  bw_tool -I -D /dev/i2c-1 -a 94 -W 11:00
  bw_tool -I -D /dev/i2c-1 -a 94 -t "$Numb2""."${Barray[$Number]}
+
  bw_tool -I -D /dev/i2c-1 -a 94 -t "$Numb2""."${Narray[$Number]}
 
  bw_tool -I -D /dev/i2c-1 -a 94 -W 11:20
 
  bw_tool -I -D /dev/i2c-1 -a 94 -W 11:20
  bw_tool -I -D /dev/i2c-1 -a 94 -t "$Numb3""."${Barray[$Numb2]}
+
  bw_tool -I -D /dev/i2c-1 -a 94 -t "$Numb3""."${Narray[$Numb2]}
 
   
 
   
 
  sleep 1
 
  sleep 1
 
   
 
   
 
  done
 
  done

Revision as of 08:41, 21 October 2015

Scroll Menu

Scroll Menu with multiple functions, where with every functions you can set up certain things. Example: Changing Alarm Time Changing volume

The reason I made this, is because I don't want to use the raspberry pi only for just 1 thing. I want to use it for multiple script and don't want to use a command section to get the other script to work. Here I can also put all my future projects in.


First mission is to make it possible that it goes up and down in the menu and than choose a certain function.

  • 1. Select option 1
  • 2. Select option 2
  • 3. go to the begin of the menu
  • 4. Go to the End of the menu
  • 5. Going down in the menu
  • 6. Going up in the menu

For this script I used some techniques from previous scripts. That you can see in blog 10(PushMenu) and blog 12(AlarmMenu).

array=( pushmenu2 AlarmMenu Jaap Tim Martin Koos Willem Bas Luuk Richard Nick Alex)
# Element 0       1         2    3   4      5    6      7   8    9       10   11

An array is a list names that are put together and you can find with typing it's number. The number counting begins with 0 and ends until you stopped giving names. For this I used 2 names of previous scripts and 10 other random names.

Narray=( "Temp Menu" "Alarm Menu" Settings "Board menu" "Fries Menu" "Banana Menu" "vega burger" "wc menu" Bananaphone "2001:ABC" "ghost server" "My  name is...")
# Element 0           1           2         3            4            5             6             7        8            9          10             11

This is the second script and I called it Narray. (Names Array. You can of course call it what ever you want ) This array I made to print this text out. As you can see some of them don't use quotation marks. I only did that to say that you only really need to put them if you want to print a text with a space in it. And also here I gave the other 10 random names.

if [ $BDetect  = "20" ]; then
   ./${array[$Number]}
fi
if [ $BDetect  = "10" ]; then
  ./${array[$Numb2]}
fi

This parts check if the button is pressed. If the button is pressed it will


The final script all together:

#!/bin/bash
bw_tool -I -D /dev/i2c-1 -a 94 -W 10:00

while true; do
BDetect=`bw_tool -I -D /dev/i2c-1 -a 94 -R 30:b`

array=( pushmenu2 AlarmMenu Jaap Tim Martin Koos Willem Bas Luuk Richard Nick Alex)
# Element 0       1         2    3   4      5    6      7   8    9       10   11

Narray=( "Temp Menu" "Alarm Menu" Settings "Board menu" "Fries Menu" "Banana Menu" "vega burger" "wc menu" Bananaphone "2001:ABC" "ghost server" "My  name is...")
# Element 0           1           2         3            4            5             6             7        8            9          10             11

 if [ $BDetect  != "00" ]; then
    bw_tool -I -D /dev/i2c-1 -a 94 -W 10:00
 fi

 if [ $BDetect  = "20" ]; then
    ./${array[$Number]}
 fi

 if [ $BDetect  = "10" ]; then
   ./${array[$Numb2]}
 fi

 if [ $BDetect  = "08" ]; then
    Number=0
 fi

 if [ $BDetect  = "04" ]; then
    Number=10
 fi

 if [ $BDetect  = "02" ]; then
    Number=$(((Number + 10) % 12 )) # can be changed to 11 if you want it to get 1 down
 fi

 if [ $BDetect  = "01" ]; then
    Number=$(((Number + 2) % 12 )) #can be changed to 1 if you want to get it up by 1 / I did 2 because I think that is more functional.
 fi

Numb2=$((Number + 1))
Numb3=$((Numb2 + 1))

bw_tool -I -D /dev/i2c-1 -a 94 -W 11:00
bw_tool -I -D /dev/i2c-1 -a 94 -t "$Numb2""."${Narray[$Number]}
bw_tool -I -D /dev/i2c-1 -a 94 -W 11:20
bw_tool -I -D /dev/i2c-1 -a 94 -t "$Numb3""."${Narray[$Numb2]}

sleep 1

done