EmbAJAX
Simplistic framework for creating and handling displays and controls on a web page served by an embeddable device (Arduino or other microcontroller with Arduino support).
Public Types | Public Member Functions | List of all members
EmbAJAXMomentaryButton Class Reference

A momentary "press-and-hold" button. More...

#include <EmbAJAX.h>

Inheritance diagram for EmbAJAXMomentaryButton:
Inheritance graph
[legend]
Collaboration diagram for EmbAJAXMomentaryButton:
Collaboration graph
[legend]

Public Types

enum  Status { Pressed , MaybePressed , Released }
 
- Public Types inherited from EmbAJAXBase
enum  Property {
  Visibility , Enabledness , Value , FirstElementSpecificProperty ,
  HTMLAllowed
}
 

Public Member Functions

 EmbAJAXMomentaryButton (const char *id, const char *label, uint16_t timeout=600, void(*callback)(EmbAJAXPushButton *)=0)
 
void print () const override
 
Status status () const
 
void updateFromDriverArg (const char *argname) override
 
- Public Member Functions inherited from EmbAJAXPushButton
 EmbAJAXPushButton (const char *id, const char *label, void(*callback)(EmbAJAXPushButton *))
 
void setText (const char *label, bool allowHTML=false)
 
const char * value (uint8_t which=EmbAJAXBase::Value) const override
 
const char * valueProperty (uint8_t which=EmbAJAXBase::Value) const override
 
bool valueNeedsEscaping (uint8_t which=EmbAJAXBase::Value) const override
 
- Public Member Functions inherited from EmbAJAXElement
 EmbAJAXElement (const char *id)
 
const char * id () const
 
bool sendUpdates (uint16_t since, bool first) override
 
EmbAJAXElementtoElement () override final
 
- Public Member Functions inherited from EmbAJAXBase
void setVisible (bool visible)
 
void setEnabled (bool enabled)
 
virtual EmbAJAXElementfindChild (const char *id) const
 

Additional Inherited Members

- Static Public Member Functions inherited from EmbAJAXBase
static void setDriver (EmbAJAXOutputDriverBase *driver)
 
- Protected Member Functions inherited from EmbAJAXElement
void setBasicProperty (uint8_t num, bool status) override
 
bool basicProperty (uint8_t num) const
 
void setChanged ()
 
bool changed (uint16_t since)
 
void printTextInput (size_t size, const char *value) const
 
- Protected Member Functions inherited from EmbAJAXBase
void printChildren (EmbAJAXBase **children, size_t num) const
 
bool sendUpdates (EmbAJAXBase **children, size_t num, uint16_t since, bool first)
 
EmbAJAXElementfindChild (EmbAJAXBase **children, size_t num, const char *id) const
 
void printPage (EmbAJAXBase **children, size_t num, const char *_title, const char *_header, uint16_t _min_interval) const
 
void handleRequest (EmbAJAXBase **children, size_t num, void(*change_callback)())
 
- Protected Attributes inherited from EmbAJAXPushButton
void(* _callback )(EmbAJAXPushButton *)
 
const char * _label
 
- Protected Attributes inherited from EmbAJAXElement
byte _flags
 
const char * _id
 
- Static Protected Attributes inherited from EmbAJAXBase
static EmbAJAXOutputDriverBase_driver
 
static char itoa_buf [8]
 
constexpr static const char null_string [1]
 

Detailed Description

A momentary "press-and-hold" button.

This button will be return status()==Pressed while the button is actively held pressed in a client. While the button is pressed, the client will send continuous "pings" to the server. If a button press has been registered, but the latest ping has timed out, the status() will return MayBePressed, instead, so your code can take select an appropriate fallback behavior in case of unreliable connections (e.g. stopping an RC car).

Constructor & Destructor Documentation

◆ EmbAJAXMomentaryButton()

EmbAJAXMomentaryButton::EmbAJAXMomentaryButton ( const char *  id,
const char *  label,
uint16_t  timeout = 600,
void(*)(EmbAJAXPushButton *)  callback = 0 
)
Parameters
text
See also
setText(). HTML is allowed, here.
Parameters
ping_intervalWhile the button is pressed, the client will send "ping" messages every timeout/1.5 milliseconds. If no ping has been received within timeout, status() will return MaybePressed.
callbackCalled when the button was clicked or relased in the UI (with a pointer to the button as parameter) Not called, when a ping has timed out.

Member Function Documentation

◆ updateFromDriverArg()

void EmbAJAXMomentaryButton::updateFromDriverArg ( const char *  argname)
overridevirtual

override this in your derived class to allow updates to be propagated from client to server (if wanted). The implementation need not call setChanged().

Reimplemented from EmbAJAXPushButton.


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