Difference between revisions of "Blog 07"
(In this text harry makes it possible to use the buttons for printing text on the screen) |
(→!BETA!) |
||
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. | ||
− | first try to | + | I am first going to try to get it work with button 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 | ||
− | + | ||
− | + | 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 |
− | 25:s = 1 | + | 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. | ||
Line 65: | Line 74: | ||
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 86: | ||
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 123: | ||
− | + | !BETA! | |
− |
Revision as of 16:12, 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!