separate sensor libs

This commit is contained in:
andreas 2023-10-29 09:46:54 +01:00
parent 6281067afa
commit f606b78929
5 changed files with 53 additions and 16 deletions

View File

@ -1,13 +1,21 @@
#include "GwIicTask.h"
#include "GwHardware.h"
#include <Wire.h>
#include "SHT3X.h"
#include "QMP6988.h"
#ifdef _GWIIC
#include <Wire.h>
#endif
#ifdef GWSHT3X
#include "SHT3X.h"
#endif
#ifdef GWQMP6988
#include "QMP6988.h"
#endif
#include "GwTimer.h"
#include "N2kMessages.h"
#include "GwHardware.h"
#include "GwXdrTypeMappings.h"
#include <Adafruit_BME280.h>
#ifdef GWBME280
#include <Adafruit_BME280.h>
#endif
//#define GWSHT3X -1
#ifndef GWIIC_SDA
@ -92,8 +100,9 @@ void runIicTask(GwApi *api);
void initIicTask(GwApi *api){
GwLog *logger=api->getLogger();
#ifndef _GWIIC
vTaskDelete(NULL);
return;
#endif
#else
bool addTask=false;
#ifdef GWSHT3X
api->addCapability("SHT3X","true");
@ -214,11 +223,11 @@ void runIicTask(GwApi *api){
return;
}
GwConfigHandler *config=api->getConfig();
SHT3X *sht3x=nullptr;
bool runLoop=false;
GwIntervalRunner timers;
int counterId=api->addCounter("iicsensors");
#ifdef GWSHT3X
SHT3X *sht3x=nullptr;
int addr=GWSHT3X;
if (addr < 0) addr=0x44; //default
SHT3XConfig sht3xConfig(config);
@ -337,4 +346,5 @@ void runIicTask(GwApi *api){
timers.loop();
}
vTaskDelete(NULL);
#endif
}

View File

@ -1,3 +1,5 @@
#include "GwHardware.h"
#ifdef GWQMP6988
#include <math.h>
#include "stdint.h"
#include "stdio.h"
@ -390,3 +392,4 @@ uint8_t QMP6988::init(uint8_t slave_addr_in, TwoWire* wire_in) {
setOversamplingT(QMP6988_OVERSAMPLING_1X);
return 1;
}
#endif

View File

@ -1,3 +1,5 @@
#include "GwHardware.h"
#ifdef GWSHT3X
#include "SHT3X.h"
bool SHT3X::init(uint8_t slave_addr_in, TwoWire* wire_in)
@ -43,3 +45,4 @@ byte SHT3X::get()
return 0;
}
#endif

View File

@ -1,18 +1,22 @@
[platformio]
#basically for testing purposes
[env:m5stack-atom-env3]
extends = sensors
board = m5stack-atom
lib_deps =
${env.lib_deps}
${sensors.lib_deps}
build_flags=
-D M5_ENV3
-D M5_CAN_KIT
${env.build_flags}
[env:m5stack-atom-bme280]
extends = sensors
board = m5stack-atom
lib_deps =
${env.lib_deps}
${sensors.lib_deps}
build_flags=
-D GWBME280=-1
-D M5_GROOVEIIC

View File

@ -33,11 +33,7 @@ lib_deps =
ESPmDNS
WiFi
Update
Wire
SPI
adafruit/Adafruit BME280 Library @ 2.2.2
adafruit/Adafruit BusIO @ 1.14.5
adafruit/Adafruit Unified Sensor @ 1.1.13
board_build.embed_files =
@ -57,6 +53,15 @@ monitor_speed = 115200
build_flags =
-D PIO_ENV_BUILD=$PIOENV
[sensors]
; collect the libraries for sensors here
lib_deps =
Wire
SPI
adafruit/Adafruit BME280 Library @ 2.2.2
adafruit/Adafruit BusIO @ 1.14.5
adafruit/Adafruit Unified Sensor @ 1.1.13
[env:m5stack-atom]
board = m5stack-atom
lib_deps = ${env.lib_deps}
@ -67,8 +72,11 @@ upload_port = /dev/esp32
upload_protocol = esptool
[env:m5stack-atom-generic]
extends = sensors
board = m5stack-atom
lib_deps = ${env.lib_deps}
lib_deps =
${env.lib_deps}
${sensors.lib_deps}
build_flags =
${env.build_flags}
upload_port = /dev/esp32
@ -84,8 +92,11 @@ upload_port = /dev/esp32s3
upload_protocol = esptool
[env:m5stack-atoms3-generic]
extends = sensors
board = m5stack-atoms3
lib_deps = ${env.lib_deps}
lib_deps =
${env.lib_deps}
${sensors.lib_deps}
build_flags =
${env.build_flags}
upload_port = /dev/esp32s3
@ -134,13 +145,16 @@ board = m5stick-c
lib_deps = ${env.lib_deps}
build_flags =
-D BOARD_M5STICK_CANUNIT -D HAS_RTC -D HAS_M5LCD
${env.build_flags}
${env.build_flags}${sensors.lib_deps}
upload_port = /dev/esp32
upload_protocol = esptool
[env:m5stickc-atom-generic]
extends = sensors
board = m5stick-c
lib_deps = ${env.lib_deps}
lib_deps =
${env.lib_deps}
${sensors.lib_deps}
build_flags =
-D BOARD_M5STICK -D HAS_RTC -D HAS_M5LCD
${env.build_flags}
@ -157,8 +171,11 @@ upload_port = /dev/esp32
upload_protocol = esptool
[env:nodemcu-generic]
extends = sensors
board = nodemcu-32s
lib_deps = ${env.lib_deps}
lib_deps =
${env.lib_deps}
${sensors.lib_deps}
build_flags =
${env.build_flags}
upload_port = /dev/esp32