Browse Source

Added new relay & wifi led mode (#604)

rfm69
Xose Pérez 6 years ago
parent
commit
d7af09e769
5 changed files with 3230 additions and 3203 deletions
  1. +3
    -2
      code/espurna/config/general.h
  2. BIN
      code/espurna/data/index.html.gz
  3. +24
    -2
      code/espurna/led.ino
  4. +3197
    -3195
      code/espurna/static/index.html.gz.h
  5. +6
    -4
      code/html/index.html

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

@ -318,10 +318,11 @@ PROGMEM const char* const custom_reset_string[] = {
#define LED_MODE_FOLLOW 2 // LED will follow state of linked relay (check RELAY#_LED) #define LED_MODE_FOLLOW 2 // LED will follow 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_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_FINDME_WIFI 5 // A mixture between WIFI and FINDME
#define LED_MODE_ON 6 // LED always ON #define LED_MODE_ON 6 // LED always ON
#define LED_MODE_OFF 7 // LED always OFF #define LED_MODE_OFF 7 // LED always OFF
#define LED_MODE_STATUS 8 // If any relay is ON, LED will be ON, otherwise OFF
#define LED_MODE_RELAY 8 // If any relay is ON, LED will be ON, otherwise OFF
#define LED_MODE_RELAY_WIFI 9 // A mixture between WIFI and RELAY, the reverse of MIXED
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// WIFI // WIFI


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


+ 24
- 2
code/espurna/led.ino View File

@ -191,7 +191,7 @@ void ledLoop() {
} }
if (_ledMode(i) == LED_MODE_MIXED) {
if (_ledMode(i) == LED_MODE_FINDME_WIFI) {
if (wifiConnected()) { if (wifiConnected()) {
if (relayStatus(_leds[i].relay-1)) { if (relayStatus(_leds[i].relay-1)) {
@ -213,6 +213,28 @@ void ledLoop() {
} }
if (_ledMode(i) == LED_MODE_RELAY_WIFI) {
if (wifiConnected()) {
if (relayStatus(_leds[i].relay-1)) {
if (WiFi.getMode() == WIFI_AP) {
_ledBlink(i, 100, 900);
} else {
_ledBlink(i, 100, 4900);
}
} else {
if (WiFi.getMode() == WIFI_AP) {
_ledBlink(i, 900, 100);
} else {
_ledBlink(i, 4900, 100);
}
}
} else {
_ledBlink(i, 500, 500);
}
}
// Relay-based modes, update only if relays have been updated // Relay-based modes, update only if relays have been updated
if (!_led_update) continue; if (!_led_update) continue;
@ -235,7 +257,7 @@ void ledLoop() {
_ledStatus(i, status); _ledStatus(i, status);
} }
if (_ledMode(i) == LED_MODE_STATUS) {
if (_ledMode(i) == LED_MODE_RELAY) {
bool status = false; bool status = false;
for (unsigned char k=0; k<relayCount(); k++) { for (unsigned char k=0; k<relayCount(); k++) {
if (relayStatus(k)) { if (relayStatus(k)) {


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


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

@ -286,10 +286,11 @@
<label class="pure-u-1 pure-u-lg-1-4">LED mode</label> <label class="pure-u-1 pure-u-lg-1-4">LED mode</label>
<select name="ledMode0" class="pure-u-1 pure-u-lg-1-4" tabindex="7"> <select name="ledMode0" class="pure-u-1 pure-u-lg-1-4" tabindex="7">
<option value="1">WiFi status</option> <option value="1">WiFi status</option>
<option value="8">Relay status</option>
<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="8">Status</option>
<option value="5">Mixed</option>
<option value="9">Relay &amp; WiFi</option>
<option value="5">Find me &amp; WiFi</option>
<option value="6">Always ON</option> <option value="6">Always ON</option>
<option value="7">Always OFF</option> <option value="7">Always OFF</option>
</select> </select>
@ -298,10 +299,11 @@
<div class="pure-u-1 pure-u-lg-3-4 hint"> <div class="pure-u-1 pure-u-lg-3-4 hint">
This setting defines the behaviour of the main LED in the board.<br /> This setting defines the behaviour of the main LED in the board.<br />
When in "WiFi status" it will blink at 1Hz when trying to connect. If successfully connected it will briefly blink 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 connect. If successfully connected it will briefly blink every 5 seconds if in STA mode or every second if in AP mode.<br />
When in "Relay status" mode the LED will be ON whenever any relay is ON, and OFF otherwise. This is global status notification.<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 "Status" mode the LED will be ON whenever any relay is ON, and OFF otherwise. This is global status notification.<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.<br />
When in "Relay &amp; WiFi" mode it will follow the WiFi status but will stay mostly off when relays are OFF, and mostly ON when any of them is ON.<br />
When in "Find me &amp; WiFi" mode is the opposite of the "Relay &amp; WiFi", 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. "Always ON" and "Always OFF" modes are self-explanatory.
</div> </div>
</div> </div>


Loading…
Cancel
Save