You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+16-10Lines changed: 16 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
Multi-platform library for controlling html elements in a esp webpages at runtime using web sockets.
3
3
4
4
## 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**.
6
6
7
7
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.
-`ctrl.put("html_id", value); // Set a default value to be send`
74
74
75
75
+ 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
+
```
80
86
81
87
+ If you want to use a global callback function to handle key changes
82
88
- `ctrl.setGlobalCallback(globalChangeFuncion);`
@@ -97,7 +103,7 @@ Controlling your elements inside you loop function
97
103
98
104
+ Handle changes inside your code with a handler function
99
105
- `void globalChangeFuncion(uint8_t ndx){ String key = ctrl[ndx].key; int val = ctrl[ndx].val.toInt() }`
100
-
106
+
101
107
+ Inside your main loop() call ControlAssist loop() to handle web sockets server clients
102
108
- `ctrl.loop();`
103
109
@@ -120,7 +126,7 @@ See example ``ControlAssist-Gauge.ino``
120
126
</p>
121
127
122
128
## 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**
0 commit comments