1 /** \file NBCCommon.h
2  * \brief Constants and macros common to both NBC and NXC
3  *
4  * NBCCommon.h contains declarations for the NBC and NXC NXT API functions.
5  *
6  * License:
7  *
8  * The contents of this file are subject to the Mozilla Public License
9  * Version 1.1 (the "License"); you may not use this file except in
10  * compliance with the License. You may obtain a copy of the License at
11  * http://www.mozilla.org/MPL/
12  *
13  * Software distributed under the License is distributed on an "AS IS"
14  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
15  * License for the specific language governing rights and limitations
16  * under the License.
17  *
18  * The Initial Developer of this code is John Hansen.
19  * Portions created by John Hansen are Copyright (C) 2009-2010 John Hansen.
20  * All Rights Reserved.
21  *
22  * ----------------------------------------------------------------------------
23  *
24  * \author John Hansen (bricxcc_at_comcast.net)
25  * \date 2011-03-13
26  * \version 63
27  */
28 
29 #ifndef NBCCOMMON_H
30 #define NBCCOMMON_H
31 
32 /** @addtogroup MiscConstants
33  * @{
34  */
35 #define TRUE  1 /*!< A true value */
36 #define FALSE 0 /*!< A false value */
37 
38 #define NA 0xFFFF /*!< The specified argument does not apply (aka unwired) */
39 
40 /** @defgroup RCPropertyConstants Property constants
41  * Use these constants for specifying the property for the GetProperty
42  * and SetProperty direct commands.
43  * @{
44  */
45 #define RC_PROP_BTONOFF       0x0  /*!< Set/get whether bluetooth is on or off */
46 #define RC_PROP_SOUND_LEVEL   0x1  /*!< Set/get the NXT sound level */
47 #define RC_PROP_SLEEP_TIMEOUT 0x2  /*!< Set/get the NXT sleep timeout value (times 60000) */
48 #define RC_PROP_DEBUGGING     0xF  /*!< Set/get enhanced firmware debugging information */
49 /** @} */  // end of RCPropertyConstants group
50 
51 /** @} */  // end of MiscConstants group
52 
53 #ifdef __ENHANCED_FIRMWARE
54 /** @addtogroup CommandModuleConstants
55  * @{
56  */
57 /** @defgroup ArrayOpConstants Array operation constants
58  * Constants for use with the NXC ArrayOp function and the NBC arrop statement.
59  * @{
60  */
61 // array operation definitions
62 #define OPARR_SUM    0x00 /*!< Calculate the sum of the elements in the numeric input array */
63 #define OPARR_MEAN   0x01 /*!< Calculate the mean value for the elements in the numeric input array */
64 #define OPARR_SUMSQR 0x02 /*!< Calculate the sum of the squares of the elements in the numeric input array */
65 #define OPARR_STD    0x03 /*!< Calculate the standard deviation of the elements in the numeric input array */
66 #define OPARR_MIN    0x04 /*!< Calculate the minimum value of the elements in the numeric input array */
67 #define OPARR_MAX    0x05 /*!< Calculate the maximum value of the elements in the numeric input array */
68 #define OPARR_SORT   0x06 /*!< Sort the elements in the numeric input array */
69 /** @} */  // end of ArrayOpConstants group
70 /** @} */  // end of CommandModuleConstants group
71 #endif
72 
73 /** @addtogroup MiscConstants
74  * @{
75  */
76 #if __FIRMWARE_VERSION > 107
77 #define PI 3.141593               /*!< A constant for PI */
78 #define RADIANS_PER_DEGREE PI/180 /*!< Used for converting from degrees to radians */
79 #define DEGREES_PER_RADIAN 180/PI /*!< Used for converting from radians to degrees */
80 #endif
81 /** @} */  // end of MiscConstants group
82 
83 #if __FIRMWARE_VERSION <= 107
84 /** @defgroup IOMapAddressConstants Direct IOMap data addresses
85  * Constants for use in direct IOMap addressing (1.0x only).
86  * @{
87  */
88 #define IO_BASE    0xC000
89 #define MOD_INPUT  0x0000
90 #define MOD_OUTPUT 0x0200
91 #define IO_IN_FPP  6
92 #define IO_OUT_FPP 15
93 
94 #define InputIOType(p)            (IO_BASE+MOD_INPUT+TypeField+((p)*IO_IN_FPP))
95 #define InputIOInputMode(p)       (IO_BASE+MOD_INPUT+InputModeField+((p)*IO_IN_FPP))
96 #define InputIORawValue(p)        (IO_BASE+MOD_INPUT+RawValueField+((p)*IO_IN_FPP))
97 #define InputIONormalizedValue(p) (IO_BASE+MOD_INPUT+NormalizedValueField+((p)*IO_IN_FPP))
98 #define InputIOScaledValue(p)     (IO_BASE+MOD_INPUT+ScaledValueField+((p)*IO_IN_FPP))
99 #define InputIOInvalidData(p)     (IO_BASE+MOD_INPUT+InvalidDataField+((p)*IO_IN_FPP))
100 
101 #define OutputIOUpdateFlags(p)     (IO_BASE+MOD_OUTPUT+UpdateFlagsField+((p)*IO_OUT_FPP))
102 #define OutputIOOutputMode(p)      (IO_BASE+MOD_OUTPUT+OutputModeField+((p)*IO_OUT_FPP))
103 #define OutputIOPower(p)           (IO_BASE+MOD_OUTPUT+PowerField+((p)*IO_OUT_FPP))
104 #define OutputIOActualSpeed(p)     (IO_BASE+MOD_OUTPUT+ActualSpeedField+((p)*IO_OUT_FPP))
105 #define OutputIOTachoCount(p)      (IO_BASE+MOD_OUTPUT+TachoCountField+((p)*IO_OUT_FPP))
106 #define OutputIOTachoLimit(p)      (IO_BASE+MOD_OUTPUT+TachoLimitField+((p)*IO_OUT_FPP))
107 #define OutputIORunState(p)        (IO_BASE+MOD_OUTPUT+RunStateField+((p)*IO_OUT_FPP))
108 #define OutputIOTurnRatio(p)       (IO_BASE+MOD_OUTPUT+TurnRatioField+((p)*IO_OUT_FPP))
109 #define OutputIORegMode(p)         (IO_BASE+MOD_OUTPUT+RegModeField+((p)*IO_OUT_FPP))
110 #define OutputIOOverload(p)        (IO_BASE+MOD_OUTPUT+OverloadField+((p)*IO_OUT_FPP))
111 #define OutputIORegPValue(p)       (IO_BASE+MOD_OUTPUT+RegPValueField+((p)*IO_OUT_FPP))
112 #define OutputIORegIValue(p)       (IO_BASE+MOD_OUTPUT+RegIValueField+((p)*IO_OUT_FPP))
113 #define OutputIORegDValue(p)       (IO_BASE+MOD_OUTPUT+RegDValueField+((p)*IO_OUT_FPP))
114 #define OutputIOBlockTachoCount(p) (IO_BASE+MOD_OUTPUT+BlockTachoCountField+((p)*IO_OUT_FPP))
115 #define OutputIORotationCount(p)   (IO_BASE+MOD_OUTPUT+RotationCountField+((p)*IO_OUT_FPP))
116 
117 #define InputIOType0             0xc000
118 #define InputIOInputMode0        0xc001
119 #define InputIORawValue0         0xc002
120 #define InputIONormalizedValue0  0xc003
121 #define InputIOScaledValue0      0xc004
122 #define InputIOInvalidData0      0xc005
123 #define InputIOType1             0xc006
124 #define InputIOInputMode1        0xc007
125 #define InputIORawValue1         0xc008
126 #define InputIONormalizedValue1  0xc009
127 #define InputIOScaledValue1      0xc00a
128 #define InputIOInvalidData1      0xc00b
129 #define InputIOType2             0xc00c
130 #define InputIOInputMode2        0xc00d
131 #define InputIORawValue2         0xc00e
132 #define InputIONormalizedValue2  0xc00f
133 #define InputIOScaledValue2      0xc010
134 #define InputIOInvalidData2      0xc011
135 #define InputIOType3             0xc012
136 #define InputIOInputMode3        0xc013
137 #define InputIORawValue3         0xc014
138 #define InputIONormalizedValue3  0xc015
139 #define InputIOScaledValue3      0xc016
140 #define InputIOInvalidData3      0xc017
141 // output IO Map addresses
142 #define OutputIOUpdateFlags0     0xc200
143 #define OutputIOOutputMode0      0xc201
144 #define OutputIOPower0           0xc202
145 #define OutputIOActualSpeed0     0xc203
146 #define OutputIOTachoCount0      0xc204
147 #define OutputIOTachoLimit0      0xc205
148 #define OutputIORunState0        0xc206
149 #define OutputIOTurnRatio0       0xc207
150 #define OutputIORegMode0         0xc208
151 #define OutputIOOverload0        0xc209
152 #define OutputIORegPValue0       0xc20a
153 #define OutputIORegIValue0       0xc20b
154 #define OutputIORegDValue0       0xc20c
155 #define OutputIOBlockTachoCount0 0xc20d
156 #define OutputIORotationCount0   0xc20e
157 #define OutputIOUpdateFlags1     0xc20f
158 #define OutputIOOutputMode1      0xc210
159 #define OutputIOPower1           0xc211
160 #define OutputIOActualSpeed1     0xc212
161 #define OutputIOTachoCount1      0xc213
162 #define OutputIOTachoLimit1      0xc214
163 #define OutputIORunState1        0xc215
164 #define OutputIOTurnRatio1       0xc216
165 #define OutputIORegMode1         0xc217
166 #define OutputIOOverload1        0xc218
167 #define OutputIORegPValue1       0xc219
168 #define OutputIORegIValue1       0xc21a
169 #define OutputIORegDValue1       0xc21b
170 #define OutputIOBlockTachoCount1 0xc21c
171 #define OutputIORotationCount1   0xc21d
172 #define OutputIOUpdateFlags2     0xc21e
173 #define OutputIOOutputMode2      0xc21f
174 #define OutputIOPower2           0xc220
175 #define OutputIOActualSpeed2     0xc221
176 #define OutputIOTachoCount2      0xc222
177 #define OutputIOTachoLimit2      0xc223
178 #define OutputIORunState2        0xc224
179 #define OutputIOTurnRatio2       0xc225
180 #define OutputIORegMode2         0xc226
181 #define OutputIOOverload2        0xc227
182 #define OutputIORegPValue2       0xc228
183 #define OutputIORegIValue2       0xc229
184 #define OutputIORegDValue2       0xc22a
185 #define OutputIOBlockTachoCount2 0xc22b
186 #define OutputIORotationCount2   0xc22c
187 /** @} */  // end of IOMapAddressConstants group
188 #endif
189 
190 /** @addtogroup CommandModuleConstants
191  * @{
192  */
193 /** @defgroup SysCallConstants System Call function constants
194  * Constants for use in the SysCall() function or NBC syscall statement.
195  * @{
196  */
197 #define FileOpenRead       0 /*!< Open a file for reading */
198 #define FileOpenWrite      1 /*!< Open a file for writing (creates a new file) */
199 #define FileOpenAppend     2 /*!< Open a file for appending to the end of the file */
200 #define FileRead           3 /*!< Read from the specified file */
201 #define FileWrite          4 /*!< Write to the specified file */
202 #define FileClose          5 /*!< Close the specified file */
203 #define FileResolveHandle  6 /*!< Get a file handle for the specified filename if it is already open */
204 #define FileRename         7 /*!< Rename a file */
205 #define FileDelete         8 /*!< Delete a file */
206 #define SoundPlayFile      9 /*!< Play a sound or melody file */
207 #define SoundPlayTone     10 /*!< Play a simple tone with the specified frequency and duration */
208 #define SoundGetState     11 /*!< Get the current sound module state */
209 #define SoundSetState     12 /*!< Set the sound module state */
210 #define DrawText          13 /*!< Draw text to one of 8 LCD lines */
211 #define DrawPoint         14 /*!< Draw a single pixel on the LCD screen */
212 #define DrawLine          15 /*!< Draw a line on the LCD screen */
213 #define DrawCircle        16 /*!< Draw a circle on the LCD screen */
214 #define DrawRect          17 /*!< Draw a rectangle on the LCD screen */
215 #define DrawGraphic       18 /*!< Draw a graphic image on the LCD screen */
216 #define SetScreenMode     19 /*!< Set the screen mode */
217 #define ReadButton        20 /*!< Read the current button state */
218 #define CommLSWrite       21 /*!< Write to a lowspeed (aka I2C) device */
219 #define CommLSRead        22 /*!< Read from a lowspeed (aka I2C) device */
220 #define CommLSCheckStatus 23 /*!< Check the status of a lowspeed (aka I2C) device */
221 #define RandomNumber      24 /*!< Generate a random number */
222 #define GetStartTick      25 /*!< Get the current system tick count */
223 #define MessageWrite      26 /*!< Write a message to a mailbox */
224 #define MessageRead       27 /*!< Read a message from a mailbox */
225 #define CommBTCheckStatus 28 /*!< Check the bluetooth status */
226 #define CommBTWrite       29 /*!< Write to a bluetooth connections */
227 #define CommBTRead        30 /*!< Read from a bluetooth connection */
228 #define KeepAlive         31 /*!< Reset the NXT sleep timer */
229 #define IOMapRead         32 /*!< Read data from one of the firmware module's IOMap structures using the module's name */
230 #define IOMapWrite        33 /*!< Write data to one of the firmware module's IOMap structures using the module's name */
231 
232 #if __FIRMWARE_VERSION <= 107
233 #ifdef __ENHANCED_FIRMWARE
234 #define IOMapReadByID          34
235 #define IOMapWriteByID         35
236 #define DisplayExecuteFunction 36
237 #define CommExecuteFunction    37
238 #define LoaderExecuteFunction  38
239 #define FileFindFirst          39
240 #define FileFindNext           40
241 #define FileOpenWriteLinear    41
242 #define FileOpenWriteNonLinear 42
243 #define FileOpenReadLinear     43
244 #define CommHSControl          44
245 #define CommHSCheckStatus      45
246 #define CommHSWrite            46
247 #define CommHSRead             47
248 #endif
249 #else
250 // NXT 2.0 firmwares
251 #define ColorSensorRead        34 /*!< Read data from the NXT 2.0 color sensor */
252 #define CommBTOnOff            35 /*!< Turn the bluetooth radio on or off */
253 #define CommBTConnection       36 /*!< Connect or disconnect to a known bluetooth device */
254 #define CommHSWrite            37 /*!< Write data to the hi-speed port */
255 #define CommHSRead             38 /*!< Read data from the hi-speed port */
256 #define CommHSCheckStatus      39 /*!< Check the status of the hi-speed port */
257 #define ReadSemData            40 /*!< Read motor semaphore data */
258 #define WriteSemData           41 /*!< Write motor semaphore data */
259 #define ComputeCalibValue      42 /*!< Compute a calibration value */
260 #define UpdateCalibCacheInfo   43 /*!< Update sensor calibration cache information */
261 #define DatalogWrite           44 /*!< Write to the datalog */
262 #define DatalogGetTimes        45 /*!< Get datalog timing information */
263 #define SetSleepTimeoutVal     46 /*!< Set the NXT sleep timeout value */
264 #define ListFiles              47 /*!< List files that match the specified filename pattern */
265 
266 #ifdef __ENHANCED_FIRMWARE
267 #define IOMapReadByID          78 /*!< Read data from one of the firmware module's IOMap structures using the module's ID */
268 #define IOMapWriteByID         79 /*!< Write data to one of the firmware module's IOMap structures using the module's ID */
269 #define DisplayExecuteFunction 80 /*!< Execute one of the Display module's internal functions */
270 #define CommExecuteFunction    81 /*!< Execute one of the Comm module's internal functions */
271 #define LoaderExecuteFunction  82 /*!< Execute one of the Loader module's internal functions */
272 #define FileFindFirst          83 /*!< Start a search for a file using a filename pattern */
273 #define FileFindNext           84 /*!< Continue searching for a file */
274 #define FileOpenWriteLinear    85 /*!< Open a linear file for writing */
275 #define FileOpenWriteNonLinear 86 /*!< Open a non-linear file for writing */
276 #define FileOpenReadLinear     87 /*!< Open a linear file for reading */
277 #define CommHSControl          88 /*!< Control the hi-speed port */
278 #define CommLSWriteEx          89 /*!< Write to a lowspeed (aka I2C) device with optional restart on read */
279 #define FileSeek               90 /*!< Seek to a specific position in an open file */
280 #define FileResize             91 /*!< Resize a file (not yet implemented) */
281 #define DrawGraphicArray       92 /*!< Draw a graphic image from a byte array to the LCD screen */
282 #define DrawPolygon            93 /*!< Draw a polygon on the LCD screen */
283 #define DrawEllipse            94 /*!< Draw an ellipse on the LCD screen */
284 #define DrawFont               95 /*!< Draw text using a custom RIC-based font to the LCD screen */
285 #define MemoryManager          96 /*!< Read memory manager information, optionally compacting the dataspace first */
286 #define ReadLastResponse       97 /*!< Read the last response packet received by the NXT.  Optionally clear the value after reading it. */
287 #define FileTell               98 /*!< Return the current file position in an open file */
288 #endif
289 #endif
290 /** @} */  // end of SysCallConstants group
291 /** @} */  // end of CommandModuleConstants group
292 
293 /** @addtogroup DisplayModuleConstants
294  * @{
295  */
296 /** @defgroup LineConstants Line number constants
297  * Line numbers for use with DrawText system function.
298  * \sa SysDrawText(), TextOut(), NumOut()
299  * @{
300  */
301 #define LCD_LINE8  0 /*!< The 8th line of the LCD screen */
302 #define LCD_LINE7  8 /*!< The 7th line of the LCD screen */
303 #define LCD_LINE6 16 /*!< The 6th line of the LCD screen */
304 #define LCD_LINE5 24 /*!< The 5th line of the LCD screen */
305 #define LCD_LINE4 32 /*!< The 4th line of the LCD screen */
306 #define LCD_LINE3 40 /*!< The 3rd line of the LCD screen */
307 #define LCD_LINE2 48 /*!< The 2nd line of the LCD screen */
308 #define LCD_LINE1 56 /*!< The 1st line of the LCD screen */
309 /** @} */  // end of LineConstants group
310 /** @} */  // end of DisplayModuleConstants group
311 
312 /** @addtogroup CommandModuleConstants
313  * @{
314  */
315 /** @defgroup TimeConstants Time constants
316  * Constants for use with the Wait() function.
317  * \sa Wait()
318  * @{
319  */
320 #define MS_1        1 /*!< 1 millisecond */
321 #define MS_2        2 /*!< 2 milliseconds */
322 #define MS_3        3 /*!< 3 milliseconds */
323 #define MS_4        4 /*!< 4 milliseconds */
324 #define MS_5        5 /*!< 5 milliseconds */
325 #define MS_6        6 /*!< 6 milliseconds */
326 #define MS_7        7 /*!< 7 milliseconds */
327 #define MS_8        8 /*!< 8 milliseconds */
328 #define MS_9        9 /*!< 9 milliseconds */
329 #define MS_10      10 /*!< 10 milliseconds */
330 #define MS_20      20 /*!< 20 milliseconds */
331 #define MS_30      30 /*!< 30 milliseconds */
332 #define MS_40      40 /*!< 40 milliseconds */
333 #define MS_50      50 /*!< 50 milliseconds */
334 #define MS_60      60 /*!< 60 milliseconds */
335 #define MS_70      70 /*!< 70 milliseconds */
336 #define MS_80      80 /*!< 80 milliseconds */
337 #define MS_90      90 /*!< 90 milliseconds */
338 #define MS_100    100 /*!< 100 milliseconds */
339 #define MS_150    150 /*!< 150 milliseconds */
340 #define MS_200    200 /*!< 200 milliseconds */
341 #define MS_250    250 /*!< 250 milliseconds */
342 #define MS_300    300 /*!< 300 milliseconds */
343 #define MS_350    350 /*!< 350 milliseconds */
344 #define MS_400    400 /*!< 400 milliseconds */
345 #define MS_450    450 /*!< 450 milliseconds */
346 #define MS_500    500 /*!< 500 milliseconds */
347 #define MS_600    600 /*!< 600 milliseconds */
348 #define MS_700    700 /*!< 700 milliseconds */
349 #define MS_800    800 /*!< 800 milliseconds */
350 #define MS_900    900 /*!< 900 milliseconds */
351 #define SEC_1    1000 /*!< 1 second */
352 #define SEC_2    2000 /*!< 2 seconds */
353 #define SEC_3    3000 /*!< 3 seconds */
354 #define SEC_4    4000 /*!< 4 seconds */
355 #define SEC_5    5000 /*!< 5 seconds */
356 #define SEC_6    6000 /*!< 6 seconds */
357 #define SEC_7    7000 /*!< 7 seconds */
358 #define SEC_8    8000 /*!< 8 seconds */
359 #define SEC_9    9000 /*!< 9 seconds */
360 #define SEC_10  10000 /*!< 10 seconds */
361 #define SEC_15  15000 /*!< 15 seconds */
362 #define SEC_20  20000 /*!< 20 seconds */
363 #define SEC_30  30000 /*!< 30 seconds */
364 #define MIN_1   60000 /*!< 1 minute */
365 /** @} */  // end of TimeConstants group
366 /** @} */ // end of CommandModuleConstants group
367 
368 /** @addtogroup CommModuleConstants
369  * @{
370  */
371 /** @defgroup MailboxConstants Mailbox constants
372  * Mailbox number constants should be used to avoid confusing NXT-G users.
373  * \sa SysMessageWrite(), SysMessageRead(), SendMessage(), ReceiveMessage(),
374  * SendRemoteBool(), SendRemoteNumber(), SendRemoteString(),
375  * SendResponseBool(), SendResponseNumber(), SendResponseString(),
376  * ReceiveRemoteBool(), ReceiveRemoteNumber(), ReceiveRemoteString(),
377  * ReceiveRemoteMessageEx(), RemoteMessageRead(), RemoteMessageWrite()
378  * @{
379  */
380 #define MAILBOX1  0 /*!< Mailbox number 1 */
381 #define MAILBOX2  1 /*!< Mailbox number 2 */
382 #define MAILBOX3  2 /*!< Mailbox number 3 */
383 #define MAILBOX4  3 /*!< Mailbox number 4 */
384 #define MAILBOX5  4 /*!< Mailbox number 5 */
385 #define MAILBOX6  5 /*!< Mailbox number 6 */
386 #define MAILBOX7  6 /*!< Mailbox number 7 */
387 #define MAILBOX8  7 /*!< Mailbox number 8 */
388 #define MAILBOX9  8 /*!< Mailbox number 9 */
389 #define MAILBOX10 9 /*!< Mailbox number 10 */
390 /** @} */  // end of MailboxConstants group
391 /** @} */ // end of CommModuleConstants group
392 
393 /** @addtogroup NXTFirmwareModules
394  * @{
395  */
396 /** @addtogroup ModuleNameConstants
397  * @{
398  */
399 #define CommandModuleName  "Command.mod"   /*!< The command module name */
400 #define IOCtrlModuleName   "IOCtrl.mod"    /*!< The IOCtrl module name */
401 #define LoaderModuleName   "Loader.mod"    /*!< The Loader module name */
402 #define SoundModuleName    "Sound.mod"     /*!< The sound module name */
403 #define ButtonModuleName   "Button.mod"    /*!< The button module name */
404 #define UIModuleName       "Ui.mod"        /*!< The Ui module name */
405 #define InputModuleName    "Input.mod"     /*!< The input module name. */
406 #define OutputModuleName   "Output.mod"    /*!< The output module name */
407 #define LowSpeedModuleName "Low Speed.mod" /*!< The low speed module name */
408 #define DisplayModuleName  "Display.mod"   /*!< The display module name */
409 #define CommModuleName     "Comm.mod"      /*!< The Comm module name */
410 /** @} */  // end of ModuleNameConstants group
411 
412 /** @addtogroup ModuleIDConstants
413  * @{
414  */
415 #define CommandModuleID  0x00010001 /*!< The command module ID */
416 #define IOCtrlModuleID   0x00060001 /*!< The IOCtrl module ID */
417 #define LoaderModuleID   0x00090001 /*!< The Loader module ID */
418 #define SoundModuleID    0x00080001 /*!< The sound module ID */
419 #define ButtonModuleID   0x00040001 /*!< The button module ID */
420 #define UIModuleID       0x000C0001 /*!< The Ui module ID */
421 #define InputModuleID    0x00030001 /*!< The input module ID */
422 #define OutputModuleID   0x00020001 /*!< The output module ID */
423 #define LowSpeedModuleID 0x000B0001 /*!< The low speed module ID */
424 #define DisplayModuleID  0x000A0001 /*!< The display module ID */
425 #define CommModuleID     0x00050001 /*!< The Comm module ID */
426 /** @} */  // end of ModuleIDConstants group
427 /** @} */ // end of NXTFirmwareModules group
428 
429 
430 /** @addtogroup CommandModule
431  * @{
432  */
433 /** @addtogroup CommandModuleConstants
434  * @{
435  */
436 //Status/error codes for the VM internal code and bytecodes
437 #define STAT_MSG_EMPTY_MAILBOX 64 /*!< Specified mailbox contains no new messages */
438 #define STAT_COMM_PENDING 32      /*!< Pending setup operation in progress */
439 
440 #define POOL_MAX_SIZE 32768      /*!< Maximum size of memory pool, in bytes */
441 
442 /** @defgroup CommandVMState VM state constants
443  * Constants defining possible VM states.
444  * @{
445  */
446 #define TIMES_UP      6 /*!< VM time is up */
447 #define ROTATE_QUEUE  5 /*!< VM should rotate queue */
448 #define STOP_REQ      4 /*!< VM should stop executing program */
449 #define BREAKOUT_REQ  3 /*!< VM should break out of current thread */
450 #define CLUMP_SUSPEND 2 /*!< VM should suspend thread */
451 #define CLUMP_DONE    1 /*!< VM has finished executing thread */
452 /** @} */  // end of CommandVMState group
453 
454 #define NO_ERR        0 /*!< Successful execution of the specified command */
455 
456 /** @defgroup CommandFatalErrors Fatal errors
457  * Constants defining various fatal error conditions.
458  * @{
459  */
460 #define ERR_ARG             -1 /*!< 0xFF Bad arguments */
461 #define ERR_INSTR           -2 /*!< 0xFE Illegal bytecode instruction */
462 #define ERR_FILE            -3 /*!< 0xFD Malformed file contents */
463 #define ERR_VER             -4 /*!< 0xFC Version mismatch between firmware and compiler */
464 #define ERR_MEM             -5 /*!< 0xFB Insufficient memory available */
465 #define ERR_BAD_PTR         -6 /*!< 0xFA Someone passed us a bad pointer! */
466 #define ERR_CLUMP_COUNT     -7 /*!< 0xF9 (FileClumpCount == 0 || FileClumpCount >= NOT_A_CLUMP) */
467 #define ERR_NO_CODE         -8 /*!< 0xF8 VarsCmd.CodespaceCount == 0 */
468 #define ERR_INSANE_OFFSET   -9 /*!< 0xF7 CurrOffset != (DataSize - VarsCmd.CodespaceCount * 2) */
469 #define ERR_BAD_POOL_SIZE   -10 /*!< 0xF6 VarsCmd.PoolSize > POOL_MAX_SIZE */
470 #define ERR_LOADER_ERR      -11 /*!< 0xF5 LOADER_ERR(LStatus) != SUCCESS || pData == NULL || DataSize == 0 */
471 #define ERR_SPOTCHECK_FAIL  -12 /*!< 0xF4 ((UBYTE*)(VarsCmd.pCodespace) < pData) (c_cmd.c 1893) */
472 #define ERR_NO_ACTIVE_CLUMP -13 /*!< 0xF3 VarsCmd.RunQ.Head == NOT_A_CLUMP */
473 #define ERR_DEFAULT_OFFSETS -14 /*!< 0xF2 (DefaultsOffset != FileOffsets.DynamicDefaults) || (DefaultsOffset + FileOffsets.DynamicDefaultsSize != FileOffsets.DSDefaultsSize) */
474 #define ERR_MEMMGR_FAIL     -15 /*!< 0xF1 (UBYTE *)VarsCmd.MemMgr.pDopeVectorArray != VarsCmd.pDataspace + DV_ARRAY[0].Offset */
475 
476 #define ERR_NON_FATAL -16 /*!< Fatal errors are greater than this value */
477 /** @} */  // end of CommandFatalErrors group
478 
479 /** @defgroup CommandGenErrors General errors
480  * Constants defining general error conditions.
481  * @{
482  */
483 #define ERR_INVALID_PORT   -16 /*!< 0xF0 Bad input or output port specified */
484 #define ERR_INVALID_FIELD  -17 /*!< 0xEF Attempted to access invalid field of a structure */
485 #define ERR_INVALID_QUEUE  -18 /*!< 0xEE Illegal queue ID specified */
486 #define ERR_INVALID_SIZE   -19 /*!< 0xED Illegal size specified */
487 #define ERR_NO_PROG        -20 /*!< 0xEC No active program */
488 /** @} */  // end of CommandGenErrors group
489 
490 /** @defgroup CommandCommErrors Communications specific errors
491  * Constants defining communication error conditions.
492  * @{
493  */
494 #define ERR_COMM_CHAN_NOT_READY -32 /*!< 0xE0 Specified channel/connection not configured or busy */
495 #define ERR_COMM_CHAN_INVALID   -33 /*!< 0xDF Specified channel/connection is not valid */
496 #define ERR_COMM_BUFFER_FULL    -34 /*!< 0xDE No room in comm buffer */
497 #define ERR_COMM_BUS_ERR        -35 /*!< 0xDD Something went wrong on the communications bus */
498 /** @} */  // end of CommandCommErrors group
499 
500 /** @defgroup CommandRCErrors Remote control (direct commands) errors
501  * Constants defining errors that can occur during remote control (RC) direct
502  * command operations.
503  * @{
504  */
505 #define ERR_RC_ILLEGAL_VAL -64 /*!< 0xC0 Data contains out-of-range values */
506 #define ERR_RC_BAD_PACKET  -65 /*!< 0xBF Clearly insane packet */
507 #define ERR_RC_UNKNOWN_CMD -66 /*!< 0xBE Unknown command opcode */
508 #define ERR_RC_FAILED      -67 /*!< 0xBD Request failed (i.e. specified file not found) */
509 /** @} */  // end of CommandRCErrors group
510 
511 /** @defgroup CommandProgStatus Program status constants
512  * Constants defining various states of the command module virtual machine.
513  * @{
514  */
515 #define PROG_IDLE     0 /*!< Program state is idle */
516 #define PROG_OK       1 /*!< Program state is okay */
517 #define PROG_RUNNING  2 /*!< Program is running */
518 #define PROG_ERROR    3 /*!< A program error has occurred */
519 #define PROG_ABORT    4 /*!< Program has been aborted */
520 #define PROG_RESET    5 /*!< Program has been reset */
521 /** @} */  // end of CommandProgStatus group
522 
523 /** @defgroup CommandIOMAP Command module IOMAP offsets
524  * Constant offsets into the Command module IOMAP structure.
525  * @{
526  */
527 #define CommandOffsetFormatString   0 /*!< Offset to the format string */
528 #define CommandOffsetPRCHandler     16 /*!< Offset to the RC Handler function pointer */
529 #define CommandOffsetTick           20 /*!< Offset to the VM's current tick */
530 #define CommandOffsetOffsetDS       24 /*!< Offset to the running program's data space (DS) */
531 #define CommandOffsetOffsetDVA      26 /*!< Offset to the running program's DOPE vector address (DVA) */
532 #define CommandOffsetProgStatus     28 /*!< Offset to the running program's status */
533 #define CommandOffsetAwake          29 /*!< Offset to the VM's awake state */
534 #define CommandOffsetActivateFlag   30 /*!< Offset to the activate flag */
535 #define CommandOffsetDeactivateFlag 31 /*!< Offset to the deactivate flag */
536 #define CommandOffsetFileName       32 /*!< Offset to the running program's filename */
537 #define CommandOffsetMemoryPool     52 /*!< Offset to the VM's memory pool */
538 #if __FIRMWARE_VERSION > 107
539 #define CommandOffsetSyncTime       32820 /*!< Offset to the VM sync time */
540 #define CommandOffsetSyncTick       32824 /*!< Offset to the VM sync tick */
541 #endif
542 /** @} */  // end of CommandIOMAP group
543 
544 /** @} */  // end of CommandModuleConstants group
545 /** @} */  // end of CommandModule group
546 
547 
548 /** @addtogroup IOCtrlModule
549  * @{
550  */
551 /** @defgroup IOCtrlModuleConstants IOCtrl module constants
552  * Constants that are part of the NXT firmware's IOCtrl module.
553  * @{
554  */
555 /** @defgroup IOCtrlPO PowerOn constants
556  * Use these constants to power down the NXT or boot it into SAMBA
557  * (aka firmware download) mode.
558  * @{
559  */
560 #define IOCTRL_POWERDOWN  0x5A00 /*!< Power down the NXT */
561 #define IOCTRL_BOOT       0xA55A /*!< Reboot the NXT into SAMBA mode */
562 /** @} */  // end of IOCtrlPO group
563 
564 /** @defgroup IOCtrlIOMAP IOCtrl module IOMAP offsets
565  * Constant offsets into the IOCtrl module IOMAP structure.
566  * @{
567  */
568 #define IOCtrlOffsetPowerOn 0 /*!< Offset to power on field */
569 /** @} */  // end of IOCtrlIOMAP group
570 
571 /** @} */  // end of IOCtrlModuleConstants group
572 /** @} */  // end of IOCtrlModule group
573 
574 
575 /** @addtogroup LoaderModule
576  * @{
577  */
578 /** @defgroup LoaderModuleConstants Loader module constants
579  * Constants that are part of the NXT firmware's Loader module.
580  * @{
581  */
582 /** @defgroup LoaderIOMAP Loader module IOMAP offsets
583  * Constant offsets into the Loader module IOMAP structure.
584  * @{
585  */
586 #define LoaderOffsetPFunc         0 /*!< Offset to the Loader module function pointer */
587 #define LoaderOffsetFreeUserFlash 4 /*!< Offset to the amount of free user flash */
588 /** @} */  // end of LoaderIOMAP group
589 
590 #define EOF -1 /*!< A constant representing end of file */
591 #define NULL 0 /*!< A constant representing NULL */
592 
593 /** @defgroup LoaderErrors Loader module error codes
594  * Error codes returned by functions in the Loader module (file access).
595  * @{
596  */
597 #define LDR_SUCCESS             0x0000 /*!< The function completed successfully. */
598 #define LDR_INPROGRESS          0x0001 /*!< The function is executing but has not yet completed. */
599 #define LDR_REQPIN              0x0002 /*!< A PIN exchange request is in progress. */
600 #define LDR_NOMOREHANDLES       0x8100 /*!< All available file handles are in use. */
601 #define LDR_NOSPACE             0x8200 /*!< Not enough free flash memory for the specified file size. */
602 #define LDR_NOMOREFILES         0x8300 /*!< The maximum number of files has been reached. */
603 #define LDR_EOFEXPECTED         0x8400 /*!< EOF expected. */
604 #define LDR_ENDOFFILE           0x8500 /*!< The end of the file has been reached. */
605 #define LDR_NOTLINEARFILE       0x8600 /*!< The specified file is not linear. */
606 #define LDR_FILENOTFOUND        0x8700 /*!< No files matched the search criteria. */
607 #define LDR_HANDLEALREADYCLOSED 0x8800 /*!< The file handle has already been closed. */
608 #define LDR_NOLINEARSPACE       0x8900 /*!< Not enough linear flash memory is available. */
609 #define LDR_UNDEFINEDERROR      0x8A00 /*!< An undefined error has occurred. */
610 #define LDR_FILEISBUSY          0x8B00 /*!< The file is already being used. */
611 #define LDR_NOWRITEBUFFERS      0x8C00 /*!< No more write buffers are available. */
612 #define LDR_APPENDNOTPOSSIBLE   0x8D00 /*!< Only datafiles can be appended to. */
613 #define LDR_FILEISFULL          0x8E00 /*!< The allocated file size has been filled. */
614 #define LDR_FILEEXISTS          0x8F00 /*!< A file with the same name already exists. */
615 #define LDR_MODULENOTFOUND      0x9000 /*!< No modules matched the specified search criteria. */
616 #define LDR_OUTOFBOUNDARY       0x9100 /*!< Specified IOMap offset is outside the bounds of the IOMap. */
617 #define LDR_ILLEGALFILENAME     0x9200 /*!< Filename length to long or attempted open a system file (*.rxe, *.rtm, or *.sys) for writing as a datafile. */
618 #define LDR_ILLEGALHANDLE       0x9300 /*!< Invalid file handle. */
619 #define LDR_BTBUSY              0x9400 /*!< The bluetooth system is busy. */
620 #define LDR_BTCONNECTFAIL       0x9500 /*!< Bluetooth connection attempt failed. */
621 #define LDR_BTTIMEOUT           0x9600 /*!< A timeout in the bluetooth system has occurred. */
622 #define LDR_FILETX_TIMEOUT      0x9700 /*!< Error transmitting file: a timeout occurred. */
623 #define LDR_FILETX_DSTEXISTS    0x9800 /*!< Error transmitting file: destination file exists. */
624 #define LDR_FILETX_SRCMISSING   0x9900 /*!< Error transmitting file: source file is missing. */
625 #define LDR_FILETX_STREAMERROR  0x9A00 /*!< Error transmitting file: a stream error occurred. */
626 #define LDR_FILETX_CLOSEERROR   0x9B00 /*!< Error transmitting file: attempt to close file failed. */
627 
628 #if defined(__ENHANCED_FIRMWARE) && (__FIRMWARE_VERSION > 107)
629 #define LDR_INVALIDSEEK         0x9C00 /*!< Invalid file seek operation. */
630 #endif
631 /** @} */  // end of LoaderErrors group
632 
633 /** @defgroup LoaderFunctionConstants Loader module function constants
634  * Constants defining the functions provided by the Loader module.
635  * @{
636  */
637 #define LDR_CMD_OPENREAD        0x80 /*!< Open a file for reading */
638 #define LDR_CMD_OPENWRITE       0x81 /*!< Open a file for writing */
639 #define LDR_CMD_READ            0x82 /*!< Read from a file */
640 #define LDR_CMD_WRITE           0x83 /*!< Write to a file */
641 #define LDR_CMD_CLOSE           0x84 /*!< Close a file handle */
642 #define LDR_CMD_DELETE          0x85 /*!< Delete a file */
643 #define LDR_CMD_FINDFIRST       0x86 /*!< Find the first file matching the specified pattern */
644 #define LDR_CMD_FINDNEXT        0x87 /*!< Find the next file matching the specified pattern */
645 #define LDR_CMD_VERSIONS        0x88 /*!< Read firmware version information */
646 #define LDR_CMD_OPENWRITELINEAR 0x89 /*!< Open a linear file for writing */
647 #define LDR_CMD_OPENREADLINEAR  0x8A /*!< Open a linear file for reading */
648 #define LDR_CMD_OPENWRITEDATA   0x8B /*!< Open a data file for writing */
649 #define LDR_CMD_OPENAPPENDDATA  0x8C /*!< Open a data file for appending */
650 #if __FIRMWARE_VERSION > 107
651 #define LDR_CMD_CROPDATAFILE    0x8D /*!< Crop a data file to its used space */
652 #endif
653 #define LDR_CMD_FINDFIRSTMODULE 0x90 /*!< Find the first module matching the specified pattern */
654 #define LDR_CMD_FINDNEXTMODULE  0x91 /*!< Find the next module matching the specified pattern */
655 #define LDR_CMD_CLOSEMODHANDLE  0x92 /*!< Close a module handle */
656 #define LDR_CMD_IOMAPREAD       0x94 /*!< Read data from a module IOMAP */
657 #define LDR_CMD_IOMAPWRITE      0x95 /*!< Write data to a module IOMAP */
658 #define LDR_CMD_BOOTCMD         0x97 /*!< Reboot the NXT into SAMBA mode */
659 #define LDR_CMD_SETBRICKNAME    0x98 /*!< Set the NXT's brick name */
660 #define LDR_CMD_BTGETADR        0x9A /*!< Get the NXT's bluetooth brick address */
661 #define LDR_CMD_DEVICEINFO      0x9B /*!< Read device information */
662 #define LDR_CMD_DELETEUSERFLASH 0xA0 /*!< Delete all files from user flash memory */
663 #define LDR_CMD_POLLCMDLEN      0xA1 /*!< Read poll command length */
664 #define LDR_CMD_POLLCMD         0xA2 /*!< Poll command */
665 #define LDR_CMD_RENAMEFILE      0xA3 /*!< Rename a file */
666 #define LDR_CMD_BTFACTORYRESET  0xA4 /*!< Reset bluetooth configuration to factory defaults */
667 #if defined(__ENHANCED_FIRMWARE) && (__FIRMWARE_VERSION > 107)
668 #define LDR_CMD_RESIZEDATAFILE  0xD0 /*!< Resize a data file */
669 #define LDR_CMD_SEEKFROMSTART   0xD1 /*!< Seek from the start of the file */
670 #define LDR_CMD_SEEKFROMCURRENT 0xD2 /*!< Seek from the current position */
671 #define LDR_CMD_SEEKFROMEND     0xD3 /*!< Seek from the end of the file */
672 #endif
673 /** @} */  // end of LoaderFunctionConstants group
674 
675 /** @} */  // end of LoaderModuleConstants group
676 /** @} */  // end of LoaderModule group
677 
678 
679 /** @addtogroup SoundModule
680  * @{
681  */
682 /** @defgroup SoundModuleConstants Sound module constants
683  * Constants that are part of the NXT firmware's Sound module.
684  * @{
685  */
686 /** @defgroup SoundFlagsConstants SoundFlags constants
687  * Constants for use with the SoundFlags() function.
688  * \sa SoundFlags()
689  * @{
690  */
691 #define SOUND_FLAGS_IDLE    0x00 /*!< R  - Sound is idle */
692 #define SOUND_FLAGS_UPDATE  0x01 /*!< W  - Make changes take effect */
693 #define SOUND_FLAGS_RUNNING 0x02 /*!< R  - Currently processing a tone or file */
694 /** @} */  // end of SoundFlagsConstants group
695 
696 /** @defgroup SoundStateConstants SoundState constants
697  * Constants for use with the SoundState() function.
698  * \sa SoundState()
699  * @{
700  */
701 #define SOUND_STATE_IDLE 0x00 /*!< R  - Idle, ready for start sound (SOUND_UPDATE) */
702 #define SOUND_STATE_FILE 0x02 /*!< R  - Processing a file of sound/melody data */
703 #define SOUND_STATE_TONE 0x03 /*!< R  - Processing a play tone request */
704 #define SOUND_STATE_STOP 0x04 /*!< W  - Stop sound immediately and close hardware */
705 /** @} */  // end of SoundStateConstants group
706 
707 /** @defgroup SoundModeConstants SoundMode constants
708  * Constants for use with the SoundMode() function.
709  * \sa SoundMode()
710  * @{
711  */
712 #define SOUND_MODE_ONCE 0x00 /*!< W  - Only play file once */
713 #define SOUND_MODE_LOOP 0x01 /*!< W  - Play file until writing SOUND_STATE_STOP into SoundState */
714 #define SOUND_MODE_TONE 0x02 /*!< W  - Play tone specified in Frequency for Duration ms */
715 /** @} */  // end of SoundModeConstants group
716 
717 /** @defgroup SoundIOMAP Sound module IOMAP offsets
718  * Constant offsets into the Sound module IOMAP structure.
719  * @{
720  */
721 #define SoundOffsetFreq           0 /*!< RW - Tone frequency [Hz] (2 bytes) */
722 #define SoundOffsetDuration       2 /*!< RW - Tone duration  [mS] (2 bytes) */
723 #define SoundOffsetSampleRate     4 /*!< RW - Sound file sample rate [2000..16000] (2 bytes) */
724 #define SoundOffsetSoundFilename  6 /*!< RW - Sound/melody filename (20 bytes) */
725 #define SoundOffsetFlags         26 /*!< RW - Play flag  - described above (1 byte) \ref SoundFlagsConstants */
726 #define SoundOffsetState         27 /*!< RW - Play state - described above (1 byte) \ref SoundStateConstants */
727 #define SoundOffsetMode          28 /*!< RW - Play mode  - described above (1 byte) \ref SoundModeConstants */
728 #define SoundOffsetVolume        29 /*!< RW - Sound/melody volume [0..4] 0 = off (1 byte) */
729 /** @} */  // end of SoundIOMAP group
730 
731 /** @defgroup SoundMisc Sound module miscellaneous constants
732  * Constants defining miscellaneous sound module aspects.
733  * @{
734  */
735 #define FREQUENCY_MIN       220       /*!< Minimum frequency [Hz] */
736 #define FREQUENCY_MAX       14080     /*!< Maximum frequency [Hz] */
737 
738 #define SAMPLERATE_MIN      2000      /*!< Min sample rate [sps] */
739 #define SAMPLERATE_DEFAULT  8000      /*!< Default sample rate [sps] */
740 #define SAMPLERATE_MAX      16000     /*!< Max sample rate [sps] */
741 /** @} */  // end of SoundMisc group
742 
743 /** @defgroup ToneConstants Tone constants
744  * Constants for use in the  SoundPlayTone() API function.
745  * \sa SoundPlayTone()
746  * @{
747  */
748 #define TONE_A3               220 /*!< Third octave A */
749 #define TONE_AS3              233 /*!< Third octave A sharp */
750 #define TONE_B3               247 /*!< Third octave B */
751 #define TONE_C4               262 /*!< Fourth octave C */
752 #define TONE_CS4              277 /*!< Fourth octave C sharp */
753 #define TONE_D4               294 /*!< Fourth octave D */
754 #define TONE_DS4              311 /*!< Fourth octave D sharp */
755 #define TONE_E4               330 /*!< Fourth octave E */
756 #define TONE_F4               349 /*!< Fourth octave F */
757 #define TONE_FS4              370 /*!< Fourth octave F sharp */
758 #define TONE_G4               392 /*!< Fourth octave G */
759 #define TONE_GS4              415 /*!< Fourth octave G sharp */
760 #define TONE_A4               440 /*!< Fourth octave A */
761 #define TONE_AS4              466 /*!< Fourth octave A sharp */
762 #define TONE_B4               494 /*!< Fourth octave B */
763 #define TONE_C5               523 /*!< Fifth octave C */
764 #define TONE_CS5              554 /*!< Fifth octave C sharp */
765 #define TONE_D5               587 /*!< Fifth octave D */
766 #define TONE_DS5              622 /*!< Fifth octave D sharp */
767 #define TONE_E5               659 /*!< Fifth octave E */
768 #define TONE_F5               698 /*!< Fifth octave F */
769 #define TONE_FS5              740 /*!< Fifth octave F sharp */
770 #define TONE_G5               784 /*!< Fifth octave G */
771 #define TONE_GS5              831 /*!< Fifth octave G sharp */
772 #define TONE_A5               880 /*!< Fifth octave A */
773 #define TONE_AS5              932 /*!< Fifth octave A sharp */
774 #define TONE_B5               988 /*!< Fifth octave B */
775 #define TONE_C6               1047 /*!< Sixth octave C */
776 #define TONE_CS6              1109 /*!< Sixth octave C sharp */
777 #define TONE_D6               1175 /*!< Sixth octave D */
778 #define TONE_DS6              1245 /*!< Sixth octave D sharp */
779 #define TONE_E6               1319 /*!< Sixth octave E */
780 #define TONE_F6               1397 /*!< Sixth octave F */
781 #define TONE_FS6              1480 /*!< Sixth octave F sharp */
782 #define TONE_G6               1568 /*!< Sixth octave G */
783 #define TONE_GS6              1661 /*!< Sixth octave G sharp */
784 #define TONE_A6               1760 /*!< Sixth octave A */
785 #define TONE_AS6              1865 /*!< Sixth octave A sharp */
786 #define TONE_B6               1976 /*!< Sixth octave B */
787 #define TONE_C7               2093 /*!< Seventh octave C */
788 #define TONE_CS7              2217 /*!< Seventh octave C sharp */
789 #define TONE_D7               2349 /*!< Seventh octave D */
790 #define TONE_DS7              2489 /*!< Seventh octave D sharp */
791 #define TONE_E7               2637 /*!< Seventh octave E */
792 #define TONE_F7               2794 /*!< Seventh octave F */
793 #define TONE_FS7              2960 /*!< Seventh octave F sharp */
794 #define TONE_G7               3136 /*!< Seventh octave G */
795 #define TONE_GS7              3322 /*!< Seventh octave G sharp */
796 #define TONE_A7               3520 /*!< Seventh octave A */
797 #define TONE_AS7              3729 /*!< Seventh octave A sharp */
798 #define TONE_B7               3951 /*!< Seventh octave B */
799 /** @} */  // end of ToneConstants group
800 
801 /** @} */  // end of SoundModuleConstants group
802 /** @} */  // end of SoundModule group
803 
804 
805 /** @addtogroup ButtonModule
806  * @{
807  */
808 /** @defgroup ButtonModuleConstants Button module constants
809  * Constants that are part of the NXT firmware's Button module.
810  * @{
811  */
812 /** @defgroup ButtonNameConstants Button name constants
813  * Constants to specify which button to use with button module functions.
814  * \sa ButtonPressed(), ButtonState(), ButtonCount(), ReadButtonEx(),
815  * SysReadButton(), ReadButtonType
816  * @{
817  */
818 #define BTN1 0 /*!< The exit button. */
819 #define BTN2 1 /*!< The right button. */
820 #define BTN3 2 /*!< The left button. */
821 #define BTN4 3 /*!< The enter button. */
822 
823 #define BTNEXIT   BTN1 /*!< The exit button. */
824 #define BTNRIGHT  BTN2 /*!< The right button. */
825 #define BTNLEFT   BTN3 /*!< The left button. */
826 #define BTNCENTER BTN4 /*!< The enter button. */
827 
828 #define NO_OF_BTNS 4 /*!< The number of NXT buttons. */
829 /** @} */  // end of ButtonNameConstants group
830 
831 /** @defgroup ButtonStateConstants ButtonState constants
832  * Constants for use with the ButtonState() function. The _EV values can be
833  * combined together using a bitwise OR operation.
834  * \sa ButtonState()
835  * @{
836  */
837 #define BTNSTATE_PRESSED_EV         0x01 /*!< Button is in the pressed state. */
838 #define BTNSTATE_SHORT_RELEASED_EV  0x02 /*!< Button is in the short released state. */
839 #define BTNSTATE_LONG_PRESSED_EV    0x04 /*!< Button is in the long pressed state. */
840 #define BTNSTATE_LONG_RELEASED_EV   0x08 /*!< Button is in the long released state. */
841 #define BTNSTATE_PRESSED_STATE      0x80 /*!< A bitmask for the button pressed state */
842 #define BTNSTATE_NONE               0x10 /*!< The default button state. */
843 /** @} */  // end of ButtonStateConstants group
844 
845 /** @defgroup ButtonIOMAP Button module IOMAP offsets
846  * Constant offsets into the Button module IOMAP structure.
847  * @{
848  */
849 #define ButtonOffsetPressedCnt(b)   (((b)*8)+0) /*!< Offset to the PressedCnt field. This field stores the press count. */
850 #define ButtonOffsetLongPressCnt(b) (((b)*8)+1) /*!< Offset to the LongPressCnt field. This field stores the long press count.*/
851 #define ButtonOffsetShortRelCnt(b)  (((b)*8)+2) /*!< Offset to the ShortRelCnt field. This field stores the short release count. */
852 #define ButtonOffsetLongRelCnt(b)   (((b)*8)+3) /*!< Offset to the LongRelCnt field. This field stores the long release count. */
853 #define ButtonOffsetRelCnt(b)       (((b)*8)+4) /*!< Offset to the RelCnt field. This field stores the release count. */
854 #define ButtonOffsetState(b)        ((b)+32)    /*!< Offset to the State field. This field stores the current button state. */
855 /** @} */  // end of ButtonIOMAP group
856 /** @} */  // end of ButtonModuleConstants group
857 /** @} */  // end of ButtonModule group
858 
859 
860 /** @addtogroup UiModule
861  * @{
862  */
863 /** @defgroup UiModuleConstants Ui module constants
864  * Constants that are part of the NXT firmware's Ui module.
865  * @{
866  */
867 /** @defgroup UiFlagsConstants CommandFlags constants
868  * Constants for use with the CommandFlags() function.
869  * \sa CommandFlags()
870  * @{
871  */
872 #define UI_FLAGS_UPDATE                   0x01 /*!< W  - Make changes take effect */
873 #define UI_FLAGS_DISABLE_LEFT_RIGHT_ENTER 0x02 /*!< RW - Disable left, right and enter button */
874 #define UI_FLAGS_DISABLE_EXIT             0x04 /*!< RW - Disable exit button */
875 #define UI_FLAGS_REDRAW_STATUS            0x08 /*!< W  - Redraw entire status line */
876 #define UI_FLAGS_RESET_SLEEP_TIMER        0x10 /*!< W  - Reset sleep timeout timer */
877 #define UI_FLAGS_EXECUTE_LMS_FILE         0x20 /*!< W  - Execute LMS file in "LMSfilename" (Try It) */
878 #define UI_FLAGS_BUSY                     0x40 /*!< R  - UI busy running or datalogging (popup disabled) */
879 #define UI_FLAGS_ENABLE_STATUS_UPDATE     0x80 /*!< W  - Enable status line to be updated */
880 /** @} */  // end of UiFlagsConstants group
881 
882 /** @defgroup UiStateConstants UIState constants
883  * Constants for use with the UIState() function.
884  * \sa UIState()
885  * @{
886  */
887 #define UI_STATE_INIT_DISPLAY       0 /*!< RW - Init display and load font, menu etc. */
888 #define UI_STATE_INIT_LOW_BATTERY   1 /*!< R  - Low battery voltage at power on */
889 #define UI_STATE_INIT_INTRO         2 /*!< R  - Display intro */
890 #define UI_STATE_INIT_WAIT          3 /*!< RW - Wait for initialization end */
891 #define UI_STATE_INIT_MENU          4 /*!< RW - Init menu system */
892 #define UI_STATE_NEXT_MENU          5 /*!< RW - Next menu icons ready for drawing */
893 #define UI_STATE_DRAW_MENU          6 /*!< RW - Execute function and draw menu icons */
894 #define UI_STATE_TEST_BUTTONS       7 /*!< RW - Wait for buttons to be pressed */
895 #define UI_STATE_LEFT_PRESSED       8 /*!< RW - Load selected function and next menu id */
896 #define UI_STATE_RIGHT_PRESSED      9 /*!< RW - Load selected function and next menu id */
897 #define UI_STATE_ENTER_PRESSED     10 /*!< RW - Load selected function and next menu id */
898 #define UI_STATE_EXIT_PRESSED      11 /*!< RW - Load selected function and next menu id */
899 #define UI_STATE_CONNECT_REQUEST   12 /*!< RW - Request for connection accept */
900 #define UI_STATE_EXECUTE_FILE      13 /*!< RW - Execute file in "LMSfilename" */
901 #define UI_STATE_EXECUTING_FILE    14 /*!< R  - Executing file in "LMSfilename" */
902 #define UI_STATE_LOW_BATTERY       15 /*!< R  - Low battery at runtime */
903 #define UI_STATE_BT_ERROR          16 /*!< R  - BT error */
904 /** @} */  // end of UiStateConstants group
905 
906 /** @defgroup UiButtonConstants UIButton constants
907  * Constants for use with the UIButton() function.
908  * \sa UIButton()
909  * @{
910  */
911 #define UI_BUTTON_NONE             0 /*!< R  - Button inserted are executed */
912 #define UI_BUTTON_LEFT             1 /*!< W  - Insert left arrow button */
913 #define UI_BUTTON_ENTER            2 /*!< W  - Insert enter button */
914 #define UI_BUTTON_RIGHT            3 /*!< W  - Insert right arrow button */
915 #define UI_BUTTON_EXIT             4 /*!< W  - Insert exit button */
916 /** @} */  // end of UiButtonConstants group
917 
918 /** @defgroup UiBluetoothStateConstants BluetoothState constants
919  * Constants for use with the BluetoothState() function.
920  * \sa BluetoothState()
921  * @{
922  */
923 #define UI_BT_STATE_VISIBLE        0x01 /*!< RW - BT visible */
924 #define UI_BT_STATE_CONNECTED      0x02 /*!< RW - BT connected to something */
925 #define UI_BT_STATE_OFF            0x04 /*!< RW - BT power off */
926 #define UI_BT_ERROR_ATTENTION      0x08 /*!< W  - BT error attention */
927 #define UI_BT_CONNECT_REQUEST      0x40 /*!< RW - BT get connect accept in progress */
928 #define UI_BT_PIN_REQUEST          0x80 /*!< RW - BT get pin code */
929 /** @} */  // end of UiBluetoothStateConstants group
930 
931 /** @defgroup UiVMRunStateConstants VM run state constants
932  * Constants for use with the VMRunState() function.
933  * \sa VMRunState()
934  * @{
935  */
936 #define UI_VM_IDLE        0 /*!< VM_IDLE: Just sitting around.  Request to run program will lead to ONE of the VM_RUN* states. */
937 #define UI_VM_RUN_FREE    1 /*!< VM_RUN_FREE: Attempt to run as many instructions as possible within our timeslice */
938 #define UI_VM_RUN_SINGLE  2 /*!< VM_RUN_SINGLE: Run exactly one instruction per timeslice */
939 #define UI_VM_RUN_PAUSE   3 /*!< VM_RUN_PAUSE: Program still "active", but someone has asked us to pause */
940 #define UI_VM_RESET1      4 /*!< VM_RESET1: Initialize state variables and some I/O devices -- executed when programs end */
941 #define UI_VM_RESET2      5 /*!< VM_RESET2: Final clean up and return to IDLE */
942 /** @} */  // end of UiVMRunStateConstants group
943 
944 /** @defgroup UiIOMAP Ui module IOMAP offsets
945  * Constant offsets into the Ui module IOMAP structure.
946  * @{
947  */
948 #define UIOffsetPMenu            0 /*!< W  - Pointer to menu file (4 bytes) */
949 #define UIOffsetBatteryVoltage   4 /*!< R  - Battery voltage in millivolts (2 bytes) */
950 #define UIOffsetLMSfilename      6 /*!< W  - LMS filename to execute (Try It) (20 bytes) */
951 #define UIOffsetFlags           26 /*!< RW - Update command flags  (flags enumerated above) (1 byte) */
952 #define UIOffsetState           27 /*!< RW - UI state              (states enumerated above) (1 byte) */
953 #define UIOffsetButton          28 /*!< RW - Insert button         (buttons enumerated above) (1 byte) */
954 #define UIOffsetRunState        29 /*!< W  - VM Run state          (0 = stopped, 1 = running) (1 byte) */
955 #define UIOffsetBatteryState    30 /*!< W  - Battery state         (0..4 capacity) (1 byte) */
956 #define UIOffsetBluetoothState  31 /*!< W  - Bluetooth state       (0=on, 1=visible, 2=conn, 3=conn.visible, 4=off, 5=dfu) (1 byte) */
957 #define UIOffsetUsbState        32 /*!< W  - Usb state             (0=disconnected, 1=connected, 2=working) (1 byte) */
958 #define UIOffsetSleepTimeout    33 /*!< RW - Sleep timeout time    (min) (1 byte) */
959 #define UIOffsetSleepTimer      34 /*!< RW - Sleep timer           (min) (1 byte) */
960 #define UIOffsetRechargeable    35 /*!< R  - Rechargeable battery  (0 = no, 1 = yes) (1 byte) */
961 #define UIOffsetVolume          36 /*!< RW - Volume used in UI     (0 - 4) (1 byte) */
962 #define UIOffsetError           37 /*!< W  - Error code (1 byte) */
963 #define UIOffsetOBPPointer      38 /*!< W  - Actual OBP step       (0 - 4) (1 byte) */
964 #define UIOffsetForceOff        39 /*!< W  - Force off             (> 0 = off) (1 byte) */
965 #define UIOffsetAbortFlag       40 /*!< RW - Long Abort            (true == use long press to abort) (1 byte) */
966 /** @} */  // end of UiIOMAP group
967 
968 /** @} */  // end of UiModuleConstants group
969 /** @} */  // end of UiModule group
970 
971 
972 /** @addtogroup InputModule
973  * @{
974  */
975 /** @addtogroup InputModuleConstants
976  * @{
977  */
978 
979 /** @defgroup NBCInputPortConstants NBC Input port constants
980  * Input port constants are used when calling sensor control API functions.
981  * These constants are intended for use in NBC.
982  * \sa SetSensorType(), SetSensorMode(), S1, S2, S3, S4
983  * @{
984  */
985 #define IN_1 0x00 /*!< Input port 1 */
986 #define IN_2 0x01 /*!< Input port 2 */
987 #define IN_3 0x02 /*!< Input port 3 */
988 #define IN_4 0x03 /*!< Input port 4 */
989 /** @} */  // end of InputPortConstants group
990 
991 /** @addtogroup InputModuleTypesAndModes
992  * @{
993  */
994 /** @defgroup NBCSensorTypeConstants NBC sensor type constants
995  * Use sensor type constants to configure an input port for a specific type
996  * of sensor. These constants are intended for use in NBC.
997  * \sa SetSensorType()
998  * @{
999  */
1000 #define IN_TYPE_NO_SENSOR      0x00 /*!< No sensor configured */
1001 #define IN_TYPE_SWITCH         0x01 /*!< NXT or RCX touch sensor */
1002 #define IN_TYPE_TEMPERATURE    0x02 /*!< RCX temperature sensor */
1003 #define IN_TYPE_REFLECTION     0x03 /*!< RCX light sensor */
1004 #define IN_TYPE_ANGLE          0x04 /*!< RCX rotation sensor */
1005 #define IN_TYPE_LIGHT_ACTIVE   0x05 /*!< NXT light sensor with light */
1006 #define IN_TYPE_LIGHT_INACTIVE 0x06 /*!< NXT light sensor without light */
1007 #define IN_TYPE_SOUND_DB       0x07 /*!< NXT sound sensor with dB scaling */
1008 #define IN_TYPE_SOUND_DBA      0x08 /*!< NXT sound sensor with dBA scaling */
1009 #define IN_TYPE_CUSTOM         0x09 /*!< NXT custom sensor */
1010 #define IN_TYPE_LOWSPEED       0x0A /*!< NXT I2C digital sensor */
1011 #define IN_TYPE_LOWSPEED_9V    0x0B /*!< NXT I2C digital sensor with 9V power */
1012 #define IN_TYPE_HISPEED        0x0C /*!< NXT Hi-speed port (only S4) */
1013 #if __FIRMWARE_VERSION > 107
1014 #define IN_TYPE_COLORFULL      0x0D /*!< NXT 2.0 color sensor in full color mode */
1015 #define IN_TYPE_COLORRED       0x0E /*!< NXT 2.0 color sensor with red light */
1016 #define IN_TYPE_COLORGREEN     0x0F /*!< NXT 2.0 color sensor with green light */
1017 #define IN_TYPE_COLORBLUE      0x10 /*!< NXT 2.0 color sensor with blue light */
1018 #define IN_TYPE_COLORNONE      0x11 /*!< NXT 2.0 color sensor with no light */
1019 #define IN_TYPE_COLOREXIT      0x12 /*!< NXT 2.0 color sensor internal state */
1020 #endif
1021 /** @} */  // end of NBCSensorTypeConstants group
1022 
1023 /** @defgroup NBCSensorModeConstants NBC sensor mode constants
1024  * Use sensor mode constants to configure an input port for the desired
1025  * sensor mode. The constants are intended for use in NBC.
1026  * \sa SetSensorMode()
1027  * @{
1028  */
1029 #define IN_MODE_RAW           0x00 /*!< Raw value from 0 to 1023 */
1030 #define IN_MODE_BOOLEAN       0x20 /*!< Boolean value (0 or 1) */
1031 #define IN_MODE_TRANSITIONCNT 0x40 /*!< Counts the number of boolean transitions */
1032 #define IN_MODE_PERIODCOUNTER 0x60 /*!< Counts the number of boolean periods */
1033 #define IN_MODE_PCTFULLSCALE  0x80 /*!< Scaled value from 0 to 100 */
1034 #define IN_MODE_CELSIUS       0xA0 /*!< RCX temperature sensor value in degrees celcius */
1035 #define IN_MODE_FAHRENHEIT    0xC0 /*!< RCX temperature sensor value in degrees fahrenheit */
1036 #define IN_MODE_ANGLESTEP     0xE0 /*!< RCX rotation sensor (16 ticks per revolution) */
1037 #define IN_MODE_SLOPEMASK     0x1F /*!< Mask for slope parameter added to mode */
1038 #define IN_MODE_MODEMASK      0xE0 /*!< Mask for the mode without any slope value */
1039 /** @} */  // end of NBCSensorModeConstants group
1040 /** @} */  // end of InputModuleTypesAndModes group
1041 
1042 /** @defgroup InputFieldConstants Input field constants
1043  * Constants for use with SetInput() and GetInput().
1044  * Each sensor has six fields that are used to define its state.
1045  * @{
1046  */
1047 #define TypeField            0 /*!< Type field. Contains one of the sensor type constants. Read/write. */
1048 #define InputModeField       1 /*!< Input mode field. Contains one of the sensor mode constants. Read/write. */
1049 #define RawValueField        2 /*!< Raw value field. Contains the current raw analog sensor value. Read only. */
1050 #define NormalizedValueField 3 /*!< Normalized value field. Contains the current normalized analog sensor value. Read only. */
1051 #define ScaledValueField     4 /*!< Scaled value field. Contains the current scaled analog sensor value. Read/write. */
1052 #define InvalidDataField     5 /*!< Invalid data field. Contains a boolean value indicating whether the sensor data is valid or not. Read/write. */
1053 /** @} */  // end of InputFieldConstants group
1054 
1055 /** @defgroup InputDigiPinConstants Input port digital pin constants
1056  * Constants for use when directly controlling or reading a port's digital pin
1057  * state.
1058  * @{
1059  */
1060 #define INPUT_DIGI0    0x01 /*!< Digital pin 0 */
1061 #define INPUT_DIGI1    0x02 /*!< Digital pin 1*/
1062 /** @} */  // end of InputDigiPinConstants group
1063 
1064 #define INPUT_CUSTOMINACTIVE 0x00 /*!< Custom sensor inactive */
1065 #define INPUT_CUSTOM9V       0x01 /*!< Custom sensor 9V */
1066 #define INPUT_CUSTOMACTIVE   0x02 /*!< Custom sensor active */
1067 
1068 #define INPUT_INVALID_DATA   0x01 /*!< Invalid data flag */
1069 
1070 #if __FIRMWARE_VERSION > 107
1071 
1072 /** @defgroup InputColorIdxConstants Color sensor array indices
1073  * Constants for use with color sensor value arrays to index RGB and blank
1074  * return values.
1075  * \sa ReadSensorColorEx(), ReadSensorColorRaw(), SysColorSensorRead(),
1076  * ColorSensorReadType
1077  * @{
1078  */
1079 #define INPUT_RED          0 /*!< Access the red value from color sensor value arrays */
1080 #define INPUT_GREEN        1 /*!< Access the green value from color sensor value arrays */
1081 #define INPUT_BLUE         2 /*!< Access the blue value from color sensor value arrays */
1082 #define INPUT_BLANK        3 /*!< Access the blank value from color sensor value arrays */
1083 #define INPUT_NO_OF_COLORS 4 /*!< The number of entries in the color sensor value arrays */
1084 /** @} */  // end of InputColorIdxConstants group
1085 
1086 /** @defgroup InputColorValueConstants Color values
1087  * Constants for use with the ColorValue returned by the color sensor in full
1088  * color mode.
1089  * \sa SensorValue(), SysColorSensorRead(), ColorSensorReadType
1090  * @{
1091  */
1092 #define INPUT_BLACKCOLOR  1 /*!< The color value is black */
1093 #define INPUT_BLUECOLOR   2 /*!< The color value is blue */
1094 #define INPUT_GREENCOLOR  3 /*!< The color value is green */
1095 #define INPUT_YELLOWCOLOR 4 /*!< The color value is yellow */
1096 #define INPUT_REDCOLOR    5 /*!< The color value is red */
1097 #define INPUT_WHITECOLOR  6 /*!< The color value is white */
1098 /** @} */  // end of InputColorIdxConstants group
1099 
1100 /** @defgroup InputColorCalibrationStateConstants Color calibration state constants
1101  * Constants for use with the color calibration state function.
1102  * \sa ColorCalibrationState()
1103  * @{
1104  */
1105 #define INPUT_SENSORCAL  0x01 /*!< The state returned while the color sensor is calibrating */
1106 #define INPUT_SENSOROFF  0x02 /*!< The state returned once calibration has completed */
1107 #define INPUT_RUNNINGCAL 0x20 /*!< Unused calibration state constant */
1108 #define INPUT_STARTCAL   0x40 /*!< Unused calibration state constant */
1109 #define INPUT_RESETCAL   0x80 /*!< Unused calibration state constant */
1110 /** @} */  // end of InputColorCalibrationStateConstants group
1111 
1112 /** @defgroup InputColorCalibrationConstants Color calibration constants
1113  * Constants for use with the color calibration functions.
1114  * \sa ColorCalibration(), ColorCalLimits()
1115  * @{
1116  */
1117 #define INPUT_CAL_POINT_0  0 /*!< Calibration point 0 */
1118 #define INPUT_CAL_POINT_1  1 /*!< Calibration point 1 */
1119 #define INPUT_CAL_POINT_2  2 /*!< Calibration point 2 */
1120 #define INPUT_NO_OF_POINTS 3 /*!< The number of calibration points */
1121 /** @} */  // end of InputColorCalibrationConstants group
1122 
1123 #endif
1124 
1125 /** @defgroup InputIOMAP Input module IOMAP offsets
1126  * Constant offsets into the Input module IOMAP structure.
1127  * @{
1128  */
1129 #define InputOffsetCustomZeroOffset(p)   (((p)*20)+0)  /*!< Read/write the zero offset of a custom sensor (2 bytes) uword */
1130 #define InputOffsetADRaw(p)              (((p)*20)+2)  /*!< Read the AD raw sensor value (2 bytes) uword */
1131 #define InputOffsetSensorRaw(p)          (((p)*20)+4)  /*!< Read the raw sensor value (2 bytes) uword */
1132 #define InputOffsetSensorValue(p)        (((p)*20)+6)  /*!< Read/write the scaled sensor value (2 bytes) sword */
1133 #define InputOffsetSensorType(p)         (((p)*20)+8)  /*!< Read/write the sensor type */
1134 #define InputOffsetSensorMode(p)         (((p)*20)+9)  /*!< Read/write the sensor mode */
1135 #define InputOffsetSensorBoolean(p)      (((p)*20)+10) /*!< Read the sensor boolean value */
1136 #define InputOffsetDigiPinsDir(p)        (((p)*20)+11) /*!< Read/write the direction of the Digital pins (1 is output, 0 is input) */
1137 #define InputOffsetDigiPinsIn(p)         (((p)*20)+12) /*!< Read/write the status of the digital pins */
1138 #define InputOffsetDigiPinsOut(p)        (((p)*20)+13) /*!< Read/write the output level of the digital pins */
1139 #define InputOffsetCustomPctFullScale(p) (((p)*20)+14) /*!< Read/write the Pct full scale of the custom sensor */
1140 #define InputOffsetCustomActiveStatus(p) (((p)*20)+15) /*!< Read/write the active or inactive state of the custom sensor */
1141 #define InputOffsetInvalidData(p)        (((p)*20)+16) /*!< Indicates whether data is invalid (1) or valid (0) */
1142 
1143 #if __FIRMWARE_VERSION > 107
1144 #define InputOffsetColorCalibration(p, np, nc) (80+((p)*84)+0+((np)*16)+((nc)*4)) /*!< Read/write color calibration point values */
1145 #define InputOffsetColorCalLimits(p, np)       (80+((p)*84)+48+((np)*2)) /*!< Read/write color calibration limits */
1146 #define InputOffsetColorADRaw(p, nc)           (80+((p)*84)+52+((nc)*2)) /*!< Read AD raw color sensor values */
1147 #define InputOffsetColorSensorRaw(p, nc)       (80+((p)*84)+60+((nc)*2)) /*!< Read raw color sensor values */
1148 #define InputOffsetColorSensorValue(p, nc)     (80+((p)*84)+68+((nc)*2)) /*!< Read scaled color sensor values */
1149 #define InputOffsetColorBoolean(p, nc)         (80+((p)*84)+76+((nc)*2)) /*!< Read color sensor boolean values */
1150 #define InputOffsetColorCalibrationState(p)    (80+((p)*84)+80)          /*!< Read color sensor calibration state */
1151 #endif
1152 /** @} */  // end of InputIOMap group
1153 /** @} */  // end of InputModuleConstants group
1154 /** @} */  // end of InputModule group
1155 
1156 
1157 /** @addtogroup OutputModule
1158  * @{
1159  */
1160 /** @addtogroup OutputModuleConstants
1161  * @{
1162  */
1163 /** @defgroup OutputPortConstants Output port constants
1164  * Output port constants are used when calling motor control API functions.
1165  * @{
1166  */
1167 #define OUT_A   0x00 /*!< Output port A */
1168 #define OUT_B   0x01 /*!< Output port B */
1169 #define OUT_C   0x02 /*!< Output port C */
1170 #define OUT_AB  0x03 /*!< Output ports A and B */
1171 #define OUT_AC  0x04 /*!< Output ports A and C */
1172 #define OUT_BC  0x05 /*!< Output ports B and C */
1173 #define OUT_ABC 0x06 /*!< Output ports A, B, and C */
1174 /** @} */  // end of OutputPortConstants group
1175 
1176 /** @defgroup PIDConstants PID constants
1177  * PID constants are for adjusting the Proportional, Integral, and Derivative
1178  * motor controller parameters.
1179  * \sa RotateMotorExPID(), RotateMotorPID(), OnFwdExPID(), OnRevExPID(),
1180  * \sa OnFwdRegExPID(), OnRevRegExPID(), OnFwdRegPID(), OnRevRegPID(),
1181  * \sa OnFwdSyncExPID(), OnRevSyncExPID(), OnFwdSyncPID(), OnRevSyncPID()
1182  * @{
1183  */
1184 #define PID_0   0 /*!< PID zero */
1185 #define PID_1  32 /*!< PID one */
1186 #define PID_2  64 /*!< PID two */
1187 #define PID_3  96 /*!< PID three */
1188 #define PID_4 128 /*!< PID four */
1189 #define PID_5 160 /*!< PID five */
1190 #define PID_6 192 /*!< PID six */
1191 #define PID_7 224 /*!< PID seven */
1192 /** @} */  // end of PIDConstants group
1193 
1194 /** @defgroup OutUFConstants Output port update flag constants
1195  * Use these constants to specify which motor values need to be updated.
1196  * Update flag constants can be combined with bitwise OR.
1197  * \sa SetOutput()
1198  * @{
1199  */
1200 #define UF_UPDATE_MODE                 0x01 /*!< Commits changes to the \ref OutputModeField output property */
1201 #define UF_UPDATE_SPEED                0x02 /*!< Commits changes to the \ref PowerField output property */
1202 #define UF_UPDATE_TACHO_LIMIT          0x04 /*!< Commits changes to the \ref TachoLimitField output property */
1203 #define UF_UPDATE_RESET_COUNT          0x08 /*!< Resets all rotation counters, cancels the current goal, and resets the rotation error-correction system */
1204 #define UF_UPDATE_PID_VALUES           0x10 /*!< Commits changes to the PID motor regulation properties */
1205 #define UF_UPDATE_RESET_BLOCK_COUNT    0x20 /*!< Resets the NXT-G block-relative rotation counter */
1206 #define UF_UPDATE_RESET_ROTATION_COUNT 0x40 /*!< Resets the program-relative (user) rotation counter */
1207 #define UF_PENDING_UPDATES             0x80 /*!< Are there any pending motor updates? */
1208 /** @} */  // end of OutUFConstants group
1209 
1210 /** @defgroup TachoResetConstants Tachometer counter reset flags
1211  * Use these constants to specify which of the three tachometer counters
1212  * should be reset. Reset constants can be combined with bitwise OR.
1213  * \sa OnFwdEx(), OnRevEx(), etc...
1214  * @{
1215  */
1216 #define RESET_NONE           0x00 /*!< No counters will be reset */
1217 #define RESET_COUNT          0x08 /*!< Reset the internal tachometer counter */
1218 #define RESET_BLOCK_COUNT    0x20 /*!< Reset the NXT-G block tachometer counter */
1219 #define RESET_ROTATION_COUNT 0x40 /*!< Reset the rotation counter */
1220 #define RESET_BLOCKANDTACHO  0x28 /*!< Reset both the internal counter and the NXT-G block counter */
1221 #define RESET_ALL            0x68 /*!< Reset all three tachometer counters */
1222 /** @} */  // end of TachoResetConstants group
1223 
1224 /** @defgroup OutModeConstants Output port mode constants
1225  * Use these constants to configure the desired mode for the
1226  * specified motor(s): coast, motoron, brake, or regulated. Mode constants
1227  * can be combined with bitwise OR.
1228  * \sa SetOutput()
1229  * @{
1230  */
1231 #define OUT_MODE_COAST     0x00 /*!< No power and no braking so motors rotate freely. */
1232 #define OUT_MODE_MOTORON   0x01 /*!< Enables PWM power to the outputs given the power setting */
1233 #define OUT_MODE_BRAKE     0x02 /*!< Uses electronic braking to outputs */
1234 #define OUT_MODE_REGULATED 0x04 /*!< Enables active power regulation using the regulation mode value */
1235 #define OUT_MODE_REGMETHOD 0xF0 /*!< Mask for unimplemented regulation mode */
1236 /** @} */  // end of OutModeConstants group
1237 
1238 #if defined(__ENHANCED_FIRMWARE) && (__FIRMWARE_VERSION > 107)
1239 /** @defgroup OutOptionConstants Output port option constants
1240  * Use these constants to configure the desired options for the
1241  * specified motor(s): hold at limit and ramp down to limit. Option constants
1242  * can be combined with bitwise OR.
1243  * \sa SetOutput()
1244  * @{
1245  */
1246 #define OUT_OPTION_HOLDATLIMIT     0x10 /*!< Option to have the firmware hold the motor when it reaches the tachometer limit */
1247 #define OUT_OPTION_RAMPDOWNTOLIMIT 0x20 /*!< Option to have the firmware rampdown the motor power as it approaches the tachometer limit */
1248 /** @} */  // end of OutOptionConstants group
1249 
1250 /** @defgroup OutRegOptionConstants Output regulation option constants
1251  * Use these constants to configure the desired options for
1252  * position regulation.
1253  * @{
1254  */
1255 #define OUT_REGOPTION_NO_SATURATION 0x01 /*!< Do not limit intermediary regulation results */
1256 /** @} */  // end of OutRegOptionConstants group
1257 #endif
1258 
1259 /** @defgroup OutRunStateConstants Output port run state constants
1260  * Use these constants to configure the desired run state for the
1261  * specified motor(s): idle, rampup, running, rampdown, or hold.
1262  * \sa SetOutput()
1263  * @{
1264  */
1265 #define OUT_RUNSTATE_IDLE     0x00 /*!< Disable all power to motors. */
1266 #define OUT_RUNSTATE_RAMPUP   0x10 /*!< Enable ramping up from a current power to a new (higher) power over a specified \ref TachoLimitField goal. */
1267 #define OUT_RUNSTATE_RUNNING  0x20 /*!< Enable power to motors at the specified power level. */
1268 #define OUT_RUNSTATE_RAMPDOWN 0x40 /*!< Enable ramping down from a current power to a new (lower) power over a specified \ref TachoLimitField goal. */
1269 #define OUT_RUNSTATE_HOLD     0x60 /*!< Set motor run state to hold at the current position. */
1270 /** @} */  // end of OutRunStateConstants group
1271 
1272 /** @defgroup OutRegModeConstants Output port regulation mode constants
1273  * Use these constants to configure the desired regulation mode for the
1274  * specified motor(s): none, speed regulation, multi-motor synchronization,
1275  * or position regulation (requires the enhanced NBC/NXC firmware version 1.31+).
1276  * \sa SetOutput()
1277  * @{
1278  */
1279 #define OUT_REGMODE_IDLE  0 /*!< No motor regulation. */
1280 #define OUT_REGMODE_SPEED 1 /*!< Regulate a motor's speed (aka power). */
1281 #define OUT_REGMODE_SYNC  2 /*!< Synchronize the rotation of two motors. */
1282 #define OUT_REGMODE_POS   4 /*!< Regulate a motor's position. */
1283 /** @} */  // end of OutRegModeConstants group
1284 
1285 /** @defgroup OutputFieldConstants Output field constants
1286  * Constants for use with SetOutput() and GetOutput().
1287  * \sa SetOutput(), GetOutput()
1288  * @{
1289  */
1290 /** Update flags field. Contains a combination of the update flag constants. Read/write.
1291  *  Use \ref UF_UPDATE_MODE, \ref UF_UPDATE_SPEED, \ref UF_UPDATE_TACHO_LIMIT, and \ref UF_UPDATE_PID_VALUES
1292  *  along with other fields to commit changes to the state of outputs. Set the appropriate
1293  *  flags after setting one or more of the output fields in order for the changes to actually
1294  *  go into affect. */
1295 #define UpdateFlagsField     0
1296 /** Mode field. Contains a combination of the output mode constants. Read/write.
1297  *  The \ref OUT_MODE_MOTORON bit must be set in order for power to be applied to the motors.
1298  *  Add \ref OUT_MODE_BRAKE to enable electronic braking. Braking means that the output voltage
1299  *  is not allowed to float between active PWM pulses. It improves the accuracy of motor
1300  *  output but uses more battery power.
1301  *  To use motor regulation include \ref OUT_MODE_REGULATED in the \ref OutputModeField value. Use
1302  *  \ref UF_UPDATE_MODE with \ref UpdateFlagsField to commit changes to this field. */
1303 #define OutputModeField      1
1304 /** Power field. Contains the desired power level (-100 to 100). Read/write.
1305  *  Specify the power level of the output. The absolute value of PowerField is a percentage of the
1306  *  full power of the motor. The sign of PowerField controls the rotation direction. Positive values
1307  *  tell the firmware to turn the motor forward, while negative values turn the motor backward.
1308  *  Use \ref UF_UPDATE_SPEED with \ref UpdateFlagsField to commit changes to this field. */
1309 #define PowerField           2
1310 /** Actual speed field. Contains the actual power level (-100 to 100). Read only.
1311  *  Return the percent of full power the firmware is applying to the output. This may vary from the
1312  *  PowerField value when auto-regulation code in the firmware responds to a load on the output. */
1313 #define ActualSpeedField     3
1314 /** Internal tachometer count field. Contains the current internal tachometer count. Read only.
1315  *  Return the internal position counter value for the specified output. The internal count is reset
1316  *  automatically when a new goal is set using the \ref TachoLimitField and the \ref UF_UPDATE_TACHO_LIMIT flag.
1317  *  Set the \ref UF_UPDATE_RESET_COUNT flag in \ref UpdateFlagsField to reset TachoCountField and cancel any \ref TachoLimitField.
1318  *  The sign of TachoCountField indicates the motor rotation direction. */
1319 #define TachoCountField      4
1320 /** Tachometer limit field. Contains the current tachometer limit. Read/write.
1321  *  Specify the number of degrees the motor should rotate.
1322  *  Use \ref UF_UPDATE_TACHO_LIMIT with the \ref UpdateFlagsField field to commit changes to the TachoLimitField.
1323  *  The value of this field is a relative distance from the current motor position at the moment when
1324  *  the \ref UF_UPDATE_TACHO_LIMIT flag is processed. */
1325 #define TachoLimitField      5
1326 /** Run state field. Contains one of the run state constants. Read/write.
1327  *  Use this field to specify the running state of an output. Set the RunStateField to \ref OUT_RUNSTATE_RUNNING
1328  *  to enable power to any output. Use \ref OUT_RUNSTATE_RAMPUP to enable automatic ramping to a new \ref PowerField
1329  *  level greater than the current \ref PowerField level. Use \ref OUT_RUNSTATE_RAMPDOWN to enable automatic ramping
1330  *  to a new \ref PowerField level less than the current \ref PowerField level.
1331  *  Both the rampup and rampdown bits must be used in conjunction with appropriate \ref TachoLimitField and \ref PowerField
1332  *  values. In this case the firmware smoothly increases or decreases the actual power to the new \ref PowerField
1333  *  level over the total number of degrees of rotation specified in \ref TachoLimitField. */
1334 #define RunStateField        6
1335 /** Turn ratio field. Contains the current turn ratio. Only applicable when synchronizing multiple motors. Read/write.
1336  *  Use this field to specify a proportional turning ratio. This field must be used in conjunction with other
1337  *  field values: \ref OutputModeField must include \ref OUT_MODE_MOTORON and \ref OUT_MODE_REGULATED, \ref RegModeField must be set to
1338  *  \ref OUT_REGMODE_SYNC, \ref RunStateField must not be \ref OUT_RUNSTATE_IDLE, and \ref PowerField must be non-zero.
1339  *  There are only three valid combinations of left and right motors for use with TurnRatioField: \ref OUT_AB, \ref OUT_BC,
1340  *  and \ref OUT_AC. In each of these three options the first motor listed is considered to be the left motor and
1341  *  the second motor is the right motor, regardless of the physical configuration of the robot.
1342  *  Negative turn ratio values shift power toward the left motor while positive values shift power toward the
1343  *  right motor. An absolute value of 50 usually results in one motor stopping. An absolute value of 100 usually
1344  *  results in two motors turning in opposite directions at equal power. */
1345 #define TurnRatioField       7
1346 /** Regulation mode field. Contains one of the regulation mode constants. Read/write.
1347  *  This field specifies the regulation mode to use with the specified port(s). It is ignored if
1348  *  the \ref OUT_MODE_REGULATED bit is not set in the \ref OutputModeField field. Unlike \ref OutputModeField, RegModeField is
1349  *  not a bitfield. Only one regulation mode value can be set at a time.
1350  *  Speed regulation means that the firmware tries to maintain a certain speed based on the \ref PowerField setting. The
1351  *  firmware adjusts the PWM duty cycle if the motor is affected by a physical load. This adjustment is
1352  *  reflected by the value of the \ref ActualSpeedField property. When using speed regulation, do not set \ref PowerField to its
1353  *  maximum value since the firmware cannot adjust to higher power levels in that situation.
1354  *  Synchronization means the firmware tries to keep two motors in sync regardless of physical loads. Use
1355  *  this mode to maintain a straight path for a mobile robot automatically. Also use this mode with the
1356  *  \ref TurnRatioField property to provide proportional turning.
1357  *  Set \ref OUT_REGMODE_SYNC on at least two motor ports in order for synchronization to function. Setting
1358  *  \ref OUT_REGMODE_SYNC on all three motor ports will result in only the first two (\ref OUT_A and \ref OUT_B) being
1359  *  synchronized. */
1360 #define RegModeField         8
1361 /** Overload field. Contains a boolean value which is TRUE if the motor is overloaded. Read only.
1362  *  This field will have a value of 1 (true) if the firmware speed regulation cannot overcome a physical
1363  *  load on the motor. In other words, the motor is turning more slowly than expected.
1364  *  If the motor speed can be maintained in spite of loading then this field value is zero (false).
1365  *  In order to use this field the motor must have a non-idle \ref RunStateField, an \ref OutputModeField which includes
1366  *  \ref OUT_MODE_MOTORON and \ref OUT_MODE_REGULATED, and its \ref RegModeField must be set to \ref OUT_REGMODE_SPEED. */
1367 #define OverloadField        9
1368 /** Proportional field. Contains the proportional constant for the PID motor controller. Read/write.
1369  *  This field specifies the proportional term used in the internal proportional-integral-derivative
1370  *  (PID) control algorithm.
1371  *  Set \ref UF_UPDATE_PID_VALUES to commit changes to RegPValue, RegIValue, and RegDValue simultaneously. */
1372 #define RegPValueField       10
1373 /** Integral field. Contains the integral constant for the PID motor controller. Read/write.
1374  *  This field specifies the integral term used in the internal proportional-integral-derivative
1375  *  (PID) control algorithm.
1376  *  Set \ref UF_UPDATE_PID_VALUES to commit changes to RegPValue, RegIValue, and RegDValue simultaneously. */
1377 #define RegIValueField       11
1378 /** Derivative field. Contains the derivative constant for the PID motor controller. Read/write.
1379  *  This field specifies the derivative term used in the internal proportional-integral-derivative
1380  *  (PID) control algorithm.
1381  *  Set \ref UF_UPDATE_PID_VALUES to commit changes to RegPValue, RegIValue, and RegDValue simultaneously. */
1382 #define RegDValueField       12
1383 /** NXT-G block tachometer count field. Contains the current NXT-G block tachometer count. Read only.
1384  *  Return the block-relative position counter value for the specified port.
1385  *  Refer to the \ref UpdateFlagsField description for information about how to use block-relative
1386  *  position counts.
1387  *  Set the \ref UF_UPDATE_RESET_BLOCK_COUNT flag in \ref UpdateFlagsField to request that the firmware
1388  *  reset the BlockTachoCountField.
1389  *  The sign of BlockTachoCountField indicates the direction of rotation. Positive values indicate
1390  *  forward rotation and negative values indicate reverse rotation. Forward and reverse depend on
1391  *  the orientation of the motor. */
1392 #define BlockTachoCountField 13
1393 /** Rotation counter field. Contains the current rotation count. Read only.
1394  *  Return the program-relative position counter value for the specified port.
1395  *  Refer to the \ref UpdateFlagsField description for information about how to use program-relative
1396  *  position counts.
1397  *  Set the \ref UF_UPDATE_RESET_ROTATION_COUNT flag in \ref UpdateFlagsField to request that the firmware reset
1398  *  the RotationCountField.
1399  *  The sign of RotationCountField indicates the direction of rotation. Positive values indicate forward
1400  *  rotation and negative values indicate reverse rotation. Forward and reverse depend on the
1401  *  orientation of the motor. */
1402 #define RotationCountField   14
1403 #if defined(__ENHANCED_FIRMWARE) && (__FIRMWARE_VERSION > 107)
1404 /** Options field. Contains a combination of the output options constants. Read/write.
1405  *  Set options for how the output module will act when a tachometer limit is reached. Option
1406  *  constants can be combined with bitwise OR.  Use OUT_OPTION_HOLDATLIMIT to have the output
1407  *  module hold the motor when it reaches the tachometer limit.  Use OUT_OPTION_RAMPDOWNTOLIMIT
1408  *  to have the output module ramp down the motor power as it approaches the tachometer limit.
1409  */
1410 #define OutputOptionsField   15
1411 /** MaxSpeed field. Contains the current max speed value. Read/write.
1412  *  Set the maximum speed to be used during position regulation.
1413  */
1414 #define MaxSpeedField   16
1415 /** MaxAcceleration field. Contains the current max acceleration value. Read/write.
1416  *  Set the maximum acceleration to be used during position regulation.
1417  */
1418 #define MaxAccelerationField   17
1419 #endif
1420 /** @} */  // end of OutputFieldConstants group
1421 
1422 /** @defgroup OutputIOMAP Output module IOMAP offsets
1423  * Constant offsets into the Output module IOMAP structure.
1424  * @{
1425  */
1426 #define OutputOffsetTachoCount(p)        (((p)*32)+0)  /*!< R  - Holds current number of counts, since last reset, updated every 1 mS (4 bytes) slong */
1427 #define OutputOffsetBlockTachoCount(p)   (((p)*32)+4)  /*!< R  - Holds current number of counts for the current output block (4 bytes) slong */
1428 #define OutputOffsetRotationCount(p)     (((p)*32)+8)  /*!< R  - Holds current number of counts for the rotation counter to the output (4 bytes) slong */
1429 #define OutputOffsetTachoLimit(p)        (((p)*32)+12) /*!< RW - Holds number of counts to travel, 0 => Run forever (4 bytes) ulong */
1430 #define OutputOffsetMotorRPM(p)          (((p)*32)+16) /*!< Not updated, will be removed later !! (2 bytes) sword */
1431 #define OutputOffsetFlags(p)             (((p)*32)+18) /*!< RW - Holds flags for which data should be updated (1 byte) ubyte */
1432 #define OutputOffsetMode(p)              (((p)*32)+19) /*!< RW - Holds motor mode: Run, Break, regulated, ... (1 byte) ubyte */
1433 #define OutputOffsetSpeed(p)             (((p)*32)+20) /*!< RW - Holds the wanted speed (1 byte) sbyte */
1434 #define OutputOffsetActualSpeed(p)       (((p)*32)+21) /*!< R  - Holds the current motor speed (1 byte) sbyte */
1435 #define OutputOffsetRegPParameter(p)     (((p)*32)+22) /*!< RW - Holds the P-constant used in the regulation (1 byte) ubyte */
1436 #define OutputOffsetRegIParameter(p)     (((p)*32)+23) /*!< RW - Holds the I-constant used in the regulation (1 byte) ubyte */
1437 #define OutputOffsetRegDParameter(p)     (((p)*32)+24) /*!< RW - Holds the D-constant used in the regulation (1 byte) ubyte */
1438 #define OutputOffsetRunState(p)          (((p)*32)+25) /*!< RW - Holds the current motor run state in the output module (1 byte) ubyte */
1439 #define OutputOffsetRegMode(p)           (((p)*32)+26) /*!< RW - Tells which regulation mode should be used (1 byte) ubyte */
1440 #define OutputOffsetOverloaded(p)        (((p)*32)+27) /*!< R  - True if the motor has been overloaded within speed control regulation (1 byte) ubyte */
1441 #define OutputOffsetSyncTurnParameter(p) (((p)*32)+28) /*!< RW - Holds the turning parameter need within MoveBlock (1 byte) sbyte */
1442 #if defined(__ENHANCED_FIRMWARE) && (__FIRMWARE_VERSION > 107)
1443 #define OutputOffsetOptions(p)           (((p)*32)+29) /*!< RW - holds extra motor options related to the tachometer limit (1 byte) ubyte  (NBC/NXC) */
1444 #define OutputOffsetMaxSpeed(p)          (((p)*32)+30) /*!< RW - holds the maximum speed for position regulation (1 byte) sbyte  (NBC/NXC) */
1445 #define OutputOffsetMaxAccel(p)          (((p)*32)+31) /*!< RW - holds the maximum acceleration for position regulation (1 byte) sbyte  (NBC/NXC) */
1446 #endif
1447 #define OutputOffsetRegulationTime       96 /*!< use for frequency of checking regulation mode (1 byte) ubyte (NBC/NXC) */
1448 #if defined(__ENHANCED_FIRMWARE) && (__FIRMWARE_VERSION > 107)
1449 #define OutputOffsetRegulationOptions    97 /*!< use for position regulation options (1 byte) ubyte (NBC/NXC) */
1450 #endif
1451 /** @} */  // end of OutputIOMAP group
1452 /** @} */  // end of OutputModuleConstants group
1453 /** @} */  // end of OutputModule group
1454 
1455 
1456 /** @addtogroup LowSpeedModule
1457  * @{
1458  */
1459 /** @defgroup LowSpeedModuleConstants LowSpeed module constants
1460  * Constants that are part of the NXT firmware's LowSpeed module.
1461  * @{
1462  */
1463 /** @defgroup LowSpeedStateConstants LSState constants
1464  * Constants for the low speed module LSState function. These values are
1465  * combined together using a bitwise OR operation.
1466  * \sa LSState()
1467  * @{
1468  */
1469 #define COM_CHANNEL_NONE_ACTIVE  0x00 /*!< None of the low speed channels are active */
1470 #define COM_CHANNEL_ONE_ACTIVE   0x01 /*!< Low speed channel 1 is active */
1471 #define COM_CHANNEL_TWO_ACTIVE   0x02 /*!< Low speed channel 2 is active */
1472 #define COM_CHANNEL_THREE_ACTIVE 0x04 /*!< Low speed channel 3 is active */
1473 #define COM_CHANNEL_FOUR_ACTIVE  0x08 /*!< Low speed channel 4 is active */
1474 /** @} */  // end of LowSpeedStateConstants group
1475 
1476 /** @defgroup LowSpeedChannelStateConstants LSChannelState constants
1477  * Constants for the low speed module LSChannelState function.
1478  * \sa LSChannelState()
1479  * @{
1480  */
1481 #define LOWSPEED_IDLE          0 /*!< Channel is idle */
1482 #define LOWSPEED_INIT          1 /*!< Channel is being initialized */
1483 #define LOWSPEED_LOAD_BUFFER   2 /*!< Channel buffer is loading */
1484 #define LOWSPEED_COMMUNICATING 3 /*!< Channel is actively communicating */
1485 #define LOWSPEED_ERROR         4 /*!< Channel is in an error state */
1486 #define LOWSPEED_DONE          5 /*!< Channel is done communicating */
1487 /** @} */  // end of LowSpeedChannelStateConstants group
1488 
1489 /** @defgroup LowSpeedModeConstants LSMode constants
1490  * Constants for the low speed module LSMode function.
1491  * \sa LSMode()
1492  * @{
1493  */
1494 #define LOWSPEED_TRANSMITTING   1 /*!< Lowspeed port is in transmitting mode */
1495 #define LOWSPEED_RECEIVING      2 /*!< Lowspeed port is in receiving mode */
1496 #define LOWSPEED_DATA_RECEIVED  3 /*!< Lowspeed port is in data received mode */
1497 /** @} */  // end of LowSpeedModeConstants group
1498 
1499 /** @defgroup LowSpeedErrorTypeConstants LSErrorType constants
1500  * Constants for the low speed module LSErrorType function.
1501  * \sa LSErrorType()
1502  * @{
1503  */
1504 #define LOWSPEED_NO_ERROR     0 /*!< Lowspeed port has no error */
1505 #define LOWSPEED_CH_NOT_READY 1 /*!< Lowspeed port is not ready */
1506 #define LOWSPEED_TX_ERROR     2 /*!< Lowspeed port encountered an error while transmitting data */
1507 #define LOWSPEED_RX_ERROR     3 /*!< Lowspeed port encountered an error while receiving data */
1508 /** @} */  // end of LowSpeedErrorTypeConstants group
1509 
1510 /** @defgroup LowSpeedIOMAP Low speed module IOMAP offsets
1511  * Constant offsets into the low speed module IOMAP structure.
1512  * @{
1513  */
1514 #define LowSpeedOffsetInBufBuf(p)       (((p)*19)+0)  /*!< RW - Input buffer data buffer field offset (16 bytes) */
1515 #define LowSpeedOffsetInBufInPtr(p)     (((p)*19)+16) /*!< RW - Input buffer in pointer field offset (1 byte) */
1516 #define LowSpeedOffsetInBufOutPtr(p)    (((p)*19)+17) /*!< RW - Input buffer out pointer field offset (1 byte) */
1517 #define LowSpeedOffsetInBufBytesToRx(p) (((p)*19)+18) /*!< RW - Input buffer bytes to receive field offset (1 byte) */
1518 
1519 #define LowSpeedOffsetOutBufBuf(p)       (((p)*19)+76) /*!< RW - Output buffer data buffer field offset (16 bytes) */
1520 #define LowSpeedOffsetOutBufInPtr(p)     (((p)*19)+92) /*!< RW - Output buffer in pointer field offset (1 byte) */
1521 #define LowSpeedOffsetOutBufOutPtr(p)    (((p)*19)+93) /*!< RW - Output buffer out pointer field offset (1 byte) */
1522 #define LowSpeedOffsetOutBufBytesToRx(p) (((p)*19)+94) /*!< RW - Output buffer bytes to receive field offset (1 byte) */
1523 
1524 #define LowSpeedOffsetMode(p)            ((p)+152) /*!< R - Lowspeed port mode (1 byte) */
1525 #define LowSpeedOffsetChannelState(p)    ((p)+156) /*!< R - Lowspeed channgel state (1 byte) */
1526 #define LowSpeedOffsetErrorType(p)       ((p)+160) /*!< R - Lowspeed port error type (1 byte) */
1527 
1528 #define LowSpeedOffsetState            164 /*!< R - Lowspeed state (all channels) */
1529 #define LowSpeedOffsetSpeed            165 /*!< R - Lowspeed speed (unused) */
1530 
1531 #ifdef __ENHANCED_FIRMWARE
1532 #define LowSpeedOffsetNoRestartOnRead  166 /*!< RW - Lowspeed option for no restart on read (all channels) (NBC/NXC) */
1533 #endif
1534 /** @} */  // end of LowSpeedIOMAP group
1535 
1536 /** @defgroup LowSpeedNoRestartConstants LSNoRestartOnRead constants
1537  * Constants for the low speed module LSNoRestartOnRead and
1538  * SetLSNoRestartOnRead functions. These values are combined with a bitwise
1539  * OR operation.
1540  * \sa LSNoRestartOnRead(), SetLSNoRestartOnRead()
1541  * @{
1542  */
1543 #ifdef __ENHANCED_FIRMWARE
1544 #define LSREAD_RESTART_ALL     0x00 /*!< Restart on read for all channels (default) */
1545 #define LSREAD_NO_RESTART_1    0x01 /*!< No restart on read for channel 1 */
1546 #define LSREAD_NO_RESTART_2    0x02 /*!< No restart on read for channel 2 */
1547 #define LSREAD_NO_RESTART_3    0x04 /*!< No restart on read for channel 3 */
1548 #define LSREAD_NO_RESTART_4    0x08 /*!< No restart on read for channel 4 */
1549 #define LSREAD_RESTART_NONE    0x0F /*!< No restart on read for all channels */
1550 #define LSREAD_NO_RESTART_MASK 0x10 /*!< No restart mask */
1551 #endif
1552 /** @} */  // end of LowSpeedNoRestartConstants group
1553 
1554 /** @defgroup GenericI2CConstants Standard I2C constants
1555  * Constants for use with standard I2C devices.
1556  * @{
1557  */
1558 #define I2C_ADDR_DEFAULT  0x02 /*!< Standard NXT I2C device address */
1559 #define I2C_REG_VERSION   0x00 /*!< Standard NXT I2C version register */
1560 #define I2C_REG_VENDOR_ID 0x08 /*!< Standard NXT I2C vendor ID register */
1561 #define I2C_REG_DEVICE_ID 0x10 /*!< Standard NXT I2C device ID register */
1562 #define I2C_REG_CMD       0x41 /*!< Standard NXT I2C device command register */
1563 /** @} */  // end of GenericI2CConstants group
1564 
1565 /** @defgroup LEGOI2CAddressConstants LEGO I2C address constants
1566  * Constants for LEGO I2C device addresses.
1567  * @{
1568  */
1569 #define LEGO_ADDR_US         0x02 /*!< The LEGO ultrasonic sensor's I2C address */
1570 #define LEGO_ADDR_TEMP       0x98 /*!< The LEGO temperature sensor's I2C address */
1571 #define LEGO_ADDR_EMETER     0x04 /*!< The LEGO e-meter sensor's I2C address */
1572 /** @} */  // end of LEGOI2CAddressConstants group
1573 
1574 /** @defgroup USI2CConstants Ultrasonic sensor constants
1575  * Constants for use with the ultrasonic sensor.
1576  * @{
1577  */
1578 #define US_CMD_OFF           0x00 /*!< Command to turn off the ultrasonic sensor */
1579 #define US_CMD_SINGLESHOT    0x01 /*!< Command to put the ultrasonic sensor into single shot mode */
1580 #define US_CMD_CONTINUOUS    0x02 /*!< Command to put the ultrasonic sensor into continuous polling mode (default) */
1581 #define US_CMD_EVENTCAPTURE  0x03 /*!< Command to put the ultrasonic sensor into event capture mode */
1582 #define US_CMD_WARMRESET     0x04 /*!< Command to warm reset the ultrasonic sensor */
1583 
1584 #define US_REG_CM_INTERVAL   0x40 /*!< The register address used to store the CM interval */
1585 #define US_REG_ACTUAL_ZERO   0x50 /*!< The register address used to store the actual zero value */
1586 #define US_REG_SCALE_FACTOR  0x51 /*!< The register address used to store the scale factor value */
1587 #define US_REG_SCALE_DIVISOR 0x52 /*!< The register address used to store the scale divisor value */
1588 
1589 #define US_REG_FACTORY_ACTUAL_ZERO   0x11 /*!< The register address containing the factory setting for the actual zero value */
1590 #define US_REG_FACTORY_SCALE_FACTOR  0x12 /*!< The register address containing the factory setting for the scale factor value */
1591 #define US_REG_FACTORY_SCALE_DIVISOR 0x13 /*!< The register address containing the factory setting for the scale divisor value */
1592 #define US_REG_MEASUREMENT_UNITS     0x14 /*!< The register address containing the measurement units (degrees C or F) */
1593 /** @} */  // end of USI2CConstants group
1594 
1595 /** @defgroup TempI2CConstants LEGO temperature sensor constants
1596  * Constants for use with the LEGO temperature sensor.
1597  * @{
1598  */
1599 // R1/R0
1600 #define TEMP_RES_9BIT      0x00 /*!< Set the temperature conversion resolution to 9 bit */
1601 #define TEMP_RES_10BIT     0x20 /*!< Set the temperature conversion resolution to 10 bit */
1602 #define TEMP_RES_11BIT     0x40 /*!< Set the temperature conversion resolution to 11 bit */
1603 #define TEMP_RES_12BIT     0x60 /*!< Set the temperature conversion resolution to 12 bit */
1604 // SD (shutdown mode)
1605 #define TEMP_SD_CONTINUOUS 0x00 /*!< Set the sensor mode to continuous */
1606 #define TEMP_SD_SHUTDOWN   0x01 /*!< Set the sensor mode to shutdown. The device will shut down after the current conversion is completed. */
1607 // TM (thermostat mode)
1608 #define TEMP_TM_COMPARATOR 0x00 /*!< Set the thermostat mode to comparator */
1609 #define TEMP_TM_INTERRUPT  0x02 /*!< Set the thermostat mode to interrupt */
1610 // OS (one shot)
1611 #define TEMP_OS_ONESHOT    0x80 /*!< Set the sensor into oneshot mode. When the device is in shutdown mode this will start a single temperature conversion. The device returns to shutdown mode when it completes. */
1612 // F1/F0 (fault queue)
1613 #define TEMP_FQ_1          0x00 /*!< Set fault queue to 1 fault before alert */
1614 #define TEMP_FQ_2          0x08 /*!< Set fault queue to 2 faults before alert */
1615 #define TEMP_FQ_4          0x10 /*!< Set fault queue to 4 faults before alert */
1616 #define TEMP_FQ_6          0x18 /*!< Set fault queue to 6 faults before alert */
1617 // POL (polarity)
1618 #define TEMP_POL_LOW       0x00 /*!< Set polarity of ALERT pin to be active LOW */
1619 #define TEMP_POL_HIGH      0x04 /*!< Set polarity of ALERT pin to be active HIGH */
1620 
1621 #define TEMP_REG_TEMP      0x00 /*!< The register where temperature values can be read */
1622 #define TEMP_REG_CONFIG    0x01 /*!< The register for reading/writing sensor configuration values */
1623 #define TEMP_REG_TLOW      0x02 /*!< The register for reading/writing a user-defined low temperature limit */
1624 #define TEMP_REG_THIGH     0x03 /*!< The register for reading/writing a user-defined high temperature limit */
1625 /** @} */  // end of TempI2CConstants group
1626 
1627 /** @defgroup EMeterI2CConstants E-Meter sensor constants
1628  * Constants for use with the e-meter sensor.
1629  * @{
1630  */
1631 #define EMETER_REG_VIN    0x0a /*!< The register address for voltage in */
1632 #define EMETER_REG_AIN    0x0c /*!< The register address for amps in */
1633 #define EMETER_REG_VOUT   0x0e /*!< The register address for voltage out */
1634 #define EMETER_REG_AOUT   0x10 /*!< The register address for amps out */
1635 #define EMETER_REG_JOULES 0x12 /*!< The register address for joules */
1636 #define EMETER_REG_WIN    0x14 /*!< The register address for watts in */
1637 #define EMETER_REG_WOUT   0x16 /*!< The register address for watts out */
1638 /** @} */  // end of EMeterI2CConstants group
1639 
1640 /** @} */  // end of LowSpeedModuleConstants group
1641 /** @} */  // end of LowSpeedModule group
1642 
1643 
1644 /** @addtogroup DisplayModule
1645  * @{
1646  */
1647 /** @defgroup DisplayModuleConstants Display module constants
1648  * Constants that are part of the NXT firmware's Display module.
1649  * @{
1650  */
1651 /** @defgroup DisplayExecuteFunctionConstants DisplayExecuteFunction constants
1652  * Constants that are for use with the DisplayExecuteFunction system call.
1653  * @{
1654  */
1655 #define DISPLAY_ERASE_ALL       0x00     /*!< W - erase entire screen     (CMD,x,x,x,x,x) */
1656 #define DISPLAY_PIXEL           0x01     /*!< W - set pixel (on/off)      (CMD,TRUE/FALSE,X,Y,x,x) */
1657 #define DISPLAY_HORIZONTAL_LINE 0x02     /*!< W - draw horizontal line    (CMD,TRUE/FALSE,X1,Y1,X2,x) */
1658 #define DISPLAY_VERTICAL_LINE   0x03     /*!< W - draw vertical line      (CMD,TRUE/FALSE,X1,Y1,x,Y2) */
1659 #define DISPLAY_CHAR            0x04     /*!< W - draw char (actual font) (CMD,TRUE,X1,Y1,Char,x) */
1660 #define DISPLAY_ERASE_LINE      0x05     /*!< W - erase a single line     (CMD,x,LINE,x,x,x) */
1661 #define DISPLAY_FILL_REGION     0x06     /*!< W - fill screen region      (CMD,TRUE/FALSE,X1,Y1,X2,Y2) */
1662 #define DISPLAY_FRAME           0x07     /*!< W - draw a frame (on/off)   (CMD,TRUE/FALSE,X1,Y1,X2,Y2) */
1663 /** @} */  // end of DisplayExecuteFunctionConstants group
1664 
1665 /** @defgroup DisplayDrawOptionConstants Drawing option constants
1666  * Constants that are for specifying drawing options in several display module API functions.
1667  * Bits 0 & 1 (values 0,1,2,3) control screen clearing behaviour (Not within RIC files).
1668  * Bit 2 (value 4) controls the NOT operation, i.e. draw in white or invert text/graphics.
1669  * Bits 3 & 4 (values 0,8,16,24) control pixel logical combinations (COPY/AND/OR/XOR).
1670  * Bit 5 (value 32) controls shape filling, or overrides text/graphic bitmaps with set pixels.
1671  * These may be ORed together for the full instruction
1672  * (e.g., DRAW_OPT_NORMAL|DRAW_OPT_LOGICAL_XOR)
1673  * These operations are resolved into the separate, common parameters
1674  * defined in 'c_display.iom' before any drawing function is called.
1675  * Note that when drawing a RIC file, the initial 'DrawingOptions' parameter
1676  * supplied in the drawing instruction controls screen clearing, but nothing else.
1677  * The 'CopyOptions' parameter from each instruction in the RIC file then controls
1678  * graphic operations, but the screen-clearing bits are ignored.
1679  * \sa TextOut(), NumOut(), PointOut(), LineOut(), CircleOut(), RectOut(),
1680  * PolyOut(), EllipseOut(), FontTextOut(), FontNumOut(), GraphicOut(),
1681  * GraphicArrayOut()
1682  * @{
1683  */
1684 #define DRAW_OPT_NORMAL                     (0x0000) /*!< Normal drawing */
1685 #define DRAW_OPT_CLEAR_WHOLE_SCREEN         (0x0001) /*!< Clear the entire screen before drawing */
1686 #define DRAW_OPT_CLEAR_EXCEPT_STATUS_SCREEN (0x0002) /*!< Clear the screen except for the status line before drawing */
1687 
1688 #define DRAW_OPT_CLEAR_PIXELS               (0x0004) /*!< Clear pixels while drawing (aka draw in white) */
1689 #define DRAW_OPT_CLEAR                      (0x0004) /*!< Clear pixels while drawing (aka draw in white) */
1690 #define DRAW_OPT_INVERT                     (0x0004) /*!< Invert text or graphics */
1691 
1692 #define DRAW_OPT_LOGICAL_COPY               (0x0000) /*!< Draw pixels using a logical copy operation */
1693 #define DRAW_OPT_LOGICAL_AND                (0x0008) /*!< Draw pixels using a logical AND operation */
1694 #define DRAW_OPT_LOGICAL_OR                 (0x0010) /*!< Draw pixels using a logical OR operation */
1695 #define DRAW_OPT_LOGICAL_XOR                (0x0018) /*!< Draw pixels using a logical XOR operation */
1696 
1697 #define DRAW_OPT_FILL_SHAPE                 (0x0020) /*!< Fill the shape while drawing (rectangle, circle, ellipses, and polygon) */
1698 
1699 #define DRAW_OPT_CLEAR_SCREEN_MODES         (0x0003) /*!< Bit mask for the clear screen modes */
1700 #define DRAW_OPT_LOGICAL_OPERATIONS         (0x0018) /*!< Bit mask for the logical drawing operations */
1701 
1702 #define DRAW_OPT_POLYGON_POLYLINE           (0x0400) /*!< When drawing polygons, do not close (i.e., draw a polyline instead) */
1703 
1704 /** @defgroup DisplayFontDrawOptionConstants Font drawing option constants
1705  * These addition drawing option constants are only for use when drawing
1706  * text and numbers on the LCD using an RIC-based font.
1707  * \sa FontTextOut(), FontNumOut()
1708  * @{
1709  */
1710 #define DRAW_OPT_FONT_DIRECTIONS            (0x01C0) /*!< Bit mask for the font direction bits */
1711 
1712 #define DRAW_OPT_FONT_WRAP       (0x0200) /*!< Option to have text wrap in \ref FontNumOut and \ref FontTextOut calls */
1713 
1714 #define DRAW_OPT_FONT_DIR_L2RB   (0x0000) /*!< Font left to right bottom align */
1715 #define DRAW_OPT_FONT_DIR_L2RT   (0x0040) /*!< Font left to right top align */
1716 #define DRAW_OPT_FONT_DIR_R2LB   (0x0080) /*!< Font right to left bottom align */
1717 #define DRAW_OPT_FONT_DIR_R2LT   (0x00C0) /*!< Font right to left top align */
1718 #define DRAW_OPT_FONT_DIR_B2TL   (0x0100) /*!< Font bottom to top left align */
1719 #define DRAW_OPT_FONT_DIR_B2TR   (0x0140) /*!< Font bottom to top right align */
1720 #define DRAW_OPT_FONT_DIR_T2BL   (0x0180) /*!< Font top to bottom left align */
1721 #define DRAW_OPT_FONT_DIR_T2BR   (0x01C0) /*!< Font top to bottom right align */
1722 /** @} */  // end of DisplayFontDrawOptionConstants group
1723 /** @} */  // end of DisplayDrawOptionConstants group
1724 
1725 /** @defgroup DisplayFlagsGroup Display flags
1726  * Constants that are for use with the display flags functions.
1727  * \sa SetDisplayFlags(), DisplayFlags()
1728  * @{
1729  */
1730 #define DISPLAY_ON               0x01     /*!< W  - Display on */
1731 #define DISPLAY_REFRESH          0x02     /*!< W  - Enable refresh */
1732 #define DISPLAY_POPUP            0x08     /*!< W  - Use popup display memory */
1733 #define DISPLAY_REFRESH_DISABLED 0x40     /*!< R  - Refresh disabled */
1734 #define DISPLAY_BUSY             0x80     /*!< R  - Refresh in progress */
1735 /** @} */  // end of DisplayFlagsGroup group
1736 
1737 #if defined(__ENHANCED_FIRMWARE) && (__FIRMWARE_VERSION > 107)
1738 /** @defgroup DisplayContrastConstants Display contrast constants
1739  * Constants that are for use with the display contrast API functions.
1740  * \sa SetDisplayContrast(), DisplayContrast()
1741  * @{
1742  */
1743 #define DISPLAY_CONTRAST_DEFAULT 0x5A /*!< Default display contrast value */
1744 #define DISPLAY_CONTRAST_MAX     0x7F /*!< Maximum display contrast value */
1745 /** @} */  // end of DisplayContrastConstants group
1746 #endif
1747 
1748 #define SCREEN_MODE_RESTORE 0x00 /*!< Restore the screen \sa SetScreenMode() */
1749 #define SCREEN_MODE_CLEAR   0x01 /*!< Clear the screen \sa SetScreenMode() */
1750 
1751 #define DISPLAY_HEIGHT 64  /*!< The height of the LCD screen in pixels */
1752 #define DISPLAY_WIDTH  100 /*!< The width of the LCD screen in pixels */
1753 
1754 #define DISPLAY_MENUICONS_Y       40 /*!< */
1755 #define DISPLAY_MENUICONS_X_OFFS  7  /*!< */
1756 #define DISPLAY_MENUICONS_X_DIFF  31 /*!< */
1757 
1758 /** @defgroup DisplayTextLineConstants Text line constants
1759  * Constants that are for use with getting/setting display data.
1760  * \sa SetDisplayNormal(), GetDisplayNormal(), SetDisplayPopup(), GetDisplayPopup()
1761  * @{
1762  */
1763 #define TEXTLINE_1 0 /*!< Text line 1 */
1764 #define TEXTLINE_2 1 /*!< Text line 2 */
1765 #define TEXTLINE_3 2 /*!< Text line 3 */
1766 #define TEXTLINE_4 3 /*!< Text line 4 */
1767 #define TEXTLINE_5 4 /*!< Text line 5 */
1768 #define TEXTLINE_6 5 /*!< Text line 6 */
1769 #define TEXTLINE_7 6 /*!< Text line 7 */
1770 #define TEXTLINE_8 7 /*!< Text line 8 */
1771 #define TEXTLINES  8 /*!< The number of text lines on the LCD */
1772 /** @} */  // end of DisplayTextLineConstants group
1773 
1774 // Used in macro "MENUICON_BIT"
1775 #define MENUICON_LEFT   0 /*!< Left icon */
1776 #define MENUICON_CENTER 1 /*!< Center icon */
1777 #define MENUICON_RIGHT  2 /*!< Right icon */
1778 #define MENUICONS       3 /*!< The number of menu icons */
1779 
1780 // Used in macro "SPECIAL_BIT"
1781 #define FRAME_SELECT 0   /*!< Center icon select frame */
1782 #define STATUSTEXT   1   /*!< Status text (BT name) */
1783 #define MENUTEXT     2   /*!< Center icon text */
1784 #define STEPLINE     3   /*!< Step collection lines */
1785 #define TOPLINE      4   /*!< Top status underline */
1786 #define SPECIALS     5   /*!< The number of special bit values */
1787 
1788 // Used in macro "STATUSICON_BIT"
1789 #define STATUSICON_BLUETOOTH 0 /*!< BlueTooth status icon collection */
1790 #define STATUSICON_USB       1 /*!< USB status icon collection */
1791 #define STATUSICON_VM        2 /*!< VM status icon collection */
1792 #define STATUSICON_BATTERY   3 /*!< Battery status icon collection */
1793 #define STATUSICONS          4 /*!< The number of status icons */
1794 
1795 // Used in macro "SCREEN_BIT"
1796 #define SCREEN_BACKGROUND 0 /*!< Entire screen */
1797 #define SCREEN_LARGE      1 /*!< Entire screen except status line */
1798 #define SCREEN_SMALL      2 /*!< Screen between menu icons and status line */
1799 #define SCREENS           3 /*!< The number of screen bits */
1800 
1801 // Used in macro "BITMAP_BIT"
1802 #define BITMAP_1 0 /*!< Bitmap 1 */
1803 #define BITMAP_2 1 /*!< Bitmap 2 */
1804 #define BITMAP_3 2 /*!< Bitmap 3 */
1805 #define BITMAP_4 3 /*!< Bitmap 4 */
1806 #define BITMAPS  4 /*!< The number of bitmap bits */
1807 
1808 // Used in macro "STEPICON_BIT"
1809 #define STEPICON_1 0 /*!< Left most step icon */
1810 #define STEPICON_2 1 /*!< */
1811 #define STEPICON_3 2 /*!< */
1812 #define STEPICON_4 3 /*!< */
1813 #define STEPICON_5 4 /*!< Right most step icon */
1814 #define STEPICONS  5 /*!< */
1815 
1816 /** @defgroup DisplayIOMAP Display module IOMAP offsets
1817  * Constant offsets into the display module IOMAP structure.
1818  * @{
1819  */
1820 #define DisplayOffsetPFunc          0             /*!< Simple draw entry */
1821 #define DisplayOffsetEraseMask      4             /*!< Section erase mask   (executed first) */
1822 #define DisplayOffsetUpdateMask     8             /*!< Section update mask  (executed next) */
1823 #define DisplayOffsetPFont          12            /*!< Pointer to font file */
1824 #define DisplayOffsetPTextLines(p)  (((p)*4)+16)  /*!< Pointer to text strings */
1825 #define DisplayOffsetPStatusText    48            /*!< Pointer to status text string */
1826 #define DisplayOffsetPStatusIcons   52            /*!< Pointer to status icon collection file */
1827 #define DisplayOffsetPScreens(p)    (((p)*4)+56)  /*!< Pointer to screen bitmap file */
1828 #define DisplayOffsetPBitmaps(p)    (((p)*4)+68)  /*!< Pointer to free bitmap files */
1829 #define DisplayOffsetPMenuText      84            /*!< Pointer to menu icon text (NULL == none) */
1830 #define DisplayOffsetPMenuIcons(p)  (((p)*4)+88)  /*!< Pointer to menu icon images (NULL == none) */
1831 #define DisplayOffsetPStepIcons     100           /*!< Pointer to step icon collection file */
1832 #define DisplayOffsetDisplay        104           /*!< Display content copied to physical display every 17 mS */
1833 #define DisplayOffsetStatusIcons(p) ((p)+108)     /*!< Index in status icon collection file (index = 0 -> none) */
1834 #define DisplayOffsetStepIcons(p)   ((p)+112)     /*!< Index in step icon collection file (index = 0 -> none) */
1835 #define DisplayOffsetFlags          117           /*!< Update flags enumerated above */
1836 #define DisplayOffsetTextLinesCenterFlags 118     /*!< Mask to center TextLines */
1837 #define DisplayOffsetNormal(l,w)    (((l)*100)+(w)+119) /*!< Raw display memory for normal screen */
1838 #define DisplayOffsetPopup(l,w)     (((l)*100)+(w)+919) /*!< Raw display memory for popup screen */
1839 
1840 #if defined(__ENHANCED_FIRMWARE) && (__FIRMWARE_VERSION > 107)
1841 #define DisplayOffsetContrast       1719 /*!< Adjust the display contrast with this field */
1842 #endif
1843 /** @} */  // end of DisplayIOMAP group
1844 /** @} */  // end of DisplayModuleConstants group
1845 /** @} */  // end of DisplayModule group
1846 
1847 
1848 /** @addtogroup CommModule
1849  * @{
1850  */
1851 /** @defgroup CommModuleConstants Comm module constants
1852  * Constants that are part of the NXT firmware's Comm module.
1853  * @{
1854  */
1855 /** @defgroup CommMiscConstants Miscellaneous Comm module constants
1856  * Miscellaneous constants related to the Comm module.
1857  * @{
1858  */
1859 #define SIZE_OF_USBBUF                64  /*!< Size of USB Buffer in bytes */
1860 #define USB_PROTOCOL_OVERHEAD         2   /*!< Size of USB Overhead in bytes -- Command type byte + Command*/
1861 #define SIZE_OF_USBDATA               62  /*!< Size of USB Buffer available for data */
1862 #define SIZE_OF_HSBUF                 128 /*!< Size of High Speed Port 4 buffer */
1863 #define SIZE_OF_BTBUF                 128 /*!< Size of Bluetooth buffer*/
1864 
1865 #define BT_CMD_BYTE                   1  /*!< Size of Bluetooth command*/
1866 #define SIZE_OF_BT_DEVICE_TABLE       30 /*!< Size of Bluetooth device table */
1867 #define SIZE_OF_BT_CONNECT_TABLE      4  /*!< Size of Bluetooth connection table -- Index 0 is always incoming connection */
1868 #define SIZE_OF_BT_NAME               16 /*!< Size of Bluetooth name */
1869 #define SIZE_OF_BRICK_NAME            8  /*!< Size of NXT Brick name */
1870 #define SIZE_OF_CLASS_OF_DEVICE       4  /*!< Size of class of device */
1871 #define SIZE_OF_BT_PINCODE            16 /*!< Size of Bluetooth PIN */
1872 #define SIZE_OF_BDADDR                7  /*!< Size of Bluetooth Address*/
1873 #define MAX_BT_MSG_SIZE               60000 /*!< Max Bluetooth Message Size */
1874 
1875 #define BT_DEFAULT_INQUIRY_MAX        0   /*!< Bluetooth default inquiry Max (0 == unlimited)*/
1876 #define BT_DEFAULT_INQUIRY_TIMEOUT_LO 15  /*!< Bluetooth inquiry timeout (15*1.28 sec = 19.2 sec) */
1877 /** @} */  // end of CommMiscConstants group
1878 
1879 /** @defgroup CommBtStateConstants Bluetooth State constants
1880  * Constants related to the bluetooth state.
1881  * @{
1882  */
1883 #define BT_ARM_OFF              0 /*!< BtState constant bluetooth off */
1884 #define BT_ARM_CMD_MODE         1 /*!< BtState constant bluetooth command mode */
1885 #define BT_ARM_DATA_MODE        2 /*!< BtState constant bluetooth data mode */
1886 /** @} */  // end of CommBtStateConstants group
1887 
1888 /** @defgroup CommDataModeConstants Data mode constants
1889  * Constants related to the bluetooth and hi-speed data modes.
1890  * @{
1891  */
1892 #define DATA_MODE_NXT    0x00 /*!< Use NXT data mode */
1893 #define DATA_MODE_GPS    0x01 /*!< Use GPS data mode */
1894 #define DATA_MODE_RAW    0x02 /*!< Use RAW data mode */
1895 #define DATA_MODE_MASK   0x07 /*!< A mask for the data mode bits. */
1896 #define DATA_MODE_UPDATE 0x08 /*!< Indicates that the data mode has been changed. */
1897 /** @} */  // end of CommDataModeConstants group
1898 
1899 /** @defgroup CommBtStateStatusConstants Bluetooth state status constants
1900  * Constants related to the bluetooth state status.
1901  * @{
1902  */
1903 #define BT_BRICK_VISIBILITY     0x01 /*!< BtStateStatus brick visibility bit */
1904 #define BT_BRICK_PORT_OPEN      0x02 /*!< BtStateStatus port open bit */
1905 #define BT_CONNECTION_0_ENABLE  0x10 /*!< BtStateStatus connection 0 enable/disable bit */
1906 #define BT_CONNECTION_1_ENABLE  0x20 /*!< BtStateStatus connection 1 enable/disable bit */
1907 #define BT_CONNECTION_2_ENABLE  0x40 /*!< BtStateStatus connection 2 enable/disable bit */
1908 #define BT_CONNECTION_3_ENABLE  0x80 /*!< BtStateStatus connection 3 enable/disable bit */
1909 /** @} */  // end of CommBtStateStatusConstants group
1910 
1911 /** @defgroup CommConnectionConstants Remote connection constants
1912  * Constants for specifying remote connection slots.
1913  * @{
1914  */
1915 #define CONN_BT0    0x0 /*!< Bluetooth connection 0 */
1916 #define CONN_BT1    0x1 /*!< Bluetooth connection 1 */
1917 #define CONN_BT2    0x2 /*!< Bluetooth connection 2 */
1918 #define CONN_BT3    0x3 /*!< Bluetooth connection 3 */
1919 #define CONN_HS4    0x4 /*!< RS485 (hi-speed) connection (port 4, all devices) */
1920 #define CONN_HS_ALL 0x4 /*!< RS485 (hi-speed) connection (port 4, all devices) */
1921 #define CONN_HS_1   0x5 /*!< RS485 (hi-speed) connection (port 4, device address 1) */
1922 #define CONN_HS_2   0x6 /*!< RS485 (hi-speed) connection (port 4, device address 2) */
1923 #define CONN_HS_3   0x7 /*!< RS485 (hi-speed) connection (port 4, device address 3) */
1924 #define CONN_HS_4   0x8 /*!< RS485 (hi-speed) connection (port 4, device address 4) */
1925 #define CONN_HS_5   0x9 /*!< RS485 (hi-speed) connection (port 4, device address 5) */
1926 #define CONN_HS_6   0xa /*!< RS485 (hi-speed) connection (port 4, device address 6) */
1927 #define CONN_HS_7   0xb /*!< RS485 (hi-speed) connection (port 4, device address 7) */
1928 #define CONN_HS_8   0xc /*!< RS485 (hi-speed) connection (port 4, device address 8) */
1929 /** @} */  // end of CommConnectionConstants group
1930 
1931 /** @defgroup CommBtHwStatusConstants Bluetooth hardware status constants
1932  * Constants related to the bluetooth hardware status.
1933  * @{
1934  */
1935 #define BT_ENABLE               0x00 /*!< BtHwStatus bluetooth enable */
1936 #define BT_DISABLE              0x01 /*!< BtHwStatus bluetooth disable */
1937 /** @} */  // end of CommBtHwStatusConstants group
1938 
1939 /** @defgroup CommHiSpeedConstants Hi-speed port constants
1940  * Constants related to the hi-speed port.
1941  * @{
1942  */
1943 /** @defgroup CommHiSpeedFlagsConstants Hi-speed port flags constants
1944  * Constants related to the hi-speed port flags.
1945  * @{
1946  */
1947 #define HS_UPDATE        1 /*!< HsFlags high speed update required */
1948 /** @} */  // end of CommHiSpeedFlagsConstants group
1949 
1950 /** @defgroup CommHiSpeedStateConstants Hi-speed port state constants
1951  * Constants related to the hi-speed port state.
1952  * @{
1953  */
1954 #define HS_INITIALISE    1 /*!< HsState initialize */
1955 #define HS_INIT_RECEIVER 2 /*!< HsState initialize receiver */
1956 #define HS_SEND_DATA     3 /*!< HsState send data */
1957 #define HS_DISABLE       4 /*!< HsState disable */
1958 #define HS_ENABLE        5 /*!< HsState enable */
1959 /** @} */  // end of CommHiSpeedStateConstants group
1960 
1961 #ifdef __ENHANCED_FIRMWARE
1962 
1963 /** @defgroup CommHiSpeedCtrlConstants Hi-speed port SysCommHSControl constants
1964  * Constants for use with the SysCommHSControl API function.
1965  * \sa SysCommHSControl()
1966  * @{
1967  */
1968 #define HS_CTRL_INIT 0 /*!< Enable the high speed port */
1969 #define HS_CTRL_UART 1 /*!< Setup the high speed port UART configuration */
1970 #define HS_CTRL_EXIT 2 /*!< Ddisable the high speed port */
1971 /** @} */  // end of CommHiSpeedCtrlConstants group
1972 
1973 #if __FIRMWARE_VERSION > 107
1974 
1975 /** @defgroup CommHiSpeedBaudConstants Hi-speed port baud rate constants
1976  * Constants for configuring the hi-speed port baud rate (HsSpeed).
1977  * @{
1978  */
1979 #define HS_BAUD_1200     0 /*!< HsSpeed 1200 Baud */
1980 #define HS_BAUD_2400     1 /*!< HsSpeed 2400 Baud */
1981 #define HS_BAUD_3600     2 /*!< HsSpeed 3600 Baud */
1982 #define HS_BAUD_4800     3 /*!< HsSpeed 4800 Baud */
1983 #define HS_BAUD_7200     4 /*!< HsSpeed 7200 Baud */
1984 #define HS_BAUD_9600     5 /*!< HsSpeed 9600 Baud */
1985 #define HS_BAUD_14400    6 /*!< HsSpeed 14400 Baud */
1986 #define HS_BAUD_19200    7 /*!< HsSpeed 19200 Baud */
1987 #define HS_BAUD_28800    8 /*!< HsSpeed 28800 Baud */
1988 #define HS_BAUD_38400    9 /*!< HsSpeed 38400 Baud */
1989 #define HS_BAUD_57600   10 /*!< HsSpeed 57600 Baud */
1990 #define HS_BAUD_76800   11 /*!< HsSpeed 76800 Baud */
1991 #define HS_BAUD_115200  12 /*!< HsSpeed 115200 Baud */
1992 #define HS_BAUD_230400  13 /*!< HsSpeed 230400 Baud */
1993 #define HS_BAUD_460800  14 /*!< HsSpeed 460800 Baud */
1994 #define HS_BAUD_921600  15 /*!< HsSpeed 921600 Baud */
1995 #define HS_BAUD_DEFAULT 15 /*!< HsSpeed default Baud (921600) */
1996 /** @} */  // end of CommHiSpeedBaudConstants group
1997 
1998 /** @defgroup CommHiSpeedModeConstants Hi-speed port UART mode constants
1999  * Constants referring to HsMode UART configuration settings
2000  * @{
2001  */
2002 #define HS_MODE_DEFAULT HS_MODE_8N1 /*!< HsMode default mode (8 data bits, no parity, 1 stop bit) */
2003 
2004 /** @defgroup CommHiSpeedDataBitsConstants Hi-speed port data bits constants
2005  * Constants referring to HsMode (number of data bits)
2006  * @{
2007  */
2008 #define HS_MODE_5_DATA 0x0000 /*!< HsMode 5 data bits */
2009 #define HS_MODE_6_DATA 0x0040 /*!< HsMode 6 data bits */
2010 #define HS_MODE_7_DATA 0x0080 /*!< HsMode 7 data bits */
2011 #define HS_MODE_8_DATA 0x00C0 /*!< HsMode 8 data bits */
2012 /** @} */  // end of CommHiSpeedDataBitsConstants group
2013 
2014 /** @defgroup CommHiSpeedStopBitsConstants Hi-speed port stop bits constants
2015  * Constants referring to HsMode (number of stop bits)
2016  * @{
2017  */
2018 #define HS_MODE_10_STOP 0x0000 /*!< HsMode 1 stop bit */
2019 #define HS_MODE_15_STOP 0x1000 /*!< HsMode 1.5 stop bits */
2020 #define HS_MODE_20_STOP 0x2000 /*!< HsMode 2 stop bits */
2021 /** @} */  // end of CommHiSpeedStopBitsConstants group
2022 
2023 /** @defgroup CommHiSpeedParityConstants Hi-speed port parity constants
2024  * Constants referring to HsMode (parity)
2025  * @{
2026  */
2027 #define HS_MODE_E_PARITY 0x0000 /*!< HsMode Even parity */
2028 #define HS_MODE_O_PARITY 0x0200 /*!< HsMode Odd parity */
2029 #define HS_MODE_S_PARITY 0x0400 /*!< HsMode Space parity */
2030 #define HS_MODE_M_PARITY 0x0600 /*!< HsMode Mark parity */
2031 #define HS_MODE_N_PARITY 0x0800 /*!< HsMode No parity */
2032 /** @} */  // end of CommHiSpeedParityConstants group
2033 
2034 /** @defgroup CommHiSpeedCombinedConstants Hi-speed port combined UART constants
2035  * Constants that combine data bits, parity, and stop bits into a single value.
2036  * @{
2037  */
2038 #define HS_MODE_8N1 (HS_MODE_8_DATA|HS_MODE_N_PARITY|HS_MODE_10_STOP) /*!< HsMode 8 data bits, no parity, 1 stop bit */
2039 #define HS_MODE_7E1 (HS_MODE_7_DATA|HS_MODE_E_PARITY|HS_MODE_10_STOP) /*!< HsMode 7 data bits, even parity, 1 stop bit */
2040 /** @} */  // end of CommHiSpeedCombinedConstants group
2041 /** @} */  // end of CommHiSpeedModeConstants group
2042 
2043 
2044 /** @defgroup CommHiSpeedAddressConstants Hi-speed port address constants
2045  * Constants that are used to specify the Hi-speed (RS-485) port device address.
2046  * @{
2047  */
2048 #define HS_ADDRESS_ALL 0 /*!< HsAddress all devices */
2049 #define HS_ADDRESS_1   1 /*!< HsAddress device address 1 */
2050 #define HS_ADDRESS_2   2 /*!< HsAddress device address 2 */
2051 #define HS_ADDRESS_3   3 /*!< HsAddress device address 3 */
2052 #define HS_ADDRESS_4   4 /*!< HsAddress device address 4 */
2053 #define HS_ADDRESS_5   5 /*!< HsAddress device address 5 */
2054 #define HS_ADDRESS_6   6 /*!< HsAddress device address 6 */
2055 #define HS_ADDRESS_7   7 /*!< HsAddress device address 7 */
2056 #define HS_ADDRESS_8   8 /*!< HsAddress device address 8 */
2057 /** @} */  // end of CommHiSpeedAddressConstants group
2058 
2059 #endif
2060 #endif
2061 /** @} */  // end of CommHiSpeedConstants group
2062 
2063 /** @defgroup CommDeviceStatusConstants Device status constants
2064  * Constants refering to DeviceStatus within DeviceTable
2065  * @{
2066  */
2067 #define BT_DEVICE_EMPTY   0x00 /*!< Bluetooth device table empty */
2068 #define BT_DEVICE_UNKNOWN 0x01 /*!< Bluetooth device unknown */
2069 #define BT_DEVICE_KNOWN   0x02 /*!< Bluetooth device known */
2070 #define BT_DEVICE_NAME    0x40 /*!< Bluetooth device name */
2071 #define BT_DEVICE_AWAY    0x80 /*!< Bluetooth device away */
2072 /** @} */  // end of CommDeviceStatusConstants group
2073 
2074 /** @defgroup CommInterfaceConstants Comm module interface function constants
2075  * Constants for all the Comm module interface functions executable via SysCommExecuteFunction.
2076  * \sa SysCommExecuteFunction()
2077  * @{
2078  */
2079 #define INTF_SENDFILE      0 /*!< Send a file via bluetooth to another device */
2080 #define INTF_SEARCH        1 /*!< Search for bluetooth devices */
2081 #define INTF_STOPSEARCH    2 /*!< Stop searching for bluetooth devices */
2082 #define INTF_CONNECT       3 /*!< Connect to one of the known devices */
2083 #define INTF_DISCONNECT    4 /*!< Disconnect from one of the connected devices */
2084 #define INTF_DISCONNECTALL 5 /*!< Disconnect all devices */
2085 #define INTF_REMOVEDEVICE  6 /*!< Remove a device from the known devices table */
2086 #define INTF_VISIBILITY    7 /*!< Set the bluetooth visibility on or off */
2087 #define INTF_SETCMDMODE    8 /*!< Set bluetooth into command mode */
2088 #define INTF_OPENSTREAM    9 /*!< Open a bluetooth stream */
2089 #define INTF_SENDDATA      10 /*!< Send data over a bluetooth connection */
2090 #define INTF_FACTORYRESET  11 /*!< Reset bluetooth settings to factory values */
2091 #define INTF_BTON          12 /*!< Turn on the bluetooth radio */
2092 #define INTF_BTOFF         13 /*!< Turn off the bluetooth radio */
2093 #define INTF_SETBTNAME     14 /*!< Set the bluetooth name */
2094 #define INTF_EXTREAD       15 /*!< External read request */
2095 #define INTF_PINREQ        16 /*!< Bluetooth PIN request */
2096 #define INTF_CONNECTREQ    17 /*!< Connection request from another device */
2097 
2098 #if __FIRMWARE_VERSION > 107
2099 #define INTF_CONNECTBYNAME 18 /*!< Connect to a bluetooth device by name */
2100 #endif
2101 /** @} */  // end of CommInterfaceConstants group
2102 
2103 /** @defgroup CommStatusCodesConstants Comm module status code constants
2104  * Constants for Comm module status codes.
2105  * @{
2106  */
2107 #define LR_SUCCESS        0x50 /*!< Bluetooth list result success */
2108 #define LR_COULD_NOT_SAVE 0x51 /*!< Bluetooth list result could not save */
2109 #define LR_STORE_IS_FULL  0x52 /*!< Bluetooth list result store is full */
2110 #define LR_ENTRY_REMOVED  0x53 /*!< Bluetooth list result entry removed */
2111 #define LR_UNKNOWN_ADDR   0x54 /*!< Bluetooth list result unknown address */
2112 
2113 #define USB_CMD_READY     0x01 /*!< A constant representing usb direct command */
2114 #define BT_CMD_READY      0x02 /*!< A constant representing bluetooth direct command */
2115 #define HS_CMD_READY      0x04 /*!< A constant representing high speed direct command */
2116 /** @} */  // end of CommStatusCodesConstants group
2117 
2118 /** @defgroup CommIOMAP Comm module IOMAP offsets
2119  * Constant offsets into the Comm module IOMAP structure.
2120  * @{
2121  */
2122 #define CommOffsetPFunc    0 /*!< Offset to the Comm module first function pointer (4 bytes) */
2123 #define CommOffsetPFuncTwo 4 /*!< Offset to the Comm module second function pointer (4 bytes) */
2124 // BtDeviceTable[30] (930 bytes)
2125 #define CommOffsetBtDeviceTableName(p)           (((p)*31)+8) /*!< Offset to BT device table name (16 bytes) */
2126 #define CommOffsetBtDeviceTableClassOfDevice(p)  (((p)*31)+24) /*!< Offset to Bluetooth device table device class (4 bytes) */
2127 #define CommOffsetBtDeviceTableBdAddr(p)         (((p)*31)+28) /*!< Offset to Bluetooth device table address (7 bytes) */
2128 #define CommOffsetBtDeviceTableDeviceStatus(p)   (((p)*31)+35) /*!< Offset to Bluetooth device table status (1 byte) */
2129 //  BDCONNECTTABLE BtConnectTable[4]; (188 bytes)
2130 #define CommOffsetBtConnectTableName(p)          (((p)*47)+938) /*!< Offset to Bluetooth connect table name (16 bytes) */
2131 #define CommOffsetBtConnectTableClassOfDevice(p) (((p)*47)+954) /*!< Offset to Bluetooth connect table device class (4 bytes) */
2132 #define CommOffsetBtConnectTablePinCode(p)       (((p)*47)+958) /*!< Offset to Bluetooth connect table pin code (16 bytes) */
2133 #define CommOffsetBtConnectTableBdAddr(p)        (((p)*47)+974) /*!< Offset to Bluetooth connect table address (7 bytes) */
2134 #define CommOffsetBtConnectTableHandleNr(p)      (((p)*47)+981) /*!< Offset to Bluetooth connect table handle (1 byte) */
2135 #define CommOffsetBtConnectTableStreamStatus(p)  (((p)*47)+982) /*!< Offset to Bluetooth connect table stream status (1 byte) */
2136 #define CommOffsetBtConnectTableLinkQuality(p)   (((p)*47)+983) /*!< Offset to Bluetooth connect table link quality (1 byte) */
2137 //General brick data
2138 //  BRICKDATA      BrickData; (31 bytes)
2139 #define CommOffsetBrickDataName            1126 /*!< Offset to brick name (16 bytes) */
2140 #define CommOffsetBrickDataBluecoreVersion 1142 /*!< Offset to Bluecore version (2 bytes) */
2141 #define CommOffsetBrickDataBdAddr          1144 /*!< Offset to Bluetooth address (7 bytes) */
2142 #define CommOffsetBrickDataBtStateStatus   1151 /*!< Offset to BtStateStatus (1 byte) */
2143 #define CommOffsetBrickDataBtHwStatus      1152 /*!< Offset to BtHwStatus (1 byte) */
2144 #define CommOffsetBrickDataTimeOutValue    1153 /*!< Offset to data timeout value (1 byte) */
2145 //  BTBUF          BtInBuf; (132 bytes)
2146 #define CommOffsetBtInBufBuf       1157 /*!< Offset to Bluetooth input buffer data (128 bytes) */
2147 #define CommOffsetBtInBufInPtr     1285 /*!< Offset to Bluetooth input buffer front pointer (1 byte) */
2148 #define CommOffsetBtInBufOutPtr    1286 /*!< Offset to Bluetooth output buffer back pointer (1 byte) */
2149 //  BTBUF          BtOutBuf; (132 bytes)
2150 #define CommOffsetBtOutBufBuf      1289 /*!< Offset to Bluetooth output buffer offset data (128 bytes) */
2151 #define CommOffsetBtOutBufInPtr    1417 /*!< Offset to Bluetooth output buffer front pointer (1 byte) */
2152 #define CommOffsetBtOutBufOutPtr   1418 /*!< Offset to Bluetooth output buffer back pointer (1 byte) */
2153 // HI Speed related entries
2154 //  HSBUF          HsInBuf; (132 bytes)
2155 #define CommOffsetHsInBufBuf       1421 /*!< Offset to High Speed input buffer data (128 bytes) */
2156 #define CommOffsetHsInBufInPtr     1549 /*!< Offset to High Speed input buffer front pointer (1 byte) */
2157 #define CommOffsetHsInBufOutPtr    1550 /*!< Offset to High Speed input buffer back pointer (1 byte) */
2158 //  HSBUF          HsOutBuf; (132 bytes)
2159 #define CommOffsetHsOutBufBuf      1553 /*!< Offset to High Speed output buffer data (128 bytes) */
2160 #define CommOffsetHsOutBufInPtr    1681 /*!< Offset to High Speed output buffer front pointer (1 byte) */
2161 #define CommOffsetHsOutBufOutPtr   1682 /*!< Offset to High Speed output buffer back pointer (1 byte) */
2162 // USB related entries
2163 //  USBBUF         UsbInBuf; (68 bytes)
2164 #define CommOffsetUsbInBufBuf        1685 /*!< Offset to Usb input buffer data (64 bytes) */
2165 #define CommOffsetUsbInBufInPtr      1749 /*!< Offset to Usb input buffer front pointer (1 byte) */
2166 #define CommOffsetUsbInBufOutPtr     1750 /*!< Offset to Usb input buffer back pointer (1 byte) */
2167 //  USBBUF         UsbOutBuf; (68 bytes)
2168 #define CommOffsetUsbOutBufBuf       1753 /*!< Offset to Usb output buffer data (64 bytes) */
2169 #define CommOffsetUsbOutBufInPtr     1817 /*!< Offset to Usb output buffer front pointer (1 byte) */
2170 #define CommOffsetUsbOutBufOutPtr    1818 /*!< Offset to Usb output buffer back pointer (1 byte) */
2171 //  USBBUF         UsbPollBuf; (68 bytes)
2172 #define CommOffsetUsbPollBufBuf      1821 /*!< Offset to Usb Poll buffer data (64 bytes) */
2173 #define CommOffsetUsbPollBufInPtr    1885 /*!< Offset to Usb Poll buffer front pointer (1 byte) */
2174 #define CommOffsetUsbPollBufOutPtr   1886 /*!< Offset to Usb Poll buffer back pointer (1 byte) */
2175 
2176 #define CommOffsetBtDeviceCnt      1889 /*!< Offset to Bluetooth device count (1 byte) */
2177 #define CommOffsetBtDeviceNameCnt  1890 /*!< Offset to Bluetooth device name count (1 byte) */
2178 #define CommOffsetHsFlags          1891 /*!< Offset to High Speed flags (1 byte) */
2179 #define CommOffsetHsSpeed          1892 /*!< Offset to High Speed speed (1 byte) */
2180 #define CommOffsetHsState          1893 /*!< Offset to High Speed state (1 byte) */
2181 #define CommOffsetUsbState         1894 /*!< Offset to Usb State (1 byte) */
2182 #ifdef __ENHANCED_FIRMWARE
2183 #define CommOffsetHsMode           1896 /*!< Offset to High Speed mode (2 bytes) */
2184 #define CommOffsetBtDataMode       1898 /*!< Offset to Bluetooth data mode (1 byte) */
2185 #define CommOffsetHsDataMode       1899 /*!< Offset to High Speed data mode (1 byte) */
2186 #endif
2187 /** @} */  // end of CommIOMAP group
2188 /** @} */  // end of CommModuleConstants group
2189 /** @} */  // end of CommModule group
2190 
2191 
2192 /** @addtogroup ThirdPartyDevices
2193  * @{
2194  */
2195 /** @defgroup RCXAPIConstants RCX constants
2196  * Constants that are for use with devices that communicate with the RCX or
2197  * Scout programmable bricks via IR such as the HiTechnic IRLink or the
2198  * MindSensors nRLink.
2199  * @{
2200  */
2201 /** @defgroup RCXOutputConstants RCX output constants
2202  * Constants for use when choosing RCX outputs.
2203  * @{
2204  */
2205 #define RCX_OUT_A   0x01 /*!< RCX Output A */
2206 #define RCX_OUT_B   0x02 /*!< RCX Output B */
2207 #define RCX_OUT_C   0x04 /*!< RCX Output C */
2208 #define RCX_OUT_AB  0x03 /*!< RCX Outputs A and B */
2209 #define RCX_OUT_AC  0x05 /*!< RCX Outputs A and C */
2210 #define RCX_OUT_BC  0x06 /*!< RCX Outputs B and C */
2211 #define RCX_OUT_ABC 0x07 /*!< RCX Outputs A, B, and C */
2212 /** @} */  // end of RCXOutputConstants group
2213 
2214 /** @defgroup RCXOutputMode RCX output mode constants
2215  * Constants for use when configuring RCX output mode.
2216  * @{
2217  */
2218 #define RCX_OUT_FLOAT 0    /*!< Set RCX output to float */
2219 #define RCX_OUT_OFF   0x40 /*!< Set RCX output to off */
2220 #define RCX_OUT_ON    0x80 /*!< Set RCX output to on */
2221 /** @} */  // end of RCXOutputMode group
2222 
2223 /** @defgroup RCXOutputDirection RCX output direction constants
2224  * Constants for use when configuring RCX output direction.
2225  * @{
2226  */
2227 #define RCX_OUT_REV    0    /*!< Set RCX output direction to reverse */
2228 #define RCX_OUT_TOGGLE 0x40 /*!< Set RCX output direction to toggle */
2229 #define RCX_OUT_FWD    0x80 /*!< Set RCX output direction to forward */
2230 /** @} */  // end of RCXOutputConstants group
2231 
2232 /** @defgroup RCXOutputPower RCX output power constants
2233  * Constants for use when configuring RCX output power.
2234  * @{
2235  */
2236 #define RCX_OUT_LOW  0 /*!< Set RCX output power level to low */
2237 #define RCX_OUT_HALF 3 /*!< Set RCX output power level to half */
2238 #define RCX_OUT_FULL 7 /*!< Set RCX output power level to full */
2239 /** @} */  // end of RCXOutputPower group
2240 
2241 /** @defgroup RCXRemoteConstants RCX IR remote constants
2242  * Constants for use when simulating RCX IR remote messages.
2243  * @{
2244  */
2245 #define RCX_RemoteKeysReleased 0x0000 /*!< All remote keys have been released */
2246 #define RCX_RemotePBMessage1   0x0100 /*!< Send PB message 1 */
2247 #define RCX_RemotePBMessage2   0x0200 /*!< Send PB message 2 */
2248 #define RCX_RemotePBMessage3   0x0400 /*!< Send PB message 3 */
2249 #define RCX_RemoteOutAForward  0x0800 /*!< Set output A forward */
2250 #define RCX_RemoteOutBForward  0x1000 /*!< Set output B forward */
2251 #define RCX_RemoteOutCForward  0x2000 /*!< Set output C forward */
2252 #define RCX_RemoteOutABackward 0x4000 /*!< Set output A backward */
2253 #define RCX_RemoteOutBBackward 0x8000 /*!< Set output B backward */
2254 #define RCX_RemoteOutCBackward 0x0001 /*!< Set output C backward */
2255 #define RCX_RemoteSelProgram1  0x0002 /*!< Select program 1 */
2256 #define RCX_RemoteSelProgram2  0x0004 /*!< Select program 2 */
2257 #define RCX_RemoteSelProgram3  0x0008 /*!< Select program 3 */
2258 #define RCX_RemoteSelProgram4  0x0010 /*!< Select program 4 */
2259 #define RCX_RemoteSelProgram5  0x0020 /*!< Select program 5 */
2260 #define RCX_RemoteStopOutOff   0x0040 /*!< Stop and turn off outputs */
2261 #define RCX_RemotePlayASound   0x0080 /*!< Play a sound */
2262 /** @} */  // end of RCXRemoteConstants group
2263 
2264 /** @defgroup RCXSoundConstants RCX and Scout sound constants
2265  * Constants for use when playing standard RCX and Scout sounds.
2266  * @{
2267  */
2268 #define SOUND_CLICK       0 /*!< Play the standard key click sound */
2269 #define SOUND_DOUBLE_BEEP 1 /*!< Play the standard double beep sound */
2270 #define SOUND_DOWN        2 /*!< Play the standard sweep down sound */
2271 #define SOUND_UP          3 /*!< Play the standard sweep up sound */
2272 #define SOUND_LOW_BEEP    4 /*!< Play the standard low beep sound */
2273 #define SOUND_FAST_UP     5 /*!< Play the standard fast up sound */
2274 /** @} */  // end of RCXSoundConstants group
2275 
2276 /** @defgroup ScoutConstants Scout constants
2277  * Constants for use when controlling the Scout brick.
2278  * @{
2279  */
2280 /** @defgroup ScoutLightConstants Scout light constants
2281  * Constants for use when controlling the Scout light settings.
2282  * @{
2283  */
2284 #define SCOUT_LIGHT_ON        0x80 /*!< Turn on the scout light */
2285 #define SCOUT_LIGHT_OFF       0    /*!< Turn off the scout light */
2286 /** @} */  // end of ScoutLightConstants group
2287 
2288 /** @defgroup ScoutSoundConstants Scout sound constants
2289  * Constants for use when playing standard Scout sounds.
2290  * @{
2291  */
2292 #define SCOUT_SOUND_REMOTE           6 /*!< Play the Scout remote sound */
2293 #define SCOUT_SOUND_ENTERSA          7 /*!< Play the Scout enter standalone sound */
2294 #define SCOUT_SOUND_KEYERROR         8 /*!< Play the Scout key error sound */
2295 #define SCOUT_SOUND_NONE             9 /*!< Play the Scout none sound */
2296 #define SCOUT_SOUND_TOUCH1_PRES     10 /*!< Play the Scout touch 1 pressed sound */
2297 #define SCOUT_SOUND_TOUCH1_REL      11 /*!< Play the Scout touch 1 released sound */
2298 #define SCOUT_SOUND_TOUCH2_PRES     12 /*!< Play the Scout touch 2 pressed sound */
2299 #define SCOUT_SOUND_TOUCH2_REL      13 /*!< Play the Scout touch 2 released sound */
2300 #define SCOUT_SOUND_ENTER_BRIGHT    14 /*!< Play the Scout enter bright sound */
2301 #define SCOUT_SOUND_ENTER_NORMAL    15 /*!< Play the Scout enter normal sound */
2302 #define SCOUT_SOUND_ENTER_DARK      16 /*!< Play the Scout enter dark sound */
2303 #define SCOUT_SOUND_1_BLINK         17 /*!< Play the Scout 1 blink sound */
2304 #define SCOUT_SOUND_2_BLINK         18 /*!< Play the Scout 2 blink sound */
2305 #define SCOUT_SOUND_COUNTER1        19 /*!< Play the Scout counter 1 sound */
2306 #define SCOUT_SOUND_COUNTER2        20 /*!< Play the Scout counter 2 sound */
2307 #define SCOUT_SOUND_TIMER1          21 /*!< Play the Scout timer 1 sound */
2308 #define SCOUT_SOUND_TIMER2          22 /*!< Play the Scout timer 2 sound */
2309 #define SCOUT_SOUND_TIMER3          23 /*!< Play the Scout timer 3 sound */
2310 #define SCOUT_SOUND_MAIL_RECEIVED   24 /*!< Play the Scout mail received sound */
2311 #define SCOUT_SOUND_SPECIAL1        25 /*!< Play the Scout special 1 sound */
2312 #define SCOUT_SOUND_SPECIAL2        26 /*!< Play the Scout special 2 sound */
2313 #define SCOUT_SOUND_SPECIAL3        27 /*!< Play the Scout special 3 sound */
2314 /** @} */  // end of ScoutSoundConstants group
2315 
2316 /** @defgroup ScoutSndSetConstants Scout sound set constants
2317  * Constants for use when choosing standard Scout sound sets.
2318  * @{
2319  */
2320 #define SCOUT_SNDSET_NONE           0 /*!< Set sound set to none */
2321 #define SCOUT_SNDSET_BASIC          1 /*!< Set sound set to basic */
2322 #define SCOUT_SNDSET_BUG            2 /*!< Set sound set to bug */
2323 #define SCOUT_SNDSET_ALARM          3 /*!< Set sound set to alarm */
2324 #define SCOUT_SNDSET_RANDOM         4 /*!< Set sound set to random */
2325 #define SCOUT_SNDSET_SCIENCE        5 /*!< Set sound set to science */
2326 /** @} */  // end of ScoutSndSetConstants group
2327 
2328 /** @defgroup ScoutModeConstants Scout mode constants
2329  * Constants for use when setting the scout mode.
2330  * @{
2331  */
2332 #define SCOUT_MODE_STANDALONE       0 /*!< Enter stand alone mode */
2333 #define SCOUT_MODE_POWER            1 /*!< Enter power mode */
2334 /** @} */  // end of ScoutModeConstants group
2335 
2336 /** @defgroup ScoutMotionRuleConstants Scout motion rule constants
2337  * Constants for use when setting the scout motion rule.
2338  * @{
2339  */
2340 #define SCOUT_MR_NO_MOTION          0 /*!< Motion rule none */
2341 #define SCOUT_MR_FORWARD            1 /*!< Motion rule forward */
2342 #define SCOUT_MR_ZIGZAG             2 /*!< Motion rule zigzag */
2343 #define SCOUT_MR_CIRCLE_RIGHT       3 /*!< Motion rule circle right */
2344 #define SCOUT_MR_CIRCLE_LEFT        4 /*!< Motion rule circle left */
2345 #define SCOUT_MR_LOOP_A             5 /*!< Motion rule loop A */
2346 #define SCOUT_MR_LOOP_B             6 /*!< Motion rule loop B */
2347 #define SCOUT_MR_LOOP_AB            7 /*!< Motion rule loop A then B */
2348 /** @} */  // end of ScoutMotionRuleConstants group
2349 
2350 /** @defgroup ScoutTouchRuleConstants Scout touch rule constants
2351  * Constants for use when setting the scout touch rule.
2352  * @{
2353  */
2354 #define SCOUT_TR_IGNORE             0 /*!< Touch rule ignore */
2355 #define SCOUT_TR_REVERSE            1 /*!< Touch rule reverse */
2356 #define SCOUT_TR_AVOID              2 /*!< Touch rule avoid */
2357 #define SCOUT_TR_WAIT_FOR           3 /*!< Touch rule wait for */
2358 #define SCOUT_TR_OFF_WHEN           4 /*!< Touch rule off when */
2359 /** @} */  // end of ScoutTouchRuleConstants group
2360 
2361 /** @defgroup ScoutLightRuleConstants Scout light rule constants
2362  * Constants for use when setting the scout light rule.
2363  * @{
2364  */
2365 #define SCOUT_LR_IGNORE             0 /*!< Light rule ignore */
2366 #define SCOUT_LR_SEEK_LIGHT         1 /*!< Light rule seek light */
2367 #define SCOUT_LR_SEEK_DARK          2 /*!< Light rule seek dark */
2368 #define SCOUT_LR_AVOID              3 /*!< Light rule avoid */
2369 #define SCOUT_LR_WAIT_FOR           4 /*!< Light rule wait for */
2370 #define SCOUT_LR_OFF_WHEN           5 /*!< Light rule off when */
2371 /** @} */  // end of ScoutLightRuleConstants group
2372 
2373 /** @defgroup ScoutTransmitRuleConstants Scout transmit rule constants
2374  * Constants for use when setting the scout transmit rule.
2375  * @{
2376  */
2377 #define SCOUT_TGS_SHORT             0 /*!< Transmit level short */
2378 #define SCOUT_TGS_MEDIUM            1 /*!< Transmit level medium */
2379 #define SCOUT_TGS_LONG              2 /*!< Transmit level long */
2380 /** @} */  // end of ScoutTransmitRuleConstants group
2381 
2382 /** @defgroup ScoutSpecialEffectConstants Scout special effect constants
2383  * Constants for use when setting the scout special effect.
2384  * @{
2385  */
2386 #define SCOUT_FXR_NONE              0 /*!< No special effects */
2387 #define SCOUT_FXR_BUG               1 /*!< Bug special effects */
2388 #define SCOUT_FXR_ALARM             2 /*!< Alarm special effects */
2389 #define SCOUT_FXR_RANDOM            3 /*!< Random special effects */
2390 #define SCOUT_FXR_SCIENCE           4 /*!< Science special effects */
2391 /** @} */  // end of ScoutSpecialEffectConstants group
2392 /** @} */  // end of ScoutConstants group
2393 
2394 /** @defgroup RCXSourceConstants RCX and Scout source constants
2395  * Constants for use when specifying RCX and Scout sources.
2396  * @{
2397  */
2398 #define RCX_VariableSrc             0  /*!< The RCX variable source */
2399 #define RCX_TimerSrc                1  /*!< The RCX timer source */
2400 #define RCX_ConstantSrc             2  /*!< The RCX constant value source */
2401 #define RCX_OutputStatusSrc         3  /*!< The RCX output status source */
2402 #define RCX_RandomSrc               4  /*!< The RCX random number source */
2403 #define RCX_ProgramSlotSrc          8  /*!< The RCX program slot source */
2404 #define RCX_InputValueSrc           9  /*!< The RCX input value source */
2405 #define RCX_InputTypeSrc            10 /*!< The RCX input type source */
2406 #define RCX_InputModeSrc            11 /*!< The RCX input mode source */
2407 #define RCX_InputRawSrc             12 /*!< The RCX input raw source */
2408 #define RCX_InputBooleanSrc         13 /*!< The RCX input boolean source */
2409 #define RCX_WatchSrc                14 /*!< The RCX watch source */
2410 #define RCX_MessageSrc              15 /*!< The RCX message source */
2411 #define RCX_GlobalMotorStatusSrc    17 /*!< The RCX global motor status source */
2412 #define RCX_ScoutRulesSrc           18 /*!< The Scout rules source */
2413 #define RCX_ScoutLightParamsSrc     19 /*!< The Scout light parameters source */
2414 #define RCX_ScoutTimerLimitSrc      20 /*!< The Scout timer limit source */
2415 #define RCX_CounterSrc              21 /*!< The RCX counter source */
2416 #define RCX_ScoutCounterLimitSrc    22 /*!< The Scout counter limit source */
2417 #define RCX_TaskEventsSrc           23 /*!< The RCX task events source */
2418 #define RCX_ScoutEventFBSrc         24 /*!< The Scout event feedback source */
2419 #define RCX_EventStateSrc           25 /*!< The RCX event static source */
2420 #define RCX_TenMSTimerSrc           26 /*!< The RCX 10ms timer source */
2421 #define RCX_ClickCounterSrc         27 /*!< The RCX event click counter source */
2422 #define RCX_UpperThresholdSrc       28 /*!< The RCX event upper threshold source */
2423 #define RCX_LowerThresholdSrc       29 /*!< The RCX event lower threshold source */
2424 #define RCX_HysteresisSrc           30 /*!< The RCX event hysteresis source */
2425 #define RCX_DurationSrc             31 /*!< The RCX event duration source */
2426 #define RCX_UARTSetupSrc            33 /*!< The RCX UART setup source */
2427 #define RCX_BatteryLevelSrc         34 /*!< The RCX battery level source */
2428 #define RCX_FirmwareVersionSrc      35 /*!< The RCX firmware version source */
2429 #define RCX_IndirectVarSrc          36 /*!< The RCX indirect variable source */
2430 #define RCX_DatalogSrcIndirectSrc   37 /*!< The RCX indirect datalog source source */
2431 #define RCX_DatalogSrcDirectSrc     38 /*!< The RCX direct datalog source source */
2432 #define RCX_DatalogValueIndirectSrc 39 /*!< The RCX indirect datalog value source */
2433 #define RCX_DatalogValueDirectSrc   40 /*!< The RCX direct datalog value source */
2434 #define RCX_DatalogRawIndirectSrc   41 /*!< The RCX indirect datalog raw source */
2435 #define RCX_DatalogRawDirectSrc     42 /*!< The RCX direct datalog raw source */
2436 /** @} */  // end of RCXSourceConstants group
2437 
2438 /** @defgroup RCXOpcodeConstants RCX and Scout opcode constants
2439  * Constants for use when specifying RCX and Scout opcodes.
2440  * @{
2441  */
2442 #define RCX_PingOp           0x10 /*!< Ping the brick */
2443 #define RCX_BatteryLevelOp   0x30 /*!< Read the battery level */
2444 #define RCX_DeleteTasksOp    0x40 /*!< Delete tasks */
2445 #define RCX_StopAllTasksOp   0x50 /*!< Stop all tasks */
2446 #define RCX_PBTurnOffOp      0x60 /*!< Turn off the brick */
2447 #define RCX_DeleteSubsOp     0x70 /*!< Delete subroutines */
2448 #define RCX_ClearSoundOp     0x80 /*!< Clear sound */
2449 #define RCX_ClearMsgOp       0x90 /*!< Clear message */
2450 #define RCX_LSCalibrateOp    0xc0 /*!< Calibrate the light sensor */
2451 #define RCX_MuteSoundOp      0xd0 /*!< Mute sound */
2452 #define RCX_UnmuteSoundOp    0xe0 /*!< Unmute sound */
2453 #define RCX_ClearAllEventsOp 0x06 /*!< Clear all events */
2454 #define RCX_OnOffFloatOp     0x21 /*!< Control motor state - on, off, float */
2455 #define RCX_IRModeOp         0x31 /*!< Set the IR transmit mode */
2456 #define RCX_PlaySoundOp      0x51 /*!< Play a sound */
2457 #define RCX_DeleteTaskOp     0x61 /*!< Delete a task */
2458 #define RCX_StartTaskOp      0x71 /*!< Start a task */
2459 #define RCX_StopTaskOp       0x81 /*!< Stop a task */
2460 #define RCX_SelectProgramOp  0x91 /*!< Select a program slot */
2461 #define RCX_ClearTimerOp     0xa1 /*!< Clear a timer */
2462 #define RCX_AutoOffOp        0xb1 /*!< Set auto off timer */
2463 #define RCX_DeleteSubOp      0xc1 /*!< Delete a subroutine */
2464 #define RCX_ClearSensorOp    0xd1 /*!< Clear a sensor */
2465 #define RCX_OutputDirOp      0xe1 /*!< Set the motor direction */
2466 #define RCX_PlayToneVarOp    0x02 /*!< Play a tone using a variable */
2467 #define RCX_PollOp           0x12 /*!< Poll a source/value combination */
2468 #define RCX_SetWatchOp       0x22 /*!< Set the watch source/value */
2469 #define RCX_InputTypeOp      0x32 /*!< Set the input type */
2470 #define RCX_InputModeOp      0x42 /*!< Set the input mode */
2471 #define RCX_SetDatalogOp     0x52 /*!< Set the datalog size */
2472 #define RCX_DatalogOp        0x62 /*!< Datalog the specified source/value*/
2473 #define RCX_SendUARTDataOp   0xc2 /*!< Send data via IR using UART settings */
2474 #define RCX_RemoteOp         0xd2 /*!< Execute simulated remote control buttons */
2475 #define RCX_VLLOp            0xe2 /*!< Send visual light link (VLL) data */
2476 #define RCX_DirectEventOp    0x03 /*!< Fire an event */
2477 #define RCX_OutputPowerOp    0x13 /*!< Set the motor power level */
2478 #define RCX_PlayToneOp       0x23 /*!< Play a tone */
2479 #define RCX_DisplayOp        0x33 /*!< Set LCD display value */
2480 #define RCX_PollMemoryOp     0x63 /*!< Poll a memory location */
2481 #define RCX_SetFeedbackOp    0x83 /*!< Set Scout feedback */
2482 #define RCX_SetEventOp       0x93 /*!< Set an event */
2483 #define RCX_GOutputPowerOp   0xa3 /*!< Set global motor power levels */
2484 #define RCX_LSUpperThreshOp  0xb3 /*!< Set the light sensor upper threshold */
2485 #define RCX_LSLowerThreshOp  0xc3 /*!< Set the light sensor lower threshold */
2486 #define RCX_LSHysteresisOp   0xd3 /*!< Set the light sensor hysteresis */
2487 #define RCX_LSBlinkTimeOp    0xe3 /*!< Set the light sensor blink time */
2488 #define RCX_CalibrateEventOp 0x04 /*!< Calibrate event */
2489 #define RCX_SetVarOp         0x14 /*!< Set function */
2490 #define RCX_SumVarOp         0x24 /*!< Sum function */
2491 #define RCX_SubVarOp         0x34 /*!< Subtract function */
2492 #define RCX_DivVarOp         0x44 /*!< Divide function */
2493 #define RCX_MulVarOp         0x54 /*!< Multiply function */
2494 #define RCX_SgnVarOp         0x64 /*!< Sign function */
2495 #define RCX_AbsVarOp         0x74 /*!< Absolute value function */
2496 #define RCX_AndVarOp         0x84 /*!< AND function */
2497 #define RCX_OrVarOp          0x94 /*!< OR function */
2498 #define RCX_UploadDatalogOp  0xa4 /*!< Upload datalog contents */
2499 #define RCX_SetTimerLimitOp  0xc4 /*!< Set timer limit */
2500 #define RCX_SetCounterOp     0xd4 /*!< Set counter value */
2501 #define RCX_SetSourceValueOp 0x05 /*!< Set a source/value*/
2502 #define RCX_UnlockOp         0x15 /*!< Unlock the brick */
2503 #define RCX_BootModeOp       0x65 /*!< Set into book mode */
2504 #define RCX_UnlockFirmOp     0xa5 /*!< Unlock the firmware */
2505 #define RCX_ScoutRulesOp     0xd5 /*!< Set Scout rules */
2506 #define RCX_ViewSourceValOp  0xe5 /*!< View a source/value */
2507 #define RCX_ScoutOp          0x47 /*!< Scout opcode */
2508 #define RCX_SoundOp          0x57 /*!< Sound opcode */
2509 #define RCX_GOutputModeOp    0x67 /*!< Set global motor mode */
2510 #define RCX_GOutputDirOp     0x77 /*!< Set global motor direction */
2511 #define RCX_LightOp          0x87 /*!< Light opcode */
2512 #define RCX_IncCounterOp     0x97 /*!< Increment a counter */
2513 #define RCX_DecCounterOp     0xa7 /*!< Decrement a counter */
2514 #define RCX_ClearCounterOp   0xb7 /*!< Clear a counter */
2515 #define RCX_SetPriorityOp    0xd7 /*!< Set task priority */
2516 #define RCX_MessageOp        0xf7 /*!< Set message */
2517 /** @} */  // end of RCXOpcodeConstants group
2518 /** @} */  // end of RCXAPIConstants group
2519 
2520 /** @defgroup HTIRLinkPFConstants HiTechnic/mindsensors Power Function/IR Train constants
2521  * Constants that are for use with the HiTechnic IRLink or mindsensors nRLink
2522  * in Power Function or IR Train mode.
2523  * @{
2524  */
2525 /** @defgroup PFCmdConstants Power Function command constants
2526  * Constants that are for sending Power Function commands.
2527  * @{
2528  */
2529 #define PF_CMD_STOP  0 /*!< Power function command stop */
2530 #define PF_CMD_FLOAT 0 /*!< Power function command float (same as stop) */
2531 #define PF_CMD_FWD   1 /*!< Power function command forward */
2532 #define PF_CMD_REV   2 /*!< Power function command reverse */
2533 #define PF_CMD_BRAKE 3 /*!< Power function command brake */
2534 /** @} */  // end of PFCmdConstants group
2535 
2536 /** @defgroup PFChannelConstants Power Function channel constants
2537  * Constants that are for specifying Power Function channels.
2538  * @{
2539  */
2540 #define PF_CHANNEL_1 0 /*!< Power function channel 1 */
2541 #define PF_CHANNEL_2 1 /*!< Power function channel 2 */
2542 #define PF_CHANNEL_3 2 /*!< Power function channel 3 */
2543 #define PF_CHANNEL_4 3 /*!< Power function channel 4 */
2544 /** @} */  // end of PFChannelConstants group
2545 
2546 /** @defgroup PFModeConstants Power Function mode constants
2547  * Constants that are for choosing Power Function modes.
2548  * @{
2549  */
2550 #define PF_MODE_TRAIN             0 /*!< Power function mode IR Train */
2551 #define PF_MODE_COMBO_DIRECT      1 /*!< Power function mode combo direct */
2552 #define PF_MODE_SINGLE_PIN_CONT   2 /*!< Power function mode single pin continuous */
2553 #define PF_MODE_SINGLE_PIN_TIME   3 /*!< Power function mode single pin timed */
2554 #define PF_MODE_COMBO_PWM         4 /*!< Power function mode combo pulse width modulation (PWM) */
2555 #define PF_MODE_SINGLE_OUTPUT_PWM 4 /*!< Power function mode single output pulse width modulation (PWM) */
2556 #define PF_MODE_SINGLE_OUTPUT_CST 6 /*!< Power function mode single output clear, set, toggle (CST) */
2557 /** @} */  // end of PFModeConstants group
2558 
2559 /** @defgroup IRTrainFuncs PF/IR Train function constants
2560  * Constants that are for sending PF/IR Train functions.
2561  * @{
2562  */
2563 #define TRAIN_FUNC_STOP         0 /*!< PF/IR Train function stop */
2564 #define TRAIN_FUNC_INCR_SPEED   1 /*!< PF/IR Train function increment speed */
2565 #define TRAIN_FUNC_DECR_SPEED   2 /*!< PF/IR Train function decrement speed */
2566 #define TRAIN_FUNC_TOGGLE_LIGHT 4 /*!< PF/IR Train function toggle light */
2567 /** @} */  // end of IRTrainFuncs group
2568 
2569 /** @defgroup IRTrainChannels IR Train channel constants
2570  * Constants that are for specifying IR Train channels.
2571  * @{
2572  */
2573 #define TRAIN_CHANNEL_1   0 /*!< IR Train channel 1 */
2574 #define TRAIN_CHANNEL_2   1 /*!< IR Train channel 2 */
2575 #define TRAIN_CHANNEL_3   2 /*!< IR Train channel 3 */
2576 #define TRAIN_CHANNEL_ALL 3 /*!< IR Train channel all */
2577 /** @} */  // end of IRTrainChannels group
2578 
2579 /** @defgroup PFOutputs Power Function output constants
2580  * Constants that are for choosing a Power Function output.
2581  * @{
2582  */
2583 #define PF_OUT_A 0 /*!< Power function output A */
2584 #define PF_OUT_B 1 /*!< Power function output B */
2585 /** @} */  // end of PFOutputs group
2586 
2587 /** @defgroup PFPinConstants Power Function pin constants
2588  * Constants that are for choosing a Power Function pin.
2589  * @{
2590  */
2591 #define PF_PIN_C1 0 /*!< Power function pin C1 */
2592 #define PF_PIN_C2 1 /*!< Power function pin C2 */
2593 /** @} */  // end of PFOutputs group
2594 
2595 /** @defgroup PFPinFuncs Power Function single pin function constants
2596  * Constants that are for sending Power Function single pin functions.
2597  * @{
2598  */
2599 #define PF_FUNC_NOCHANGE 0 /*!< Power function single pin - no change */
2600 #define PF_FUNC_CLEAR    1 /*!< Power function single pin - clear */
2601 #define PF_FUNC_SET      2 /*!< Power function single pin - set */
2602 #define PF_FUNC_TOGGLE   3 /*!< Power function single pin - toggle */
2603 /** @} */  // end of PFCSTFuncs group
2604 
2605 /** @defgroup PFCSTOptions Power Function CST options constants
2606  * Constants that are for specifying Power Function CST options.
2607  * @{
2608  */
2609 #define PF_CST_CLEAR1_CLEAR2 0 /*!< Power function CST clear 1 and clear 2 */
2610 #define PF_CST_SET1_CLEAR2   1 /*!< Power function CST set 1 and clear 2*/
2611 #define PF_CST_CLEAR1_SET2   2 /*!< Power function CST clear 1 and set 2 */
2612 #define PF_CST_SET1_SET2     3 /*!< Power function CST set 1 and set 2 */
2613 #define PF_CST_INCREMENT_PWM 4 /*!< Power function CST increment PWM */
2614 #define PF_CST_DECREMENT_PWM 5 /*!< Power function CST decrement PWM */
2615 #define PF_CST_FULL_FWD      6 /*!< Power function CST full forward */
2616 #define PF_CST_FULL_REV      7 /*!< Power function CST full reverse */
2617 #define PF_CST_TOGGLE_DIR    8 /*!< Power function CST toggle direction*/
2618 /** @} */  // end of PFCSTOptions group
2619 
2620 /** @defgroup PFPWMOptions Power Function PWM option constants
2621  * Constants that are for specifying Power Function PWM options.
2622  * @{
2623  */
2624 #define PF_PWM_FLOAT 0  /*!< Power function PWM float */
2625 #define PF_PWM_FWD1  1  /*!< Power function PWM foward level 1 */
2626 #define PF_PWM_FWD2  2  /*!< Power function PWM foward level 2 */
2627 #define PF_PWM_FWD3  3  /*!< Power function PWM foward level 3 */
2628 #define PF_PWM_FWD4  4  /*!< Power function PWM foward level 4 */
2629 #define PF_PWM_FWD5  5  /*!< Power function PWM foward level 5 */
2630 #define PF_PWM_FWD6  6  /*!< Power function PWM foward level 6 */
2631 #define PF_PWM_FWD7  7  /*!< Power function PWM foward level 7 */
2632 #define PF_PWM_BRAKE 8  /*!< Power function PWM brake */
2633 #define PF_PWM_REV7  9  /*!< Power function PWM reverse level 7  */
2634 #define PF_PWM_REV6  10 /*!< Power function PWM reverse level 6 */
2635 #define PF_PWM_REV5  11 /*!< Power function PWM reverse level 5 */
2636 #define PF_PWM_REV4  12 /*!< Power function PWM reverse level 4 */
2637 #define PF_PWM_REV3  13 /*!< Power function PWM reverse level 3 */
2638 #define PF_PWM_REV2  14 /*!< Power function PWM reverse level 2 */
2639 #define PF_PWM_REV1  15 /*!< Power function PWM reverse level 1 */
2640 /** @} */  // end of PFPWMOptions group
2641 /** @} */  // end of HTIRLinkPFConstants group
2642 
2643 /** @addtogroup HiTechnicAPI
2644  * @{
2645  */
2646 /** @defgroup HiTechnicConstants HiTechnic device constants
2647  * Constants that are for use with HiTechnic devices.
2648  * @{
2649  */
2650 
2651 #define HT_ADDR_IRSEEKER   0x02 /*!< HiTechnic IRSeeker I2C address */
2652 #define HT_ADDR_IRSEEKER2  0x10 /*!< HiTechnic IRSeeker2 I2C address */
2653 #define HT_ADDR_IRRECEIVER 0x02 /*!< HiTechnic IRReceiver I2C address */
2654 #define HT_ADDR_COMPASS    0x02 /*!< HiTechnic Compass I2C address */
2655 #define HT_ADDR_ACCEL      0x02 /*!< HiTechnic Accel I2C address */
2656 #define HT_ADDR_COLOR      0x02 /*!< HiTechnic Color I2C address */
2657 #define HT_ADDR_COLOR2     0x02 /*!< HiTechnic Color2 I2C address */
2658 #define HT_ADDR_IRLINK     0x02 /*!< HiTechnic IRLink I2C address */
2659 #define HT_ADDR_ANGLE      0x02 /*!< HiTechnic Angle I2C address */
2660 
2661 /** @defgroup HTIRSeeker2Constants HiTechnic IRSeeker2 constants
2662  * Constants that are for use with the HiTechnic IRSeeker2 device.
2663  * @{
2664  */
2665 #define HTIR2_MODE_1200 0 /*!< Set IRSeeker2 to 1200 mode */
2666 #define HTIR2_MODE_600  1 /*!< Set IRSeeker2 to 600 mode */
2667 
2668 #define HTIR2_REG_MODE  0x41 /*!< IRSeeker2 mode register */
2669 #define HTIR2_REG_DCDIR 0x42 /*!< IRSeeker2 DC direction register */
2670 #define HTIR2_REG_DC01  0x43 /*!< IRSeeker2 DC 01 register */
2671 #define HTIR2_REG_DC02  0x44 /*!< IRSeeker2 DC 02 register */
2672 #define HTIR2_REG_DC03  0x45 /*!< IRSeeker2 DC 03 register */
2673 #define HTIR2_REG_DC04  0x46 /*!< IRSeeker2 DC 04 register */
2674 #define HTIR2_REG_DC05  0x47 /*!< IRSeeker2 DC 05 register */
2675 #define HTIR2_REG_DCAVG 0x48 /*!< IRSeeker2 DC average register */
2676 #define HTIR2_REG_ACDIR 0x49 /*!< IRSeeker2 AC direction register */
2677 #define HTIR2_REG_AC01  0x4A /*!< IRSeeker2 AC 01 register */
2678 #define HTIR2_REG_AC02  0x4B /*!< IRSeeker2 AC 02 register */
2679 #define HTIR2_REG_AC03  0x4C /*!< IRSeeker2 AC 03 register */
2680 #define HTIR2_REG_AC04  0x4D /*!< IRSeeker2 AC 04 register */
2681 #define HTIR2_REG_AC05  0x4E /*!< IRSeeker2 AC 05 register */
2682 /** @} */  // end of HTIRSeeker2Constants group
2683 
2684 /** @defgroup HTIRReceiverConstants HiTechnic IRReceiver constants
2685  * Constants that are for use with the HiTechnic IRReceiver device.
2686  * @{
2687  */
2688 #define HT_CH1_A 0 /*!< Use IRReceiver channel 1 output A */
2689 #define HT_CH1_B 1 /*!< Use IRReceiver channel 1 output B */
2690 #define HT_CH2_A 2 /*!< Use IRReceiver channel 2 output A */
2691 #define HT_CH2_B 3 /*!< Use IRReceiver channel 2 output B */
2692 #define HT_CH3_A 4 /*!< Use IRReceiver channel 3 output A */
2693 #define HT_CH3_B 5 /*!< Use IRReceiver channel 3 output B */
2694 #define HT_CH4_A 6 /*!< Use IRReceiver channel 4 output A */
2695 #define HT_CH4_B 7 /*!< Use IRReceiver channel 4 output B */
2696 /** @} */  // end of HTIRSeeker2Constants group
2697 
2698 /** @defgroup HTColor2Constants HiTechnic Color2 constants
2699  * Constants that are for use with the HiTechnic Color2 device.
2700  * @{
2701  */
2702 #define HT_CMD_COLOR2_ACTIVE  0x00 /*!< Set the Color2 sensor to active mode */
2703 #define HT_CMD_COLOR2_PASSIVE 0x01 /*!< Set the Color2 sensor to passive mode */
2704 #define HT_CMD_COLOR2_RAW     0x03 /*!< Set the Color2 sensor to raw mode */
2705 #define HT_CMD_COLOR2_50HZ    0x35 /*!< Set the Color2 sensor to 50Hz mode */
2706 #define HT_CMD_COLOR2_60HZ    0x36 /*!< Set the Color2 sensor to 60Hz mode */
2707 #define HT_CMD_COLOR2_BLCAL   0x42 /*!< Set the Color2 sensor to black level calibration mode */
2708 #define HT_CMD_COLOR2_WBCAL   0x43 /*!< Set the Color2 sensor to white level calibration mode */
2709 #define HT_CMD_COLOR2_FAR     0x46 /*!< Set the Color2 sensor to far mode */
2710 #define HT_CMD_COLOR2_LED_HI  0x48 /*!< Set the Color2 sensor to LED high mode */
2711 #define HT_CMD_COLOR2_LED_LOW 0x4C /*!< Set the Color2 sensor to LED low mode */
2712 #define HT_CMD_COLOR2_NEAR    0x4E /*!< Set the Color2 sensor to near mode */
2713 /** @} */  // end of HTColor2Constants group
2714 
2715 /** @defgroup HTAngleConstants HiTechnic Angle sensor constants
2716  * Constants that are for use with the HiTechnic Angle sensor device.
2717  * @{
2718  */
2719 #define HTANGLE_MODE_NORMAL    0x00 /*!< Normal angle measurement mode */
2720 #define HTANGLE_MODE_CALIBRATE 0x43 /*!< Resets 0 degree position to current shaft angle */
2721 #define HTANGLE_MODE_RESET     0x52 /*!< Resets the accumulated angle */
2722 
2723 #define HTANGLE_REG_MODE  0x41 /*!< Angle mode register */
2724 #define HTANGLE_REG_DCDIR 0x42 /*!< Angle current angle (2 degree increments) register */
2725 #define HTANGLE_REG_DC01  0x43 /*!< Angle current angle (1 degree adder) register */
2726 #define HTANGLE_REG_DC02  0x44 /*!< Angle 32 bit accumulated angle, high byte register */
2727 #define HTANGLE_REG_DC03  0x45 /*!< Angle 32 bit accumulated angle, mid byte register */
2728 #define HTANGLE_REG_DC04  0x46 /*!< Angle 32 bit accumulated angle, mid byte register */
2729 #define HTANGLE_REG_DC05  0x47 /*!< Angle 32 bit accumulated angle, low byte register */
2730 #define HTANGLE_REG_DCAVG 0x48 /*!< Angle 16 bit revolutions per minute, high byte register */
2731 #define HTANGLE_REG_ACDIR 0x49 /*!< Angle 16 bit revolutions per minute, low byte register */
2732 /** @} */  // end of HTAngleConstants group
2733 
2734 
2735 /** @} */  // end of HiTechnicConstants group
2736 /** @} */  // end of HiTechnicAPI group
2737 
2738 
2739 /** @addtogroup MindSensorsAPI
2740  * @{
2741  */
2742 /** @defgroup MindSensorsConstants MindSensors device constants
2743  * Constants that are for use with MindSensors devices.
2744  * @{
2745  */
2746 // MindSensors constants
2747 #define MS_CMD_ENERGIZED   0x45 /*!< Energize the MindSensors device */
2748 #define MS_CMD_DEENERGIZED 0x44 /*!< De-energize the MindSensors device */
2749 #define MS_CMD_ADPA_ON     0x4E /*!< Turn MindSensors ADPA mode on */
2750 #define MS_CMD_ADPA_OFF    0x4F /*!< Turn MindSensors ADPA mode off */
2751 
2752 #define MS_ADDR_RTCLOCK     0xD0 /*!< MindSensors RTClock I2C address */
2753 #define MS_ADDR_DISTNX      0x02 /*!< MindSensors DIST-Nx I2C address */
2754 #define MS_ADDR_NRLINK      0x02 /*!< MindSensors NRLink I2C address */
2755 #define MS_ADDR_ACCLNX      0x02 /*!< MindSensors ACCL-Nx I2C address */
2756 #define MS_ADDR_CMPSNX      0x02 /*!< MindSensors CMPS-Nx I2C address */
2757 #define MS_ADDR_PSPNX       0x02 /*!< MindSensors PSP-Nx I2C address */
2758 #define MS_ADDR_LINELDR     0x02 /*!< MindSensors LineLdr I2C address */
2759 #define MS_ADDR_NXTCAM      0x02 /*!< MindSensors NXTCam I2C address */
2760 #define MS_ADDR_NXTHID      0x04 /*!< MindSensors NXTHID I2C address */
2761 #define MS_ADDR_NXTSERVO    0xB0 /*!< MindSensors NXTServo I2C address */
2762 #define MS_ADDR_NXTSERVO_EM 0x40 /*!< MindSensors NXTServo in edit macro mode I2C address */
2763 #define MS_ADDR_PFMATE      0x48 /*!< MindSensors PFMate I2C address */
2764 #define MS_ADDR_MTRMUX      0xB4 /*!< MindSensors MTRMux I2C address */
2765 #define MS_ADDR_NXTMMX      0x06 /*!< MindSensors NXTMMX I2C address */
2766 #define MS_ADDR_IVSENS      0x12 /*!< MindSensors IVSens (NXTPowerMeter) I2C address */
2767 #define MS_ADDR_RXMUX       0x7E /*!< MindSensors RXMux I2C address */
2768 
2769 /** @defgroup MSDistNX MindSensors DIST-Nx constants
2770  * Constants that are for use with the MindSensors DIST-Nx device.
2771  * @{
2772  */
2773 // DIST-Nx Commands
2774 #define DIST_CMD_GP2D12      0x31 /*!< Set the DIST-Nx to GP2D12 mode */
2775 #define DIST_CMD_GP2D120     0x32 /*!< Set the DIST-Nx to GP2D120 mode */
2776 #define DIST_CMD_GP2YA21     0x33 /*!< Set the DIST-Nx to GP2YA21 mode */
2777 #define DIST_CMD_GP2YA02     0x34 /*!< Set the DIST-Nx to GP2YA02 mode */
2778 #define DIST_CMD_CUSTOM      0x35 /*!< Set the DIST-Nx to a custom mode */
2779 
2780 // DIST-Nx Registers
2781 #define DIST_REG_DIST          0x42 /*!< The DIST-Nx distance register */
2782 #define DIST_REG_VOLT          0x44 /*!< The DIST-Nx voltage register */
2783 #define DIST_REG_MODULE_TYPE   0x50 /*!< The DIST-Nx module type register */
2784 #define DIST_REG_NUM_POINTS    0x51 /*!< The DIST-Nx number of data points in Custom curve register */
2785 #define DIST_REG_DIST_MIN      0x52 /*!< The DIST-Nx minimum distance register */
2786 #define DIST_REG_DIST_MAX      0x54 /*!< The DIST-Nx maximum distance register */
2787 #define DIST_REG_VOLT1         0x56 /*!< The DIST-Nx voltage 1 register */
2788 #define DIST_REG_DIST1         0x58 /*!< The DIST-Nx distance 1 register */
2789 /** @} */  // end of MSDistNX group
2790 
2791 /** @defgroup MSPSPNX MindSensors PSP-Nx constants
2792  * Constants that are for use with the MindSensors PSP-Nx device.
2793  * @{
2794  */
2795 // PSP-Nx commands
2796 #define PSP_CMD_DIGITAL 0x41 /*!< Set the PSP-Nx to digital mode */
2797 #define PSP_CMD_ANALOG  0x73 /*!< Set the PSP-Nx to analog mode */
2798 
2799 // PSP-Nx registers
2800 #define PSP_REG_BTNSET1 0x42 /*!< The PSP-Nx button set 1 register */
2801 #define PSP_REG_BTNSET2 0x43 /*!< The PSP-Nx button set 2 register */
2802 #define PSP_REG_XLEFT   0x44 /*!< The PSP-Nx X left register */
2803 #define PSP_REG_YLEFT   0x45 /*!< The PSP-Nx Y left register */
2804 #define PSP_REG_XRIGHT  0x46 /*!< The PSP-Nx X right register */
2805 #define PSP_REG_YRIGHT  0x47 /*!< The PSP-Nx Y right register */
2806 
2807 /** @defgroup MSPSPNXBtnSet1 MindSensors PSP-Nx button set 1 constants
2808  * Constants that are for interpretting MindSensors PSP-Nx button set 1 values.
2809  * @{
2810  */
2811 #define PSP_BTNSET1_LEFT     0x01 /*!< The PSP-Nx button set 1 left arrow */
2812 #define PSP_BTNSET1_DOWN     0x02 /*!< The PSP-Nx button set 1 down arrow */
2813 #define PSP_BTNSET1_RIGHT    0x04 /*!< The PSP-Nx button set 1 right arrow */
2814 #define PSP_BTNSET1_UP       0x08 /*!< The PSP-Nx button set 1 up arrow */
2815 #define PSP_BTNSET1_R3       0x20 /*!< The PSP-Nx button set 1 R3 */
2816 #define PSP_BTNSET1_L3       0x40 /*!< The PSP-Nx button set 1 L3 */
2817 /** @} */  // end of MSPSPNXBtnSet1 group
2818 
2819 /** @defgroup MSPSPNXBtnSet2 MindSensors PSP-Nx button set 2 constants
2820  * Constants that are for interpretting MindSensors PSP-Nx button set 2 values.
2821  * @{
2822  */
2823 #define PSP_BTNSET2_SQUARE   0x01 /*!< The PSP-Nx button set 2 square */
2824 #define PSP_BTNSET2_CROSS    0x02 /*!< The PSP-Nx button set 2 cross */
2825 #define PSP_BTNSET2_CIRCLE   0x04 /*!< The PSP-Nx button set 2 circle */
2826 #define PSP_BTNSET2_TRIANGLE 0x08 /*!< The PSP-Nx button set 2 triangle */
2827 #define PSP_BTNSET2_R1       0x10 /*!< The PSP-Nx button set 2 R1 */
2828 #define PSP_BTNSET2_L1       0x20 /*!< The PSP-Nx button set 2 L1 */
2829 #define PSP_BTNSET2_R2       0x40 /*!< The PSP-Nx button set 2 R2 */
2830 #define PSP_BTNSET2_L2       0x80 /*!< The PSP-Nx button set 2 L2 */
2831 /** @} */  // end of MSPSPNXBtnSet2 group
2832 /** @} */  // end of MSPSPNX group
2833 
2834 /** @defgroup MSNRLink MindSensors nRLink constants
2835  * Constants that are for use with the MindSensors nRLink device.
2836  * @{
2837  */
2838 // NRLink commands
2839 #define NRLINK_CMD_2400      0x44 /*!< Set NRLink to 2400 baud */
2840 #define NRLINK_CMD_FLUSH     0x46 /*!< Flush the NRLink */
2841 #define NRLINK_CMD_4800      0x48 /*!< Set NRLink to 4800 baud */
2842 #define NRLINK_CMD_IR_LONG   0x4C /*!< Set the NRLink to long range IR */
2843 #define NRLINK_CMD_IR_SHORT  0x53 /*!< Set the NRLink to short range IR */
2844 #define NRLINK_CMD_RUN_MACRO 0x52 /*!< Run an NRLink macro */
2845 #define NRLINK_CMD_TX_RAW    0x55 /*!< Set the NRLink to transmit raw bytes */
2846 #define NRLINK_CMD_SET_RCX   0x58 /*!< Set the NRLink to RCX mode */
2847 #define NRLINK_CMD_SET_TRAIN 0x54 /*!< Set the NRLink to IR Train mode */
2848 #define NRLINK_CMD_SET_PF    0x50 /*!< Set the NRLink to Power Function mode */
2849 
2850 // NRLink registers
2851 #define NRLINK_REG_BYTES  0x40 /*!< The NRLink bytes register */
2852 #define NRLINK_REG_DATA   0x42 /*!< The NRLink data register */
2853 #define NRLINK_REG_EEPROM 0x50 /*!< The NRLink eeprom register */
2854 
2855 /** @} */  // end of MSNRLink group
2856 
2857 /** @defgroup MSACCLNx MindSensors ACCL-Nx constants
2858  * Constants that are for use with the MindSensors ACCL-Nx device.
2859  * @{
2860  */
2861 // ACCL-Nx commands
2862 #define ACCL_CMD_X_CAL      0x58 /*!< Acquire X-axis calibration point */
2863 #define ACCL_CMD_Y_CAL      0x59 /*!< Acquire Y-axis calibration point */
2864 #define ACCL_CMD_Z_CAL      0x5a /*!< Acquire Z-axis calibration point */
2865 #define ACCL_CMD_X_CAL_END  0x78 /*!< Acquire X-axis calibration point and end calibration */
2866 #define ACCL_CMD_Y_CAL_END  0x79 /*!< Acquire Y-axis calibration point and end calibration */
2867 #define ACCL_CMD_Z_CAL_END  0x7a /*!< Acquire Z-axis calibration point and end calibration */
2868 #define ACCL_CMD_RESET_CAL  0x52 /*!< Reset to factory calibration */
2869 
2870 // ACCL-Nx registers
2871 #define ACCL_REG_SENS_LVL 0x19 /*!< The current sensitivity */
2872 #define ACCL_REG_X_TILT   0x42 /*!< The X-axis tilt data */
2873 #define ACCL_REG_Y_TILT   0x43 /*!< The Y-axis tilt data */
2874 #define ACCL_REG_Z_TILT   0x44 /*!< The Z-axis tilt data */
2875 #define ACCL_REG_X_ACCEL  0x45 /*!< The X-axis acceleration data */
2876 #define ACCL_REG_Y_ACCEL  0x47 /*!< The Y-axis acceleration data */
2877 #define ACCL_REG_Z_ACCEL  0x49 /*!< The Z-axis acceleration data */
2878 #define ACCL_REG_X_OFFSET 0x4b /*!< The X-axis offset */
2879 #define ACCL_REG_X_RANGE  0x4d /*!< The X-axis range */
2880 #define ACCL_REG_Y_OFFSET 0x4f /*!< The Y-axis offset */
2881 #define ACCL_REG_Y_RANGE  0x51 /*!< The Y-axis range */
2882 #define ACCL_REG_Z_OFFSET 0x53 /*!< The Z-axis offset */
2883 #define ACCL_REG_Z_RANGE  0x55 /*!< The Z-axis range */
2884 
2885 /** @defgroup MSACCLNxSLevel MindSensors ACCL-Nx sensitivity level constants
2886  * Constants that are for setting the MindSensors ACCL-Nx sensitivity level.
2887  * @{
2888  */
2889 #define ACCL_SENSITIVITY_LEVEL_1 0x31 /*!< The ACCL-Nx sensitivity level 1 */
2890 #define ACCL_SENSITIVITY_LEVEL_2 0x32 /*!< The ACCL-Nx sensitivity level 2 */
2891 #define ACCL_SENSITIVITY_LEVEL_3 0x33 /*!< The ACCL-Nx sensitivity level 3 */
2892 #define ACCL_SENSITIVITY_LEVEL_4 0x34 /*!< The ACCL-Nx sensitivity level 4 */
2893 /** @} */  // end of MSACCLNxSLevel group
2894 
2895 /** @} */  // end of MSACCLNx group
2896 
2897 /** @defgroup PFMateConstants MindSensors PFMate constants
2898  * Constants that are for use with the MindSensors PFMate device.
2899  * @{
2900  */
2901 #define PFMATE_REG_CMD     0x41 /*!< PFMate command */
2902 #define PFMATE_REG_CHANNEL 0x42 /*!< PF channel? 1, 2, 3, or 4 */
2903 #define PFMATE_REG_MOTORS  0x43 /*!< PF motors? (0 = both, 1 = A, 2 = B) */
2904 #define PFMATE_REG_A_CMD   0x44 /*!< PF command for motor A? (PF_CMD_FLOAT, PF_CMD_FWD, PF_CMD_REV, PF_CMD_BRAKE) */
2905 #define PFMATE_REG_A_SPEED 0x45 /*!< PF speed for motor A? (0-7) */
2906 #define PFMATE_REG_B_CMD   0x46 /*!< PF command for motor B? (PF_CMD_FLOAT, PF_CMD_FWD, PF_CMD_REV, PF_CMD_BRAKE) */
2907 #define PFMATE_REG_B_SPEED 0x47 /*!< PF speed for motor B? (0-7) */
2908 
2909 #define PFMATE_CMD_GO      0x47 /*!< Send IR signal to IR receiver */
2910 #define PFMATE_CMD_RAW     0x52 /*!< Send raw IR signal to IR receiver */
2911 
2912 /** @defgroup PFMateMotorConstants PFMate motor constants
2913  * Constants that are for specifying PFMate motors.
2914  * @{
2915  */
2916 #define PFMATE_MOTORS_BOTH 0x00 /*!< Control both motors */
2917 #define PFMATE_MOTORS_A    0x01 /*!< Control only motor A */
2918 #define PFMATE_MOTORS_B    0x02 /*!< Control only motor B */
2919 /** @} */  // end of PFMateMotorConstants group
2920 
2921 /** @defgroup PFMateChannelConstants PFMate channel constants
2922  * Constants that are for specifying PFMate channels.
2923  * @{
2924  */
2925 #define PFMATE_CHANNEL_1 1 /*!< Power function channel 1 */
2926 #define PFMATE_CHANNEL_2 2 /*!< Power function channel 2 */
2927 #define PFMATE_CHANNEL_3 3 /*!< Power function channel 3 */
2928 #define PFMATE_CHANNEL_4 4 /*!< Power function channel 4 */
2929 /** @} */  // end of PFMateChannelConstants group
2930 
2931 /** @} */  // end of PFMateConstants group
2932 
2933 /** @defgroup NXTServoConstants MindSensors NXTServo constants
2934  * Constants that are for use with the MindSensors NXTServo device.
2935  * @{
2936  */
2937 /** @defgroup NXTServoRegisters MindSensors NXTServo registers
2938  * NXTServo device register constants.
2939  * @{
2940  */
2941 #define NXTSERVO_REG_VOLTAGE   0x41 /*!< Battery voltage register. (read only) */
2942 #define NXTSERVO_REG_CMD       0x41 /*!< NXTServo command register.  See \ref NXTServoCommands group. (write only) */
2943 // position registers (2 bytes little endian)
2944 #define NXTSERVO_REG_S1_POS    0x42 /*!< NXTServo servo 1 position register. */
2945 #define NXTSERVO_REG_S2_POS    0x44 /*!< NXTServo servo 2 position register. */
2946 #define NXTSERVO_REG_S3_POS    0x46 /*!< NXTServo servo 3 position register. */
2947 #define NXTSERVO_REG_S4_POS    0x48 /*!< NXTServo servo 4 position register. */
2948 #define NXTSERVO_REG_S5_POS    0x4A /*!< NXTServo servo 5 position register. */
2949 #define NXTSERVO_REG_S6_POS    0x4C /*!< NXTServo servo 6 position register. */
2950 #define NXTSERVO_REG_S7_POS    0x4E /*!< NXTServo servo 7 position register. */
2951 #define NXTSERVO_REG_S8_POS    0x50 /*!< NXTServo servo 8 position register. */
2952 // speed registers
2953 #define NXTSERVO_REG_S1_SPEED  0x52 /*!< NXTServo servo 1 speed register. */
2954 #define NXTSERVO_REG_S2_SPEED  0x53 /*!< NXTServo servo 2 speed register. */
2955 #define NXTSERVO_REG_S3_SPEED  0x54 /*!< NXTServo servo 3 speed register. */
2956 #define NXTSERVO_REG_S4_SPEED  0x55 /*!< NXTServo servo 4 speed register. */
2957 #define NXTSERVO_REG_S5_SPEED  0x56 /*!< NXTServo servo 5 speed register. */
2958 #define NXTSERVO_REG_S6_SPEED  0x57 /*!< NXTServo servo 6 speed register. */
2959 #define NXTSERVO_REG_S7_SPEED  0x58 /*!< NXTServo servo 7 speed register. */
2960 #define NXTSERVO_REG_S8_SPEED  0x59 /*!< NXTServo servo 8 speed register. */
2961 // quick position registers
2962 #define NXTSERVO_REG_S1_QPOS   0x5A /*!< NXTServo servo 1 quick position register. (write only) */
2963 #define NXTSERVO_REG_S2_QPOS   0x5B /*!< NXTServo servo 2 quick position register. (write only) */
2964 #define NXTSERVO_REG_S3_QPOS   0x5C /*!< NXTServo servo 3 quick position register. (write only) */
2965 #define NXTSERVO_REG_S4_QPOS   0x5D /*!< NXTServo servo 4 quick position register. (write only) */
2966 #define NXTSERVO_REG_S5_QPOS   0x5E /*!< NXTServo servo 5 quick position register. (write only) */
2967 #define NXTSERVO_REG_S6_QPOS   0x5F /*!< NXTServo servo 6 quick position register. (write only) */
2968 #define NXTSERVO_REG_S7_QPOS   0x60 /*!< NXTServo servo 7 quick position register. (write only) */
2969 #define NXTSERVO_REG_S8_QPOS   0x61 /*!< NXTServo servo 8 quick position register. (write only) */
2970 
2971 #define NXTSERVO_EM_REG_CMD          0x00 /*!< NXTServo in macro edit mode command register. */
2972 #define NXTSERVO_EM_REG_EEPROM_START 0x21 /*!< NXTServo in macro edit mode EEPROM start register. */
2973 #define NXTSERVO_EM_REG_EEPROM_END   0xFF /*!< NXTServo in macro edit mode EEPROM end register. */
2974 /** @} */  // end of NXTServoRegisters group
2975 
2976 /** @defgroup NXTServoPos MindSensors NXTServo position constants
2977  * NXTServo device position constants.
2978  * @{
2979  */
2980 #define NXTSERVO_POS_CENTER 1500 /*!< Center position for 1500us servos. */
2981 #define NXTSERVO_POS_MIN     500 /*!< Minimum position for 1500us servos. */
2982 #define NXTSERVO_POS_MAX    2500 /*!< Maximum position for 1500us servos. */
2983 /** @} */  // end of NXTServoPos group
2984 
2985 /** @defgroup NXTServoQPos MindSensors NXTServo quick position constants
2986  * NXTServo device quick position constants.
2987  * @{
2988  */
2989 #define NXTSERVO_QPOS_CENTER 150 /*!< Center quick position for 1500us servos. */
2990 #define NXTSERVO_QPOS_MIN     50 /*!< Minimum quick position for 1500us servos. */
2991 #define NXTSERVO_QPOS_MAX    250 /*!< Maximum quick position for 1500us servos. */
2992 /** @} */  // end of NXTServoQPos group
2993 
2994 /** @defgroup NXTServoNumbers MindSensors NXTServo servo numbers
2995  * NXTServo device servo number constants.
2996  * @{
2997  */
2998 #define NXTSERVO_SERVO_1 0 /*!< NXTServo server number 1. */
2999 #define NXTSERVO_SERVO_2 1 /*!< NXTServo server number 2. */
3000 #define NXTSERVO_SERVO_3 2 /*!< NXTServo server number 3. */
3001 #define NXTSERVO_SERVO_4 3 /*!< NXTServo server number 4. */
3002 #define NXTSERVO_SERVO_5 4 /*!< NXTServo server number 5. */
3003 #define NXTSERVO_SERVO_6 5 /*!< NXTServo server number 6. */
3004 #define NXTSERVO_SERVO_7 6 /*!< NXTServo server number 7. */
3005 #define NXTSERVO_SERVO_8 7 /*!< NXTServo server number 8. */
3006 /** @} */  // end of NXTServoNumbers group
3007 
3008 /** @defgroup NXTServoCommands MindSensors NXTServo commands
3009  * NXTServo device command constants. These are written to the command register
3010  * to control the device.
3011  * @{
3012  */
3013 #define NXTSERVO_CMD_INIT    0x49 /*!< Store the initial speed and position properties of the servo motor 'n'. Current speed and position values of the nth servo is read from the servo speed register and servo position register and written to permanent memory. */
3014 #define NXTSERVO_CMD_RESET   0x53 /*!< Reset servo properties to factory default.  Initial Position of servos to 1500, and speed to 0. */
3015 #define NXTSERVO_CMD_HALT    0x48 /*!< Halt Macro. This command re-initializes the macro environment. */
3016 #define NXTSERVO_CMD_RESUME  0x52 /*!< Resume macro Execution. This command resumes macro where it was paused last, using the same environment. */
3017 #define NXTSERVO_CMD_GOTO    0x47 /*!< Goto EEPROM position x. This command re-initializes the macro environment. */
3018 #define NXTSERVO_CMD_PAUSE   0x50 /*!< Pause Macro. This command will pause the macro, and save the environment for subsequent resumption. */
3019 #define NXTSERVO_CMD_EDIT1   0x45 /*!< Edit Macro (part 1 of 2 character command sequence) */
3020 #define NXTSERVO_CMD_EDIT2   0x4D /*!< Edit Macro (part 2 of 2 character command sequence) */
3021 #define NXTSERVO_EM_CMD_QUIT 0x51 /*!< Exit edit macro mode */
3022 /** @} */  // end of NXTServoCommands group
3023 /** @} */  // end of NXTServoConstants group
3024 
3025 /** @defgroup NXTHIDConstants MindSensors NXTHID constants
3026  * Constants that are for use with the MindSensors NXTHID device.
3027  * @{
3028  */
3029 /** @defgroup NXTHIDRegisters MindSensors NXTHID registers
3030  * NXTHID device register constants.
3031  * @{
3032  */
3033 #define NXTHID_REG_CMD       0x41 /*!< NXTHID command register.  See \ref NXTHIDCommands group. */
3034 #define NXTHID_REG_MODIFIER  0x42 /*!< NXTHID modifier register.  See \ref NXTHIDModifiers group. */
3035 #define NXTHID_REG_DATA      0x43 /*!< NXTHID data register. */
3036 /** @} */  // end of NXTHIDRegisters group
3037 
3038 /** @defgroup NXTHIDModifiers MindSensors NXTHID modifier keys
3039  * NXTHID device modifier key constants.
3040  * @{
3041  */
3042 #define NXTHID_MOD_NONE        0x00 /*!< NXTHID no modifier. */
3043 #define NXTHID_MOD_LEFT_CTRL   0x01 /*!< NXTHID left control modifier. */
3044 #define NXTHID_MOD_LEFT_SHIFT  0x02 /*!< NXTHID left shift modifier. */
3045 #define NXTHID_MOD_LEFT_ALT    0x04 /*!< NXTHID left alt modifier. */
3046 #define NXTHID_MOD_LEFT_GUI    0x08 /*!< NXTHID left gui modifier. */
3047 #define NXTHID_MOD_RIGHT_CTRL  0x10 /*!< NXTHID right control modifier. */
3048 #define NXTHID_MOD_RIGHT_SHIFT 0x20 /*!< NXTHID right shift modifier. */
3049 #define NXTHID_MOD_RIGHT_ALT   0x40 /*!< NXTHID right alt modifier. */
3050 #define NXTHID_MOD_RIGHT_GUI   0x80 /*!< NXTHID right gui modifier. */
3051 /** @} */  // end of NXTHIDModifiers group
3052 
3053 /** @defgroup NXTHIDCommands MindSensors NXTHID commands
3054  * NXTHID device command constants. These are written to the command register
3055  * to control the device.
3056  * @{
3057  */
3058 #define NXTHID_CMD_ASCII    0x41 /*!< Use ASCII data mode. In ASCII mode no non-printable characters can be sent. */
3059 #define NXTHID_CMD_DIRECT   0x44 /*!< Use direct data mode In direct mode any character can be sent. */
3060 #define NXTHID_CMD_TRANSMIT 0x54 /*!< Transmit data to the host computer. */
3061 /** @} */  // end of NXTHIDCommands group
3062 /** @} */  // end of NXTHIDConstants group
3063 
3064 /** @defgroup NXTPowerMeterConstants MindSensors NXTPowerMeter constants
3065  * Constants that are for use with the MindSensors NXTPowerMeter device.
3066  * @{
3067  */
3068 /** @defgroup NXTPowerMeterRegisters MindSensors NXTPowerMeter registers
3069  * NXTPowerMeter device register constants.
3070  * @{
3071  */
3072 #define NXTPM_REG_CMD        0x41 /*!< NXTPowerMeter command register.  See the \ref NXTPowerMeterCommands group. */
3073 #define NXTPM_REG_CURRENT    0x42 /*!< NXTPowerMeter present current in mA register. (2 bytes) */
3074 #define NXTPM_REG_VOLTAGE    0x44 /*!< NXTPowerMeter present voltage in mV register. (2 bytes) */
3075 #define NXTPM_REG_CAPACITY   0x46 /*!< NXTPowerMeter capacity used since last reset register. (2 bytes) */
3076 #define NXTPM_REG_POWER      0x48 /*!< NXTPowerMeter present power register. (2 bytes) */
3077 #define NXTPM_REG_TOTALPOWER 0x4A /*!< NXTPowerMeter total power consumed since last reset register. (4 bytes) */
3078 #define NXTPM_REG_MAXCURRENT 0x4E /*!< NXTPowerMeter max current register. (2 bytes) */
3079 #define NXTPM_REG_MINCURRENT 0x50 /*!< NXTPowerMeter min current register. (2 bytes) */
3080 #define NXTPM_REG_MAXVOLTAGE 0x52 /*!< NXTPowerMeter max voltage register. (2 bytes) */
3081 #define NXTPM_REG_MINVOLTAGE 0x54 /*!< NXTPowerMeter min voltage register. (2 bytes) */
3082 #define NXTPM_REG_TIME       0x56 /*!< NXTPowerMeter time register. (4 bytes) */
3083 #define NXTPM_REG_USERGAIN   0x5A /*!< NXTPowerMeter user gain register. Not yet implemented. (4 bytes) */
3084 #define NXTPM_REG_GAIN       0x5E /*!< NXTPowerMeter gain register. (1 byte) */
3085 #define NXTPM_REG_ERRORCOUNT 0x5F /*!< NXTPowerMeter error count register. (2 bytes) */
3086 /** @} */  // end of NXTPowerMeterRegisters group
3087 
3088 /** @defgroup NXTPowerMeterCommands MindSensors NXTPowerMeter commands
3089  * NXTPowerMeter device command constants. These are written to the command register
3090  * to control the device.
3091  * @{
3092  */
3093 #define NXTPM_CMD_RESET    0x52 /*!< Reset counters. */
3094 /** @} */  // end of NXTPowerMeterCommands group
3095 /** @} */  // end of NXTPowerMeterConstants group
3096 
3097 /** @defgroup NXTSumoEyesConstants MindSensors NXTSumoEyes constants
3098  * Constants that are for use with the MindSensors NXTSumoEyes device.
3099  * @{
3100  */
3101 #define NXTSE_ZONE_NONE  0 /*!< Obstacle zone none. */
3102 #define NXTSE_ZONE_FRONT 1 /*!< Obstacle zone front. */
3103 #define NXTSE_ZONE_LEFT  2 /*!< Obstacle zone left. */
3104 #define NXTSE_ZONE_RIGHT 3 /*!< Obstacle zone right. */
3105 /** @} */  // end of NXTSumoEyesConstants group
3106 
3107 /** @defgroup NXTLineLeaderConstants MindSensors NXTLineLeader constants
3108  * Constants that are for use with the MindSensors NXTLineLeader device.
3109  * @{
3110  */
3111 /** @defgroup NXTLineLeaderRegisters MindSensors NXTLineLeader registers
3112  * NXTLineLeader device register constants.
3113  * @{
3114  */
3115 #define NXTLL_REG_CMD         0x41 /*!< NXTLineLeader command register.  See the \ref NXTLineLeaderCommands group. */
3116 #define NXTLL_REG_STEERING    0x42 /*!< NXTLineLeader steering register. */
3117 #define NXTLL_REG_AVERAGE     0x43 /*!< NXTLineLeader average result register. */
3118 #define NXTLL_REG_RESULT      0x44 /*!< NXTLineLeader result register (sensor bit values). */
3119 #define NXTLL_REG_SETPOINT    0x45 /*!< NXTLineLeader user settable average (setpoint) register. Default = 45. */
3120 #define NXTLL_REG_KP_VALUE    0x46 /*!< NXTLineLeader Kp value register. Default = 25. */
3121 #define NXTLL_REG_KI_VALUE    0x47 /*!< NXTLineLeader Ki value register. Default = 0. */
3122 #define NXTLL_REG_KD_VALUE    0x48 /*!< NXTLineLeader Kd value register. Default = 8. */
3123 #define NXTLL_REG_CALIBRATED  0x49 /*!< NXTLineLeader calibrated sensor reading registers. 8 bytes. */
3124 #define NXTLL_REG_WHITELIMITS 0x51 /*!< NXTLineLeader white limit registers. 8 bytes. */
3125 #define NXTLL_REG_BLACKLIMITS 0x59 /*!< NXTLineLeader black limit registers. 8 bytes. */
3126 #define NXTLL_REG_KP_FACTOR   0x61 /*!< NXTLineLeader Kp factor register. Default = 32. */
3127 #define NXTLL_REG_KI_FACTOR   0x62 /*!< NXTLineLeader Ki factor register. Default = 32. */
3128 #define NXTLL_REG_KD_FACTOR   0x63 /*!< NXTLineLeader Kd factor register. Default = 32. */
3129 #define NXTLL_REG_WHITEDATA   0x64 /*!< NXTLineLeader white calibration data registers. 8 bytes. */
3130 #define NXTLL_REG_BLACKDATA   0x6C /*!< NXTLineLeader black calibration data registers. 8 bytes. */
3131 #define NXTLL_REG_RAWVOLTAGE  0x74 /*!< NXTLineLeader uncalibrated sensor voltage registers. 16 bytes. */
3132 /** @} */  // end of NXTLineLeaderRegisters group
3133 
3134 /** @defgroup NXTLineLeaderCommands MindSensors NXTLineLeader commands
3135  * NXTLineLeader device command constants. These are written to the command register
3136  * to control the device.
3137  * @{
3138  */
3139 #define NXTLL_CMD_USA       0x41 /*!< USA power frequency. (60hz) */
3140 #define NXTLL_CMD_BLACK     0x42 /*!< Black calibration. */
3141 #define NXTLL_CMD_POWERDOWN 0x44 /*!< Power down the device. */
3142 #define NXTLL_CMD_EUROPEAN  0x45 /*!< European power frequency. (50hz) */
3143 #define NXTLL_CMD_INVERT    0x49 /*!< Invert color. */
3144 #define NXTLL_CMD_POWERUP   0x50 /*!< Power up the device. */
3145 #define NXTLL_CMD_RESET     0x52 /*!< Reset inversion. */
3146 #define NXTLL_CMD_SNAPSHOT  0x53 /*!< Setpoint based on snapshot (automatically sets invert if needed). */
3147 #define NXTLL_CMD_UNIVERSAL 0x55 /*!< Universal power frequency. The sensor auto adjusts for any frequency. This is the default mode. */
3148 #define NXTLL_CMD_WHITE     0x57 /*!< White balance calibration. */
3149 /** @} */  // end of NXTLineLeaderCommands group
3150 /** @} */  // end of NXTLineLeaderConstants group
3151 
3152 /** @} */  // end of MindSensorsConstants group
3153 /** @} */  // end of MindSensorsAPI group
3154 
3155 
3156 /** @addtogroup CodatexAPI
3157  * @{
3158  */
3159 /** @defgroup CodatexConstants Codatex device constants
3160  * Constants that are for use with Codatex devices.
3161  * @{
3162  */
3163 /** @defgroup CTRFIDConstants Codatex RFID sensor constants
3164  * Constants that are for use with the Codatex RFID sensor device.
3165  * @{
3166  */
3167 /** @defgroup CTRFIDModeConstants Codatex RFID sensor modes
3168  * Constants that are for configuring the Codatex RFID sensor mode.
3169  * @{
3170  */
3171 #define RFID_MODE_STOP       0  /*!< Stop the RFID device */
3172 #define RFID_MODE_SINGLE     1  /*!< Configure the RFID device for a single reading */
3173 #define RFID_MODE_CONTINUOUS 2  /*!< Configure the RFID device for continuous reading */
3174 /** @} */  // end of CTRFIDModeConstants group
3175 
3176 #define CT_ADDR_RFID     0x04   /*!< RFID I2C address */
3177 
3178 #define CT_REG_STATUS    0x32   /*!< RFID status register */
3179 #define CT_REG_MODE      0x41   /*!< RFID mode register */
3180 #define CT_REG_DATA      0x42   /*!< RFID data register */
3181 
3182 /** @} */  // end of CTRFIDConstants group
3183 /** @} */  // end of CodatexConstants group
3184 /** @} */  // end of CodatexAPI group
3185 
3186 /** @} */  // end of ThirdPartyDevices group
3187 
3188 
3189 /** @addtogroup RICMacros
3190  * @{
3191  */
3192 /**
3193  * Output an RIC ImgPoint structure
3194  * \param _X The X coordinate.
3195  * \param _Y The Y coordinate.
3196  */
3197 #define RICImgPoint(_X, _Y) (_X)&0xFF, (_X)>>8, (_Y)&0xFF, (_Y)>>8
3198 
3199 /**
3200  * Output an RIC ImgRect structure
3201  * \param _Pt An ImgPoint. See \ref RICImgPoint.
3202  * \param _W The rectangle width.
3203  * \param _H The rectangle height.
3204  */
3205 #define RICImgRect(_Pt, _W, _H) _Pt, (_W)&0xFF, (_W)>>8, (_H)&0xFF, (_H)>>8
3206 
3207 /**
3208  * Output an RIC Description opcode
3209  * \param _Options RIC options.
3210  * \param _Width The total RIC width.
3211  * \param _Height The total RIC height.
3212  */
3213 #define RICOpDescription(_Options, _Width, _Height) 8, 0, 0, 0, (_Options)&0xFF, (_Options)>>8, (_Width)&0xFF, (_Width)>>8, (_Height)&0xFF, (_Height)>>8
3214 
3215 /**
3216  * Output an RIC CopyBits opcode
3217  * \param _CopyOptions CopyBits copy options.  See \ref DisplayDrawOptionConstants.
3218  * \param _DataAddr The address of the sprite from which to copy data.
3219  * \param _SrcRect The rectangular portion of the sprite to copy.  See \ref RICImgRect.
3220  * \param _DstPoint The LCD coordinate to which to copy the data.  See \ref RICImgPoint.
3221  */
3222 #define RICOpCopyBits(_CopyOptions, _DataAddr, _SrcRect, _DstPoint) 18, 0, 3, 0, (_CopyOptions)&0xFF, (_CopyOptions)>>8, (_DataAddr)&0xFF, (_DataAddr)>>8, _SrcRect, _DstPoint
3223 
3224 /**
3225  * Output an RIC Pixel opcode
3226  * \param _CopyOptions Pixel copy options.  See \ref DisplayDrawOptionConstants.
3227  * \param _Point The pixel coordinate. See \ref RICImgPoint.
3228  * \param _Value The pixel value (unused).
3229  */
3230 #define RICOpPixel(_CopyOptions, _Point, _Value) 10, 0, 4, 0, (_CopyOptions)&0xFF, (_CopyOptions)>>8, _Point, (_Value)&0xFF, (_Value)>>8
3231 
3232 /**
3233  * Output an RIC Line opcode
3234  * \param _CopyOptions Line copy options.  See \ref DisplayDrawOptionConstants.
3235  * \param _Point1 The starting point of the line.  See \ref RICImgPoint.
3236  * \param _Point2 The ending point of the line.  See \ref RICImgPoint.
3237  */
3238 #define RICOpLine(_CopyOptions, _Point1, _Point2) 12, 0, 5, 0, (_CopyOptions)&0xFF, (_CopyOptions)>>8, _Point1, _Point2
3239 
3240 /**
3241  * Output an RIC Rect opcode
3242  * \param _CopyOptions Rect copy options.  See \ref DisplayDrawOptionConstants.
3243  * \param _Point The rectangle's top left corner.  See \ref RICImgPoint.
3244  * \param _Width The rectangle's width.
3245  * \param _Height The rectangle's height.
3246  */
3247 #define RICOpRect(_CopyOptions, _Point, _Width, _Height) 12, 0, 6, 0, (_CopyOptions)&0xFF, (_CopyOptions)>>8, _Point, (_Width)&0xFF, (_Width)>>8, (_Height)&0xFF, (_Height)>>8
3248 
3249 /**
3250  * Output an RIC Circle opcode
3251  * \param _CopyOptions Circle copy options.  See \ref DisplayDrawOptionConstants.
3252  * \param _Point The circle's center point.  See \ref RICImgPoint.
3253  * \param _Radius The circle's radius.
3254  */
3255 #define RICOpCircle(_CopyOptions, _Point, _Radius) 10, 0, 7, 0, (_CopyOptions)&0xFF, (_CopyOptions)>>8, _Point, (_Radius)&0xFF, (_Radius)>>8
3256 
3257 /**
3258  * Output an RIC NumBox opcode
3259  * \param _CopyOptions NumBox copy options.  See \ref DisplayDrawOptionConstants.
3260  * \param _Point The numbox bottom left corner.  See \ref RICImgPoint.
3261  * \param _Value The number to draw.
3262  */
3263 #define RICOpNumBox(_CopyOptions, _Point, _Value) 10, 0, 8, 0, (_CopyOptions)&0xFF, (_CopyOptions)>>8, _Point, (_Value)&0xFF, (_Value)>>8
3264 
3265 /**
3266  * Output an RIC Sprite opcode
3267  * \param _DataAddr The address of the sprite.
3268  * \param _Rows The number of rows of data.
3269  * \param _BytesPerRow The number of bytes per row.
3270  * \param _SpriteData The actual sprite data. See \ref RICSpriteData.
3271  */
3272 #define RICOpSprite(_DataAddr, _Rows, _BytesPerRow, _SpriteData) ((_Rows*_BytesPerRow)+((_Rows*_BytesPerRow)%2)+8)&0xFF, ((_Rows*_BytesPerRow)+((_Rows*_BytesPerRow)%2)+8)>>8, 1, 0, (_DataAddr)&0xFF, (_DataAddr)>>8, (_Rows)&0xFF, (_Rows)>>8, (_BytesPerRow)&0xFF, (_BytesPerRow)>>8, _SpriteData
3273 
3274 /**
3275  * Output RIC sprite data
3276  */
3277 #define RICSpriteData(...) __VA_ARGS__
3278 
3279 /**
3280  * Output an RIC VarMap opcode
3281  * \param _DataAddr The address of the varmap.
3282  * \param _MapCount The number of points in the function.
3283  * \param _MapFunction The definition of the varmap function.  See \ref RICMapFunction.
3284  */
3285 #define RICOpVarMap(_DataAddr, _MapCount, _MapFunction) ((_MapCount*4)+6)&0xFF, ((_MapCount*4)+6)>>8, 2, 0, (_DataAddr)&0xFF, (_DataAddr)>>8, (_MapCount)&0xFF, (_MapCount)>>8, _MapFunction
3286 
3287 /**
3288  * Output an RIC map element
3289  * \param _Domain The map element domain.
3290  * \param _Range The map element range.
3291  */
3292 #define RICMapElement(_Domain, _Range) (_Domain)&0xFF, (_Domain)>>8, (_Range)&0xFF, (_Range)>>8
3293 
3294 /**
3295  * Output an RIC VarMap function
3296  * \param _MapElement An entry in the varmap function.  At least 2 elements are
3297  * required.  See \ref RICMapElement.
3298  */
3299 #define RICMapFunction(_MapElement, ...) _MapElement, __VA_ARGS__
3300 
3301 /**
3302  * Output an RIC parameterized argument
3303  * \param _arg The argument that you want to parameterize.
3304  */
3305 #define RICArg(_arg) ((_arg)|0x1000)
3306 
3307 /**
3308  * Output an RIC parameterized and mapped argument
3309  * \param _mapidx The varmap data address.
3310  * \param _arg The parameterized argument you want to pass through a varmap.
3311  */
3312 #define RICMapArg(_mapidx, _arg) ((_arg)|0x1000|(((_mapidx)&0xF)<<8))
3313 
3314 /**
3315  * Output an RIC Polygon opcode
3316  * \param _CopyOptions Polygon copy options.  See \ref DisplayDrawOptionConstants.
3317  * \param _Count The number of points in the polygon.
3318  * \param _ThePoints The list of polygon points.  See \ref RICPolygonPoints.
3319  */
3320 #define RICOpPolygon(_CopyOptions, _Count, _ThePoints)  ((_Count*4)+6)&0xFF, ((_Count*4)+6)>>8, 10, 0, (_CopyOptions)&0xFF, (_CopyOptions)>>8, (_Count)&0xFF, (_Count)>>8, _ThePoints
3321 
3322 /**
3323  * Output RIC polygon points
3324  * \param _pPoint1 The first polygon point.  See \ref RICImgPoint.
3325  * \param _pPoint2 The second polygon point (at least 3 points are required).
3326  * See \ref RICImgPoint.
3327  */
3328 #define RICPolygonPoints(_pPoint1, _pPoint2, ...) _pPoint1, _pPoint2, __VA_ARGS__
3329 
3330 /**
3331  * Output an RIC Ellipse opcode
3332  * \param _CopyOptions Ellipse copy options.  See \ref DisplayDrawOptionConstants.
3333  * \param _Point The center of the ellipse. See \ref RICImgPoint.
3334  * \param _RadiusX The x-axis radius of the ellipse.
3335  * \param _RadiusY The y-axis radius of the ellipse.
3336  */
3337 #define RICOpEllipse(_CopyOptions, _Point, _RadiusX, _RadiusY) 12, 0, 9, 0, (_CopyOptions)&0xFF, (_CopyOptions)>>8, _Point, (_RadiusX)&0xFF, (_RadiusX)>>8, (_RadiusY)&0xFF, (_RadiusY)>>8
3338 
3339 /** @} */  // end of RICMacros group
3340 
3341 /** @addtogroup MiscConstants
3342  * @{
3343  */
3344 /** @defgroup NXTLimits Data type limits
3345  * Constants that define various data type limits.
3346  * @{
3347  */
3348 #define CHAR_BIT   8           /*!< The number of bits in the char type */
3349 #define SCHAR_MIN  -128        /*!< The minimum value of the signed char type */
3350 #define SCHAR_MAX  127         /*!< The maximum value of the signed char type */
3351 #define UCHAR_MAX  255         /*!< The maximum value of the unsigned char type */
3352 #define CHAR_MIN   -128        /*!< The minimum value of the char type */
3353 #define CHAR_MAX   127         /*!< The maximum value of the char type */
3354 #define SHRT_MIN   -32768      /*!< The minimum value of the short type */
3355 #define SHRT_MAX   32767       /*!< The maximum value of the short type */
3356 #define USHRT_MAX  65535       /*!< The maximum value of the unsigned short type */
3357 #define INT_MIN    -32768      /*!< The minimum value of the int type */
3358 #define INT_MAX    32767       /*!< The maximum value of the int type */
3359 #define UINT_MAX   65535       /*!< The maximum value of the unsigned int type */
3360 #define LONG_MIN   -2147483648 /*!< The minimum value of the long type */
3361 #define LONG_MAX   2147483647  /*!< The maximum value of the long type */
3362 #define ULONG_MAX  4294967295  /*!< The maximum value of the unsigned long type */
3363 #define RAND_MAX   32768       /*!< The maximum unsigned int random number returned by rand */
3364 /** @} */  // end of NXTLimits group
3365 /** @} */  // end of MiscConstants group
3366 
3367 
3368 /** @addtogroup GraphicsLibrary
3369  * @{
3370  */
3371 /*------------------------------------------------------------------------------
3372 ; File          : nbcGL.nbc
3373 ; Description   : Data and subroutines for a very simple 3D engine.
3374 ; Programmed by : Arno van der Vegt, avandervegt@home.nl
3375 ;-----------------------------------------------------------------------------*/
3376 
3377 /** @defgroup GLConstantsBeginModes Graphics library begin modes
3378  * Constants that are used to specify the polygon surface begin mode.
3379  * @{
3380  */
3381 #define GL_POLYGON             1 /*!< Use polygon mode. */
3382 #define GL_LINE                2 /*!< Use line mode. */
3383 #define GL_POINT               3 /*!< Use point mode. */
3384 #define GL_CIRCLE              4 /*!< Use circle mode. */
3385 /** @} */  // end of GLConstantsBeginModes group
3386 
3387 /** @defgroup GLConstantsActions Graphics library actions
3388  * Constants that are used to specify a graphics library action.
3389  * @{
3390  */
3391 #define GL_TRANSLATE_X       1 /*!< Translate along the X axis. */
3392 #define GL_TRANSLATE_Y       2 /*!< Translate along the Y axis. */
3393 #define GL_TRANSLATE_Z       3 /*!< Translate along the Z axis. */
3394 #define GL_ROTATE_X          4 /*!< Rotate around the X axis. */
3395 #define GL_ROTATE_Y          5 /*!< Rotate around the Y axis. */
3396 #define GL_ROTATE_Z          6 /*!< Rotate around the Z axis. */
3397 #define GL_SCALE_X           7 /*!< Scale along the X axis. */
3398 #define GL_SCALE_Y           8 /*!< Scale along the Y axis. */
3399 #define GL_SCALE_Z           9 /*!< Scale along the Z axis. */
3400 /** @} */  // end of GLConstantsSettings group
3401 
3402 /** @defgroup GLConstantsSettings Graphics library settings
3403  * Constants that are used to configure the graphics library settings.
3404  * @{
3405  */
3406 #define GL_CIRCLE_SIZE          1 /*!< Set the circle size. */
3407 #define GL_CULL_MODE            2 /*!< Set the cull mode.  */
3408 #define GL_CAMERA_DEPTH         3 /*!< Set the camera depth. */
3409 #define GL_ZOOM_FACTOR          4 /*!< Set the zoom factor. */
3410 /** @} */  // end of GLConstantsSettings group
3411 
3412 /** @defgroup GLConstantsCullMode Graphics library cull mode
3413  * Constants to use when setting the graphics library cull mode.
3414  * @{
3415  */
3416 #define GL_CULL_BACK           2 /*!< Cull lines in back. */
3417 #define GL_CULL_FRONT          3 /*!< Cull lines in front. */
3418 #define GL_CULL_NONE           4 /*!< Do not cull any lines. */
3419 /** @} */  // end of GLConstantsCullMode group
3420 
3421 /** @} */  // end of GraphicsLibrary group
3422 
3423 #endif // NBCCOMMON_H
3424