mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
tracker_l1: support for EnvironmentSensorManager
This commit is contained in:
parent
59ea6cdb89
commit
f9543bb7bb
6 changed files with 30 additions and 128 deletions
|
|
@ -108,7 +108,13 @@ bool EnvironmentSensorManager::begin() {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENV_PIN_SDA && ENV_PIN_SCL
|
#if ENV_PIN_SDA && ENV_PIN_SCL
|
||||||
|
#ifdef NRF52_PLATFORM
|
||||||
|
Wire1.setPins(ENV_PIN_SDA, ENV_PIN_SCL);
|
||||||
|
Wire1.setClock(100000);
|
||||||
|
Wire1.begin();
|
||||||
|
#else
|
||||||
Wire1.begin(ENV_PIN_SDA, ENV_PIN_SCL, 100000);
|
Wire1.begin(ENV_PIN_SDA, ENV_PIN_SCL, 100000);
|
||||||
|
#endif
|
||||||
MESH_DEBUG_PRINTLN("Second I2C initialized on pins SDA: %d SCL: %d", ENV_PIN_SDA, ENV_PIN_SCL);
|
MESH_DEBUG_PRINTLN("Second I2C initialized on pins SDA: %d SCL: %d", ENV_PIN_SDA, ENV_PIN_SCL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,12 @@ build_flags = ${nrf52_base.build_flags}
|
||||||
-D DISPLAY_ROTATION=1
|
-D DISPLAY_ROTATION=1
|
||||||
-D DISABLE_DIAGNOSTIC_OUTPUT
|
-D DISABLE_DIAGNOSTIC_OUTPUT
|
||||||
-D AUTO_OFF_MILLIS=0
|
-D AUTO_OFF_MILLIS=0
|
||||||
|
-D ENV_INCLUDE_GPS=1
|
||||||
|
-D ENV_INCLUDE_BME280=1
|
||||||
|
-D GPS_BAUD_RATE=9600
|
||||||
|
-D PIN_GPS_EN=PIN_GPS_STANDBY
|
||||||
|
-D ENV_PIN_SDA=PIN_WIRE1_SDA
|
||||||
|
-D ENV_PIN_SCL=PIN_WIRE1_SCL
|
||||||
build_src_filter = ${nrf52_base.build_src_filter}
|
build_src_filter = ${nrf52_base.build_src_filter}
|
||||||
+<WioTrackerL1Board.cpp>
|
+<WioTrackerL1Board.cpp>
|
||||||
+<../variants/wio-tracker-l1>
|
+<../variants/wio-tracker-l1>
|
||||||
|
|
@ -51,7 +57,7 @@ build_flags = ${WioTrackerL1Eink.build_flags}
|
||||||
-D QSPIFLASH=1
|
-D QSPIFLASH=1
|
||||||
; -D MESH_PACKET_LOGGING=1
|
; -D MESH_PACKET_LOGGING=1
|
||||||
; -D MESH_DEBUG=1
|
; -D MESH_DEBUG=1
|
||||||
-D UI_RECENT_LIST_SIZE=9
|
-D UI_RECENT_LIST_SIZE=6
|
||||||
-D UI_SENSORS_PAGE=1
|
-D UI_SENSORS_PAGE=1
|
||||||
build_src_filter = ${WioTrackerL1Eink.build_src_filter}
|
build_src_filter = ${WioTrackerL1Eink.build_src_filter}
|
||||||
+<helpers/nrf52/SerialBLEInterface.cpp>
|
+<helpers/nrf52/SerialBLEInterface.cpp>
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,12 @@ build_flags = ${nrf52_base.build_flags}
|
||||||
-D SX126X_CURRENT_LIMIT=140
|
-D SX126X_CURRENT_LIMIT=140
|
||||||
-D SX126X_RX_BOOSTED_GAIN=1
|
-D SX126X_RX_BOOSTED_GAIN=1
|
||||||
-D PIN_OLED_RESET=-1
|
-D PIN_OLED_RESET=-1
|
||||||
; -D MESH_DEBUG=1
|
-D ENV_INCLUDE_GPS=1
|
||||||
|
-D ENV_INCLUDE_BME280=1
|
||||||
|
-D GPS_BAUD_RATE=9600
|
||||||
|
-D PIN_GPS_EN=PIN_GPS_STANDBY
|
||||||
|
-D ENV_PIN_SDA=PIN_WIRE1_SDA
|
||||||
|
-D ENV_PIN_SCL=PIN_WIRE1_SCL
|
||||||
build_src_filter = ${nrf52_base.build_src_filter}
|
build_src_filter = ${nrf52_base.build_src_filter}
|
||||||
+<WioTrackerL1Board.cpp>
|
+<WioTrackerL1Board.cpp>
|
||||||
+<../variants/wio-tracker-l1>
|
+<../variants/wio-tracker-l1>
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,13 @@ WRAPPER_CLASS radio_driver(radio, board);
|
||||||
|
|
||||||
VolatileRTCClock fallback_clock;
|
VolatileRTCClock fallback_clock;
|
||||||
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||||
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1);
|
|
||||||
WioTrackerL1SensorManager sensors = WioTrackerL1SensorManager(nmea);
|
#ifdef ENV_INCLUDE_GPS
|
||||||
|
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
|
||||||
|
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
|
||||||
|
#else
|
||||||
|
EnvironmentSensorManager sensors = EnvironmentSensorManager();
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef DISPLAY_CLASS
|
#ifdef DISPLAY_CLASS
|
||||||
DISPLAY_CLASS display;
|
DISPLAY_CLASS display;
|
||||||
|
|
@ -42,107 +47,6 @@ void radio_set_tx_power(uint8_t dbm) {
|
||||||
radio.setOutputPower(dbm);
|
radio.setOutputPower(dbm);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WioTrackerL1SensorManager::start_gps()
|
|
||||||
{
|
|
||||||
if (!gps_active)
|
|
||||||
{
|
|
||||||
MESH_DEBUG_PRINTLN("starting GPS");
|
|
||||||
digitalWrite(PIN_GPS_STANDBY, HIGH);
|
|
||||||
gps_active = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void WioTrackerL1SensorManager::stop_gps()
|
|
||||||
{
|
|
||||||
if (gps_active)
|
|
||||||
{
|
|
||||||
MESH_DEBUG_PRINTLN("stopping GPS");
|
|
||||||
digitalWrite(PIN_GPS_STANDBY, LOW);
|
|
||||||
gps_active = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool WioTrackerL1SensorManager::begin()
|
|
||||||
{
|
|
||||||
Serial1.setPins(PIN_GPS_TX, PIN_GPS_RX); // be sure to tx into rx and rx into tx
|
|
||||||
Serial1.begin(GPS_BAUDRATE);
|
|
||||||
|
|
||||||
pinMode(PIN_GPS_STANDBY, OUTPUT);
|
|
||||||
digitalWrite(PIN_GPS_STANDBY, HIGH); // Wake GPS from standby
|
|
||||||
delay(500);
|
|
||||||
|
|
||||||
// We'll consider GPS detected if we see any data on Serial1
|
|
||||||
if (Serial1.available() > 0)
|
|
||||||
{
|
|
||||||
MESH_DEBUG_PRINTLN("GPS detected");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MESH_DEBUG_PRINTLN("No GPS detected");
|
|
||||||
}
|
|
||||||
digitalWrite(PIN_GPS_STANDBY, LOW); // Put GPS back into standby mode
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool WioTrackerL1SensorManager::querySensors(uint8_t requester_permissions, CayenneLPP &telemetry)
|
|
||||||
{
|
|
||||||
if (requester_permissions & TELEM_PERM_LOCATION)
|
|
||||||
{ // does requester have permission?
|
|
||||||
telemetry.addGPS(TELEM_CHANNEL_SELF, node_lat, node_lon, node_altitude);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void WioTrackerL1SensorManager::loop()
|
|
||||||
{
|
|
||||||
static long next_gps_update = 0;
|
|
||||||
_location->loop();
|
|
||||||
if (millis() > next_gps_update && gps_active) // don't bother if gps position is not enabled
|
|
||||||
{
|
|
||||||
if (_location->isValid())
|
|
||||||
{
|
|
||||||
node_lat = ((double)_location->getLatitude()) / 1000000.;
|
|
||||||
node_lon = ((double)_location->getLongitude()) / 1000000.;
|
|
||||||
node_altitude = ((double)_location->getAltitude()) / 1000.0;
|
|
||||||
MESH_DEBUG_PRINTLN("lat %f lon %f", node_lat, node_lon);
|
|
||||||
}
|
|
||||||
next_gps_update = millis() + (1000 * 60); // after initial update, only check every minute TODO: should be configurable
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int WioTrackerL1SensorManager::getNumSettings() const { return 1; } // just one supported: "gps" (power switch)
|
|
||||||
|
|
||||||
const char *WioTrackerL1SensorManager::getSettingName(int i) const
|
|
||||||
{
|
|
||||||
return i == 0 ? "gps" : NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *WioTrackerL1SensorManager::getSettingValue(int i) const
|
|
||||||
{
|
|
||||||
if (i == 0)
|
|
||||||
{
|
|
||||||
return gps_active ? "1" : "0";
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool WioTrackerL1SensorManager::setSettingValue(const char *name, const char *value)
|
|
||||||
{
|
|
||||||
if (strcmp(name, "gps") == 0)
|
|
||||||
{
|
|
||||||
if (strcmp(value, "0") == 0)
|
|
||||||
{
|
|
||||||
stop_gps();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
start_gps();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false; // not supported
|
|
||||||
}
|
|
||||||
|
|
||||||
mesh::LocalIdentity radio_new_identity() {
|
mesh::LocalIdentity radio_new_identity() {
|
||||||
RadioNoiseListener rng(radio);
|
RadioNoiseListener rng(radio);
|
||||||
return mesh::LocalIdentity(&rng); // create new random identity
|
return mesh::LocalIdentity(&rng); // create new random identity
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
#include <helpers/radiolib/CustomSX1262Wrapper.h>
|
#include <helpers/radiolib/CustomSX1262Wrapper.h>
|
||||||
#include <helpers/AutoDiscoverRTCClock.h>
|
#include <helpers/AutoDiscoverRTCClock.h>
|
||||||
#include <helpers/ArduinoHelpers.h>
|
#include <helpers/ArduinoHelpers.h>
|
||||||
|
#include <helpers/sensors/EnvironmentSensorManager.h>
|
||||||
#ifdef DISPLAY_CLASS
|
#ifdef DISPLAY_CLASS
|
||||||
#if defined(WIO_TRACKER_L1_EINK)
|
#if defined(WIO_TRACKER_L1_EINK)
|
||||||
#include <helpers/ui/GxEPDDisplay.h>
|
#include <helpers/ui/GxEPDDisplay.h>
|
||||||
|
|
@ -17,30 +18,10 @@
|
||||||
#endif
|
#endif
|
||||||
#include <helpers/sensors/EnvironmentSensorManager.h>
|
#include <helpers/sensors/EnvironmentSensorManager.h>
|
||||||
|
|
||||||
class WioTrackerL1SensorManager : public SensorManager
|
|
||||||
{
|
|
||||||
bool gps_active = false;
|
|
||||||
LocationProvider *_location;
|
|
||||||
|
|
||||||
void start_gps();
|
|
||||||
void stop_gps();
|
|
||||||
|
|
||||||
public:
|
|
||||||
WioTrackerL1SensorManager(LocationProvider &location) : _location(&location) {}
|
|
||||||
bool begin() override;
|
|
||||||
bool querySensors(uint8_t requester_permissions, CayenneLPP &telemetry) override;
|
|
||||||
void loop() override;
|
|
||||||
int getNumSettings() const override;
|
|
||||||
const char *getSettingName(int i) const override;
|
|
||||||
const char *getSettingValue(int i) const override;
|
|
||||||
bool setSettingValue(const char *name, const char *value) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
extern WioTrackerL1Board board;
|
extern WioTrackerL1Board board;
|
||||||
extern WRAPPER_CLASS radio_driver;
|
extern WRAPPER_CLASS radio_driver;
|
||||||
extern AutoDiscoverRTCClock rtc_clock;
|
extern AutoDiscoverRTCClock rtc_clock;
|
||||||
extern WioTrackerL1SensorManager sensors;
|
extern EnvironmentSensorManager sensors;
|
||||||
#ifdef DISPLAY_CLASS
|
#ifdef DISPLAY_CLASS
|
||||||
extern DISPLAY_CLASS display;
|
extern DISPLAY_CLASS display;
|
||||||
extern MomentaryButton user_btn;
|
extern MomentaryButton user_btn;
|
||||||
|
|
|
||||||
|
|
@ -78,8 +78,8 @@
|
||||||
|
|
||||||
#define PIN_WIRE_SDA (14)
|
#define PIN_WIRE_SDA (14)
|
||||||
#define PIN_WIRE_SCL (15)
|
#define PIN_WIRE_SCL (15)
|
||||||
#define PIN_WIRE1_SDA (17)
|
#define PIN_WIRE1_SDA (18)
|
||||||
#define PIN_WIRE1_SCL (18)
|
#define PIN_WIRE1_SCL (17)
|
||||||
#define I2C_NO_RESCAN
|
#define I2C_NO_RESCAN
|
||||||
#define DISPLAY_ADDRESS 0x3D // SH1106 OLED I2C address
|
#define DISPLAY_ADDRESS 0x3D // SH1106 OLED I2C address
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue