52
IOIO-BOT
: Android Robotics
6.3.1 Android device operation
The main function is displaying the slider of motor controller. The slider creation is
not simila r the commonly Button. Norma lly Button use Event Listener with
OnClickListener type. It will be activated when users tap a button only. It does not response
about sliding the button back to back. Then change to use Linear Layout instead. Normally
using the Linear Layout is layout for placing the button or text. But in this app development
use the Linear Layout to background area of the slider image. There are 2 images. One is
background of the slider. Another is slider of motor controller image that move following
the fingers touching. The slider image will be move within the Linear Layout only following
the figure 6-6
For Event Listener that used with the Linear Layout is OnTouchListener. It activate
when any touching screen is appeared such as user tap on the Linear Layout. It cause
Listener active. Touching screen is called “
Down
”. In case user move the finger back to
back after down, it is called “
Move
”. Finally, user lift the finger from screen. It is called
“
Up
”.
When Down and Move are happened, application will read Y position of touching
and draw the slider or controller by using Canvas on the Linear Layout. Next, calculate
the distance of touching point to center of Y axis of Linear Layout to speed value. The
maximum speed is equal to 100. It is duty cycle of PWM signal of motor driver. For IOIO-Q,
PWM determination is 0 to 1. Then divide the value by 100. If duty cycle is 50%, the PWM
value for IOIO-Q is 0.5.
Figure 6-6 : Slider of motor controller image that used in the IOIO-Bot app
Summary of Contents for IOIO-BOT
Page 1: ...IOIO BOT Android Robotics 1 IOIO BOT Android Robotics...
Page 2: ...2 IOIO BOT Android Robotics...
Page 4: ...4 IOIO BOT Android Robotics...
Page 12: ...12 IOIO BOT Android Robotics...
Page 38: ...38 IOIO BOT Android Robotics...
Page 46: ...46 IOIO BOT Android Robotics...
Page 51: ...IOIO BOT Android Robotics 51 Figure 6 5 IOIO Bot app flowchart final...
Page 55: ......
Page 56: ......