The single entry point for interacting with the ROBO Interface
- libroboint
- .RoboInterface
- .MOTOR_DIR_LEFT
- .MOTOR_DIR_RIGHT
- .MOTOR_DIR_STOP
- .connect([opts])
- .hasInterface() ⇒
boolean
- .close()
- .getDeviceTypeString() ⇒
string
- .getDeviceType() ⇒
number
- .setMotor(motor, direction, [speed]) ⇒
- .setOutput(output, [power])
- .getInput(inputNumber) ⇒
number
- .getA1() ⇒
number
- .getA2() ⇒
number
- .getAX() ⇒
number
- .getAY() ⇒
number
- .getD1() ⇒
number
- .getD2() ⇒
number
- .loop(theLoop, interval)
- .useCounter(inputNumber)
If you need multiple instances (e.g. two Robo interfaces on two separate USB ports), you can use the class directly. Remember to call close on each of your instances.
Kind: static constant of libroboint
Example
const libroboint = require('libroboint');
const ri = new libroboint.RoboInterface(connectOptions);
ri.setMotor(1,libroboint.MOTOR_DIR_LEFT);
ri.close();
Kind: static constant of libroboint
Kind: static constant of libroboint
Kind: static constant of libroboint
Connect to the Robo Interface
Kind: static method of libroboint
Param | Type | Description |
---|---|---|
[opts] | Object |
The connection options. Optional. |
opts.deviceNumber | number |
The number of the device to connect to, defaults to 0. |
opts.usbSerial | number |
If specified, will connect using the serialNumber. |
opts.serialType | number |
Type of device at serial port, either FT_INTELLIGENT_IF (10), FT_INTELLIGENT_IF_SLAVE (20) or FT_ROBO_IF_COM (70) |
opts.enableDistance | boolean |
Enable D1 and D2 for use with the ft distance sensor, defaults to false |
opts.startTransferArea | boolean |
Start the transfer area. Usually you want that, defaults to true |
Example
const libroboint = require('libroboint');
libroboint.connect({
deviceNumber: 0
});
Tells if we have a connection to the Interface. Useful to call after "connect()"
Kind: static method of libroboint
Example
const libroboint = require('libroboint');
libroboint.connect();
if(libroboint.hasInterface()){
// do something
}
Closes the connection to the ftDevice. This is also done when the nodeJS process is terminated (SIGINT).
Kind: static method of libroboint
Example
const libroboint = require('libroboint');
libroboint.connect();
// do something
libroboint.close();
Returns a string that identifies this interface in a human readable form like "Robo Interface"
Kind: static method of libroboint
Returns the type of the interface (as integer), which is one of
NO_FT_DEVICE 0 // No ft Device connected
FT_AUTO_TYPE 1 // Search for Device
FT_INTELLIGENT_IF 10 // FT-Intelligent Interface connect (serial)
FT_INTELLIGENT_IF_SLAVE 20 // FT-Intelligent Interface with Extension connect (serial)
FT_ROBO_IF_IIM 50 // FT-Robo Interface with Intelligent-Interface-Modus connect (serial)
FT_ROBO_IF_USB 60 // FT-Robo Interface connect with USB-Port
FT_ROBO_IF_COM 70 // FT-Robo Interface connect with COM- (serial-) Port
FT_ROBO_IF_OVER_RF 80 // FT-Robo Interface connect over RF-Data-Link
FT_ROBO_IO_EXTENSION 90 // FT-Robo I/O-Extension
FT_ROBO_LT_CONTROLLER 91 // FT-Robo LT Controller
FT_ROBO_RF_DATA_LINK 110 // FT-Robo RF Data Link
FT_SOUND_AND_LIGHTS 120 // FT-Sound + Lights Module
Kind: static method of libroboint
Sets a motor's speed and direction
Kind: static method of libroboint
Returns: null
Param | Type | Default | Description |
---|---|---|---|
motor | number |
The motor number, 1-4, with I/O Extensions also 5-8, 9-12, 13-16 | |
direction | number |
The direction. one of libroboint.MOTOR_DIR_LEFT (1), libroboint.MOTOR_DIR_RIGHT (2), libroboint.MOTOR_DIR_STOP (0) | |
[speed] | number |
7 |
The speed between 0 and 7. Optional. Defaults to 7 |
Example
const libroboint = require('libroboint');
libroboint.connect();
libroboint.setMotor(1, libroboint.MOTOR_DIR_STOP); // stop motor 1
libroboint.setMotor(2, libroboint.MOTOR_DIR_LEFT, 5); // start motor 2, direction left with speed 5
libroboint.setMotor(2, libroboint.MOTOR_DIR_RIGHT); // start motor 2, direction right with default speed (max = 7)
Sets a outputs's power
Kind: static method of libroboint
Param | Type | Default | Description |
---|---|---|---|
output | number |
The putput number, 1-8, with I/O Extensions also 9-16, 17-24, 25-32 | |
[power] | number |
7 |
The power between 0 and 7. Optional. Defaults to 7 |
Example
const libroboint = require('libroboint');
libroboint.connect();
libroboint.setOutput(7); // set output 7 on (default power)
libroboint.setOutput(2, 5); // set output 2 on, with power 5
Gets the state of a digital input.
Kind: static method of libroboint
Returns: number
- 1 or 0
Param | Type | Description |
---|---|---|
inputNumber | number |
The input between 1 and Max |
Example
const libroboint = require('libroboint');
libroboint.connect();
console.log(libroboint.getInput(1));
Reads analog input A1
Kind: static method of libroboint
Returns: number
- The voltage between 0 and 1023
Reads analog input A2
Kind: static method of libroboint
Returns: number
- The voltage between 0 and 1023
Reads analog input AX
Kind: static method of libroboint
Returns: number
- The resistor value between 0 and 1023
Reads analog input AY
Kind: static method of libroboint
Returns: number
- The resistor value between 0 and 1023
Reads analog input D1
Kind: static method of libroboint
Returns: number
- The voltage or distance value between 0 and 1023. Depending on connect option flag "enableDistance"
Reads analog input D2
Kind: static method of libroboint
Returns: number
- The voltage or distance value between 0 and 1023. Depending on connect option flag "enableDistance"
Kind: static method of libroboint
Param | Type | Default | Description |
---|---|---|---|
theLoop | function |
||
interval | number |
50 |
The interval in milliseconds |
Use within loop to count "switching" on a digital input. This will count state change from 0 to 1. Handy when using a mini switch on a axle.
Kind: static method of libroboint
Param | Type |
---|---|
inputNumber | number |
Example
const [c, resetC] = libroboint.useCounter(1);
if (c > 10) {
console.log('reached 11, resetting');
resetC();
}