Retrieving The Latest Input Data Values
As was mentioned earlier, callbacks are preferred over polling for input data change notifications.
That being said, your application may dictate using polling over callbacks. This section describes the API methods to retrieve the latest cached input data values.
analog_read
def analog_read(self, pin)
Retrieve the last data update for the specified analog pin.
:param pin: Analog pin number (ex. A2 is specified as 2)
:returns: A list = [last value change, time_stamp]
Examples:
dht_read
def dht_read(self, pin):
"""
Retrieve the last data update for the specified dht pin.
:param pin: digital pin number
:return: A list = [humidity, temperature time_stamp]
ERROR CODES: If either humidity or temperature value:
== -1 Configuration Error
== -2 Checksum Error
== -3 Timeout Error
"""
Examples:
digital_read
def digital_read(self, pin)
Retrieve the last data update for the specified digital pin.
:param pin: Digital pin number
:returns: A list = [last value change, time_stamp]
Examples:
i2c_read_saved_data
def i2c_read_saved_data(self, address)
This method retrieves cached i2c data to support a polling mode.
:param address: I2C device address
:returns: Last cached value reported This contains the number of bytes requested followed by the time_stamp.
Example:
sonar_read
def sonar_read(self, trigger_pin)
This is a FirmataExpress feature
Retrieve Ping (HC-SR04 type) data. The data is presented as a dictionary.
The 'key' is the trigger pin specified in sonar_config() and the 'data' is the current measured distance (in centimeters) for that pin. If there is no data, the value is set to None.
:param trigger_pin: key into sonar data map
:returns: A list = [last value, raw time_stamp]
Example: 1. hc-sr04_distance_sensor.py
Copyright (C) 2020 Alan Yorinks. All Rights Reserved.