Struct mpr121_hal::Mpr121

source ·
pub struct Mpr121<I2C: Write + WriteRead> { /* private fields */ }
Expand description

I2C connected Mpr121. Use either new_default or new to create a new instance.

If you want to collect the I²C bus upon drop, use free, which deconstructs Self.

Implementations

Creates the driver for the given I²C ports. Assumes that the I²C port is configured as master. If use_auto_config is set, the controller will use its auto configuration routine to setup charging parameters whenever it is transitioned from STOP to START mode.

Note that we use the same default values as the Adafruit implementation, except for threshold values. Use set_thresholds to define those.

Initializes the driver assuming the sensors address is the default one (0x5a). If this fails, consider searching for the driver. Or following the documentation on setting a driver address, and use new to specify the address.

Have a look at new for further documentation.

Set the touch and release threshold for all channels. Usually the touch threshold is a little bigger than the release threshold. This creates some debounce characteristics. The correct thresholds depend on the application.

Have a look at note AN3892 of the mpr121 guidelines.

Sets the count for both touch and release. See 5.7 of the data sheet.

value must be 0..8, is clamped if it exceeds.

Reads the filtered data form channel t. Noise gets filtered out by the chip. See 5.3 in the data sheet.

Note that the resulting value is only 10bit wide.

Note that 0 is returned, if channel > 12.

Reads the baseline data for the channel. Note that this has only a resolution of 8bit.

Note that 0 is returned, if channel > 12, or reading failed

Reads the touched state of all channels. Returns a u16 where each bit 0..12 indicates whether the pin is touched or not. Use bit shifting / masking to generate a mask, or, if only one sensor’s value is needed, use get_touch_state.

Returns 0 if reading failed.

Returns the touch state of the given sensor.

Returns false if channel>11, or reading failed.

Consumes self and releases the i2c bus that is used.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.