Browse Source

Accept single MQTT color value for white

fastled
Xose Pérez 7 years ago
parent
commit
ec989ca44e
2 changed files with 15 additions and 6 deletions
  1. +0
    -2
      code/espurna/config/hardware.h
  2. +15
    -4
      code/espurna/relay.ino

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

@ -250,8 +250,6 @@
#define MANUFACTURER "AI THINKER" #define MANUFACTURER "AI THINKER"
#define DEVICE "AI LIGHT" #define DEVICE "AI LIGHT"
#define RELAY1_PIN 2
#define RELAY1_PIN_INVERSE 0
#undef RELAY_PROVIDER #undef RELAY_PROVIDER
#define RELAY_PROVIDER RELAY_PROVIDER_MY9291 #define RELAY_PROVIDER RELAY_PROVIDER_MY9291


+ 15
- 4
code/espurna/relay.ino View File

@ -478,13 +478,19 @@ void relayMQTTCallback(unsigned int type, const char * topic, const char * paylo
#if RELAY_PROVIDER == RELAY_PROVIDER_MY9291 #if RELAY_PROVIDER == RELAY_PROVIDER_MY9291
if (strncmp(t, MQTT_COLOR_TOPIC, strlen(MQTT_COLOR_TOPIC)) == 0) { if (strncmp(t, MQTT_COLOR_TOPIC, strlen(MQTT_COLOR_TOPIC)) == 0) {
unsigned char red, green, blue = 0;
char * p; char * p;
p = strtok((char *) payload, ","); p = strtok((char *) payload, ",");
unsigned char red = atoi(p);
p = strtok(NULL, ",");
unsigned char green = atoi(p);
red = atoi(p);
p = strtok(NULL, ","); p = strtok(NULL, ",");
unsigned char blue = atoi(p);
if (p != NULL) {
green = atoi(p);
p = strtok(NULL, ",");
if (p != NULL) blue = atoi(p);
} else {
green = blue = red;
}
if ((red == green) && (green == blue)) { if ((red == green) && (green == blue)) {
setLightColor(0, 0, 0, red); setLightColor(0, 0, 0, red);
} else { } else {
@ -543,6 +549,11 @@ void relaySetup() {
_relays.push_back((relay_t) {0, 0}); _relays.push_back((relay_t) {0, 0});
_relays.push_back((relay_t) {0, 0}); _relays.push_back((relay_t) {0, 0});
#elif AI_LIGHT
// One dummy relay for the AI Thinker Light
_relays.push_back((relay_t) {0, 0});
#else #else
#ifdef RELAY1_PIN #ifdef RELAY1_PIN


Loading…
Cancel
Save