1
0
mirror of https://github.com/s00500/ESPUI.git synced 2024-12-23 05:50:49 +00:00

IDs are uint16_t, removed not used member ESPUIClass::cIndex

This commit is contained in:
Christian Riggenbach 2019-03-03 21:53:59 +01:00
parent 6c8f113861
commit acce17b82c
2 changed files with 22 additions and 20 deletions

View File

@ -432,7 +432,7 @@ int ESPUIClass::text( const char* label, void ( *callback )( Control, int ),
}
Control* ESPUIClass::getControl( int id ) {
Control* ESPUIClass::getControl( uint16_t id ) {
Control* control = this->controls;
while ( control != nullptr ) {
@ -501,7 +501,7 @@ void ESPUIClass::updateControl( Control* control, String value, int clientId ) {
}
}
}
void ESPUIClass::updateControl( int id, String value, int clientId ) {
void ESPUIClass::updateControl( uint16_t id, String value, int clientId ) {
Control* control = getControl( id );
if ( control ) {
@ -526,7 +526,7 @@ void ESPUIClass::updateControl( String label, String value, int clientId ) {
void ESPUIClass::print( int id, String value ) {
void ESPUIClass::print( uint16_t id, String value ) {
updateControl( id, value );
}
@ -534,7 +534,7 @@ void ESPUIClass::print( String label, String value ) {
updateControl( label, value );
}
void ESPUIClass::updateLabel( int id, String value ) {
void ESPUIClass::updateLabel( uint16_t id, String value ) {
updateControl( id, value );
}
@ -542,7 +542,7 @@ void ESPUIClass::updateLabel( String label, String value ) {
updateControl( label, value );
}
void ESPUIClass::updateSlider( int id, int nValue, int clientId ) {
void ESPUIClass::updateSlider( uint16_t id, int nValue, int clientId ) {
updateControl( id, String( nValue ), clientId );
}
@ -550,7 +550,7 @@ void ESPUIClass::updateSlider( String label, int nValue, int clientId ) {
updateControl( label, String( nValue ), clientId );
}
void ESPUIClass::updateSwitcher( int id, bool nValue, int clientId ) {
void ESPUIClass::updateSwitcher( uint16_t id, bool nValue, int clientId ) {
updateControl( id, String( int( nValue ? 1 : 0 ) ), clientId );
}
@ -558,7 +558,7 @@ void ESPUIClass::updateSwitcher( String label, bool nValue, int clientId ) {
updateControl( label, String( int( nValue ? 1 : 0 ) ), clientId );
}
void ESPUIClass::updateNumber( int id, int number, int clientId ) {
void ESPUIClass::updateNumber( uint16_t id, int number, int clientId ) {
updateControl( id, String( number ), clientId );
}
@ -566,7 +566,7 @@ void ESPUIClass::updateNumber( String label, int number, int clientId ) {
updateControl( label, String( number ), clientId );
}
void ESPUIClass::updateText( int id, String text, int clientId ) {
void ESPUIClass::updateText( uint16_t id, String text, int clientId ) {
updateControl( id, text, clientId );
}

View File

@ -103,11 +103,14 @@ enum ControlColor : uint8_t {
class Control {
public:
ControlType type;
unsigned int id; // just mirroring the id here for practical reasons
uint16_t id; // just mirroring the id here for practical reasons
const char* label;
void ( *callback )( Control, int );
String value;
ControlColor color;
Control* next;
Control(
@ -201,43 +204,42 @@ class ESPUIClass {
// Update Elements
Control* getControl( int id );
Control* getControl( uint16_t id );
Control* getControl( String label );
// Update Elements
void updateControl( int id, String value, int clientId = -1 );
void updateControl( uint16_t id, String value, int clientId = -1 );
void updateControl( String label, String value, int clientId = -1 );
void updateControl( Control* control, String value, int clientId = -1 );
void print( int id, String value );
void print( uint16_t id, String value );
void print( String label, String value );
void updateLabel( int id, String value );
void updateLabel( uint16_t id, String value );
void updateLabel( String label, String value );
void updateSwitcher( int id, bool nValue, int clientId = -1 );
void updateSwitcher( uint16_t id, bool nValue, int clientId = -1 );
void updateSwitcher( String label, bool nValue, int clientId = -1 );
void updateSlider( int id, int nValue, int clientId = -1 );
void updateSlider( uint16_t id, int nValue, int clientId = -1 );
void updateSlider( String label, int nValue, int clientId = -1 );
void updateNumber( int id, int nValue, int clientId = -1 );
void updateNumber( uint16_t id, int nValue, int clientId = -1 );
void updateNumber( String label, int nValue, int clientId = -1 );
void updateText( int id, String nValue, int clientId = -1 );
void updateText( uint16_t id, String nValue, int clientId = -1 );
void updateText( String label, String nValue, int clientId = -1 );
void clearGraph( int id, int clientId = -1 );
void clearGraph( uint16_t id, int clientId = -1 );
void clearGraph( String label, int clientId = -1 );
void addGraphPoint( int id, int nValue, int clientId = -1 );
void addGraphPoint( uint16_t id, int nValue, int clientId = -1 );
void addGraphPoint( String label, int nValue, int clientId = -1 );
// void textThem( String text, int clientId = -1 );
// Variables ---
const char* ui_title = "ESPUI"; // Store UI Title and Header Name
int cIndex = 0; // Control index
Control* controls = nullptr;
void jsonDom( AsyncWebSocketClient* client );