Treehopper C# API
|
Commonly used external peripherals, sensors, and other devices. More...
Namespaces | |
namespace | ArduinoShim |
Provide some Arduino functions to make it easier to run Arduino code with Treehopper in C# | |
namespace | Displays |
Individual and array LEDs, plus character and graphic displays | |
namespace | Input |
Rotary encoders, buttons, faders, and other physical input devices | |
namespace | IO |
Port expanders, shift registers, ADCs, and DACs | |
namespace | Memory |
Discrete flash and RAM memory | |
namespace | Motors |
Motors, motor controllers, and H-bridge drivers | |
namespace | Sensors |
Sensors for measuring physical phenomena | |
namespace | Utilities |
Utility classes used across Treehopper.Libraries | |
Classes | |
interface | IPolledEvents |
class | Register |
class | RegisterManager |
class | SMBusDevice |
Device class used to abstract i2C interfacing More... | |
class | SpiDevice |
Represents a peripheral attached to the SPI bus More... | |
class | Supports |
Commonly used external peripherals, sensors, and other devices.
Many sensors require several milliseconds or longer to update their values; to make the API both easy to use and also performant, Treehopper provides control over how sensor properties are updated.
By default, reading from a sensor's property (as example, the Accelerometer property of an IMU) will fetch an update from the sensor and set the property's value to this reading.
This is convenient for console scripts and simple applications, but for more efficient bus usage, consider changing the sensor's AutoUpdateWhenPropertyRead property to false, which allows you to read from properties without fetching updates.
When you do want to request an update, call the sensor's UpdateAsync() method. This method will update all the properties, and fire PropertyChanged events where appropriate.
Because most library components expose PropertyChanged-capable properties that hold the object's state, you can directly bind UI controls — like text boxes, list views, buttons, progress bars, and sliders — to library component properties.
Similarly, for output devices, changing a device's property will write out this value to the device immediately by default. Many devices — like LED arrays, shift registers, and graphical LCDs — require the entire peripheral to be updated at once.
To enable more control over how peripheral updates are flushed out, you can disable this functionality by setting AutoFlush to false. Then, whenever you wish to flush writes out to the device, call the FlushAsync() method.