mirror of https://github.com/arendst/Tasmota.git
Fix GUI password and Add rule expression
* Fix GUI wifi password acception starting with asteriks (*) (#5231, #5242) * Add rule expression enabled by define USE_EXPRESSION in my_user_config.h (#5210)
This commit is contained in:
parent
7c9720de9d
commit
14d5f7fb54
|
@ -1,6 +1,8 @@
|
|||
/* 6.4.1.17 20190214
|
||||
* Change template update by removing possibility to add user module config keeping template as defined (#5222)
|
||||
* Fix regression from 6.4.1.16 where GPIO9 and GPIO10 connected devices did not work (#5197)
|
||||
* Fix GUI wifi password acception starting with asteriks (*) (#5231, #5242)
|
||||
* Add rule expression enabled by define USE_EXPRESSION in my_user_config.h (#5210)
|
||||
*
|
||||
* 6.4.1.16 20190211
|
||||
* Initial support for online template change using command Template or GUI Configure Other (#5177)
|
||||
|
|
|
@ -278,9 +278,7 @@
|
|||
|
||||
// -- Rules ---------------------------------------
|
||||
#define USE_RULES // Add support for rules (+4k4 code)
|
||||
#ifdef USE_RULES
|
||||
#define USE_EXPRESSION // Add support for expression evaluation in rules (+3k1 code, +28 bytes mem)
|
||||
#endif
|
||||
#define USE_EXPRESSION // Add support for expression evaluation in rules (+3k2 code, +64 bytes mem)
|
||||
|
||||
// -- Internal Analog input -----------------------
|
||||
#define USE_ADC_VCC // Display Vcc in Power status. Disable for use as Analog input on selected devices
|
||||
|
|
|
@ -64,9 +64,6 @@
|
|||
#ifdef USE_SPI
|
||||
#include <SPI.h> // SPI support, TFT
|
||||
#endif // USE_SPI
|
||||
#ifdef USE_EXPRESSION
|
||||
#include <LinkedList.h> // Import LinkedList library
|
||||
#endif
|
||||
// Structs
|
||||
#include "settings.h"
|
||||
|
||||
|
|
|
@ -91,6 +91,8 @@
|
|||
const char kCompareOperators[] PROGMEM = "=\0>\0<\0|\0==!=>=<=";
|
||||
|
||||
#ifdef USE_EXPRESSION
|
||||
#include <LinkedList.h> // Import LinkedList library
|
||||
|
||||
const char kExpressionOperators[] PROGMEM = "+-*/%^";
|
||||
#define EXPRESSION_OPERATOR_ADD 0
|
||||
#define EXPRESSION_OPERATOR_SUBTRACT 1
|
||||
|
@ -101,7 +103,7 @@ const char kCompareOperators[] PROGMEM = "=\0>\0<\0|\0==!=>=<=";
|
|||
|
||||
const uint8_t kExpressionOperatorsPriorities[] PROGMEM = {1, 1, 2, 2, 3, 4};
|
||||
#define MAX_EXPRESSION_OPERATOR_PRIORITY 4
|
||||
#endif //USE_EXPRESSION
|
||||
#endif // USE_EXPRESSION
|
||||
|
||||
enum RulesCommands { CMND_RULE, CMND_RULETIMER, CMND_EVENT, CMND_VAR, CMND_MEM, CMND_ADD, CMND_SUB, CMND_MULT, CMND_SCALE, CMND_CALC_RESOLUTION };
|
||||
const char kRulesCommands[] PROGMEM = D_CMND_RULE "|" D_CMND_RULETIMER "|" D_CMND_EVENT "|" D_CMND_VAR "|" D_CMND_MEM "|" D_CMND_ADD "|" D_CMND_SUB "|" D_CMND_MULT "|" D_CMND_SCALE "|" D_CMND_CALC_RESOLUTION ;
|
||||
|
@ -686,7 +688,7 @@ bool findNextVariableValue(char * &pVarname, double &value)
|
|||
bool findNextObjectValue(char * &pointer, double &value)
|
||||
{
|
||||
bool bSucceed = false;
|
||||
while (*pointer)
|
||||
while (*pointer)
|
||||
{
|
||||
if (isspace(*pointer)) { //Skip leading spaces
|
||||
pointer++;
|
||||
|
@ -748,7 +750,7 @@ bool findNextObjectValue(char * &pointer, double &value)
|
|||
bool findNextOperator(char * &pointer, int8_t &op)
|
||||
{
|
||||
bool bSucceed = false;
|
||||
while (*pointer)
|
||||
while (*pointer)
|
||||
{
|
||||
if (isspace(*pointer)) { //Skip leading spaces
|
||||
pointer++;
|
||||
|
@ -809,7 +811,7 @@ double calculateTwoValues(double v1, double v2, uint8_t op)
|
|||
* expression - The expression to be evaluated
|
||||
* len - Length of the expression
|
||||
* Return:
|
||||
* double - result.
|
||||
* double - result.
|
||||
* 0 - if the expression is invalid
|
||||
* An example:
|
||||
* MEM1 = 3, MEM2 = 6, VAR2 = 15, VAR10 = 80
|
||||
|
@ -848,15 +850,15 @@ double evaluateExpression(const char * expression, unsigned int len)
|
|||
}
|
||||
while (*scan_pointer)
|
||||
{
|
||||
if (findNextOperator(scan_pointer, op)
|
||||
if (findNextOperator(scan_pointer, op)
|
||||
&& *scan_pointer
|
||||
&& findNextObjectValue(scan_pointer, va))
|
||||
&& findNextObjectValue(scan_pointer, va))
|
||||
{
|
||||
operators.add(op);
|
||||
object_values.add(va);
|
||||
} else {
|
||||
//No operator followed or no more object after this operator, we done.
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue