From 6b797b51475904db7c5625b5ceb30d33dc385e04 Mon Sep 17 00:00:00 2001 From: SciLor Date: Sat, 29 Oct 2016 09:23:00 +0200 Subject: [PATCH 1/8] Removed unused modeFallback method --- HyperionRGB.ino | 3 --- 1 file changed, 3 deletions(-) diff --git a/HyperionRGB.ino b/HyperionRGB.ino index f8dd363..b2ff89b 100644 --- a/HyperionRGB.ino +++ b/HyperionRGB.ino @@ -63,9 +63,6 @@ void animationStep() { void changeMode(Mode newMode) { activeMode = newMode; } -void modeFallback(void) { - changeMode(RAINBOW); -} void handleEvents(void) { ota.handle(); From a41e33fb0181af3a56d58dec18e46ef9b5204f0a Mon Sep 17 00:00:00 2001 From: SciLor Date: Sat, 29 Oct 2016 09:41:49 +0200 Subject: [PATCH 2/8] Changed enum order --- BaseHeader.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BaseHeader.h b/BaseHeader.h index 2d7b37f..4da7c52 100644 --- a/BaseHeader.h +++ b/BaseHeader.h @@ -12,7 +12,7 @@ typeof (Y) y_ = (Y); \ (x_ < y_) ? x_ : y_; })*/ -enum Mode { RAINBOW, STATIC_COLOR, AMBILIGHT, FIRE2012, OFF }; +enum Mode { OFF, AMBILIGHT, STATIC_COLOR, RAINBOW, FIRE2012 }; #endif From c6fbac687f8e5aed830f7f176c3363f741114ba4 Mon Sep 17 00:00:00 2001 From: SciLor Date: Sat, 29 Oct 2016 09:42:30 +0200 Subject: [PATCH 3/8] Implemented JSON effect selection via hyperion app --- HyperionRGB.ino | 8 ++++++-- WrapperJsonServer.cpp | 15 +++++++++++++++ WrapperJsonServer.h | 8 ++++---- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/HyperionRGB.ino b/HyperionRGB.ino index b2ff89b..55dc1dd 100644 --- a/HyperionRGB.ino +++ b/HyperionRGB.ino @@ -61,7 +61,10 @@ void animationStep() { } void changeMode(Mode newMode) { - activeMode = newMode; + if (newMode != activeMode) { + Log.info("Mode changed to %i", newMode); + activeMode = newMode; + } } void handleEvents(void) { @@ -106,7 +109,7 @@ void ledColorWipe(byte r, byte g, byte b) { changeMode(STATIC_COLOR); } void resetMode(void) { - Log.info("reset Mode"); + Log.info("Reset Mode"); changeMode(CONFIG_LED_STANDARD_MODE); resetThread.enabled = false; } @@ -179,6 +182,7 @@ void setup(void) { jsonServer.begin(); jsonServer.onLedColorWipe(ledColorWipe); jsonServer.onClearCmd(resetMode); + jsonServer.onEffectChange(changeMode); pinMode(LED, OUTPUT); // LED pin as output. Log.info("HEAP=%i", ESP.getFreeHeap()); diff --git a/WrapperJsonServer.cpp b/WrapperJsonServer.cpp index 57565f6..dc5a3e1 100644 --- a/WrapperJsonServer.cpp +++ b/WrapperJsonServer.cpp @@ -64,6 +64,12 @@ void WrapperJsonServer::readData(void) { //{"command":"effect","effect":{"name":"Rainbow mood","args":{"speed":1}},"priority":50} String effect = root["effect"]["name"].asString(); int speed = root["effect"]["speed"]; + + if (effect.equals("Rainbow mood")) { + effectChange(RAINBOW); + } else if (effect.equals("Fire2012")) { + effectChange(FIRE2012); + } _tcpClient.println("{\"success\":true}"); } else { _tcpClient.println("{\"success\":false}"); @@ -91,3 +97,12 @@ void WrapperJsonServer::clearCmd(void) { } } +void WrapperJsonServer::onEffectChange(void(* function) (Mode)) { + effectChangePointer = function; +} +void WrapperJsonServer::effectChange(Mode effect) { + if (effectChangePointer) { + effectChangePointer(effect); + } +} + diff --git a/WrapperJsonServer.h b/WrapperJsonServer.h index ff984d2..184c995 100644 --- a/WrapperJsonServer.h +++ b/WrapperJsonServer.h @@ -19,8 +19,8 @@ class WrapperJsonServer { void onLedColorWipe(void(* function) (byte, byte, byte)), - onClearCmd(void(* function) (void)); -// onEffect(void(* function) (Mode)); + onClearCmd(void(* function) (void)), + onEffectChange(void(* function) (Mode)); private: void handleConnection(boolean newClient), @@ -33,8 +33,8 @@ class WrapperJsonServer { clearCmd(void), (* clearCmdPointer) (void); void - effect(Mode effect), - (* effectPointer) (Mode); + effectChange(Mode effect), + (* effectChangePointer) (Mode); WiFiServer _tcpServer; WiFiClient _tcpClient; From c376b6bae986ea18efaccbadb84952d215a5661e Mon Sep 17 00:00:00 2001 From: SciLor Date: Sat, 29 Oct 2016 09:44:18 +0200 Subject: [PATCH 4/8] Fixed static config, added doc for standard mode --- ConfigStatic.h.example | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ConfigStatic.h.example b/ConfigStatic.h.example index 8c576ac..1fdd26a 100644 --- a/ConfigStatic.h.example +++ b/ConfigStatic.h.example @@ -14,6 +14,7 @@ #define LOGLEVEL LOG_LEVEL_VERBOSE /*------------------------------------------------*/ +<<<<<<< HEAD /*Main static configuration*/ //This cannot be changed via web inteface @@ -26,6 +27,7 @@ #define CONFIG_LED_COLOR_ORDER RGB #define CONFIG_LED_COUNT 50 +//OFF, RAINBOW, FIRE2012 #define CONFIG_LED_STANDARD_MODE FIRE2012 /*------------------------------------------------*/ From 1f30c317911fa2695c29e4c23376b0165e23567c Mon Sep 17 00:00:00 2001 From: SciLor Date: Sat, 29 Oct 2016 09:46:20 +0200 Subject: [PATCH 5/8] Implemented clearall command like clear command --- WrapperJsonServer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WrapperJsonServer.cpp b/WrapperJsonServer.cpp index dc5a3e1..e34e09e 100644 --- a/WrapperJsonServer.cpp +++ b/WrapperJsonServer.cpp @@ -57,7 +57,7 @@ void WrapperJsonServer::readData(void) { } else if (command.equals("color")) { ledColorWipe(root["color"][0], root["color"][1], root["color"][2]); _tcpClient.println("{\"success\":true}"); - } else if (command.equals("clear")) { + } else if (command.equals("clear") || command.equals("clearall")) { clearCmd(); _tcpClient.println("{\"success\":true}"); } else if (command.equals("effect")) { From 48bd2f0cce3e7ba4e7dba867d6825062eaf8997a Mon Sep 17 00:00:00 2001 From: SciLor Date: Sat, 29 Oct 2016 09:46:59 +0200 Subject: [PATCH 6/8] Removed unused comments --- WrapperJsonServer.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/WrapperJsonServer.cpp b/WrapperJsonServer.cpp index e34e09e..f7e2a93 100644 --- a/WrapperJsonServer.cpp +++ b/WrapperJsonServer.cpp @@ -48,8 +48,6 @@ void WrapperJsonServer::readData(void) { String command = root["command"].asString(); if (command.equals("serverinfo")) { Log.info("serverinfo"); - //_tcpClient.println("{\"success\":true}"); - //enum Mode { RAINBOW, STATIC_COLOR, AMBILIGHT, FIRE2012, OFF }; _tcpClient.println("{\"info\":{\"effects\":[" "{\"args\":{\"speed\":1.0},\"name\":\"Rainbow mood\",\"script\":\"rainbow\"}," "{\"args\":{\"speed\":1.0},\"name\":\"Fire2012\",\"script\":\"fire2012\"}" @@ -61,7 +59,6 @@ void WrapperJsonServer::readData(void) { clearCmd(); _tcpClient.println("{\"success\":true}"); } else if (command.equals("effect")) { - //{"command":"effect","effect":{"name":"Rainbow mood","args":{"speed":1}},"priority":50} String effect = root["effect"]["name"].asString(); int speed = root["effect"]["speed"]; From bbe0d3551919be6e7e635737f769d0066730e481 Mon Sep 17 00:00:00 2001 From: SciLor Date: Sat, 29 Oct 2016 09:48:26 +0200 Subject: [PATCH 7/8] Removed merge artefacts, logging to info --- ConfigStatic.h.example | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ConfigStatic.h.example b/ConfigStatic.h.example index 1fdd26a..fce43c6 100644 --- a/ConfigStatic.h.example +++ b/ConfigStatic.h.example @@ -9,12 +9,11 @@ /*------------------------------------------------*/ /*Logging level*/ -//#define LOGLEVEL LOG_LEVEL_INFOS +#define LOGLEVEL LOG_LEVEL_INFOS //#define LOGLEVEL LOG_LEVEL_DEBUG -#define LOGLEVEL LOG_LEVEL_VERBOSE +//#define LOGLEVEL LOG_LEVEL_VERBOSE /*------------------------------------------------*/ -<<<<<<< HEAD /*Main static configuration*/ //This cannot be changed via web inteface From 9278190a00dc3983b371db6a3fa9d1ac032ef1df Mon Sep 17 00:00:00 2001 From: SciLor Date: Sat, 29 Oct 2016 12:13:43 +0200 Subject: [PATCH 8/8] Fixed GPIO Order to RAW order. Otherwise PINs are mapped wrong --- WrapperFastLed.h | 5 +++++ WrapperWebconfig.h | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/WrapperFastLed.h b/WrapperFastLed.h index ab48017..e92262f 100644 --- a/WrapperFastLed.h +++ b/WrapperFastLed.h @@ -2,6 +2,11 @@ #define WrapperFastLed_h #include "BaseHeader.h" + +#define FASTLED_ESP8266_RAW_PIN_ORDER +//#define FASTLED_ESP8266_NODEMCU_PIN_ORDER +//#define FASTLED_ESP8266_D1_PIN_ORDER + #include class WrapperFastLed { diff --git a/WrapperWebconfig.h b/WrapperWebconfig.h index 5321732..fab9de5 100644 --- a/WrapperWebconfig.h +++ b/WrapperWebconfig.h @@ -3,7 +3,7 @@ #include "BaseHeader.h" #include -#include +#include "WrapperFastLed.h" #include class SelectEntryBase {