mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2025-12-16 15:33:05 +01:00
intermediate: support for QMP6988
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
#include "GwIicTask.h"
|
||||
#include "GwHardware.h"
|
||||
#include <Wire.h>
|
||||
#include <SHT3X.h>
|
||||
#include "SHT3X.h"
|
||||
#include "QMP6988.h"
|
||||
#include "GwTimer.h"
|
||||
#include "N2kMessages.h"
|
||||
#include "GwHardware.h"
|
||||
@@ -36,6 +37,17 @@ class SHT3XConfig{
|
||||
tempSource=(tN2kTempSource)(config->getInt(GwConfigDefinitions::SHT3XTempSource));
|
||||
}
|
||||
};
|
||||
|
||||
class QMP6988Config{
|
||||
public:
|
||||
String transducer="Pressure";
|
||||
int iid=99;
|
||||
bool active=true;
|
||||
long interval=2000;
|
||||
QMP6988Config(GwConfigHandler *config){
|
||||
//TODO
|
||||
}
|
||||
};
|
||||
void runIicTask(GwApi *api);
|
||||
void initIicTask(GwApi *api){
|
||||
GwLog *logger=api->getLogger();
|
||||
@@ -73,6 +85,12 @@ void initIicTask(GwApi *api){
|
||||
}
|
||||
if (sht3xConfig.tempActive || sht3xConfig.humidActive) addTask=true;
|
||||
#endif
|
||||
#ifdef GWQMP6988
|
||||
api->addCapability("QMP6988","true");
|
||||
LOG_DEBUG(GwLog::LOG,"QMP6988 configured, adding capability and xdr mappings");
|
||||
QMP6988Config qmp6988Config(api->getConfig());
|
||||
if (qmp6988Config.active) addTask=true;
|
||||
#endif
|
||||
if (addTask){
|
||||
api->addUserTask(runIicTask,"iicTask",3000);
|
||||
}
|
||||
@@ -127,6 +145,20 @@ void runIicTask(GwApi *api){
|
||||
});
|
||||
}
|
||||
#endif
|
||||
#ifdef GWQMP6988
|
||||
int qaddr=GWQMP6988;
|
||||
if (qaddr < 0) qaddr=0x56;
|
||||
QMP6988Config qmp6988Config(api->getConfig());
|
||||
QMP6988 *qmp6988=nullptr;
|
||||
if (qmp6988Config.active){
|
||||
qmp6988=new QMP6988();
|
||||
qmp6988->init(qaddr,&Wire);
|
||||
timers.addAction(qmp6988Config.interval,[logger,api,qmp6988,qmp6988Config](){
|
||||
float pressure=qmp6988->calcPressure();
|
||||
LOG_DEBUG(GwLog::DEBUG,"qmp6988 measure %2.0fPa",pressure);
|
||||
});
|
||||
}
|
||||
#endif
|
||||
if (! runLoop){
|
||||
LOG_DEBUG(GwLog::LOG,"nothing to do for IIC task, finish");
|
||||
vTaskDelete(NULL);
|
||||
|
||||
Reference in New Issue
Block a user