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

intermediate: prepare for multiple grove configs

This commit is contained in:
andreas
2024-03-18 20:20:38 +01:00
parent 8641f0efd9
commit 59a80fcc9a
7 changed files with 107 additions and 70 deletions

View File

@@ -6,15 +6,9 @@
#include <MD5Builder.h>
using CfgInit=std::function<void(GwConfigHandler *)>;
static std::vector<CfgInit> cfgInits;
class CfgInitializer{
public:
CfgInitializer(CfgInit f){
cfgInits.push_back(f);
}
};
#define CFG_INIT(name,value,mode) \
__MSG("config set " #name " " #value " " #mode); \
static CfgInitializer _ ## name ## _init([](GwConfigHandler *cfg){ \
static GwInitializer<CfgInit> _ ## name ## _init(cfgInits,[](GwConfigHandler *cfg){ \
cfg->setValue(GwConfigDefinitions::name,value,GwConfigInterface::mode); \
});
#include "GwHardware.h"

View File

@@ -2,7 +2,6 @@
#define _GWCONFIGITEM_H
#include "WString.h"
#include <vector>
class GwConfigHandler;
class GwConfigInterface{
public:
@@ -79,4 +78,14 @@ class GwNmeaFilter{
#define __XSTR(x) __STR(x)
#define __STR(x) #x
#define __MSG(x) _Pragma (__STR(message (x)))
template<typename F>
class GwInitializer{
public:
using List=std::vector<F>;
GwInitializer(List &l,F f){
l.push_back(f);
}
};
#endif