Browse Source

New LED modes: always ON and always OFF (#348)

i18n
Xose Pérez 6 years ago
parent
commit
f06c841639
6 changed files with 2512 additions and 2482 deletions
  1. +2
    -0
      code/espurna/config/general.h
  2. BIN
      code/espurna/data/index.html.gz
  3. +20
    -0
      code/espurna/led.ino
  4. +3
    -0
      code/espurna/relay.ino
  5. +2483
    -2481
      code/espurna/static/index.html.gz.h
  6. +4
    -1
      code/html/index.html

+ 2
- 0
code/espurna/config/general.h View File

@ -264,6 +264,8 @@ PROGMEM const char* const custom_reset_string[] = {
#define LED_MODE_FOLLOW_INVERSE 3 // LED will follow the opposite state of linked relay (check RELAY#_LED) #define LED_MODE_FOLLOW_INVERSE 3 // LED will follow the opposite state of linked relay (check RELAY#_LED)
#define LED_MODE_FINDME 4 // LED will be ON if all relays are OFF #define LED_MODE_FINDME 4 // LED will be ON if all relays are OFF
#define LED_MODE_MIXED 5 // A mixed between WIFI and FINDME #define LED_MODE_MIXED 5 // A mixed between WIFI and FINDME
#define LED_MODE_ON 6 // LED always ON
#define LED_MODE_OFF 7 // LED always OFF
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// WIFI // WIFI


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


+ 20
- 0
code/espurna/led.ino View File

@ -18,6 +18,7 @@ typedef struct {
} led_t; } led_t;
std::vector<led_t> _leds; std::vector<led_t> _leds;
bool _led_update = false; // For relay-based modes
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -115,10 +116,15 @@ void _ledConfigure() {
for (unsigned int i=0; i < _leds.size(); i++) { for (unsigned int i=0; i < _leds.size(); i++) {
_ledMode(i, getSetting("ledMode", i, _ledMode(i)).toInt()); _ledMode(i, getSetting("ledMode", i, _ledMode(i)).toInt());
} }
_led_update = true;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void ledUpdate(bool value) {
_led_update = value;
}
void ledSetup() { void ledSetup() {
#ifdef LED1_PIN #ifdef LED1_PIN
@ -206,6 +212,9 @@ void ledLoop() {
} }
// Relay-based modes, update only if relays have been updated
if (!_led_update) continue;
if (_ledMode(i) == LED_MODE_FOLLOW) { if (_ledMode(i) == LED_MODE_FOLLOW) {
_ledStatus(i, relayStatus(_leds[i].relay-1)); _ledStatus(i, relayStatus(_leds[i].relay-1));
} }
@ -225,5 +234,16 @@ void ledLoop() {
_ledStatus(i, status); _ledStatus(i, status);
} }
if (_ledMode(i) == LED_MODE_ON) {
_ledStatus(i, true);
}
if (_ledMode(i) == LED_MODE_OFF) {
_ledStatus(i, false);
}
} }
_led_update = false;
} }

+ 3
- 0
code/espurna/relay.ino View File

@ -747,6 +747,9 @@ void relayLoop(void) {
relayInfluxDB(id); relayInfluxDB(id);
#endif #endif
// Flag relay-based LEDs to update status
ledUpdate(true);
_relays[id].report = false; _relays[id].report = false;
_relays[id].group_report = false; _relays[id].group_report = false;


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


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

@ -268,6 +268,8 @@
<option value="0">MQTT managed</option> <option value="0">MQTT managed</option>
<option value="4">Find me</option> <option value="4">Find me</option>
<option value="5">Mixed</option> <option value="5">Mixed</option>
<option value="6">Always ON</option>
<option value="7">Always OFF</option>
</select> </select>
<div class="pure-u-0 pure-u-lg-1-2"></div> <div class="pure-u-0 pure-u-lg-1-2"></div>
<div class="pure-u-0 pure-u-lg-1-4"></div> <div class="pure-u-0 pure-u-lg-1-4"></div>
@ -276,7 +278,8 @@
When in "WiFi status" it will blink at 1Hz when trying to connecting. If successfully connected if will briefly lit every 5 seconds if in STA mode or every second if in AP mode.<br /> When in "WiFi status" it will blink at 1Hz when trying to connecting. If successfully connected if will briefly lit every 5 seconds if in STA mode or every second if in AP mode.<br />
When in "MQTT managed" mode you will be able to set the LED state sending a message to "&lt;base_topic&gt;/led/0/set" with a payload of 0, 1 or 2 (to toggle it).<br /> When in "MQTT managed" mode you will be able to set the LED state sending a message to "&lt;base_topic&gt;/led/0/set" with a payload of 0, 1 or 2 (to toggle it).<br />
When in "Find me" mode the LED will be ON when all relays are OFF. This is meant to locate switches at night.<br /> When in "Find me" mode the LED will be ON when all relays are OFF. This is meant to locate switches at night.<br />
When in "Mixed" mode it will follow the WiFi status but will stay mostly on when relays are OFF, and mostly OFF when any of them is ON.
When in "Mixed" mode it will follow the WiFi status but will stay mostly on when relays are OFF, and mostly OFF when any of them is ON.<br />
"Always ON" and "Always OFF" modes are self-explanatory.
</div> </div>
</div> </div>


Loading…
Cancel
Save