|
Make sure that you have the latest test release of BricxCC/NBC/NXC which you can download from http://bricxcc.sourceforge.net/test_release.zip. Extract the zip over your existing BricxCC installation with directory structure maintained as in the zip. Then make sure you tell BricxCC to target an NXT 2.0 compatible firmware on the Compiler|NBC/NXC preferences tab. If you use the command line compiler directly then pass -v=128 on the command line. Also make sure you have either the enhanced NBC/NXC firmware version 1.28 or the standard NXT firmware version 1.28 installed on your NXT. The enhanced NBC/NXC firmware will be updated to version 1.28 in the latest test release later on today. Right now the enhanced firmware is at version 1.27, which does include color sensor support but not via the built-in menu system.
Support for the new color sensor is built into the header files that are automatically included by the compiler (NBCCommon.h and NXCDefs.h). To configure the sensor use one of these functions:
SetSensorColorFull(byte port);
SetSensorColorRed(byte port);
SetSensorColorGreen(byte port);
SetSensorColorBlue(byte port);
SetSensorColorNone(byte port);
Use the first if you want to use the sensor as a full color sensor. Use the Red, Green, and Blue functions to turn the sensor on as a color lamp with either red, green, or blue light. The last one turns off the lamp.
To read the sensor color number just use SENSOR_1, SENSOR_2, SENSOR_3, or SENSOR_4 (depending on which port your sensor is connected to). To read additional values from the color sensor's IOMap structure you can a number of other API functions. I posted a list on the nxtasy forums.
http://forums.nxtasy.org/index.php?s=&showtopic=4080&view=findpost&p=31616
Hope this helps,
John Hansen |
评分
-
查看全部评分
|