avoid multiple logs, test multi sensor config
This commit is contained in:
		
							parent
							
								
									0c736bd24a
								
							
						
					
					
						commit
						28ae7d3bbd
					
				| 
						 | 
					@ -17,6 +17,10 @@
 | 
				
			||||||
    #include <Adafruit_BME280.h>
 | 
					    #include <Adafruit_BME280.h>
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
#ifdef _GWBME280
 | 
					#ifdef _GWBME280
 | 
				
			||||||
 | 
					#define PRFX1 "BME2801"
 | 
				
			||||||
 | 
					#define PRFX2 "BME2802"
 | 
				
			||||||
 | 
					#define PRFX3 "BME2803"
 | 
				
			||||||
 | 
					#define PRFX4 "BME2804"
 | 
				
			||||||
class BME280Config : public SensorBase{
 | 
					class BME280Config : public SensorBase{
 | 
				
			||||||
    public:
 | 
					    public:
 | 
				
			||||||
    bool prAct=true;
 | 
					    bool prAct=true;
 | 
				
			||||||
| 
						 | 
					@ -88,7 +92,7 @@ class BME280Config : public SensorBase{
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    virtual void readConfig(GwConfigHandler *cfg) override
 | 
					    virtual void readConfig(GwConfigHandler *cfg) override
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (prefix == "BME2801")
 | 
					        if (prefix == PRFX1)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            busId = 1;
 | 
					            busId = 1;
 | 
				
			||||||
            addr = 0x76;
 | 
					            addr = 0x76;
 | 
				
			||||||
| 
						 | 
					@ -108,7 +112,7 @@ class BME280Config : public SensorBase{
 | 
				
			||||||
            CG(prOff);
 | 
					            CG(prOff);
 | 
				
			||||||
            ok=true;
 | 
					            ok=true;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (prefix == "BME2802")
 | 
					        if (prefix == PRFX2)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            busId = 1;
 | 
					            busId = 1;
 | 
				
			||||||
            addr = 0x77;
 | 
					            addr = 0x77;
 | 
				
			||||||
| 
						 | 
					@ -128,7 +132,7 @@ class BME280Config : public SensorBase{
 | 
				
			||||||
            CG(prOff);
 | 
					            CG(prOff);
 | 
				
			||||||
            ok=true;
 | 
					            ok=true;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (prefix == "BME2803")
 | 
					        if (prefix == PRFX3)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            busId = 2;
 | 
					            busId = 2;
 | 
				
			||||||
            addr = 0x76;
 | 
					            addr = 0x76;
 | 
				
			||||||
| 
						 | 
					@ -148,7 +152,7 @@ class BME280Config : public SensorBase{
 | 
				
			||||||
            CG(prOff);
 | 
					            CG(prOff);
 | 
				
			||||||
            ok=true;
 | 
					            ok=true;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (prefix == "BME2804")
 | 
					        if (prefix == PRFX4)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            busId = 1;
 | 
					            busId = 1;
 | 
				
			||||||
            addr = 0x77;
 | 
					            addr = 0x77;
 | 
				
			||||||
| 
						 | 
					@ -173,23 +177,29 @@ class BME280Config : public SensorBase{
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void registerBME280(GwApi *api,SensorList &sensors){
 | 
					void registerBME280(GwApi *api,SensorList &sensors){
 | 
				
			||||||
    GwLog *logger=api->getLogger();
 | 
					 | 
				
			||||||
    #if defined(GWBME280) || defined(GWBME2801)
 | 
					    #if defined(GWBME280) || defined(GWBME2801)
 | 
				
			||||||
        BME280Config *cfg=new BME280Config(api,"BME2801");
 | 
					    {
 | 
				
			||||||
 | 
					        BME280Config *cfg=new BME280Config(api,PRFX1);
 | 
				
			||||||
        sensors.add(api,cfg);
 | 
					        sensors.add(api,cfg);
 | 
				
			||||||
        LOG_DEBUG(GwLog::LOG,"%s configured %d",cfg->prefix.c_str(),(int)cfg->ok);
 | 
					    }
 | 
				
			||||||
    #endif
 | 
					    #endif
 | 
				
			||||||
    #if defined(GWBME2802)
 | 
					    #if defined(GWBME2802)
 | 
				
			||||||
        BME280Config *cfg=new BME280Config(api,"BME2802");
 | 
					    {
 | 
				
			||||||
 | 
					        BME280Config *cfg=new BME280Config(api,PRFX2);
 | 
				
			||||||
        sensors.add(api,cfg);
 | 
					        sensors.add(api,cfg);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    #endif
 | 
					    #endif
 | 
				
			||||||
    #if defined(GWBME2803)
 | 
					    #if defined(GWBME2803)
 | 
				
			||||||
        BME280Config *cfg=new BME280Config(api,"BME2803");
 | 
					    {
 | 
				
			||||||
 | 
					        BME280Config *cfg=new BME280Config(api,PRFX3);
 | 
				
			||||||
        sensors.add(api,cfg);
 | 
					        sensors.add(api,cfg);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    #endif
 | 
					    #endif
 | 
				
			||||||
    #if defined(GWBME2804)
 | 
					    #if defined(GWBME2804)
 | 
				
			||||||
        BME280Config *cfg=new BME280Config(api,"BME2804");
 | 
					    {
 | 
				
			||||||
 | 
					        BME280Config *cfg=new BME280Config(api,PRFX4);
 | 
				
			||||||
        sensors.add(api,cfg);
 | 
					        sensors.add(api,cfg);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    #endif
 | 
					    #endif
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -120,6 +120,7 @@ class SensorList : public std::vector<SensorBase*>{
 | 
				
			||||||
    public:
 | 
					    public:
 | 
				
			||||||
    void add(GwApi *api, SensorBase *sensor){
 | 
					    void add(GwApi *api, SensorBase *sensor){
 | 
				
			||||||
        sensor->readConfig(api->getConfig());
 | 
					        sensor->readConfig(api->getConfig());
 | 
				
			||||||
 | 
					        api->getLogger()->logDebug(GwLog::LOG,"configured sensor %s, status %d",sensor->prefix.c_str(),(int)sensor->ok);
 | 
				
			||||||
        push_back(sensor);
 | 
					        push_back(sensor);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    using std::vector<SensorBase*>::vector;
 | 
					    using std::vector<SensorBase*>::vector;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,6 +17,10 @@
 | 
				
			||||||
    #include "QMP6988.h"
 | 
					    #include "QMP6988.h"
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
#ifdef _GWQMP6988
 | 
					#ifdef _GWQMP6988
 | 
				
			||||||
 | 
					#define PRFX1 "QMP69881"
 | 
				
			||||||
 | 
					#define PRFX2 "QMP69882"
 | 
				
			||||||
 | 
					#define PRFX3 "QMP69883"
 | 
				
			||||||
 | 
					#define PRFX4 "QMP69884"
 | 
				
			||||||
class QMP6988Config : public SensorBase{
 | 
					class QMP6988Config : public SensorBase{
 | 
				
			||||||
    public:
 | 
					    public:
 | 
				
			||||||
        String prNam="Pressure";
 | 
					        String prNam="Pressure";
 | 
				
			||||||
| 
						 | 
					@ -54,7 +58,7 @@ class QMP6988Config : public SensorBase{
 | 
				
			||||||
            sendN2kPressure(api,*this,computed,counterId);
 | 
					            sendN2kPressure(api,*this,computed,counterId);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        virtual void readConfig(GwConfigHandler *cfg){
 | 
					        virtual void readConfig(GwConfigHandler *cfg){
 | 
				
			||||||
            if (prefix == "QMP69881"){
 | 
					            if (prefix == PRFX1){
 | 
				
			||||||
                busId=1;
 | 
					                busId=1;
 | 
				
			||||||
                addr=86;
 | 
					                addr=86;
 | 
				
			||||||
                #undef CG
 | 
					                #undef CG
 | 
				
			||||||
| 
						 | 
					@ -66,7 +70,7 @@ class QMP6988Config : public SensorBase{
 | 
				
			||||||
                CG(prOff);
 | 
					                CG(prOff);
 | 
				
			||||||
                ok=true;
 | 
					                ok=true;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            if (prefix == "QMP69882"){
 | 
					            if (prefix == PRFX2){
 | 
				
			||||||
                busId=1;
 | 
					                busId=1;
 | 
				
			||||||
                addr=112;
 | 
					                addr=112;
 | 
				
			||||||
                #undef CG
 | 
					                #undef CG
 | 
				
			||||||
| 
						 | 
					@ -78,7 +82,7 @@ class QMP6988Config : public SensorBase{
 | 
				
			||||||
                CG(prOff);
 | 
					                CG(prOff);
 | 
				
			||||||
                ok=true;
 | 
					                ok=true;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            if (prefix == "QMP69883"){
 | 
					            if (prefix == PRFX3){
 | 
				
			||||||
                busId=2;
 | 
					                busId=2;
 | 
				
			||||||
                addr=86;
 | 
					                addr=86;
 | 
				
			||||||
                #undef CG
 | 
					                #undef CG
 | 
				
			||||||
| 
						 | 
					@ -90,7 +94,7 @@ class QMP6988Config : public SensorBase{
 | 
				
			||||||
                CG(prOff);
 | 
					                CG(prOff);
 | 
				
			||||||
                ok=true;
 | 
					                ok=true;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            if (prefix == "QMP69884"){
 | 
					            if (prefix == PRFX4){
 | 
				
			||||||
                busId=2;
 | 
					                busId=2;
 | 
				
			||||||
                addr=112;
 | 
					                addr=112;
 | 
				
			||||||
                #undef CG
 | 
					                #undef CG
 | 
				
			||||||
| 
						 | 
					@ -110,29 +114,25 @@ void registerQMP6988(GwApi *api,SensorList &sensors){
 | 
				
			||||||
    GwLog *logger=api->getLogger();
 | 
					    GwLog *logger=api->getLogger();
 | 
				
			||||||
    #if defined(GWQMP6988) || defined(GWQMP69881)
 | 
					    #if defined(GWQMP6988) || defined(GWQMP69881)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        QMP6988Config *scfg=new QMP6988Config(api,"QMP69881");
 | 
					        QMP6988Config *scfg=new QMP6988Config(api,PRFX1);
 | 
				
			||||||
        LOG_DEBUG(GwLog::LOG,"%s configured",scfg->prefix.c_str());
 | 
					 | 
				
			||||||
        sensors.add(api,scfg);
 | 
					        sensors.add(api,scfg);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    #endif
 | 
					    #endif
 | 
				
			||||||
    #if defined(GWQMP69882)
 | 
					    #if defined(GWQMP69882)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        QMP6988Config *scfg=new QMP6988Config(api,"QMP69882");
 | 
					        QMP6988Config *scfg=new QMP6988Config(api,PRFX2);
 | 
				
			||||||
        LOG_DEBUG(GwLog::LOG,"%s configured",scfg->prefix.c_str());
 | 
					 | 
				
			||||||
        sensors.add(api,scfg);
 | 
					        sensors.add(api,scfg);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    #endif
 | 
					    #endif
 | 
				
			||||||
    #if defined(GWQMP69883)
 | 
					    #if defined(GWQMP69883)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        QMP6988Config *scfg=new QMP6988Config(api,"QMP69883");
 | 
					        QMP6988Config *scfg=new QMP6988Config(api,PRFX3);
 | 
				
			||||||
        LOG_DEBUG(GwLog::LOG,"%s configured",scfg->prefix.c_str());
 | 
					 | 
				
			||||||
        sensors.add(api,scfg);
 | 
					        sensors.add(api,scfg);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    #endif
 | 
					    #endif
 | 
				
			||||||
    #if defined(GWQMP69884)
 | 
					    #if defined(GWQMP69884)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        QMP6988Config *scfg=new QMP6988Config(api,"QMP69884");
 | 
					        QMP6988Config *scfg=new QMP6988Config(api,PRFX4);
 | 
				
			||||||
        LOG_DEBUG(GwLog::LOG,"%s configured",scfg->prefix.c_str());
 | 
					 | 
				
			||||||
        sensors.add(api,scfg);
 | 
					        sensors.add(api,scfg);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    #endif
 | 
					    #endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -18,6 +18,10 @@
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef _GWSHT3X
 | 
					#ifdef _GWSHT3X
 | 
				
			||||||
 | 
					#define PRFX1 "SHT3X1"
 | 
				
			||||||
 | 
					#define PRFX2 "SHT3X2"
 | 
				
			||||||
 | 
					#define PRFX3 "SHT3X3"
 | 
				
			||||||
 | 
					#define PRFX4 "SHT3X4"
 | 
				
			||||||
class SHT3XConfig : public SensorBase{
 | 
					class SHT3XConfig : public SensorBase{
 | 
				
			||||||
    public:
 | 
					    public:
 | 
				
			||||||
    String tmNam;
 | 
					    String tmNam;
 | 
				
			||||||
| 
						 | 
					@ -74,8 +78,13 @@ class SHT3XConfig : public SensorBase{
 | 
				
			||||||
            LOG_DEBUG(GwLog::DEBUG, "unable to query SHT3X: %d", rt);
 | 
					            LOG_DEBUG(GwLog::DEBUG, "unable to query SHT3X: %d", rt);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * we do not dynamically compute the config names
 | 
				
			||||||
 | 
					     * just to get compile time errors if something does not fit
 | 
				
			||||||
 | 
					     * correctly
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
    virtual void readConfig(GwConfigHandler *cfg){
 | 
					    virtual void readConfig(GwConfigHandler *cfg){
 | 
				
			||||||
        if (prefix == "SHT3X1"){
 | 
					        if (prefix == PRFX1){
 | 
				
			||||||
            busId=1;
 | 
					            busId=1;
 | 
				
			||||||
            addr=0x44;
 | 
					            addr=0x44;
 | 
				
			||||||
            #undef CG
 | 
					            #undef CG
 | 
				
			||||||
| 
						 | 
					@ -90,7 +99,7 @@ class SHT3XConfig : public SensorBase{
 | 
				
			||||||
            CG(tmSrc);
 | 
					            CG(tmSrc);
 | 
				
			||||||
            ok=true; 
 | 
					            ok=true; 
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (prefix == "SHT3X2"){
 | 
					        if (prefix == PRFX2){
 | 
				
			||||||
            busId=1;
 | 
					            busId=1;
 | 
				
			||||||
            addr=0x45;
 | 
					            addr=0x45;
 | 
				
			||||||
            #undef CG
 | 
					            #undef CG
 | 
				
			||||||
| 
						 | 
					@ -105,7 +114,7 @@ class SHT3XConfig : public SensorBase{
 | 
				
			||||||
            CG(tmSrc); 
 | 
					            CG(tmSrc); 
 | 
				
			||||||
            ok=true;
 | 
					            ok=true;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (prefix == "SHT3X3"){
 | 
					        if (prefix == PRFX3){
 | 
				
			||||||
            busId=2;
 | 
					            busId=2;
 | 
				
			||||||
            addr=0x44;
 | 
					            addr=0x44;
 | 
				
			||||||
            #undef CG
 | 
					            #undef CG
 | 
				
			||||||
| 
						 | 
					@ -120,7 +129,7 @@ class SHT3XConfig : public SensorBase{
 | 
				
			||||||
            CG(tmSrc); 
 | 
					            CG(tmSrc); 
 | 
				
			||||||
            ok=true;
 | 
					            ok=true;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (prefix == "SHT3X4"){
 | 
					        if (prefix == PRFX4){
 | 
				
			||||||
            busId=2;
 | 
					            busId=2;
 | 
				
			||||||
            addr=0x45;
 | 
					            addr=0x45;
 | 
				
			||||||
            #undef CG
 | 
					            #undef CG
 | 
				
			||||||
| 
						 | 
					@ -142,29 +151,25 @@ void registerSHT3X(GwApi *api,SensorList &sensors){
 | 
				
			||||||
    GwLog *logger=api->getLogger();
 | 
					    GwLog *logger=api->getLogger();
 | 
				
			||||||
    #if defined(GWSHT3X) || defined (GWSHT3X1)
 | 
					    #if defined(GWSHT3X) || defined (GWSHT3X1)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        SHT3XConfig *scfg=new SHT3XConfig(api,"SHT3X1");
 | 
					        SHT3XConfig *scfg=new SHT3XConfig(api,PRFX1);
 | 
				
			||||||
        LOG_DEBUG(GwLog::LOG,"%s configured",scfg->prefix.c_str());
 | 
					 | 
				
			||||||
        sensors.add(api,scfg);
 | 
					        sensors.add(api,scfg);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    #endif
 | 
					    #endif
 | 
				
			||||||
    #if defined(GWSHT3X2)
 | 
					    #if defined(GWSHT3X2)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        SHT3XConfig *scfg=new SHT3XConfig(api,"SHT3X2");
 | 
					        SHT3XConfig *scfg=new SHT3XConfig(api,PRFX2);
 | 
				
			||||||
        LOG_DEBUG(GwLog::LOG,"%s configured",scfg->prefix.c_str());
 | 
					 | 
				
			||||||
        sensors.add(api,scfg);
 | 
					        sensors.add(api,scfg);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    #endif
 | 
					    #endif
 | 
				
			||||||
    #if defined(GWSHT3X3)
 | 
					    #if defined(GWSHT3X3)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        SHT3XConfig *scfg=new SHT3XConfig(api,"SHT3X3");
 | 
					        SHT3XConfig *scfg=new SHT3XConfig(api,PRFX3);
 | 
				
			||||||
        LOG_DEBUG(GwLog::LOG,"%s configured",scfg->prefix.c_str());
 | 
					 | 
				
			||||||
        sensors.add(api,scfg);
 | 
					        sensors.add(api,scfg);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    #endif
 | 
					    #endif
 | 
				
			||||||
    #if defined(GWSHT3X4)
 | 
					    #if defined(GWSHT3X4)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        SHT3XConfig *scfg=new SHT3XConfig(api,"SHT3X4");
 | 
					        SHT3XConfig *scfg=new SHT3XConfig(api,PRFX4);
 | 
				
			||||||
        LOG_DEBUG(GwLog::LOG,"%s configured",scfg->prefix.c_str());
 | 
					 | 
				
			||||||
        sensors.add(api,scfg);
 | 
					        sensors.add(api,scfg);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    #endif
 | 
					    #endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,3 +22,16 @@ build_flags=
 | 
				
			||||||
    -D M5_GROOVEIIC
 | 
					    -D M5_GROOVEIIC
 | 
				
			||||||
    -D M5_CAN_KIT
 | 
					    -D M5_CAN_KIT
 | 
				
			||||||
    ${env.build_flags}
 | 
					    ${env.build_flags}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[env:m5stack-atom-bme2802]
 | 
				
			||||||
 | 
					extends = sensors
 | 
				
			||||||
 | 
					board = m5stack-atom
 | 
				
			||||||
 | 
					lib_deps = 
 | 
				
			||||||
 | 
					    ${env.lib_deps}
 | 
				
			||||||
 | 
					    ${sensors.lib_deps}
 | 
				
			||||||
 | 
					build_flags=
 | 
				
			||||||
 | 
					    -D GWBME280
 | 
				
			||||||
 | 
					    -D GWBME2802
 | 
				
			||||||
 | 
					    -D M5_GROOVEIIC
 | 
				
			||||||
 | 
					    -D M5_CAN_KIT
 | 
				
			||||||
 | 
					    ${env.build_flags}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue