Browse Source

Stickyness, rpn.ops,...

rules-rpn
Xose Pérez 5 years ago
parent
commit
f8488fff6a
21 changed files with 19191 additions and 19162 deletions
  1. +1
    -0
      code/espurna/config/arduino.h
  2. +5
    -5
      code/espurna/config/general.h
  3. +1
    -0
      code/espurna/config/hardware.h
  4. BIN
      code/espurna/data/index.all.html.gz
  5. BIN
      code/espurna/data/index.light.html.gz
  6. BIN
      code/espurna/data/index.lightfox.html.gz
  7. BIN
      code/espurna/data/index.rfbridge.html.gz
  8. BIN
      code/espurna/data/index.rfm69.html.gz
  9. BIN
      code/espurna/data/index.sensor.html.gz
  10. BIN
      code/espurna/data/index.small.html.gz
  11. BIN
      code/espurna/data/index.thermostat.html.gz
  12. +18
    -5
      code/espurna/rpnrules.ino
  13. +2442
    -2440
      code/espurna/static/index.all.html.gz.h
  14. +2301
    -2299
      code/espurna/static/index.light.html.gz.h
  15. +1941
    -1939
      code/espurna/static/index.lightfox.html.gz.h
  16. +1990
    -1988
      code/espurna/static/index.rfbridge.html.gz.h
  17. +3314
    -3312
      code/espurna/static/index.rfm69.html.gz.h
  18. +2576
    -2574
      code/espurna/static/index.sensor.html.gz.h
  19. +1941
    -1939
      code/espurna/static/index.small.html.gz.h
  20. +2660
    -2658
      code/espurna/static/index.thermostat.html.gz.h
  21. +1
    -3
      code/html/index.html

+ 1
- 0
code/espurna/config/arduino.h View File

@ -159,6 +159,7 @@
//#define NTP_SUPPORT 0 //#define NTP_SUPPORT 0
//#define RF_SUPPORT 1 //#define RF_SUPPORT 1
//#define RFM69_SUPPORT 1 //#define RFM69_SUPPORT 1
//#define RPN_RULES_SUPPORT 0
//#define SCHEDULER_SUPPORT 0 //#define SCHEDULER_SUPPORT 0
//#define SENSOR_SUPPORT 1 //#define SENSOR_SUPPORT 1
//#define SPIFFS_SUPPORT 1 //#define SPIFFS_SUPPORT 1


+ 5
- 5
code/espurna/config/general.h View File

@ -1165,11 +1165,11 @@
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#ifndef SCHEDULER_SUPPORT #ifndef SCHEDULER_SUPPORT
#define SCHEDULER_SUPPORT 1 // Enable scheduler (1.77Kb)
#define SCHEDULER_SUPPORT 1 // Enable scheduler (2.45Kb)
#endif #endif
#ifndef SCHEDULER_MAX_SCHEDULES #ifndef SCHEDULER_MAX_SCHEDULES
#define SCHEDULER_MAX_SCHEDULES 10 // Max schedules alowed
#define SCHEDULER_MAX_SCHEDULES 10 // Max schedules alowed
#endif #endif
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -1177,11 +1177,11 @@
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#ifndef RPN_RULES_SUPPORT #ifndef RPN_RULES_SUPPORT
#define RPN_RULES_SUPPORT 1 // Enable RPN Rules (?Kb)
#define RPN_RULES_SUPPORT 1 // Enable RPN Rules (8.13Kb)
#endif #endif
#ifndef RPN_BUFFER_DELAY
#define RPN_BUFFER_DELAY 100 // Execute rules after 100ms without messages
#ifndef RPN_DELAY
#define RPN_DELAY 100 // Execute rules after 100ms without messages
#endif #endif
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------


+ 1
- 0
code/espurna/config/hardware.h View File

@ -46,6 +46,7 @@
#define I2C_SUPPORT 0 #define I2C_SUPPORT 0
#define MQTT_SUPPORT 0 #define MQTT_SUPPORT 0
#define NTP_SUPPORT 0 #define NTP_SUPPORT 0
#define RPN_RULES_SUPPORT 0
#define SCHEDULER_SUPPORT 0 #define SCHEDULER_SUPPORT 0
#define SENSOR_SUPPORT 0 #define SENSOR_SUPPORT 0
#define THINGSPEAK_SUPPORT 0 #define THINGSPEAK_SUPPORT 0


BIN
code/espurna/data/index.all.html.gz View File


BIN
code/espurna/data/index.light.html.gz View File


BIN
code/espurna/data/index.lightfox.html.gz View File


BIN
code/espurna/data/index.rfbridge.html.gz View File


BIN
code/espurna/data/index.rfm69.html.gz View File


BIN
code/espurna/data/index.sensor.html.gz View File


BIN
code/espurna/data/index.small.html.gz View File


BIN
code/espurna/data/index.thermostat.html.gz View File


+ 18
- 5
code/espurna/rpnrules.ino View File

@ -17,7 +17,7 @@ Copyright (C) 2019 by Xose Pérez <xose dot perez at gmail dot com>
rpn_context _rpn_ctxt; rpn_context _rpn_ctxt;
bool _rpn_run = false; bool _rpn_run = false;
bool _rpn_inject = true; bool _rpn_inject = true;
unsigned long _rpn_delay = RPN_BUFFER_DELAY;
unsigned long _rpn_delay = RPN_DELAY;
float _rpn_value = 0; float _rpn_value = 0;
unsigned long _rpn_last = 0; unsigned long _rpn_last = 0;
@ -31,7 +31,7 @@ void _rpnWebSocketOnSend(JsonObject& root) {
root["rpnVisible"] = 1; root["rpnVisible"] = 1;
root["rpnSticky"] = getSetting("rpnSticky", 1).toInt(); root["rpnSticky"] = getSetting("rpnSticky", 1).toInt();
root["rpnDelay"] = getSetting("rpnDelay", RPN_BUFFER_DELAY).toInt();
root["rpnDelay"] = getSetting("rpnDelay", RPN_DELAY).toInt();
JsonArray& rules = root.createNestedArray("rpnRules"); JsonArray& rules = root.createNestedArray("rpnRules");
JsonArray& topics = root.createNestedArray("rpnTopics"); JsonArray& topics = root.createNestedArray("rpnTopics");
JsonArray& names = root.createNestedArray("rpnNames"); JsonArray& names = root.createNestedArray("rpnNames");
@ -101,7 +101,7 @@ void _rpnConfigure() {
#if MQTT_SUPPORT #if MQTT_SUPPORT
if (mqttConnected()) _rpnMQTTSubscribe(); if (mqttConnected()) _rpnMQTTSubscribe();
#endif #endif
_rpn_delay = getSetting("rpnDelay", RPN_BUFFER_DELAY).toInt();
_rpn_delay = getSetting("rpnDelay", RPN_DELAY).toInt();
} }
void _rpnBrokerCallback(const unsigned char type, const char * topic, unsigned char id, const char * payload) { void _rpnBrokerCallback(const unsigned char type, const char * topic, unsigned char id, const char * payload) {
@ -134,6 +134,10 @@ void _rpnInit() {
rpn_stack_push(ctxt, now()); rpn_stack_push(ctxt, now());
return true; return true;
}); });
rpn_operator_set(_rpn_ctxt, "utc", 0, [](rpn_context & ctxt) {
rpn_stack_push(ctxt, ntpLocal2UTC(now()));
return true;
});
rpn_operator_set(_rpn_ctxt, "dow", 1, [](rpn_context & ctxt) { rpn_operator_set(_rpn_ctxt, "dow", 1, [](rpn_context & ctxt) {
float a; float a;
rpn_stack_pop(ctxt, a); rpn_stack_pop(ctxt, a);
@ -182,7 +186,7 @@ void _rpnInit() {
}); });
rpn_operator_set(_rpn_ctxt, "black", 0, [](rpn_context & ctxt) { rpn_operator_set(_rpn_ctxt, "black", 0, [](rpn_context & ctxt) {
lightColor(0);
lightColor((unsigned long) 0);
return true; return true;
}); });
@ -212,12 +216,21 @@ void _rpnInitCommands() {
char * name = rpn_variable_name(_rpn_ctxt, i); char * name = rpn_variable_name(_rpn_ctxt, i);
float value; float value;
rpn_variable_get(_rpn_ctxt, name, value); rpn_variable_get(_rpn_ctxt, name, value);
DEBUG_MSG_P(PSTR(" %s: %s\n"), name, String(value).c_str());
DEBUG_MSG_P(PSTR(" %s: %s\n"), name, String(value).c_str());
} }
} }
terminalOK(); terminalOK();
}); });
terminalRegisterCommand(F("RPN.OPS"), [](Embedis* e) {
unsigned char num = _rpn_ctxt.operators.size();
DEBUG_MSG_P(PSTR("[RPN] Operators:\n"));
for (unsigned char i=0; i<num; i++) {
DEBUG_MSG_P(PSTR(" %s (%d)\n"), _rpn_ctxt.operators[i].name, _rpn_ctxt.operators[i].argc);
}
terminalOK();
});
terminalRegisterCommand(F("RPN.TEST"), [](Embedis* e) { terminalRegisterCommand(F("RPN.TEST"), [](Embedis* e) {
if (e->argc == 2) { if (e->argc == 2) {
DEBUG_MSG_P(PSTR("[RPN] Running \"%s\"\n"), e->argv[1]); DEBUG_MSG_P(PSTR("[RPN] Running \"%s\"\n"), e->argv[1]);


+ 2442
- 2440
code/espurna/static/index.all.html.gz.h
File diff suppressed because it is too large
View File


+ 2301
- 2299
code/espurna/static/index.light.html.gz.h
File diff suppressed because it is too large
View File


+ 1941
- 1939
code/espurna/static/index.lightfox.html.gz.h
File diff suppressed because it is too large
View File


+ 1990
- 1988
code/espurna/static/index.rfbridge.html.gz.h
File diff suppressed because it is too large
View File


+ 3314
- 3312
code/espurna/static/index.rfm69.html.gz.h
File diff suppressed because it is too large
View File


+ 2576
- 2574
code/espurna/static/index.sensor.html.gz.h
File diff suppressed because it is too large
View File


+ 1941
- 1939
code/espurna/static/index.small.html.gz.h
File diff suppressed because it is too large
View File


+ 2660
- 2658
code/espurna/static/index.thermostat.html.gz.h
File diff suppressed because it is too large
View File


+ 1
- 3
code/html/index.html View File

@ -1406,7 +1406,7 @@
<div class="header"> <div class="header">
<h1>RULES</h1> <h1>RULES</h1>
<h2> <h2>
Here you can configure advanced rules based on RPN sentences.
Here you can configure advanced rules based on RPN expressions. Check the <a href="https://github.com/xoseperez/espurna/wiki/RPN-Rules" target="_blank">wiki page about the RPN Rules module</a> to know how to use them.
</h2> </h2>
</div> </div>
@ -1436,7 +1436,6 @@
<legend>Rules</legend> <legend>Rules</legend>
<div id="rpnRules"></div> <div id="rpnRules"></div>
<button type="button" class="pure-button button-add-rpnrule">Add</button> <button type="button" class="pure-button button-add-rpnrule">Add</button>
<legend>MQTT</legend> <legend>MQTT</legend>
@ -1447,7 +1446,6 @@
</div> </div>
<div id="rpnTopics"></div> <div id="rpnTopics"></div>
<button type="button" class="pure-button button-add-rpntopic">Add</button> <button type="button" class="pure-button button-add-rpntopic">Add</button>
</fieldset> </fieldset>


Loading…
Cancel
Save