Treehopper Java API
|
The core class for communicating with Treehopper USB boards. More...
Public Member Functions | |
TreehopperUsb (Connection connection) | |
Construct a Treehopper from a Connection. More... | |
boolean | getConnected () |
Get whether the board is connected. More... | |
boolean | connect () |
Connect to the board and reinitialize all peripherals. More... | |
void | disconnect () |
Disconnect from the board. More... | |
void | reinitialize () |
Reinitialize the board, setting all pins as digital inputs. More... | |
String | getName () |
String | getSerialNumber () |
boolean | isLed () |
void | setLed (boolean led) |
Connection | getConnection () |
Get the connection associated with this Treehopper board. More... | |
void | onPinReportReceived (byte[] pinReport) |
Internal event used by the Connection to report pin changes. More... | |
void | sendPeripheralConfigPacket (byte[] dataToSend) |
send a peripheral configuration packet directly to the connection More... | |
byte [] | receiveCommsResponsePacket (int numBytesToRead) |
receive a peripheral response packet from the connection More... | |
Public Attributes | |
Pin [] | pins = new Pin[20] |
I2c | i2c |
Spi | spi |
Pwm | pwm1 |
Pwm | pwm2 |
Pwm | pwm3 |
HardwarePwmManager | hardwarePwmManager |
HardwareUart | uart |
Static Public Attributes | |
static Settings | Settings = new Settings() |
The core class for communicating with Treehopper USB boards.
Treehopper is a USB 2.0 Full Speed device with 20 Pins — each of which can be used as an analog input, digital input, digital output, or soft-PWM output. Many of these pins also have dedicated peripheral functions for SPI, I2C, UART, and PWM.
You'll access all the pins, peripherals, and board functions through this class, which will automatically create all peripheral instances for you.
To obtain a reference to the board, use the ConnectionService.getInstance().getFirstDevice() method:
Or the ConnectionService.getInstance().getBoards() vector.
Before you use the board, you must explicitly connect to it by calling the ConnectAsync() method
To learn about accessing different Treehopper peripherals, visit the doc links to the relevant classes:
io.treehopper.TreehopperUsb.TreehopperUsb | ( | Connection | connection | ) |
Construct a Treehopper from a Connection.
connection | the connection to use |
boolean io.treehopper.TreehopperUsb.connect | ( | ) |
Connect to the board and reinitialize all peripherals.
void io.treehopper.TreehopperUsb.disconnect | ( | ) |
Disconnect from the board.
boolean io.treehopper.TreehopperUsb.getConnected | ( | ) |
Get whether the board is connected.
Connection io.treehopper.TreehopperUsb.getConnection | ( | ) |
Get the connection associated with this Treehopper board.
String io.treehopper.TreehopperUsb.getName | ( | ) |
String io.treehopper.TreehopperUsb.getSerialNumber | ( | ) |
boolean io.treehopper.TreehopperUsb.isLed | ( | ) |
void io.treehopper.TreehopperUsb.onPinReportReceived | ( | byte [] | pinReport | ) |
Internal event used by the Connection to report pin changes.
pinReport | the pin report received |
byte [] io.treehopper.TreehopperUsb.receiveCommsResponsePacket | ( | int | numBytesToRead | ) |
receive a peripheral response packet from the connection
numBytesToRead | the number of bytes to read |
void io.treehopper.TreehopperUsb.reinitialize | ( | ) |
Reinitialize the board, setting all pins as digital inputs.
void io.treehopper.TreehopperUsb.sendPeripheralConfigPacket | ( | byte [] | dataToSend | ) |
send a peripheral configuration packet directly to the connection
dataToSend | The data to send |
void io.treehopper.TreehopperUsb.setLed | ( | boolean | led | ) |
HardwarePwmManager io.treehopper.TreehopperUsb.hardwarePwmManager |
I2c io.treehopper.TreehopperUsb.i2c |
Pwm io.treehopper.TreehopperUsb.pwm1 |
Pwm io.treehopper.TreehopperUsb.pwm2 |
Pwm io.treehopper.TreehopperUsb.pwm3 |
Spi io.treehopper.TreehopperUsb.spi |
HardwareUart io.treehopper.TreehopperUsb.uart |