SensESP 2.7.2
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. More...

#include <sensesp/transforms/click_type.h>

Inheritance diagram for sensesp::ClickType:
[legend]

Public Member Functions

 ClickType (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_input (bool input, uint8_t input_channel=0) override
 
virtual void get_configuration (JsonObject &doc) override
 
virtual bool set_configuration (const JsonObject &config) override
 
virtual String get_config_schema () 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 (String config_path="")
 
- Public Member Functions inherited from sensesp::Configurable
 Configurable (String config_path="", String description="", int sort_order=1000)
 
String get_description ()
 
void set_description (String description)
 Set the description of the Configurable.
 
int get_sort_order ()
 
void set_sort_order (int sort_order)
 
virtual void save_configuration ()
 
- Public Member Functions inherited from sensesp::Startable
 Startable (int priority=0)
 
virtual void start ()
 
const int get_start_priority ()
 
void set_start_priority (int priority)
 
- Public Member Functions inherited from sensesp::ValueConsumer< T >
virtual void set_input (T new_value, uint8_t input_channel=0)
 
void connect_from (ValueProducer< T > *producer, uint8_t input_channel=0)
 
- Public Member Functions inherited from sensesp::ValueProducer< T >
 ValueProducer ()
 
virtual const T & get () const
 
void connect_to (ValueConsumer< T > *consumer, uint8_t input_channel=0)
 
template<typename CT >
void connect_to (ValueConsumer< CT > *consumer, uint8_t input_channel=0)
 Connect a producer to a consumer of a different type.
 
template<typename T2 >
Transform< T, T2 > * connect_to (Transform< T, T2 > *consumer_producer, uint8_t input_channel=0)
 
template<typename TT , typename T2 >
Transform< TT, T2 > * connect_to (Transform< TT, T2 > *consumer_producer, uint8_t input_channel=0)
 Connect a producer to a transform with a different input type.
 
void emit (T 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 ()
 
- Static Public Member Functions inherited from sensesp::Startable
static void start_all ()
 

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 Member Functions inherited from sensesp::Configurable
virtual void load_configuration ()
 

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.
 
DelayReactiondelayed_click_report_
 
- Protected Attributes inherited from sensesp::Configurable
String description_ = ""
 
int sort_order_ = 1000
 
- Protected Attributes inherited from sensesp::ValueProducer< T >
output
 

Additional Inherited Members

- Public Attributes inherited from sensesp::Configurable
const String config_path_
 

Detailed Description

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

See also
ClickTypes

Definition at line 28 of file click_type.h.

Constructor & Destructor Documentation

◆ ClickType()

sensesp::ClickType::ClickType ( 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 7 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 124 of file click_type.cpp.

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

◆ get_config_schema()

String sensesp::ClickType::get_config_schema ( )
overridevirtual

Returns a configuration schema that specifies the key/value pairs that can be expected when calling get_configuration(), or are expected by set_configuration(). The schema will be in JSON Schema format

See also
https://json-schema.org

Reimplemented from sensesp::Configurable.

Definition at line 159 of file click_type.cpp.

◆ get_configuration()

void sensesp::ClickType::get_configuration ( JsonObject configObject)
overridevirtual

Returns the current configuration data as a JsonObject. In general, the current state of local member variables are saved to a new object created with JsonDocument::as<JsonObject>() and returned.

Reimplemented from sensesp::Configurable.

Definition at line 144 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 27 of file click_type.cpp.

Here is the caller graph for this function:

◆ on_button_press()

void sensesp::ClickType::on_button_press ( )
protected

Processes incoming values that represent a "ButonPress" event.

Definition at line 32 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 68 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 128 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 135 of file click_type.cpp.

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

◆ set_configuration()

bool sensesp::ClickType::set_configuration ( const JsonObject config)
overridevirtual

Sets the current state of local member variables using the data stored in config.

Reimplemented from sensesp::Configurable.

Definition at line 161 of file click_type.cpp.

◆ set_input()

void sensesp::ClickType::set_input ( bool  input,
uint8_t  input_channel = 0 
)
overridevirtual

Definition at line 19 of file click_type.cpp.

Here is the call graph for this function:

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_

DelayReaction* 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: