From 5e1e8ad29aedf6334b7ae4a01b43a601e3e8bf4e Mon Sep 17 00:00:00 2001
From: Michael Ingraham <34340210+meingraham@users.noreply.github.com>
Date: Tue, 15 Oct 2019 16:30:16 -0400
Subject: [PATCH] >b Button State section
---
Scripting-Language.md | 26 +++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)
diff --git a/Scripting-Language.md b/Scripting-Language.md
index 6ef0b559..3384b3f1 100644
--- a/Scripting-Language.md
+++ b/Scripting-Language.md
@@ -19,11 +19,12 @@ These features are enabled by adding the following `#define` compiler directive
| Feature | Description |
| -- | -- |
USE_WEBSEND_RESPONSE | enable receiving the response of a [`WebSend`](Commands#websend) command (received in section E)
-USE_SCRIPT_JSON_EXPORT | enable `>J` section
-USE_SCRIPT_WEB_DISPLAY | enable `>W` section
+USE_SCRIPT_JSON_EXPORT | enable `>J` section (publish JSON payload on [TelePeriod](Commands#teleperiod))
+USE_SCRIPT_WEB_DISPLAY | enable `>W` section (modify web UI)
USE_SCRIPT_SUB_COMMAND | enables invoking named script subroutines via the Console or MQTT
-USE_SCRIPT_HUE | enable `>H` section
-USE_SCRIPT_STATUS | enable `>U` section
+USE_SCRIPT_HUE | enable `>H` section (Alexa Hue emulation)
+USE_SCRIPT_STATUS | enable `>U` section (receive JSON payloads)
+USE_BUTTON_EVENT | enable `>b` section (detect button state changes)
SUPPORT_MQTT_EVENT | enables support for subscribe unsubscribe
USE_TOUCH_BUTTONS | enable virtual touch button support with touch displays
USE_24C256 | enables use of 24C256 I2C EEPROM to expand script buffer (defaults to 4k)
@@ -33,7 +34,7 @@ SDCARD_DIR | enables support for web UI for SD card directory upload and downloa
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).
+The maximum script size is 1535 bytes (uses rule set buffers). If the pasted script is larger than 1535 characters, comments will be stripped to attempt to make the script fit.
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.
@@ -47,6 +48,7 @@ To save code space almost no error messages are provided. However it is taken ca
- `and` , `or` support
- Hexadecimal numbers with prefix `0x` are supported
- Strings support `+` and `+=` operators
+- Support for \\n \\r regular expressions on strings
- String comparison `==`, `!=`
- String size is 19 characters (default). This can be increased or decreased by the optional parameter on the `>D` section definition
@@ -81,7 +83,7 @@ To save code space almost no error messages are provided. However it is taken ca
Memory is dynamically allocated as a result of the D section.
Copying a string to a number or reverse is supported
->`>B`
+>`>B` _(note upper case)_
executed on BOOT time and on save script
>`>E`
@@ -113,6 +115,12 @@ lamp1,E,on=pwr1,hue=hue1,sat=sat1,bri=bri1,ct=ct1
>`>U`
status JSON Messages arrive here
+
+>`>b` _(note lower case)_
+executed on button state change
+`bt[x]` read button state (x = `1.. MAX_KEYS`)
+example:
+print button event =>\%bt[1]\%
>`>J`
The lines in this section are published via MQTT in a JSON payload on [TelePeriod](Commands#teleperiod). Requires compiling with `#define USE_SCRIPT_JSON_EXPORT `.
@@ -333,16 +341,16 @@ The script itself is also stored on the SD card with a default size of 4096 char
Enable SD card directory support (+ 1,2k flash)
`#define SDCARD_DIR`
-Shows a web SD card directory (submeu of scripter) where you can upload and download files to/from sd card
+Shows a web SD card directory (submenu of scripter) where you can upload and download files to/from sd card
`fr=fo("fname" m)` open file fname, mode 0=read, 1=write (returns file reference (0-3) or -1 for error)
`res=fw("text" fr)` writes text to (the end of) file fr, returns number of bytes written
-`res=fr(svar fr)` reads a string into svar, returns bytes read (string is read until delimiter \t \n \r or eof)
+`res=fr(svar fr)` reads a string into svar, returns bytes read. String is read until delimiter (\\t \\n \\r) or eof
`fc(fr)` close file
`ff(fr)` flush file, writes cached data and updates directory
`fd("fname")` delete file fname
`flx(fname)` create download link for file (x=1 or 2) fname = file name of file to download
-`fsm` return 1 if filesystem is mounted, (valid sd card found)
+`fsm` return 1 if filesystem is mounted, (valid SD card found)
**Extended commands** (+0,9k flash)
`#define USE_SCRIPT_FATFS_EXT`