Correction to doc about new setWebLogCallback()

Correcting closing P tag
This commit is contained in:
Francois 2023-10-29 13:44:33 -04:00
parent b41bb653dc
commit ac765e70ff
1 changed files with 9 additions and 9 deletions

View File

@ -86,23 +86,23 @@ Note that HomeSpan outputs the full content of the Web Log HTML, including whate
Homespan provides a hook into the text used to generate the Web Log that you can extend to add your own data to the initial table as well as more generally add any custom HTML.
To access this text, set a Web Log callback using `homeSpan.setWebLogCallback(void (*func)(String &htmlText))` where
To access this text, set a Web Log callback using `homeSpan.setWebLogCallback(String (*func)())` where
* *func* is a function of type *void* that takes a single argument of type *String*, and
* *htmlText* will be set by HomeSpan to a String reference containing all the HTML text that the Web Log has already generated to produce the initial table.
* *func* is a function returning a *String* that takes no argument.
* The string returned will be appended by HomeSpan to the bottom of the initial table.
To add your own data to the table, simply extend the String *htmlText* by adding as many `<tr>` and `<td>` HTML tags as needed. If you wish to end the table and add any other HTML, simple include the `</table>` tag in *htmlText*, and then add any other custom HTML. For example, the following function could be used to extend the initial Web Log table to show free DRAM, end the table, and provide a hot link to the HomeSpan Repo:
To add your own data to the table, simply have your callback function return a String variable by adding as many `<tr>` and `<td>` HTML tags as needed. Ensure to include the `</table>` tag in your callback to terminate the table. You can then add any other custom HTML. For example, the following function could be used to extend the initial Web Log table to show free DRAM, end the table, and provide a hot link to the HomeSpan Repo:
```C++
void extraData(String &r){
String extraWebData(){
String r = "";
r+="<tr><td>Free DRAM:</td><td>" + String(esp_get_free_internal_heap_size()) + " bytes</td></tr>\n";
r+="</table><p><a href=\"https://github.com/HomeSpan/HomeSpan\">Click Here to Access HomeSpan Repo</a><p>";
r+="</table><p><a href=\"https://github.com/HomeSpan/HomeSpan\">Click Here to Access HomeSpan Repo</a></p>";
return r;
}
```
To embed this custom HTML text in the Web Log, call `homeSpan.setWebLogCallback(extraWebData)` in your sketch.
Note that *r* is being passed as a reference and already includes all the HTML text the Web Log has produced to set up the page and create the initial table. You should therefore *extend* this String using `+=`. Do not simple assign this variable to a new String with `=` or you will overwrite all the HTML already produced!
To embed this custom HTML text in the Web Log, call `homeSpan.setWebLogCallback(&extraWebData)` in your sketch.
---