Re-add syntax where missing and remove example if trivial

This commit is contained in:
Marcel Stör 2016-01-08 22:39:07 +01:00
parent 94f407a269
commit affa61ecd2
2 changed files with 105 additions and 84 deletions

View File

@ -9,8 +9,11 @@ The default setting in the NodeMCU firmware can be controlled via user_config.h
Samples the ADC.
####Syntax
`adc.read(channel)`
####Parameters
`channel` always zero on the ESP8266
`channel` always 0 on the ESP8266
####Returns
the sampled value (number)
@ -24,6 +27,9 @@ val = adc.read(0)
Reads the system voltage.
####Syntax
`adc.readvdd33()`
####Parameters
none
@ -31,8 +37,3 @@ none
system voltage in millivolts (number)
If the ESP8266 has been configured to use the ADC for sampling the external pin, this function will always return 65535. This is a hardware and/or SDK limitation.
####Example
```lua
mv = adc.readvdd33()
```

View File

@ -12,36 +12,35 @@ This is the raw code, not the new "reset info" code which was introduced in rece
- 3, hardware reset via reset pin
- 4, WDT reset (watchdog timeout)
#### Syntax
`node.bootreason()`
#### Parameters
none
#### Returns
the boot reason code (number)
####Example
```lua
rsn = node.bootreason()
```
## node.chipid()
Returns the ESP chip ID.
#### Syntax
`node.chipid()`
#### Parameters
none
#### Returns
chip ID (number)
####Example
```lua
id = node.chipid();
```
## node.compile()
Compiles a Lua text file into Lua bytecode, and saves it as .lc file.
#### Syntax
`node.compile("file.lua")`
#### Parameters
`filename` name of Lua text file
@ -71,6 +70,9 @@ Firmware from before 05 Jan 2016 have a maximum sleeptime of ~35 minutes.
This function can only be used in the condition that esp8266 PIN32(RST) and PIN8(XPD_DCDC aka GPIO16) are connected together. Using sleep(0) will set no wake up timer, connect a GPIO to pin RST, the chip will wake up by a falling-edge on pin RST.
#### Syntax
`node.dsleep(us, option)`
#### Parameters
- `us` number (integer) or `nil`, sleep time in micro second. If `us == 0`, it will sleep forever. If `us == nil`, will not set sleep time.
@ -101,36 +103,35 @@ node.dsleep(nil,4)
Returns the flash chip ID.
#### Syntax
`node.flashid()`
#### Parameters
none
#### Returns
flash ID (number)
####Example
```lua
flashid = node.flashid();
```
## node.heap()
Returns the current available heap size in bytes. Note that due to fragmentation, actual allocations of this size may not be possible.
#### Syntax
`node.heap()`
#### Parameters
none
#### Returns
system heap size left in bytes (number)
####Example
```lua
heap_size = node.heap();
```
## node.info()
Returns NodeMCU version, chipid, flashid, flash size, flash mode, flash speed.
#### Syntax
`node.info()`
#### Parameters
none
@ -158,6 +159,8 @@ Submits a string to the Lua interpreter. Similar to `pcall(loadstring(str))`, bu
This function only has an effect when invoked from a callback. Using it directly on the console **does not work**.
#### Syntax
`node.input(str)`
#### Parameters
`str` Lua chunk
@ -179,6 +182,9 @@ Defines action to take on button press (on the old devkit 0.9), button connected
This function is only available if the firmware was compiled with DEVKIT_VERSION_0_9 defined.
#### Syntax
`node.key(type, function())`
#### Parameters
- `type`: type is either string "long" or "short". long: press the key for 3 seconds, short: press shortly(less than 3 seconds)
- `function`: user defined function which is called when key is pressed. If nil, remove the user defined function. Default function: long: change LED blinking rate, short: reset chip
@ -199,8 +205,11 @@ Sets the on/off time for the LED (on the old devkit 0.9), with the LED connected
This function is only available if the firmware was compiled with DEVKIT_VERSION_0_9 defined.
#### Syntax
`node.led(low, high)`
#### Parameters
- `low` LED off time, LED keeps on when low=0. Unit: milliseconds, time resolution: 80~100ms<br />
- `low` LED off time, LED keeps on when low=0. Unit: milliseconds, time resolution: 80~100ms
- `high` LED on time. Unit: milliseconds, time resolution: 80~100ms
#### Returns
@ -211,6 +220,7 @@ This function is only available if the firmware was compiled with DEVKIT_VERSION
-- turn led on forever.
node.led(0)
```
#### See also
[`node.key()`](#nodekey-deprecated)
@ -222,6 +232,9 @@ Redirects the Lua interpreter output to a callback function. Optionally also pri
Do **not** attempt to `print()` or otherwise induce the Lua interpreter to produce output from within the callback function. Doing so results in infinite recursion, and leads to a watchdog-triggered restart.
#### Syntax
`node.output(function(str), serial_debug)`
#### Parameters
- `output_fn(str)` a function accept every output as str, and can send the output to a socket (or maybe a file).
- `serial_debug` 1 output also show in serial. 0: no serial output.
@ -267,23 +280,24 @@ Moved to [`adc.readvdd33()`](adc/#adcreadvdd33).
Restarts the chip.
#### Syntax
`node.restart()`
#### Parameters
none
#### Returns
`nil`
####Example
```lua
node.restart();
```
## node.restore()
Restores system configuration to defaults. Erases all stored WiFi settings, and resets the "esp init data" to the defaults. This function is intended as a last-resort without having to reflash the ESP altogether.
This also uses the SDK function `system_restore()`, which doesn't document precisely what it erases/restores.
#### Syntax
`node.restore()`
#### Parameters
none
@ -300,6 +314,9 @@ node.restart() -- ensure the restored settings take effect
Change the working CPU Frequency.
#### Syntax
`node.setcpufreq(speed)`
#### Parameters
`speed` constant 'node.CPU80MHZ' or 'node.CPU160MHZ'
@ -313,15 +330,18 @@ node.setcpufreq(node.CPU80MHZ)
## node.stripdebug()
Controls the amount of debug information kept during `node.compile()`, and allows removal of debug information from already compiled Lua code.
Controls the amount of debug information kept during [`node.compile()`](#nodecompile), and allows removal of debug information from already compiled Lua code.
Only recommended for advanced users, the NodeMCU defaults are fine for almost all use cases.
####Syntax
`node.stripdebug([level[, function]])`
#### Parameters
- `level`
- 1: don't discard debug info
- 2: discard Local and Upvalue debug info
- 3: discard Local, Upvalue and line-number debug info
- 1, don't discard debug info
- 2, discard Local and Upvalue debug info
- 3, discard Local, Upvalue and line-number debug info
- `function` a compiled function to be stripped per setfenv except 0 is not permitted.
If no arguments are given then the current default setting is returned. If function is omitted, this is the default setting for future compiles. The function argument uses the same rules as for `setfenv()`.