1
0
mirror of https://github.com/s00500/ESPUI.git synced 2025-07-04 21:30:19 +00:00

Changed signature of the callback

Call the callback with a pointer instead of a copy of the Control.
Changed all the examples
This commit is contained in:
Christian Riggenbach
2019-03-04 20:49:18 +01:00
parent 2b31e81f50
commit 3c42b43fe6
5 changed files with 197 additions and 153 deletions

View File

@ -110,17 +110,18 @@ class Control {
ControlType type;
uint16_t id; // just mirroring the id here for practical reasons
const char* label;
void ( *callback )( Control, int );
void ( *callback )( Control*, int );
String value;
ControlColor color;
uint16_t parentControl;
Control* next;
static constexpr uint16_t noParent = 0xffff;
Control(
ControlType type, const char* label,
void ( *callback )( Control, int ),
String value, ControlColor color, uint16_t parentControl = 0xffff )
void ( *callback )( Control*, int ),
String value, ControlColor color, uint16_t parentControl = Control::noParent )
: type( type ), label( label ), callback( callback ), value( value ), color( color ), parentControl(parentControl), next( nullptr ) {
id = idCounter++;
}
@ -181,25 +182,25 @@ class ESPUIClass {
uint16_t addControl( ControlType type, const char* label,
String value = String( "" ), ControlColor color = ControlColor::Turquoise,
void ( *callback )( Control, int ) = nullptr, uint16_t parentControl = 0xffff );
uint16_t parentControl = Control::noParent, void ( *callback )( Control*, int ) = nullptr );
int button( const char* label,
void ( *callback )( Control, int ), ControlColor color,
void ( *callback )( Control*, int ), ControlColor color,
String value = "" ); // Create Event Button
int switcher( const char* label, bool startState,
void ( *callback )( Control, int ),
void ( *callback )( Control*, int ),
ControlColor color ); // Create Toggle Button
int pad( const char* label, bool centerButton,
void ( *callback )( Control, int ),
void ( *callback )( Control*, int ),
ControlColor color ); // Create Pad Control
int slider( const char* label,
void ( *callback )( Control, int ),
void ( *callback )( Control*, int ),
ControlColor color, String value ); // Create Slider Control
int number( const char* label,
void ( *callback )( Control, int ),
void ( *callback )( Control*, int ),
ControlColor color, int number, int min, int max ); // Create a Number Input Control
int text( const char* label,
void ( *callback )( Control, int ),
void ( *callback )( Control*, int ),
ControlColor color, String value = "" ); // Create a Text Input Control
// Output only