Browse Source

Change pulse units (for MQTT and HTTP API) to seconds for coherence (#831)

fastled^2
Xose Pérez 6 years ago
parent
commit
74e27eebea
1 changed files with 3 additions and 3 deletions
  1. +3
    -3
      code/espurna/relay.ino

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

@ -631,11 +631,11 @@ void relaySetupAPI() {
snprintf_P(key, sizeof(key), PSTR("%s/%d"), MQTT_TOPIC_PULSE, relayID); snprintf_P(key, sizeof(key), PSTR("%s/%d"), MQTT_TOPIC_PULSE, relayID);
apiRegister(key, apiRegister(key,
[relayID](char * buffer, size_t len) { [relayID](char * buffer, size_t len) {
snprintf_P(buffer, len, PSTR("%lu"), _relays[relayID].pulse_ms);
dtostrf((double) _relays[relayID].pulse_ms / 1000, 1-len, 3, buffer);
}, },
[relayID](const char * payload) { [relayID](const char * payload) {
unsigned long pulse = String(payload).toInt();
unsigned long pulse = 1000 * String(payload).toFloat();
if (0 == pulse) return; if (0 == pulse) return;
if (RELAY_PULSE_NONE != _relays[relayID].pulse) { if (RELAY_PULSE_NONE != _relays[relayID].pulse) {
@ -751,7 +751,7 @@ void relayMQTTCallback(unsigned int type, const char * topic, const char * paylo
return; return;
} }
unsigned long pulse = String(payload).toInt();
unsigned long pulse = 1000 * String(payload).toFloat();
if (0 == pulse) return; if (0 == pulse) return;
if (RELAY_PULSE_NONE != _relays[id].pulse) { if (RELAY_PULSE_NONE != _relays[id].pulse) {


Loading…
Cancel
Save