From e165c578a5f7bfc0cd626a4ace37d600a41dcd8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Mon, 15 Jan 2018 17:08:10 +0100 Subject: [PATCH] Normalize code --- code/espurna/alexa.ino | 25 +++++++++++++------------ code/espurna/config/general.h | 2 +- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/code/espurna/alexa.ino b/code/espurna/alexa.ino index a7991bac..8f0ced46 100644 --- a/code/espurna/alexa.ino +++ b/code/espurna/alexa.ino @@ -9,19 +9,19 @@ Copyright (C) 2016-2018 by Xose PĂ©rez #if ALEXA_SUPPORT #include -#include fauxmoESP alexa; -// ----------------------------------------------------------------------------- -// ALEXA -// ----------------------------------------------------------------------------- struct AlexaDevChange { - AlexaDevChange(unsigned char device_id, bool state) : device_id(device_id), state(state) {}; - unsigned char device_id = 0; - bool state = false; + AlexaDevChange(unsigned char device_id, bool state) : device_id(device_id), state(state) {}; + unsigned char device_id = 0; + bool state = false; }; +#include static std::queue _alexa_dev_changes; +// ----------------------------------------------------------------------------- +// ALEXA +// ----------------------------------------------------------------------------- void _alexaWebSocketOnSend(JsonObject& root) { root["alexaVisible"] = 1; root["alexaEnabled"] = getSetting("alexaEnabled", ALEXA_ENABLED).toInt() == 1; @@ -64,7 +64,7 @@ void alexaSetup() { _alexa_dev_changes.push(change); }); - alexa.onGetState([relays](unsigned char device_id, const char * name) { + alexa.onGetState([](unsigned char device_id, const char * name) { return relayStatus(device_id); }); @@ -75,11 +75,12 @@ void alexaLoop() { alexa.handle(); while (!_alexa_dev_changes.empty()) { - AlexaDevChange& change = _alexa_dev_changes.front(); - DEBUG_MSG_P(PSTR("[ALEXA] Device #%d state: %s\n"), change.device_id, change.state ? "ON" : "OFF"); - relayStatus(change.device_id, change.state); - _alexa_dev_changes.pop(); + AlexaDevChange& change = _alexa_dev_changes.front(); + DEBUG_MSG_P(PSTR("[ALEXA] Device #%d state: %s\n"), change.device_id, change.state ? "ON" : "OFF"); + relayStatus(change.device_id, change.state); + _alexa_dev_changes.pop(); } + } #endif diff --git a/code/espurna/config/general.h b/code/espurna/config/general.h index fb97335e..57cf9c66 100644 --- a/code/espurna/config/general.h +++ b/code/espurna/config/general.h @@ -720,7 +720,7 @@ PROGMEM const char* const custom_reset_string[] = { // This setting defines whether Alexa support should be built into the firmware #ifndef ALEXA_SUPPORT -#define ALEXA_SUPPORT 1 // Enable Alexa support by default (9.5Kb) +#define ALEXA_SUPPORT 1 // Enable Alexa support by default (10.84Kb) #endif // This is default value for the alexaEnabled setting that defines whether