Skip to content

Commit 592e10e

Browse files
author
gemi254
committed
Updated v1.1.3
1 parent 258395d commit 592e10e

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

README.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Multi-platform library for controlling html elements in a esp webpages at runtime using web sockets.
33

44
## Description
5-
A library allowing linking **html elements** to **sketch variables** on pages hosted on **esp32/esp8266** devices. It uses a **web socket server** on the esp **device** and a JavaScript **web socket client** implementation on the web **page** allowing bi-directional real-time communication between **device** and **page**.
5+
A library allowing linking **html elements** to **sketch variables** on pages hosted on **esp32/esp8266** devices. It uses a **web socket server** on the esp **device** and a JavaScript **web socket client** implementation on the web **page** allowing bi-directional real-time communication between **device** and **page**.
66

77
In a typical webpage, html **elements** like ``input box``, ``textbox``, ``range``, ``checkbox`` can be **binded** with ControlAssist internal variables using their unique **html ids** in order to associate their values. A **vectors** list will be generated to hold all associated element keys and their values.
88

@@ -38,7 +38,7 @@ PROGMEM const char HTML_FOOTER[] = R"=====(</htmll>)=====";
3838
You can also upload page html code sections to spiffs as a html files
3939

4040
## ControlAssist init functions
41-
Define and initialize you class
41+
Define and initialize you class
4242
+ include the **ControlAssist** class
4343
- `#include <ControlAssist.h> //ControlAssist class`
4444

@@ -60,23 +60,29 @@ Define and initialize you class
6060
- `ctrl.setHtmlHeadersFile(HTML_HEADERS_FILENAME);`
6161
- `ctrl.setHtmlBodyFile(HTML_BODY_FILENAME);`
6262
- `ctrl.setHtmlFooterFile(HTML_SCRIPT_FILENAME);`
63-
63+
6464
See example <a href="examples/ControlAssist-ESPVisualizer">ControlAssist-ESPVisualizer</a>
6565

6666
+ in your setup you must bind the html elements you want to control.
6767
- `ctrl.bind("html_id");` to link the html element
6868
- `ctrl.bind("html_id", start_value );` if you need to bind and init for sending on connection
6969
- `ctrl.bind("html_id", start_value, changeFunction);` if you need also to handle changes
70-
70+
7171
+ in your setup specify if you want ot auto send key initial values during web socket connection.
7272
- `ctrl.setAutoSendOnCon("html_id",true /* send: enable/disable */);`
7373
- `ctrl.put("html_id", value); // Set a default value to be send`
7474

7575
+ Configure web server to handle control assist page on a uri
76-
- ` ctrl.setup(server, "/"); // Add a web server handler on url "/"`
77-
78-
+ Or define a custom web server handler to host your webpage
79-
- `void handleRoot(){ ctrl.sendHtml(server); }`
76+
- ``` // Setup webserver
77+
server.on("/", []() {
78+
server.setContentLength(CONTENT_LENGTH_UNKNOWN);
79+
String res = "";
80+
res.reserve(CTRLASSIST_STREAM_CHUNKSIZE);
81+
while( ctrl.getHtmlChunk(res)){
82+
server.sendContent(res);
83+
}
84+
});
85+
```
8086
8187
+ If you want to use a global callback function to handle key changes
8288
- `ctrl.setGlobalCallback(globalChangeFuncion);`
@@ -97,7 +103,7 @@ Controlling your elements inside you loop function
97103
98104
+ Handle changes inside your code with a handler function
99105
- `void globalChangeFuncion(uint8_t ndx){ String key = ctrl[ndx].key; int val = ctrl[ndx].val.toInt() }`
100-
106+
101107
+ Inside your main loop() call ControlAssist loop() to handle web sockets server clients
102108
- `ctrl.loop();`
103109
@@ -120,7 +126,7 @@ See example ``ControlAssist-Gauge.ino``
120126
</p>
121127
122128
## Logging and debugging with log level
123-
In you application you use **LOG_E**, **LOG_W**, **LOG_I**, **LOG_D** macros instead of **Serial.prinf** to print your messages. **ControlAssist** displays these messages with **timestamps**
129+
In you application you use **LOG_E**, **LOG_W**, **LOG_I**, **LOG_D** macros instead of **Serial.prinf** to print your messages. **ControlAssist** displays these messages with **timestamps**
124130
125131
You can define log level for each module
126132
```#define LOGGER_LOG_LEVEL 4```

0 commit comments

Comments
 (0)