diff --git a/lib/channel/GwChannelList.cpp b/lib/channel/GwChannelList.cpp index a118f13..c736ae2 100644 --- a/lib/channel/GwChannelList.cpp +++ b/lib/channel/GwChannelList.cpp @@ -72,7 +72,7 @@ public: if (handled > 0){ memmove(logBuffer,logBuffer+handled,wp-handled); wp-=handled; - logBuffer[handled]=0; + logBuffer[wp]=0; } return; } diff --git a/lib/ledtask/GwLedTask.cpp b/lib/ledtask/GwLedTask.cpp index 5df1e9d..0a03005 100644 --- a/lib/ledtask/GwLedTask.cpp +++ b/lib/ledtask/GwLedTask.cpp @@ -1,8 +1,19 @@ #include "GwLedTask.h" #include "GwHardware.h" #include "GwApi.h" + +void handleLeds(GwApi *api); +void initLeds(GwApi *param) +{ +#ifdef GWLED_FASTLED + param->addUserTask(handleLeds, "handleLeds"); +#endif +} + +#ifdef GWLED_FASTLED #include "FastLED.h" -typedef enum { +typedef enum +{ LED_OFF, LED_GREEN, LED_BLUE, @@ -10,41 +21,38 @@ typedef enum { LED_WHITE } GwLedMode; -static CRGB::HTMLColorCode colorFromMode(GwLedMode cmode){ - switch(cmode){ - case LED_BLUE: - return CRGB::Blue; - case LED_GREEN: - return CRGB::Green; - case LED_RED: - return CRGB::Red; - case LED_WHITE: - return CRGB::White; - default: - return CRGB::Black; +static CRGB::HTMLColorCode colorFromMode(GwLedMode cmode) +{ + switch (cmode) + { + case LED_BLUE: + return CRGB::Blue; + case LED_GREEN: + return CRGB::Green; + case LED_RED: + return CRGB::Red; + case LED_WHITE: + return CRGB::White; + default: + return CRGB::Black; } } -void handleLeds(GwApi *api){ - GwLog *logger=api->getLogger(); - #ifndef GWLED_FASTLED - LOG_DEBUG(GwLog::LOG,"currently only fastled handling"); - delay(50); - vTaskDelete(NULL); - return; - #else +void handleLeds(GwApi *api) +{ + GwLog *logger = api->getLogger(); CRGB leds[1]; - #ifdef GWLED_SCHEMA - FastLED.addLeds(leds,1); - #else - FastLED.addLeds(leds,1); - #endif - uint8_t brightness=api->getConfig()->getInt(GwConfigDefinitions::ledBrightness,128); - GwLedMode currentMode=LED_GREEN; - leds[0]=colorFromMode(currentMode); +#ifdef GWLED_SCHEMA + FastLED.addLeds(leds, 1); +#else + FastLED.addLeds(leds, 1); +#endif + uint8_t brightness = api->getConfig()->getInt(GwConfigDefinitions::ledBrightness, 128); + GwLedMode currentMode = LED_GREEN; + leds[0] = colorFromMode(currentMode); FastLED.setBrightness(brightness); FastLED.show(); - LOG_DEBUG(GwLog::LOG,"led task started with mode %d",(int)currentMode); - int apiResult=0; + LOG_DEBUG(GwLog::LOG, "led task started with mode %d, brightness=%d", (int)currentMode, (int)brightness); + int apiResult = 0; while (true) { delay(50); @@ -77,5 +85,5 @@ void handleLeds(GwApi *api){ } } vTaskDelete(NULL); - #endif -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/lib/ledtask/GwLedTask.h b/lib/ledtask/GwLedTask.h index 2ae1532..03cb980 100644 --- a/lib/ledtask/GwLedTask.h +++ b/lib/ledtask/GwLedTask.h @@ -1,8 +1,9 @@ #ifndef _GWLEDS_H #define _GWLEDS_H #include "GwApi.h" -//task function -void handleLeds(GwApi *param); +//task init function -DECLARE_USERTASK(handleLeds); +void initLeds(GwApi *param); + +DECLARE_INITFUNCTION(initLeds); #endif \ No newline at end of file diff --git a/lib/ledtask/platformio.ini b/lib/ledtask/platformio.ini new file mode 100644 index 0000000..c883d3b --- /dev/null +++ b/lib/ledtask/platformio.ini @@ -0,0 +1,15 @@ +[platformio] +#if you want a pio run to only build +#your special environments you can set this here +#by uncommenting the next line +#default_envs = testboard +[env:nodemculed] +board = nodemcu-32s +lib_deps = ${env.lib_deps} +build_flags = + -D BOARD_HOMBERGER + -D GWLED_CODE=1 + -D GWLED_PIN=33 + ${env.build_flags} +upload_port = /dev/esp32 +upload_protocol = esptool diff --git a/platformio.ini b/platformio.ini index b249ef8..0616d7f 100644 --- a/platformio.ini +++ b/platformio.ini @@ -16,6 +16,19 @@ default_envs= extra_configs= lib/*task*/platformio.ini +[basedeps] +lib_deps = + ttlappalainen/NMEA2000-library @ 4.18.9 + ttlappalainen/NMEA0183 @ 1.9.1 + ArduinoJson @ 6.18.5 + AsyncTCP-esphome @ 2.0.1 + ottowinter/ESPAsyncWebServer-esphome@2.0.1 + FS + Preferences + ESPmDNS + WiFi + Update + [env] platform = espressif32 @ 6.3.2 framework = arduino @@ -23,18 +36,8 @@ framework = arduino ; framework-arduinoespressif32 @ 3.20011.230801 ; framework-espidf @ 3.50101.0 lib_deps = - ttlappalainen/NMEA2000-library @ 4.18.9 - ttlappalainen/NMEA0183 @ 1.9.1 - ArduinoJson @ 6.18.5 - AsyncTCP-esphome @ 2.0.1 - ottowinter/ESPAsyncWebServer-esphome@2.0.1 - fastled/FastLED @ 3.6.0 - FS - Preferences - ESPmDNS - WiFi - Update - + ${basedeps.lib_deps} + fastled/FastLED @ 3.6.0 board_build.embed_files =