Treehopper C++ API
|
The core class for communicating with Treehopper USB boards. More...
#include <TreehopperUsb.h>
Public Member Functions | |
TreehopperUsb (UsbConnection &connection) | |
~TreehopperUsb () | |
TreehopperUsb & | operator= (const TreehopperUsb &rhs) |
TreehopperUsb (const TreehopperUsb &rhs) | |
void | reinitialize () |
Reinitialize the board, setting all pins as high-impedance More... | |
bool | connect () |
Establish a connection with the board. More... | |
void | disconnect () |
Disconnect from the board. More... | |
wstring | serialNumber () |
Gets the serial number of the board. More... | |
wstring | name () |
Gets the name of the board. More... | |
void | led (bool value) |
Sets the state of the LED. More... | |
bool | led () |
Gets the state of the LED. More... | |
wstring | toString () |
Gets a string representation of the board. More... | |
Public Attributes | |
bool | isConnected |
Gets whether or not the board is connected. More... | |
vector< Pin > | pins |
Gets a collection of pins on the board. More... | |
const int | numberOfPins = 20 |
Gets the number of pins on the board (20) More... | |
HardwareI2c | i2c |
Gets the HardwareI2c interface. More... | |
HardwareSpi | spi |
Gets the HardwareSpi interface. More... | |
HardwarePwm | pwm1 |
Gets the HardwarePwm PWM1 pin. More... | |
HardwarePwm | pwm2 |
Gets the HardwarePwm PWM2 pin. More... | |
HardwarePwm | pwm3 |
Gets the HardwarePwm PWM3 pin. More... | |
HardwarePwmManager | pwmManager |
Gets the HardwarePwmManager module. More... | |
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::instance().getFirstDevice() method:
Or the ConnectionService::instance().boards 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:
TreehopperUsb | ( | UsbConnection & | connection | ) |
~TreehopperUsb | ( | ) |
|
inline |
bool connect | ( | ) |
void disconnect | ( | ) |
void led | ( | bool | value | ) |
bool led | ( | ) |
wstring name | ( | ) |
|
inline |
void reinitialize | ( | ) |
wstring serialNumber | ( | ) |
|
inline |
HardwareI2c i2c |
bool isConnected |
const int numberOfPins = 20 |
vector<Pin> pins |
HardwarePwm pwm1 |
HardwarePwm pwm2 |
HardwarePwm pwm3 |
HardwarePwmManager pwmManager |
HardwareSpi spi |