Skip to content

Commit 92e8e08

Browse files
committed
english readme
1 parent 1907cf0 commit 92e8e08

File tree

1 file changed

+141
-28
lines changed

1 file changed

+141
-28
lines changed

README_EN.md

Lines changed: 141 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ This is an automatic translation, may be incorrect in some places. See sources a
22

33
# Settings
44
Library for creating a simple settings web interface on ESP8266/ESP32
5-
- The web application weighs only 7 kb and is sewn to the program in the binary gzip form, no fuss with files
5+
- The web application weighs about 10 kb and is sewn to the program in the binary gzip form without the forth with files
66
- Comfortable builder control panel from sketch
77
- A dozen typical widgets with the possibility of unification into groups and nested menu
8+
- system of authorization with different rights for authorized users and guests
9+
- file manager and OTA (air update)
810
- Integration with the library [gyverdb] (https://github.com/gyverlibs/gyverdb) for fully automatic data storage
911
- Compact binary communication protocol
1012
- Easily adapts to any HTTP server library, three versions are implemented from the box: Gyverhttp, standard ESP-WEBSERVER, ESPASYNCWEBSERVER
@@ -16,11 +18,11 @@ Library for creating a simple settings web interface on ESP8266/ESP32
1618
ESP8266, ESP32
1719

1820
### Dependencies
19-
- gtl v1.0.11+
20-
- gyverdb v1.0.6+
21-
- Stringutils v1.4.23+
22-
- Gyverhttp v1.0.11+
23-
- Gson v1.5.6+
21+
- gtl v1.1.1+
22+
- gyverdb v1.1.2+
23+
- Stringutils v1.4.24+
24+
- Gyverhttp v1.0.17+
25+
- Gson v1.5.9+
2426

2527
<details>
2628
<summary> platformio.ini </summary>
@@ -69,11 +71,14 @@ Board_Build.filesystem = Littlefs
6971
<a id="usage"> </a>
7072

7173
## Usage
72-
### How it works
74+
### how it works
7375
The web server is configured in the library, which sends webmord files when entering the IP board.Webmord files are sewn in the Progmem (to the program code) in binary form - you do not need to upload files to FS, everything works out of the box.A light html file is loaded each time, and scripts and styles are cramped by a browser to speed up loading.In fact, they are loaded once after updating the library.Webmord is a web application that communicates with the HTTP board.When loading, it requests a package with widgets and other information at the board, the package has a binary json format.
7476

75-
### Database
76-
The library is integrated with [gyverdb] (https://github.com/gyverlibs/gyverdb) - a relatively quick database for storing data from any type.Settings automatically reads and updates the data in the database, so it is recommended to study how to work with the database on the description page Gyverdb.When using Gyverdbfile, the database will automatically write to the file with changes, and the file system will take care of the optimal wear of the Flash memory.When starting, it is recommended to initialize the database by indicating the keys and the corresponding initial values ​​and types.These values ​​will be recorded only in thatCranberry, if the recording in the database does not yet exist.At the same time, the automatic renewal of the database works only for existing records, i.e.Settings will only work with nourishing cells and will not create new ones.Minimum example:
77+
## Captive Portal
78+
In all three server implementations, the DNS is configured to work as Captive Portal - if the ESP operates in access point (AP or AP_STA), then when connecting to the point, the browser window with the settings page will automatically open.
79+
80+
### database
81+
The library is integrated with [gyverdb] (https://github.com/gyverlibs/gyverdb) - a relatively quick database for storing data from any type.Settings automatically reads and updates the data in the database, soCranberries are mental to study how to work with a database on the description page Gyverdb.When using Gyverdbfile, the database will automatically write to the file with changes, and the file system will take care of the optimal wear of the Flash memory.When starting, it is recommended to initialize the database by indicating the keys and the corresponding initial values ​​and types.These values ​​will be recorded only if the recording in the database does not yet exist.At the same time, the automatic renewal of the database works only for existing records, i.e.Settings will only work with nourishing cells and will not create new ones.Minimum example:
7782
`` `CPP
7883
// connect libraries and create databases and settings
7984
#include <gyverdbfile.h>
@@ -133,8 +138,10 @@ sett.tick ();
133138
}
134139
`` `
135140

136-
## Mayer
137-
The package is assembled by a build in a builder - a function in a program that is called when a request from webmord comes.Inside the builder, you need to call the components in the order in which they should be in webmord.Calling the component adds information about it to the package.At this stage, the value is also reading for the widget according to its ID from the database, if it is connected and the value is not indicated clearly.
141+
## biller
142+
The package is assembled by a build in a builder - a function in a program that is called when a request from webmord comes.Inside the builder, you need to call the components in the order in which they should be in webmord.Calling the component adds information about it to the package.At this stage, the value is also reading for the widget according to its ID from the database, if it is connected and *the value is not indicated explicitly *.
143+
144+
> If you need the parameter to be read from the database, but you need to specify the argument after it - the value must be specified `Text ()` as it is made in the default function.For example, color for Label `B.Label (Key," Label! ", Text (), sets :: colors :: Mint);`.If you specify an empty line (`B.Label (Key," Label! "," ", Sets :: colors :: Mint);`) - an empty line will go as a value, i.e.The value is not from the database.
138145
139146
`` `CPP
140147
Gyverdb DB;
@@ -175,8 +182,8 @@ Serial.println (B.Build (). Value ());
175182
`` `
176183

177184
### containers
178-
Widgets can be combined into containers.The container must be started and finished, since the data package is assembled linearly in order to optimize speed and memory.The Begin Container method will always return True for the beauty of the organization of code in the Condition block:
179-
`` `CPP
185+
Widgets can be combined into containers.The container must be started and finished, since the data package is assembled linearly in order to optimize speed and memory.The `begin -stagnant method will always return True for the beauty of the organization of code in the conditions:
186+
```CPP
180187
VOID Build (Sets :: Builder & B) {
181188
if (B.Begingroup ("Group 1")) {
182189
B.INPUT ("Input1" _H, "text");
@@ -199,7 +206,8 @@ B.INPUT ("Input1" _H, "text");
199206

200207
You can create an invested menu.The specified title will be displayed on the button and in the page heading at the entrance to the menu.All widgets and groups located in the block with the menu will be on a separate page.The nuclearment of the menu is unlimited.
201208
`` `CPP
202-
VOID Build (Sets :: Builder & B) {B.Input ("Input1" _H, "Text 1");
209+
VOID Build (Sets :: Builder & B) {
210+
B.INPUT ("Input1" _H, "Text 1");
203211

204212
{
205213
sets :: menu g (b, "submenu");
@@ -236,7 +244,7 @@ B.Label ("LBL2" _H, "Millis ()", "", sets :: colors :: RED);
236244
}
237245
VOID update (Sets :: Updater & Upd) {
238246
UPD.UPDATE ("LBL1" _H, RANDOM (100));
239-
upd.update ("lbl2" _h, millis ());
247+
UPD.UPDATE ("LBL2" _H, Millis ());
240248
}
241249

242250
VOID setup () {
@@ -248,16 +256,50 @@ sett.onupdate (update);
248256

249257
Webmord monitors the status of the device, with a communication loss, the Offline text will appear in the page title.After losing the connection, webmord will request information about widgets, this is very convenient when developing - for example, add a widget, load the firmware.During this time, webmord already understands that the device is offline and with the first successful connection, it displays relevant widgets.When changing the values ​​of webmord widgets, he also monitors the delivery of the package, when the communication error will appear the inscription error in the corresponding widget.
250258

259+
### Authorization
260+
The system provides for authorization: if in the firmware, indicate the password different from the empty line - webmord will work in the “guest” mode: only widgets allowed to guests are displayed, the file manager and OTA are hidden and blocked.To enter the password, you need to go to the menu (right upper button) and press on the key.The gray key means that the authorization is disabled, the green is authorized, red - the wrong password.The password can contain any characters and have any length - in explicitly it is not stored and not transmitted.The password is stored in the browser and the authorization works automatically when the page reloads.
261+
262+
The Guest virtual container is provided for the separation of admin and guest access.If the password is installed and the client is not authorized, he will only see widgets from guest containers.For the correct operation, the guest container should not be interrupted by conventional containers.Example:
263+
264+
`` `CPP
265+
if (B.Begingroup ("Group 1")) {
266+
// Guests do not see
267+
b.pass (kk :: pass, "password");
268+
269+
// Widgets that guests and admins see
270+
{
271+
Sets :: Guestaccess G (b);
272+
B.Input (kk :: uintw, "uint");
273+
B.INPUT (KK :: Intw,Cranberries "int");
274+
B.INPUT (KK :: int64W, "int 64");
275+
}
276+
277+
// Guests do not see
278+
{
279+
Sets :: Menu M (b, "subject sub");
280+
B.Label (kk :: lbl2, "millis ()", "", sets :: colors :: red);
281+
}
282+
283+
B.EndGroup ();
284+
}
285+
`` `
286+
In the guest container, you can place several ordinary containers, such as groups.
287+
251288
## description of classes
252-
- `settingsbase` (*settingsbase.h*) - base class without a web server
253289
- `settingsgyver` (*settingsgyver.h*) - on the webcerver Gyverhttp
254-
- `settingSesp` (*settingSesp.h*) - on the standard ESP webcierver (DNS works correctly here)
290+
- `settingSesp` (*settingSesp.h*) - on the standard ESP webcierver
255291
- `settingsasync` (*settingsasync.h*) - on asynchronous Espasyncwebserver
256292

257293
## settingsbase/settingsgyver/settingSesp/settingsasync
258294
`` `CPP
259295
Settings (const string & title = "", gyverdb* db = nullptr);
260296

297+
// Install the password on the webmord.Empty line "" to turn off
298+
Void setpass (Text Pass);
299+
300+
// Reload page.Can be called anywhere + in the update processor
301+
VOID RELOAD ();
302+
261303
// Install page title
262304
VOID settitle (Constation String & Title);
263305

@@ -285,46 +327,111 @@ VOID Tick ();
285327
// Info about build
286328
Build Build ();
287329

288-
// Reload page
330+
// Reload page (call in action)
289331
VOID RELOAD ();
290332

291333
// containers
334+
// allow unauthorized customers the following code
335+
Bool Betinguest ();
336+
337+
// prohibit non -authorized customers
338+
VOID Enguest ();
339+
340+
// group
292341
Bool BeginGroup (Text Title = Text ());
293342
VOID EndGroup ();
294343

344+
// Bethered menu
295345
Bool Beginmenu (Text Title);
296346
VOID ENDMENU ();
297347

348+
// Row buttons
298349
Bool Beginbuttons ();
299350
VOID Endbuttons ();
300351

301-
// Passive widgets
352+
// Widgets
353+
// Passive
354+
// multi -line text
302355
VOID Paragraph (Size_T ID, Text Label, Text Text = Text ());
356+
357+
// Text value
303358
Void Label (Size_T ID, Text Label, Text Text = Text (), Uint32_T Color = Sets_default_color);
304359
Void Label (Size_t ID, Text Label, Text Text, Sets :: Colors Color);
305360

306-
// Active widgets
361+
// without ID
362+
Void Label (Text Label, Text Text = Text (), Uint32_t Color = Sets_default_color);
363+
Void Label (Text Label, Text Text, Sets :: Colors Color);
364+
365+
// LED (turned on - green, turned off - red)
366+
VOID LED (SIZE_T ID, Text Label, Bool Value);
367+
VOID LED (Text Label, Bool Value);
368+
369+
// Active
370+
// Entering text and numbers
307371
Bool Input (Size_T ID, Text Label, Text Value = Text ());
372+
373+
// Password entering
374+
// you can install a "plug" for a password, for example "***" so that the password does not display in the browser
308375
Bool Pass (Size_T ID, Text Label, Text Value = Text ());
376+
377+
// Input of color, the result in the usual 24-bit format
309378
Bool Color (Size_T ID, Text Label, Text Value = Text ());
379+
380+
// switch, result 1/0
310381
Bool Switch (Size_T ID, Text Label, Text Value = Text ());
382+
383+
// Date, result in unix seconds
311384
Bool Date (Size_T ID, Text Label, Text Value = Text ());
312-
Bool Time (Size_T ID, Text Label, Text Value = Text ());
385+
386+
// Date and time, result in UNIX seconds
313387
Bool DateTime (Size_T ID, Text Label, Text Value = Text ());
314-
Bool Slider (Size_T ID, Text Label, Float Min =0, Float Max = 100, Float Step = 1, Text Unit = Text (), Text Value = Text ());
388+
389+
// Time, result in seconds from the beginning of the day
390+
Bool Time (Size_T ID, Text Label, Text Value = Text ());
391+
392+
// Slider
393+
Bool Slider (Size_t ID, Text Label, Float Min = 0, Float Max = 100, Float Step = 1, Text Unit = Text (), Text Value = Text ());
315394

316395
// button can be added both inside the buttons container, and as a single widget
317396
Bool Button (Size_T ID, Text Label, Uint32_T Color = Sets_default_color);
318397
Bool Button (Size_T ID, Text Label, Sets :: Colors Color);
319398

320-
// options are divided;
399+
// list of choice, options in the form of text are separated;
321400
Bool Select (Size_T ID, Text Label, Text Options, Text Value = Text ());
322401

323-
// For activation, send an empty update to its ID
402+
// Confirmation window, for activation, send an empty update to its ID
324403
Bool Confirm (Size_T ID, Text Label);
325404
`` `
326405

327-
Here `Text` is a universal text format, takes lines in any form.When indicating `value`, its value will be sent different from the standard.Otherwise, the value from the database will be sent if it is connected.If you need the value of the number - use the `value` designer, for example` B.color ("color", "color", value (my_color)); `where` my_color` is `uint32_t`.
406+
Here `Text` is a universal text format, takes lines in any form.When indicating `value`, its value will be sent different from the standard.Otherwise, the value from the database will be sent if it is connected.If you need a value as a value - use the constructor `vaLue`, for example `B.color (" color "," color ", value (my_color));` where `my_color` is` uint32_t`.
407+
408+
### Build
409+
Info about build
410+
`` `CPP
411+
// Client is authorized (or password is not indicated, i.e. all admins)
412+
Bool ISGranted ();
413+
414+
// ID widget (action)
415+
size_t id ();
416+
417+
// Widget value (action)
418+
Text & Value ();
419+
`` `
420+
421+
### containers
422+
`` `CPP
423+
// Guest access container
424+
Class guestaccess (Builder & B);
425+
426+
// Container group of widgets
427+
Class Group (Builder & B, Text Title = Text ());
428+
429+
// container of an invested menu
430+
Class Menu (Builder & B, Text Title);
431+
432+
// Container buttons
433+
Class Buttons (Builder & B);
434+
`` `
328435

329436
## updater
330437
`` `CPP
@@ -337,8 +444,8 @@ VOID update (Size_T ID, Text Value);
337444
// update with Float
338445
VOID update (Size_t ID, Float Value, Uint8_t Dec = 2);
339446

340-
// update with the number
341-
VOID update (size_t ID, <Any numerical type> value);
447+
// Update with the number
448+
VOID update (Size_T ID, <Any numerical type> value);
342449
`` `
343450

344451
<a id="versions"> </a>
@@ -348,6 +455,12 @@ VOID update (size_t ID, <Any numerical type> value);
348455
- V1.0.2
349456
- Added a confirm widget (a pop -up confirmation window)
350457
- custom pop -up windows for Input (Input now works on a view of AP wifi points on Xiaomi)
458+
- V1.0.5
459+
- Added LED widget
460+
- Added file manager
461+
- Added Ot Update
462+
- Added authorization and guest filter of widgets
463+
- New style for Select
351464

352465
<a id="install"> </a>
353466
## Installation
@@ -379,4 +492,4 @@ When reporting about bugs or incorrect work of the library, it is necessary to i
379492
- version of Arduino ide
380493
- whether the built -in examples work correctly, in which the functions and designs are used, leading to a bug in your code
381494
- what code has been loaded, what work was expected from it and how it works in reality
382-
- Ideally, attach the minimum code in which the bug is observed.Not a canvas of thousands of lines, but the minimum code
495+
- Ideally, attach the minimum code in which the bug is observed.Not a canvas of a thousand lines, but a minimum code

0 commit comments

Comments
 (0)