Difference between revisions of "Blog 07"

From BitWizard Wiki
Jump to navigation Jump to search
 
Line 66: Line 66:
./type.
./type.


To do this we will add a sleep of 0.5sec at every button.
To do this we will add a sleep of 0.5sec at every button:



#!/bin/bash
#!/bin/bash

Latest revision as of 15:13, 16 September 2015

!BETA!

I am now going to make it possible to use the Raspberry Interface buttons as some kind of keyboard. Later I want to make it possible that instead of just printing letters it will print scripts.

I am first going to try to get it work with button 3.

so we read button 23:s without pressing the button it says; 0101 and with pressing the right button it says 0000

$ bw_tool -I -D /dev/i2c-1 -a 94 -R 23:s 
0101 
$ bw_tool -I -D /dev/i2c-1 -a 94 -R 23:s 
0000 

When we make a shell we have to put the code:

if [ `bw_tool -I -D /dev/i2c-1 -a 94 -R 23:s`  = "0000" ]; then 
  echo `bw_tool -I -D /dev/i2c-1 -a 94 -t Bananaphone 
fi 


It will look if the place is 0000 and then if that is true it will print the text after that it is finished


what I found out is that the numbers are mirrored so:

20:s = button 6
21:s = button 5
22:s = button 4
23:s = button 3
24:s = button 2
25:s = button 1


Now to try the full 6 buttons!


When the mirror in mind we make this code:


#!/bin/bash 

if [ `bw_tool -I -D /dev/i2c-1 -a 94 -R 25:s`  = "0000" ]; then 
  echo `bw_tool -I -D /dev/i2c-1 -a 94 -t W` 
elif [ `bw_tool -I -D /dev/i2c-1 -a 94 -R 24:s`  = "0000" ]; then 
  echo `bw_tool -I -D /dev/i2c-1 -a 94 -t i` 
elif [ `bw_tool -I -D /dev/i2c-1 -a 94 -R 23:s`  = "0000" ]; then 
  echo `bw_tool -I -D /dev/i2c-1 -a 94 -t z` 
elif [ `bw_tool -I -D /dev/i2c-1 -a 94 -R 22:s`  = "0000" ]; then 
  echo `bw_tool -I -D /dev/i2c-1 -a 94 -t a` 
elif [ `bw_tool -I -D /dev/i2c-1 -a 94 -R 21:s`  = "0000" ]; then 
  echo `bw_tool -I -D /dev/i2c-1 -a 94 -t r` 
elif [ `bw_tool -I -D /dev/i2c-1 -a 94 -R 20:s`  = "0000" ]; then 
  echo `bw_tool -I -D /dev/i2c-1 -a 94 -t d` 
fi 

with this code you sadly always have to activate it with

./type

Now we have to make it possible you can just keep typing and don't have to turn it on again after every time you entered

./type. 

To do this we will add a sleep of 0.5sec at every button:

#!/bin/bash  

 while true; do
 if [ `bw_tool -I -D /dev/i2c-1 -a 94 -R 25:s`  = "0000" ]; then
   echo `bw_tool -I -D /dev/i2c-1 -a 94 -t W`
        sleep 0.5
elif [ `bw_tool -I -D /dev/i2c-1 -a 94 -R 24:s`  = "0000" ]; then
  echo `bw_tool -I -D /dev/i2c-1 -a 94 -t i`
        sleep 0.5
elif [ `bw_tool -I -D /dev/i2c-1 -a 94 -R 23:s`  = "0000" ]; then
  echo `bw_tool -I -D /dev/i2c-1 -a 94 -t z`
        sleep 0.5
elif [ `bw_tool -I -D /dev/i2c-1 -a 94 -R 22:s`  = "0000" ]; then
  echo `bw_tool -I -D /dev/i2c-1 -a 94 -t a`
        sleep 0.4
elif [ `bw_tool -I -D /dev/i2c-1 -a 94 -R 21:s`  = "0000" ]; then
  echo `bw_tool -I -D /dev/i2c-1 -a 94 -t r`
        sleep 0.5
elif [ `bw_tool -I -D /dev/i2c-1 -a 94 -R 20:s`  = "0000" ]; then
  echo `bw_tool -I -D /dev/i2c-1 -a 94 -t d`
         sleep 0.5
fi

done 


Wiz.png
Wizard.png














!BETA!