From 191d9d689fd709e51a2dec6075979bae0dfdb909 Mon Sep 17 00:00:00 2001 From: openshwprojects Date: Tue, 7 Mar 2023 12:42:37 +0100 Subject: [PATCH] docs formatting --- docs/README.md | 2 +- docs/json/generic.json | 2 +- docs/scriptExamples.md | 28 ++++++++++++++++++++-------- scripts/getcommands.js | 6 ++++-- 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/docs/README.md b/docs/README.md index 9c4d68991..397deee2d 100644 --- a/docs/README.md +++ b/docs/README.md @@ -14,5 +14,5 @@ Do not add anything here, as it will overwritten with next rebuild. | [Console/Script commands](https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/commands.md) (225 total) | There are multiple console commands that allow you to automate your devices. Commands can be entered manually in command line, can be send by HTTP (just like in Tasmota), can be send by MQTT and also can be scripted. | | [Command Examples](https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/commandExamples.md) (6 total) | Here you can find some examples of console commands usage | | [Autoexec.bat examples (configs)](https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/autoexecExamples.md) (7 total) | Here you can find examples of autoexec.bat configs. The autoexec.bat file can be created in Web Application, under LittleFS tab, and is run every time device reboots (unless device enters safe mode/AP mode). The autoexec.bat file allows you to create more advanced configs, setup TuyaMCU mappings, etc | -| [Script examples](https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/scriptExamples.md) (4 total) | Scripts can be put in autoexec.bat and then they will start automatically on reboot, you can also put script in other file and use startScript command to run them. | +| [Script examples](https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/scriptExamples.md) (4 total) | Scripts can be put in autoexec.bat and then they will start automatically on reboot, you can also put script in other LittleFS file and use startScript [fileName] [Label] command to run them. From the firmware point of view, scripts and autoexecs are basically the same thing. There is, however, a little bit more advananced system of execution for scripts which can be written in a form of scripts threads that run over time, can have delays within then, conditional checks and jumps. | | [Console/Script commands [Extended Edition]](https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/commands-extended.md) (225 total) | More details on commands. | diff --git a/docs/json/generic.json b/docs/json/generic.json index dde7d9b18..55ec099ce 100644 --- a/docs/json/generic.json +++ b/docs/json/generic.json @@ -8,5 +8,5 @@ "faq": "Here is a detailed list of questions you may ask. Some information from docs is repeated here.", "commandExamples":"Here you can find some examples of console commands usage", "autoexecExamples":"Here you can find examples of autoexec.bat configs. The autoexec.bat file can be created in Web Application, under LittleFS tab, and is run every time device reboots (unless device enters safe mode/AP mode). The autoexec.bat file allows you to create more advanced configs, setup TuyaMCU mappings, etc", - "scriptExamples":"Scripts can be put in autoexec.bat and then they will start automatically on reboot, you can also put script in other file and use startScript command to run them." + "scriptExamples":"Scripts can be put in autoexec.bat and then they will start automatically on reboot, you can also put script in other LittleFS file and use startScript [fileName] [Label] command to run them. From the firmware point of view, scripts and autoexecs are basically the same thing. There is, however, a little bit more advananced system of execution for scripts which can be written in a form of scripts threads that run over time, can have delays within then, conditional checks and jumps." } \ No newline at end of file diff --git a/docs/scriptExamples.md b/docs/scriptExamples.md index 45066a563..60a906422 100644 --- a/docs/scriptExamples.md +++ b/docs/scriptExamples.md @@ -1,9 +1,11 @@ # Example script files -Loop demo +Loop demo
Features a 'goto' script command (for use within script) and, obviously, a label. -
Requirements:
-channel 1 - output relay
+
Requirements:
+- channel 1 - output relay
+ ```again: echo "Step 1" setChannel 1 0 @@ -17,9 +19,12 @@ Loop demo ``` -Loop & if demo +Loop & if demo
This example shows how you can use a dummy channel as a variable to create a loop -
Requirements:
-channel 1 - output relay
-channel 11 - loop variable counter
+
Requirements:
+- channel 1 - output relay
+- channel 11 - loop variable counter
+ ```restart: // Channel 11 is a counter variable and starts at 0 setChannel 11 0 @@ -45,9 +50,13 @@ done: ``` -Thread cancelation demo and exclude self demo +Thread cancelation demo and exclude self demo
This example shows how you can create a script thread with an unique ID and use this ID to cancel the thread later -
Requirements:
-channel 1 - output relay
-pin 8 - button
-pin 9 - button
+
Requirements:
+- channel 1 - output relay
+- pin 8 - button
+- pin 9 - button
+ ```// 'this' is a special keyword - it mean search for script/label in this file // 123 and 456 are unique script thread names addEventHandler OnClick 8 startScript this label1 123 @@ -94,9 +103,12 @@ label2: ``` -Using channel value as a variable demo +Using channel value as a variable demo
-
Requirements:
-channel 1 - output relay
-channel 11 - you may use it as ADC, or just use setChannel 11 100 or setChannel 11 500 in console to change delay
+
Requirements:
+- channel 1 - output relay
+- channel 11 - you may use it as ADC, or just use setChannel 11 100 or setChannel 11 500 in console to change delay
+ ``` // set default value setChannel 11 500 diff --git a/scripts/getcommands.js b/scripts/getcommands.js index 1ec5e8004..794780126 100644 --- a/scripts/getcommands.js +++ b/scripts/getcommands.js @@ -819,15 +819,17 @@ for (let i = 0; i < scriptExamples.length; i++) { let scr = scriptExamples[i]; - scriptsmdshort += "" + scr.title + ""; + scriptsmdshort += "" + scr.title + ""; scriptsmdshort += '\n'; scriptsmdshort += '
'; scriptsmdshort += "" + scr.description + ""; scriptsmdshort += '\n'; scriptsmdshort += '
'; scriptsmdshort += 'Requirements:
'; + scriptsmdshort += '\n'; for (let j = 0; j < scr.requirements.length; j++) { - scriptsmdshort += '-' + scr.requirements[j]+'
'; + scriptsmdshort += '- ' + scr.requirements[j] + '
'; + scriptsmdshort += '\n'; } scriptsmdshort += '\n'; scriptsmdshort += "```";