Difference between revisions of "Blog 07"
(In this text harry makes it possible to use the buttons for printing text on the screen) |
(→!BETA!) |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
== !BETA! == |
== !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. |
|||
first try to see if it can detect the raspberry pi button to make sure if it works I choose to detect the middle number 3. |
|||
so we read button 23:s |
so we read button 23:s |
||
without pressing the button it says; |
without pressing the button it says; |
||
Line 16: | Line 19: | ||
When we make a shell we have to put the code: |
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 |
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 |
echo `bw_tool -I -D /dev/i2c-1 -a 94 -t Bananaphone |
||
fi |
fi |
||
in ir |
|||
It will look if the place is 0000 |
|||
and then if that is true it will print the text |
and then if that is true it will print the text |
||
after that it is finished |
after that it is finished |
||
Line 26: | Line 29: | ||
what I found out is that the numbers are mirrored so: |
what I found out is that the numbers are mirrored so: |
||
20:s = 6 |
20:s = button 6 |
||
21:s = button 5 |
|||
22:s = button 4 |
|||
23:s = button 3 |
|||
24:s = button 2 |
|||
25:s = button 1 |
|||
Line 34: | Line 41: | ||
When |
When the mirror in mind we make this code: |
||
Line 56: | Line 63: | ||
./type |
./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. |
./type. |
||
To do this we will add a sleep of 0.5sec at every button: |
|||
#!/bin/bash |
#!/bin/bash |
||
Line 65: | Line 73: | ||
if [ `bw_tool -I -D /dev/i2c-1 -a 94 -R 25:s` = "0000" ]; then |
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` |
echo `bw_tool -I -D /dev/i2c-1 -a 94 -t W` |
||
sleep 0. |
sleep 0.5 |
||
elif [ `bw_tool -I -D /dev/i2c-1 -a 94 -R 24:s` = "0000" ]; then |
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` |
echo `bw_tool -I -D /dev/i2c-1 -a 94 -t i` |
||
sleep 0. |
sleep 0.5 |
||
elif [ `bw_tool -I -D /dev/i2c-1 -a 94 -R 23:s` = "0000" ]; then |
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` |
echo `bw_tool -I -D /dev/i2c-1 -a 94 -t z` |
||
sleep 0. |
sleep 0.5 |
||
elif [ `bw_tool -I -D /dev/i2c-1 -a 94 -R 22:s` = "0000" ]; then |
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` |
echo `bw_tool -I -D /dev/i2c-1 -a 94 -t a` |
||
Line 77: | Line 85: | ||
elif [ `bw_tool -I -D /dev/i2c-1 -a 94 -R 21:s` = "0000" ]; then |
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` |
echo `bw_tool -I -D /dev/i2c-1 -a 94 -t r` |
||
sleep 0. |
sleep 0.5 |
||
elif [ `bw_tool -I -D /dev/i2c-1 -a 94 -R 20:s` = "0000" ]; then |
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` |
echo `bw_tool -I -D /dev/i2c-1 -a 94 -t d` |
||
sleep 0. |
sleep 0.5 |
||
fi |
fi |
||
done |
done |
||
Line 113: | Line 122: | ||
!BETA! |
|||
for now I added sleep 0.4 sec after every echo |
|||
but this doesn't help because now people have to type slower or faster if you change the time. !BETA! |
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
!BETA!