Your functions that get called when the buttons are pressed.
On Apr 11, 2014 8:48 PM, "Chia Waicheong" <[email protected]> wrote:

> Sorry, what is handler?
>
> On Friday, April 11, 2014 1:48:07 AM UTC+8, Chia Waicheong wrote:
>>
>> im trying to connect 2DC motor driver using arduino motor shield, tested
>> all the ioio output using led and it seems providing the desired output.
>> However, the 2 motor didnt move when i try to connect the ioio to the motor
>> driver. Im using a 9V battery for the motor. Is the motor driver not
>> compatible with ioio or it is other problem? my coding:
>>
>> package ioio.examples.hello;
>>
>> import ioio.lib.api.DigitalOutput;
>> import ioio.lib.api.exception.ConnectionLostException;
>> import ioio.lib.util.BaseIOIOLooper;
>> import ioio.lib.util.IOIOLooper;
>> import ioio.lib.util.android.IOIOActivity;
>> import android.os.Bundle;
>> import android.widget.ToggleButton;
>> import ioio.lib.api.Sequencer;
>> import ioio.lib.api.Sequencer.ChannelConfig;
>> import ioio.lib.api.Sequencer.ChannelConfigPwmSpeed;
>> import ioio.lib.api.Sequencer.ChannelCuePwmSpeed;
>>
>>
>>
>> /**
>>  * This is the main activity of the HelloIOIO example
>>
>> application.
>>  *
>>  * It displays a toggle button on the screen, which enables
>>
>> control of the
>>  * on-board LED. This example shows a very simple usage of the
>>
>> IOIO, by using
>>  * the {@link IOIOActivity} class. For a more advanced use
>>
>> case, see the
>>  * HelloIOIOPower example.
>>  */
>> public class MainActivity extends IOIOActivity {
>>
>> /**
>>  * Called when the activity is first created. Here we
>>
>> normally initialize
>>  * our GUI.
>>  */
>> @Override
>> public void onCreate(Bundle savedInstanceState) {
>> super.onCreate(savedInstanceState);
>> setContentView(R.layout.main);
>>  }
>>
>> /**
>>  * This is the thread on which all the IOIO activity
>>
>> happens. It will be run
>>  * every time the application is resumed and aborted
>>
>> when it is paused. The
>>  * method setup() will be called right after a
>>
>> connection with the IOIO has
>>  * been established (which might happen several
>>
>> times!). Then, loop() will
>>  * be called repetitively until the IOIO gets
>>
>> disconnected.
>>  */
>> class Looper extends BaseIOIOLooper {
>>   private Sequencer.ChannelCuePwmSpeed dcMotorACue_ = new
>> ChannelCuePwmSpeed();
>> private Sequencer.ChannelCuePwmSpeed dcMotorBCue_ = new
>> ChannelCuePwmSpeed();
>> private Sequencer.ChannelCue[] cue_ = new Sequencer.ChannelCue[]
>> {dcMotorACue_, dcMotorBCue_ };
>> private Sequencer sequencer_;
>>
>> /**
>>  * Called every time a connection with IOIO has
>>
>> been established.
>>  * Typically used to open pins.
>>  *
>>  * @throws ConnectionLostException
>>  *             When IOIO connection is lost.
>>  * @throws InterruptedException
>>  *
>>  * @see
>>
>> ioio.lib.util.AbstractIOIOActivity.IOIOThread#setup()
>>  */
>> @Override
>> protected void setup() throws ConnectionLostException,
>> InterruptedException {
>>  DigitalOutput enable1 = ioio_.openDigitalOutput(3);
>> DigitalOutput enable2 = ioio_.openDigitalOutput(4);
>> enable1.write(true);
>> enable2.write(true);
>> final ChannelConfigPwmSpeed dcMotorAConfig = new Sequencer.
>> ChannelConfigPwmSpeed(Sequencer.Clock.CLK_2M, 2000, 0, new
>> DigitalOutput.Spec(1));
>> final ChannelConfigPwmSpeed dcMotorBConfig = new Sequencer.
>> ChannelConfigPwmSpeed(Sequencer.Clock.CLK_2M, 2000, 0, new
>> DigitalOutput.Spec(2));
>> final ChannelConfig[] config = new ChannelConfig[] {dcMotorAConfig,
>> dcMotorBConfig };
>>
>> sequencer_ = ioio_.openSequencer(config);
>>
>> // Pre-fill.
>> sequencer_.waitEventType
>>
>> (Sequencer.Event.Type.STOPPED);
>>
>> sequencer_.start();
>>  }
>>
>> /**
>>  * Called repetitively while the IOIO is
>>
>> connected.
>>  *
>>  * @throws ConnectionLostException
>>  *             When IOIO connection is lost.
>>  * @throws InterruptedException
>>  *
>>  * @see
>>
>> ioio.lib.util.AbstractIOIOActivity.IOIOThread#loop()
>>
>>  */
>> @Override
>> public void loop() throws ConnectionLostException, InterruptedException {
>> push();
>> }
>>
>>  private void push() throws
>>
>> ConnectionLostException, InterruptedException {
>> dcMotorACue_.pulseWidth = 1000;
>> dcMotorBCue_.pulseWidth = 1000;
>> sequencer_.push(cue_, 62500);
>>  }
>>
>> /**
>>  * A method to create our IOIO thread.
>>  *
>>  * @see
>>
>> ioio.lib.util.AbstractIOIOActivity#createIOIOThread()
>>  */
>>  }
>> protected IOIOLooper createIOIOLooper() {
>> return new Looper();
>> }}
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "ioio-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/ioio-users.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"ioio-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/ioio-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to