From c2f990d42bb7b265fcc6bb27f943ebdcf05b52ea Mon Sep 17 00:00:00 2001 From: jdgarcia99 Date: Thu, 22 Aug 2024 16:44:24 +0200 Subject: [PATCH 1/6] Resync with OpenEVSE project --- platformio.ini | 21 ++++- src/LedManagerTask.cpp | 205 ++++++++++++++++++++++++++++++++++++++++- src/LedManagerTask.h | 13 +++ src/main.cpp | 4 + 4 files changed, 237 insertions(+), 6 deletions(-) diff --git a/platformio.ini b/platformio.ini index b00f8d3d..555d2687 100644 --- a/platformio.ini +++ b/platformio.ini @@ -122,6 +122,7 @@ build_partitions_debug = min_spiffs_debug.csv build_partitions_16mb = openevse_16mb.csv neopixel_lib = adafruit/Adafruit NeoPixel@1.12.3 +ws2812fx_lib = kitesurfer1404/WS2812FX@1.4.4 gfx_display_libs = # lvgl/lvgl@8.3.9 @@ -381,16 +382,32 @@ build_flags = [env:wt32-eth01] # For Wireless Tag board = wt32-eth01 +lib_deps = + ${common.lib_deps} + ${common.neopixel_lib} + ${common.ws2812fx_lib} + adafruit/Adafruit MCP9808 Library @ 1.1.2 build_flags = ${common.build_flags} ${common.src_build_flags} - -D WIFI_LED=12 - -D WIFI_LED_ON_STATE=HIGH + #-D WIFI_LED=12 + #-D WIFI_LED_ON_STATE=HIGH + -D NEO_PIXEL_PIN=12 + -D NEO_PIXEL_LENGTH=15 + -D ENABLE_WS2812FX + -D WIFI_PIXEL_NUMBER=1 -D WIFI_BUTTON=4 -D WIFI_BUTTON_PRESSED_STATE=LOW # -D DEBUG_PORT=Serial -D RAPI_PORT=Serial2 + # Need to comment pin definition for SDA and SCL at .platformio/packages/framework-arduinoespressif32/variants/wt32-eth01/pins_arduino.h + -D I2C_SDA=2 + -D I2C_SCL=4 + -D SDA=2 + -D SCL=4 -D ENABLE_WIRED_ETHERNET + -D ENABLE_MCP9808 + -D ENABLE_PN532 -D RESET_ETH_PHY_ON_BOOT=1 -D RX2=5 -D TX2=17 diff --git a/src/LedManagerTask.cpp b/src/LedManagerTask.cpp index ecd2118a..c721d499 100644 --- a/src/LedManagerTask.cpp +++ b/src/LedManagerTask.cpp @@ -30,9 +30,12 @@ #include "emonesp.h" #include "LedManagerTask.h" -#if defined(NEO_PIXEL_PIN) && defined(NEO_PIXEL_LENGTH) +#if defined(NEO_PIXEL_PIN) && defined(NEO_PIXEL_LENGTH) && !defined(ENABLE_WS2812FX) #include Adafruit_NeoPixel strip = Adafruit_NeoPixel(NEO_PIXEL_LENGTH, NEO_PIXEL_PIN, NEO_GRB + NEO_KHZ800); +#elif defined(NEO_PIXEL_PIN) && defined(NEO_PIXEL_LENGTH) && defined(ENABLE_WS2812FX) +#include +WS2812FX ws2812fx = WS2812FX(NEO_PIXEL_LENGTH, NEO_PIXEL_PIN, NEO_GRB + NEO_KHZ800); #endif #define FADE_STEP 16 @@ -41,6 +44,13 @@ Adafruit_NeoPixel strip = Adafruit_NeoPixel(NEO_PIXEL_LENGTH, NEO_PIXEL_PIN, NEO #define CONNECTING_FLASH_TIME 450 #define CONNECTED_FLASH_TIME 250 +#if defined(ENABLE_WS2812FX) +// Speed for FX Bar Effects +#define DEFAULT_FX_SPEED 1000 +#define CONNECTING_FX_SPEED 2000 +#define CONNECTED_FX_SPEED 1000 +#endif + #define TEST_LED_TIME 500 #if defined(RED_LED) && defined(GREEN_LED) && defined(BLUE_LED) @@ -91,6 +101,41 @@ uint8_t buttonShareState = 0; #define rgb(r,g,b) (r<<16|g<<8|b) +#if defined(NEO_PIXEL_PIN) && defined(NEO_PIXEL_LENGTH) && defined(ENABLE_WS2812FX) + +static uint32_t status_colour_map(u_int8_t lcdcol) +{ + u_int32_t color; + switch (lcdcol) + { + case OPENEVSE_LCD_OFF: + color = 0x000000; // BLACK + break; + case OPENEVSE_LCD_RED: + color = 0xFF0000; // RED + break; + case OPENEVSE_LCD_GREEN: + color = 0x00FF00; // GREEN + break; + case OPENEVSE_LCD_YELLOW: + color = 0xFFFF00; // YELLOW + break; + case OPENEVSE_LCD_BLUE: + color = 0x0000FF; // BLUE + break; + case OPENEVSE_LCD_VIOLET: + color = 0xFF00FF; // VIOLET + break; + case OPENEVSE_LCD_TEAL: + color = 0x00FFFF; // TEAL + break; + case OPENEVSE_LCD_WHITE: + color = 0xFFFFFF; // WHITE + break; + } + return color; // WHITE +} +#else static uint32_t status_colour_map[] = { rgb(0, 0, 0), // OPENEVSE_LCD_OFF @@ -103,6 +148,7 @@ static uint32_t status_colour_map[] = rgb(255, 255, 255), // OPENEVSE_LCD_WHITE }; #endif +#endif LedManagerTask::LedManagerTask() : MicroTasks::Task(), @@ -125,11 +171,22 @@ void LedManagerTask::begin(EvseManager &evse) void LedManagerTask::setup() { -#if defined(NEO_PIXEL_PIN) && defined(NEO_PIXEL_LENGTH) +#if defined(NEO_PIXEL_PIN) && defined(NEO_PIXEL_LENGTH) && !defined(ENABLE_WS2812FX) DBUGF("Initialising NeoPixels"); strip.begin(); //strip.setBrightness(brightness); setAllRGB(0, 0, 0); +#elif defined(NEO_PIXEL_PIN) && defined(NEO_PIXEL_LENGTH) && defined(ENABLE_WS2812FX) + DEBUG.printf("Initialising NeoPixels WS2812FX MODE...\n"); + ws2812fx.init(); + ws2812fx.setBrightness(brightness); + ws2812fx.setSpeed(DEFAULT_FX_SPEED); + ws2812fx.setColor(BLACK); + ws2812fx.setMode(FX_MODE_STATIC); + //ws2812fx.setBrightness(this->brightness); + DEBUG.printf("Brightness: %d ", this->brightness); + DEBUG.printf("Brightness: %d ", brightness); + ws2812fx.start(); #endif #if defined(RED_LED) && defined(GREEN_LED) && defined(BLUE_LED) @@ -179,6 +236,100 @@ unsigned long LedManagerTask::loop(MicroTasks::WakeReason reason) } #if RGB_LED +#if defined(NEO_PIXEL_PIN) && defined(NEO_PIXEL_LENGTH) && defined(ENABLE_WS2812FX) + switch(state) + { + case LedState_Off: + //setAllRGB(0, 0, 0); + ws2812fx.setColor(BLACK); + return MicroTask.Infinate; + + case LedState_Test_Red: + //setAllRGB(255, 0, 0); + ws2812fx.setColor(RED); + state = LedState_Test_Green; + return TEST_LED_TIME; + + case LedState_Test_Green: + //setAllRGB(0, 255, 0); + ws2812fx.setColor(GREEN); + state = LedState_Test_Blue; + return TEST_LED_TIME; + + case LedState_Test_Blue: + //setAllRGB(0, 0, 255); + ws2812fx.setColor(BLUE); + state = LedState_Off; + setNewState(false); + return TEST_LED_TIME; + + + case LedState_Evse_State: + case LedState_WiFi_Access_Point_Waiting: + case LedState_WiFi_Access_Point_Connected: + case LedState_WiFi_Client_Connecting: + case LedState_WiFi_Client_Connected: + { + uint8_t lcdCol = _evse->getStateColour(); + DBUGVAR(lcdCol); + uint32_t col = status_colour_map(lcdCol); + DBUGVAR(col, HEX); + //DEBUG.printf("Color: %x\n", col); + bool isCharging; + u_int16_t speed; + speed = 2000 - ((_evse->getChargeCurrent()/_evse->getMaxHardwareCurrent())*1000); + DEBUG.printf("Speed: %d ",speed); + DEBUG.printf("Amps: %d ", _evse->getAmps()); + DEBUG.printf("ChargeCurrent: %d ", _evse->getChargeCurrent()); + DEBUG.printf("MaxHWCurrent: %d ", _evse->getMaxHardwareCurrent()); + if (this->brightness == 0){ + ws2812fx.setBrightness(255); + } + else { + ws2812fx.setBrightness(this->brightness-1); + } + switch(state) + { + case LedState_Evse_State: + isCharging = _evse->isCharging(); + if(isCharging){ + setAllRGB(col, FX_MODE_COLOR_WIPE, speed); + } + else { + setAllRGB(col, FX_MODE_STATIC, DEFAULT_FX_SPEED); + } + //DEBUG.printf("MODO: LedState_Evse_State\n"); + return MicroTask.Infinate; + + case LedState_WiFi_Access_Point_Waiting: + setEvseAndWifiRGB(col, FX_MODE_BLINK, CONNECTING_FX_SPEED); + //DEBUG.printf("MODO: LedState_WiFi_Access_Point_Waiting\n"); + return CONNECTING_FLASH_TIME; + + case LedState_WiFi_Access_Point_Connected: + setEvseAndWifiRGB(col, FX_MODE_FADE, CONNECTED_FX_SPEED); + flashState = !flashState; + //DEBUG.printf("MODO: LedState_WiFi_Access_Point_Connected\n"); + return CONNECTED_FLASH_TIME; + + case LedState_WiFi_Client_Connecting: + setEvseAndWifiRGB(col, FX_MODE_FADE, CONNECTING_FX_SPEED); + flashState = !flashState; + //DEBUG.printf("MODO: LedState_WiFi_Client_Connecting\n"); + return CONNECTING_FLASH_TIME; + + case LedState_WiFi_Client_Connected: + setEvseAndWifiRGB(col, FX_MODE_FADE, CONNECTED_FX_SPEED); + //DEBUG.printf("MODO: LedState_WiFi_Client_Connected\n"); + return MicroTask.Infinate; + + default: + break; + } + } + + } +#else switch(state) { case LedState_Off: @@ -279,6 +430,7 @@ unsigned long LedManagerTask::loop(MicroTasks::WakeReason reason) #endif } #endif +#endif #ifdef WIFI_LED switch(state) @@ -339,13 +491,39 @@ int LedManagerTask::fadeLed(int fadeValue, int FadeDir) */ #if RGB_LED +#if defined(NEO_PIXEL_PIN) && defined(NEO_PIXEL_LENGTH) && defined(ENABLE_WS2812FX) +void LedManagerTask::setAllRGB(uint32_t color, u_int8_t mode, uint16_t speed) +{ + setEvseAndWifiRGB(color, mode, speed); +} + + +void LedManagerTask::setEvseAndWifiRGB(uint32_t evseColor, u_int8_t mode, u_int16_t speed) +{ + DBUG("EVSE LED COLOR:"); + DBUG(evseColor); + if(evseColor != ws2812fx.getColor()){ + ws2812fx.setColor(evseColor); + } + + if(speed != ws2812fx.getSpeed()){ + ws2812fx.setSpeed(speed); + } + + if (ws2812fx.getMode() != mode){ + ws2812fx.setMode(mode); + } + +} +#else void LedManagerTask::setAllRGB(uint8_t red, uint8_t green, uint8_t blue) { setEvseAndWifiRGB(red, green, blue, red, green, blue); } #endif +#endif -#if WIFI_PIXEL_NUMBER +#if WIFI_PIXEL_NUMBER && !defined(ENABLE_WS2812FX) void LedManagerTask::setEvseAndWifiRGB(uint8_t evseRed, uint8_t evseGreen, uint8_t evseBlue, uint8_t wifiRed, uint8_t wifiGreen, uint8_t wifiBlue) { DBUG("EVSE LED R:"); @@ -385,7 +563,7 @@ void LedManagerTask::setEvseAndWifiRGB(uint8_t evseRed, uint8_t evseGreen, uint8 DBUG(" B:"); DBUGLN(wifiBlue); -#if defined(NEO_PIXEL_PIN) && defined(NEO_PIXEL_LENGTH) +#if defined(NEO_PIXEL_PIN) && defined(NEO_PIXEL_LENGTH) && !defined(ENABLE_WS2812FX) uint32_t col = strip.gamma32(strip.Color(evseRed, evseGreen, evseBlue)); DBUGVAR(col, HEX); strip.fill(col); @@ -549,6 +727,18 @@ void LedManagerTask::setBrightness(uint8_t brightness) // brightness (off), 255 = just below max brightness. this->brightness = brightness + 1; +#if defined(NEO_PIXEL_PIN) && defined(NEO_PIXEL_LENGTH) && defined(ENABLE_WS2812FX) +// This controls changes on the limits of the web interface slidebar. +// Otherwise it gets out of sync + if (this->brightness == 0){ + ws2812fx.setBrightness(255); + } + else { + ws2812fx.setBrightness(this->brightness-1); + } + +#endif + DBUGVAR(this->brightness); // Wake the task to refresh the state @@ -556,3 +746,10 @@ void LedManagerTask::setBrightness(uint8_t brightness) } LedManagerTask ledManager; + +#if defined(NEO_PIXEL_PIN) && defined(NEO_PIXEL_LENGTH) && defined(ENABLE_WS2812FX) +extern void ledManager_loop() +{ + ws2812fx.service(); +} +#endif \ No newline at end of file diff --git a/src/LedManagerTask.h b/src/LedManagerTask.h index 28cb4d12..8eb633e0 100644 --- a/src/LedManagerTask.h +++ b/src/LedManagerTask.h @@ -44,9 +44,14 @@ class LedManagerTask : public MicroTasks::Task MicroTasks::EventListener onStateChange; #if RGB_LED +#if defined(NEO_PIXEL_PIN) && defined(NEO_PIXEL_LENGTH) && defined(ENABLE_WS2812FX) + void setAllRGB(uint32_t color, u_int8_t mode, u_int16_t speed); + void setEvseAndWifiRGB(uint32_t evseColor, u_int8_t mode, u_int16_t speed); +#else void setAllRGB(uint8_t red, uint8_t green, uint8_t blue); void setEvseAndWifiRGB(uint8_t evseRed, uint8_t evseGreen, uint8_t evseBlue, uint8_t wifiRed, uint8_t wifiGreen, uint8_t wifiBlue); #endif +#endif #ifdef WIFI_LED void setWiFiLed(uint8_t state); @@ -77,4 +82,12 @@ class LedManagerTask : public MicroTasks::Task extern LedManagerTask ledManager; +// ------------------------------------------------------------------- +// Perform the background status bar operations. Must be called in the main +// loop function +// ------------------------------------------------------------------- +#if defined(NEO_PIXEL_PIN) && defined(NEO_PIXEL_LENGTH) && defined(ENABLE_WS2812FX) +extern void ledManager_loop(); +#endif + #endif // LED_MANAGER_TASK_H diff --git a/src/main.cpp b/src/main.cpp index cf77d485..6fc75b79 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -215,6 +215,10 @@ loop() { MicroTask.update(); Profile_End(MicroTask, 10); +#if defined(NEO_PIXEL_PIN) && defined(NEO_PIXEL_LENGTH) && defined(ENABLE_WS2812FX) + ledManager_loop(); +#endif + if(OpenEVSE.isConnected()) { if(OPENEVSE_STATE_STARTING != evse.getEvseState()) From 765252fb67777df75760e2c9804a008bb9eab0de Mon Sep 17 00:00:00 2001 From: jdgarcia99 Date: Thu, 22 Aug 2024 18:08:38 +0200 Subject: [PATCH 2/6] Created individual env for wt32-et01 board with 2812 led bar --- platformio.ini | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/platformio.ini b/platformio.ini index 555d2687..01e46b9d 100644 --- a/platformio.ini +++ b/platformio.ini @@ -379,9 +379,33 @@ build_flags = -D RX1=25 -D TX1=27 + [env:wt32-eth01] # For Wireless Tag board = wt32-eth01 +build_flags = + ${common.build_flags} + ${common.src_build_flags} + -D WIFI_LED=12 + -D WIFI_LED_ON_STATE=HIGH + -D WIFI_BUTTON=4 + -D WIFI_BUTTON_PRESSED_STATE=LOW + # -D DEBUG_PORT=Serial + -D RAPI_PORT=Serial2 + -D ENABLE_WIRED_ETHERNET + -D RESET_ETH_PHY_ON_BOOT=1 + -D RX2=5 + -D TX2=17 + -D ETH_PHY_TYPE=ETH_PHY_LAN8720 + -D ETH_PHY_ADDR=1 + -D ETH_PHY_MDC=23 + -D ETH_PHY_MDIO=18 + -D ETH_CLK_MODE=ETH_CLOCK_GPIO0_IN + -D ETH_PHY_POWER=16 + +[env:wt32-eth01-ws2812] +# For Wireless Tag +board = wt32-eth01 lib_deps = ${common.lib_deps} ${common.neopixel_lib} @@ -400,14 +424,16 @@ build_flags = -D WIFI_BUTTON_PRESSED_STATE=LOW # -D DEBUG_PORT=Serial -D RAPI_PORT=Serial2 + # If using PN532 RFID reader through I2C # Need to comment pin definition for SDA and SCL at .platformio/packages/framework-arduinoespressif32/variants/wt32-eth01/pins_arduino.h - -D I2C_SDA=2 - -D I2C_SCL=4 - -D SDA=2 - -D SCL=4 + #-D I2C_SDA=2 + #-D I2C_SCL=4 + #-D ENABLE_PN532 + # If Using MCP9808 + #-D SDA=2 + #-D SCL=4 + #-D ENABLE_MCP9808 -D ENABLE_WIRED_ETHERNET - -D ENABLE_MCP9808 - -D ENABLE_PN532 -D RESET_ETH_PHY_ON_BOOT=1 -D RX2=5 -D TX2=17 From 888c9ca853259a64301517515f45fe90e3dbcb00 Mon Sep 17 00:00:00 2001 From: jdgarcia99 Date: Thu, 29 Aug 2024 19:25:12 +0200 Subject: [PATCH 3/6] Update src/LedManagerTask.cpp Co-authored-by: Jeremy Poulter --- src/LedManagerTask.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/LedManagerTask.cpp b/src/LedManagerTask.cpp index c721d499..4bab56c7 100644 --- a/src/LedManagerTask.cpp +++ b/src/LedManagerTask.cpp @@ -184,8 +184,8 @@ void LedManagerTask::setup() ws2812fx.setColor(BLACK); ws2812fx.setMode(FX_MODE_STATIC); //ws2812fx.setBrightness(this->brightness); - DEBUG.printf("Brightness: %d ", this->brightness); - DEBUG.printf("Brightness: %d ", brightness); + DBUGF("Brightness: %d ", this->brightness); + DBUGF("Brightness: %d ", brightness); ws2812fx.start(); #endif From fe8dfa12c6f6ee14403d56862467b600885275a6 Mon Sep 17 00:00:00 2001 From: jdgarcia99 Date: Fri, 30 Aug 2024 02:10:17 +0200 Subject: [PATCH 4/6] Changes to acommodate PR899 requirements for main loop call --- src/LedManagerTask.cpp | 8 ++++---- src/LedManagerTask.h | 13 ++++++------- src/main.cpp | 3 ++- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/LedManagerTask.cpp b/src/LedManagerTask.cpp index c721d499..8ff50cd0 100644 --- a/src/LedManagerTask.cpp +++ b/src/LedManagerTask.cpp @@ -745,11 +745,11 @@ void LedManagerTask::setBrightness(uint8_t brightness) MicroTask.wakeTask(this); } -LedManagerTask ledManager; - #if defined(NEO_PIXEL_PIN) && defined(NEO_PIXEL_LENGTH) && defined(ENABLE_WS2812FX) -extern void ledManager_loop() +void LedManagerTask::service() { ws2812fx.service(); } -#endif \ No newline at end of file +#endif + +LedManagerTask ledManager; \ No newline at end of file diff --git a/src/LedManagerTask.h b/src/LedManagerTask.h index 8eb633e0..f08a5f21 100644 --- a/src/LedManagerTask.h +++ b/src/LedManagerTask.h @@ -78,16 +78,15 @@ class LedManagerTask : public MicroTasks::Task int getButtonPressed(); void setBrightness(uint8_t brightness); -}; - -extern LedManagerTask ledManager; - +#if defined(NEO_PIXEL_PIN) && defined(NEO_PIXEL_LENGTH) && defined(ENABLE_WS2812FX) // ------------------------------------------------------------------- // Perform the background status bar operations. Must be called in the main // loop function // ------------------------------------------------------------------- -#if defined(NEO_PIXEL_PIN) && defined(NEO_PIXEL_LENGTH) && defined(ENABLE_WS2812FX) -extern void ledManager_loop(); + void service(); #endif +}; + +extern LedManagerTask ledManager; -#endif // LED_MANAGER_TASK_H +#endif // LED_MANAGER_TASK_H \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 6fc75b79..f25928a0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -216,7 +216,8 @@ loop() { Profile_End(MicroTask, 10); #if defined(NEO_PIXEL_PIN) && defined(NEO_PIXEL_LENGTH) && defined(ENABLE_WS2812FX) - ledManager_loop(); + // Call ws2812fx service method to update ledbar effect + ledManager.service(); #endif if(OpenEVSE.isConnected()) From d8ae1a625780ff69d5804a6d01971f80dd1f06bd Mon Sep 17 00:00:00 2001 From: jdgarcia99 Date: Sat, 31 Aug 2024 00:55:46 +0200 Subject: [PATCH 5/6] Changes for PR899 as Suggested by jeremypoulter to reuse MicroTasks for ledBar animations. DEBUG calls cleaned --- src/LedManagerTask.cpp | 39 +++++++++++++++++++++++---------------- src/LedManagerTask.h | 7 ------- src/main.cpp | 5 ----- 3 files changed, 23 insertions(+), 28 deletions(-) diff --git a/src/LedManagerTask.cpp b/src/LedManagerTask.cpp index 5ecacbef..5da6156c 100644 --- a/src/LedManagerTask.cpp +++ b/src/LedManagerTask.cpp @@ -36,6 +36,17 @@ Adafruit_NeoPixel strip = Adafruit_NeoPixel(NEO_PIXEL_LENGTH, NEO_PIXEL_PIN, NEO #elif defined(NEO_PIXEL_PIN) && defined(NEO_PIXEL_LENGTH) && defined(ENABLE_WS2812FX) #include WS2812FX ws2812fx = WS2812FX(NEO_PIXEL_LENGTH, NEO_PIXEL_PIN, NEO_GRB + NEO_KHZ800); + +class LedAnimatorTask : public MicroTasks::Task +{ + public: + void setup() { + } + unsigned long loop(MicroTasks::WakeReason reason) { + ws2812fx.service(); + return 40; + } +} animator; #endif #define FADE_STEP 16 @@ -186,7 +197,9 @@ void LedManagerTask::setup() //ws2812fx.setBrightness(this->brightness); DBUGF("Brightness: %d ", this->brightness); DBUGF("Brightness: %d ", brightness); + ws2812fx.start(); + MicroTask.startTask(&animator); #endif #if defined(RED_LED) && defined(GREEN_LED) && defined(BLUE_LED) @@ -274,14 +287,14 @@ unsigned long LedManagerTask::loop(MicroTasks::WakeReason reason) DBUGVAR(lcdCol); uint32_t col = status_colour_map(lcdCol); DBUGVAR(col, HEX); - //DEBUG.printf("Color: %x\n", col); + //DBUGF("Color: %x\n", col); bool isCharging; u_int16_t speed; speed = 2000 - ((_evse->getChargeCurrent()/_evse->getMaxHardwareCurrent())*1000); - DEBUG.printf("Speed: %d ",speed); - DEBUG.printf("Amps: %d ", _evse->getAmps()); - DEBUG.printf("ChargeCurrent: %d ", _evse->getChargeCurrent()); - DEBUG.printf("MaxHWCurrent: %d ", _evse->getMaxHardwareCurrent()); + DBUGF("Speed: %d ",speed); + DBUGF("Amps: %d ", _evse->getAmps()); + DBUGF("ChargeCurrent: %d ", _evse->getChargeCurrent()); + DBUGF("MaxHWCurrent: %d ", _evse->getMaxHardwareCurrent()); if (this->brightness == 0){ ws2812fx.setBrightness(255); } @@ -298,29 +311,29 @@ unsigned long LedManagerTask::loop(MicroTasks::WakeReason reason) else { setAllRGB(col, FX_MODE_STATIC, DEFAULT_FX_SPEED); } - //DEBUG.printf("MODO: LedState_Evse_State\n"); + //DBUGF("MODE: LedState_Evse_State\n"); return MicroTask.Infinate; case LedState_WiFi_Access_Point_Waiting: setEvseAndWifiRGB(col, FX_MODE_BLINK, CONNECTING_FX_SPEED); - //DEBUG.printf("MODO: LedState_WiFi_Access_Point_Waiting\n"); + //DBUGF("MODE: LedState_WiFi_Access_Point_Waiting\n"); return CONNECTING_FLASH_TIME; case LedState_WiFi_Access_Point_Connected: setEvseAndWifiRGB(col, FX_MODE_FADE, CONNECTED_FX_SPEED); flashState = !flashState; - //DEBUG.printf("MODO: LedState_WiFi_Access_Point_Connected\n"); + //DBUGF("MODE: LedState_WiFi_Access_Point_Connected\n"); return CONNECTED_FLASH_TIME; case LedState_WiFi_Client_Connecting: setEvseAndWifiRGB(col, FX_MODE_FADE, CONNECTING_FX_SPEED); flashState = !flashState; - //DEBUG.printf("MODO: LedState_WiFi_Client_Connecting\n"); + //DBUGF("MODE: LedState_WiFi_Client_Connecting\n"); return CONNECTING_FLASH_TIME; case LedState_WiFi_Client_Connected: setEvseAndWifiRGB(col, FX_MODE_FADE, CONNECTED_FX_SPEED); - //DEBUG.printf("MODO: LedState_WiFi_Client_Connected\n"); + //DBUGF("MODOE: LedState_WiFi_Client_Connected\n"); return MicroTask.Infinate; default: @@ -745,11 +758,5 @@ void LedManagerTask::setBrightness(uint8_t brightness) MicroTask.wakeTask(this); } -#if defined(NEO_PIXEL_PIN) && defined(NEO_PIXEL_LENGTH) && defined(ENABLE_WS2812FX) -void LedManagerTask::service() -{ - ws2812fx.service(); -} -#endif LedManagerTask ledManager; \ No newline at end of file diff --git a/src/LedManagerTask.h b/src/LedManagerTask.h index f08a5f21..61d05d85 100644 --- a/src/LedManagerTask.h +++ b/src/LedManagerTask.h @@ -78,13 +78,6 @@ class LedManagerTask : public MicroTasks::Task int getButtonPressed(); void setBrightness(uint8_t brightness); -#if defined(NEO_PIXEL_PIN) && defined(NEO_PIXEL_LENGTH) && defined(ENABLE_WS2812FX) -// ------------------------------------------------------------------- -// Perform the background status bar operations. Must be called in the main -// loop function -// ------------------------------------------------------------------- - void service(); -#endif }; extern LedManagerTask ledManager; diff --git a/src/main.cpp b/src/main.cpp index f25928a0..cf77d485 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -215,11 +215,6 @@ loop() { MicroTask.update(); Profile_End(MicroTask, 10); -#if defined(NEO_PIXEL_PIN) && defined(NEO_PIXEL_LENGTH) && defined(ENABLE_WS2812FX) - // Call ws2812fx service method to update ledbar effect - ledManager.service(); -#endif - if(OpenEVSE.isConnected()) { if(OPENEVSE_STATE_STARTING != evse.getEvseState()) From e73981c2e34c491d5d85e06da6c755d78457f1f6 Mon Sep 17 00:00:00 2001 From: jdgarcia99 Date: Sat, 31 Aug 2024 12:49:53 +0200 Subject: [PATCH 6/6] Adjust 10 ms refresh timer as best approach ro run ledBar Task smoothly --- src/LedManagerTask.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LedManagerTask.cpp b/src/LedManagerTask.cpp index 5da6156c..9003fb95 100644 --- a/src/LedManagerTask.cpp +++ b/src/LedManagerTask.cpp @@ -44,7 +44,7 @@ class LedAnimatorTask : public MicroTasks::Task } unsigned long loop(MicroTasks::WakeReason reason) { ws2812fx.service(); - return 40; + return 10; } } animator; #endif