SensESP 3.0.1
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
sensesp::ClickType Class Reference

ClickType is a transform that consumes button clicks and translates them as events of type ClickTypes. Use AceButton instead. More...

#include <sensesp/transforms/click_type.h>

Inheritance diagram for sensesp::ClickType:
[legend]

Public Member Functions

 ClickType (const String &config_path="", uint16_t long_click_delay=1300, uint16_t double_click_interval=400, uint16_t ultra_long_click_delay=5000)
 
virtual void set (const bool &input) override
 
virtual bool to_json (JsonObject &root) override
 
virtual bool from_json (const JsonObject &config) override
 
- Public Member Functions inherited from sensesp::Transform< bool, ClickTypes >
 Transform (String config_path="")
 
Transform< bool, ClickTypes > * connect_from (ValueProducer< ClickTypes > *producer0, ValueProducer< ClickTypes > *producer1=NULL, ValueProducer< ClickTypes > *producer2=NULL, ValueProducer< ClickTypes > *producer3=NULL, ValueProducer< ClickTypes > *producer4=NULL)
 
- Public Member Functions inherited from sensesp::TransformBase
 TransformBase (const String &config_path)
 
- Public Member Functions inherited from sensesp::FileSystemSaveable
 FileSystemSaveable (const String &config_path)
 
virtual bool load () override
 Load and populate the object from a persistent storage.
 
virtual bool save () override
 Save the object to a persistent storage.
 
virtual bool clear () override
 Delete the data from a persistent storage.
 
bool find_config_file (const String &config_path, String &filename)
 
- Public Member Functions inherited from sensesp::Saveable
 Saveable (const String &config_path)
 
virtual bool refresh ()
 Refresh the object. This may or may not access the persistent storage but is not expected to overwrite the object's state.
 
const String & get_config_path () const
 
- Public Member Functions inherited from sensesp::Serializable
- Public Member Functions inherited from sensesp::ValueConsumer< bool >
virtual void set_input (const bool &new_value)
 
void connect_from (ValueProducer< bool > *producer)
 
- Public Member Functions inherited from sensesp::ValueProducer< ClickTypes >
 ValueProducer ()
 
 ValueProducer (const ClickTypes &initial_value)
 
virtual const ClickTypesget () const
 
std::enable_if< std::is_base_of< ValueConsumer< typenameVConsumer::input_type >, VConsumer >::value &&std::is_convertible< ClickTypes, typenameVConsumer::input_type >::value, std::shared_ptr< VConsumer > >::type connect_to (std::shared_ptr< VConsumer > consumer)
 Connect a producer to a transform with a different input type.
 
std::enable_if< std::is_base_of< ValueConsumer< typenameVConsumer::input_type >, VConsumer >::value &&std::is_convertible< ClickTypes, typenameVConsumer::input_type >::value, VConsumer * >::type connect_to (VConsumer *consumer)
 
std::enable_if< std::is_base_of< ValueConsumer< typenameVConsumer::input_type >, VConsumer >::value &&std::is_convertible< ClickTypes, typenameVConsumer::input_type >::value, VConsumer * >::type connect_to (VConsumer &consumer)
 
void emit (const ClickTypes &new_value)
 
- Public Member Functions inherited from sensesp::Observable
 Observable ()
 
 Observable (Observable &&other)
 Move constructor.
 
void notify ()
 
void attach (std::function< void()> observer)
 

Static Public Member Functions

static bool is_click (ClickTypes value)
 
- Static Public Member Functions inherited from sensesp::TransformBase
static const std::set< TransformBase * > & get_transforms ()
 

Protected Member Functions

void on_button_press ()
 Processes incoming values that represent a "ButonPress" event.
 
void on_button_release ()
 Processes incoming value that represent a "ButtonRelease" event.
 
void on_ultra_long_click ()
 
void on_click_completed ()
 
void emitDelayed (ClickTypes value)
 

Protected Attributes

int click_count_
 
uint16_t long_click_delay_ {}
 
uint16_t ultra_long_click_delay_ {}
 
uint16_t double_click_interval_ {}
 
elapsedMillis press_duration_
 Timmer to time button presses.
 
elapsedMillis release_duration_
 Timer to time interval between button releases.
 
reactesp::DelayEvent * delayed_click_report_ {}
 
- Protected Attributes inherited from sensesp::Saveable
const String config_path_
 
- Protected Attributes inherited from sensesp::ValueProducer< ClickTypes >
ClickTypes output_
 

Additional Inherited Members

- Public Types inherited from sensesp::ValueConsumer< bool >
using input_type
 

Detailed Description

ClickType is a transform that consumes button clicks and translates them as events of type ClickTypes. Use AceButton instead.

See also
ClickTypes

Definition at line 29 of file click_type.h.

Constructor & Destructor Documentation

◆ ClickType()

sensesp::ClickType::ClickType ( const String & config_path = "",
uint16_t long_click_delay = 1300,
uint16_t double_click_interval = 400,
uint16_t ultra_long_click_delay = 5000 )

The constructor

Parameters
config_pathThe configuration path to use if you want the end user to be able to change these values with the configuration UI. Leave as blank to disable this feature.
long_click_delayThe number of milliseconds that an incoming button press must be held to differentiate between a SingleClick and a LongSingleClick. This value should be less than ultra_long_click_delay
double_click_intervalThe maximum number of milliseconds that can pass before two consecutive button presses are sent as two SingleClick events, or a single DoubleClick event. If the interval is less than or equal to double_click_interval milliseconds, a single DoubleClick event is emitted.
ultra_long_click_delayThe number of milliseconds that an incoming button press must be held to register a single UltraLongSingleClick. Once a button has been held for ultra_long_click_delay milliseoncs, an UltraLongSingleClick is immediately emitted. This value should be longer than long_click_delay

Definition at line 8 of file click_type.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ emitDelayed()

void sensesp::ClickType::emitDelayed ( ClickTypes value)
protected

Emits the specified value after a 5 millisecond delay. This allows translated click types like SingleClick and DoubleClick to be sent but delays its processing so the ClickTypes::ButtonReleased can propogate through the system.

Definition at line 131 of file click_type.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ from_json()

bool sensesp::ClickType::from_json ( const JsonObject & root)
overridevirtual

Deserializes the current object data from a JsonObject.

Reimplemented from sensesp::Serializable.

Definition at line 160 of file click_type.cpp.

◆ is_click()

bool sensesp::ClickType::is_click ( ClickTypes value)
static

Returns TRUE if the specified value is one of the higher level click interpretations like SingleClick or UltraLongDoubleClick. It returns FALSE if the value is ButtonPress or ButtonRelease

Definition at line 28 of file click_type.cpp.

◆ on_button_press()

void sensesp::ClickType::on_button_press ( )
protected

Processes incoming values that represent a "ButonPress" event.

Definition at line 33 of file click_type.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_button_release()

void sensesp::ClickType::on_button_release ( )
protected

Processes incoming value that represent a "ButtonRelease" event.

Definition at line 70 of file click_type.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_click_completed()

void sensesp::ClickType::on_click_completed ( )
protected

Resets click tracking variables after a press has been released so the next button press can be processed.

Definition at line 136 of file click_type.cpp.

Here is the caller graph for this function:

◆ on_ultra_long_click()

void sensesp::ClickType::on_ultra_long_click ( )
protected

Processes an ultra long click. Unlike the other click types, ultra long clicks are executed as soon as they pass the "ultra long"

Definition at line 143 of file click_type.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set()

void sensesp::ClickType::set ( const bool & new_value)
overridevirtual

Used to set an input of this consumer. It is called automatically by a ValueProducer but can also be called manually.

Parameters
new_valuethe value of the input

Reimplemented from sensesp::ValueConsumer< bool >.

Definition at line 20 of file click_type.cpp.

Here is the call graph for this function:

◆ to_json()

bool sensesp::ClickType::to_json ( JsonObject & root)
overridevirtual

Serializes the current object data into a JsonObject.

Reimplemented from sensesp::Serializable.

Definition at line 153 of file click_type.cpp.

Member Data Documentation

◆ click_count_

int sensesp::ClickType::click_count_
protected

A counter to specify how many clicks are currently being processed. Used to distinguish between single and double clicks.

Definition at line 70 of file click_type.h.

◆ delayed_click_report_

reactesp::DelayEvent* sensesp::ClickType::delayed_click_report_ {}
protected

Holds a delayed "SingleClick" report that we can pull back if the second click of a double click comes through. This value will be NULL if no click report is currently queued up.

Definition at line 96 of file click_type.h.

◆ double_click_interval_

uint16_t sensesp::ClickType::double_click_interval_ {}
protected

The maximum number of milliseconds that can pass before two clicks in a row are combined into a single DoubleClick

Definition at line 84 of file click_type.h.

◆ long_click_delay_

uint16_t sensesp::ClickType::long_click_delay_ {}
protected

How many milliseconds a button is pressed to distinguish between a normal SingleClick and a LongSingleClick

Definition at line 76 of file click_type.h.

◆ press_duration_

elapsedMillis sensesp::ClickType::press_duration_
protected

Timmer to time button presses.

Definition at line 87 of file click_type.h.

◆ release_duration_

elapsedMillis sensesp::ClickType::release_duration_
protected

Timer to time interval between button releases.

Definition at line 90 of file click_type.h.

◆ ultra_long_click_delay_

uint16_t sensesp::ClickType::ultra_long_click_delay_ {}
protected

How many milliseoncs a button is pressed to distinguish between a normal SingleClick and an UltraLongSingleClick

Definition at line 80 of file click_type.h.


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