Skip to content

Commit f2f15b9

Browse files
authored
Merge branch 'develop' into ble-Banner
2 parents 6b46366 + 840b298 commit f2f15b9

103 files changed

Lines changed: 1388 additions & 384 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/main_matrix.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ jobs:
9696
pio_platform: ${{ matrix.check.platform }}
9797
pio_env: ${{ matrix.check.board }}
9898
pio_target: check
99+
pio_opts: --fail-on-defect=low
99100

100101
build:
101102
needs: [setup, version]

boards/station-g2.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"extra_flags": [
99
"-DBOARD_HAS_PSRAM",
1010
"-DARDUINO_USB_CDC_ON_BOOT=1",
11-
"-DARDUINO_USB_MODE=0",
11+
"-DARDUINO_USB_MODE=1",
1212
"-DARDUINO_RUNNING_CORE=1",
1313
"-DARDUINO_EVENT_RUNNING_CORE=0"
1414
],

platformio.ini

Lines changed: 17 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ lib_deps =
184184
# renovate: datasource=custom.pio depName=BH1750_WE packageName=wollewald/library/BH1750_WE
185185
wollewald/BH1750_WE@1.1.10
186186

187-
; (not included in native / portduino)
188-
[environmental_extra]
187+
; Common environmental sensor libraries (not included in native / portduino)
188+
[environmental_extra_common]
189189
lib_deps =
190190
# renovate: datasource=custom.pio depName=Adafruit BMP3XX packageName=adafruit/library/Adafruit BMP3XX Library
191191
adafruit/Adafruit BMP3XX Library@2.1.6
@@ -205,10 +205,6 @@ lib_deps =
205205
sparkfun/SparkFun Qwiic Scale NAU7802 Arduino Library@1.0.6
206206
# renovate: datasource=custom.pio depName=ClosedCube OPT3001 packageName=closedcube/library/ClosedCube OPT3001
207207
closedcube/ClosedCube OPT3001@1.1.2
208-
# renovate: datasource=custom.pio depName=Bosch BSEC2 packageName=boschsensortec/library/bsec2
209-
boschsensortec/bsec2@1.10.2610
210-
# renovate: datasource=custom.pio depName=Bosch BME68x packageName=boschsensortec/library/BME68x Sensor Library
211-
boschsensortec/BME68x Sensor Library@1.3.40408
212208
# renovate: datasource=git-refs depName=meshtastic-DFRobot_LarkWeatherStation packageName=https://github.com/meshtastic/DFRobot_LarkWeatherStation gitBranch=master
213209
https://github.com/meshtastic/DFRobot_LarkWeatherStation/archive/4de3a9cadef0f6a5220a8a906cf9775b02b0040d.zip
214210
# renovate: datasource=custom.pio depName=Sensirion Core packageName=sensirion/library/Sensirion Core
@@ -217,33 +213,21 @@ lib_deps =
217213
sensirion/Sensirion I2C SCD4x@1.1.0
218214
# renovate: datasource=custom.pio depName=Sensirion I2C SFA3x packageName=sensirion/library/Sensirion I2C SFA3x
219215
sensirion/Sensirion I2C SFA3x@1.0.0
216+
# renovate: datasource=custom.pio depName=Sensirion I2C SCD30 packageName=sensirion/library/Sensirion I2C SCD30
217+
sensirion/Sensirion I2C SCD30@1.0.0
220218

221-
; Same as environmental_extra but without BSEC (saves ~3.5KB DRAM for original ESP32 targets)
219+
; Environmental sensors with BSEC2 (Bosch proprietary IAQ)
220+
[environmental_extra]
221+
lib_deps =
222+
${environmental_extra_common.lib_deps}
223+
# renovate: datasource=custom.pio depName=Bosch BSEC2 packageName=boschsensortec/library/bsec2
224+
boschsensortec/bsec2@1.10.2610
225+
# renovate: datasource=custom.pio depName=Bosch BME68x packageName=boschsensortec/library/BME68x Sensor Library
226+
boschsensortec/BME68x Sensor Library@1.3.40408
227+
228+
; Environmental sensors without BSEC (saves ~3.5KB DRAM for original ESP32 targets)
222229
[environmental_extra_no_bsec]
223230
lib_deps =
224-
# renovate: datasource=custom.pio depName=Adafruit BMP3XX packageName=adafruit/library/Adafruit BMP3XX Library
225-
adafruit/Adafruit BMP3XX Library@2.1.6
226-
# renovate: datasource=custom.pio depName=Adafruit MAX1704X packageName=adafruit/library/Adafruit MAX1704X
227-
adafruit/Adafruit MAX1704X@1.0.3
228-
# renovate: datasource=custom.pio depName=Adafruit SHTC3 packageName=adafruit/library/Adafruit SHTC3 Library
229-
adafruit/Adafruit SHTC3 Library@1.0.2
230-
# renovate: datasource=custom.pio depName=Adafruit LPS2X packageName=adafruit/library/Adafruit LPS2X
231-
adafruit/Adafruit LPS2X@2.0.6
232-
# renovate: datasource=custom.pio depName=Adafruit SHT31 packageName=adafruit/library/Adafruit SHT31 Library
233-
adafruit/Adafruit SHT31 Library@2.2.2
234-
# renovate: datasource=custom.pio depName=Adafruit VEML7700 packageName=adafruit/library/Adafruit VEML7700 Library
235-
adafruit/Adafruit VEML7700 Library@2.1.6
236-
# renovate: datasource=custom.pio depName=Adafruit SHT4x packageName=adafruit/library/Adafruit SHT4x Library
237-
adafruit/Adafruit SHT4x Library@1.0.5
238-
# renovate: datasource=custom.pio depName=SparkFun Qwiic Scale NAU7802 packageName=sparkfun/library/SparkFun Qwiic Scale NAU7802 Arduino Library
239-
sparkfun/SparkFun Qwiic Scale NAU7802 Arduino Library@1.0.6
240-
# renovate: datasource=custom.pio depName=ClosedCube OPT3001 packageName=closedcube/library/ClosedCube OPT3001
241-
closedcube/ClosedCube OPT3001@1.1.2
242-
# renovate: datasource=git-refs depName=meshtastic-DFRobot_LarkWeatherStation packageName=https://github.com/meshtastic/DFRobot_LarkWeatherStation gitBranch=master
243-
https://github.com/meshtastic/DFRobot_LarkWeatherStation/archive/4de3a9cadef0f6a5220a8a906cf9775b02b0040d.zip
244-
# renovate: datasource=custom.pio depName=Sensirion Core packageName=sensirion/library/Sensirion Core
245-
sensirion/Sensirion Core@0.7.3
246-
# renovate: datasource=custom.pio depName=Sensirion I2C SCD4x packageName=sensirion/library/Sensirion I2C SCD4x
247-
sensirion/Sensirion I2C SCD4x@1.1.0
248-
# renovate: datasource=custom.pio depName=Sensirion I2C SFA3x packageName=sensirion/library/Sensirion I2C SFA3x
249-
sensirion/Sensirion I2C SFA3x@1.0.0
231+
${environmental_extra_common.lib_deps}
232+
# renovate: datasource=custom.pio depName=adafruit/Adafruit BME680 Library packageName=adafruit/library/Adafruit BME680
233+
adafruit/Adafruit BME680 Library@^2.0.5

src/AudioThread.h

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "configuration.h"
55
#include "main.h"
66
#include "sleep.h"
7+
#include <memory>
78

89
#ifdef HAS_I2S
910
#include <AudioFileSourcePROGMEM.h>
@@ -29,9 +30,9 @@ class AudioThread : public concurrency::OSThread
2930
io.digitalWrite(EXPANDS_AMP_EN, HIGH);
3031
#endif
3132
setCPUFast(true);
32-
rtttlFile = new AudioFileSourcePROGMEM(data, len);
33-
i2sRtttl = new AudioGeneratorRTTTL();
34-
i2sRtttl->begin(rtttlFile, audioOut);
33+
rtttlFile = std::unique_ptr<AudioFileSourcePROGMEM>(new AudioFileSourcePROGMEM(data, len));
34+
i2sRtttl = std::unique_ptr<AudioGeneratorRTTTL>(new AudioGeneratorRTTTL());
35+
i2sRtttl->begin(rtttlFile.get(), audioOut.get());
3536
}
3637

3738
// Also handles actually playing the RTTTL, needs to be called in loop
@@ -47,12 +48,10 @@ class AudioThread : public concurrency::OSThread
4748
{
4849
if (i2sRtttl != nullptr) {
4950
i2sRtttl->stop();
50-
delete i2sRtttl;
5151
i2sRtttl = nullptr;
5252
}
5353

5454
if (rtttlFile != nullptr) {
55-
delete rtttlFile;
5655
rtttlFile = nullptr;
5756
}
5857

@@ -66,16 +65,14 @@ class AudioThread : public concurrency::OSThread
6665
{
6766
if (i2sRtttl != nullptr) {
6867
i2sRtttl->stop();
69-
delete i2sRtttl;
7068
i2sRtttl = nullptr;
7169
}
7270

7371
#ifdef T_LORA_PAGER
7472
io.digitalWrite(EXPANDS_AMP_EN, HIGH);
7573
#endif
76-
ESP8266SAM *sam = new ESP8266SAM;
77-
sam->Say(audioOut, text);
78-
delete sam;
74+
auto sam = std::unique_ptr<ESP8266SAM>(new ESP8266SAM);
75+
sam->Say(audioOut.get(), text);
7976
setCPUFast(false);
8077
#ifdef T_LORA_PAGER
8178
io.digitalWrite(EXPANDS_AMP_EN, LOW);
@@ -96,15 +93,15 @@ class AudioThread : public concurrency::OSThread
9693
private:
9794
void initOutput()
9895
{
99-
audioOut = new AudioOutputI2S(1, AudioOutputI2S::EXTERNAL_I2S);
96+
audioOut = std::unique_ptr<AudioOutputI2S>(new AudioOutputI2S(1, AudioOutputI2S::EXTERNAL_I2S));
10097
audioOut->SetPinout(DAC_I2S_BCK, DAC_I2S_WS, DAC_I2S_DOUT, DAC_I2S_MCLK);
10198
audioOut->SetGain(0.2);
10299
};
103100

104-
AudioGeneratorRTTTL *i2sRtttl = nullptr;
105-
AudioOutputI2S *audioOut = nullptr;
101+
std::unique_ptr<AudioGeneratorRTTTL> i2sRtttl = nullptr;
102+
std::unique_ptr<AudioOutputI2S> audioOut = nullptr;
106103

107-
AudioFileSourcePROGMEM *rtttlFile = nullptr;
104+
std::unique_ptr<AudioFileSourcePROGMEM> rtttlFile = nullptr;
108105
};
109106

110107
#endif

src/Power.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -704,11 +704,11 @@ bool Power::setup()
704704
found = true;
705705
} else if (analogInit()) {
706706
found = true;
707-
}
708-
707+
} else {
709708
#ifdef NRF_APM
710-
found = true;
709+
found = true;
711710
#endif
711+
}
712712
#ifdef EXT_PWR_DETECT
713713
attachInterrupt(
714714
EXT_PWR_DETECT,
@@ -846,8 +846,10 @@ void Power::readPowerStatus()
846846

847847
if (batteryLevel) {
848848
hasBattery = batteryLevel->isBatteryConnect() ? OptTrue : OptFalse;
849+
#ifndef NRF_APM
849850
usbPowered = batteryLevel->isVbusIn() ? OptTrue : OptFalse;
850851
isChargingNow = batteryLevel->isCharging() ? OptTrue : OptFalse;
852+
#endif
851853
if (hasBattery) {
852854
batteryVoltageMv = batteryLevel->getBattVoltage();
853855
// If the AXP192 returns a valid battery percentage, use it

src/configuration.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
244244
#define BQ25896_ADDR 0x6B
245245
#define LTR553ALS_ADDR 0x23
246246
#define SEN5X_ADDR 0x69
247+
#define SCD30_ADDR 0x61
247248

248249
// -----------------------------------------------------------------------------
249250
// ACCELEROMETER

src/detect/ScanI2C.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ class ScanI2C
9191
CST226SE,
9292
SEN5X,
9393
SFA30,
94-
CW2015
94+
CW2015,
95+
SCD30
9596
} DeviceType;
9697

9798
// typedef uint8_t DeviceAddress;

src/detect/ScanI2CTwoWire.cpp

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,25 @@ uint16_t ScanI2CTwoWire::getRegisterValue(const ScanI2CTwoWire::RegisterLocation
117117
return value;
118118
}
119119

120+
bool ScanI2CTwoWire::i2cCommandResponseLength(ScanI2C::DeviceAddress addr, uint16_t command, uint8_t expectedLength) const
121+
{
122+
TwoWire *i2cBus = fetchI2CBus(addr);
123+
i2cBus->beginTransmission(addr.address);
124+
if (command > 0xFF) {
125+
i2cBus->write((uint8_t)(command >> 8));
126+
}
127+
i2cBus->write((uint8_t)(command & 0xFF));
128+
if (i2cBus->endTransmission() != 0) {
129+
return false;
130+
}
131+
delay(20);
132+
uint8_t received = i2cBus->requestFrom(addr.address, expectedLength);
133+
bool match = (received == expectedLength);
134+
while (i2cBus->available())
135+
i2cBus->read();
136+
return match;
137+
}
138+
120139
/// for SEN5X detection
121140
// Note, this code needs to be called before setting the I2C bus speed
122141
// for the screen at high speed. The speed needs to be at 100kHz, otherwise
@@ -432,8 +451,7 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
432451
if (getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x7E), 2) == 0x5449) {
433452
type = OPT3001;
434453
logFoundDevice("OPT3001", (uint8_t)addr.address);
435-
} else if (getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x89), 6) !=
436-
0) { // unique SHT4x serial number (6 bytes inc. CRC)
454+
} else if (i2cCommandResponseLength(addr, 0x89, 6)) { // SHT4x serial number (6 bytes inc. CRC)
437455
type = SHT4X;
438456
logFoundDevice("SHT4X", (uint8_t)addr.address);
439457
} else {
@@ -458,13 +476,19 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
458476
break;
459477

460478
case LPS22HB_ADDR_ALT:
461-
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0xD060), 48); // get device marking
462-
if (registerValue != 0) {
479+
// SFA30 detection: send 2-byte command 0xD060 (Get Device Marking) and check for 48-byte response
480+
if (i2cCommandResponseLength(addr, 0xD060, 48)) {
463481
type = SFA30;
464482
logFoundDevice("SFA30", (uint8_t)addr.address);
465483
break;
466484
}
467-
// TODO - What happens with these two?
485+
// Fallback: LPS22HB detection at alternate address using WHO_AM_I register (0x0F == 0xB1)
486+
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x0F), 1);
487+
if (registerValue == 0xB1) {
488+
type = LPS22HB;
489+
logFoundDevice("LPS22HB", (uint8_t)addr.address);
490+
}
491+
break;
468492
SCAN_SIMPLE_CASE(LPS22HB_ADDR, LPS22HB, "LPS22HB", (uint8_t)addr.address)
469493
SCAN_SIMPLE_CASE(QMC6310U_ADDR, QMC6310U, "QMC6310U", (uint8_t)addr.address)
470494

@@ -557,6 +581,7 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
557581
SCAN_SIMPLE_CASE(DFROBOT_RAIN_ADDR, DFROBOT_RAIN, "DFRobot Rain Gauge", (uint8_t)addr.address);
558582
SCAN_SIMPLE_CASE(LTR390UV_ADDR, LTR390UV, "LTR390UV", (uint8_t)addr.address);
559583
SCAN_SIMPLE_CASE(PCT2075_ADDR, PCT2075, "PCT2075", (uint8_t)addr.address);
584+
SCAN_SIMPLE_CASE(SCD30_ADDR, SCD30, "SCD30", (uint8_t)addr.address);
560585
case CST328_ADDR:
561586
// Do we have the CST328 or the CST226SE
562587
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0xAB), 1);

src/detect/ScanI2CTwoWire.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ class ScanI2CTwoWire : public ScanI2C
5555

5656
uint16_t getRegisterValue(const RegisterLocation &, ResponseWidth, bool) const;
5757

58+
bool i2cCommandResponseLength(DeviceAddress addr, uint16_t command, uint8_t expectedLength) const;
59+
5860
DeviceType probeOLED(ScanI2C::DeviceAddress) const;
5961

6062
static void logFoundDevice(const char *device, uint8_t address);

src/gps/RTC.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ const char *RtcName(RTCQuality quality)
312312
* @param t The time to potentially set the RTC to.
313313
* @return True if the RTC was set to the provided time, false otherwise.
314314
*/
315-
RTCSetResult perhapsSetRTC(RTCQuality q, struct tm &t)
315+
RTCSetResult perhapsSetRTC(RTCQuality q, const struct tm &t)
316316
{
317317
/* Convert to unix time
318318
The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of seconds that have elapsed since January 1, 1970

0 commit comments

Comments
 (0)