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).
|
A push-button. More...
#include <EmbAJAX.h>
Public Member Functions | |
EmbAJAXPushButton (const char *id, const char *label, void(*callback)(EmbAJAXPushButton *)) | |
void | print () const override |
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 |
void | updateFromDriverArg (const char *argname) override |
Public Member Functions inherited from EmbAJAXElement | |
EmbAJAXElement (const char *id) | |
const char * | id () const |
bool | sendUpdates (uint16_t since, bool first) override |
EmbAJAXElement * | toElement () override final |
Public Member Functions inherited from EmbAJAXBase | |
void | setVisible (bool visible) |
void | setEnabled (bool enabled) |
virtual EmbAJAXElement * | findChild (const char *id) const |
Protected Attributes | |
void(* | _callback )(EmbAJAXPushButton *) |
const char * | _label |
Protected Attributes inherited from EmbAJAXElement | |
byte | _flags |
const char * | _id |
Additional Inherited Members | |
Public Types inherited from EmbAJAXBase | |
enum | Property { Visibility , Enabledness , Value , FirstElementSpecificProperty , HTMLAllowed } |
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) |
EmbAJAXElement * | findChild (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)()) |
Static Protected Attributes inherited from EmbAJAXBase | |
static EmbAJAXOutputDriverBase * | _driver |
static char | itoa_buf [8] |
constexpr static const char | null_string [1] |
A push-button.
When clicked a custom callback function will be called on the server.
EmbAJAXPushButton::EmbAJAXPushButton | ( | const char * | id, |
const char * | label, | ||
void(*)(EmbAJAXPushButton *) | callback | ||
) |
label |
callback | Called when the button was clicked in the UI (with a pointer to the button as parameter) |
void EmbAJAXPushButton::setText | ( | const char * | label, |
bool | allowHTML = false |
||
) |
Change the button text
value | Note: The string is not copied, so don't make this a temporary. |
allowHTML | if true, you can set the text to any valid HTML string, which allows for much flexibility, but is not safe when value is untrusted user input. if false (the default), any "<" and "&" in value will be escaped, before rendering on the client, making the string plain but safe. |
|
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 EmbAJAXElement.
Reimplemented in EmbAJAXMomentaryButton.
|
overridevirtual |
const char representation of the current server side value. Must be implemented in derived class. This base class handles visibility and enabledness, only. Do call the base implementation for any "which" that is not handled in your derived class.
Reimplemented from EmbAJAXElement.
|
overridevirtual |
Returns true, if the value may contain HTML, and needs HTML escaping when passed to the client. Base implementation simply returns false.
Reimplemented from EmbAJAXElement.
|
overridevirtual |
The JS property that will have to be set on the client. Must be implemented in derived class. This base class handles visibility and enabledness, only. Do call the base implementation for any "which" that is not handled in your derived class.
Reimplemented from EmbAJAXElement.