$darkmode
cloe::utility::PushButton< D > Class Template Reference

#include <hmi_contact.hpp>

Inheritance diagram for cloe::utility::PushButton< D >:
Collaboration diagram for cloe::utility::PushButton< D >:

Public Member Functions

 PushButton (std::function< void()> click_fn)
 
 PushButton (std::function< void()> click_fn, std::function< void()> repeat_fn)
 
void set_delay (D delay)
 
void set_interval (D interval)
 
- Public Member Functions inherited from cloe::utility::Contact< Duration >
 Contact (bool active)
 
void update (Duration time, bool down)
 
bool has_contact () const
 

Protected Member Functions

void contact_down (D time) override
 
void contact_up (D) override
 
void reset ()
 
- Protected Member Functions inherited from cloe::utility::Contact< Duration >
virtual void contact_down (Duration time)=0
 
virtual void contact_up (Duration time)=0
 

Additional Inherited Members

- Protected Attributes inherited from cloe::utility::Contact< Duration >
bool active_
 

Detailed Description

template<typename D = Duration>
class cloe::utility::PushButton< D >

PushButton simulates a push button.

Pressing a button generally applies a current to a circuit. This current flows for a time t, which is variable. How often a button is triggered then is subject to the following algorithm:

---------—|--—|--—|--—|--—|— push delay | | inter-arrival time release

At delay and every inter-arrival time, the repeated function is executed, and at release the repeated function is not performed, or the single function is executed if the delay has not been reached yet.

WARNING: PushButton requires regular updates. On each update it will trigger at most once, so if you update with (0, true) and then again at (10000, true), it will simply trigger the repeated function once.

Member Function Documentation

◆ set_delay()

template<typename D = Duration>
void cloe::utility::PushButton< D >::set_delay ( delay)
inline

Set the initial delay before a repeated button activation is triggered.

Regardless of the delay, on release a "click" is activated.

◆ set_interval()

template<typename D = Duration>
void cloe::utility::PushButton< D >::set_interval ( interval)
inline

Set the interarrival time of repeated button activations.

After the first delay, interval amount of time elapses between button activations.


The documentation for this class was generated from the following file: