Component: Formula AllCode API (Mechatronics)
Author | Matrix Ltd |
Version | 1.2 (Release) |
Category | Mechatronics |
Contents
- 1 Formula AllCode API component
- 2 Examples
- 3 Downloadable macro reference
- 4 Simulation macro reference
- 4.1 PlayNote
- 4.2 LEDOn
- 4.3 LCDPrintString
- 4.4 ReadLight
- 4.5 Right
- 4.6 SetLogoSpeed
- 4.7 SampleMag
- 4.8 CardCreate
- 4.9 LCDPrintNumber
- 4.10 LEDOff
- 4.11 LEDWrite
- 4.12 ReadAxis
- 4.13 ServoSetAutoMoveSpeed
- 4.14 CardPlayback
- 4.15 ReadMic
- 4.16 ReadSwitch
- 4.17 SampleAccel
- 4.18 Left
- 4.19 ReadIR
- 4.20 LCDDrawPixel
- 4.21 ServoSetPosition
- 4.22 CardBitmap
- 4.23 CardRecordMic
- 4.24 CardOpen
- 4.25 Forwards
- 4.26 ReadBearing
- 4.27 GetConsoleHandle
- 4.28 LCDDrawLine
- 4.29 ServoAutoMoveToPosition
- 4.30 LCDBacklight
- 4.31 LCDDrawRect
- 4.32 ReadLine
- 4.33 ServoDisable
- 4.34 ServoEnable
- 4.35 CardReadByte
- 4.36 CardErase
- 4.37 CardWriteByte
- 4.38 EncoderRead
- 4.39 SetMotors
- 4.40 Backwards
- 4.41 EncoderReset
- 4.42 LCDVerbose
- 4.43 SetProp
- 4.44 CardInit
- 4.45 GetProp
- 4.46 LCDClear
- 5 Property reference
Formula AllCode API component
A simulation only component to allow the Formula AllCode robot to be controlled via it's API interface and Bluetooth data connection without having to compile or re-program the robot.
Examples
No additional examples
Downloadable macro reference
This component does not contain any downloadable macros
Simulation macro reference
PlayNote
Plays a note using the speaker on the FA
Parameters
- UINT Note
- Range 1 to 65535 in Hz
- UINT Delay
- Number of milliseconds to play the note for
Return value
- This call does not return a value
LEDOn
Sets a single LED 0-7
Parameters
- BYTE index
- Range: 0-7
Return value
- This call does not return a value
LCDPrintString
Prints a string to the LCD
Parameters
- BYTE X
- X Pixel 0-127
- BYTE Y
- LCD Y Coordinate 0-31
- <- STRING Data
- This parameter may be returned back to the caller
Return value
- This call does not return a value
ReadLight
Reads the light sensor 0-4095 - 4095 = Max Brightness
Parameters
- This macro has no parameters
Return value
Right
Rotates the robot right - waits for the angle to be traversed before returning
Parameters
- UINT Angle
- Angle to turn in degrees
Return value
- This call does not return a value
SetLogoSpeed
Sets the speed of logo movements
Parameters
- BYTE Speed
- Logo Speed 1-100 - Default 40
Return value
- This call does not return a value
SampleMag
Samples the magnetometer
0 = no new data, 1 = new data available
Parameters
- This macro has no parameters
Return value
CardCreate
Attempts to create a file on the SD card
255=Error, 1=File Already Exists, 0=Create OK
Parameters
- <- STRING Filename
- This parameter may be returned back to the caller
Return value
LCDPrintNumber
Prints a 16-bit signed number to the LCD
Parameters
- BYTE X
- X Pixel 0-127
- BYTE Y
- LCD Y coordinate 0-31
- <- INT Number
- Range -32768 to 32767
- This parameter may be returned back to the caller
Return value
- This call does not return a value
LEDOff
Clears a single LED 0-7
Parameters
- BYTE index
- Range: 0-7
Return value
- This call does not return a value
LEDWrite
Sets the value of the LEDs as an 8-bit output
Parameters
- BYTE Value
- LED value 0=All Off, 255 = All On
Return value
- This call does not return a value
ReadAxis
Reads a single X/Y/Z axis from the accelerometer sensor.
Parameters
- BYTE index
- 0=X, 1=Y, 2=Z
Return value
ServoSetAutoMoveSpeed
Changes the speed of the auto movements
Default - 1
Parameters
- BYTE Speed
- Range 1-50
Return value
- This call does not return a value
CardPlayback
Plays back a .Wav file audio stream from the card
Parameters
- <- STRING Filename
- This parameter may be returned back to the caller
Return value
ReadMic
Reads the microphone sensor 0 - 4095
Parameters
- This macro has no parameters
Return value
ReadSwitch
Read the switch value
Parameters
- BYTE index
- 0 (left) or 1 (right)
Return value
SampleAccel
Samples the accelerometer
0 = no new data, 1 = new data available
Parameters
- This macro has no parameters
Return value
Left
Rotates the robot left - waits for the angle to be traversed before returning
Parameters
- UINT Angle
- Angle to turn in degrees
Return value
- This call does not return a value
ReadIR
Reads an IR sensor
0=Left, 1=FrontLeft, 2=Front, 3=FrontRight, 4=Right, 5=RearRight,
6=Rear, 7=RearLeft
Parameters
- BYTE index
- 0=Left, 1=FrontLeft, 2=Front, 3=FrontRight, 4=Right, 5=RearRight, 6=Rear, 7=RearLeft
Return value
LCDDrawPixel
Allows a single pixel on the LCD to be set or cleared
Parameters
- BYTE X
- X Pixel 0-127
- BYTE Y
- Y Pixel 0-31
- <- BYTE State
- 0=White (Off), 1=Black (On)
- This parameter may be returned back to the caller
Return value
- This call does not return a value
ServoSetPosition
Allows one of the servo positions to be assigned
Parameters
- BYTE Channel
- Range 0-3
- BYTE Position
- Range 0-255
Return value
- This call does not return a value
CardBitmap
Displays a monochrome bitmap read from the card on the LCD
Parameters
- BYTE X
- Range 0-127
- BYTE Y
- Range 0-31
- <- STRING Filename
- This parameter may be returned back to the caller
Return value
CardRecordMic
Records an audio stream on the card from the microphone
Parameters
- BYTE BitDepth
- 0=8-bit, 1=16-bit
- BYTE SampleRate
- Sample Rate 0=8KHz, 1=16KHz
- UINT RecordTime
- Time to record for in seconds, Range 0-65535
- <- STRING Filename
- This parameter may be returned back to the caller
Return value
CardOpen
Attempts to open an existing file on the SD card
255=Error, 1=File not found, 0=Open OK
Parameters
- <- STRING Filename
- This parameter may be returned back to the caller
Return value
Forwards
Drives the robot forwards - waits for the distance to be traversed before returning
Parameters
- UINT Distance
- Distance in mm
Return value
- This call does not return a value
ReadBearing
Reads the compass bearing based on the degrees clockwise from magnetic north.
Parameters
- This macro has no parameters
Return value
GetConsoleHandle
Gets the handle to the console allowing data displaying on the panel etc.
Parameters
- This macro has no parameters
Return value
LCDDrawLine
Allows a single pixel width line to be drawn on the LCD
Parameters
- BYTE X1
- X Pixel 0-127
- BYTE Y1
- Y Pixel 0-31
- <- BYTE X2
- X Pixel 0-127
- This parameter may be returned back to the caller
- BYTE Y2
- Y Pixel 0-31
Return value
- This call does not return a value
ServoAutoMoveToPosition
Allows one of the servo positions to move gradually to a new position
Parameters
- BYTE Channel
- Range 0-3
- BYTE Position
- Range 0-255
Return value
- This call does not return a value
LCDBacklight
Allows the LCD backlight brighntess to be adjusted
Parameters
- BYTE Intensity
- Range 0-100, 0=Off, 1=Min Brightness, 100=Max Brightness
Return value
- This call does not return a value
LCDDrawRect
Allows a rectangle to be drawn on the LCD
Parameters
- BYTE X1
- X Pixel 0-127
- BYTE Y1
- Y Pixel 0-31
- <- BYTE X2
- X Pixel 0-127
- This parameter may be returned back to the caller
- BYTE Y2
- Y Pixel 0-31
Return value
- This call does not return a value
ReadLine
Reads one of the IR line sensors 0-1
0=Left, 1=Right
Parameters
- BYTE index
- 0=Left, 1=Right
Return value
ServoDisable
Allows one of the servo outputs 0-3 to be disabled
Parameters
- BYTE Channel
- Range 0-3
Return value
- This call does not return a value
ServoEnable
Allows one of the servo outputs 0-3 to be enabled
Parameters
- BYTE Channel
- Range 0-3
Return value
- This call does not return a value
CardReadByte
Reads a byte from the currently open file.
Starts at the beginning of the file and auto increments to the end
Parameters
- This macro has no parameters
Return value
CardErase
Attempts to delete an existing file on the SD card
255=Error, 1=File not found, 0=Delete OK
Parameters
- <- STRING Filename
- This parameter may be returned back to the caller
Return value
CardWriteByte
Appends a byte to the end of the currently open file
Parameters
- <- BYTE Data
- This parameter may be returned back to the caller
Return value
- This call does not return a value
EncoderRead
Reads one of the motor encoder counters.
Approx 0.328296mm of travel per encoder unit.
Parameters
- BYTE index
- 0=Left, 1=Right
Return value
SetMotors
Sets the motor speeds without feedback
Range -100 to 100
Parameters
- INT Left
- Range -100 to 100
- INT Right
- Range -100 to 100
Return value
- This call does not return a value
Backwards
Drives the robot backwards - waits for the distance to be traversed before returning
Parameters
- UINT Distance
- Distance in mm
Return value
- This call does not return a value
EncoderReset
Resets the motor encoder counters
Parameters
- This macro has no parameters
Return value
- This call does not return a value
LCDVerbose
Allows the LCD to automatically report the API commands as they get processed.
Default - verbose on
Parameters
- BYTE State
- 0=Off 1=On
Return value
- This call does not return a value
SetProp
Allows the COM port property to be set from a parent component.
Parameters
- <- STRING PropName
- This parameter may be returned back to the caller
- ULONG PropVal
Return value
- This call does not return a value
CardInit
Attempts to startup the SD card
255=No Card, 254=Init Fail, 0=Init OK
Parameters
- This macro has no parameters
Return value
GetProp
Allows the property filter for the COM port list to be copied to a parent component.
Parameters
- <- STRING PropName
- This parameter may be returned back to the caller
Return value
LCDClear
Clears the LCD
Parameters
- This macro has no parameters
Return value
- This call does not return a value
Property reference
COM Port
This property is of type Fixed list of ints and can be referenced with the variable name COM_port.
Selects which port to communicate with, only lists ports which are currently available.
Refresh COM Ports
This property is of type True or false and can be referenced with the variable name Refresh.
When set to yes the COM port list is rescanned for newly connected or available ports.
Note that refreshing the ports list may take a few seconds depending on the number of connected ports.
Baud
This property is of type Signed integer and can be referenced with the variable name baud_rate.
Baud rate passed to the COM port to control the rate of data.
Label
This property is of type Line of text and can be referenced with the variable name label.
No additional information