Update for v0.9.8 documentation

pull/57/head
Hieromon Ikasamo 6 years ago
parent 6422b7b4ba
commit 2ab227e6c1
  1. 35
      mkdocs/acelements.md
  2. 33
      mkdocs/acjson.md
  3. 13
      mkdocs/apielements.md
  4. 10
      mkdocs/changelog.md
  5. BIN
      mkdocs/images/acfile.png
  6. 2
      mkdocs/index.md

@ -72,7 +72,21 @@ The enumerators for *ACElement_t* are as follows:
- AutoConnectText: **AC_Text** - AutoConnectText: **AC_Text**
- Uninitialized element: **AC_Unknown** - Uninitialized element: **AC_Unknown**
Furthermore, to convert an entity that is not an AutoConnectElement to its native type, you must [re-interpret](https://en.cppreference.com/w/cpp/language/reinterpret_cast) that type with c++. Furthermore, to convert an entity that is not an AutoConnectElement to its native type, you must [re-interpret](https://en.cppreference.com/w/cpp/language/reinterpret_cast) that type with c++. Or, you can be coding the sketch more easily with using the [**as<T\>**](apielements.md#ast62) function.
```cpp hl_lines="6"
AutoConnectAux customPage;
AutoConnectElementVT& elements = customPage.getElements();
for (AutoConnectElement& elm : elements) {
if (elm.type() == AC_Text) {
AutoConnectText& text = customPage[elm.name].as<AutoConnectText>();
text.style = "color:gray;";
// Or, it is also possible to write the code further reduced as follows.
// customPage[elm.name].as<AutoConnectText>().style = "color:gray;";
}
}
```
## AutoConnectButton ## AutoConnectButton
@ -151,10 +165,10 @@ A checked is a Boolean value and indicates the checked status of the checkbox. T
## AutoConnectFile ## AutoConnectFile
AutoConnectFile generates asn HTML `#!html <input type="file">` tag and a `#!html <label>` tag. AutoConnectFile generates asn HTML `#!html <input type="file">` tag and a `#!html <label>` tag. AutoConnectFile enables file upload from the client through the web browser to ESP8266/ESP32 module. You can select the flash in the module, external SD device or any output destination as the storage of the uploaded file.
<i class="fa fa-eye"></i> **Sample**<br> <i class="fa fa-eye"></i> **Sample**<br>
<small>**`AutoConnectFile file("file", "", "Upload", AC_File_FS)`**</small> <small>**`AutoConnectFile file("file", "", "Upload:", AC_File_FS)`**</small>
<small>On the page:</small><br><img src="images/acfile.png"> <small>On the page:</small><br><img src="images/acfile.png">
@ -166,12 +180,27 @@ AutoConnectFile(const char* name, const char* value, const char* label, const AC
### <i class="fa fa-caret-right"></i> name ### <i class="fa fa-caret-right"></i> name
It is the `name` of the AutoConnectFile element and matches the name attribute of the input tag. It also becomes the parameter name of the query string when submitted.
### <i class="fa fa-caret-right"></i> value ### <i class="fa fa-caret-right"></i> value
File name to be upload. The value contains the value entered by the client browser to the `#!html <input type="file">` tag and is read-only. Even If you give a value to the constructor, it does not affect as an initial value like a default file name.
### <i class="fa fa-caret-right"></i> label ### <i class="fa fa-caret-right"></i> label
A `label` is an optional string. A label is always arranged on the left side of the input box. Specification of a label will generate an HTML `#!html <label>` tag with an id attribute. The input box and the label are connected by the id attribute.
### <i class="fa fa-caret-right"></i> store ### <i class="fa fa-caret-right"></i> store
Specifies the destination to save the uploaded file. The destination can be specified the following values in the *ACFile_t* enumeration type.
- AC_File_FS: Save as the SPIFFS file in flash of ESP8266/ESP32 module.
- AC_File_SD: Save to an external SD device connected to ESP8266/ESP32 module.
- AC_File_Ext: Pass the content of the uploaded file to the uploader which is declared by the sketch individually. Its uploader must inherit **AutoConnectUploadHandler** class and implements *_open*, *_write* and *_close* function.
!!! note "Built-in uploader is ready."
AutoConnect already equips the built-in uploader for saving to the SPIFFS as AC_File_FS and the external SD as AC_File_SD. It is already implemented inside AutoConnect and will store uploaded file automatically.
## AutoConnectInput ## AutoConnectInput
AutoConnectInput generates an HTML `#!html <input type="text">` tag and a `#!html <label>` tag. It can also have a placeholder. The value of the input box is passed to the destination in the query string and can be retrieved programmatically. You can also update from the sketches. AutoConnectInput generates an HTML `#!html <input type="text">` tag and a `#!html <label>` tag. It can also have a placeholder. The value of the input box is passed to the destination in the query string and can be retrieved programmatically. You can also update from the sketches.

@ -144,6 +144,12 @@ This is different for each AutoConnectElements, and the key that can be specifie
: - **value** : Specifies the source code of generating HTML. The value is native HTML code and is output as HTML as it is. : - **value** : Specifies the source code of generating HTML. The value is native HTML code and is output as HTML as it is.
#### <i class="fa fa-caret-right"></i> ACFile #### <i class="fa fa-caret-right"></i> ACFile
: - **value** : The file name of the upload file will be stored. The `value` is read-only and will be ignored if specified.
: - **label** : Specifies a label of the file selection box. Its placement is always to the left of the file selection box.
: - **store** : Specifies the destination to save the uploaded file. Its value accepts one of the following:<p>
<b>fs</b>&nbsp;: Save as the SPIFFS file in flash of ESP8266/ESP32 module.<br>
<b>sd</b>&nbsp;: Save to an external SD device connected to ESP8266/ESP32 module.<br>
<b>ext</b>&nbsp;: Pass the content of the uploaded file to the uploader which is declared by the sketch individually. Its uploader must inherit **AutoConnectUploadHandler** class and implements *_open*, *_write* and *_close* function.</p>
#### <i class="fa fa-caret-right"></i> ACInput #### <i class="fa fa-caret-right"></i> ACInput
: - **value** : Specifies the initial text string of the input box. If this value is omitted, placeholder is displayed as the initial string. : - **value** : Specifies the initial text string of the input box. If this value is omitted, placeholder is displayed as the initial string.
@ -170,12 +176,15 @@ This is different for each AutoConnectElements, and the key that can be specifie
#### <i class="fa fa-caret-right"></i> ACText #### <i class="fa fa-caret-right"></i> ACText
: - **value** : Specifies a content and also can contain the native HTML code, but remember that your written code is enclosed by the div tag. : - **value** : Specifies a content and also can contain the native HTML code, but remember that your written code is enclosed by the div tag.
: - **style** : Specifies the qualification style to give to the content and can use the style attribute format as it is. : - **style** : Specifies the qualification style to give to the content and can use the style attribute format as it is.
: - **format** : Specifies how to interpret the value. It specifies the conversion format when outputting values. The format string conforms to the C-style printf library functions, but depends on the espressif sdk implementation. The conversion specification is valid only for **%s** format. (Left and Right justification, width are also valid.)
!!! caution "AutoConnect's JSON parsing process is not perfect" !!! caution "AutoConnect's JSON parsing process is not perfect"
It is based on analysis by ArduinoJson, but the semantic analysis is simplified to save memory. Consequently, it is not an error that a custom Web page JSON document to have unnecessary keys. It will be ignored. It is based on analysis by ArduinoJson, but the semantic analysis is simplified to save memory. Consequently, it is not an error that a custom Web page JSON document to have unnecessary keys. It will be ignored.
## Loading JSON document ## Loading JSON document
### <i class="fa fa-caret-right"></i> Loading from the streamed file
AutoConnect supports loading of JSON document from the following instances: AutoConnect supports loading of JSON document from the following instances:
- String - String
@ -226,6 +235,30 @@ aux.close();
AutoConnect passes the given JSON document directly to the [**parseObject()**](https://arduinojson.org/v5/api/jsonbuffer/parseobject/) function of the ArduinoJson library for parsing. Therefore, the constraint of the parseObject() function is applied as it is in the parsing of the JSON document for the AutoConnect. That is, if the JSON string is read-only, duplicating the input string occurs and consumes more memory. AutoConnect passes the given JSON document directly to the [**parseObject()**](https://arduinojson.org/v5/api/jsonbuffer/parseobject/) function of the ArduinoJson library for parsing. Therefore, the constraint of the parseObject() function is applied as it is in the parsing of the JSON document for the AutoConnect. That is, if the JSON string is read-only, duplicating the input string occurs and consumes more memory.
### <i class="fa fa-caret-right"></i> Adjust the JSON document buffer size
AutoConnect uses ArduinoJson library's dynamic buffer to parse JSON documents. Its dynamic buffer allocation scheme depends on the version 5 or version 6 of ArduinoJson library. Either version must have enough buffer to parse the custom web page's JSON document successfully. AutoConnect has the following three constants internally to complete the parsing as much as possible in both ArduinoJson version. These constants are macro defined in [AutoConnectDefs.h](https://github.com/Hieromon/AutoConnect/blob/master/src/AutoConnectDefs.h).
If memory insufficiency occurs during JSON document parsing, you can adjust these constants to avoid insufficiency by using the [JsonAssistant](https://arduinojson.org/v6/assistant/) with deriving the required buffer size in advance.
```cpp
#define AUTOCONNECT_JSONBUFFER_SIZE 256
#define AUTOCONNECT_JSONDOCUMENT_SIZE (8 * 1024)
#define AUTOCONNECT_JSONPSRAM_SIZE (16* 1024)
```
#### AUTOCONNECT_JSONBUFFER_SIZE
This is a unit size constant of [DynamicJsonBuffer](https://arduinojson.org/v5/faq/what-are-the-differences-between-staticjsonbuffer-and-dynamicjsonbuffer/) and works when the library used is ArduinoJson version 5. A buffer size of the JSON document increases with this unit. This value relates to the impact of the fragmented heap area. If it is too large, may occur run-out of memory.
#### AUTOCONNECT_JSONDOCUMENT_SIZE
This is a size of [DynamicJsonDocument](https://arduinojson.org/v6/api/dynamicjsondocument/) for ArduinoJson version 6. This buffer is not automatically expanding, and the size determines the limit.
#### AUTOCONNECT_JSONPSRAM_SIZE
For ESP32 module equips with PSRAM, you can allocate the JSON document buffer to PSRAM. Buffer allocation to PSRAM will enable when **PSRAM:Enabled** option selected in the Arduino IDE's Board Manager menu. It is available since ArduinoJson 6.10.0.
## Saving JSON document ## Saving JSON document
The sketch can persist AutoConnectElements as a JSON document and also uses [this function](achandling.md#saving-autoconnectelements-with-json) to save the values entered on the custom Web page. And you can reload the saved JSON document into AutoConnectElements as the field in a custom Web page using the [load function](achandling.md#loading-autoconnectaux-autoconnectelements-with-json). The sketch can persist AutoConnectElements as a JSON document and also uses [this function](achandling.md#saving-autoconnectelements-with-json) to save the values entered on the custom Web page. And you can reload the saved JSON document into AutoConnectElements as the field in a custom Web page using the [load function](achandling.md#loading-autoconnectaux-autoconnectelements-with-json).

@ -200,7 +200,7 @@ The element name.
#### <i class="fa fa-caret-right"></i> value #### <i class="fa fa-caret-right"></i> value
File name to be upload. This attribute is read only. File name to be upload. The value contains the value entered by the client browser to the `#!html <input type="file">` tag and is read-only.
<dl class="apidl"> <dl class="apidl">
<dt>**Type**</dt> <dt>**Type**</dt>
<dd><span class="apidef">String</span><span class="apidesc"></span></dd> <dd><span class="apidef">String</span><span class="apidesc"></span></dd>
@ -640,13 +640,14 @@ Returns type of AutoConnectElement.
### <i class="fa fa-code"></i> Constructor ### <i class="fa fa-code"></i> Constructor
```cpp ```cpp
AutoConnectText(const char* name = "", const char* value = "", const char* style = "") AutoConnectText(const char* name = "", const char* value = "", const char* style = "", const char* format = "")
``` ```
<dl class="apidl"> <dl class="apidl">
<dt>**Parameters**</dt> <dt>**Parameters**</dt>
<dd><span class="apidef">name</span><span class="apidesc">The element name.</span></dd> <dd><span class="apidef">name</span><span class="apidesc">The element name.</span></dd>
<dd><span class="apidef">value</span><span class="apidesc">String of content for the text element.</span></dd> <dd><span class="apidef">value</span><span class="apidesc">String of content for the text element.</span></dd>
<dd><span class="apidef">style</span><span class="apidesc">A style code with CSS format that qualifiers the text.</span></dd> <dd><span class="apidef">style</span><span class="apidesc">A style code with CSS format that qualifiers the text.</span></dd>
<dd><span class="apidef">format</span><span class="apidesc">A pointer to a null-terminated multibyte string specifying how to interpret the value. It specifies the conversion format when outputting values. The format string conforms to C-style printf library functions</span></dd>
</dl> </dl>
### <i class="fa fa-code"></i> Public member variables ### <i class="fa fa-code"></i> Public member variables
@ -675,6 +676,14 @@ A style code with CSS format that qualifiers the text.
<dd><span class="apidef">String</span><span class="apidesc"></span></dd> <dd><span class="apidef">String</span><span class="apidesc"></span></dd>
</dl> </dl>
#### <i class="fa fa-caret-right"></i> format
The conversion format when outputting values. The format string conforms to C-style printf library functions.
<dl class="apidl">
<dt>**Type**</dt>
<dd><span class="apidef">String</span><span class="apidesc"></span></dd>
</dl>
### <i class="fa fa-code"></i> Public member functions ### <i class="fa fa-code"></i> Public member functions
#### <i class="fa fa-caret-right"></i> typeOf #### <i class="fa fa-caret-right"></i> typeOf

@ -1,3 +1,13 @@
#### [0.9.8] Apr. 25, 2019
- Supports ArduinoJson 6.9.1 or later.
- Supports allocating JsonDocument buffer to PSRAM on ESP32 with ArduinoJson 6.10.0 or later.
- Supports [**operator`[]`**](apiaux.md#operator) as a shortcut for AutoConnectAux::getElement function.
- Supports [**AutoConnectElement::as<T\>**](apielements.md#ast62) function to easily coding for conversion from an AutoConnectElement to an actual type.
- Supports new element type [**AutoConnectFile**](acelements.md#autoconnectfile) and built-in file uploader.
- Supports a [**format attribute**](acelements.md#format) with the AutoConnectText element.
- Fixed blank page responds with Configure new.
- Changed menu labels placement in source files structure.
#### [0.9.7] Jan. 25, 2019 #### [0.9.7] Jan. 25, 2019
- Fixed crash in some environments. Thank you @ageurtse - Fixed crash in some environments. Thank you @ageurtse

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

@ -92,7 +92,7 @@ To install the PageBuilder library into your Arduino IDE, you can use the *Libra
<i class="fa fa-download"></i> <strong>Additional library (Optional)</strong> <i class="fa fa-download"></i> <strong>Additional library (Optional)</strong>
By adding the [ArduinoJson](https://github.com/bblanchon/ArduinoJson) library, AutoConnect will be able to handle the [**custom Web pages**](acintro.md) described with JSON. With AutoConnect v0.9.7 you can insert user-owned web pages that can consist of representative HTML elements as styled TEXT, INPUT, BUTTON, CHECKBOX, SELECT, SUBMIT and invoke them from the AutoConnect menu. These HTML elements can be added by sketches using the AutoConnect API. Further it possible importing the custom Web pages declarations described with JSON which stored in PROGMEM, SPIFFS, or SD. [ArduinoJson](https://arduinojson.org/) is required to use this feature.[^2] AutoConnect can work with ArduinoJson both [version 5](https://arduinojson.org/v5/doc/) and [version 6](https://arduinojson.org/v6/doc/). By adding the [ArduinoJson](https://github.com/bblanchon/ArduinoJson) library, AutoConnect will be able to handle the [**custom Web pages**](acintro.md) described with JSON. Since AutoConnect v0.9.7 you can insert user-owned web pages that can consist of representative HTML elements as styled TEXT, INPUT, BUTTON, CHECKBOX, SELECT, SUBMIT and invoke them from the AutoConnect menu. These HTML elements can be added by sketches using the AutoConnect API. Further it possible importing the custom Web pages declarations described with JSON which stored in PROGMEM, SPIFFS, or SD. [ArduinoJson](https://arduinojson.org/) is required to use this feature.[^2] AutoConnect can work with ArduinoJson both [version 5](https://arduinojson.org/v5/doc/) and [version 6](https://arduinojson.org/v6/doc/).
[^2]:Using the AutoConnect API natively allows you to sketch custom Web pages without JSON. [^2]:Using the AutoConnect API natively allows you to sketch custom Web pages without JSON.
### Install the AutoConnect ### Install the AutoConnect

Loading…
Cancel
Save