mirror of https://github.com/arendst/Tasmota.git
Updated Scripting Language (markdown)
parent
c3e1ef42c2
commit
ff01512d04
|
@ -14,7 +14,7 @@ To use, you must compile your own firmware. Add the following compiler directive
|
|||
|
||||
**Optional Features**
|
||||
|
||||
These features are enabled by adding the following `#define` compiler directive parameters and then compiling the firmware. These are explained further below in the article.
|
||||
These features are enabled by adding the following `#define` compiler directive parameters and then compiling the firmware. These parameters are explained further below in the article.
|
||||
|
||||
| Feature | Description |
|
||||
| -- | -- |
|
||||
|
@ -25,12 +25,11 @@ USE_24C256 | enables use of 24C256 i2c eeprom to expand script buffer (defaults
|
|||
SUPPORT_MQTT_EVENT | enables support for subscribe unsubscribe
|
||||
USE_TOUCH_BUTTONS | enable virtual touch button support with touch displays
|
||||
|
||||
|
||||
To enter a script, go to `Configuration` =\> `Edit script` in the Tasmota web UI menu
|
||||
<BR><BR>To enter a script, go to `Configuration` =\> `Edit script` in the Tasmota web UI menu
|
||||
|
||||
The maximum script size is 1535 bytes (uses rule set buffers).
|
||||
|
||||
Scripter Features
|
||||
<BR><BR>**Scripter Features**
|
||||
- Up to 50 variables (45 numeric and 5 strings, maybe changed by #define)
|
||||
- Freely definable variable names (all names are intentionally case sensitive)
|
||||
- Nested if,then,else up to a level of 8
|
||||
|
@ -46,7 +45,7 @@ Scripter Features
|
|||
- Hexadecimal numbers with prefix `0x` are supported
|
||||
- Strings support `+` and `+=` operators
|
||||
- String comparison `==`, `!=`
|
||||
- String size is 19 characters (default) This can be increased or decreased by optional `>D` parameter
|
||||
- String size is 19 characters (default). This can be increased or decreased by the optional parameter on the `>D` section definition
|
||||
- Comments start with `;`
|
||||
|
||||
**Script Sections**
|
||||
|
@ -136,7 +135,7 @@ The following variables are cleared after reading true:
|
|||
`wific` = true on wifi connect
|
||||
`wifid` = true on wifi disconnect
|
||||
|
||||
**System variables** (for debugging)
|
||||
**System variables** (for debugging)
|
||||
`stack` = stack size
|
||||
`heap` = heap size
|
||||
`ram` = used ram size
|
||||
|
@ -158,10 +157,10 @@ A single percent sign must be given as `%%`
|
|||
`=\> print` prints to info log for debugging
|
||||
|
||||
To save code space almost no error messages are provided. However it is taken care of that at least it should not crash on syntax errors.
|
||||
If a variable does not exist a **???** is given on commands
|
||||
If a variable does not exist, `???` is displayed for commands
|
||||
If a `SENSOR` or `STATUS` or `RESULT` message or a var does not exist the destination variable is NOT updated.
|
||||
|
||||
2 possibilities for conditionals:
|
||||
There are two syntax alternatives for conditional statements. You may **_NOT_** mix both methods.
|
||||
```
|
||||
if a==b
|
||||
and x==y
|
||||
|
@ -182,46 +181,45 @@ or k==i {
|
|||
=> do that
|
||||
}
|
||||
```
|
||||
|
||||
You may **_NOT_** mix both methods
|
||||
|
||||
Also possible e.g.
|
||||
|
||||
Calculations are permitted in conditional statements, e.g.,
|
||||
```
|
||||
if var1-var2==var3*var4
|
||||
then
|
||||
```
|
||||
|
||||
Remarks:
|
||||
The last closing bracket must be on a single line
|
||||
The last closing bracket must be on a single line
|
||||
The condition may not be enclosed in brackets
|
||||
|
||||
`break` exits a section or terminates a for next loop
|
||||
`break` exits a section or terminates a `for next` loop
|
||||
`dpx` sets decimal precision to x (0-9)
|
||||
`svars` save permanent vars
|
||||
`delay(x)` pauses x milliseconds (should be as short as possible)
|
||||
`spin(x m)` set gpio pin x (0-16) to value m (0,1) only the last bit is used, so even values set the pin to zero and uneven values set the pin to 1
|
||||
`spinm(x m)` set pin mode gpio pin x (0-16) to mode m (input=0,output=1,input with pullup=2)
|
||||
`ws2812(array)` copies an array (defined with m:name) to the WS2812 LED chain the array should be defined as long as the number of pixels. the color is coded as 24 bit RGB
|
||||
`spin(x b)` set GPIO pin value. `x` (0..16) to value `b` (0,1). Only bit 0 is used. Even values set the pin to zero and uneven values set the pin to 1
|
||||
`spinm(x m)` set GPIO pin mode. `x` (0..16) to mode `m` (input=0, output=1, input with pullup=2)
|
||||
`ws2812(array)` copies an array (defined with m:name) to the WS2812 LED chain
|
||||
The array should be defined as long as the number of pixels. the color is coded as 24 bit RGB
|
||||
|
||||
`#name` names a subroutine, subroutines are called with `=#name`
|
||||
`#name(param)` names a subroutines with a parameter is called with `=#name(param)`
|
||||
Subroutines end with the next `#` or `>` line or break, may be nested
|
||||
Parameters can be numbers or strings and on mismatch are converted
|
||||
|
||||
**For loop** (loop count must not be less than 1)
|
||||
```
|
||||
for var from to inc
|
||||
next
|
||||
```
|
||||
specifies a for next loop, (loop count must not be less than 1)
|
||||
|
||||
|
||||
**Switch selector** (numeric or string)
|
||||
```
|
||||
switch x
|
||||
case a
|
||||
case b
|
||||
ends
|
||||
```
|
||||
specifies a switch case selector (numeric or string)
|
||||
|
||||
|
||||
**SD Card Support** (+ 10k flash)
|
||||
`#define USE_SCRIPT_FATFS` `CARD_CS`
|
||||
`CARD_CS` = gpio pin of card chip select
|
||||
|
|
Loading…
Reference in New Issue