1
0
mirror of https://github.com/s00500/ESPUI.git synced 2024-11-26 00:21:27 +00:00

Cleanup and reformat header

- Construct inside library
- Adds setVerbosity
This commit is contained in:
Lukas Bachschwell 2019-03-24 16:06:35 +01:00
parent b9a087c169
commit 63b6761044
3 changed files with 143 additions and 123 deletions

View File

@ -24,14 +24,26 @@ THIS IS THE 2.0.0 development branch
**Roadmap for 2.0.0:** **Roadmap for 2.0.0:**
- ArduinoJSON 6.10.0 Support - ArduinoJSON 6.10.0 Support
- Tabs by engerlingi ISSUE #45 - Tabs by engerlingi ISSUE #45
- remove black line without tabs
- API changes by engerlingi
- less updateCotrol functions
- proper wrappers for all create/update actions
- OptionList by engerlingi - OptionList by engerlingi
- Better returnvalues - Better returnvalues
- Min Max on slider - Min Max on slider
- Accelerometer Widget - Accelerometer Widget
- Cleanup Example - Cleanup Example
- New Documentation - New Documentation
- Numberfield
- Textfield
- Data directory
- Graph Usage
- Accelerometer
- Slider
- OptionList
- Tab usage
## Dependencies ## Dependencies

View File

@ -838,3 +838,7 @@ void ESPUIClass::begin(const char* _title, const char* username,
Serial.println("UI Initialized"); Serial.println("UI Initialized");
} }
} }
void ESPUIClass::setVerbosity(Verbosity v) { this->verbosity = v; }
ESPUIClass ESPUI;

View File

@ -131,26 +131,33 @@ class Control {
static constexpr uint16_t noParent = 0xffff; static constexpr uint16_t noParent = 0xffff;
Control( Control(ControlType type, const char* label, void (*callback)(Control*, int),
ControlType type, const char* label, String value, ControlColor color,
void ( *callback )( Control*, int ), uint16_t parentControl = Control::noParent)
String value, ControlColor color, uint16_t parentControl = Control::noParent ) : type(type),
: type( type ), label( label ), callback( callback ), value( value ), color( color ), parentControl( parentControl ), next( nullptr ) { label(label),
callback(callback),
value(value),
color(color),
parentControl(parentControl),
next(nullptr) {
id = idCounter++; id = idCounter++;
// Serial.print( "Control id: " );
// Serial.println( id );
} }
Control(const Control& control) Control(const Control& control)
: type( control.type ), id( control.id ), label( control.label ), : type(control.type),
callback( control.callback ), value( control.value ), id(control.id),
color( control.color ), parentControl( control.parentControl ), next( control.next ) {} label(control.label),
callback(control.callback),
value(control.value),
color(control.color),
parentControl(control.parentControl),
next(control.next) {}
private: private:
static uint16_t idCounter; static uint16_t idCounter;
}; };
// Values // Values
#define B_DOWN -1 #define B_DOWN -1
#define B_UP 1 #define B_UP 1
@ -174,22 +181,20 @@ class Control {
#define T_VALUE 10 #define T_VALUE 10
#define S_VALUE 11 #define S_VALUE 11
enum Verbosity : uint8_t { enum Verbosity : uint8_t { Quiet = 0, Verbose, VerboseJSON };
Quiet = 0,
Verbose,
VerboseJSON
};
class ESPUIClass { class ESPUIClass {
public: public:
ESPUIClass( Verbosity verbosity = Verbosity::Quiet ) ESPUIClass() { verbosity = Verbosity::Quiet; }
: verbosity( verbosity ) {}
// void begin( const char* _title, bool enableDebug=false ); // Setup servers and page in Memorymode void setVerbosity(Verbosity verbosity);
void begin( const char* _title, const char* username = nullptr, const char* password = nullptr ); // Setup server and page in Memorymode
void begin(const char* _title, const char* username = nullptr,
const char* password = nullptr);
// void beginSPIFFS( const char* _title, bool enableDebug=false ); // Setup servers and page in SPIFFSmode // Setup server and page in SPIFFSmode
void beginSPIFFS( const char* _title, const char* username = nullptr, const char* password = nullptr ); void beginSPIFFS(const char* _title, const char* username = nullptr,
const char* password = nullptr);
void prepareFileSystem(); // Initially preps the filesystem and loads a lot void prepareFileSystem(); // Initially preps the filesystem and loads a lot
// of stuff into SPIFFS // of stuff into SPIFFS
@ -197,30 +202,31 @@ class ESPUIClass {
// Creating Elements // Creating Elements
uint16_t addControl(ControlType type, const char* label, uint16_t addControl(ControlType type, const char* label,
String value = String( "" ), ControlColor color = ControlColor::Turquoise, String value = String(""),
uint16_t parentControl = Control::noParent, void ( *callback )( Control*, int ) = nullptr ); ControlColor color = ControlColor::Turquoise,
uint16_t parentControl = Control::noParent,
void (*callback)(Control*, int) = nullptr);
int button( const char* label, int button(const char* label, void (*callback)(Control*, int),
void ( *callback )( Control*, int ), ControlColor color, ControlColor color,
String value = ""); // Create Event Button String value = ""); // Create Event Button
int switcher(const char* label, bool startState, int switcher(const char* label, bool startState,
void (*callback)(Control*, int), void (*callback)(Control*, int),
ControlColor color); // Create Toggle Button ControlColor color); // Create Toggle Button
int pad( const char* label, bool centerButton, int pad(const char* label, bool centerButton, void (*callback)(Control*, int),
void ( *callback )( Control*, int ),
ControlColor color); // Create Pad Control ControlColor color); // Create Pad Control
int slider( const char* label, int slider(const char* label, void (*callback)(Control*, int),
void ( *callback )( Control*, int ),
ControlColor color, String value); // Create Slider Control ControlColor color, String value); // Create Slider Control
int number( const char* label, int number(const char* label, void (*callback)(Control*, int),
void ( *callback )( Control*, int ), ControlColor color, int number, int min,
ControlColor color, int number, int min, int max ); // Create a Number Input Control int max); // Create a Number Input Control
int text( const char* label, int text(const char* label, void (*callback)(Control*, int),
void ( *callback )( Control*, int ), ControlColor color,
ControlColor color, String value = "" ); // Create a Text Input Control String value = ""); // Create a Text Input Control
// Output only // Output only
int label( const char* label, ControlColor color, String value = "" ); // Create Label int label(const char* label, ControlColor color,
String value = ""); // Create Label
int graph(const char* label, ControlColor color); // Create Graph display int graph(const char* label, ControlColor color); // Create Graph display
// Update Elements // Update Elements
@ -230,6 +236,7 @@ class ESPUIClass {
// Update Elements // Update Elements
void updateControl(uint16_t id, String value, int clientId = -1); void updateControl(uint16_t id, String value, int clientId = -1);
void updateControl(Control* control, String value, int clientId = -1); void updateControl(Control* control, String value, int clientId = -1);
void updateControl(uint16_t id, int clientId = -1); void updateControl(uint16_t id, int clientId = -1);
void updateControl(Control* control, int clientId = -1); void updateControl(Control* control, int clientId = -1);
@ -251,8 +258,6 @@ class ESPUIClass {
void addGraphPoint(uint16_t id, int nValue, int clientId = -1); void addGraphPoint(uint16_t id, int nValue, int clientId = -1);
// void textThem( String text, int clientId = -1 );
// Variables --- // Variables ---
const char* ui_title = "ESPUI"; // Store UI Title and Header Name const char* ui_title = "ESPUI"; // Store UI Title and Header Name
Control* controls = nullptr; Control* controls = nullptr;
@ -270,4 +275,3 @@ class ESPUIClass {
extern ESPUIClass ESPUI; extern ESPUIClass ESPUI;
#endif #endif