Was just introduced to DroidScript this morning and had a quick question.
Is there any way to automatically have the app connect to an NXT Brick when it is launched?
I have a system in place right now (my blinds get raised and lowered using a bluetooth-connected NXT Brick) that uses Tasker to input taps and navigate my current app (consists of 3 buttons), but it takes a while and isn't the "right way" to do it.
//Called when application is started.
function OnStart()
{
//Create our screen layout.
CreateLayout();
//Create NXT controller object.
nxt = app.CreateNxt();
}
//Create the screen layout.
function CreateLayout()
{
//Create the layout (with repeating pattern background).
lay = app.CreateLayout( "Linear", "VCenter,FillXY" );
lay.SetBackground( "/Sys/Img/Tile.png", "repeat" );
//Create 'Connect' button.
btn = app.CreateButton( "Connect", 0.3,0.1, "Lego" );
btn.SetMargins( 0,0,0,0.1 );
btn.SetOnTouch( btn_OnTouch );
lay.AddChild( btn );
//Create 'Blinds - Up' Button
btnUp = app.CreateButton( "Up", 0.3, 0.1, "Lego" );
btnUp.SetOnTouch( btnUp_OnTouch );
lay.AddChild( btnUp );
//Create 'Blinds - Down' Button
btnDown = app.CreateButton( "Down", 0.3, 0.1, "Lego" );
btnDown.SetOnTouch( btnDown_OnTouch );
lay.AddChild( btnDown );
//Add layout to the app.
app.AddLayout( lay );
}
//Called when user presses connect.
function btn_OnTouch()
{
//Show list of NXT devices.
nxt.ShowDevices();
}
//Called when 'Blinds - Up' button is pressed.
function btnUp_OnTouch( e )
{
nxt.StartProgram( "Blinds - Up.rxe" );
}
//Called when 'Blinds - Down' button is pressed.
function btnDown_OnTouch( f )
{
nxt.StartProgram( "Blinds - Down.rxe" );
}