pub struct FTrig {
pub clk: bool,
pub q: bool,
/* private fields */
}Expand description
Falling Edge Trigger (F_TRIG)
Detects a falling edge (true → false transition) on the input signal.
The output q is true for exactly one cycle when the input clk
transitions from true to false.
This is equivalent to the IEC 61131-3 F_TRIG function block.
§Example
use autocore_std::FTrig;
let mut trigger = FTrig::new();
// Signal starts low
assert_eq!(trigger.call(false), false);
// Signal goes high
assert_eq!(trigger.call(true), false);
// Falling edge detected!
assert_eq!(trigger.call(false), true);
// Signal still low, edge already passed
assert_eq!(trigger.call(false), false);§Timing Diagram
clk: _____|‾‾‾‾‾‾‾‾‾|_____|‾‾‾‾‾
q: _______________|‾|________§Use Cases
- Detecting button releases
- Detecting signal loss
- Triggering actions when a condition ends
Fields§
§clk: boolCurrent input value
q: boolOutput: true for one cycle on falling edge
Implementations§
Source§impl FTrig
impl FTrig
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new falling edge trigger with all values initialized to false.
§Example
use autocore_std::FTrig;
let trigger = FTrig::new();
assert_eq!(trigger.q, false);Sourcepub fn call(&mut self, clk: bool) -> bool
pub fn call(&mut self, clk: bool) -> bool
Executes the falling edge detection logic.
Call this method once per control cycle with the current input value.
Returns true for exactly one cycle when a falling edge is detected.
§Arguments
clk- The current state of the input signal
§Returns
true if a falling edge (true → false transition) was detected, false otherwise.
§Example
use autocore_std::FTrig;
let mut trigger = FTrig::new();
// Simulate button release
trigger.call(true); // Button held
if trigger.call(false) { // Button released
println!("Button was just released!");
}Trait Implementations§
Auto Trait Implementations§
impl Freeze for FTrig
impl RefUnwindSafe for FTrig
impl Send for FTrig
impl Sync for FTrig
impl Unpin for FTrig
impl UnsafeUnpin for FTrig
impl UnwindSafe for FTrig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more