handle the leds as user task

This commit is contained in:
andreas 2023-10-24 15:23:54 +02:00
parent 155c7a8d1c
commit 91c1e6f85c
4 changed files with 9 additions and 8 deletions

View File

@ -1,7 +1,7 @@
#include "GwButtons.h"
#include "GwHardware.h"
#include "GwApi.h"
#include "GwLeds.h"
#include "GwLedTask.h"
class FactoryResetRequest: public GwMessage{
private:

View File

@ -1,4 +1,4 @@
#include "GwLeds.h"
#include "GwLedTask.h"
#include "GwHardware.h"
#include "GwApi.h"
#include "FastLED.h"
@ -23,8 +23,7 @@ static CRGB::HTMLColorCode colorFromMode(GwLedMode cmode){
return CRGB::Black;
}
}
void handleLeds(void *param){
GwApi *api=(GwApi*)param;
void handleLeds(GwApi *api){
GwLog *logger=api->getLogger();
#ifndef GWLED_FASTLED
LOG_DEBUG(GwLog::LOG,"currently only fastled handling");
@ -43,6 +42,7 @@ void handleLeds(void *param){
leds[0]=colorFromMode(currentMode);
FastLED.setBrightness(brightness);
FastLED.show();
LOG_DEBUG(GwLog::LOG,"led task started with mode %d",(int)currentMode);
while(true){
delay(50);
GwLedMode newMode=mode;

View File

@ -1,7 +1,8 @@
#ifndef _GWLEDS_H
#define _GWLEDS_H
#include "GwApi.h"
//task function
void handleLeds(void *param);
void handleLeds(GwApi *param);
typedef enum {
LED_OFF,
LED_GREEN,
@ -10,4 +11,5 @@ typedef enum {
LED_WHITE
} GwLedMode;
void setLedMode(GwLedMode mode);
DECLARE_USERTASK(handleLeds);
#endif

View File

@ -54,7 +54,7 @@ const unsigned long HEAP_REPORT_TIME=2000; //set to 0 to disable heap reporting
#include "GwWebServer.h"
#include "NMEA0183DataToN2K.h"
#include "GwButtons.h"
#include "GwLeds.h"
#include "GwLedTask.h"
#include "GwCounter.h"
#include "GwXDRMappings.h"
#include "GwSynchronized.h"
@ -852,9 +852,8 @@ void setup() {
NMEA2000.Open();
logger.logDebug(GwLog::LOG,"starting addon tasks");
logger.flush();
userCodeHandler.startAddonTask(F("handleButtons"),handleButtons,100);
setLedMode(LED_GREEN);
userCodeHandler.startAddonTask(F("handleLeds"),handleLeds,101);
userCodeHandler.startAddonTask(F("handleButtons"),handleButtons,100);
{
GWSYNCHRONIZED(&mainLock);
userCodeHandler.startUserTasks(MIN_USER_TASK);