Sure.. Pretty straightforward:
/**
* This is the thread on which all the IOIO activity happens.
*/
class IOIO extends BaseIOIOLooper
{
private static final int BAUD = 31250;
private static final int MIDI_OUTPUT_PIN = 7;
/** The on-board LED. */
private DigitalOutput led_;
/**
* The output for MIDI messages
*/
private Uart _midiOut;
/**
* The stream used for sending the MIDI bytes
*/
private OutputStream _outputStream;
/**
* A class for handling keyboard input
*/
private ButtonScanner _buttonScanner;
/**
* A class for handling fader and knob input
*/
private PotScanner _potScanner;
/**
* 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
{
Log.i(DEBUG_TAG,"setup");
led_ = ioio_.openDigitalOutput(0, false);
_potScanner = new PotScanner(this.ioio_, _inputHandler);
_buttonScanner = new ButtonScanner(this.ioio_, AACSmain.this, led_);
_potScanner.start();
_buttonScanner.start();
//Initializing the output
_midiOut = ioio_.openUart(null,new Spec(MIDI_OUTPUT_PIN,Mode.NORMAL),
BAUD,Parity.NONE,StopBits.ONE);
_outputStream = _midiOut.getOutputStream();
//Increases the priority of the current thread
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
Log.i(DEBUG_TAG,"setup finished");
}
/**
* Kills the threads
*/
@Override
public void disconnected()
{
try{
_potScanner.abort();
_buttonScanner.abort();
}
catch (NullPointerException e)
{
System.out.println("Nullpointer error");
}
}
/**
* Called repetitively while the IOIO is connected.
*
* @throws ConnectionLostException
* When IOIO connection is lost.
*
* @see ioio.lib.util.AbstractIOIOActivity.IOIOThread#loop()
*/
@Override
public void loop() throws ConnectionLostException
{
if (!out_queue.isEmpty())
{
try
{
_outputStream.write(out_queue.poll().getMessage());
led_.write(false);
Thread.sleep(1);
led_.write(true);
}
catch (IOException e)
{
Log.e(DEBUG_TAG,"Problem with MIDI output");
}
catch (InterruptedException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
/**
* A method to create our IOIO thread.
*
* @see ioio.lib.util.AbstractIOIOActivity#createIOIOThread()
*/
@Override
protected IOIOLooper createIOIOLooper()
{
return new IOIO();
}
--
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/groups/opt_out.