$darkmode
#include <hmi_contact.hpp>
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< D > | |
| Contact (bool active) | |
| void | update (D time, bool down) |
| bool | has_contact () const |
Protected Member Functions | |
| void | contact_down (D time) override |
| void | contact_up (D) override |
| void | reset () |
Additional Inherited Members | |
Protected Attributes inherited from cloe::utility::Contact< D > | |
| bool | active_ {false} |
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.
|
inlineoverrideprotectedvirtual |
Apply the contact.
This corresponds to pushing down on a key or button, or moving a switch to the ON position, and should set active_ to true.
Implements cloe::utility::Contact< D >.
|
inlineoverrideprotectedvirtual |
Release the contact.
This corresponds to releasing a previous push on a key or button, or moving a switch to the OFF position, and should set active_ to false.
Implements cloe::utility::Contact< D >.
|
inline |
Set the initial delay before a repeated button activation is triggered.
Regardless of the delay, on release a "click" is activated.
|
inline |
Set the interarrival time of repeated button activations.
After the first delay, interval amount of time elapses between button activations.