only link FastLED stuff when GWLED_FASTLED is defined
This commit is contained in:
parent
d63b4d1661
commit
55145726c3
|
@ -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,8 +21,10 @@ typedef enum {
|
|||
LED_WHITE
|
||||
} GwLedMode;
|
||||
|
||||
static CRGB::HTMLColorCode colorFromMode(GwLedMode cmode){
|
||||
switch(cmode){
|
||||
static CRGB::HTMLColorCode colorFromMode(GwLedMode cmode)
|
||||
{
|
||||
switch (cmode)
|
||||
{
|
||||
case LED_BLUE:
|
||||
return CRGB::Blue;
|
||||
case LED_GREEN:
|
||||
|
@ -24,27 +37,22 @@ static CRGB::HTMLColorCode colorFromMode(GwLedMode cmode){
|
|||
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, brightness=%d",(int)currentMode,(int)brightness);
|
||||
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
|
|
@ -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
|
Loading…
Reference in New Issue