1
0
mirror of https://github.com/thooge/esp32-nmea2000-obp60.git synced 2025-12-13 05:53:06 +01:00

#12: multiple capabilities in user task, user init function, cleanup message handling in main, clearer api

This commit is contained in:
wellenvogel
2021-12-01 20:03:33 +01:00
parent 16cf7655f0
commit c105eef969
9 changed files with 215 additions and 126 deletions

View File

@@ -4,6 +4,12 @@
#include "GwExampleTask.h"
#include "GwApi.h"
/**
* an init function that ist being called before other initializations from the core
*/
void exampleInit(GwApi *api){
api->getLogger()->logDebug(GwLog::LOG,"example init running");
}
#define INVALID_COORD -99999
class GetBoatDataRequest: public GwMessage{
private:
@@ -32,8 +38,7 @@ class GetBoatDataRequest: public GwMessage{
longitude=api->getBoatData()->Longitude->getDataWithDefault(INVALID_COORD);
};
};
void exampleTask(void *param){
GwApi *api=(GwApi*)param;
void exampleTask(GwApi *api){
GwLog *logger=api->getLogger();
//get some configuration data
bool exampleSwitch=api->getConfig()->getConfigItem(

View File

@@ -23,11 +23,19 @@
//brightness 0...255
#define GWLED_BRIGHTNESS 64
void exampleTask(void *param);
void exampleTask(GwApi *param);
void exampleInit(GwApi *param);
//make the task known to the core
//the task function should not return (unless you delete the task - see example code)
DECLARE_USERTASK(exampleTask);
//let the core call an init function before the
//N2K Stuff and the communication is set up
//normally you should not need this at all
//this function must return when done - otherwise the core will not start up
DECLARE_INITFUNCTION(exampleInit);
//we declare a capability that we can
//use in config.json to only show some
//elements when this capability is set correctly
DECLARE_CAPABILITY(testboard,true);
DECLARE_CAPABILITY(testboard2,true);
#endif

View File

@@ -1,7 +1,7 @@
[
{
"name": "exampleConfig",
"label": "logging on",
"label": "monitor position",
"type": "boolean",
"default": "false",
"description": "switch on logging of position acquired/failed",