From 4903fd3a7ca661cf14bf30f62084f5ad8be82f7c Mon Sep 17 00:00:00 2001 From: SciLor Date: Sat, 5 May 2018 15:13:06 +0200 Subject: [PATCH] ESP32 compatibility -Added hint for right onboard LED -Workaround for the EnhancedThread compiling problems -ESP32Webserver now used for ESP32 --- HyperionRGB/EnhancedThread.cpp | 31 ++++++------------------------- HyperionRGB/EnhancedThread.h | 25 ++++++++++++++++++++++++- HyperionRGB/HyperionRGB.ino | 2 +- HyperionRGB/WrapperWebconfig.h | 10 +++++++--- 4 files changed, 38 insertions(+), 30 deletions(-) diff --git a/HyperionRGB/EnhancedThread.cpp b/HyperionRGB/EnhancedThread.cpp index 1f87208..d7b08de 100644 --- a/HyperionRGB/EnhancedThread.cpp +++ b/HyperionRGB/EnhancedThread.cpp @@ -1,25 +1,6 @@ -#include "EnhancedThread.h" - -void EnhancedThread::run() { - Thread::run(); - if (_runOnce) - Thread::enabled = false; -} - -void EnhancedThread::runIfNeeded(void) { - if(Thread::shouldRun()) - Thread::run(); -} - -void EnhancedThread::reset(void) { - Thread::enabled = true; - Thread::runned(); -} - -void EnhancedThread::setRunOnce(bool runOnce) { - _runOnce = runOnce; -} -unsigned long EnhancedThread::getInterval(void) { - return interval; -} - +//#include "EnhancedThread.h" +/* + * Put everything into the EnhancedThread.h to make it compatible with the ESP32 + * There seems to be a bug in the ArduinoThread lib + * + */ diff --git a/HyperionRGB/EnhancedThread.h b/HyperionRGB/EnhancedThread.h index 1a53491..6bd20d5 100644 --- a/HyperionRGB/EnhancedThread.h +++ b/HyperionRGB/EnhancedThread.h @@ -4,7 +4,7 @@ #include "BaseHeader.h" #include -class EnhancedThread: public Thread { +class EnhancedThread : public Thread { public: void run(void), @@ -16,4 +16,27 @@ class EnhancedThread: public Thread { bool _runOnce; }; +void EnhancedThread::run() { + Thread::run(); + if (_runOnce) + Thread::enabled = false; +} + +void EnhancedThread::runIfNeeded(void) { + if(Thread::shouldRun()) + Thread::run(); +} + +void EnhancedThread::reset(void) { + Thread::enabled = true; + Thread::runned(); +} + +void EnhancedThread::setRunOnce(bool runOnce) { + _runOnce = runOnce; +} +unsigned long EnhancedThread::getInterval(void) { + return interval; +} + #endif diff --git a/HyperionRGB/HyperionRGB.ino b/HyperionRGB/HyperionRGB.ino index 6f5d9e9..868230a 100644 --- a/HyperionRGB/HyperionRGB.ino +++ b/HyperionRGB/HyperionRGB.ino @@ -15,7 +15,7 @@ #include "WrapperWebconfig.h" -#define LED D0 // LED in NodeMCU at pin GPIO16 (D0). +#define LED LED_BUILTIN // LED in NodeMCU at pin GPIO16 (D0) or LED_BUILTIN @Lolin32. int ledState = LOW; LoggerInit loggerInit; diff --git a/HyperionRGB/WrapperWebconfig.h b/HyperionRGB/WrapperWebconfig.h index 59bdcb0..85ba1ae 100644 --- a/HyperionRGB/WrapperWebconfig.h +++ b/HyperionRGB/WrapperWebconfig.h @@ -78,9 +78,13 @@ class WrapperWebconfig { template T getSelectedEntry(String selectedEntryValue, LinkedList* target); - LinkedList* _idleModes;; - - ESP8266WebServer _server = ESP8266WebServer(80); + LinkedList* _idleModes; + + #if defined(ESP8266) + ESP8266WebServer _server = ESP8266WebServer(80); + #elif defined(ESP32) + ESP32WebServer _server = ESP32WebServer(80); + #endif }; #endif