mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2025-12-14 06:23:07 +01:00
add some compile time checks for necessary i2c definitions
This commit is contained in:
@@ -191,6 +191,14 @@ class GwApi{
|
||||
virtual GwBoatData *getBoatData()=0;
|
||||
virtual ~GwApi(){}
|
||||
};
|
||||
|
||||
/**
|
||||
* a simple generic function to create runtime errors if some necessary values are not defined
|
||||
*/
|
||||
template<typename... T>
|
||||
static void checkDef(T... args){};
|
||||
|
||||
|
||||
#ifndef DECLARE_USERTASK
|
||||
#define DECLARE_USERTASK(task)
|
||||
#endif
|
||||
|
||||
@@ -176,11 +176,13 @@ class BME280Config : public SensorBase{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
void registerBME280(GwApi *api,SensorList &sensors){
|
||||
#if defined(GWBME280) || defined(GWBME28011)
|
||||
{
|
||||
BME280Config *cfg=new BME280Config(api,PRFX1);
|
||||
sensors.add(api,cfg);
|
||||
CHECK_IIC1();
|
||||
#pragma message "GWBME28011 defined"
|
||||
}
|
||||
#endif
|
||||
@@ -188,6 +190,7 @@ void registerBME280(GwApi *api,SensorList &sensors){
|
||||
{
|
||||
BME280Config *cfg=new BME280Config(api,PRFX2);
|
||||
sensors.add(api,cfg);
|
||||
CHECK_IIC1();
|
||||
#pragma message "GWBME28012 defined"
|
||||
}
|
||||
#endif
|
||||
@@ -195,6 +198,7 @@ void registerBME280(GwApi *api,SensorList &sensors){
|
||||
{
|
||||
BME280Config *cfg=new BME280Config(api,PRFX3);
|
||||
sensors.add(api,cfg);
|
||||
CHECK_IIC2();
|
||||
#pragma message "GWBME28021 defined"
|
||||
}
|
||||
#endif
|
||||
@@ -202,6 +206,7 @@ void registerBME280(GwApi *api,SensorList &sensors){
|
||||
{
|
||||
BME280Config *cfg=new BME280Config(api,PRFX4);
|
||||
sensors.add(api,cfg);
|
||||
CHECK_IIC1();
|
||||
#pragma message "GWBME28022 defined"
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -126,4 +126,7 @@ class SensorList : public std::vector<SensorBase*>{
|
||||
using std::vector<SensorBase*>::vector;
|
||||
};
|
||||
|
||||
#define CHECK_IIC1() checkDef(GWIIC_SCL,GWIIC_SDA)
|
||||
#define CHECK_IIC2() checkDef(GWIIC_SCL2,GWIIC_SDA2)
|
||||
|
||||
#endif
|
||||
@@ -95,28 +95,36 @@ class QMP6988Config : public SensorBase{
|
||||
};
|
||||
void registerQMP6988(GwApi *api,SensorList &sensors){
|
||||
GwLog *logger=api->getLogger();
|
||||
#if defined(GWQMP6988) || defined(GWQMP69881)
|
||||
#if defined(GWQMP6988) || defined(GWQMP698811)
|
||||
{
|
||||
QMP6988Config *scfg=new QMP6988Config(api,PRFX1);
|
||||
sensors.add(api,scfg);
|
||||
CHECK_IIC1();
|
||||
#pragma message "GWQMP698811 defined"
|
||||
}
|
||||
#endif
|
||||
#if defined(GWQMP69882)
|
||||
#if defined(GWQMP698812)
|
||||
{
|
||||
QMP6988Config *scfg=new QMP6988Config(api,PRFX2);
|
||||
sensors.add(api,scfg);
|
||||
CHECK_IIC1();
|
||||
#pragma message "GWQMP698812 defined"
|
||||
}
|
||||
#endif
|
||||
#if defined(GWQMP69883)
|
||||
#if defined(GWQMP698821)
|
||||
{
|
||||
QMP6988Config *scfg=new QMP6988Config(api,PRFX3);
|
||||
sensors.add(api,scfg);
|
||||
CHECK_IIC2();
|
||||
#pragma message "GWQMP698821 defined"
|
||||
}
|
||||
#endif
|
||||
#if defined(GWQMP69884)
|
||||
#if defined(GWQMP698822)
|
||||
{
|
||||
QMP6988Config *scfg=new QMP6988Config(api,PRFX4);
|
||||
sensors.add(api,scfg);
|
||||
CHECK_IIC2();
|
||||
#pragma message "GWQMP698822 defined"
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -136,24 +136,32 @@ void registerSHT3X(GwApi *api,SensorList &sensors){
|
||||
{
|
||||
SHT3XConfig *scfg=new SHT3XConfig(api,PRFX1);
|
||||
sensors.add(api,scfg);
|
||||
CHECK_IIC1();
|
||||
#pragma message "GWSHT3X11 defined"
|
||||
}
|
||||
#endif
|
||||
#if defined(GWSHT3X12)
|
||||
{
|
||||
SHT3XConfig *scfg=new SHT3XConfig(api,PRFX2);
|
||||
sensors.add(api,scfg);
|
||||
CHECK_IIC1();
|
||||
#pragma message "GWSHT3X12 defined"
|
||||
}
|
||||
#endif
|
||||
#if defined(GWSHT3X21)
|
||||
{
|
||||
SHT3XConfig *scfg=new SHT3XConfig(api,PRFX3);
|
||||
sensors.add(api,scfg);
|
||||
CHECK_IIC2();
|
||||
#pragma message "GWSHT3X21 defined"
|
||||
}
|
||||
#endif
|
||||
#if defined(GWSHT3X22)
|
||||
{
|
||||
SHT3XConfig *scfg=new SHT3XConfig(api,PRFX4);
|
||||
sensors.add(api,scfg);
|
||||
CHECK_IIC2();
|
||||
#pragma message "GWSHT3X22 defined"
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user