1
0
mirror of https://github.com/thooge/esp32-nmea2000-obp60.git synced 2025-12-14 14:33:07 +01:00

allow for dynamic user task registration

This commit is contained in:
andreas
2023-10-27 19:55:22 +02:00
parent 682bbb5bb4
commit 9e05a86820
6 changed files with 42 additions and 7 deletions

View File

@@ -36,12 +36,13 @@ class SHT3XConfig{
tempSource=(tN2kTempSource)(config->getInt(GwConfigDefinitions::SHT3XTempSource));
}
};
void runIicTask(GwApi *api);
void initIicTask(GwApi *api){
GwLog *logger=api->getLogger();
#ifndef _GWIIC
return;
#endif
bool addTask=false;
#ifdef GWSHT3X
api->addCapability("SHT3X","true");
LOG_DEBUG(GwLog::LOG,"GWSHT3X configured, adding capability and xdr mappings");
@@ -70,7 +71,11 @@ void initIicTask(GwApi *api){
xdr.xdrName=sht3xConfig.tempTransducer;
api->addXdrMapping(xdr);
}
if (sht3xConfig.tempActive || sht3xConfig.humidActive) addTask=true;
#endif
if (addTask){
api->addUserTask(runIicTask,"iicTask",3000);
}
}
void runIicTask(GwApi *api){
GwLog *logger=api->getLogger();

View File

@@ -1,8 +1,6 @@
#ifndef _GWIICTASK_H
#define _GWIICTASK_H
#include "GwApi.h"
void runIicTask(GwApi *api);
void initIicTask(GwApi *api);
DECLARE_USERTASK_PARAM(runIicTask,3000);
DECLARE_INITFUNCTION(initIicTask);
#endif