mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-07-28 04:07:47 +00:00
[Rules] Introduce commands Inc and Dec, update documentation
This commit is contained in:
@@ -112,6 +112,14 @@
|
||||
|
||||
``Debug,<1-4>``"
|
||||
"
|
||||
Dec","
|
||||
:red:`Internal`","
|
||||
Decrement the value of variable n (1..INT_MAX) by 1 or an optional value.
|
||||
|
||||
``Dec,<n>[,<value>]`` (``value`` = 1 by default)
|
||||
|
||||
See also ``Let`` and ``Inc``."
|
||||
"
|
||||
DeepSleep","
|
||||
:red:`Internal`","
|
||||
Switch the node to deep sleep.
|
||||
@@ -191,6 +199,14 @@
|
||||
|
||||
"
|
||||
"
|
||||
Inc","
|
||||
:red:`Internal`","
|
||||
Increment the value of variable n (1..INT_MAX) by 1 or an optional value.
|
||||
|
||||
``Inc,<n>[,<value>]`` (``value`` = 1 by default)
|
||||
|
||||
See also ``Let`` and ``Dec``."
|
||||
"
|
||||
IP","
|
||||
:red:`Internal`","
|
||||
Get or set IP address
|
||||
@@ -203,9 +219,11 @@
|
||||
"
|
||||
Let","
|
||||
:red:`Internal`","
|
||||
Set the value of n (1..16).
|
||||
Set the value of variable n (1..INT_MAX).
|
||||
|
||||
``Let,<n>,<value>``"
|
||||
``Let,<n>,<value>``
|
||||
|
||||
See also ``Inc`` and ``Dec``."
|
||||
"
|
||||
Load","
|
||||
:red:`Internal`","
|
||||
|
||||
@@ -284,6 +284,7 @@ bool executeInternalCommand(command_case_data & data)
|
||||
case 'd': {
|
||||
COMMAND_CASE_R( "datetime", Command_DateTime, 2); // Time.h
|
||||
COMMAND_CASE_R( "debug", Command_Debug, 1); // Diagnostic.h
|
||||
COMMAND_CASE_A( "dec", Command_Rules_Dec, -1); // Rules.h
|
||||
COMMAND_CASE_R("deepsleep", Command_System_deepSleep, 1); // System.h
|
||||
COMMAND_CASE_R( "delay", Command_Delay, 1); // Timers.h
|
||||
COMMAND_CASE_R( "dns", Command_DNS, 1); // Network Command
|
||||
@@ -318,6 +319,7 @@ bool executeInternalCommand(command_case_data & data)
|
||||
}
|
||||
case 'i': {
|
||||
COMMAND_CASE_R("i2cscanner", Command_i2c_Scanner, -1); // i2c.h
|
||||
COMMAND_CASE_A( "inc", Command_Rules_Inc, -1); // Rules.h
|
||||
COMMAND_CASE_R( "ip", Command_IP, 1); // Network Command
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -85,3 +85,28 @@ const __FlashStringHelper * Command_Rules_Let(struct EventStruct *event, const c
|
||||
}
|
||||
return return_command_failed();
|
||||
}
|
||||
|
||||
const __FlashStringHelper * Command_Rules_IncDec(struct EventStruct *event, const char *Line, const double factor)
|
||||
{
|
||||
String TmpStr1;
|
||||
double result = 1.0;
|
||||
|
||||
if (GetArgv(Line, TmpStr1, 3) && isError(Calculate(TmpStr1, result))) {
|
||||
return return_command_failed();
|
||||
}
|
||||
if (event->Par1 >= 0) {
|
||||
setCustomFloatVar(event->Par1, getCustomFloatVar(event->Par1) + (result * factor));
|
||||
return return_command_success();
|
||||
}
|
||||
return return_command_failed();
|
||||
}
|
||||
|
||||
const __FlashStringHelper * Command_Rules_Inc(struct EventStruct *event, const char *Line)
|
||||
{
|
||||
return Command_Rules_IncDec(event, Line, 1.0);
|
||||
}
|
||||
|
||||
const __FlashStringHelper * Command_Rules_Dec(struct EventStruct *event, const char *Line)
|
||||
{
|
||||
return Command_Rules_IncDec(event, Line, -1.0);
|
||||
}
|
||||
|
||||
@@ -8,5 +8,7 @@ String Command_Rules_UseRules(struct EventStruct *event, const char *Line);
|
||||
const __FlashStringHelper * Command_Rules_Async_Events(struct EventStruct *event, const char *Line);
|
||||
const __FlashStringHelper * Command_Rules_Events(struct EventStruct *event, const char *Line);
|
||||
const __FlashStringHelper * Command_Rules_Let(struct EventStruct *event, const char *Line);
|
||||
const __FlashStringHelper * Command_Rules_Inc(struct EventStruct *event, const char *Line);
|
||||
const __FlashStringHelper * Command_Rules_Dec(struct EventStruct *event, const char *Line);
|
||||
|
||||
#endif // COMMAND_RULES_H
|
||||
|
||||
Reference in New Issue
Block a user