Skip to content

Latest commit

 

History

History
268 lines (181 loc) · 6.03 KB

api.md

File metadata and controls

268 lines (181 loc) · 6.03 KB

Summary

class ModulinoButtons

class ModulinoButtons(Modulino)

default_long_press_duration

1 second

update

def update()

Update the button status and call the corresponding callbacks. Returns True if any of the buttons has changed its state.

class I2CHelper

class I2CHelper()

A helper class for interacting with I2C devices on supported boards.

frequency

Modulinos operate at 100kHz

reset_bus

@staticmethod
def reset_bus(i2c_bus)

Resets the I2C bus in case it got stuck. To unblock the bus the SDA line is kept high for 20 clock cycles Which causes the triggering of a NAK message.

find_interface

@staticmethod
def find_interface() -> I2C

Returns an instance of the I2C interface for the current board.

Raises: RuntimeError: If the current board is not supported.

Returns: I2C: An instance of the I2C interface.

class Modulino

class Modulino()

discover

def discover(default_addresses)

Tries to find the given modulino device in the device chain based on the pre-defined default addresses. If the address has been changed to a custom one it won't be found with this function.

__bool__

def __bool__()

Boolean cast operator to determine if the given i2c device has a correct address and if the bus is defined. In case of auto discovery this also means that the device was found on the bus because otherwise the address would be None.

connected

@property
def connected()

Determines if the given modulino is connected to the i2c bus.

pin_strap_address

@property
def pin_strap_address()

Returns the pin strap i2c address of the modulino. This address is set via resistors on the modulino board. Since all modulinos generally use the same firmware, the pinstrap address is needed to determine the type of the modulino at boot time, so it know what to do. At boot it checks the internal flash in case its address has been overridden by the user which would take precedence.

read

def read(amount_of_bytes)

Reads the given amount of bytes from the i2c device and returns the data. It skips the first byte which is the pinstrap address.

write

def write(data_buffer)

Writes the given buffer to the i2c device.

has_default_address

@property
def has_default_address()

Determines if the given modulino has a default address or if a custom one was set.

reset_bus

@staticmethod
def reset_bus(i2c_bus)

Resets the i2c bus. This is useful when the bus is in an unknown state. The modulinos that are equipped with a micro controller use DMA operations. If the host board does a reset during such operation it can make the bus get stuck.

Returns ---- I2C: A new i2c bus object after resetting the bus.

class ModulinoColor

class ModulinoColor()

__int__

def __int__()

Return the 32-bit integer representation of the color.

class ModulinoThermo

class ModulinoThermo(Modulino)

measurements

@property
def measurements() -> Measurement

Return Temperature and Relative Humidity or None if the data is stalled

relative_humidity

@property
def relative_humidity() -> float

The current relative humidity in % rH

temperature

@property
def temperature() -> float

The current temperature in Celsius