Browse Source

Accept decimals in pulse time, limit it to 60s

fastled
Xose Pérez 7 years ago
parent
commit
79a0816053
5 changed files with 69 additions and 71 deletions
  1. +2
    -2
      code/espurna/config/general.h
  2. +3
    -5
      code/espurna/relay.ino
  3. +61
    -61
      code/espurna/static/index.html.gz.h
  4. +1
    -1
      code/espurna/web.ino
  5. +2
    -2
      code/html/index.html

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

@ -76,8 +76,8 @@
#define RELAY_PROVIDER_DUAL 1 #define RELAY_PROVIDER_DUAL 1
#define RELAY_PROVIDER_LIGHT 2 #define RELAY_PROVIDER_LIGHT 2
// Pulse time in seconds
#define RELAY_PULSE_TIME 1
// Pulse time in milliseconds
#define RELAY_PULSE_TIME 1.0
// 0 means OFF, 1 ON and 2 whatever was before // 0 means OFF, 1 ON and 2 whatever was before
#define RELAY_MODE RELAY_MODE_OFF #define RELAY_MODE RELAY_MODE_OFF


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

@ -101,6 +101,8 @@ void relayPulse(unsigned char id) {
byte relayPulseMode = getSetting("relayPulseMode", RELAY_PULSE_MODE).toInt(); byte relayPulseMode = getSetting("relayPulseMode", RELAY_PULSE_MODE).toInt();
if (relayPulseMode == RELAY_PULSE_NONE) return; if (relayPulseMode == RELAY_PULSE_NONE) return;
long relayPulseTime = 1000.0 * getSetting("relayPulseTime", RELAY_PULSE_TIME).toFloat();
if (relayPulseTime == 0) return;
bool status = relayStatus(id); bool status = relayStatus(id);
bool pulseStatus = (relayPulseMode == RELAY_PULSE_ON); bool pulseStatus = (relayPulseMode == RELAY_PULSE_ON);
@ -109,11 +111,7 @@ void relayPulse(unsigned char id) {
return; return;
} }
_relays[id].pulseTicker.once(
getSetting("relayPulseTime", RELAY_PULSE_TIME).toInt(),
relayToggle,
id
);
_relays[id].pulseTicker.once_ms(relayPulseTime, relayToggle, id);
} }


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


+ 1
- 1
code/espurna/web.ino View File

@ -441,7 +441,7 @@ void _wsStart(uint32_t client_id) {
root["relayMode"] = getSetting("relayMode", RELAY_MODE); root["relayMode"] = getSetting("relayMode", RELAY_MODE);
root["relayPulseMode"] = getSetting("relayPulseMode", RELAY_PULSE_MODE); root["relayPulseMode"] = getSetting("relayPulseMode", RELAY_PULSE_MODE);
root["relayPulseTime"] = getSetting("relayPulseTime", RELAY_PULSE_TIME);
root["relayPulseTime"] = getSetting("relayPulseTime", RELAY_PULSE_TIME).toFloat();
if (relayCount() > 1) { if (relayCount() > 1) {
root["multirelayVisible"] = 1; root["multirelayVisible"] = 1;
root["relaySync"] = getSetting("relaySync", RELAY_SYNC); root["relaySync"] = getSetting("relaySync", RELAY_SYNC);


+ 2
- 2
code/html/index.html View File

@ -311,9 +311,9 @@
<div class="pure-g"> <div class="pure-g">
<label class="pure-u-1 pure-u-md-1-4" for="relayPulseTime">Switch pulse time</label> <label class="pure-u-1 pure-u-md-1-4" for="relayPulseTime">Switch pulse time</label>
<input name="relayPulseTime" class="pure-u-1 pure-u-md-3-4" type="number" min="1" tabindex="5" />
<input name="relayPulseTime" class="pure-u-1 pure-u-md-3-4" type="number" min="0" step="0.1" max="60" tabindex="5" />
<div class="pure-u-0 pure-u-md-1-4">&nbsp;</div> <div class="pure-u-0 pure-u-md-1-4">&nbsp;</div>
<div class="pure-u-1 pure-u-md-3-4 hint">Pulse time in seconds.</div>
<div class="pure-u-1 pure-u-md-3-4 hint">Pulse time in seconds (maximum value is 60s, accepts decimals).</div>
</div> </div>
<div class="pure-g module module-fauxmo"> <div class="pure-g module module-fauxmo">


Loading…
Cancel
Save