pub struct IndustrialDigitalIn4Bricklet { /* private fields */ }
Expand description
4 galvanically isolated digital inputs
Implementations
sourceimpl IndustrialDigitalIn4Bricklet
impl IndustrialDigitalIn4Bricklet
pub const DEVICE_IDENTIFIER: u16 = 223u16
pub const DEVICE_DISPLAY_NAME: &'static str = "Industrial Digital In 4 Bricklet"
sourcepub fn new(
uid: &str,
ip_connection: &IpConnection
) -> IndustrialDigitalIn4Bricklet
pub fn new(
uid: &str,
ip_connection: &IpConnection
) -> IndustrialDigitalIn4Bricklet
Creates an object with the unique device ID uid
. This object can then be used after the IP Connection ip_connection
is connected.
sourcepub fn get_response_expected(
&mut self,
fun: IndustrialDigitalIn4BrickletFunction
) -> Result<bool, GetResponseExpectedError>
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 send 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.
sourcepub fn set_response_expected(
&mut self,
fun: IndustrialDigitalIn4BrickletFunction,
response_expected: bool
) -> Result<(), SetResponseExpectedError>
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 send and errors are silently ignored, because they cannot be detected.
sourcepub fn set_response_expected_all(&mut self, response_expected: bool)
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.
sourcepub fn get_interrupt_callback_receiver(
&self
) -> ConvertingCallbackReceiver<InterruptEvent>
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.
sourcepub fn get_value(&self) -> ConvertingReceiver<u16>
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 Digital 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.
sourcepub fn set_group(&self, group: [char; 4]) -> ConvertingReceiver<()>
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.
sourcepub fn get_group(&self) -> ConvertingReceiver<[char; 4]>
pub fn get_group(&self) -> ConvertingReceiver<[char; 4]>
Returns the group as set by Set Group
sourcepub fn get_available_for_group(&self) -> ConvertingReceiver<u8>
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.
sourcepub fn set_debounce_period(&self, debounce: u32) -> ConvertingReceiver<()>
pub fn set_debounce_period(&self, debounce: u32) -> ConvertingReceiver<()>
Sets the debounce period of the get_interrupt_callback_receiver
receiver in ms.
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.
The default value is 100.
sourcepub fn get_debounce_period(&self) -> ConvertingReceiver<u32>
pub fn get_debounce_period(&self) -> ConvertingReceiver<u32>
Returns the debounce period as set by Set Debounce Period
.
sourcepub fn set_interrupt(&self, interrupt_mask: u16) -> ConvertingReceiver<()>
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.
sourcepub fn get_interrupt(&self) -> ConvertingReceiver<u16>
pub fn get_interrupt(&self) -> ConvertingReceiver<u16>
Returns the interrupt bitmask as set by Set Interrupt
.
sourcepub fn get_edge_count(
&self,
pin: u8,
reset_counter: bool
) -> ConvertingReceiver<u32>
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.
.. versionadded:: 2.0.1$nbsp;(Plugin)
sourcepub fn set_edge_count_config(
&self,
selection_mask: u16,
edge_type: u8,
debounce: u8
) -> ConvertingReceiver<()>
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 (default)
- 1 = falling
- 2 = both
The debounce time is given in ms.
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.
Default values: 0 (edge type) and 100ms (debounce time)
.. versionadded:: 2.0.1$nbsp;(Plugin)
Associated constants:
- INDUSTRIAL_DIGITAL_IN_4BRICKLET_EDGE_TYPE_RISING
- INDUSTRIAL_DIGITAL_IN_4BRICKLET_EDGE_TYPE_FALLING
- INDUSTRIAL_DIGITAL_IN_4BRICKLET_EDGE_TYPE_BOTH
sourcepub fn get_edge_count_config(
&self,
pin: u8
) -> ConvertingReceiver<EdgeCountConfig>
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_4BRICKLET_EDGE_TYPE_RISING
- INDUSTRIAL_DIGITAL_IN_4BRICKLET_EDGE_TYPE_FALLING
- INDUSTRIAL_DIGITAL_IN_4BRICKLET_EDGE_TYPE_BOTH
sourcepub fn get_identity(&self) -> ConvertingReceiver<Identity>
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’ or ‘d’.
The device identifier numbers can be found here. |device_identifier_constant|
Trait Implementations
sourceimpl Clone for IndustrialDigitalIn4Bricklet
impl Clone for IndustrialDigitalIn4Bricklet
sourcefn clone(&self) -> IndustrialDigitalIn4Bricklet
fn clone(&self) -> IndustrialDigitalIn4Bricklet
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more