1
0
mirror of https://github.com/s00500/ESPUI.git synced 2024-11-22 09:10:54 +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:**
- ArduinoJSON 6.10.0 Support
- ArduinoJSON 6.10.0 Support
- 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
- Better returnvalues
- Min Max on slider
- Accelerometer Widget
- Cleanup Example
- New Documentation
- Numberfield
- Textfield
- Data directory
- Graph Usage
- Accelerometer
- Slider
- OptionList
- Tab usage
## Dependencies

View File

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