Treehopper C# API
Treehopper Namespace Reference

Base Treehopper namespace. More...

Namespaces

namespace  Libraries
 Commonly used external peripherals, sensors, and other devices.
 
namespace  Utilities
 Utility classes for working with common data types
 

Classes

interface  AdcPin
 Base interface representing pins capable of reading analog values More...
 
class  AdcValueChangedEventArgs
 ADC value changed EventArgs More...
 
class  AnalogValueChangedEventArgs
 Analog value changed EventArgs More...
 
class  AnalogVoltageChangedEventArgs
 Analog voltage changed EventArgs More...
 
class  ConnectionService
 Discovers Treehopper boards attached to your device. More...
 
interface  DigitalBase
 Base interface that describes a pin with a DigitalValue property More...
 
interface  DigitalIn
 Interface for digital pins supporting input functionality More...
 
class  DigitalInValueChangedEventArgs
 An EventArgs that represents a digital input changing More...
 
interface  DigitalIO
 Helper interface to describe pins that are both inputs and outputs More...
 
interface  DigitalOut
 Interface for digital output pins More...
 
class  HardwareI2C
 Built-in I2C module. More...
 
class  HardwarePwm
 Built-in hardware PWM channels. More...
 
class  HardwarePwmManager
 Hardware PWM manager More...
 
class  HardwareSpi
 Built-in SPI peripheral. More...
 
class  HardwareUart
 Built-in UART peripheral. More...
 
interface  I2C
 I2c master device More...
 
class  I2CTransferException
 An Exception representing I2c transfer errors that may occur More...
 
interface  IConnection
 UsbConnection interface
 
interface  IConnectionService
 An interface representing connection services
 
interface  OneWire
 Represents a OneWire-capable host. More...
 
class  ParallelInterface
 This module is used to provide an 8080-style R/W parallel interface (especially useful for displays) More...
 
class  Pin
 Built-in I/O pins. More...
 
interface  Pwm
 This provides a generic interface to PWM operation. More...
 
interface  ReadWriteParallelInterface
 A parallel interface that can read and write data More...
 
class  Settings
 This class represents global settings used by the Treehopper API More...
 
class  SoftPwmManager
 The SoftPwmManager is used to configure soft-PWM pins on the board
 
class  SoftPwmPinConfig
 
interface  Spi
 An SPI interface More...
 
interface  SpiChipSelectPin
 A pin that can be used as an SPI chip-select More...
 
class  TreehopperBoardEqualityComparer
 This comparer is used to compare Treehopper boards More...
 
class  TreehopperRuntimeException
 A runtime exception caused in Treehopper More...
 
class  TreehopperUsb
 The core class for communicating with Treehopper USB boards. More...
 
interface  Uart
 
interface  WriteOnlyParallelInterface
 Represents an 8080-style parallel interface that can write data More...
 

Enumerations

enum  AdcReferenceLevel {
  Vref_3V3, Vref_1V65, Vref_1V85, Vref_2V4,
  Vref_3V3Derived, Vref_3V7
}
 Select the reference to use for the analog input of the pin More...
 
enum  ChipSelectMode {
  SpiActiveLow, SpiActiveHigh, PulseHighAtBeginning, PulseHighAtEnd,
  PulseLowAtBeginning, PulseLowAtEnd
}
 Defines whether a signal is active high (rising-edge) or active low (falling-edge) More...
 
enum  HardwarePwmFrequency { Freq732Hz, Freq183Hz, Freq61Hz }
 Defines the PWM period options More...
 
enum  I2CTransferError {
  ArbitrationLostError, NackError, UnknownError, TxunderError,
  Success = 255
}
 Describes the transfer error, if not Success, that occured More...
 
enum  PinMode {
  Reserved, DigitalInput, PushPullOutput, OpenDrainOutput,
  AnalogInput, SoftPwm, Unassigned
}
 An enumeration representing the different supported modes of this pin. More...
 
enum  SpiBurstMode { NoBurst, BurstTx, BurstRx }
 The SPI burst mode to use More...
 
enum  SpiMode { Mode00 = 0x00, Mode01 = 0x20, Mode10 = 0x10, Mode11 = 0x30 }
 Defines the clock phase and polarity used for SPI communication More...
 
enum  UartMode { Uart, OneWire }
 Whether to use UART or OneWire mode More...
 

Functions

delegate void TreehopperUsbAddedHandler (TreehopperUsb boardAdded)
 An event handler for when a board is added More...
 
delegate void TreehopperUsbRemovedHandler (TreehopperUsb boardRemoved)
 An event handler for when a board is removed More...
 
delegate void PinValuesUpdatedHandler (object sender, EventArgs e)
 An event handler for when a new pin update report comes in More...
 
delegate void OnDigitalInValueChanged (object sender, DigitalInValueChangedEventArgs e)
 This is the delegate prototype used for event-driven reading of digital pins. More...
 
delegate void OnAnalogVoltageChanged (object sender, AnalogVoltageChangedEventArgs e)
 Used to send VoltageChanged events from the AnalogIn pin. More...
 
delegate void OnAdcValueChanged (object sender, AdcValueChangedEventArgs e)
 Used to send ValueChanged events from the AnalogIn pin. More...
 
delegate void OnAnalogValueChanged (object sender, AnalogValueChangedEventArgs e)
 Used to send ValueChanged events from the pin. More...
 
delegate void PinEventData (byte[] data)
 Pin event data delegate More...
 
delegate void ConnectionAddedHandler (IConnection connectionAdded)
 A delegate representing a new connection More...
 
delegate void ConnectionRemovedHandler (IConnection connectionRemoved)
 A delegate representing a removed connection More...
 

Detailed Description

Base Treehopper namespace.

Enumeration Type Documentation

◆ AdcReferenceLevel

enum AdcReferenceLevel
strong

Select the reference to use for the analog input of the pin

Enumerator
Vref_3V3 

3.3V rail generated by on-board LDO, rated at 1.5% accuracy.

Vref_1V65 

1.65V reference rated at 1.8% accuracy.

Vref_1V85 

1.85V reference.

Accuracy TBD.

Vref_2V4 

2.4V reference rated at 2.1% accuracy.

Vref_3V3Derived 

3.3V supply derived from the 1.65V reference rated at 3.6% accuracy.

Vref_3V7 

3.7V reference derived from the 1.85V LDO.

Accuracy TBD.

◆ ChipSelectMode

enum ChipSelectMode
strong

Defines whether a signal is active high (rising-edge) or active low (falling-edge)

Enumerator
SpiActiveLow 

CS is asserted low, the SPI transaction takes place, and then the signal is returned high.

SpiActiveHigh 

CS is asserted high, the SPI transaction takes place, and then the signal is returned low.

PulseHighAtBeginning 

CS is pulsed high, and then the SPI transaction takes place.

PulseHighAtEnd 

The SPI transaction takes place, and once finished, CS is pulsed high

PulseLowAtBeginning 

CS is pulsed low, and then the SPI transaction takes place.

PulseLowAtEnd 

The SPI transaction takes place, and once finished, CS is pulsed low

◆ HardwarePwmFrequency

enum HardwarePwmFrequency
strong

Defines the PWM period options

Enumerator
Freq732Hz 

732 Hz PWM frequency

Freq183Hz 

183 Hz PWM frequency

Freq61Hz 

61 Hz PWM frequency

◆ I2CTransferError

enum I2CTransferError
strong

Describes the transfer error, if not Success, that occured

Enumerator
ArbitrationLostError 

Bus arbitration was lost

NackError 

The slave device failed to Nack back.

UnknownError 

Unknown error

TxunderError 

Tx buffer underrun error

Success 

Successful transaction

◆ PinMode

enum PinMode
strong

An enumeration representing the different supported modes of this pin.

Enumerator
Reserved 

Pin is reserved for other use

DigitalInput 

Pin is a digital input

PushPullOutput 

Pin is a push-pull output

OpenDrainOutput 

Pin is an open-drain output

AnalogInput 

Pin is an analog input

SoftPwm 

Pin is a SoftPWM output

Unassigned 

Pin is unassigned

◆ SpiBurstMode

enum SpiBurstMode
strong

The SPI burst mode to use

Enumerator
NoBurst 

No burst – always read the same number of bytes as transmitted

BurstTx 

Transmit burst – don't return any data read from the bus

BurstRx 

Receive burst – ignore transmitted data above 53 bytes long, but receive the full number of bytes specified

◆ SpiMode

enum SpiMode
strong

Defines the clock phase and polarity used for SPI communication

The left number indicates the clock polarity (CPOL), while the right number indicates the clock phase (CPHA). Consult https://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus#Clock_polarity_and_phase for more information.

Note that the numeric values of this enum do not match the standard nomenclature, but instead match the value needed by Treehopper's MCU. Do not attempt to cast integers from/to this enum.

Enumerator
Mode00 

Clock is initially low; data is valid on the rising edge of the clock

Mode01 

Clock is initially low; data is valid on the falling edge of the clock

Mode10 

Clock is initially high; data is valid on the rising edge of the clock

Mode11 

Clock is initially high; data is valid on the falling edge of the clock

◆ UartMode

enum UartMode
strong

Whether to use UART or OneWire mode

Enumerator
Uart 

The module is operating in UART mode

OneWire 

The module is operating in OneWire mode.

Only the TX pin is used.

Function Documentation

◆ TreehopperUsbAddedHandler()

delegate void Treehopper.TreehopperUsbAddedHandler ( TreehopperUsb  boardAdded)

An event handler for when a board is added

Parameters
boardAddedThe new board

◆ TreehopperUsbRemovedHandler()

delegate void Treehopper.TreehopperUsbRemovedHandler ( TreehopperUsb  boardRemoved)

An event handler for when a board is removed

Parameters
boardRemovedthe removed board

◆ PinValuesUpdatedHandler()

delegate void Treehopper.PinValuesUpdatedHandler ( object  sender,
EventArgs  e 
)

An event handler for when a new pin update report comes in

Parameters
senderThe board from where it originated
eA ference to the new pin update report

◆ OnDigitalInValueChanged()

delegate void Treehopper.OnDigitalInValueChanged ( object  sender,
DigitalInValueChangedEventArgs  e 
)

This is the delegate prototype used for event-driven reading of digital pins.

Parameters
senderThe Pin that changed
eThe new value of the pin

◆ OnAnalogVoltageChanged()

delegate void Treehopper.OnAnalogVoltageChanged ( object  sender,
AnalogVoltageChangedEventArgs  e 
)

Used to send VoltageChanged events from the AnalogIn pin.

Parameters
senderThe AnalogIn pin that sent that message
eThe new voltage of the AnalogIn pin

◆ OnAdcValueChanged()

delegate void Treehopper.OnAdcValueChanged ( object  sender,
AdcValueChangedEventArgs  e 
)

Used to send ValueChanged events from the AnalogIn pin.

Parameters
senderThe AnalogIn pin that sent that message
eThe new voltage of the AnalogIn pin

◆ OnAnalogValueChanged()

delegate void Treehopper.OnAnalogValueChanged ( object  sender,
AnalogValueChangedEventArgs  e 
)

Used to send ValueChanged events from the pin.

Parameters
senderThe pin that sent that message
eThe new normalized value of the pin

◆ PinEventData()

delegate void Treehopper.PinEventData ( byte []  data)

Pin event data delegate

Parameters
dataThe pin event data sent by the board

◆ ConnectionAddedHandler()

delegate void Treehopper.ConnectionAddedHandler ( IConnection  connectionAdded)

A delegate representing a new connection

Parameters
connectionAddedThe new connection

◆ ConnectionRemovedHandler()

delegate void Treehopper.ConnectionRemovedHandler ( IConnection  connectionRemoved)

A delegate representing a removed connection

Parameters
connectionRemovedThe old connection