Data Types

From ROBOTC API Guide
Revision as of 18:19, 10 May 2012 by Bfeher (Talk | contribs)

Jump to: navigation, search
General Programming → Data Types


The ROBOTC Compiler supports several different data types. Some are standard C return types and others are custom created for ROBOTC.
Data Types will be marked with the following tags if applicable: [arduino 328], [arduino Mega], [cortex], [nxt], [pic], [tetrix].



Standard C data types:

data type Comments [arduino 328] [arduino Mega] [cortex] [nxt] [pic] [tetrix]
bool A Boolean value; either true or false.

Note that false is equivalent to zero (0), and true is equivalent to any non-zero number (both positive and negative).

[arduino 328] [arduino Mega] [cortex] [nxt] [pic] [tetrix]
byte A whole number ranging from -128 to 127. [arduino 328] [arduino Mega] [cortex] [nxt] [pic] [tetrix]
char A whole number ranging from -128 to 127. Can be interpreted as a character value.

For example, 42 = 'B' and vice versa.

[arduino 328] [arduino Mega] [cortex] [nxt] [pic] [tetrix]
float A floating-point number (decimal) with the following length and accuracy restrictions:
0.#### 0.0000 to +2,048.0000
0.### 0.000 to +32,768.000
0.## 0.00 to +262,144.00
0.# 0.0 to +2,097,200.0
[arduino Mega] [cortex] [nxt] [tetrix]
long A whole number ranging from -2,147,483,648 to 2,147,483,647. [arduino Mega] [cortex] [nxt] [tetrix]
int A whole number ranging from -32,768 to 32,767. [arduino 328] [arduino Mega] [cortex] [nxt] [pic] [tetrix]
short A whole number ranging from -32,768 to 32,767. [arduino 328] [arduino Mega] [cortex] [nxt] [pic] [tetrix]
string A sequence of characters. [arduino Mega] [cortex] [nxt] [tetrix]
word A whole number ranging from -32,768 to 32,767. [arduino 328] [arduino Mega] [cortex] [nxt] [pic] [tetrix]
ubyte An unsigned byte (0 to 255). [arduino 328] [arduino Mega] [cortex] [nxt] [pic] [tetrix]
void This means that the function doesn't return anything. [arduino 328] [arduino Mega] [cortex] [nxt] [pic] [tetrix]


ROBOTC data types:

TBaudRate

TBaudRate
Command Comments [arduino 328] [arduino Mega] [cortex] [nxt] [pic] [tetrix]
baudRate1200 = 0 [arduino 328] [arduino Mega] [cortex] [pic]
baudRate2400 = 1 [arduino 328] [arduino Mega] [cortex] [pic]
baudRate4800 = 2 [arduino 328] [arduino Mega] [cortex] [pic]
baudRate9600 = 3 [arduino 328] [arduino Mega] [cortex] [pic]
baudRate14400 = 4 [arduino 328] [arduino Mega] [cortex] [pic]
baudRate19200 = 5 [arduino 328] [arduino Mega] [cortex] [pic]
baudRate28800 = 6 [arduino 328] [arduino Mega] [cortex] [pic]
baudRate38400 = 7 [arduino 328] [arduino Mega] [cortex] [pic]
baudRate57600 = 8 [arduino 328] [arduino Mega] [cortex] [pic]
baudRate76800 = 9 [arduino 328] [arduino Mega] [cortex] [pic]
baudRate100000 = 10 [arduino 328] [arduino Mega] [cortex] [pic]
baudRate115200 = 11 [arduino 328] [arduino Mega] [cortex] [pic]
baudRate200000 = 12 [arduino 328] [arduino Mega] [cortex] [pic]
baudRate230400 = 13 [arduino 328] [arduino Mega] [cortex] [pic]
baudRate250000 = 14 [arduino 328] [arduino Mega] [cortex] [pic]
baudRateUndefined = 15 [arduino 328] [arduino Mega] [cortex] [pic]


TBTCommands

TBTCommands
Command Comments [arduino 328] [arduino Mega] [cortex] [nxt] [pic] [tetrix]
SENDFILE = 0 [nxt] [tetrix]
SEARCH = 1 (For Internal use only!) [nxt] [tetrix]
STOPSEARCH = 2 (For Internal use only!) [nxt] [tetrix]
CONNECT = 3 [nxt] [tetrix]
DISCONNECT = 4 [nxt] [tetrix]
DISCONNECTALL = 5 [nxt] [tetrix]
REMOVEDEVICE = 6 [nxt] [tetrix]
VISIBILITY = 7 [nxt] [tetrix]
SETCMDMODE = 8 (For Internal use only!) [nxt] [tetrix]
OPENSTREAM = 9 [nxt] [tetrix]
SENDDATA = 10 (For Internal use only!) [nxt] [tetrix]
FACTORYRESET = 11 [nxt] [tetrix]
BTON = 12 [nxt] [tetrix]
BTOFF = 13 [nxt] [tetrix]
SETBTNAME = 14 [nxt] [tetrix]
EXTREAD = 15 (For Internal use only!) [nxt] [tetrix]
PinReq = 16 (For Internal use only!) [nxt] [tetrix]
CONNECTREQ = 17 (For Internal use only!) [nxt] [tetrix]
IDLE = 18 [nxt] [tetrix]
LinkQualityReq = 19. Requests quality of link from Bluecore. [nxt] [tetrix]
opSetRawDataMode = 20. Sets Bluecore into Raw Data mode. [nxt] [tetrix]
opSetDefaultPIN = 21. Sets default Passcode. Immediate command. Bluecore interaction not required. [nxt] [tetrix]
opGetDefaultPIN = 22. Retrieves default Passcode. Immediate command. Bluecore interaction not required. [nxt] [tetrix]
opSetSessionPIN = 23. Sets session Passcode. Immediate command. Initialized to "default" passcode on power up [nxt] [tetrix]
opGetSessionPIN = 24. Retrieves session Passcode. Immediate command. Bluecore interaction not required. [nxt] [tetrix]
opResetSessionPIN = 25. Resets session Passcode to default passcode. [nxt] [tetrix]
opGetFriendlyName = 26. Gets the Bluetooth "Friendly Name" String. [nxt] [tetrix]
opGetBTAddress = 27 [nxt] [tetrix]
opGetMyContactInfo = 28. // Gets info on selected "My Contacts" list. [nxt] [tetrix]


TButtons

TButtons
Command Comments [arduino 328] [arduino Mega] [cortex] [nxt] [pic] [tetrix]
kNoButton = -1 [nxt] [tetrix]
kExitButton = 0. NXT Exit button. [nxt] [tetrix]
kRightButton = 1. NXT Right-Arrow button. [nxt] [tetrix]
kLeftButton = 2. NXT Left-Arrow button. [nxt] [tetrix]
kEnterButton = 3. NXT Enter button (orange square). [nxt] [tetrix]


TFileHandle

TFileHandle
Command Comments [arduino 328] [arduino Mega] [cortex] [nxt] [pic] [tetrix]
TFileHandle #define TFileHandle short [nxt] [tetrix]


TFileIOResult

TFileIOResult
Command Comments [arduino 328] [arduino Mega] [cortex] [nxt] [pic] [tetrix]
ioRsltSuccess = (0x00FF & (SUCCESS >> 8)) [nxt] [tetrix]
ioRsltInProgress = (0x00FF & (0x01)) [nxt] [tetrix]
ioRsltReqPIN = (0x00FF & (0x02)) [nxt] [tetrix]
ioRsltNoMoreHandles = (0x00FF & (NOMOREHANDLES >> 8)) [nxt] [tetrix]
ioRsltNoSpace = (0x00FF & (NOSPACE >> 8)) [nxt] [tetrix]
ioRsltNoMoreFiles = (0x00FF & (NOMOREFILES >> 8)) [nxt] [tetrix]
ioRsltEofExpected = (0x00FF & (EOFEXSPECTED >> 8)) [nxt] [tetrix]
ioRsltEndOfFile = (0x00FF & (ENDOFFILE >> 8)) [nxt] [tetrix]
ioRsltNotLinearFile = (0x00FF & (NOTLINEARFILE >> 8)) [nxt] [tetrix]
ioRsltFileNotFound = (0x00FF & (FILENOTFOUND >> 8)) [nxt] [tetrix]
ioRsltHandleAlreadyClosed = (0x00FF & (HANDLEALREADYCLOSED >> 8)) [nxt] [tetrix]
ioRsltNoLinearSpace = (0x00FF & (NOLINEARSPACE >> 8)) [nxt] [tetrix]
ioRsltUndefinedError = (0x00FF & (UNDEFINEDERROR >> 8)) [nxt] [tetrix]
ioRsltFileIsBusy = (0x00FF & (FILEISBUSY >> 8)) [nxt] [tetrix]
ioRsltNoWriteBuffers = (0x00FF & (NOWRITEBUFFERS >> 8)) [nxt] [tetrix]
ioRsltAppendNotPossible = (0x00FF & (APPENDNOTPOSSIBLE >> 8)) [nxt] [tetrix]
ioRsltFileIsFull = (0x00FF & (FILEISFULL >> 8)) [nxt] [tetrix]
ioRsltFileExists = (0x00FF & (FILEEXISTS >> 8)) [nxt] [tetrix]
ioRsltModuleNotFound = (0x00FF & (MODULENOTFOUND >> 8)) [nxt] [tetrix]
ioRsltOutOfBoundery = (0x00FF & (OUTOFBOUNDERY >> 8)) [nxt] [tetrix]
ioRsltIllegalFilename = (0x00FF & (ILLEGALFILENAME >> 8)) [nxt] [tetrix]
ioRsltIllegalHandle = (0x00FF & (ILLEGALHANDLE >> 8)) [nxt] [tetrix]
ioRsltBTBusy = (0x00FF & (BTBUSY >> 8)) [nxt] [tetrix]
ioRsltBTConnectFail = (0x00FF & (BTCONNECTFAIL >> 8)) [nxt] [tetrix]
ioRsltBTTimeout = (0x00FF & (BTTIMEOUT >> 8)) [nxt] [tetrix]
ioRsltFileTxTimeout = (0x00FF & (FILETX_TIMEOUT >> 8)) [nxt] [tetrix]
ioRsltFileTxDSTExists = (0x00FF & (FILETX_DSTEXISTS >> 8)) [nxt] [tetrix]
ioRsltFileTxSRCMissing = (0x00FF & (FILETX_SRCMISSING >> 8)) [nxt] [tetrix]
ioRsltFileTxStreamError = (0x00FF & (FILETX_STREAMERROR >> 8)) [nxt] [tetrix]
ioRsltFileTxCloseError = (0x00FF & (FILETX_CLOSEERROR >> 8)) [nxt] [tetrix]
ioRsltCommChannelBusError = (0x00FF & -35). (0xDD Something went wrong on the communications bus) [nxt] [tetrix]
ioRsltCommBufferFull = (0x00FF & -34). (0xDE No room in comm buffer) [nxt] [tetrix]
ioRsltCommChannelBad = (0x00FF & -33). (0xDF Specified channel/connection is not valid) [nxt] [tetrix]
ioRsltCommChannelNotReady = (0x00FF & -32). (0xE0 Specified channel/connection not configured or busy) [nxt] [tetrix]
ERR_COMM_BUFFER_FULL = ((short) ioRsltCommBufferFull) [nxt] [tetrix]
ERR_COMM_CHAN_INVALID = ((short) ioRsltCommChannelBad) [nxt] [tetrix]
ERR_INVALID_PORT = (0x00FF & -16) [nxt] [tetrix]
ERR_INVALID_FIELD = (0x00FF & -17) [nxt] [tetrix]
ERR_INVALID_QUEUE = (0x00FF & -18) [nxt] [tetrix]
ERR_INVALID_SIZE = (0x00FF & -19) [nxt] [tetrix]
ioRsltCommPending = (0x00FF & STAT_COMM_PENDING) [nxt] [tetrix]
ioRsltEmptyMailbox = (0x00FF & STAT_MSG_EMPTY_MAILBOX) [nxt] [tetrix]
ioRsltBadArgs = (0x00FF & ERR_ARG) [nxt] [tetrix]


TI2CStatus

TI2CStatus
Command Comments [arduino 328] [arduino Mega] [cortex] [nxt] [pic] [tetrix]
NO_ERR = 0 [cortex] [nxt] [tetrix]
STAT_COMM_PENDING = 32 [cortex] [nxt] [tetrix]
ERR_COMM_CHAN_NOT_READY = -32 [cortex] [nxt] [tetrix]
ERR_COMM_BUS_ERR = -35 [cortex] [nxt] [tetrix]


TMailboxIDs

TMailboxIDs
Command Comments [arduino 328] [arduino Mega] [cortex] [nxt] [pic] [tetrix]
mailbox1 = 0 [nxt] [tetrix]
mailbox2 = 1 [nxt] [tetrix]
mailbox3 = 2 [nxt] [tetrix]
mailbox4 = 3 [nxt] [tetrix]
mailbox5 = 4 [nxt] [tetrix]
mailbox6 = 5 [nxt] [tetrix]
mailbox7 = 6 [nxt] [tetrix]
mailbox8 = 7 [nxt] [tetrix]
mailbox9 = 8 [nxt] [tetrix]
mailbox10 = 9 [nxt] [tetrix]
mailbox11 = 10 (For Internal use only!) [nxt] [tetrix]
mailbox12 = 11 (For Internal use only!) [nxt] [tetrix]
mailbox13 = 12 (For Internal use only!) [nxt] [tetrix]
mailbox14 = 13 (For Internal use only!) [nxt] [tetrix]
mailbox15 = 14 (For Internal use only!) [nxt] [tetrix]
mailbox16 = 15 (For Internal use only!) [nxt] [tetrix]
mailbox17 = 16 (For Internal use only!) [nxt] [tetrix]
mailbox18 = 17 (For Internal use only!) [nxt] [tetrix]
mailbox19 = 18 (For Internal use only!) [nxt] [tetrix]
mailbox20 = 19 (For Internal use only!) [nxt] [tetrix]


TMotorRegulation

TMotorRegulation
Command Comments [arduino 328] [arduino Mega] [cortex] [nxt] [pic] [tetrix]
mtrNoReg = 0 [nxt] [tetrix]
mtrSpeedReg = 1 [nxt] [tetrix]
mtrSyncRegMaster = 2 [nxt] [tetrix]
mtrSyncRegSlave = 3 [nxt] [tetrix]
mtrEncoderReg = 4 [nxt] [tetrix]


TNxtRunState

TNxtRunState
Command Comments [arduino 328] [arduino Mega] [cortex] [nxt] [pic] [tetrix]
runStateIdle = 0x00. Published IOMAP value. Do Not Change. [nxt] [tetrix]
runStateRampUp = 0x10. Published IOMAP value. Do Not Change. [nxt] [tetrix]
runStateRunning = 0x20. Published IOMAP value. Do Not Change. [nxt] [tetrix]
runStateRampDown = 0x40. Published IOMAP value. Do Not Change. [nxt] [tetrix]
runStateHoldPosition = 0x01 [nxt] [tetrix]


TPCJoystick

TPCJoystick
Command Comments [arduino 328] [arduino Mega] [cortex] [nxt] [pic] [tetrix]
joy1_x1 (short) -128 to +127 [arduino 328] [arduino Mega] [nxt] [tetrix]
joy1_x2 (short) -128 to +127 [arduino 328] [arduino Mega] [nxt] [tetrix]
joy1_y1 (short) -128 to +127 [arduino 328] [arduino Mega] [nxt] [tetrix]
joy1_y2 (short) -128 to +127 [arduino 328] [arduino Mega] [nxt] [tetrix]
joy1_Buttons (short) Bit map for 12-buttons. [arduino 328] [arduino Mega] [nxt] [tetrix]
joy1_TopHat (short) Value of -1 = not pressed, otherwise 0 to 7 for selected "octant". [arduino 328] [arduino Mega] [nxt] [tetrix]


tSensors

tSensors
Command Comments
S1 = 0 [nxt] [tetrix]
S2 = 1 [nxt] [tetrix]
S3 = 2 [nxt] [tetrix]
S4 = 3 [nxt] [tetrix]
in1 = 0 [cortex] [pic]
in2 = 1 [cortex] [pic]
in3 = 2 [cortex] [pic]
in4 = 3 [cortex] [pic]
in5 = 4 [cortex] [pic]
in6 = 5 [cortex] [pic]
in7 = 6 [cortex] [pic]
in8 = 7 [cortex] [pic]
in9 = 8 [pic]
in10 = 9 [pic]
in11 = 10 [pic]
in12 = 11 [pic]
in13 = 12 [pic]
in14 = 13 [pic]
in15 = 14 [pic]
in16 = 15 [pic]
dgtl1 = 8 [cortex]
dgtl2 = 9 [cortex]
dgtl3 = 10 [cortex]
dgtl4 = 11 [cortex]
dgtl5 = 12 [cortex]
dgtl6 = 13 [cortex]
dgtl7 = 14 [cortex]
dgtl8 = 15 [cortex]
dgtl9 = 16 [cortex]
dgtl10 = 17 [cortex]
dgtl11 = 18 [cortex]
dgtl12 = 19 [cortex]
I2C_1 = 20 [cortex]
I2C_2 = 21 [cortex]
I2C_3 = 22 [cortex]
I2C_4 = 23 [cortex]
I2C_5 = 24 [cortex]
I2C_6 = 25 [cortex]
I2C_7 = 26 [cortex]
I2C_8 = 27 [cortex]


TSounds

TSounds
Command Comments
soundBlip = 0 [nxt] [tetrix] [cortex] [pic]
soundBeepBeep = 1 [nxt] [tetrix] [cortex] [pic]
soundDownwardTones = 2 [nxt] [tetrix] [cortex] [pic]
soundUpwardTones = 3 [nxt] [tetrix] [cortex] [pic]
soundLowBuzz = 4 [nxt] [tetrix] [cortex] [pic]
soundFastUpwardTones = 5 [nxt] [tetrix] [cortex] [pic]
soundShortBlip = 6 [nxt] [tetrix] [cortex] [pic]
soundException = 7 [nxt] [tetrix] [cortex] [pic]
soundLowBuzzShort = 8 [nxt] [tetrix] [cortex] [pic]


TSynchedMotors

TSynchedMotors
Command Comments
synchNone = 0 [nxt] [tetrix]
synchAB = 1 [nxt] [tetrix]
synchAC = 2 [nxt] [tetrix]
synchBA = 3 [nxt] [tetrix]
synchBC = 4 [nxt] [tetrix]
synchCA = 5 [nxt] [tetrix]
synchCB = 6 [nxt] [tetrix]


TTimers

TTimers
Command Comments
T1 = 0 [nxt] [tetrix] [cortex] [pic]
T2 = 1 [nxt] [tetrix] [cortex] [pic]
T3 = 2 [nxt] [tetrix] [cortex] [pic]
T4 = 3 [nxt] [tetrix] [cortex] [pic]


TUARTs

TUARTs
Command Comments
uartOne = 0 [cortex] [pic]
uartTwo = 1 [cortex] [pic]
uartThree = 2 [cortex] [pic]


TVexJoysticks

TVexJoysticks
Command Comments
Ch1 = 0 [cortex] [pic]
Ch2 = 1 [cortex] [pic]
Ch3 = 2 [cortex] [pic]
Ch4 = 3 [cortex] [pic]
Ch5 = 4 [cortex] [pic]
Ch6 = 5 [cortex] [pic]
Btn5U = Btn5D + 1 [cortex] [pic]
Btn5D = 14 [cortex] [pic]
Btn6U = Btn5D + 3 [cortex] [pic]
Btn6D = Btn5D + 2 [cortex] [pic]
Btn7U = Btn5D + 10 [cortex] [pic]
Btn7D = Btn5D + 8 [cortex] [pic]
Btn7L = Btn5D + 9 [cortex] [pic]
Btn7R = Btn5D + 11 [cortex] [pic]
Btn8U = Btn5D + 6 [cortex] [pic]
Btn8D = Btn5D + 4 [cortex] [pic]
Btn8L = Btn5D + 5 [cortex] [pic]
Btn8R = Btn5D + 7 [cortex] [pic]
AccelX = 38 [cortex] [pic]
AccelY = AccelX + 1 [cortex] [pic]
AccelZ = AccelX + 2 [cortex] [pic]
Ch1Xmtr2 = 6 [cortex] [pic]
Ch2Xmtr2 = 7 [cortex] [pic]
Ch3Xmtr2 = 8 [cortex] [pic]
Ch4Xmtr2 = 9 [cortex] [pic]
Ch5Xmtr2 = 10 [cortex] [pic]
Ch6Xmtr2 = 11 [cortex] [pic]
Btn5UXmtr2 = Btn5DXmtr2 + 1 [cortex] [pic]
Btn5DXmtr2 = 26 [cortex] [pic]
Btn6UXmtr2 = Btn5DXmtr2 + 3 [cortex] [pic]
Btn6DXmtr2 = Btn5DXmtr2 + 2 [cortex] [pic]
Btn7UXmtr2 = Btn5DXmtr2 + 10 [cortex] [pic]
Btn7DXmtr2 = Btn5DXmtr2 + 8 [cortex] [pic]
Btn7LXmtr2 = Btn5DXmtr2 + 9 [cortex] [pic]
Btn7RXmtr2 = Btn5DXmtr2 + 11 [cortex] [pic]
Btn8UXmtr2 = Btn5DXmtr2 + 6 [cortex] [pic]
Btn8DXmtr2 = Btn5DXmtr2 + 4 [cortex] [pic]
Btn8LXmtr2 = Btn5DXmtr2 + 5 [cortex] [pic]
Btn8RXmtr2 = Btn5DXmtr2 + 7 [cortex] [pic]
AccelXXmtr2 = 41 [cortex] [pic]
AccelYXmtr2 = AccelXXmtr2 + 1 [cortex] [pic]
AccelZXmtr2 = AccelXXmtr2 + 2 [cortex] [pic]


TVexReceiverState

TVexReceiverState
Command Comments
vrNoXmiters = 0
No transmitters connected
[cortex]
vrXmit1 = 0x01
1: Transmitter 1 connected
[cortex]
vrXmit2 = 0x02
1: Transmitter 2 connected
[cortex]
vrBit2 = 0x04
unused
[cortex]
vrCompetitionSwitch = 0x08
0: No Comp Switch
1: Competition Switch attached
[cortex]
vrResetSlave = 0x10
unused
[cortex]
vrGameController = 0x20
0: Legacy75MHz
1: Game Controller
[cortex]
vrAutonomousMode = 0x40
0: Driver Control
1: Autonomous Mode
[cortex]
vrDisabled = 0x80
0: Enabled
1: Disabled
[cortex]