pub struct IndustrialDigitalIn4Bricklet { /* private fields */ }
Expand description

4 galvanically isolated digital inputs

Implementations§

source§

impl IndustrialDigitalIn4Bricklet

source

pub const DEVICE_IDENTIFIER: u16 = 223u16

source

pub const DEVICE_DISPLAY_NAME: &'static str = "Industrial Digital In 4 Bricklet"

source

pub fn new<T: GetRequestSender>( uid: &str, req_sender: T ) -> IndustrialDigitalIn4Bricklet

Creates an object with the unique device ID uid. This object can then be used after the IP Connection ip_connection is connected.

source

pub fn get_response_expected( &mut self, fun: IndustrialDigitalIn4BrickletFunction ) -> Result<bool, GetResponseExpectedError>

Returns the response expected flag for the function specified by the function ID parameter. It is true if the function is expected to send a response, false otherwise.

For getter functions this is enabled by default and cannot be disabled, because those functions will always send a response. For callback configuration functions it is enabled by default too, but can be disabled by set_response_expected. For setter functions it is disabled by default and can be enabled.

Enabling the response expected flag for a setter function allows to detect timeouts and other error conditions calls of this setter as well. The device will then send a response for this purpose. If this flag is disabled for a setter function then no response is sent and errors are silently ignored, because they cannot be detected.

See set_response_expected for the list of function ID constants available for this function.

source

pub fn set_response_expected( &mut self, fun: IndustrialDigitalIn4BrickletFunction, response_expected: bool ) -> Result<(), SetResponseExpectedError>

Changes the response expected flag of the function specified by the function ID parameter. This flag can only be changed for setter (default value: false) and callback configuration functions (default value: true). For getter functions it is always enabled.

Enabling the response expected flag for a setter function allows to detect timeouts and other error conditions calls of this setter as well. The device will then send a response for this purpose. If this flag is disabled for a setter function then no response is sent and errors are silently ignored, because they cannot be detected.

source

pub fn set_response_expected_all(&mut self, response_expected: bool)

Changes the response expected flag for all setter and callback configuration functions of this device at once.

source

pub fn get_api_version(&self) -> [u8; 3]

Returns the version of the API definition (major, minor, revision) implemented by this API bindings. This is neither the release version of this API bindings nor does it tell you anything about the represented Brick or Bricklet.

source

pub fn get_interrupt_callback_receiver( &self ) -> ConvertingCallbackReceiver<InterruptEvent>

This receiver is triggered whenever a change of the voltage level is detected on pins where the interrupt was activated with set_interrupt.

The values are a bitmask that specifies which interrupts occurred and the current value bitmask.

For example:

  • (1, 1) or (0b0001, 0b0001) means that an interrupt on pin 0 occurred and currently pin 0 is high and pins 1-3 are low.
  • (9, 14) or (0b1001, 0b1110) means that interrupts on pins 0 and 3 occurred and currently pin 0 is low and pins 1-3 are high.

The interrupts use the grouping as set by set_group.

source

pub fn get_value(&self) -> ConvertingReceiver<u16>

Returns the input value with a bitmask. The bitmask is 16bit long, true refers to high and false refers to low.

For example: The value 3 or 0b0011 means that pins 0-1 are high and the other pins are low.

If no groups are used (see [set_group]), the pins correspond to the markings on the IndustrialDigital In 4 Bricklet.

If groups are used, the pins correspond to the element in the group. Element 1 in the group will get pins 0-3, element 2 pins 4-7, element 3 pins 8-11 and element 4 pins 12-15.

source

pub fn set_group(&self, group: [char; 4]) -> ConvertingReceiver<()>

Sets a group of Digital In 4 Bricklets that should work together. You can find Bricklets that can be grouped together with [get_available_for_group].

The group consists of 4 elements. Element 1 in the group will get pins 0-3, element 2 pins 4-7, element 3 pins 8-11 and element 4 pins 12-15.

Each element can either be one of the ports (‘a’ to ‘d’) or ‘n’ if it should not be used.

For example: If you have two Digital In 4 Bricklets connected to port A and port B respectively, you could call with ['a', 'b', 'n', 'n'].

Now the pins on the Digital In 4 on port A are assigned to 0-3 and the pins on the Digital In 4 on port B are assigned to 4-7. It is now possible to call [get_value] and read out two Bricklets at the same time.

Changing the group configuration resets all edge counter configurations and values.

source

pub fn get_group(&self) -> ConvertingReceiver<[char; 4]>

Returns the group as set by [set_group]

source

pub fn get_available_for_group(&self) -> ConvertingReceiver<u8>

Returns a bitmask of ports that are available for grouping. For example the value 5 or 0b0101 means: Port A and port C are connected to Bricklets that can be grouped together.

source

pub fn set_debounce_period(&self, debounce: u32) -> ConvertingReceiver<()>

Sets the debounce period of the [get_interrupt_callback_receiver] receiver.

For example: If you set this value to 100, you will get the interrupt maximal every 100ms. This is necessary if something that bounces is connected to the Digital In 4 Bricklet, such as a button.

source

pub fn get_debounce_period(&self) -> ConvertingReceiver<u32>

Returns the debounce period as set by [set_debounce_period].

source

pub fn set_interrupt(&self, interrupt_mask: u16) -> ConvertingReceiver<()>

Sets the pins on which an interrupt is activated with a bitmask. Interrupts are triggered on changes of the voltage level of the pin, i.e. changes from high to low and low to high.

For example: An interrupt bitmask of 9 or 0b1001 will enable the interrupt for pins 0 and 3.

The interrupts use the grouping as set by [set_group].

The interrupt is delivered with the [get_interrupt_callback_receiver] receiver.

source

pub fn get_interrupt(&self) -> ConvertingReceiver<u16>

Returns the interrupt bitmask as set by [set_interrupt].

source

pub fn get_edge_count( &self, pin: u8, reset_counter: bool ) -> ConvertingReceiver<u32>

Returns the current value of the edge counter for the selected pin. You can configure the edges that are counted with [set_edge_count_config].

If you set the reset counter to true, the count is set back to 0 directly after it is read.

The edge counters use the grouping as set by [set_group].

.. versionadded:: 2.0.1$nbsp;(Plugin)

source

pub fn set_edge_count_config( &self, selection_mask: u16, edge_type: u8, debounce: u8 ) -> ConvertingReceiver<()>

Configures the edge counter for the selected pins. A bitmask of 9 or 0b1001 will enable the edge counter for pins 0 and 3.

The edge type parameter configures if rising edges, falling edges or both are counted if the pin is configured for input. Possible edge types are:

  • 0 = rising
  • 1 = falling
  • 2 = both

Configuring an edge counter resets its value to 0.

If you don’t know what any of this means, just leave it at default. The default configuration is very likely OK for you.

The edge counters use the grouping as set by [set_group].

.. versionadded:: 2.0.1$nbsp;(Plugin)

Associated constants:

  • INDUSTRIAL_DIGITAL_IN_4_BRICKLET_EDGE_TYPE_RISING
  • INDUSTRIAL_DIGITAL_IN_4_BRICKLET_EDGE_TYPE_FALLING
  • INDUSTRIAL_DIGITAL_IN_4_BRICKLET_EDGE_TYPE_BOTH
source

pub fn get_edge_count_config( &self, pin: u8 ) -> ConvertingReceiver<EdgeCountConfig>

Returns the edge type and debounce time for the selected pin as set by [set_edge_count_config].

.. versionadded:: 2.0.1$nbsp;(Plugin)

Associated constants:

  • INDUSTRIAL_DIGITAL_IN_4_BRICKLET_EDGE_TYPE_RISING
  • INDUSTRIAL_DIGITAL_IN_4_BRICKLET_EDGE_TYPE_FALLING
  • INDUSTRIAL_DIGITAL_IN_4_BRICKLET_EDGE_TYPE_BOTH
source

pub fn get_identity(&self) -> ConvertingReceiver<Identity>

Returns the UID, the UID where the Bricklet is connected to, the position, the hardware and firmware version as well as the device identifier.

The position can be ‘a’, ‘b’, ‘c’, ‘d’, ‘e’, ‘f’, ‘g’ or ‘h’ (Bricklet Port). A Bricklet connected to an Isolator Bricklet is always at position ‘z’.

The device identifier numbers can be found here. |device_identifier_constant|

Trait Implementations§

source§

impl Clone for IndustrialDigitalIn4Bricklet

source§

fn clone(&self) -> IndustrialDigitalIn4Bricklet

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V