I'm teaching a class using NXC and would like my students to write their own NXC code to control a robot that can take driver controlled commands from a joystick. The robot will be connected via Bluetooth to a laptop with a Logitech F310 Gamepad attached via USB. To test out this setup, I've installed the July 24 2012 test release of BricxCC that includes support for NXC 1.2.1 r5 (provides the JoystickMessageRead() function) on my laptop. When I compile and run the following example program provided in Help on an NXT running the v. 1.31 enhanced firmware provided in the test release package:
Code: Select all
/*
struct JoystickMessageType {
byte JoystickDir;
byte LeftMotor;
byte RightMotor;
byte BothMotors;
char LeftSpeed;
char RightSpeed;
unsigned long Buttons;
};
*/
task main()
{
JoystickMessageType jmt;
while (true)
{
char result = JoystickMessageRead(MAILBOX1, jmt);
if (result == NO_ERR)
{
NumOut(0, LCD_LINE1, jmt.JoystickDir);
NumOut(0, LCD_LINE2, jmt.LeftMotor);
NumOut(0, LCD_LINE3, jmt.RightMotor);
NumOut(0, LCD_LINE4, jmt.BothMotors);
ClearLine(LCD_LINE5);
NumOut(0, LCD_LINE5, jmt.LeftSpeed);
ClearLine(LCD_LINE6);
NumOut(0, LCD_LINE6, jmt.RightSpeed);
ClearLine(LCD_LINE7);
NumOut(0, LCD_LINE7, jmt.Buttons);
}
else
NumOut(0, LCD_LINE8, result);
Wait(MS_100);
}
}
I see only "64" on the last line of the NXT display regardless of what buttons or controls are activated on the attached Logictech Gamepad (have tried separate tests with the NXT connected via Bluetooth and then directly attached via USB with same results.) I've confirmed that the Gamepad is functional and can use it successfully to control the NXT using the Joystick tool accessible from the Tools menu of BricxCC. I'm clearly doing something wrong. Can someone help me understand what it is? Hopefully, it's a simple oversight.
Many thanks to the community!
-Chad