Merge branch 'wellenvogel:master' into master

This commit is contained in:
Norbert Walter 2024-09-20 12:44:29 +02:00 committed by GitHub
commit 5a6801b2d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 76 additions and 49 deletions

View File

@ -72,7 +72,7 @@ public:
if (handled > 0){
memmove(logBuffer,logBuffer+handled,wp-handled);
wp-=handled;
logBuffer[handled]=0;
logBuffer[wp]=0;
}
return;
}

View File

@ -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<GWLED_TYPE,GWLED_PIN,(EOrder)GWLED_SCHEMA>(leds,1);
#else
FastLED.addLeds<GWLED_TYPE,GWLED_PIN>(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<GWLED_TYPE, GWLED_PIN, (EOrder)GWLED_SCHEMA>(leds, 1);
#else
FastLED.addLeds<GWLED_TYPE, GWLED_PIN>(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
}
}
#endif

View File

@ -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

View File

@ -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

View File

@ -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 =