mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2025-12-14 14:33:07 +01:00
intermediate: move to ldf none mode
This commit is contained in:
@@ -1,12 +1,19 @@
|
||||
//#ifdef _GWIIC
|
||||
#include "GwIicTask.h"
|
||||
#include "GwHardware.h"
|
||||
#include <Wire.h>
|
||||
#include <SHT3X.h>
|
||||
#include "GwTimer.h"
|
||||
#include "N2kMessages.h"
|
||||
#define GWSHT3X -1
|
||||
#include "GwHardware.h"
|
||||
#include "GwXdrTypeMappings.h"
|
||||
//#define GWSHT3X -1
|
||||
|
||||
#ifndef GWIIC_SDA
|
||||
#define GWIIC_SDA -1
|
||||
#endif
|
||||
#ifndef GWIIC_SCL
|
||||
#define GWIIC_SCL -1
|
||||
#endif
|
||||
class SHT3XConfig{
|
||||
public:
|
||||
String tempTransducer;
|
||||
@@ -29,19 +36,49 @@ class SHT3XConfig{
|
||||
tempSource=N2kts_InsideTemperature;
|
||||
}
|
||||
};
|
||||
void runIicTask(GwApi *api){
|
||||
|
||||
void initIicTask(GwApi *api){
|
||||
GwLog *logger=api->getLogger();
|
||||
#ifndef _GWIIC
|
||||
return;
|
||||
#endif
|
||||
#ifdef GWSHT3X
|
||||
api->addCapability("SHT3X","true");
|
||||
LOG_DEBUG(GwLog::LOG,"GWSHT3X configured, adding capability and xdr mappings");
|
||||
SHT3XConfig sht3xConfig(api->getConfig());
|
||||
if (sht3xConfig.humidActive && ! sht3xConfig.humidTransducer.isEmpty()){
|
||||
//add XDR mapping for humidity
|
||||
GwXDRMappingDef xdr;
|
||||
xdr.category=GwXDRCategory::XDRHUMIDITY;
|
||||
xdr.direction=GwXDRMappingDef::M_FROM2K;
|
||||
xdr.field=GWXDRFIELD_HUMIDITY_ACTUALHUMIDITY;
|
||||
xdr.selector=(int)sht3xConfig.humiditySource;
|
||||
xdr.instanceMode=GwXDRMappingDef::IS_SINGLE;
|
||||
xdr.instanceId=sht3xConfig.iid;
|
||||
xdr.xdrName=sht3xConfig.humidTransducer;
|
||||
api->addXdrMapping(xdr);
|
||||
}
|
||||
if (sht3xConfig.tempActive && ! sht3xConfig.tempTransducer.isEmpty()){
|
||||
//add XDR mapping for humidity
|
||||
GwXDRMappingDef xdr;
|
||||
xdr.category=GwXDRCategory::XDRTEMP;
|
||||
xdr.direction=GwXDRMappingDef::M_FROM2K;
|
||||
xdr.field=GWXDRFIELD_TEMPERATURE_ACTUALTEMPERATURE;
|
||||
xdr.selector=(int)sht3xConfig.tempSource;
|
||||
xdr.instanceMode=GwXDRMappingDef::IS_SINGLE;
|
||||
xdr.instanceId=sht3xConfig.iid;
|
||||
xdr.xdrName=sht3xConfig.tempTransducer;
|
||||
api->addXdrMapping(xdr);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
void runIicTask(GwApi *api){
|
||||
GwLog *logger=api->getLogger();
|
||||
#ifndef _GWIIC
|
||||
LOG_DEBUG(GwLog::LOG,"no iic defined, iic task stopped");
|
||||
vTaskDelete(NULL);
|
||||
return;
|
||||
#endif
|
||||
#ifndef GWIIC_SDA
|
||||
#define GWIIC_SDA -1
|
||||
#endif
|
||||
#ifndef GWIIC_SCL
|
||||
#define GWIIC_SCL -1
|
||||
#endif
|
||||
LOG_DEBUG(GwLog::LOG,"iic task started");
|
||||
bool rt=Wire.begin(GWIIC_SDA,GWIIC_SCL);
|
||||
if (! rt){
|
||||
@@ -60,7 +97,7 @@ void runIicTask(GwApi *api){
|
||||
if (sht3xConfig.humidActive || sht3xConfig.tempActive){
|
||||
sht3x=new SHT3X();
|
||||
sht3x->init(addr,&Wire);
|
||||
LOG_DEBUG(GwLog::LOG,"initialized SHT3X at address %d",(int)addr);
|
||||
LOG_DEBUG(GwLog::LOG,"initialized SHT3X at address %d, interval %ld",(int)addr,sht3xConfig.interval);
|
||||
runLoop=true;
|
||||
timers.addAction(sht3xConfig.interval,[logger,api,sht3x,sht3xConfig](){
|
||||
int rt=0;
|
||||
@@ -94,5 +131,5 @@ void runIicTask(GwApi *api){
|
||||
delay(100);
|
||||
timers.loop();
|
||||
}
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
//#endif
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
#ifndef _GWIICTASK
|
||||
#define _GWIICTASK
|
||||
#ifndef _GWIICTASK_H
|
||||
#define _GWIICTASK_H
|
||||
#include "GwApi.h"
|
||||
DECLARE_USERTASK(runIicTask)
|
||||
void runIicTask(GwApi *api);
|
||||
void initIicTask(GwApi *api);
|
||||
DECLARE_USERTASK_PARAM(runIicTask,3000);
|
||||
DECLARE_INITFUNCTION(initIicTask);
|
||||
#endif
|
||||
@@ -1,6 +1,6 @@
|
||||
#ifndef __SHT3X_H
|
||||
#define __HT3X_H
|
||||
|
||||
//taken from https://github.com/m5stack/M5Unit-ENV/tree/0.0.8/src
|
||||
|
||||
#if ARDUINO >= 100
|
||||
#include "Arduino.h"
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
[
|
||||
{
|
||||
"name": "iicSHT3XTemp",
|
||||
"label": "SHT3X Temperature",
|
||||
"type": "boolen",
|
||||
"default": true,
|
||||
"label": "SHT3X Temp",
|
||||
"type": "boolean",
|
||||
"default": "true",
|
||||
"description": "Enable the I2C SHT3x temp sensor",
|
||||
"category": "sensors",
|
||||
"capabilities": {
|
||||
@@ -14,7 +14,7 @@
|
||||
"name": "iicSHT3XHumid",
|
||||
"label": "SHT3X Humidity",
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"default": "true",
|
||||
"description": "Enable the I2C SHT3x humidity sensor",
|
||||
"category": "sensors",
|
||||
"capabilities": {
|
||||
@@ -23,7 +23,7 @@
|
||||
},
|
||||
{
|
||||
"name": "SHT3XTempName",
|
||||
"label": "SHT3X Temperature XDR",
|
||||
"label": "SHT3X Temp XDR",
|
||||
"type": "String",
|
||||
"default": "Temp",
|
||||
"description": "set the XDR transducer name for the SHT3X Temperature, leave empty to disable ",
|
||||
@@ -34,7 +34,7 @@
|
||||
},
|
||||
{
|
||||
"name": "SHT3XHumidName",
|
||||
"label": "SHT3X Humidity XDR",
|
||||
"label": "SHT3X Humid XDR",
|
||||
"type": "String",
|
||||
"default": "Humidity",
|
||||
"description": "set the XDR transducer name for the SHT3X Humidity, leave empty to disable ",
|
||||
@@ -45,7 +45,7 @@
|
||||
},
|
||||
{
|
||||
"name": "SHT3Xiid",
|
||||
"label": "SHT3X N2K instance id",
|
||||
"label": "SHT3X N2K iid",
|
||||
"type": "number",
|
||||
"default": 99,
|
||||
"description": "the N2K instance id the SHT3X Temperature and Humidity ",
|
||||
|
||||
Reference in New Issue
Block a user