View unanswered posts | View active topics It is currently Wed Oct 22, 2014 5:44 am






Reply to topic  [ 4 posts ] 
NXT buttons in Virtual World doesn't work 
Author Message
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post NXT buttons in Virtual World doesn't work
For the FTC competition, our library has a "choice menu" module which displays autonomous strategy choices on the NXT LCD screen and allowing the user to press the left/right arrow buttons to go up and down the menu and press ENTER to select the choice. The code works fine with a real NXT but when running it in Virtual World, the code doesn't work. I have simplified the code to demonstrate the problem.
Code:
/**
    According to nxtFileIODefs.h:
    kNoButton = -1
    kExitButton = 0
    kRightButton = 1
    kLeftButton = 2
    kEnterButton = 3
   
    But in Virtual World:
    kNoButton = -1
    kLeftButton = 1
    kRightButton = 0
    kEnterButton and kExitButton has no effect
*/

task main()
{
    while (true)
    {
        nxtDisplayTextLine(0, "Btn=%x", nNxtButtonPressed);
        wait1Msec(100);
    }
}


Sat Oct 06, 2012 2:42 pm
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 592
Post Re: NXT buttons in Virtual World doesn't work
We are currently looking into to these button values, but in the meanwhile I would like to make an educational note of some of the differences between the NXT Remote screen in normal ROBOTC operation and Virtual Worlds operation.

Virtual Worlds will support only one program at a time, so you won't be able to use a Program Chooser program to switch between multiple programs once one has been loaded to a Virtual World table. However, you can code a program that does different things depending on which buttons are pressed on the NXT Remote Screen:

Code:
task main()
{
   while   (nNxtButtonPressed == -1)
      { }

      if (nNxtButtonPressed == 1)
         {
          nxtDisplayTextLine(0, "Btn=%x", nNxtButtonPressed);
        wait1Msec(1000);
         }
      
      if (nNxtButtonPressed == 2)
         {
           nxtDisplayTextLine(0, "Btn=%x", nNxtButtonPressed);
             wait1Msec(1000);
         }
         
      if (nNxtButtonPressed == 3)
         {
           nxtDisplayTextLine(0, "Btn=%x", nNxtButtonPressed);
         wait1Msec(1000);
         }

}


What the above code does is sit idle in the first while loop until any button is pressed (a value of -1 for the nNxtButtonPressed means no button is pressed). Once a button is pressed, the NXT displays which button is pressed on the screen for 1 second. The grey button will still cancel the program.

You can tailor-fit a program like this to your individual needs (by calling functions or starting tasks when a specific button is pressed, for example).

For more information on coding the NXT buttons, the NXT display, and all of the other ROBOTC functions for the NXT, please see our wiki.

_________________
Check out our Blog! And our Facebook page!
Need help? Take a look at our Wiki and our Forums.

I just met you,
And this is crazy,
But here's my code now,
So fix it, maybe?
~ Carly Rae Jepsen parody


Tue Oct 09, 2012 10:32 am
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: NXT buttons in Virtual World doesn't work
No, it is not a program chooser. One single program implements all the competition strategies and the menu code is to choose what strategy to use. So it is not changing to another program.


Tue Oct 09, 2012 12:24 pm
Profile
Site Admin
Site Admin

Joined: Tue May 15, 2007 9:02 am
Posts: 405
Post Re: NXT buttons in Virtual World doesn't work
This will be fixed in the next ROBOTC update, coming soon! Thanks.

_________________
Jesse Flot
CMU Robotics Academy
ROBOTC Support


Thu Oct 11, 2012 9:38 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.