Browse Source

Revert "Removed Ticker-based pulses. This allows to change pulse time on the go (#816)"

This reverts commit aaab65f877.
fastled^2
Maxim Prokhorov 6 years ago
parent
commit
8b60eb8486
4 changed files with 2306 additions and 2320 deletions
  1. BIN
      code/espurna/data/index.html.gz
  2. +6
    -20
      code/espurna/relay.ino
  3. +2299
    -2299
      code/espurna/static/index.html.gz.h
  4. +1
    -1
      code/html/index.html

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


+ 6
- 20
code/espurna/relay.ino View File

@ -23,7 +23,6 @@ typedef struct {
unsigned long delay_off; // Delay to turn relay OFF
unsigned char pulse; // RELAY_PULSE_NONE, RELAY_PULSE_OFF or RELAY_PULSE_ON
unsigned long pulse_ms; // Pulse length in millis
unsigned long pulse_start; // Current pulse start (millis), 0 means no pulse
// Status variables
@ -35,6 +34,10 @@ typedef struct {
bool report; // Whether to report to own topic
bool group_report; // Whether to report to group topic
// Helping objects
Ticker pulseTicker; // Holds the pulse back timer
} relay_t;
std::vector<relay_t> _relays;
bool _relayRecursive = false;
@ -200,21 +203,6 @@ void _relayProcess(bool mode) {
}
/**
* Walks the relay vector check if any relay has to pulse back
*/
void _relayPulseCheck() {
unsigned long current_time = millis();
for (unsigned char id = 0; id < _relays.size(); id++) {
if (_relays[id].pulse_start > 0) {
if (current_time - _relays[id].pulse_start > _relays[id].pulse_ms) {
_relays[id].pulse_start = 0;
relayToggle(id);
}
}
}
}
// -----------------------------------------------------------------------------
// RELAY
// -----------------------------------------------------------------------------
@ -230,10 +218,10 @@ void relayPulse(unsigned char id) {
bool pulseStatus = (mode == RELAY_PULSE_ON);
if (pulseStatus == status) {
_relays[id].pulse_start = 0;
_relays[id].pulseTicker.detach();
} else {
DEBUG_MSG_P(PSTR("[RELAY] Scheduling relay #%d back in %lums (pulse)\n"), id, ms);
_relays[id].pulse_start = millis();
_relays[id].pulseTicker.once_ms(ms, relayToggle, id);
}
}
@ -476,7 +464,6 @@ void _relayBoot() {
}
_relays[i].current_status = !status;
_relays[i].target_status = status;
_relays[i].pulse_start = 0;
#if RELAY_PROVIDER == RELAY_PROVIDER_STM
_relays[i].change_time = millis() + 3000 + 1000 * i;
#else
@ -834,7 +821,6 @@ void _relayInitCommands() {
//------------------------------------------------------------------------------
void _relayLoop() {
_relayPulseCheck();
_relayProcess(false);
_relayProcess(true);
}


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


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

@ -1336,7 +1336,7 @@
</div>
<div class="pure-g">
<div class="pure-u-1 pure-u-lg-1-4"><label>Pulse time (s)</label></div>
<div class="pure-u-1 pure-u-lg-1-4"><input name="relayTime" class="pure-u-1" type="number" min="0" step="0.1" max="86400" /></div>
<div class="pure-u-1 pure-u-lg-1-4"><input name="relayTime" class="pure-u-1" type="number" min="0" step="0.1" max="3600" /></div>
</div>
<div class="pure-g module module-mqtt">
<div class="pure-u-1 pure-u-lg-1-4"><label>MQTT group</label></div>


Loading…
Cancel
Save