mirror of
https://github.com/alexhopeoconnor/firmware.git
synced 2026-10-06 12:10:59 +10:00
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
81bde47cd4 | ||
|
|
370f62a8c9 | ||
|
|
a43ce34143 | ||
|
|
fa5631523e |
@@ -59,14 +59,8 @@ BuildRequires: pkgconfig(libbsd-overlay)
|
||||
|
||||
Requires: systemd-udev
|
||||
|
||||
# Declare that this package provides the user/group it creates in %pre
|
||||
# Required for Fedora 43+ which tracks users/groups as RPM dependencies
|
||||
Provides: user(%{meshtasticd_user})
|
||||
Provides: group(%{meshtasticd_user})
|
||||
Provides: group(spi)
|
||||
|
||||
%description
|
||||
Meshtastic daemon. Meshtastic is an off-grid
|
||||
Meshtastic daemon for controlling Meshtastic devices. Meshtastic is an off-grid
|
||||
text communication platform that uses inexpensive LoRa radios.
|
||||
|
||||
%prep
|
||||
@@ -157,7 +151,6 @@ fi
|
||||
%license LICENSE
|
||||
%doc README.md
|
||||
%{_bindir}/meshtasticd
|
||||
%{_bindir}/meshtasticd-start.sh
|
||||
%dir %{_localstatedir}/lib/meshtasticd
|
||||
%{_udevrulesdir}/99-meshtasticd-udev.rules
|
||||
%dir %{_sysconfdir}/meshtasticd
|
||||
|
||||
@@ -50,7 +50,6 @@ build_flags = -Wno-missing-field-initializers
|
||||
-DRADIOLIB_EXCLUDE_APRS=1
|
||||
-DRADIOLIB_EXCLUDE_LORAWAN=1
|
||||
-DMESHTASTIC_EXCLUDE_DROPZONE=1
|
||||
-DMESHTASTIC_EXCLUDE_REPLYBOT=1
|
||||
-DMESHTASTIC_EXCLUDE_REMOTEHARDWARE=1
|
||||
-DMESHTASTIC_EXCLUDE_HEALTH_TELEMETRY=1
|
||||
-DMESHTASTIC_EXCLUDE_POWERSTRESS=1 ; exclude power stress test module from main firmware
|
||||
@@ -214,8 +213,6 @@ lib_deps =
|
||||
sensirion/Sensirion Core@0.7.2
|
||||
# renovate: datasource=custom.pio depName=Sensirion I2C SCD4x packageName=sensirion/library/Sensirion I2C SCD4x
|
||||
sensirion/Sensirion I2C SCD4x@1.1.0
|
||||
# renovate: datasource=custom.pio depName=Sensirion I2C STC3x packageName=sensirion/library/Sensirion I2C STC3x
|
||||
sensirion/Sensirion I2C STC3x@1.0.1
|
||||
|
||||
; Same as environmental_extra but without BSEC (saves ~3.5KB DRAM for original ESP32 targets)
|
||||
[environmental_extra_no_bsec]
|
||||
@@ -244,5 +241,3 @@ lib_deps =
|
||||
sensirion/Sensirion Core@0.7.2
|
||||
# renovate: datasource=custom.pio depName=Sensirion I2C SCD4x packageName=sensirion/library/Sensirion I2C SCD4x
|
||||
sensirion/Sensirion I2C SCD4x@1.1.0
|
||||
# renovate: datasource=custom.pio depName=Sensirion I2C STC3x packageName=sensirion/library/Sensirion I2C STC3x
|
||||
sensirion/Sensirion I2C STC3x@1.0.1
|
||||
|
||||
+1
-1
Submodule protobufs updated: e1a6b3a868...e80cb2e410
+10
-2
@@ -89,14 +89,22 @@ class BluetoothStatus : public Status
|
||||
case ConnectionState::CONNECTED:
|
||||
LOG_DEBUG("BluetoothStatus CONNECTED");
|
||||
#ifdef BLE_LED
|
||||
digitalWrite(BLE_LED, LED_STATE_ON);
|
||||
#ifdef BLE_LED_INVERTED
|
||||
digitalWrite(BLE_LED, LOW);
|
||||
#else
|
||||
digitalWrite(BLE_LED, HIGH);
|
||||
#endif
|
||||
#endif
|
||||
break;
|
||||
|
||||
case ConnectionState::DISCONNECTED:
|
||||
LOG_DEBUG("BluetoothStatus DISCONNECTED");
|
||||
#ifdef BLE_LED
|
||||
digitalWrite(BLE_LED, LED_STATE_OFF);
|
||||
#ifdef BLE_LED_INVERTED
|
||||
digitalWrite(BLE_LED, HIGH);
|
||||
#else
|
||||
digitalWrite(BLE_LED, LOW);
|
||||
#endif
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
#include "Led.h"
|
||||
#include "PowerMon.h"
|
||||
#include "main.h"
|
||||
#include "power.h"
|
||||
|
||||
GpioVirtPin ledForceOn, ledBlink;
|
||||
|
||||
#if defined(LED_PIN)
|
||||
// Most boards have a GPIO for LED control
|
||||
static GpioHwPin ledRawHwPin(LED_PIN);
|
||||
#else
|
||||
static GpioVirtPin ledRawHwPin; // Dummy pin for no hardware
|
||||
#endif
|
||||
|
||||
#if LED_STATE_ON == 0
|
||||
static GpioVirtPin ledHwPin;
|
||||
static GpioNotTransformer ledInverter(&ledHwPin, &ledRawHwPin);
|
||||
#else
|
||||
static GpioPin &ledHwPin = ledRawHwPin;
|
||||
#endif
|
||||
|
||||
#if defined(HAS_PMU)
|
||||
/**
|
||||
* A GPIO controlled by the PMU
|
||||
*/
|
||||
class GpioPmuPin : public GpioPin
|
||||
{
|
||||
public:
|
||||
void set(bool value)
|
||||
{
|
||||
if (pmu_found && PMU) {
|
||||
// blink the axp led
|
||||
PMU->setChargingLedMode(value ? XPOWERS_CHG_LED_ON : XPOWERS_CHG_LED_OFF);
|
||||
}
|
||||
}
|
||||
} ledPmuHwPin;
|
||||
|
||||
// In some cases we need to drive a PMU LED and a normal LED
|
||||
static GpioSplitter ledFinalPin(&ledHwPin, &ledPmuHwPin);
|
||||
#else
|
||||
static GpioPin &ledFinalPin = ledHwPin;
|
||||
#endif
|
||||
|
||||
#ifdef USE_POWERMON
|
||||
/**
|
||||
* We monitor changes to the LED drive output because we use that as a sanity test in our power monitor stuff.
|
||||
*/
|
||||
class MonitoredLedPin : public GpioPin
|
||||
{
|
||||
public:
|
||||
void set(bool value)
|
||||
{
|
||||
if (powerMon) {
|
||||
if (value)
|
||||
powerMon->setState(meshtastic_PowerMon_State_LED_On);
|
||||
else
|
||||
powerMon->clearState(meshtastic_PowerMon_State_LED_On);
|
||||
}
|
||||
ledFinalPin.set(value);
|
||||
}
|
||||
} monitoredLedPin;
|
||||
#else
|
||||
static GpioPin &monitoredLedPin = ledFinalPin;
|
||||
#endif
|
||||
|
||||
static GpioBinaryTransformer ledForcer(&ledForceOn, &ledBlink, &monitoredLedPin, GpioBinaryTransformer::Or);
|
||||
@@ -0,0 +1,7 @@
|
||||
#include "GpioLogic.h"
|
||||
#include "configuration.h"
|
||||
|
||||
/**
|
||||
* ledForceOn and ledForceOff both override the normal ledBlinker behavior (which is controlled by main)
|
||||
*/
|
||||
extern GpioVirtPin ledForceOn, ledBlink;
|
||||
+8
-93
@@ -459,8 +459,6 @@ class AnalogBatteryLevel : public HasBatteryLevel
|
||||
}
|
||||
// if it's not HIGH - check the battery
|
||||
#endif
|
||||
// If we have an EXT_PWR_DETECT pin and it indicates no external power, believe it.
|
||||
return false;
|
||||
|
||||
// technically speaking this should work for all(?) NRF52 boards
|
||||
// but needs testing across multiple devices. NRF52 USB would not even work if
|
||||
@@ -692,9 +690,7 @@ bool Power::setup()
|
||||
bool found = false;
|
||||
if (axpChipInit()) {
|
||||
found = true;
|
||||
} else if (cw2015Init()) {
|
||||
found = true;
|
||||
} else if (max17048Init()) {
|
||||
} else if (lipoInit()) {
|
||||
found = true;
|
||||
} else if (lipoChargerInit()) {
|
||||
found = true;
|
||||
@@ -1323,7 +1319,7 @@ bool Power::axpChipInit()
|
||||
/**
|
||||
* Wrapper class for an I2C MAX17048 Lipo battery sensor.
|
||||
*/
|
||||
class MAX17048BatteryLevel : public HasBatteryLevel
|
||||
class LipoBatteryLevel : public HasBatteryLevel
|
||||
{
|
||||
private:
|
||||
MAX17048Singleton *max17048 = nullptr;
|
||||
@@ -1371,18 +1367,18 @@ class MAX17048BatteryLevel : public HasBatteryLevel
|
||||
virtual bool isCharging() override { return max17048->isBatteryCharging(); }
|
||||
};
|
||||
|
||||
MAX17048BatteryLevel max17048Level;
|
||||
LipoBatteryLevel lipoLevel;
|
||||
|
||||
/**
|
||||
* Init the Lipo battery level sensor
|
||||
*/
|
||||
bool Power::max17048Init()
|
||||
bool Power::lipoInit()
|
||||
{
|
||||
bool result = max17048Level.runOnce();
|
||||
LOG_DEBUG("Power::max17048Init lipo sensor is %s", result ? "ready" : "not ready yet");
|
||||
bool result = lipoLevel.runOnce();
|
||||
LOG_DEBUG("Power::lipoInit lipo sensor is %s", result ? "ready" : "not ready yet");
|
||||
if (!result)
|
||||
return false;
|
||||
batteryLevel = &max17048Level;
|
||||
batteryLevel = &lipoLevel;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1390,88 +1386,7 @@ bool Power::max17048Init()
|
||||
/**
|
||||
* The Lipo battery level sensor is unavailable - default to AnalogBatteryLevel
|
||||
*/
|
||||
bool Power::max17048Init()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !MESHTASTIC_EXCLUDE_I2C && HAS_CW2015
|
||||
|
||||
class CW2015BatteryLevel : public AnalogBatteryLevel
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Battery state of charge, from 0 to 100 or -1 for unknown
|
||||
*/
|
||||
virtual int getBatteryPercent() override
|
||||
{
|
||||
int data = -1;
|
||||
Wire.beginTransmission(CW2015_ADDR);
|
||||
Wire.write(0x04);
|
||||
if (Wire.endTransmission() == 0) {
|
||||
if (Wire.requestFrom(CW2015_ADDR, (uint8_t)1)) {
|
||||
data = Wire.read();
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* The raw voltage of the battery in millivolts, or NAN if unknown
|
||||
*/
|
||||
virtual uint16_t getBattVoltage() override
|
||||
{
|
||||
uint16_t mv = 0;
|
||||
Wire.beginTransmission(CW2015_ADDR);
|
||||
Wire.write(0x02);
|
||||
if (Wire.endTransmission() == 0) {
|
||||
if (Wire.requestFrom(CW2015_ADDR, (uint8_t)2)) {
|
||||
mv = Wire.read();
|
||||
mv <<= 8;
|
||||
mv |= Wire.read();
|
||||
// Voltage is read in 305uV units, convert to mV
|
||||
mv = mv * 305 / 1000;
|
||||
}
|
||||
}
|
||||
return mv;
|
||||
}
|
||||
};
|
||||
|
||||
CW2015BatteryLevel cw2015Level;
|
||||
|
||||
/**
|
||||
* Init the CW2015 battery level sensor
|
||||
*/
|
||||
bool Power::cw2015Init()
|
||||
{
|
||||
|
||||
Wire.beginTransmission(CW2015_ADDR);
|
||||
uint8_t getInfo[] = {0x0a, 0x00};
|
||||
Wire.write(getInfo, 2);
|
||||
Wire.endTransmission();
|
||||
delay(10);
|
||||
Wire.beginTransmission(CW2015_ADDR);
|
||||
Wire.write(0x00);
|
||||
bool result = false;
|
||||
if (Wire.endTransmission() == 0) {
|
||||
if (Wire.requestFrom(CW2015_ADDR, (uint8_t)1)) {
|
||||
uint8_t data = Wire.read();
|
||||
LOG_DEBUG("CW2015 init read data: 0x%x", data);
|
||||
if (data == 0x73) {
|
||||
result = true;
|
||||
batteryLevel = &cw2015Level;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#else
|
||||
/**
|
||||
* The CW2015 battery level sensor is unavailable - default to AnalogBatteryLevel
|
||||
*/
|
||||
bool Power::cw2015Init()
|
||||
bool Power::lipoInit()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
+4
-4
@@ -9,13 +9,13 @@
|
||||
*/
|
||||
#include "PowerFSM.h"
|
||||
#include "Default.h"
|
||||
#include "Led.h"
|
||||
#include "MeshService.h"
|
||||
#include "NodeDB.h"
|
||||
#include "PowerMon.h"
|
||||
#include "configuration.h"
|
||||
#include "graphics/Screen.h"
|
||||
#include "main.h"
|
||||
#include "modules/StatusLEDModule.h"
|
||||
#include "sleep.h"
|
||||
#include "target_specific.h"
|
||||
|
||||
@@ -103,7 +103,7 @@ static void lsIdle()
|
||||
uint32_t sleepTime = SLEEP_TIME;
|
||||
|
||||
powerMon->setState(meshtastic_PowerMon_State_CPU_LightSleep);
|
||||
statusLEDModule->setPowerLED(false);
|
||||
ledBlink.set(false); // Never leave led on while in light sleep
|
||||
esp_sleep_source_t wakeCause2 = doLightSleep(sleepTime * 1000LL);
|
||||
powerMon->clearState(meshtastic_PowerMon_State_CPU_LightSleep);
|
||||
|
||||
@@ -111,7 +111,7 @@ static void lsIdle()
|
||||
case ESP_SLEEP_WAKEUP_TIMER:
|
||||
// Normal case: timer expired, we should just go back to sleep ASAP
|
||||
|
||||
statusLEDModule->setPowerLED(true);
|
||||
ledBlink.set(true); // briefly turn on led
|
||||
wakeCause2 = doLightSleep(100); // leave led on for 1ms
|
||||
|
||||
secsSlept += sleepTime;
|
||||
@@ -146,7 +146,7 @@ static void lsIdle()
|
||||
}
|
||||
} else {
|
||||
// Time to stop sleeping!
|
||||
statusLEDModule->setPowerLED(false);
|
||||
ledBlink.set(false);
|
||||
LOG_INFO("Reached ls_secs, service loop()");
|
||||
powerFSM.trigger(EVENT_WAKE_TIMER);
|
||||
}
|
||||
|
||||
@@ -233,8 +233,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#define NAU7802_ADDR 0x2A
|
||||
#define MAX30102_ADDR 0x57
|
||||
#define SCD4X_ADDR 0x62
|
||||
#define CW2015_ADDR 0x62
|
||||
#define STC31_ADDR 0x2c // RAK12008 uses 0x2C address
|
||||
#define MLX90614_ADDR_DEF 0x5A
|
||||
#define CGRADSENS_ADDR 0x66
|
||||
#define LTR390UV_ADDR 0x53
|
||||
|
||||
@@ -43,7 +43,7 @@ ScanI2C::FoundDevice ScanI2C::firstAccelerometer() const
|
||||
|
||||
ScanI2C::FoundDevice ScanI2C::firstAQI() const
|
||||
{
|
||||
ScanI2C::DeviceType types[] = {PMSA003I, SEN5X, SCD4X};
|
||||
ScanI2C::DeviceType types[] = {PMSA003I, SCD4X};
|
||||
return firstOfOrNONE(2, types);
|
||||
}
|
||||
|
||||
|
||||
@@ -89,9 +89,7 @@ class ScanI2C
|
||||
DA217,
|
||||
CHSC6X,
|
||||
CST226SE,
|
||||
CW2015,
|
||||
SEN5X,
|
||||
STC31
|
||||
SEN5X
|
||||
} DeviceType;
|
||||
|
||||
// typedef uint8_t DeviceAddress;
|
||||
|
||||
@@ -154,42 +154,6 @@ String readSEN5xProductName(TwoWire *i2cBus, uint8_t address)
|
||||
return String(productName);
|
||||
}
|
||||
|
||||
/// for STC31 detection - probe by reading product identifier
|
||||
/// Uses two-step sequence: prepareProductIdentifier (0x367c) then readProductIdentifier (0xe102)
|
||||
bool probeSTC31(TwoWire *i2cBus, uint8_t address)
|
||||
{
|
||||
// Step 1: Send prepare product identifier command (0x367c)
|
||||
uint8_t prepCmd[] = {0x36, 0x7c};
|
||||
i2cBus->beginTransmission(address);
|
||||
i2cBus->write(prepCmd, 2);
|
||||
if (i2cBus->endTransmission() != 0)
|
||||
return false;
|
||||
delay(1);
|
||||
|
||||
// Step 2: Send read product identifier command (0xe102)
|
||||
uint8_t readCmd[] = {0xe1, 0x02};
|
||||
i2cBus->beginTransmission(address);
|
||||
i2cBus->write(readCmd, 2);
|
||||
if (i2cBus->endTransmission() != 0)
|
||||
return false;
|
||||
delay(10);
|
||||
|
||||
// Read 6 bytes: product number (4 bytes with CRC) + more data
|
||||
// Product number is 32-bit: STC31 = 0x08010301
|
||||
if (i2cBus->requestFrom(address, (uint8_t)6) != 6)
|
||||
return false;
|
||||
|
||||
uint8_t response[6] = {0};
|
||||
for (int i = 0; i < 6 && i2cBus->available(); ++i) {
|
||||
response[i] = i2cBus->read();
|
||||
}
|
||||
|
||||
uint32_t productId =
|
||||
((uint32_t)response[0] << 24) | ((uint32_t)response[1] << 16) | ((uint32_t)response[3] << 8) | response[4];
|
||||
|
||||
return productId == 0x08010301;
|
||||
}
|
||||
|
||||
#define SCAN_SIMPLE_CASE(ADDR, T, ...) \
|
||||
case ADDR: \
|
||||
logFoundDevice(__VA_ARGS__); \
|
||||
@@ -568,23 +532,13 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
|
||||
}
|
||||
break;
|
||||
case TSL25911_ADDR:
|
||||
// TSL25911_ADDR (0x29) is shared by TSL2591, TSL2561, and STC31
|
||||
// Probe for STC31 first (Sensirion CO2 sensor)
|
||||
LOG_DEBUG("Probing address 0x29 for STC31...");
|
||||
if (probeSTC31(i2cBus, addr.address)) {
|
||||
type = STC31;
|
||||
LOG_DEBUG("STC31 probe successful!");
|
||||
logFoundDevice("STC31", (uint8_t)addr.address);
|
||||
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0xA0 | 0x12), 1);
|
||||
if (registerValue == 0x50) {
|
||||
type = TSL2591;
|
||||
logFoundDevice("TSL25911", (uint8_t)addr.address);
|
||||
} else {
|
||||
LOG_DEBUG("STC31 probe failed, checking for TSL sensors...");
|
||||
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0xA0 | 0x12), 1);
|
||||
if (registerValue == 0x50) {
|
||||
type = TSL2591;
|
||||
logFoundDevice("TSL25911", (uint8_t)addr.address);
|
||||
} else {
|
||||
type = TSL2561;
|
||||
logFoundDevice("TSL2561", (uint8_t)addr.address);
|
||||
}
|
||||
type = TSL2561;
|
||||
logFoundDevice("TSL2561", (uint8_t)addr.address);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -594,18 +548,6 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
|
||||
SCAN_SIMPLE_CASE(DFROBOT_RAIN_ADDR, DFROBOT_RAIN, "DFRobot Rain Gauge", (uint8_t)addr.address);
|
||||
SCAN_SIMPLE_CASE(LTR390UV_ADDR, LTR390UV, "LTR390UV", (uint8_t)addr.address);
|
||||
SCAN_SIMPLE_CASE(PCT2075_ADDR, PCT2075, "PCT2075", (uint8_t)addr.address);
|
||||
case STC31_ADDR:
|
||||
// RAK12008 uses address 0x2C for STC31
|
||||
LOG_DEBUG("Probing address 0x2c for STC31...");
|
||||
if (probeSTC31(i2cBus, addr.address)) {
|
||||
type = STC31;
|
||||
LOG_DEBUG("STC31 probe successful at 0x2c!");
|
||||
logFoundDevice("STC31", (uint8_t)addr.address);
|
||||
} else {
|
||||
LOG_DEBUG("STC31 probe failed at 0x2c");
|
||||
LOG_INFO("Device found at address 0x%x was not able to be enumerated", (uint8_t)addr.address);
|
||||
}
|
||||
break;
|
||||
case CST328_ADDR:
|
||||
// Do we have the CST328 or the CST226SE
|
||||
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0xAB), 1);
|
||||
@@ -639,17 +581,7 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
|
||||
break;
|
||||
|
||||
SCAN_SIMPLE_CASE(BHI260AP_ADDR, BHI260AP, "BHI260AP", (uint8_t)addr.address);
|
||||
case SCD4X_ADDR: {
|
||||
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x8), 1);
|
||||
if (registerValue == 0x18) {
|
||||
logFoundDevice("CW2015", (uint8_t)addr.address);
|
||||
type = CW2015;
|
||||
} else {
|
||||
logFoundDevice("SCD4X", (uint8_t)addr.address);
|
||||
type = SCD4X;
|
||||
}
|
||||
break;
|
||||
}
|
||||
SCAN_SIMPLE_CASE(SCD4X_ADDR, SCD4X, "SCD4X", (uint8_t)addr.address);
|
||||
SCAN_SIMPLE_CASE(BMM150_ADDR, BMM150, "BMM150", (uint8_t)addr.address);
|
||||
#ifdef HAS_TPS65233
|
||||
SCAN_SIMPLE_CASE(TPS65233_ADDR, TPS65233, "TPS65233", (uint8_t)addr.address);
|
||||
|
||||
@@ -221,6 +221,7 @@ void drawCommonHeader(OLEDDisplay *display, int16_t x, int16_t y, const char *ti
|
||||
|
||||
if (rtc_sec > 0) {
|
||||
// === Build Time String ===
|
||||
long hms = (rtc_sec % SEC_PER_DAY + SEC_PER_DAY) % SEC_PER_DAY;
|
||||
int hour, minute, second;
|
||||
graphics::decomposeTime(rtc_sec, hour, minute, second);
|
||||
snprintf(timeStr, sizeof(timeStr), "%d:%02d", hour, minute);
|
||||
|
||||
@@ -429,10 +429,6 @@ void VirtualKeyboard::drawKey(OLEDDisplay *display, const VirtualKey &key, bool
|
||||
c = c - 'a' + 'A';
|
||||
}
|
||||
keyText = (key.character == ' ' || key.character == '_') ? "_" : std::string(1, c);
|
||||
// Show the common "/" pairing next to "?" like on a real keyboard
|
||||
if (key.type == VK_CHAR && key.character == '?') {
|
||||
keyText = "?/";
|
||||
}
|
||||
}
|
||||
|
||||
int textWidth = display->getStringWidth(keyText.c_str());
|
||||
@@ -522,13 +518,9 @@ char VirtualKeyboard::getCharForKey(const VirtualKey &key, bool isLongPress)
|
||||
|
||||
char c = key.character;
|
||||
|
||||
// Long-press: letters become uppercase; for "?" provide "/" like a typical keyboard
|
||||
if (isLongPress) {
|
||||
if (c >= 'a' && c <= 'z') {
|
||||
c = (char)(c - 'a' + 'A');
|
||||
} else if (c == '?') {
|
||||
c = '/';
|
||||
}
|
||||
// Long-press: only keep letter lowercase->uppercase conversion; remove other symbol mappings
|
||||
if (isLongPress && c >= 'a' && c <= 'z') {
|
||||
c = (char)(c - 'a' + 'A');
|
||||
}
|
||||
|
||||
return c;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "graphics/niche/InkHUD/Tile.h"
|
||||
#include <cstdint>
|
||||
#ifdef MESHTASTIC_INCLUDE_INKHUD
|
||||
|
||||
#include "./Applet.h"
|
||||
@@ -787,16 +785,6 @@ void InkHUD::Applet::drawHeader(std::string text)
|
||||
drawPixel(x, 0, BLACK);
|
||||
drawPixel(x, headerDivY, BLACK); // Dotted 50%
|
||||
}
|
||||
|
||||
// Dither near battery
|
||||
if (settings->optionalFeatures.batteryIcon) {
|
||||
constexpr uint16_t ditherSizePx = 4;
|
||||
Tile *batteryTile = ((Applet *)inkhud->getSystemApplet("BatteryIcon"))->getTile();
|
||||
const uint16_t batteryTileLeft = batteryTile->getLeft();
|
||||
const uint16_t batteryTileTop = batteryTile->getTop();
|
||||
const uint16_t batteryTileHeight = batteryTile->getHeight();
|
||||
hatchRegion(batteryTileLeft - ditherSizePx, batteryTileTop, ditherSizePx, batteryTileHeight, 2, WHITE);
|
||||
}
|
||||
}
|
||||
|
||||
// Get the height of the standard applet header
|
||||
|
||||
@@ -48,27 +48,37 @@ int InkHUD::BatteryIconApplet::onPowerStatusUpdate(const meshtastic::Status *sta
|
||||
|
||||
void InkHUD::BatteryIconApplet::onRender(bool full)
|
||||
{
|
||||
// Clear the region beneath the tile, including the border
|
||||
// Fill entire tile
|
||||
// - size of icon controlled by size of tile
|
||||
int16_t l = 0;
|
||||
int16_t t = 0;
|
||||
uint16_t w = width();
|
||||
int16_t h = height();
|
||||
|
||||
// Clear the region beneath the tile
|
||||
// Most applets are drawing onto an empty frame buffer and don't need to do this
|
||||
// We do need to do this with the battery though, as it is an "overlay"
|
||||
fillRect(0, 0, width(), height(), WHITE);
|
||||
fillRect(l, t, w, h, WHITE);
|
||||
|
||||
// Vertical centerline
|
||||
const int16_t m = t + (h / 2);
|
||||
|
||||
// =====================
|
||||
// Draw battery outline
|
||||
// =====================
|
||||
|
||||
// Positive terminal "bump"
|
||||
const int16_t &bumpL = l;
|
||||
const uint16_t bumpH = h / 2;
|
||||
const int16_t bumpT = m - (bumpH / 2);
|
||||
constexpr uint16_t bumpW = 2;
|
||||
const int16_t &bumpL = 1;
|
||||
const uint16_t bumpH = (height() - 2) / 2;
|
||||
const int16_t bumpT = (1 + ((height() - 2) / 2)) - (bumpH / 2);
|
||||
fillRect(bumpL, bumpT, bumpW, bumpH, BLACK);
|
||||
|
||||
// Main body of battery
|
||||
const int16_t bodyL = 1 + bumpW;
|
||||
const int16_t &bodyT = 1;
|
||||
const int16_t &bodyH = height() - 2; // Handle top/bottom padding
|
||||
const int16_t bodyW = (width() - 1) - bumpW; // Handle 1px left pad
|
||||
const int16_t bodyL = bumpL + bumpW;
|
||||
const int16_t &bodyT = t;
|
||||
const int16_t &bodyH = h;
|
||||
const int16_t bodyW = w - bumpW;
|
||||
drawRect(bodyL, bodyT, bodyW, bodyH, BLACK);
|
||||
|
||||
// Erase join between bump and body
|
||||
@@ -79,13 +89,12 @@ void InkHUD::BatteryIconApplet::onRender(bool full)
|
||||
// ===================
|
||||
|
||||
constexpr int16_t slicePad = 2;
|
||||
int16_t sliceL = bodyL + slicePad;
|
||||
const int16_t sliceL = bodyL + slicePad;
|
||||
const int16_t sliceT = bodyT + slicePad;
|
||||
const uint16_t sliceH = bodyH - (slicePad * 2);
|
||||
uint16_t sliceW = bodyW - (slicePad * 2);
|
||||
|
||||
sliceW = (sliceW * socRounded) / 100; // Apply percentage
|
||||
sliceL += ((bodyW - (slicePad * 2)) - sliceW); // Shift slice to the battery's negative terminal, correcting drain direction
|
||||
sliceW = (sliceW * socRounded) / 100; // Apply percentage
|
||||
|
||||
hatchRegion(sliceL, sliceT, sliceW, sliceH, 2, BLACK);
|
||||
drawRect(sliceL, sliceT, sliceW, sliceH, BLACK);
|
||||
|
||||
@@ -510,10 +510,10 @@ void InkHUD::WindowManager::placeSystemTiles()
|
||||
const uint16_t batteryIconWidth = batteryIconHeight * 1.8;
|
||||
inkhud->getSystemApplet("BatteryIcon")
|
||||
->getTile()
|
||||
->setRegion(inkhud->width() - batteryIconWidth - 1, // x
|
||||
1, // y
|
||||
batteryIconWidth + 1, // width
|
||||
batteryIconHeight + 2); // height
|
||||
->setRegion(inkhud->width() - batteryIconWidth, // x
|
||||
2, // y
|
||||
batteryIconWidth, // width
|
||||
batteryIconHeight); // height
|
||||
|
||||
// Note: the tiles of placeholder and menu applets are manipulated specially
|
||||
// - menuApplet borrows user tiles
|
||||
|
||||
+59
-20
@@ -7,13 +7,13 @@
|
||||
#include "NodeDB.h"
|
||||
#include "PowerFSM.h"
|
||||
#include "PowerMon.h"
|
||||
#include "RadioLibInterface.h"
|
||||
#include "ReliableRouter.h"
|
||||
#include "airtime.h"
|
||||
#include "buzz.h"
|
||||
#include "power/PowerHAL.h"
|
||||
|
||||
#include "FSCommon.h"
|
||||
#include "Led.h"
|
||||
#include "RTC.h"
|
||||
#include "SPILock.h"
|
||||
#include "Throttle.h"
|
||||
@@ -193,8 +193,6 @@ bool kb_found = false;
|
||||
// global bool to record that on-screen keyboard (OSK) is present
|
||||
bool osk_found = false;
|
||||
|
||||
unsigned long last_listen = 0;
|
||||
|
||||
// The I2C address of the RTC Module (if found)
|
||||
ScanI2C::DeviceAddress rtc_found = ScanI2C::ADDRESS_NONE;
|
||||
// The I2C address of the Accelerometer (if found)
|
||||
@@ -244,8 +242,26 @@ const char *getDeviceName()
|
||||
return name;
|
||||
}
|
||||
|
||||
// TODO remove from main.cpp
|
||||
static int32_t ledBlinker()
|
||||
{
|
||||
// Still set up the blinking (heartbeat) interval but skip code path below, so LED will blink if
|
||||
// config.device.led_heartbeat_disabled is changed
|
||||
if (config.device.led_heartbeat_disabled)
|
||||
return 1000;
|
||||
|
||||
static bool ledOn;
|
||||
ledOn ^= 1;
|
||||
|
||||
ledBlink.set(ledOn);
|
||||
|
||||
// have a very sparse duty cycle of LED being on, unless charging, then blink 0.5Hz square wave rate to indicate that
|
||||
return powerStatus->getIsCharging() ? 1000 : (ledOn ? 1 : 1000);
|
||||
}
|
||||
|
||||
uint32_t timeLastPowered = 0;
|
||||
|
||||
static Periodic *ledPeriodic;
|
||||
static OSThread *powerFSMthread;
|
||||
static OSThread *ambientLightingThread;
|
||||
|
||||
@@ -283,16 +299,21 @@ void earlyInitVariant() {}
|
||||
// blink user led in 3 flashes sequence to indicate what is happening
|
||||
void waitUntilPowerLevelSafe()
|
||||
{
|
||||
|
||||
#ifdef LED_PIN
|
||||
pinMode(LED_PIN, OUTPUT);
|
||||
#endif
|
||||
|
||||
while (powerHAL_isPowerLevelSafe() == false) {
|
||||
|
||||
#ifdef LED_POWER
|
||||
#ifdef LED_PIN
|
||||
|
||||
// 3x: blink for 300 ms, pause for 300 ms
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
digitalWrite(LED_POWER, LED_STATE_ON);
|
||||
digitalWrite(LED_PIN, LED_STATE_ON);
|
||||
delay(300);
|
||||
digitalWrite(LED_POWER, LED_STATE_OFF);
|
||||
digitalWrite(LED_PIN, LED_STATE_OFF);
|
||||
delay(300);
|
||||
}
|
||||
#endif
|
||||
@@ -316,11 +337,6 @@ void setup()
|
||||
// initialize power HAL layer as early as possible
|
||||
powerHAL_init();
|
||||
|
||||
#ifdef LED_POWER
|
||||
pinMode(LED_POWER, OUTPUT);
|
||||
digitalWrite(LED_POWER, LED_STATE_ON);
|
||||
#endif
|
||||
|
||||
// prevent booting if device is in power failure mode
|
||||
// boot sequence will follow when battery level raises to safe mode
|
||||
waitUntilPowerLevelSafe();
|
||||
@@ -333,6 +349,11 @@ void setup()
|
||||
digitalWrite(PIN_POWER_EN, HIGH);
|
||||
#endif
|
||||
|
||||
#ifdef LED_POWER
|
||||
pinMode(LED_POWER, OUTPUT);
|
||||
digitalWrite(LED_POWER, LED_STATE_ON);
|
||||
#endif
|
||||
|
||||
#ifdef LED_NOTIFICATION
|
||||
pinMode(LED_NOTIFICATION, OUTPUT);
|
||||
digitalWrite(LED_NOTIFICATION, HIGH ^ LED_STATE_ON);
|
||||
@@ -345,7 +366,11 @@ void setup()
|
||||
|
||||
#ifdef BLE_LED
|
||||
pinMode(BLE_LED, OUTPUT);
|
||||
digitalWrite(BLE_LED, LED_STATE_OFF);
|
||||
#ifdef BLE_LED_INVERTED
|
||||
digitalWrite(BLE_LED, HIGH);
|
||||
#else
|
||||
digitalWrite(BLE_LED, LOW);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
concurrency::hasBeenSetup = true;
|
||||
@@ -463,6 +488,14 @@ void setup()
|
||||
|
||||
OSThread::setup();
|
||||
|
||||
// TODO make this ifdef based on defined pins and move from main.cpp
|
||||
#if defined(ELECROW_ThinkNode_M1) || defined(ELECROW_ThinkNode_M2)
|
||||
// The ThinkNodes have their own blink logic
|
||||
// ledPeriodic = new Periodic("Blink", elecrowLedBlinker);
|
||||
#else
|
||||
ledPeriodic = new Periodic("Blink", ledBlinker);
|
||||
#endif
|
||||
|
||||
fsInit();
|
||||
|
||||
#if !MESHTASTIC_EXCLUDE_I2C
|
||||
@@ -680,13 +713,19 @@ void setup()
|
||||
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::ICM20948, meshtastic_TelemetrySensorType_ICM20948);
|
||||
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::MAX30102, meshtastic_TelemetrySensorType_MAX30102);
|
||||
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::SCD4X, meshtastic_TelemetrySensorType_SCD4X);
|
||||
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::STC31, meshtastic_TelemetrySensorType_STC31);
|
||||
#endif
|
||||
|
||||
#ifdef HAS_SDCARD
|
||||
setupSDCard();
|
||||
#endif
|
||||
|
||||
// LED init
|
||||
|
||||
#ifdef LED_PIN
|
||||
pinMode(LED_PIN, OUTPUT);
|
||||
digitalWrite(LED_PIN, LED_STATE_ON); // turn on for now
|
||||
#endif
|
||||
|
||||
// Hello
|
||||
printInfo();
|
||||
#ifdef BUILD_EPOCH
|
||||
@@ -794,7 +833,7 @@ void setup()
|
||||
SPI.begin();
|
||||
#endif
|
||||
#else
|
||||
// ESP32
|
||||
// ESP32
|
||||
#if defined(HW_SPI1_DEVICE)
|
||||
SPI1.begin(LORA_SCK, LORA_MISO, LORA_MOSI, LORA_CS);
|
||||
LOG_DEBUG("SPI1.begin(SCK=%d, MISO=%d, MOSI=%d, NSS=%d)", LORA_SCK, LORA_MISO, LORA_MOSI, LORA_CS);
|
||||
@@ -927,6 +966,12 @@ void setup()
|
||||
setupNicheGraphics();
|
||||
#endif
|
||||
|
||||
#ifdef LED_PIN
|
||||
// Turn LED off after boot, if heartbeat by config
|
||||
if (config.device.led_heartbeat_disabled)
|
||||
digitalWrite(LED_PIN, HIGH ^ LED_STATE_ON);
|
||||
#endif
|
||||
|
||||
// Do this after service.init (because that clears error_code)
|
||||
#ifdef HAS_PMU
|
||||
if (!pmu_found)
|
||||
@@ -1123,12 +1168,6 @@ void loop()
|
||||
#endif
|
||||
power->powerCommandsCheck();
|
||||
|
||||
if (RadioLibInterface::instance != nullptr && !Throttle::isWithinTimespanMs(last_listen, 1000 * 60) &&
|
||||
!(RadioLibInterface::instance->isSending() || RadioLibInterface::instance->isActivelyReceiving())) {
|
||||
RadioLibInterface::instance->startReceive();
|
||||
LOG_DEBUG("attempting AGC reset");
|
||||
}
|
||||
|
||||
#ifdef DEBUG_STACK
|
||||
static uint32_t lastPrint = 0;
|
||||
if (!Throttle::isWithinTimespanMs(lastPrint, 10 * 1000L)) {
|
||||
|
||||
@@ -33,7 +33,6 @@ extern ScanI2C::DeviceAddress cardkb_found;
|
||||
extern uint8_t kb_model;
|
||||
extern bool kb_found;
|
||||
extern bool osk_found;
|
||||
extern unsigned long last_listen;
|
||||
extern ScanI2C::DeviceAddress rtc_found;
|
||||
extern ScanI2C::DeviceAddress accelerometer_found;
|
||||
extern ScanI2C::FoundDevice rgb_found;
|
||||
|
||||
@@ -1408,15 +1408,6 @@ void NodeDB::loadFromDisk()
|
||||
if (portduino_config.has_configDisplayMode) {
|
||||
config.display.displaymode = (_meshtastic_Config_DisplayConfig_DisplayMode)portduino_config.configDisplayMode;
|
||||
}
|
||||
if (portduino_config.has_statusMessage) {
|
||||
moduleConfig.has_statusmessage = true;
|
||||
strncpy(moduleConfig.statusmessage.node_status, portduino_config.statusMessage.c_str(),
|
||||
sizeof(moduleConfig.statusmessage.node_status));
|
||||
moduleConfig.statusmessage.node_status[sizeof(moduleConfig.statusmessage.node_status) - 1] = '\0';
|
||||
}
|
||||
if (portduino_config.enable_UDP) {
|
||||
config.network.enabled_protocols = true;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
@@ -1557,7 +1548,6 @@ bool NodeDB::saveToDiskNoRetry(int saveWhat)
|
||||
moduleConfig.has_ambient_lighting = true;
|
||||
moduleConfig.has_audio = true;
|
||||
moduleConfig.has_paxcounter = true;
|
||||
moduleConfig.has_statusmessage = true;
|
||||
|
||||
success &=
|
||||
saveProto(moduleConfigFileName, meshtastic_LocalModuleConfig_size, &meshtastic_LocalModuleConfig_msg, &moduleConfig);
|
||||
|
||||
@@ -82,6 +82,7 @@ template <class T> class ProtobufModule : protected SinglePortModule
|
||||
// it would be better to update even if the message was destined to others.
|
||||
|
||||
auto &p = mp.decoded;
|
||||
LOG_INFO("Received %s from=0x%0x, id=0x%x, portnum=%d, payloadlen=%d", name, mp.from, mp.id, p.portnum, p.payload.size);
|
||||
|
||||
T scratch;
|
||||
T *decoded = NULL;
|
||||
@@ -89,8 +90,6 @@ template <class T> class ProtobufModule : protected SinglePortModule
|
||||
memset(&scratch, 0, sizeof(scratch));
|
||||
if (pb_decode_from_bytes(p.payload.bytes, p.payload.size, fields, &scratch)) {
|
||||
decoded = &scratch;
|
||||
LOG_INFO("Received %s from=0x%0x, id=0x%x, portnum=%d, payloadlen=%d", name, mp.from, mp.id, p.portnum,
|
||||
p.payload.size);
|
||||
} else {
|
||||
LOG_ERROR("Error decoding proto module!");
|
||||
// if we can't decode it, nobody can process it!
|
||||
|
||||
@@ -514,8 +514,6 @@ void RadioLibInterface::handleReceiveInterrupt()
|
||||
|
||||
void RadioLibInterface::startReceive()
|
||||
{
|
||||
// Note the updated timestamp, to avoid unneeded AGC resets
|
||||
last_listen = millis();
|
||||
isReceiving = true;
|
||||
powerMon->setState(meshtastic_PowerMon_State_Lora_RXOn);
|
||||
}
|
||||
|
||||
@@ -103,13 +103,7 @@ typedef enum _meshtastic_TelemetrySensorType {
|
||||
/* TSL2561 light sensor */
|
||||
meshtastic_TelemetrySensorType_TSL2561 = 44,
|
||||
/* BH1750 light sensor */
|
||||
meshtastic_TelemetrySensorType_BH1750 = 45,
|
||||
/* HDC1080 Temperature and Humidity Sensor */
|
||||
meshtastic_TelemetrySensorType_HDC1080 = 46,
|
||||
/* STH21 Temperature and R. Humidity sensor */
|
||||
meshtastic_TelemetrySensorType_SHT21 = 47,
|
||||
/* Sensirion STC31 CO2 sensor */
|
||||
meshtastic_TelemetrySensorType_STC31 = 48
|
||||
meshtastic_TelemetrySensorType_BH1750 = 45
|
||||
} meshtastic_TelemetrySensorType;
|
||||
|
||||
/* Struct definitions */
|
||||
@@ -467,8 +461,8 @@ extern "C" {
|
||||
|
||||
/* Helper constants for enums */
|
||||
#define _meshtastic_TelemetrySensorType_MIN meshtastic_TelemetrySensorType_SENSOR_UNSET
|
||||
#define _meshtastic_TelemetrySensorType_MAX meshtastic_TelemetrySensorType_STC31
|
||||
#define _meshtastic_TelemetrySensorType_ARRAYSIZE ((meshtastic_TelemetrySensorType)(meshtastic_TelemetrySensorType_STC31+1))
|
||||
#define _meshtastic_TelemetrySensorType_MAX meshtastic_TelemetrySensorType_BH1750
|
||||
#define _meshtastic_TelemetrySensorType_ARRAYSIZE ((meshtastic_TelemetrySensorType)(meshtastic_TelemetrySensorType_BH1750+1))
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#if HAS_WIFI
|
||||
#include "mesh/wifi/WiFiAPClient.h"
|
||||
#endif
|
||||
#include "Led.h"
|
||||
#include "SPILock.h"
|
||||
#include "power.h"
|
||||
#include "serialization/JSON.h"
|
||||
@@ -91,6 +92,7 @@ void registerHandlers(HTTPServer *insecureServer, HTTPSServer *secureServer)
|
||||
ResourceNode *nodeFormUpload = new ResourceNode("/upload", "POST", &handleFormUpload);
|
||||
|
||||
ResourceNode *nodeJsonScanNetworks = new ResourceNode("/json/scanNetworks", "GET", &handleScanNetworks);
|
||||
ResourceNode *nodeJsonBlinkLED = new ResourceNode("/json/blink", "POST", &handleBlinkLED);
|
||||
ResourceNode *nodeJsonReport = new ResourceNode("/json/report", "GET", &handleReport);
|
||||
ResourceNode *nodeJsonNodes = new ResourceNode("/json/nodes", "GET", &handleNodes);
|
||||
ResourceNode *nodeJsonFsBrowseStatic = new ResourceNode("/json/fs/browse/static", "GET", &handleFsBrowseStatic);
|
||||
@@ -108,6 +110,7 @@ void registerHandlers(HTTPServer *insecureServer, HTTPSServer *secureServer)
|
||||
secureServer->registerNode(nodeRestart);
|
||||
secureServer->registerNode(nodeFormUpload);
|
||||
secureServer->registerNode(nodeJsonScanNetworks);
|
||||
secureServer->registerNode(nodeJsonBlinkLED);
|
||||
secureServer->registerNode(nodeJsonFsBrowseStatic);
|
||||
secureServer->registerNode(nodeJsonDelete);
|
||||
secureServer->registerNode(nodeJsonReport);
|
||||
@@ -130,6 +133,7 @@ void registerHandlers(HTTPServer *insecureServer, HTTPSServer *secureServer)
|
||||
insecureServer->registerNode(nodeRestart);
|
||||
insecureServer->registerNode(nodeFormUpload);
|
||||
insecureServer->registerNode(nodeJsonScanNetworks);
|
||||
insecureServer->registerNode(nodeJsonBlinkLED);
|
||||
insecureServer->registerNode(nodeJsonFsBrowseStatic);
|
||||
insecureServer->registerNode(nodeJsonDelete);
|
||||
insecureServer->registerNode(nodeJsonReport);
|
||||
@@ -900,6 +904,45 @@ void handleRestart(HTTPRequest *req, HTTPResponse *res)
|
||||
webServerThread->requestRestart = (millis() / 1000) + 5;
|
||||
}
|
||||
|
||||
void handleBlinkLED(HTTPRequest *req, HTTPResponse *res)
|
||||
{
|
||||
res->setHeader("Content-Type", "application/json");
|
||||
res->setHeader("Access-Control-Allow-Origin", "*");
|
||||
res->setHeader("Access-Control-Allow-Methods", "POST");
|
||||
|
||||
ResourceParameters *params = req->getParams();
|
||||
std::string blink_target;
|
||||
|
||||
if (!params->getQueryParameter("blink_target", blink_target)) {
|
||||
// if no blink_target was supplied in the URL parameters of the
|
||||
// POST request, then assume we should blink the LED
|
||||
blink_target = "LED";
|
||||
}
|
||||
|
||||
if (blink_target == "LED") {
|
||||
uint8_t count = 10;
|
||||
while (count > 0) {
|
||||
ledBlink.set(true);
|
||||
delay(50);
|
||||
ledBlink.set(false);
|
||||
delay(50);
|
||||
count = count - 1;
|
||||
}
|
||||
} else {
|
||||
#if HAS_SCREEN
|
||||
if (screen)
|
||||
screen->blink();
|
||||
#endif
|
||||
}
|
||||
|
||||
JSONObject jsonObjOuter;
|
||||
jsonObjOuter["status"] = new JSONValue("ok");
|
||||
JSONValue *value = new JSONValue(jsonObjOuter);
|
||||
std::string jsonString = value->Stringify();
|
||||
res->print(jsonString.c_str());
|
||||
delete value;
|
||||
}
|
||||
|
||||
void handleScanNetworks(HTTPRequest *req, HTTPResponse *res)
|
||||
{
|
||||
res->setHeader("Content-Type", "application/json");
|
||||
|
||||
@@ -11,6 +11,7 @@ void handleFormUpload(HTTPRequest *req, HTTPResponse *res);
|
||||
void handleScanNetworks(HTTPRequest *req, HTTPResponse *res);
|
||||
void handleFsBrowseStatic(HTTPRequest *req, HTTPResponse *res);
|
||||
void handleFsDeleteStatic(HTTPRequest *req, HTTPResponse *res);
|
||||
void handleBlinkLED(HTTPRequest *req, HTTPResponse *res);
|
||||
void handleReport(HTTPRequest *req, HTTPResponse *res);
|
||||
void handleNodes(HTTPRequest *req, HTTPResponse *res);
|
||||
void handleUpdateFs(HTTPRequest *req, HTTPResponse *res);
|
||||
|
||||
@@ -643,6 +643,12 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c)
|
||||
accelerometerThread->enabled = true;
|
||||
accelerometerThread->start();
|
||||
}
|
||||
#endif
|
||||
#ifdef LED_PIN
|
||||
// Turn LED off if heartbeat by config
|
||||
if (c.payload_variant.device.led_heartbeat_disabled) {
|
||||
digitalWrite(LED_PIN, HIGH ^ LED_STATE_ON);
|
||||
}
|
||||
#endif
|
||||
if (config.device.button_gpio == c.payload_variant.device.button_gpio &&
|
||||
config.device.buzzer_gpio == c.payload_variant.device.buzzer_gpio &&
|
||||
@@ -899,11 +905,10 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c)
|
||||
|
||||
bool AdminModule::handleSetModuleConfig(const meshtastic_ModuleConfig &c)
|
||||
{
|
||||
bool shouldReboot = true;
|
||||
// If we are in an open transaction or configuring MQTT or Serial (which have validation), defer disabling Bluetooth
|
||||
// Otherwise, disable Bluetooth to prevent the phone from interfering with the config
|
||||
if (!hasOpenEditTransaction && !IS_ONE_OF(c.which_payload_variant, meshtastic_ModuleConfig_mqtt_tag,
|
||||
meshtastic_ModuleConfig_serial_tag, meshtastic_ModuleConfig_statusmessage_tag)) {
|
||||
if (!hasOpenEditTransaction &&
|
||||
!IS_ONE_OF(c.which_payload_variant, meshtastic_ModuleConfig_mqtt_tag, meshtastic_ModuleConfig_serial_tag)) {
|
||||
disableBluetooth();
|
||||
}
|
||||
|
||||
@@ -995,14 +1000,8 @@ bool AdminModule::handleSetModuleConfig(const meshtastic_ModuleConfig &c)
|
||||
moduleConfig.has_paxcounter = true;
|
||||
moduleConfig.paxcounter = c.payload_variant.paxcounter;
|
||||
break;
|
||||
case meshtastic_ModuleConfig_statusmessage_tag:
|
||||
LOG_INFO("Set module config: StatusMessage");
|
||||
moduleConfig.has_statusmessage = true;
|
||||
moduleConfig.statusmessage = c.payload_variant.statusmessage;
|
||||
shouldReboot = false;
|
||||
break;
|
||||
}
|
||||
saveChanges(SEGMENT_MODULECONFIG, shouldReboot);
|
||||
saveChanges(SEGMENT_MODULECONFIG);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1181,11 +1180,6 @@ void AdminModule::handleGetModuleConfig(const meshtastic_MeshPacket &req, const
|
||||
res.get_module_config_response.which_payload_variant = meshtastic_ModuleConfig_paxcounter_tag;
|
||||
res.get_module_config_response.payload_variant.paxcounter = moduleConfig.paxcounter;
|
||||
break;
|
||||
case meshtastic_AdminMessage_ModuleConfigType_STATUSMESSAGE_CONFIG:
|
||||
LOG_INFO("Get module config: StatusMessage");
|
||||
res.get_module_config_response.which_payload_variant = meshtastic_ModuleConfig_statusmessage_tag;
|
||||
res.get_module_config_response.payload_variant.statusmessage = moduleConfig.statusmessage;
|
||||
break;
|
||||
}
|
||||
|
||||
// NOTE: The phone app needs to know the ls_secsvalue so it can properly expect sleep behavior.
|
||||
|
||||
+3
-12
@@ -1,11 +1,8 @@
|
||||
#include "configuration.h"
|
||||
#if !MESHTASTIC_EXCLUDE_INPUTBROKER
|
||||
#include "buzz/BuzzerFeedbackThread.h"
|
||||
#include "modules/SystemCommandsModule.h"
|
||||
#endif
|
||||
#include "modules/StatusLEDModule.h"
|
||||
#if !MESHTASTIC_EXCLUDE_REPLYBOT
|
||||
#include "ReplyBotModule.h"
|
||||
#include "modules/SystemCommandsModule.h"
|
||||
#endif
|
||||
#if !MESHTASTIC_EXCLUDE_PKI
|
||||
#include "KeyVerificationModule.h"
|
||||
@@ -93,9 +90,6 @@
|
||||
#if !MESHTASTIC_EXCLUDE_DROPZONE
|
||||
#include "modules/DropzoneModule.h"
|
||||
#endif
|
||||
#if !MESHTASTIC_EXCLUDE_STATUS
|
||||
#include "modules/StatusMessageModule.h"
|
||||
#endif
|
||||
|
||||
#if defined(HAS_HARDWARE_WATCHDOG)
|
||||
#include "watchdog/watchdogThread.h"
|
||||
@@ -112,10 +106,10 @@ void setupModules()
|
||||
buzzerFeedbackThread = new BuzzerFeedbackThread();
|
||||
}
|
||||
#endif
|
||||
#if defined(LED_CHARGE) || defined(LED_PAIRING)
|
||||
statusLEDModule = new StatusLEDModule();
|
||||
#if !MESHTASTIC_EXCLUDE_REPLYBOT
|
||||
new ReplyBotModule();
|
||||
#endif
|
||||
|
||||
#if !MESHTASTIC_EXCLUDE_ADMIN
|
||||
adminModule = new AdminModule();
|
||||
#endif
|
||||
@@ -156,9 +150,6 @@ void setupModules()
|
||||
#if !MESHTASTIC_EXCLUDE_DROPZONE
|
||||
dropzoneModule = new DropzoneModule();
|
||||
#endif
|
||||
#if !MESHTASTIC_EXCLUDE_STATUS
|
||||
statusMessageModule = new StatusMessageModule();
|
||||
#endif
|
||||
#if !MESHTASTIC_EXCLUDE_GENERIC_THREAD_MODULE
|
||||
new GenericThreadModule();
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "PowerStressModule.h"
|
||||
#include "Led.h"
|
||||
#include "MeshService.h"
|
||||
#include "NodeDB.h"
|
||||
#include "PowerMon.h"
|
||||
@@ -77,12 +78,10 @@ int32_t PowerStressModule::runOnce()
|
||||
|
||||
switch (p.cmd) {
|
||||
case meshtastic_PowerStressMessage_Opcode_LED_ON:
|
||||
// FIXME - implement
|
||||
// ledForceOn.set(true);
|
||||
ledForceOn.set(true);
|
||||
break;
|
||||
case meshtastic_PowerStressMessage_Opcode_LED_OFF:
|
||||
// FIXME - implement
|
||||
// ledForceOn.set(false);
|
||||
ledForceOn.set(false);
|
||||
break;
|
||||
case meshtastic_PowerStressMessage_Opcode_GPS_ON:
|
||||
// FIXME - implement
|
||||
|
||||
@@ -1,183 +0,0 @@
|
||||
#include "configuration.h"
|
||||
#if !MESHTASTIC_EXCLUDE_REPLYBOT
|
||||
/*
|
||||
* ReplyBotModule.cpp
|
||||
*
|
||||
* This module implements a simple reply bot for the Meshtastic firmware. It listens for
|
||||
* specific text commands ("/ping", "/hello" and "/test") delivered either via a direct
|
||||
* message (DM) or a broadcast on the primary channel. When a supported command is
|
||||
* received the bot responds with a short status message that includes the hop count
|
||||
* (minimum number of relays), RSSI and SNR of the received packet. To avoid spamming
|
||||
* the network it enforces a per‑sender cooldown between responses. By default the
|
||||
* module is disabled. See the official firmware documentation for guidance on adding modules.
|
||||
* To enable this module, set `#undef MESHTASTIC_EXCLUDE_REPLYBOT` in your variant.h file.
|
||||
*/
|
||||
|
||||
#include "Channels.h"
|
||||
#include "MeshService.h"
|
||||
#include "NodeDB.h"
|
||||
#include "ReplyBotModule.h"
|
||||
#include "mesh/MeshTypes.h"
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <cctype>
|
||||
#include <cstring>
|
||||
|
||||
//
|
||||
// Rate limiting data structures
|
||||
//
|
||||
// Each sender is tracked in a small ring buffer. When a message arrives from a
|
||||
// sender we check the last time we responded to them. If the difference is
|
||||
// less than the configured cooldown (different values for DM vs broadcast)
|
||||
// the message is ignored; otherwise we update the last response time and
|
||||
// proceed with replying.
|
||||
|
||||
struct ReplyBotCooldownEntry {
|
||||
uint32_t from = 0;
|
||||
uint32_t lastMs = 0;
|
||||
};
|
||||
|
||||
static constexpr uint8_t REPLYBOT_COOLDOWN_SLOTS = 8; // ring buffer size
|
||||
static constexpr uint32_t REPLYBOT_DM_COOLDOWN_MS = 15 * 1000; // 15 seconds for DMs
|
||||
static constexpr uint32_t REPLYBOT_LF_COOLDOWN_MS = 60 * 1000; // 60 seconds for LongFast broadcasts
|
||||
|
||||
static ReplyBotCooldownEntry replybotCooldown[REPLYBOT_COOLDOWN_SLOTS];
|
||||
static uint8_t replybotCooldownIdx = 0;
|
||||
|
||||
// Return true if a reply should be rate‑limited for this sender, updating the
|
||||
// entry table as needed.
|
||||
static bool replybotRateLimited(uint32_t from, uint32_t cooldownMs)
|
||||
{
|
||||
const uint32_t now = millis();
|
||||
for (auto &e : replybotCooldown) {
|
||||
if (e.from == from) {
|
||||
// Found existing entry; check if cooldown expired
|
||||
if ((uint32_t)(now - e.lastMs) < cooldownMs) {
|
||||
return true;
|
||||
}
|
||||
e.lastMs = now;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// No entry found – insert new sender into the ring
|
||||
replybotCooldown[replybotCooldownIdx].from = from;
|
||||
replybotCooldown[replybotCooldownIdx].lastMs = now;
|
||||
replybotCooldownIdx = (replybotCooldownIdx + 1) % REPLYBOT_COOLDOWN_SLOTS;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Constructor – registers a single text port and marks the module promiscuous
|
||||
// so that broadcast messages on the primary channel are visible.
|
||||
ReplyBotModule::ReplyBotModule() : SinglePortModule("replybot", meshtastic_PortNum_TEXT_MESSAGE_APP)
|
||||
{
|
||||
isPromiscuous = true;
|
||||
}
|
||||
|
||||
void ReplyBotModule::setup()
|
||||
{
|
||||
// In future we may add a protobuf configuration; for now the module is
|
||||
// always enabled when compiled in.
|
||||
}
|
||||
|
||||
// Determine whether we want to process this packet. We only care about
|
||||
// plain text messages addressed to our port.
|
||||
bool ReplyBotModule::wantPacket(const meshtastic_MeshPacket *p)
|
||||
{
|
||||
return (p && p->decoded.portnum == ourPortNum);
|
||||
}
|
||||
|
||||
ProcessMessage ReplyBotModule::handleReceived(const meshtastic_MeshPacket &mp)
|
||||
{
|
||||
// Accept only direct messages to us or broadcasts on the Primary channel
|
||||
// (regardless of modem preset: LongFast, MediumFast, etc).
|
||||
|
||||
const uint32_t ourNode = nodeDB->getNodeNum();
|
||||
const bool isDM = (mp.to == ourNode);
|
||||
const bool isPrimaryChannel = (mp.channel == channels.getPrimaryIndex()) && isBroadcast(mp.to);
|
||||
if (!isDM && !isPrimaryChannel) {
|
||||
return ProcessMessage::CONTINUE;
|
||||
}
|
||||
|
||||
// Ignore empty payloads
|
||||
if (mp.decoded.payload.size == 0) {
|
||||
return ProcessMessage::CONTINUE;
|
||||
}
|
||||
|
||||
// Copy payload into a null‑terminated buffer
|
||||
char buf[260];
|
||||
memset(buf, 0, sizeof(buf));
|
||||
size_t n = mp.decoded.payload.size;
|
||||
if (n > sizeof(buf) - 1)
|
||||
n = sizeof(buf) - 1;
|
||||
memcpy(buf, mp.decoded.payload.bytes, n);
|
||||
|
||||
// React only to supported slash commands
|
||||
if (!isCommand(buf)) {
|
||||
return ProcessMessage::CONTINUE;
|
||||
}
|
||||
|
||||
// Apply rate limiting per sender depending on DM/broadcast
|
||||
const uint32_t cooldownMs = isDM ? REPLYBOT_DM_COOLDOWN_MS : REPLYBOT_LF_COOLDOWN_MS;
|
||||
if (replybotRateLimited(mp.from, cooldownMs)) {
|
||||
return ProcessMessage::CONTINUE;
|
||||
}
|
||||
|
||||
// Compute hop count indicator – if the relay_node is non‑zero we know
|
||||
// there was at least one relay. Some firmware builds support a hop_start
|
||||
// field which could be used for more accurate counts, but here we use
|
||||
// the available relay_node flag only.
|
||||
// int hopsAway = mp.hop_start - mp.hop_limit;
|
||||
int hopsAway = getHopsAway(mp);
|
||||
|
||||
// Normalize RSSI: if positive adjust down by 200 to align with typical values
|
||||
int rssi = mp.rx_rssi;
|
||||
if (rssi > 0) {
|
||||
rssi -= 200;
|
||||
}
|
||||
float snr = mp.rx_snr;
|
||||
|
||||
// Build the reply message and send it back via DM
|
||||
char reply[96];
|
||||
snprintf(reply, sizeof(reply), "🎙️ Mic Check : %d Hops away | RSSI %d | SNR %.1f", hopsAway, rssi, snr);
|
||||
sendDm(mp, reply);
|
||||
return ProcessMessage::CONTINUE;
|
||||
}
|
||||
|
||||
// Check if the message starts with one of the supported commands. Leading
|
||||
// whitespace is skipped and commands must be followed by end‑of‑string or
|
||||
// whitespace.
|
||||
bool ReplyBotModule::isCommand(const char *msg) const
|
||||
{
|
||||
if (!msg)
|
||||
return false;
|
||||
while (*msg == ' ' || *msg == '\t')
|
||||
msg++;
|
||||
auto isEndOrSpace = [](char c) { return c == '\0' || std::isspace(static_cast<unsigned char>(c)); };
|
||||
if (strncmp(msg, "/ping", 5) == 0 && isEndOrSpace(msg[5]))
|
||||
return true;
|
||||
if (strncmp(msg, "/hello", 6) == 0 && isEndOrSpace(msg[6]))
|
||||
return true;
|
||||
if (strncmp(msg, "/test", 5) == 0 && isEndOrSpace(msg[5]))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Send a direct message back to the originating node.
|
||||
void ReplyBotModule::sendDm(const meshtastic_MeshPacket &rx, const char *text)
|
||||
{
|
||||
if (!text)
|
||||
return;
|
||||
meshtastic_MeshPacket *p = allocDataPacket();
|
||||
p->to = rx.from;
|
||||
p->channel = rx.channel;
|
||||
p->want_ack = false;
|
||||
p->decoded.want_response = false;
|
||||
size_t len = strlen(text);
|
||||
if (len > sizeof(p->decoded.payload.bytes)) {
|
||||
len = sizeof(p->decoded.payload.bytes);
|
||||
}
|
||||
p->decoded.payload.size = len;
|
||||
memcpy(p->decoded.payload.bytes, text, len);
|
||||
service->sendToMesh(p);
|
||||
}
|
||||
#endif // MESHTASTIC_EXCLUDE_REPLYBOT
|
||||
@@ -1,19 +0,0 @@
|
||||
#pragma once
|
||||
#include "configuration.h"
|
||||
#if !MESHTASTIC_EXCLUDE_REPLYBOT
|
||||
#include "SinglePortModule.h"
|
||||
#include "mesh/generated/meshtastic/mesh.pb.h"
|
||||
|
||||
class ReplyBotModule : public SinglePortModule
|
||||
{
|
||||
public:
|
||||
ReplyBotModule();
|
||||
void setup() override;
|
||||
bool wantPacket(const meshtastic_MeshPacket *p) override;
|
||||
ProcessMessage handleReceived(const meshtastic_MeshPacket &mp) override;
|
||||
|
||||
protected:
|
||||
bool isCommand(const char *msg) const;
|
||||
void sendDm(const meshtastic_MeshPacket &rx, const char *text);
|
||||
};
|
||||
#endif // MESHTASTIC_EXCLUDE_REPLYBOT
|
||||
@@ -13,10 +13,8 @@ StatusLEDModule::StatusLEDModule() : concurrency::OSThread("StatusLEDModule")
|
||||
{
|
||||
bluetoothStatusObserver.observe(&bluetoothStatus->onNewStatus);
|
||||
powerStatusObserver.observe(&powerStatus->onNewStatus);
|
||||
#if !MESHTASTIC_EXCLUDE_INPUTBROKER
|
||||
if (inputBroker)
|
||||
inputObserver.observe(inputBroker);
|
||||
#endif
|
||||
}
|
||||
|
||||
int StatusLEDModule::handleStatusUpdate(const meshtastic::Status *arg)
|
||||
@@ -64,22 +62,19 @@ int StatusLEDModule::handleStatusUpdate(const meshtastic::Status *arg)
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
#if !MESHTASTIC_EXCLUDE_INPUTBROKER
|
||||
|
||||
int StatusLEDModule::handleInputEvent(const InputEvent *event)
|
||||
{
|
||||
lastUserbuttonTime = millis();
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t StatusLEDModule::runOnce()
|
||||
{
|
||||
my_interval = 1000;
|
||||
|
||||
if (power_state == charging) {
|
||||
#ifndef POWER_LED_HARDWARE_BLINKS_WHILE_CHARGING
|
||||
CHARGE_LED_state = !CHARGE_LED_state;
|
||||
#endif
|
||||
} else if (power_state == charged) {
|
||||
CHARGE_LED_state = LED_STATE_ON;
|
||||
} else if (power_state == critical) {
|
||||
@@ -93,19 +88,13 @@ int32_t StatusLEDModule::runOnce()
|
||||
my_interval = 250;
|
||||
if (POWER_LED_starttime + 2000 < millis()) {
|
||||
doing_fast_blink = false;
|
||||
CHARGE_LED_state = LED_STATE_OFF;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (power_state != charging && power_state != charged && !doing_fast_blink) {
|
||||
if (CHARGE_LED_state == LED_STATE_ON) {
|
||||
CHARGE_LED_state = LED_STATE_OFF;
|
||||
my_interval = 999;
|
||||
} else {
|
||||
CHARGE_LED_state = LED_STATE_ON;
|
||||
my_interval = 1;
|
||||
CHARGE_LED_state = LED_STATE_OFF;
|
||||
}
|
||||
|
||||
} else {
|
||||
CHARGE_LED_state = LED_STATE_OFF;
|
||||
}
|
||||
|
||||
if (!config.bluetooth.enabled || PAIRING_LED_starttime + 30 * 1000 < millis() || doing_fast_blink) {
|
||||
@@ -123,11 +112,6 @@ int32_t StatusLEDModule::runOnce()
|
||||
PAIRING_LED_state = LED_STATE_ON;
|
||||
}
|
||||
|
||||
// Override if disabled in config
|
||||
if (config.device.led_heartbeat_disabled) {
|
||||
CHARGE_LED_state = LED_STATE_OFF;
|
||||
}
|
||||
#ifdef Battery_LED_1
|
||||
bool chargeIndicatorLED1 = LED_STATE_OFF;
|
||||
bool chargeIndicatorLED2 = LED_STATE_OFF;
|
||||
bool chargeIndicatorLED3 = LED_STATE_OFF;
|
||||
@@ -142,23 +126,9 @@ int32_t StatusLEDModule::runOnce()
|
||||
if (powerStatus && powerStatus->getBatteryChargePercent() >= 75)
|
||||
chargeIndicatorLED4 = LED_STATE_ON;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(HAS_PMU)
|
||||
if (pmu_found && PMU) {
|
||||
// blink the axp led
|
||||
PMU->setChargingLedMode(CHARGE_LED_state ? XPOWERS_CHG_LED_ON : XPOWERS_CHG_LED_OFF);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PCA_LED_POWER
|
||||
io.digitalWrite(PCA_LED_POWER, CHARGE_LED_state);
|
||||
#endif
|
||||
#ifdef PCA_LED_ENABLE
|
||||
io.digitalWrite(PCA_LED_ENABLE, CHARGE_LED_state);
|
||||
#endif
|
||||
#ifdef LED_POWER
|
||||
digitalWrite(LED_POWER, CHARGE_LED_state);
|
||||
#ifdef LED_CHARGE
|
||||
digitalWrite(LED_CHARGE, CHARGE_LED_state);
|
||||
#endif
|
||||
#ifdef LED_PAIRING
|
||||
digitalWrite(LED_PAIRING, PAIRING_LED_state);
|
||||
@@ -179,43 +149,3 @@ int32_t StatusLEDModule::runOnce()
|
||||
|
||||
return (my_interval);
|
||||
}
|
||||
|
||||
void StatusLEDModule::setPowerLED(bool LEDon)
|
||||
{
|
||||
|
||||
#if defined(HAS_PMU)
|
||||
if (pmu_found && PMU) {
|
||||
// blink the axp led
|
||||
PMU->setChargingLedMode(LEDon ? XPOWERS_CHG_LED_ON : XPOWERS_CHG_LED_OFF);
|
||||
}
|
||||
#endif
|
||||
if (LEDon)
|
||||
LEDon = LED_STATE_ON;
|
||||
else
|
||||
LEDon = LED_STATE_OFF;
|
||||
#ifdef PCA_LED_POWER
|
||||
io.digitalWrite(PCA_LED_POWER, LEDon);
|
||||
#endif
|
||||
#ifdef PCA_LED_ENABLE
|
||||
io.digitalWrite(PCA_LED_ENABLE, LEDon);
|
||||
#endif
|
||||
#ifdef LED_POWER
|
||||
digitalWrite(LED_POWER, LEDon);
|
||||
#endif
|
||||
#ifdef LED_PAIRING
|
||||
digitalWrite(LED_PAIRING, LEDon);
|
||||
#endif
|
||||
|
||||
#ifdef Battery_LED_1
|
||||
digitalWrite(Battery_LED_1, LEDon);
|
||||
#endif
|
||||
#ifdef Battery_LED_2
|
||||
digitalWrite(Battery_LED_2, LEDon);
|
||||
#endif
|
||||
#ifdef Battery_LED_3
|
||||
digitalWrite(Battery_LED_3, LEDon);
|
||||
#endif
|
||||
#ifdef Battery_LED_4
|
||||
digitalWrite(Battery_LED_4, LEDon);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -5,14 +5,10 @@
|
||||
#include "PowerStatus.h"
|
||||
#include "concurrency/OSThread.h"
|
||||
#include "configuration.h"
|
||||
#include "main.h"
|
||||
#include "input/InputBroker.h"
|
||||
#include <Arduino.h>
|
||||
#include <functional>
|
||||
|
||||
#if !MESHTASTIC_EXCLUDE_INPUTBROKER
|
||||
#include "input/InputBroker.h"
|
||||
#endif
|
||||
|
||||
class StatusLEDModule : private concurrency::OSThread
|
||||
{
|
||||
bool slowTrack = false;
|
||||
@@ -21,11 +17,8 @@ class StatusLEDModule : private concurrency::OSThread
|
||||
StatusLEDModule();
|
||||
|
||||
int handleStatusUpdate(const meshtastic::Status *);
|
||||
#if !MESHTASTIC_EXCLUDE_INPUTBROKER
|
||||
int handleInputEvent(const InputEvent *arg);
|
||||
#endif
|
||||
|
||||
void setPowerLED(bool);
|
||||
int handleInputEvent(const InputEvent *arg);
|
||||
|
||||
protected:
|
||||
unsigned int my_interval = 1000; // interval in millisconds
|
||||
@@ -35,10 +28,8 @@ class StatusLEDModule : private concurrency::OSThread
|
||||
CallbackObserver<StatusLEDModule, const meshtastic::Status *>(this, &StatusLEDModule::handleStatusUpdate);
|
||||
CallbackObserver<StatusLEDModule, const meshtastic::Status *> powerStatusObserver =
|
||||
CallbackObserver<StatusLEDModule, const meshtastic::Status *>(this, &StatusLEDModule::handleStatusUpdate);
|
||||
#if !MESHTASTIC_EXCLUDE_INPUTBROKER
|
||||
CallbackObserver<StatusLEDModule, const InputEvent *> inputObserver =
|
||||
CallbackObserver<StatusLEDModule, const InputEvent *>(this, &StatusLEDModule::handleInputEvent);
|
||||
#endif
|
||||
|
||||
private:
|
||||
bool CHARGE_LED_state = LED_STATE_OFF;
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
#if !MESHTASTIC_EXCLUDE_STATUS
|
||||
|
||||
#include "StatusMessageModule.h"
|
||||
#include "MeshService.h"
|
||||
#include "ProtobufModule.h"
|
||||
|
||||
StatusMessageModule *statusMessageModule;
|
||||
|
||||
int32_t StatusMessageModule::runOnce()
|
||||
{
|
||||
if (moduleConfig.has_statusmessage && moduleConfig.statusmessage.node_status[0] != '\0') {
|
||||
// create and send message with the status message set
|
||||
meshtastic_StatusMessage ourStatus = meshtastic_StatusMessage_init_zero;
|
||||
strncpy(ourStatus.status, moduleConfig.statusmessage.node_status, sizeof(ourStatus.status));
|
||||
ourStatus.status[sizeof(ourStatus.status) - 1] = '\0'; // ensure null termination
|
||||
meshtastic_MeshPacket *p = allocDataPacket();
|
||||
p->decoded.payload.size = pb_encode_to_bytes(p->decoded.payload.bytes, sizeof(p->decoded.payload.bytes),
|
||||
meshtastic_StatusMessage_fields, &ourStatus);
|
||||
p->to = NODENUM_BROADCAST;
|
||||
p->decoded.want_response = false;
|
||||
p->priority = meshtastic_MeshPacket_Priority_BACKGROUND;
|
||||
p->channel = 0;
|
||||
service->sendToMesh(p);
|
||||
}
|
||||
|
||||
return 1000 * 12 * 60 * 60;
|
||||
}
|
||||
|
||||
ProcessMessage StatusMessageModule::handleReceived(const meshtastic_MeshPacket &mp)
|
||||
{
|
||||
if (mp.which_payload_variant == meshtastic_MeshPacket_decoded_tag) {
|
||||
meshtastic_StatusMessage incomingMessage;
|
||||
if (pb_decode_from_bytes(mp.decoded.payload.bytes, mp.decoded.payload.size, meshtastic_StatusMessage_fields,
|
||||
&incomingMessage)) {
|
||||
LOG_INFO("Received a NodeStatus message %s", incomingMessage.status);
|
||||
}
|
||||
}
|
||||
return ProcessMessage::CONTINUE;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,35 +0,0 @@
|
||||
#pragma once
|
||||
#if !MESHTASTIC_EXCLUDE_STATUS
|
||||
#include "SinglePortModule.h"
|
||||
#include "configuration.h"
|
||||
|
||||
class StatusMessageModule : public SinglePortModule, private concurrency::OSThread
|
||||
{
|
||||
|
||||
public:
|
||||
/** Constructor
|
||||
* name is for debugging output
|
||||
*/
|
||||
StatusMessageModule()
|
||||
: SinglePortModule("statusMessage", meshtastic_PortNum_NODE_STATUS_APP), concurrency::OSThread("StatusMessage")
|
||||
{
|
||||
if (moduleConfig.has_statusmessage && moduleConfig.statusmessage.node_status[0] != '\0') {
|
||||
this->setInterval(2 * 60 * 1000);
|
||||
} else {
|
||||
this->setInterval(1000 * 12 * 60 * 60);
|
||||
}
|
||||
// TODO: If we have a string, set the initial delay (15 minutes maybe)
|
||||
}
|
||||
|
||||
virtual int32_t runOnce() override;
|
||||
|
||||
protected:
|
||||
/** Called to handle a particular incoming message
|
||||
*/
|
||||
virtual ProcessMessage handleReceived(const meshtastic_MeshPacket &mp) override;
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
extern StatusMessageModule *statusMessageModule;
|
||||
#endif
|
||||
@@ -22,17 +22,9 @@
|
||||
#include "Sensor/AddI2CSensorTemplate.h"
|
||||
#include "Sensor/PMSA003ISensor.h"
|
||||
#include "Sensor/SEN5XSensor.h"
|
||||
#if __has_include(<SensirionI2cScd4x.h>)
|
||||
#include "Sensor/SCD4XSensor.h"
|
||||
#endif
|
||||
#if __has_include(<SensirionI2cStc3x.h>)
|
||||
#include "Sensor/STC31Sensor.h"
|
||||
#endif
|
||||
|
||||
void AirQualityTelemetryModule::i2cScanFinished(ScanI2C *i2cScanner)
|
||||
{
|
||||
LOG_DEBUG("AirQualityTelemetryModule::i2cScanFinished called, air_quality_enabled=%d",
|
||||
moduleConfig.telemetry.air_quality_enabled);
|
||||
if (!moduleConfig.telemetry.air_quality_enabled && !AIR_QUALITY_TELEMETRY_MODULE_ENABLE) {
|
||||
return;
|
||||
}
|
||||
@@ -52,12 +44,6 @@ void AirQualityTelemetryModule::i2cScanFinished(ScanI2C *i2cScanner)
|
||||
// order by priority of metrics/values (low top, high bottom)
|
||||
addSensor<PMSA003ISensor>(i2cScanner, ScanI2C::DeviceType::PMSA003I);
|
||||
addSensor<SEN5XSensor>(i2cScanner, ScanI2C::DeviceType::SEN5X);
|
||||
#if __has_include(<SensirionI2cScd4x.h>)
|
||||
addSensor<SCD4XSensor>(i2cScanner, ScanI2C::DeviceType::SCD4X);
|
||||
#endif
|
||||
#if __has_include(<SensirionI2cStc3x.h>)
|
||||
addSensor<STC31Sensor>(i2cScanner, ScanI2C::DeviceType::STC31);
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t AirQualityTelemetryModule::runOnce()
|
||||
@@ -100,10 +86,6 @@ int32_t AirQualityTelemetryModule::runOnce()
|
||||
return disable();
|
||||
}
|
||||
|
||||
bool isSensorRole = config.device.role == meshtastic_Config_DeviceConfig_Role_SENSOR;
|
||||
// SENSOR role bypasses airtime restrictions - telemetry is its primary purpose
|
||||
bool airTimeAllows = isSensorRole || (airTime->isTxAllowedChannelUtil(true) && airTime->isTxAllowedAirUtil());
|
||||
|
||||
// Wake up the sensors that need it
|
||||
LOG_INFO("Waking up sensors...");
|
||||
for (TelemetrySensor *sensor : sensors) {
|
||||
@@ -114,7 +96,8 @@ int32_t AirQualityTelemetryModule::runOnce()
|
||||
Default::getConfiguredOrDefaultMsScaled(
|
||||
moduleConfig.telemetry.air_quality_interval,
|
||||
default_telemetry_broadcast_interval_secs, numOnlineNodes))) &&
|
||||
airTimeAllows) {
|
||||
airTime->isTxAllowedChannelUtil(config.device.role != meshtastic_Config_DeviceConfig_Role_SENSOR) &&
|
||||
airTime->isTxAllowedAirUtil()) {
|
||||
if (!sensor->isActive()) {
|
||||
LOG_DEBUG("Waking up: %s", sensor->sensorName);
|
||||
return sensor->wakeUp();
|
||||
@@ -128,19 +111,18 @@ int32_t AirQualityTelemetryModule::runOnce()
|
||||
}
|
||||
}
|
||||
|
||||
bool timeToSend = (lastSentToMesh == 0) ||
|
||||
!Throttle::isWithinTimespanMs(
|
||||
lastSentToMesh,
|
||||
Default::getConfiguredOrDefaultMsScaled(moduleConfig.telemetry.air_quality_interval,
|
||||
default_telemetry_broadcast_interval_secs, numOnlineNodes));
|
||||
|
||||
if (timeToSend && airTimeAllows) {
|
||||
if (((lastSentToMesh == 0) ||
|
||||
!Throttle::isWithinTimespanMs(lastSentToMesh, Default::getConfiguredOrDefaultMsScaled(
|
||||
moduleConfig.telemetry.air_quality_interval,
|
||||
default_telemetry_broadcast_interval_secs, numOnlineNodes))) &&
|
||||
airTime->isTxAllowedChannelUtil(config.device.role != meshtastic_Config_DeviceConfig_Role_SENSOR) &&
|
||||
airTime->isTxAllowedAirUtil()) {
|
||||
sendTelemetry();
|
||||
lastSentToMesh = millis();
|
||||
} else if (((lastSentToPhone == 0) || !Throttle::isWithinTimespanMs(lastSentToPhone, sendToPhoneIntervalMs)) &&
|
||||
(isSensorRole || service->isToPhoneQueueEmpty())) {
|
||||
(service->isToPhoneQueueEmpty())) {
|
||||
// Just send to phone when it's not our time to send to mesh yet
|
||||
// SENSOR role always sends; others only send while queue is empty (phone assumed connected)
|
||||
// Only send while queue is empty (phone assumed connected)
|
||||
sendTelemetry(NODENUM_BROADCAST, true);
|
||||
lastSentToPhone = millis();
|
||||
}
|
||||
@@ -204,7 +186,7 @@ void AirQualityTelemetryModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiSta
|
||||
const auto &m = telemetry.variant.air_quality_metrics;
|
||||
|
||||
// Check if any telemetry field has valid data
|
||||
bool hasAny = m.has_pm10_standard || m.has_pm25_standard || m.has_pm100_standard || m.has_co2;
|
||||
bool hasAny = m.has_pm10_standard || m.has_pm25_standard || m.has_pm100_standard;
|
||||
|
||||
if (!hasAny) {
|
||||
display->drawString(x, currentY, "No Telemetry");
|
||||
@@ -231,8 +213,6 @@ void AirQualityTelemetryModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiSta
|
||||
entries.push_back("PM2.5: " + String(m.pm25_standard) + "ug/m3");
|
||||
if (m.has_pm100_standard)
|
||||
entries.push_back("PM10: " + String(m.pm100_standard) + "ug/m3");
|
||||
if (m.has_co2)
|
||||
entries.push_back("CO2: " + String(m.co2) + "ppm");
|
||||
|
||||
// === Show first available metric on top-right of first line ===
|
||||
if (!entries.empty()) {
|
||||
@@ -276,9 +256,6 @@ bool AirQualityTelemetryModule::handleReceivedProtobuf(const meshtastic_MeshPack
|
||||
// LOG_INFO(" | PM1.0(Environmental)=%i, PM2.5(Environmental)=%i, PM10.0(Environmental)=%i",
|
||||
// t->variant.air_quality_metrics.pm10_environmental, t->variant.air_quality_metrics.pm25_environmental,
|
||||
// t->variant.air_quality_metrics.pm100_environmental);
|
||||
|
||||
LOG_INFO(" | CO2=%i, CO2_T=%f, CO2_H=%f", t->variant.air_quality_metrics.co2,
|
||||
t->variant.air_quality_metrics.co2_temperature, t->variant.air_quality_metrics.co2_humidity);
|
||||
#endif
|
||||
// release previous packet before occupying a new spot
|
||||
if (lastMeasurementPacket != nullptr)
|
||||
@@ -292,20 +269,15 @@ bool AirQualityTelemetryModule::handleReceivedProtobuf(const meshtastic_MeshPack
|
||||
|
||||
bool AirQualityTelemetryModule::getAirQualityTelemetry(meshtastic_Telemetry *m)
|
||||
{
|
||||
// Note: this is different to the case in EnvironmentTelemetryModule
|
||||
// There, if any sensor fails to read - valid = false.
|
||||
bool valid = false;
|
||||
bool valid = true;
|
||||
bool hasSensor = false;
|
||||
m->time = getTime();
|
||||
m->which_variant = meshtastic_Telemetry_air_quality_metrics_tag;
|
||||
m->variant.air_quality_metrics = meshtastic_AirQualityMetrics_init_zero;
|
||||
|
||||
bool sensor_get = false;
|
||||
for (TelemetrySensor *sensor : sensors) {
|
||||
LOG_DEBUG("Reading %s", sensor->sensorName);
|
||||
// Note - this function doesn't get properly called if within a conditional
|
||||
sensor_get = sensor->getMetrics(m);
|
||||
valid = valid || sensor_get;
|
||||
valid = valid && sensor->getMetrics(m);
|
||||
hasSensor = true;
|
||||
}
|
||||
|
||||
@@ -347,28 +319,12 @@ bool AirQualityTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly)
|
||||
m.time = getTime();
|
||||
|
||||
if (getAirQualityTelemetry(&m)) {
|
||||
|
||||
bool hasAnyPM =
|
||||
m.variant.air_quality_metrics.has_pm10_standard || m.variant.air_quality_metrics.has_pm25_standard ||
|
||||
m.variant.air_quality_metrics.has_pm100_standard || m.variant.air_quality_metrics.has_pm10_environmental ||
|
||||
m.variant.air_quality_metrics.has_pm25_environmental || m.variant.air_quality_metrics.has_pm100_environmental;
|
||||
|
||||
if (hasAnyPM) {
|
||||
LOG_INFO("Send: pm10_standard=%u, pm25_standard=%u, pm100_standard=%u", m.variant.air_quality_metrics.pm10_standard,
|
||||
m.variant.air_quality_metrics.pm25_standard, m.variant.air_quality_metrics.pm100_standard);
|
||||
if (m.variant.air_quality_metrics.has_pm10_environmental)
|
||||
LOG_INFO("pm10_environmental=%u, pm25_environmental=%u, pm100_environmental=%u",
|
||||
m.variant.air_quality_metrics.pm10_environmental, m.variant.air_quality_metrics.pm25_environmental,
|
||||
m.variant.air_quality_metrics.pm100_environmental);
|
||||
}
|
||||
|
||||
bool hasAnyCO2 = m.variant.air_quality_metrics.has_co2 || m.variant.air_quality_metrics.has_co2_temperature ||
|
||||
m.variant.air_quality_metrics.has_co2_humidity;
|
||||
|
||||
if (hasAnyCO2) {
|
||||
LOG_INFO("Send: co2=%i, co2_t=%f, co2_rh=%f", m.variant.air_quality_metrics.co2,
|
||||
m.variant.air_quality_metrics.co2_temperature, m.variant.air_quality_metrics.co2_humidity);
|
||||
}
|
||||
LOG_INFO("Send: pm10_standard=%u, pm25_standard=%u, pm100_standard=%u", m.variant.air_quality_metrics.pm10_standard,
|
||||
m.variant.air_quality_metrics.pm25_standard, m.variant.air_quality_metrics.pm100_standard);
|
||||
if (m.variant.air_quality_metrics.has_pm10_environmental)
|
||||
LOG_INFO("pm10_environmental=%u, pm25_environmental=%u, pm100_environmental=%u",
|
||||
m.variant.air_quality_metrics.pm10_environmental, m.variant.air_quality_metrics.pm25_environmental,
|
||||
m.variant.air_quality_metrics.pm100_environmental);
|
||||
|
||||
meshtastic_MeshPacket *p = allocDataProtobuf(m);
|
||||
p->to = dest;
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
// Sensors
|
||||
#include "Sensor/CGRadSensSensor.h"
|
||||
#include "Sensor/RCWL9620Sensor.h"
|
||||
#include "Sensor/TelemetrySensor.h"
|
||||
#include "Sensor/nullSensor.h"
|
||||
|
||||
namespace graphics
|
||||
@@ -572,13 +571,6 @@ bool EnvironmentTelemetryModule::getEnvironmentTelemetry(meshtastic_Telemetry *m
|
||||
valid = valid || get_metrics;
|
||||
hasSensor = true;
|
||||
#endif
|
||||
|
||||
// Update shared humidity for cross-sensor compensation (e.g., STC31 CO2 sensor)
|
||||
if (m->variant.environment_metrics.has_relative_humidity) {
|
||||
lastEnvironmentHumidity = m->variant.environment_metrics.relative_humidity;
|
||||
hasValidHumidity = true;
|
||||
}
|
||||
|
||||
return valid && hasSensor;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,893 +0,0 @@
|
||||
#include "configuration.h"
|
||||
|
||||
#if !MESHTASTIC_EXCLUDE_AIR_QUALITY_SENSOR && __has_include(<SensirionI2cScd4x.h>)
|
||||
|
||||
#include "../detect/reClockI2C.h"
|
||||
#include "../mesh/generated/meshtastic/telemetry.pb.h"
|
||||
#include "SCD4XSensor.h"
|
||||
|
||||
#define SCD4X_NO_ERROR 0
|
||||
|
||||
SCD4XSensor::SCD4XSensor() : TelemetrySensor(meshtastic_TelemetrySensorType_SCD4X, "SCD4X") {}
|
||||
|
||||
bool SCD4XSensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
|
||||
{
|
||||
LOG_INFO("Init sensor: %s", sensorName);
|
||||
|
||||
_bus = bus;
|
||||
_address = dev->address.address;
|
||||
|
||||
#ifdef SCD4X_I2C_CLOCK_SPEED
|
||||
#ifdef CAN_RECLOCK_I2C
|
||||
uint32_t currentClock = reClockI2C(SCD4X_I2C_CLOCK_SPEED, _bus, false);
|
||||
#elif !HAS_SCREEN
|
||||
reClockI2C(SCD4X_I2C_CLOCK_SPEED, _bus, true);
|
||||
#else
|
||||
LOG_WARN("%s can't be used at this clock speed, with a screen", sensorName);
|
||||
return false;
|
||||
#endif /* CAN_RECLOCK_I2C */
|
||||
#endif /* SCD4X_I2C_CLOCK_SPEED */
|
||||
|
||||
scd4x.begin(*_bus, _address);
|
||||
|
||||
// From SCD4X library
|
||||
delay(30);
|
||||
|
||||
// Stop periodic measurement
|
||||
if (!stopMeasurement()) {
|
||||
#if defined(SCD4X_I2C_CLOCK_SPEED) && defined(CAN_RECLOCK_I2C)
|
||||
reClockI2C(currentClock, _bus, false);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get sensor variant
|
||||
scd4x.getSensorVariant(sensorVariant);
|
||||
|
||||
if (sensorVariant == SCD4X_SENSOR_VARIANT_SCD41) {
|
||||
LOG_INFO("%s: Found SCD41", sensorName);
|
||||
if (!powerUp()) {
|
||||
LOG_ERROR("%s: Error trying to execute powerUp()", sensorName);
|
||||
#if defined(SCD4X_I2C_CLOCK_SPEED) && defined(CAN_RECLOCK_I2C)
|
||||
reClockI2C(currentClock, _bus, false);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!getASC(ascActive)) {
|
||||
LOG_ERROR("%s: Unable to check if ASC is enabled", sensorName);
|
||||
#if defined(SCD4X_I2C_CLOCK_SPEED) && defined(CAN_RECLOCK_I2C)
|
||||
reClockI2C(currentClock, _bus, false);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
// Start measurement in selected power mode (low power by default)
|
||||
if (!startMeasurement()) {
|
||||
LOG_ERROR("%s: Couldn't start measurement", sensorName);
|
||||
#if defined(SCD4X_I2C_CLOCK_SPEED) && defined(CAN_RECLOCK_I2C)
|
||||
reClockI2C(currentClock, _bus, false);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
#if defined(SCD4X_I2C_CLOCK_SPEED) && defined(CAN_RECLOCK_I2C)
|
||||
reClockI2C(currentClock, _bus, false);
|
||||
#endif
|
||||
|
||||
if (state == SCD4X_MEASUREMENT) {
|
||||
status = 1;
|
||||
} else {
|
||||
status = 0;
|
||||
}
|
||||
|
||||
initI2CSensor();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SCD4XSensor::getMetrics(meshtastic_Telemetry *measurement)
|
||||
{
|
||||
|
||||
if (state != SCD4X_MEASUREMENT) {
|
||||
LOG_ERROR("%s: Not in measurement mode", sensorName);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint16_t co2, error;
|
||||
float temperature, humidity;
|
||||
|
||||
#ifdef SCD4X_I2C_CLOCK_SPEED
|
||||
#ifdef CAN_RECLOCK_I2C
|
||||
uint32_t currentClock = reClockI2C(SCD4X_I2C_CLOCK_SPEED, _bus, false);
|
||||
#elif !HAS_SCREEN
|
||||
reClockI2C(SCD4X_I2C_CLOCK_SPEED, _bus, true);
|
||||
#else
|
||||
LOG_WARN("%s can't be used at this clock speed, with a screen", sensorName);
|
||||
return false;
|
||||
#endif /* CAN_RECLOCK_I2C */
|
||||
#endif /* SCD4X_I2C_CLOCK_SPEED */
|
||||
|
||||
bool dataReady;
|
||||
error = scd4x.getDataReadyStatus(dataReady);
|
||||
if (!dataReady) {
|
||||
#if defined(SCD4X_I2C_CLOCK_SPEED) && defined(CAN_RECLOCK_I2C)
|
||||
reClockI2C(currentClock, _bus, false);
|
||||
#endif
|
||||
LOG_ERROR("SCD4X: Data is not ready");
|
||||
return false;
|
||||
}
|
||||
|
||||
error = scd4x.readMeasurement(co2, temperature, humidity);
|
||||
|
||||
#if defined(SCD4X_I2C_CLOCK_SPEED) && defined(CAN_RECLOCK_I2C)
|
||||
reClockI2C(currentClock, _bus, false);
|
||||
#endif
|
||||
|
||||
LOG_DEBUG("%s readings: %u ppm, %.2f degC, %.2f %rh", sensorName, co2, temperature, humidity);
|
||||
if (error != SCD4X_NO_ERROR) {
|
||||
LOG_DEBUG("%s: Error while getting measurements: %u", sensorName, error);
|
||||
if (co2 == 0) {
|
||||
LOG_ERROR("%s: Skipping invalid measurement.", sensorName);
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
measurement->variant.air_quality_metrics.has_co2_temperature = true;
|
||||
measurement->variant.air_quality_metrics.has_co2_humidity = true;
|
||||
measurement->variant.air_quality_metrics.has_co2 = true;
|
||||
measurement->variant.air_quality_metrics.co2_temperature = temperature;
|
||||
measurement->variant.air_quality_metrics.co2_humidity = humidity;
|
||||
measurement->variant.air_quality_metrics.co2 = co2;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Perform a forced recalibration (FRC) of the CO₂ concentration.
|
||||
*
|
||||
* From Sensirion SCD4X I2C Library
|
||||
*
|
||||
* 1. Operate the SCD4x in the operation mode later used for normal sensor
|
||||
* operation (e.g. periodic measurement) for at least 3 minutes in an
|
||||
* environment with a homogenous and constant CO2 concentration. The sensor
|
||||
* must be operated at the voltage desired for the application when
|
||||
* performing the FRC sequence. 2. Issue the stop_periodic_measurement
|
||||
* command. 3. Issue the perform_forced_recalibration command.
|
||||
* @note This function should not change the clock
|
||||
*/
|
||||
bool SCD4XSensor::performFRC(uint32_t targetCO2)
|
||||
{
|
||||
uint16_t error, frcCorr;
|
||||
|
||||
LOG_INFO("%s: Issuing FRC. Ensure device has been working at least 3 minutes in stable target environment", sensorName);
|
||||
|
||||
if (!stopMeasurement()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
LOG_INFO("%s: Target CO2: %u ppm", sensorName, targetCO2);
|
||||
error = scd4x.performForcedRecalibration((uint16_t)targetCO2, frcCorr);
|
||||
|
||||
// SCD4X Sensirion datasheet
|
||||
delay(400);
|
||||
|
||||
if (error != SCD4X_NO_ERROR) {
|
||||
LOG_ERROR("%s: Unable to perform forced recalibration.", sensorName);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (frcCorr == 0xFFFF) {
|
||||
LOG_ERROR("%s: Error while performing forced recalibration.", sensorName);
|
||||
return false;
|
||||
}
|
||||
|
||||
LOG_INFO("%s: FRC Correction successful. Correction output: %u", sensorName, (uint16_t)(frcCorr - 0x8000));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Start measurement mode
|
||||
* @note This function should not change the clock
|
||||
*/
|
||||
bool SCD4XSensor::startMeasurement()
|
||||
{
|
||||
uint16_t error;
|
||||
|
||||
if (state == SCD4X_MEASUREMENT) {
|
||||
LOG_DEBUG("%s: Already in measurement mode", sensorName);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (lowPower) {
|
||||
error = scd4x.startLowPowerPeriodicMeasurement();
|
||||
} else {
|
||||
error = scd4x.startPeriodicMeasurement();
|
||||
}
|
||||
|
||||
if (error == SCD4X_NO_ERROR) {
|
||||
LOG_INFO("%s: Started measurement mode", sensorName);
|
||||
if (lowPower) {
|
||||
LOG_INFO("%s: Low power mode", sensorName);
|
||||
} else {
|
||||
LOG_INFO("%s: Normal power mode", sensorName);
|
||||
}
|
||||
|
||||
state = SCD4X_MEASUREMENT;
|
||||
return true;
|
||||
} else {
|
||||
LOG_ERROR("%s: Couldn't start measurement mode", sensorName);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Stop measurement mode
|
||||
* @note This function should not change the clock
|
||||
*/
|
||||
bool SCD4XSensor::stopMeasurement()
|
||||
{
|
||||
uint16_t error;
|
||||
|
||||
error = scd4x.stopPeriodicMeasurement();
|
||||
if (error != SCD4X_NO_ERROR) {
|
||||
LOG_ERROR("%s: Unable to set idle mode on SCD4X.", sensorName);
|
||||
return false;
|
||||
}
|
||||
|
||||
state = SCD4X_IDLE;
|
||||
co2MeasureStarted = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set power mode
|
||||
* Pass true to set low power mode
|
||||
* @note This function should not change the clock
|
||||
*/
|
||||
bool SCD4XSensor::setPowerMode(bool _lowPower)
|
||||
{
|
||||
lowPower = _lowPower;
|
||||
|
||||
if (!stopMeasurement()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (lowPower) {
|
||||
LOG_DEBUG("%s: Set low power mode", sensorName);
|
||||
} else {
|
||||
LOG_DEBUG("%s: Set normal power mode", sensorName);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check the current mode (ASC or FRC)
|
||||
* From Sensirion SCD4X I2C Library
|
||||
* @note This function should not change the clock
|
||||
*/
|
||||
bool SCD4XSensor::getASC(uint16_t &_ascActive)
|
||||
{
|
||||
uint16_t error;
|
||||
LOG_INFO("%s: Getting ASC", sensorName);
|
||||
|
||||
if (!stopMeasurement()) {
|
||||
return false;
|
||||
}
|
||||
error = scd4x.getAutomaticSelfCalibrationEnabled(_ascActive);
|
||||
|
||||
if (error != SCD4X_NO_ERROR) {
|
||||
LOG_ERROR("%s: Unable to send command.", sensorName);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_ascActive) {
|
||||
LOG_INFO("%s: ASC is enabled", sensorName);
|
||||
} else {
|
||||
LOG_INFO("%s: FRC is enabled", sensorName);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable or disable automatic self calibration (ASC).
|
||||
*
|
||||
* From Sensirion SCD4X I2C Library
|
||||
*
|
||||
* Sets the current state (enabled / disabled) of the ASC. By default, ASC
|
||||
* is enabled.
|
||||
* @note This function should not change the clock
|
||||
*/
|
||||
bool SCD4XSensor::setASC(bool ascEnabled)
|
||||
{
|
||||
uint16_t error;
|
||||
|
||||
if (ascEnabled) {
|
||||
LOG_INFO("%s: Enabling ASC", sensorName);
|
||||
} else {
|
||||
LOG_INFO("%s: Disabling ASC", sensorName);
|
||||
}
|
||||
|
||||
if (!stopMeasurement()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
error = scd4x.setAutomaticSelfCalibrationEnabled((uint16_t)ascEnabled);
|
||||
|
||||
if (error != SCD4X_NO_ERROR) {
|
||||
LOG_ERROR("%s: Unable to send command.", sensorName);
|
||||
return false;
|
||||
}
|
||||
|
||||
error = scd4x.persistSettings();
|
||||
if (error != SCD4X_NO_ERROR) {
|
||||
LOG_ERROR("%s: Unable to make settings persistent.", sensorName);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!getASC(ascActive)) {
|
||||
LOG_ERROR("%s: Unable to check if ASC is enabled", sensorName);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ascActive) {
|
||||
LOG_INFO("%s: ASC is enabled", sensorName);
|
||||
} else {
|
||||
LOG_INFO("%s: ASC is disabled", sensorName);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the value of ASC baseline target in ppm.
|
||||
*
|
||||
* From Sensirion SCD4X I2C Library.
|
||||
*
|
||||
* Sets the value of the ASC baseline target, i.e. the CO₂ concentration in
|
||||
* ppm which the ASC algorithm will assume as lower-bound background to
|
||||
* which the SCD4x is exposed to regularly within one ASC period of
|
||||
* operation. To save the setting to the EEPROM, the persist_settings
|
||||
* command must be issued subsequently. The factory default value is 400
|
||||
* ppm.
|
||||
* @note This function should not change the clock
|
||||
*/
|
||||
bool SCD4XSensor::setASCBaseline(uint32_t targetCO2)
|
||||
{
|
||||
// TODO - Remove?
|
||||
// Available in library, but not described in datasheet.
|
||||
uint16_t error;
|
||||
LOG_INFO("%s: Setting ASC baseline to: %u", sensorName, targetCO2);
|
||||
|
||||
getASC(ascActive);
|
||||
if (!ascActive) {
|
||||
LOG_ERROR("%s: Can't set ASC baseline. ASC is not active", sensorName);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!stopMeasurement()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
error = scd4x.setAutomaticSelfCalibrationTarget((uint16_t)targetCO2);
|
||||
|
||||
if (error != SCD4X_NO_ERROR) {
|
||||
LOG_ERROR("%s: Unable to send command.", sensorName);
|
||||
return false;
|
||||
}
|
||||
|
||||
error = scd4x.persistSettings();
|
||||
if (error != SCD4X_NO_ERROR) {
|
||||
LOG_ERROR("%s: Unable to make settings persistent.", sensorName);
|
||||
return false;
|
||||
}
|
||||
|
||||
LOG_INFO("%s: Setting ASC baseline successful", sensorName);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the temperature compensation reference.
|
||||
*
|
||||
* From Sensirion SCD4X I2C Library.
|
||||
*
|
||||
* Setting the temperature offset of the SCD4x inside the customer device
|
||||
* allows the user to optimize the RH and T output signal.
|
||||
* By default, the temperature offset is set to 4 °C. To save
|
||||
* the setting to the EEPROM, the persist_settings command may be issued.
|
||||
* Equation (1) details how the characteristic temperature offset can be
|
||||
* calculated using the current temperature output of the sensor (TSCD4x), a
|
||||
* reference temperature value (TReference), and the previous temperature
|
||||
* offset (Toffset_pervious) obtained using the get_temperature_offset_raw
|
||||
* command:
|
||||
*
|
||||
* Toffset_actual = TSCD4x - TReference + Toffset_pervious.
|
||||
*
|
||||
* Recommended temperature offset values are between 0 °C and 20 °C. The
|
||||
* temperature offset does not impact the accuracy of the CO2 output.
|
||||
* @note This function should not change the clock
|
||||
*/
|
||||
bool SCD4XSensor::setTemperature(float tempReference)
|
||||
{
|
||||
uint16_t error;
|
||||
float prevTempOffset;
|
||||
float updatedTempOffset;
|
||||
float tempOffset;
|
||||
bool dataReady;
|
||||
uint16_t co2;
|
||||
float temperature;
|
||||
float humidity;
|
||||
|
||||
LOG_INFO("%s: Setting reference temperature at: %.2f", sensorName, tempReference);
|
||||
|
||||
error = scd4x.getDataReadyStatus(dataReady);
|
||||
if (!dataReady) {
|
||||
LOG_ERROR("%s: Data is not ready", sensorName);
|
||||
return false;
|
||||
}
|
||||
|
||||
error = scd4x.readMeasurement(co2, temperature, humidity);
|
||||
if (error != SCD4X_NO_ERROR) {
|
||||
LOG_ERROR("%s: Unable to read current temperature. Error code: %u", sensorName, error);
|
||||
return false;
|
||||
}
|
||||
|
||||
LOG_INFO("%s: Current sensor temperature: %.2f", sensorName, temperature);
|
||||
|
||||
if (!stopMeasurement()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
error = scd4x.getTemperatureOffset(prevTempOffset);
|
||||
|
||||
if (error != SCD4X_NO_ERROR) {
|
||||
LOG_ERROR("%s: Unable to get temperature offset. Error code: %u", sensorName, error);
|
||||
return false;
|
||||
}
|
||||
LOG_INFO("%s: Current sensor temperature offset: %.2f", sensorName, prevTempOffset);
|
||||
|
||||
tempOffset = temperature - tempReference + prevTempOffset;
|
||||
|
||||
LOG_INFO("%s: Setting temperature offset: %.2f", sensorName, tempOffset);
|
||||
error = scd4x.setTemperatureOffset(tempOffset);
|
||||
if (error != SCD4X_NO_ERROR) {
|
||||
LOG_ERROR("%s: Unable to set temperature offset. Error code: %u", sensorName, error);
|
||||
return false;
|
||||
}
|
||||
|
||||
error = scd4x.persistSettings();
|
||||
if (error != SCD4X_NO_ERROR) {
|
||||
LOG_ERROR("%s: Unable to make settings persistent. Error code: %u", sensorName, error);
|
||||
return false;
|
||||
}
|
||||
|
||||
scd4x.getTemperatureOffset(updatedTempOffset);
|
||||
LOG_INFO("%s: Updated sensor temperature offset: %.2f", sensorName, updatedTempOffset);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the sensor altitude.
|
||||
*
|
||||
* From Sensirion SCD4X I2C Library.
|
||||
*
|
||||
* Altitude in meters above sea level can be set after device installation.
|
||||
* Valid value between 0 and 3000m. This overrides pressure offset.
|
||||
* @note This function should not change the clock
|
||||
*/
|
||||
bool SCD4XSensor::getAltitude(uint16_t &altitude)
|
||||
{
|
||||
uint16_t error;
|
||||
LOG_INFO("%s: Requesting sensor altitude", sensorName);
|
||||
|
||||
if (!stopMeasurement()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
error = scd4x.getSensorAltitude(altitude);
|
||||
|
||||
if (error != SCD4X_NO_ERROR) {
|
||||
LOG_ERROR("%s: Unable to get altitude. Error code: %u", sensorName, error);
|
||||
return false;
|
||||
}
|
||||
LOG_INFO("%s: Sensor altitude: %u", sensorName, altitude);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the ambient pressure around the sensor.
|
||||
*
|
||||
* From Sensirion SCD4X I2C Library.
|
||||
*
|
||||
* Gets the ambient pressure in Pa.
|
||||
* @note This function should not change the clock
|
||||
*/
|
||||
bool SCD4XSensor::getAmbientPressure(uint32_t &ambientPressure)
|
||||
{
|
||||
uint16_t error;
|
||||
LOG_INFO("%s: Requesting sensor ambient pressure", sensorName);
|
||||
|
||||
error = scd4x.getAmbientPressure(ambientPressure);
|
||||
|
||||
if (error != SCD4X_NO_ERROR) {
|
||||
LOG_ERROR("%s: Unable to get altitude. Error code: %u", sensorName, error);
|
||||
return false;
|
||||
}
|
||||
LOG_INFO("%s: Sensor ambient pressure: %u", sensorName, ambientPressure);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the sensor altitude.
|
||||
*
|
||||
* From Sensirion SCD4X I2C Library.
|
||||
*
|
||||
* Altitude in meters above sea level can be set after device installation.
|
||||
* Valid value between 0 and 3000m. This overrides pressure offset.
|
||||
* @note This function should not change the clock
|
||||
*/
|
||||
bool SCD4XSensor::setAltitude(uint32_t altitude)
|
||||
{
|
||||
uint16_t error;
|
||||
|
||||
if (!stopMeasurement()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
error = scd4x.setSensorAltitude(altitude);
|
||||
|
||||
if (error != SCD4X_NO_ERROR) {
|
||||
LOG_ERROR("%s: Unable to set altitude. Error code: %u", sensorName, error);
|
||||
return false;
|
||||
}
|
||||
|
||||
error = scd4x.persistSettings();
|
||||
if (error != SCD4X_NO_ERROR) {
|
||||
LOG_ERROR("%s: Unable to make settings persistent. Error code: %u", sensorName, error);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the ambient pressure around the sensor.
|
||||
*
|
||||
* From Sensirion SCD4X I2C Library.
|
||||
*
|
||||
* The set_ambient_pressure command can be sent during periodic measurements
|
||||
* to enable continuous pressure compensation. Note that setting an ambient
|
||||
* pressure overrides any pressure compensation based on a previously set
|
||||
* sensor altitude. Use of this command is highly recommended for
|
||||
* applications experiencing significant ambient pressure changes to ensure
|
||||
* sensor accuracy. Valid input values are between 70000 - 120000 Pa. The
|
||||
* default value is 101300 Pa.
|
||||
* @note This function should not change the clock
|
||||
*/
|
||||
bool SCD4XSensor::setAmbientPressure(uint32_t ambientPressure)
|
||||
{
|
||||
uint16_t error;
|
||||
|
||||
error = scd4x.setAmbientPressure(ambientPressure);
|
||||
|
||||
if (error != SCD4X_NO_ERROR) {
|
||||
LOG_ERROR("%s: Unable to set altitude. Error code: %u", sensorName, error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Sensirion doesn't indicate if this is necessary. We send it anyway
|
||||
error = scd4x.persistSettings();
|
||||
if (error != SCD4X_NO_ERROR) {
|
||||
LOG_ERROR("%s: Unable to make settings persistent. Error code: %u", sensorName, error);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Perform factory reset to erase the settings stored in the EEPROM.
|
||||
*
|
||||
* From Sensirion SCD4X I2C Library.
|
||||
*
|
||||
* The perform_factory_reset command resets all configuration settings
|
||||
* stored in the EEPROM and erases the FRC and ASC algorithm history.
|
||||
* @note This function should not change the clock
|
||||
*/
|
||||
bool SCD4XSensor::factoryReset()
|
||||
{
|
||||
uint16_t error;
|
||||
|
||||
LOG_INFO("%s: Requesting factory reset", sensorName);
|
||||
|
||||
if (!stopMeasurement()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
error = scd4x.performFactoryReset();
|
||||
|
||||
if (error != SCD4X_NO_ERROR) {
|
||||
LOG_ERROR("%s: Unable to do factory reset. Error code: %u", sensorName, error);
|
||||
return false;
|
||||
}
|
||||
|
||||
LOG_INFO("%s: Factory reset successful", sensorName);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Put the sensor into sleep mode from idle mode.
|
||||
*
|
||||
* From Sensirion SCD4X I2C Library.
|
||||
*
|
||||
* Put the sensor from idle to sleep to reduce power consumption. Can be
|
||||
* used to power down when operating the sensor in power-cycled single shot
|
||||
* mode.
|
||||
* @note This command is only available in idle mode. Only for SCD41.
|
||||
*/
|
||||
bool SCD4XSensor::powerDown()
|
||||
{
|
||||
LOG_INFO("%s: Trying to send sensor to sleep", sensorName);
|
||||
|
||||
if (sensorVariant != SCD4X_SENSOR_VARIANT_SCD41) {
|
||||
LOG_WARN("SCD4X: Can't send sensor to sleep. Incorrect variant. Ignoring");
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef SCD4X_I2C_CLOCK_SPEED
|
||||
#ifdef CAN_RECLOCK_I2C
|
||||
uint32_t currentClock = reClockI2C(SCD4X_I2C_CLOCK_SPEED, _bus, false);
|
||||
#elif !HAS_SCREEN
|
||||
reClockI2C(SCD4X_I2C_CLOCK_SPEED, _bus, true);
|
||||
#else
|
||||
LOG_WARN("%s can't be used at this clock speed, with a screen", sensorName);
|
||||
return false;
|
||||
#endif /* CAN_RECLOCK_I2C */
|
||||
#endif /* SCD4X_I2C_CLOCK_SPEED */
|
||||
|
||||
if (!stopMeasurement()) {
|
||||
#if defined(SCD4X_I2C_CLOCK_SPEED) && defined(CAN_RECLOCK_I2C)
|
||||
reClockI2C(currentClock, _bus, false);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
if (scd4x.powerDown() != SCD4X_NO_ERROR) {
|
||||
LOG_ERROR("%s: Error trying to execute sleep()", sensorName);
|
||||
#if defined(SCD4X_I2C_CLOCK_SPEED) && defined(CAN_RECLOCK_I2C)
|
||||
reClockI2C(currentClock, _bus, false);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
#if defined(SCD4X_I2C_CLOCK_SPEED) && defined(CAN_RECLOCK_I2C)
|
||||
reClockI2C(currentClock, _bus, false);
|
||||
#endif
|
||||
|
||||
state = SCD4X_OFF;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Wake up sensor from sleep mode to idle mode (powerUp)
|
||||
*
|
||||
* From Sensirion SCD4X I2C Library.
|
||||
*
|
||||
* Wake up the sensor from sleep mode into idle mode. Note that the SCD4x
|
||||
* does not acknowledge the wake_up command. The sensor's idle state after
|
||||
* wake up can be verified by reading out the serial number.
|
||||
* @note This command is only available for SCD41.
|
||||
* @note This function can't change clock (used in init)
|
||||
*/
|
||||
bool SCD4XSensor::powerUp()
|
||||
{
|
||||
LOG_INFO("%s: Waking up", sensorName);
|
||||
|
||||
if (scd4x.wakeUp() != SCD4X_NO_ERROR) {
|
||||
LOG_ERROR("%s: Error trying to execute wakeUp()", sensorName);
|
||||
return false;
|
||||
}
|
||||
|
||||
state = SCD4X_IDLE;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if sensor is in measurement mode
|
||||
*/
|
||||
bool SCD4XSensor::isActive()
|
||||
{
|
||||
return state == SCD4X_MEASUREMENT;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Start measurement mode
|
||||
* @note Not used in admin comands, getMetrics or init, can change clock.
|
||||
*/
|
||||
uint32_t SCD4XSensor::wakeUp()
|
||||
{
|
||||
|
||||
#ifdef SCD4X_I2C_CLOCK_SPEED
|
||||
#ifdef CAN_RECLOCK_I2C
|
||||
uint32_t currentClock = reClockI2C(SCD4X_I2C_CLOCK_SPEED, _bus, false);
|
||||
#elif !HAS_SCREEN
|
||||
reClockI2C(SCD4X_I2C_CLOCK_SPEED, _bus, true);
|
||||
#else
|
||||
LOG_WARN("%s can't be used at this clock speed, with a screen", sensorName);
|
||||
return 0;
|
||||
#endif /* CAN_RECLOCK_I2C */
|
||||
#endif /* SCD4X_I2C_CLOCK_SPEED */
|
||||
|
||||
if (startMeasurement()) {
|
||||
co2MeasureStarted = getTime();
|
||||
#if defined(SCD4X_I2C_CLOCK_SPEED) && defined(CAN_RECLOCK_I2C)
|
||||
reClockI2C(currentClock, _bus, false);
|
||||
#endif
|
||||
return SCD4X_WARMUP_MS;
|
||||
}
|
||||
|
||||
#if defined(SCD4X_I2C_CLOCK_SPEED) && defined(CAN_RECLOCK_I2C)
|
||||
reClockI2C(currentClock, _bus, false);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Stop measurement mode
|
||||
* @note Not used in admin comands, getMetrics or init, can change clock.
|
||||
*/
|
||||
void SCD4XSensor::sleep()
|
||||
{
|
||||
#ifdef SCD4X_I2C_CLOCK_SPEED
|
||||
#ifdef CAN_RECLOCK_I2C
|
||||
uint32_t currentClock = reClockI2C(SCD4X_I2C_CLOCK_SPEED, _bus, false);
|
||||
#elif !HAS_SCREEN
|
||||
reClockI2C(SCD4X_I2C_CLOCK_SPEED, _bus, true);
|
||||
#else
|
||||
LOG_WARN("%s can't be used at this clock speed, with a screen", sensorName);
|
||||
return;
|
||||
#endif /* CAN_RECLOCK_I2C */
|
||||
#endif /* SCD4X_I2C_CLOCK_SPEED */
|
||||
|
||||
stopMeasurement();
|
||||
|
||||
#if defined(SCD4X_I2C_CLOCK_SPEED) && defined(CAN_RECLOCK_I2C)
|
||||
reClockI2C(currentClock, _bus, false);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Can sleep function
|
||||
*
|
||||
* Power consumption is very low on lowPower mode, modify this function if
|
||||
* you still want to override this behaviour. Otherwise, sleep is disabled
|
||||
* routinely in low power mode
|
||||
*/
|
||||
bool SCD4XSensor::canSleep()
|
||||
{
|
||||
return lowPower ? false : true;
|
||||
}
|
||||
|
||||
int32_t SCD4XSensor::wakeUpTimeMs()
|
||||
{
|
||||
return SCD4X_WARMUP_MS;
|
||||
}
|
||||
|
||||
int32_t SCD4XSensor::pendingForReadyMs()
|
||||
{
|
||||
uint32_t now;
|
||||
now = getTime();
|
||||
uint32_t sinceCO2MeasureStarted = (now - co2MeasureStarted) * 1000;
|
||||
LOG_DEBUG("%s: Since measure started: %ums", sensorName, sinceCO2MeasureStarted);
|
||||
|
||||
if (sinceCO2MeasureStarted < SCD4X_WARMUP_MS) {
|
||||
LOG_INFO("%s: not enough time passed since starting measurement", sensorName);
|
||||
return SCD4X_WARMUP_MS - sinceCO2MeasureStarted;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
AdminMessageHandleResult SCD4XSensor::handleAdminMessage(const meshtastic_MeshPacket &mp, meshtastic_AdminMessage *request,
|
||||
meshtastic_AdminMessage *response)
|
||||
{
|
||||
AdminMessageHandleResult result;
|
||||
|
||||
#ifdef SCD4X_I2C_CLOCK_SPEED
|
||||
#ifdef CAN_RECLOCK_I2C
|
||||
uint32_t currentClock = reClockI2C(SCD4X_I2C_CLOCK_SPEED, _bus, false);
|
||||
#elif !HAS_SCREEN
|
||||
reClockI2C(SCD4X_I2C_CLOCK_SPEED, _bus, true);
|
||||
#else
|
||||
LOG_WARN("%s can't be used at this clock speed, with a screen", sensorName);
|
||||
return AdminMessageHandleResult::NOT_HANDLED;
|
||||
#endif /* CAN_RECLOCK_I2C */
|
||||
#endif /* SCD4X_I2C_CLOCK_SPEED */
|
||||
|
||||
// TODO: potentially add selftest command?
|
||||
switch (request->which_payload_variant) {
|
||||
case meshtastic_AdminMessage_sensor_config_tag:
|
||||
// Check for ASC-FRC request first
|
||||
if (!request->sensor_config.has_scd4x_config) {
|
||||
result = AdminMessageHandleResult::NOT_HANDLED;
|
||||
break;
|
||||
}
|
||||
|
||||
if (request->sensor_config.scd4x_config.has_factory_reset) {
|
||||
LOG_DEBUG("%s: Requested factory reset", sensorName);
|
||||
this->factoryReset();
|
||||
} else {
|
||||
|
||||
if (request->sensor_config.scd4x_config.has_set_asc) {
|
||||
this->setASC(request->sensor_config.scd4x_config.set_asc);
|
||||
if (request->sensor_config.scd4x_config.set_asc == false) {
|
||||
LOG_DEBUG("%s: Request for FRC", sensorName);
|
||||
if (request->sensor_config.scd4x_config.has_set_target_co2_conc) {
|
||||
this->performFRC(request->sensor_config.scd4x_config.set_target_co2_conc);
|
||||
} else {
|
||||
// FRC requested but no target CO2 provided
|
||||
LOG_ERROR("%s: target CO2 not provided", sensorName);
|
||||
result = AdminMessageHandleResult::NOT_HANDLED;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
LOG_DEBUG("%s: Request for ASC", sensorName);
|
||||
if (request->sensor_config.scd4x_config.has_set_target_co2_conc) {
|
||||
LOG_DEBUG("%s: Request has target CO2", sensorName);
|
||||
// TODO - Remove? see setASCBaseline function
|
||||
this->setASCBaseline(request->sensor_config.scd4x_config.set_target_co2_conc);
|
||||
} else {
|
||||
LOG_DEBUG("%s: Request doesn't have target CO2", sensorName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check for temperature offset
|
||||
// NOTE: this requires to have a sensor working on stable environment
|
||||
// And to make it between readings
|
||||
if (request->sensor_config.scd4x_config.has_set_temperature) {
|
||||
this->setTemperature(request->sensor_config.scd4x_config.set_temperature);
|
||||
}
|
||||
|
||||
// Check for altitude or pressure offset
|
||||
if (request->sensor_config.scd4x_config.has_set_altitude) {
|
||||
this->setAltitude(request->sensor_config.scd4x_config.set_altitude);
|
||||
} else if (request->sensor_config.scd4x_config.has_set_ambient_pressure) {
|
||||
this->setAmbientPressure(request->sensor_config.scd4x_config.set_ambient_pressure);
|
||||
}
|
||||
|
||||
// Check for low power mode
|
||||
// NOTE: to switch from one mode to another do:
|
||||
// setPowerMode -> startMeasurement
|
||||
if (request->sensor_config.scd4x_config.has_set_power_mode) {
|
||||
this->setPowerMode(request->sensor_config.scd4x_config.set_power_mode);
|
||||
}
|
||||
}
|
||||
|
||||
// Start measurement mode
|
||||
this->startMeasurement();
|
||||
|
||||
result = AdminMessageHandleResult::HANDLED;
|
||||
break;
|
||||
|
||||
default:
|
||||
result = AdminMessageHandleResult::NOT_HANDLED;
|
||||
}
|
||||
|
||||
#if defined(SCD4X_I2C_CLOCK_SPEED) && defined(CAN_RECLOCK_I2C)
|
||||
reClockI2C(currentClock, _bus, false);
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,63 +0,0 @@
|
||||
#include "configuration.h"
|
||||
|
||||
#if !MESHTASTIC_EXCLUDE_AIR_QUALITY_SENSOR && __has_include(<SensirionI2cScd4x.h>)
|
||||
|
||||
#include "../mesh/generated/meshtastic/telemetry.pb.h"
|
||||
#include "RTC.h"
|
||||
#include "TelemetrySensor.h"
|
||||
#include <SensirionI2cScd4x.h>
|
||||
|
||||
// Max speed 400kHz
|
||||
#define SCD4X_I2C_CLOCK_SPEED 100000
|
||||
#define SCD4X_WARMUP_MS 5000
|
||||
|
||||
class SCD4XSensor : public TelemetrySensor
|
||||
{
|
||||
private:
|
||||
SensirionI2cScd4x scd4x;
|
||||
TwoWire *_bus{};
|
||||
uint8_t _address{};
|
||||
|
||||
bool performFRC(uint32_t targetCO2);
|
||||
bool setASCBaseline(uint32_t targetCO2);
|
||||
bool getASC(uint16_t &ascEnabled);
|
||||
bool setASC(bool ascEnabled);
|
||||
bool setTemperature(float tempReference);
|
||||
bool getAltitude(uint16_t &altitude);
|
||||
bool setAltitude(uint32_t altitude);
|
||||
bool getAmbientPressure(uint32_t &ambientPressure);
|
||||
bool setAmbientPressure(uint32_t ambientPressure);
|
||||
bool factoryReset();
|
||||
bool setPowerMode(bool _lowPower);
|
||||
bool startMeasurement();
|
||||
bool stopMeasurement();
|
||||
|
||||
uint16_t ascActive = 1;
|
||||
// low power measurement mode (on sensirion side). Disables sleep mode
|
||||
// Improvement and testing needed for timings
|
||||
bool lowPower = true;
|
||||
uint32_t co2MeasureStarted = 0;
|
||||
|
||||
public:
|
||||
SCD4XSensor();
|
||||
virtual bool getMetrics(meshtastic_Telemetry *measurement) override;
|
||||
virtual bool initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev) override;
|
||||
|
||||
enum SCD4XState { SCD4X_OFF, SCD4X_IDLE, SCD4X_MEASUREMENT };
|
||||
SCD4XState state = SCD4X_OFF;
|
||||
SCD4xSensorVariant sensorVariant{};
|
||||
|
||||
virtual bool isActive() override;
|
||||
|
||||
virtual void sleep() override; // Stops measurement (measurement -> idle)
|
||||
virtual uint32_t wakeUp() override; // Starts measurement (idle -> measurement)
|
||||
bool powerDown(); // Powers down sensor (idle -> power-off)
|
||||
bool powerUp(); // Powers the sensor (power-off -> idle)
|
||||
virtual bool canSleep() override;
|
||||
virtual int32_t wakeUpTimeMs() override;
|
||||
virtual int32_t pendingForReadyMs() override;
|
||||
AdminMessageHandleResult handleAdminMessage(const meshtastic_MeshPacket &mp, meshtastic_AdminMessage *request,
|
||||
meshtastic_AdminMessage *response) override;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,137 +0,0 @@
|
||||
#include "configuration.h"
|
||||
|
||||
#if !MESHTASTIC_EXCLUDE_AIR_QUALITY_SENSOR && __has_include(<SensirionI2cStc3x.h>)
|
||||
|
||||
#include "../mesh/generated/meshtastic/telemetry.pb.h"
|
||||
#include "STC31Sensor.h"
|
||||
|
||||
#define STC31_NO_ERROR 0
|
||||
|
||||
// Binary gas configurations from STC31 datasheet
|
||||
// See: setBinaryGas() - section 3.3.2 in the datasheet
|
||||
#define STC31_BINARY_GAS_CO2_N2_100 0x0000 // CO2 in N2, 0-100 vol%
|
||||
#define STC31_BINARY_GAS_CO2_AIR_100 0x0001 // CO2 in air, 0-100 vol%
|
||||
#define STC31_BINARY_GAS_CO2_N2_25 0x0002 // CO2 in N2, 0-25 vol%
|
||||
#define STC31_BINARY_GAS_CO2_AIR_25 0x0003 // CO2 in air, 0-25 vol%
|
||||
|
||||
STC31Sensor::STC31Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_STC31, "STC31") {}
|
||||
|
||||
bool STC31Sensor::configureBinaryGas()
|
||||
{
|
||||
// STC31 requires binary gas mode to be set before measurements
|
||||
// It resets to default mode (no gas selected) after power cycle or reset
|
||||
LOG_DEBUG("%s: Configuring binary gas mode (CO2 in air, 0-25%%)", sensorName);
|
||||
int16_t error = stc3x.setBinaryGas(STC31_BINARY_GAS_CO2_AIR_25);
|
||||
if (error != STC31_NO_ERROR) {
|
||||
LOG_ERROR("%s: Failed to set binary gas mode, error: %d", sensorName, error);
|
||||
return false;
|
||||
}
|
||||
LOG_DEBUG("%s: Binary gas mode configured successfully", sensorName);
|
||||
binaryGasConfigured = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool STC31Sensor::setHumidityCompensation()
|
||||
{
|
||||
// Use actual humidity from environment sensor if available, otherwise default to 50%
|
||||
float humidity = hasValidHumidity ? lastEnvironmentHumidity : 50.0f;
|
||||
|
||||
LOG_DEBUG("%s: Setting humidity compensation to %.1f%%", sensorName, humidity);
|
||||
int16_t error = stc3x.setRelativeHumidity(humidity);
|
||||
if (error != STC31_NO_ERROR) {
|
||||
LOG_WARN("%s: Failed to set humidity compensation (%.1f%%), error: %d", sensorName, humidity, error);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool STC31Sensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
|
||||
{
|
||||
LOG_INFO("Init sensor: %s at address 0x%02x", sensorName, dev->address.address);
|
||||
|
||||
_bus = bus;
|
||||
_address = dev->address.address;
|
||||
|
||||
stc3x.begin(*_bus, _address);
|
||||
|
||||
// Allow sensor to fully stabilize after power-on
|
||||
delay(100);
|
||||
|
||||
// Run self-test to verify sensor is working
|
||||
STC3xTestResultT selfTestResult;
|
||||
int16_t testError = stc3x.selfTest(selfTestResult);
|
||||
if (testError != STC31_NO_ERROR) {
|
||||
LOG_WARN("%s: Self-test command failed with error: %d", sensorName, testError);
|
||||
} else if (selfTestResult.value != 0) {
|
||||
LOG_WARN("%s: Self-test reported error: 0x%04x", sensorName, selfTestResult.value);
|
||||
} else {
|
||||
LOG_DEBUG("%s: Self-test passed", sensorName);
|
||||
}
|
||||
|
||||
// Wait after self-test before configuring
|
||||
delay(50);
|
||||
|
||||
if (!configureBinaryGas())
|
||||
return false;
|
||||
|
||||
setHumidityCompensation(); // Non-fatal if this fails
|
||||
|
||||
status = 1;
|
||||
initI2CSensor();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool STC31Sensor::getMetrics(meshtastic_Telemetry *measurement)
|
||||
{
|
||||
float gasConcentration = 0;
|
||||
float temperature = 0;
|
||||
|
||||
// Binary gas mode is configured once during initDevice() and persists
|
||||
// Humidity compensation can be updated for each measurement
|
||||
setHumidityCompensation(); // Non-fatal if this fails
|
||||
|
||||
// Small delay for humidity compensation to take effect
|
||||
delay(10);
|
||||
|
||||
// Retry measurement up to 3 times with increasing delays
|
||||
int16_t error = STC31_NO_ERROR;
|
||||
for (int attempt = 0; attempt < 3; attempt++) {
|
||||
error = stc3x.measureGasConcentration(gasConcentration, temperature);
|
||||
if (error == STC31_NO_ERROR)
|
||||
break;
|
||||
LOG_WARN("%s: Measurement attempt %d failed (error %d), retrying...", sensorName, attempt + 1, error);
|
||||
|
||||
// If we get NotEnoughDataError (0x00F in error), the sensor may have lost its config
|
||||
// Try re-configuring binary gas mode
|
||||
if ((error & 0x00F) == 0x00F && attempt == 1) {
|
||||
LOG_WARN("%s: Sensor may have lost configuration, re-configuring binary gas mode", sensorName);
|
||||
configureBinaryGas();
|
||||
delay(100);
|
||||
} else {
|
||||
delay(100 * (attempt + 1));
|
||||
}
|
||||
}
|
||||
|
||||
if (error != STC31_NO_ERROR) {
|
||||
LOG_ERROR("%s: Error reading measurement after retries: %d", sensorName, error);
|
||||
// Mark that we need to re-configure on next attempt
|
||||
binaryGasConfigured = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Convert percentage to ppm: 1% = 10000 ppm
|
||||
uint32_t co2_ppm = (uint32_t)(gasConcentration * 10000.0f);
|
||||
|
||||
LOG_DEBUG("%s readings: %.2f%% CO2 (=%u ppm), %.2f degC", sensorName, gasConcentration, co2_ppm, temperature);
|
||||
|
||||
measurement->variant.air_quality_metrics.has_co2 = true;
|
||||
measurement->variant.air_quality_metrics.co2 = co2_ppm;
|
||||
|
||||
measurement->variant.air_quality_metrics.has_co2_temperature = true;
|
||||
measurement->variant.air_quality_metrics.co2_temperature = temperature;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,26 +0,0 @@
|
||||
#include "configuration.h"
|
||||
|
||||
#if !MESHTASTIC_EXCLUDE_AIR_QUALITY_SENSOR && __has_include(<SensirionI2cStc3x.h>)
|
||||
|
||||
#include "../mesh/generated/meshtastic/telemetry.pb.h"
|
||||
#include "TelemetrySensor.h"
|
||||
#include <SensirionI2cStc3x.h>
|
||||
|
||||
class STC31Sensor : public TelemetrySensor
|
||||
{
|
||||
private:
|
||||
SensirionI2cStc3x stc3x;
|
||||
TwoWire *_bus{};
|
||||
uint8_t _address{};
|
||||
bool binaryGasConfigured = false;
|
||||
|
||||
bool configureBinaryGas();
|
||||
bool setHumidityCompensation();
|
||||
|
||||
public:
|
||||
STC31Sensor();
|
||||
virtual bool getMetrics(meshtastic_Telemetry *measurement) override;
|
||||
virtual bool initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev) override;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -7,9 +7,4 @@
|
||||
#include "TelemetrySensor.h"
|
||||
#include "main.h"
|
||||
|
||||
// Shared humidity value for cross-sensor compensation
|
||||
// Default to 50% if no humidity sensor is available
|
||||
float lastEnvironmentHumidity = 50.0f;
|
||||
bool hasValidHumidity = false;
|
||||
|
||||
#endif
|
||||
@@ -16,11 +16,6 @@ class TwoWire;
|
||||
#define DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS 1000
|
||||
extern std::pair<uint8_t, TwoWire *> nodeTelemetrySensorsMap[_meshtastic_TelemetrySensorType_MAX + 1];
|
||||
|
||||
// Shared humidity value for cross-sensor compensation (e.g., STC31 CO2 sensor)
|
||||
// Updated by environment sensors that measure humidity
|
||||
extern float lastEnvironmentHumidity;
|
||||
extern bool hasValidHumidity;
|
||||
|
||||
class TelemetrySensor
|
||||
{
|
||||
protected:
|
||||
|
||||
@@ -757,7 +757,11 @@ void NimbleBluetooth::deinit()
|
||||
isDeInit = true;
|
||||
|
||||
#ifdef BLE_LED
|
||||
digitalWrite(BLE_LED, LED_STATE_OFF);
|
||||
#ifdef BLE_LED_INVERTED
|
||||
digitalWrite(BLE_LED, HIGH);
|
||||
#else
|
||||
digitalWrite(BLE_LED, LOW);
|
||||
#endif
|
||||
#endif
|
||||
#ifndef NIMBLE_TWO
|
||||
NimBLEDevice::deinit();
|
||||
|
||||
@@ -158,7 +158,7 @@
|
||||
#endif
|
||||
|
||||
#ifdef PIN_LED1
|
||||
#define LED_POWER PIN_LED1 // LED1 on nrf52840-DK
|
||||
#define LED_PIN PIN_LED1 // LED1 on nrf52840-DK
|
||||
#endif
|
||||
|
||||
#ifdef PIN_BUTTON1
|
||||
|
||||
@@ -872,7 +872,6 @@ bool loadConfig(const char *configPath)
|
||||
}
|
||||
|
||||
if (yamlConfig["Config"]) {
|
||||
portduino_config.has_config_overrides = true;
|
||||
if (yamlConfig["Config"]["DisplayMode"]) {
|
||||
portduino_config.has_configDisplayMode = true;
|
||||
if ((yamlConfig["Config"]["DisplayMode"]).as<std::string>("") == "TWOCOLOR") {
|
||||
@@ -885,13 +884,6 @@ bool loadConfig(const char *configPath)
|
||||
portduino_config.configDisplayMode = meshtastic_Config_DisplayConfig_DisplayMode_DEFAULT;
|
||||
}
|
||||
}
|
||||
if (yamlConfig["Config"]["StatusMessage"]) {
|
||||
portduino_config.has_statusMessage = true;
|
||||
portduino_config.statusMessage = (yamlConfig["Config"]["StatusMessage"]).as<std::string>("");
|
||||
}
|
||||
if ((yamlConfig["Config"]["EnableUDP"]).as<bool>(false)) {
|
||||
portduino_config.enable_UDP = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (yamlConfig["General"]) {
|
||||
|
||||
@@ -177,12 +177,8 @@ extern struct portduino_config_struct {
|
||||
int hostMetrics_channel = 0;
|
||||
|
||||
// config
|
||||
bool has_config_overrides = false;
|
||||
int configDisplayMode = 0;
|
||||
bool has_configDisplayMode = false;
|
||||
std::string statusMessage = "";
|
||||
bool has_statusMessage = false;
|
||||
bool enable_UDP = false;
|
||||
|
||||
// General
|
||||
std::string mac_address = "";
|
||||
@@ -509,30 +505,21 @@ extern struct portduino_config_struct {
|
||||
}
|
||||
|
||||
// config
|
||||
if (has_config_overrides) {
|
||||
if (has_configDisplayMode) {
|
||||
out << YAML::Key << "Config" << YAML::Value << YAML::BeginMap;
|
||||
if (has_configDisplayMode) {
|
||||
|
||||
switch (configDisplayMode) {
|
||||
case meshtastic_Config_DisplayConfig_DisplayMode_TWOCOLOR:
|
||||
out << YAML::Key << "DisplayMode" << YAML::Value << "TWOCOLOR";
|
||||
break;
|
||||
case meshtastic_Config_DisplayConfig_DisplayMode_INVERTED:
|
||||
out << YAML::Key << "DisplayMode" << YAML::Value << "INVERTED";
|
||||
break;
|
||||
case meshtastic_Config_DisplayConfig_DisplayMode_COLOR:
|
||||
out << YAML::Key << "DisplayMode" << YAML::Value << "COLOR";
|
||||
break;
|
||||
case meshtastic_Config_DisplayConfig_DisplayMode_DEFAULT:
|
||||
out << YAML::Key << "DisplayMode" << YAML::Value << "DEFAULT";
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (has_statusMessage) {
|
||||
out << YAML::Key << "StatusMessage" << YAML::Value << statusMessage;
|
||||
}
|
||||
if (enable_UDP) {
|
||||
out << YAML::Key << "EnableUDP" << YAML::Value << true;
|
||||
switch (configDisplayMode) {
|
||||
case meshtastic_Config_DisplayConfig_DisplayMode_TWOCOLOR:
|
||||
out << YAML::Key << "DisplayMode" << YAML::Value << "TWOCOLOR";
|
||||
break;
|
||||
case meshtastic_Config_DisplayConfig_DisplayMode_INVERTED:
|
||||
out << YAML::Key << "DisplayMode" << YAML::Value << "INVERTED";
|
||||
break;
|
||||
case meshtastic_Config_DisplayConfig_DisplayMode_COLOR:
|
||||
out << YAML::Key << "DisplayMode" << YAML::Value << "COLOR";
|
||||
break;
|
||||
case meshtastic_Config_DisplayConfig_DisplayMode_DEFAULT:
|
||||
out << YAML::Key << "DisplayMode" << YAML::Value << "DEFAULT";
|
||||
break;
|
||||
}
|
||||
|
||||
out << YAML::EndMap; // Config
|
||||
|
||||
+2
-4
@@ -103,10 +103,8 @@ class Power : private concurrency::OSThread
|
||||
bool axpChipInit();
|
||||
/// Setup a simple ADC input based battery sensor
|
||||
bool analogInit();
|
||||
/// Setup cw2015 battery level sensor
|
||||
bool cw2015Init();
|
||||
/// Setup a 17048 battery level sensor
|
||||
bool max17048Init();
|
||||
/// Setup a Lipo battery level sensor
|
||||
bool lipoInit();
|
||||
/// Setup a Lipo charger
|
||||
bool lipoChargerInit();
|
||||
/// Setup a meshSolar battery sensor
|
||||
|
||||
@@ -149,15 +149,18 @@ std::string MeshPacketSerializer::JsonSerialize(const meshtastic_MeshPacket *mp,
|
||||
if (decoded->variant.air_quality_metrics.has_pm100_standard) {
|
||||
msgPayload["pm100"] = new JSONValue((unsigned int)decoded->variant.air_quality_metrics.pm100_standard);
|
||||
}
|
||||
if (decoded->variant.air_quality_metrics.has_co2) {
|
||||
msgPayload["co2"] = new JSONValue((unsigned int)decoded->variant.air_quality_metrics.co2);
|
||||
}
|
||||
if (decoded->variant.air_quality_metrics.has_co2_temperature) {
|
||||
msgPayload["co2_temperature"] = new JSONValue(decoded->variant.air_quality_metrics.co2_temperature);
|
||||
}
|
||||
if (decoded->variant.air_quality_metrics.has_co2_humidity) {
|
||||
msgPayload["co2_humidity"] = new JSONValue(decoded->variant.air_quality_metrics.co2_humidity);
|
||||
}
|
||||
// if (decoded->variant.air_quality_metrics.has_pm10_environmental) {
|
||||
// msgPayload["pm10_e"] =
|
||||
// new JSONValue((unsigned int)decoded->variant.air_quality_metrics.pm10_environmental);
|
||||
// }
|
||||
// if (decoded->variant.air_quality_metrics.has_pm25_environmental) {
|
||||
// msgPayload["pm25_e"] =
|
||||
// new JSONValue((unsigned int)decoded->variant.air_quality_metrics.pm25_environmental);
|
||||
// }
|
||||
// if (decoded->variant.air_quality_metrics.has_pm100_environmental) {
|
||||
// msgPayload["pm100_e"] =
|
||||
// new JSONValue((unsigned int)decoded->variant.air_quality_metrics.pm100_environmental);
|
||||
// }
|
||||
} else if (decoded->which_variant == meshtastic_Telemetry_power_metrics_tag) {
|
||||
if (decoded->variant.power_metrics.has_ch1_voltage) {
|
||||
msgPayload["voltage_ch1"] = new JSONValue(decoded->variant.power_metrics.ch1_voltage);
|
||||
|
||||
@@ -120,15 +120,15 @@ std::string MeshPacketSerializer::JsonSerialize(const meshtastic_MeshPacket *mp,
|
||||
if (decoded->variant.air_quality_metrics.has_pm100_standard) {
|
||||
jsonObj["payload"]["pm100"] = (unsigned int)decoded->variant.air_quality_metrics.pm100_standard;
|
||||
}
|
||||
if (decoded->variant.air_quality_metrics.has_co2) {
|
||||
jsonObj["payload"]["co2"] = (unsigned int)decoded->variant.air_quality_metrics.co2;
|
||||
}
|
||||
if (decoded->variant.air_quality_metrics.has_co2_temperature) {
|
||||
jsonObj["payload"]["co2_temperature"] = decoded->variant.air_quality_metrics.co2_temperature;
|
||||
}
|
||||
if (decoded->variant.air_quality_metrics.has_co2_humidity) {
|
||||
jsonObj["payload"]["co2_humidity"] = decoded->variant.air_quality_metrics.co2_humidity;
|
||||
}
|
||||
// if (decoded->variant.air_quality_metrics.has_pm10_environmental) {
|
||||
// jsonObj["payload"]["pm10_e"] = (unsigned int)decoded->variant.air_quality_metrics.pm10_environmental;
|
||||
// }
|
||||
// if (decoded->variant.air_quality_metrics.has_pm25_environmental) {
|
||||
// jsonObj["payload"]["pm25_e"] = (unsigned int)decoded->variant.air_quality_metrics.pm25_environmental;
|
||||
// }
|
||||
// if (decoded->variant.air_quality_metrics.has_pm100_environmental) {
|
||||
// jsonObj["payload"]["pm100_e"] = (unsigned int)decoded->variant.air_quality_metrics.pm100_environmental;
|
||||
// }
|
||||
} else if (decoded->which_variant == meshtastic_Telemetry_power_metrics_tag) {
|
||||
if (decoded->variant.power_metrics.has_ch1_voltage) {
|
||||
jsonObj["payload"]["voltage_ch1"] = decoded->variant.power_metrics.ch1_voltage;
|
||||
|
||||
+3
-2
@@ -5,6 +5,7 @@
|
||||
#endif
|
||||
|
||||
#include "Default.h"
|
||||
#include "Led.h"
|
||||
#include "MeshRadio.h"
|
||||
#include "MeshService.h"
|
||||
#include "NodeDB.h"
|
||||
@@ -12,7 +13,6 @@
|
||||
#include "detect/LoRaRadioType.h"
|
||||
#include "error.h"
|
||||
#include "main.h"
|
||||
#include "modules/StatusLEDModule.h"
|
||||
#include "sleep.h"
|
||||
#include "target_specific.h"
|
||||
|
||||
@@ -268,7 +268,8 @@ void doDeepSleep(uint32_t msecToWake, bool skipPreflight = false, bool skipSaveN
|
||||
digitalWrite(PIN_WD_EN, LOW);
|
||||
#endif
|
||||
#endif
|
||||
statusLEDModule->setPowerLED(false);
|
||||
ledBlink.set(false);
|
||||
|
||||
#ifdef RESET_OLED
|
||||
digitalWrite(RESET_OLED, 1); // put the display in reset before killing its power
|
||||
#endif
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#define LORA_CS 5
|
||||
#define RF95_FAN_EN 17
|
||||
|
||||
// This is a LED_WS2812 not a standard LED
|
||||
// #define LED_PIN 16 // This is a LED_WS2812 not a standard LED
|
||||
#define HAS_NEOPIXEL // Enable the use of neopixels
|
||||
#define NEOPIXEL_COUNT 1 // How many neopixels are connected
|
||||
#define NEOPIXEL_DATA 16 // gpio pin used to send data to the neopixels
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#define LORA_DIO2
|
||||
#define LORA_DIO3
|
||||
|
||||
#define LED_POWER 16 // green - blue is at 17
|
||||
#define LED_PIN 16 // green - blue is at 17
|
||||
|
||||
#define BUTTON_PIN 25
|
||||
#define BUTTON_NEED_PULLUP
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
#define SX126X_TXEN RADIOLIB_NC
|
||||
#define SX126X_RXEN RADIOLIB_NC
|
||||
|
||||
// Status
|
||||
// #define LED_PIN 1
|
||||
// External notification
|
||||
// FIXME: Check if EXT_NOTIFY_OUT actualy has any effect and removes the need for setting the external notication pin in the
|
||||
// app/preferences
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
#define BUTTON_PIN 15 // Right side button - if not available, set device.button_gpio to 0 from Meshtastic client
|
||||
|
||||
// LEDs
|
||||
#define LED_POWER 13 // Tx LED
|
||||
#define USER_LED 2 // Rx LED
|
||||
#define LED_PIN 13 // Tx LED
|
||||
#define USER_LED 2 // Rx LED
|
||||
|
||||
// Buzzer
|
||||
#define PIN_BUZZER 33
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#define ADC_MULTIPLIER 1.85 // (R1 = 470k, R2 = 680k)
|
||||
#define EXT_PWR_DETECT 4 // Pin to detect connected external power source for LILYGO® TTGO T-Energy T18 and other DIY boards
|
||||
#define EXT_NOTIFY_OUT 12 // Overridden default pin to use for Ext Notify Module (#975).
|
||||
#define LED_POWER 2 // add status LED (compatible with core-pcb and DIY targets)
|
||||
#define LED_PIN 2 // add status LED (compatible with core-pcb and DIY targets)
|
||||
|
||||
// Radio
|
||||
#define USE_SX1262 // E22-900M30S uses SX1262
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#define ADC_MULTIPLIER 1.85 // (R1 = 470k, R2 = 680k)
|
||||
#define EXT_PWR_DETECT 4 // Pin to detect connected external power source for LILYGO® TTGO T-Energy T18 and other DIY boards
|
||||
#define EXT_NOTIFY_OUT 12 // Overridden default pin to use for Ext Notify Module (#975).
|
||||
#define LED_POWER 2 // add status LED (compatible with core-pcb and DIY targets)
|
||||
#define LED_PIN 2 // add status LED (compatible with core-pcb and DIY targets)
|
||||
|
||||
#define LORA_DIO0 26 // a No connect on the SX1262/SX1268 module
|
||||
#define LORA_RESET 23 // RST for SX1276, and for SX1262/SX1268
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// HACKBOX LoRa IO Kit
|
||||
// Uses a ESP-32-WROOM and a RA-01SH (SX1262) LoRa Board
|
||||
|
||||
#define LED_POWER 2 // LED
|
||||
#define LED_PIN 2 // LED
|
||||
#define LED_STATE_ON 1 // State when LED is lit
|
||||
|
||||
#define HAS_SCREEN 0
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
#define RESET_OLED 16 // If defined, this pin will be used to reset the display controller
|
||||
|
||||
#define LED_POWER 25 // If defined we will blink this LED
|
||||
#define LED_PIN 25 // If defined we will blink this LED
|
||||
#define BUTTON_PIN 0 // If defined, this will be used for user button presses
|
||||
|
||||
#define USE_RF95
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#define RESET_OLED 16 // If defined, this pin will be used to reset the display controller
|
||||
|
||||
#define VEXT_ENABLE 21 // active low, powers the oled display and the lora antenna boost
|
||||
#define LED_POWER 25 // If defined we will blink this LED
|
||||
#define LED_PIN 25 // If defined we will blink this LED
|
||||
#define BUTTON_PIN 0 // If defined, this will be used for user button presses
|
||||
|
||||
#define USE_RF95
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#define RESET_OLED 16 // If defined, this pin will be used to reset the display controller
|
||||
|
||||
#define VEXT_ENABLE 21 // active low, powers the oled display and the lora antenna boost
|
||||
#define LED_POWER 25 // If defined we will blink this LED
|
||||
#define LED_PIN 25 // If defined we will blink this LED
|
||||
#define BUTTON_PIN 0 // If defined, this will be used for user button presses
|
||||
|
||||
#define USE_RF95
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#undef GPS_TX_PIN
|
||||
|
||||
// Green / Lora = PIN 22 / GPIO2, Yellow / Wifi = PIN 23 / GPIO0, Blue / BLE = PIN 25 / GPIO16
|
||||
#define LED_POWER 22
|
||||
#define LED_PIN 22
|
||||
#define WIFI_LED 23
|
||||
#define BLE_LED 25
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#define I2C_SCL SCL
|
||||
#define I2C_SDA SDA
|
||||
|
||||
#define LED_POWER LED
|
||||
#define LED_PIN LED
|
||||
|
||||
// active low, powers the Battery reader, but no lora antenna boost (?)
|
||||
// #define VEXT_ENABLE Vext
|
||||
|
||||
@@ -19,7 +19,7 @@ build_flags =
|
||||
lib_deps =
|
||||
${esp32_base.lib_deps}
|
||||
# renovate: datasource=custom.pio depName=GxEPD2 packageName=zinggjm/library/GxEPD2
|
||||
zinggjm/GxEPD2@1.6.7
|
||||
zinggjm/GxEPD2@1.6.6
|
||||
# renovate: datasource=custom.pio depName=SensorLib packageName=lewisxhe/library/SensorLib
|
||||
lewisxhe/SensorLib@0.3.4
|
||||
lib_ignore =
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
// Green LED
|
||||
#define LED_STATE_ON 1 // State when LED is lit
|
||||
#define LED_POWER 10
|
||||
#define LED_PIN 10
|
||||
|
||||
// PCF8563 RTC Module
|
||||
#define PCF8563_RTC 0x51
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
/*
|
||||
LED PIN setup.
|
||||
*/
|
||||
#define LED_POWER 15
|
||||
#define LED_PIN 15
|
||||
|
||||
/*
|
||||
Five way button when using ADC.
|
||||
|
||||
@@ -43,7 +43,7 @@ static const uint8_t SCK = 33;
|
||||
#undef GPS_TX_PIN
|
||||
#define GPS_TX_PIN (TX1)
|
||||
|
||||
#define LED_POWER LED_BLUE
|
||||
#define LED_PIN LED_BLUE
|
||||
|
||||
#define PIN_VBAT WB_A0
|
||||
#define BATTERY_PIN PIN_VBAT
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#define EXT_NOTIFY_OUT 13 // Default pin to use for Ext Notify Module.
|
||||
|
||||
#define LED_STATE_ON 0 // State when LED is lit
|
||||
#define LED_POWER 4 // Newer tbeams (1.1) have an extra led on GPIO4
|
||||
#define LED_PIN 4 // Newer tbeams (1.1) have an extra led on GPIO4
|
||||
|
||||
// TTGO uses a common pinout for their SX1262 vs RF95 modules - both can be enabled and we will probe at runtime for RF95 and if
|
||||
// not found then probe for SX1262
|
||||
@@ -49,7 +49,7 @@
|
||||
|
||||
#undef EXT_NOTIFY_OUT
|
||||
#undef LED_STATE_ON
|
||||
#undef LED_POWER
|
||||
#undef LED_PIN
|
||||
|
||||
#define HAS_CST226SE 1
|
||||
#define HAS_TOUCHSCREEN 1
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#define VEXT_ENABLE 21 // active low, powers the oled display and the lora antenna boost
|
||||
#define VEXT_ON_VALUE LOW
|
||||
#define LED_POWER 2 // If defined we will blink this LED
|
||||
#define LED_PIN 2 // If defined we will blink this LED
|
||||
#define BUTTON_PIN 0 // If defined, this will be used for user button presses
|
||||
#define BUTTON_NEED_PULLUP
|
||||
#define EXT_NOTIFY_OUT 13 // Default pin to use for Ext Notify Module.
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#define RESET_OLED 16 // If defined, this pin will be used to reset the display controller
|
||||
|
||||
#define VEXT_ENABLE 21 // active low, powers the oled display and the lora antenna boost
|
||||
#define LED_POWER 25 // If defined we will blink this LED
|
||||
#define LED_PIN 25 // If defined we will blink this LED
|
||||
#define BUTTON_PIN 36
|
||||
#define BUTTON_NEED_PULLUP
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#define I2C_SCL 22
|
||||
|
||||
#define VEXT_ENABLE 21 // active low, powers the oled display and the lora antenna boost
|
||||
#define LED_POWER 25 // If defined we will blink this LED
|
||||
#define LED_PIN 25 // If defined we will blink this LED
|
||||
#define BUTTON_PIN \
|
||||
0 // If defined, this will be used for user button presses, if your board doesn't have a physical switch, you can wire one
|
||||
// between this pin and ground
|
||||
|
||||
@@ -22,4 +22,4 @@ build_flags =
|
||||
${env:tlora-v2-1-1_6.build_flags}
|
||||
-DBUTTON_PIN=0
|
||||
-DPIN_BUZZER=25
|
||||
-DLED_POWER=-1
|
||||
-DLED_PIN=-1
|
||||
@@ -8,10 +8,10 @@
|
||||
#define I2C_SDA 21 // I2C pins for this board
|
||||
#define I2C_SCL 22
|
||||
|
||||
#if defined(LED_POWER) && LED_POWER == -1
|
||||
#undef LED_POWER
|
||||
#if defined(LED_PIN) && LED_PIN == -1
|
||||
#undef LED_PIN
|
||||
#else
|
||||
#define LED_POWER 25 // If defined we will blink this LED
|
||||
#define LED_PIN 25 // If defined we will blink this LED
|
||||
#endif
|
||||
|
||||
#define USE_RF95
|
||||
|
||||
@@ -7,5 +7,4 @@ build_flags =
|
||||
-D TLORA_V2_1_16
|
||||
-I variants/esp32/tlora_v2_1_16
|
||||
-D LORA_TCXO_GPIO=33
|
||||
-ULED_BUILTIN
|
||||
upload_speed = 115200
|
||||
upload_speed = 115200
|
||||
@@ -6,7 +6,7 @@
|
||||
#define I2C_SDA 21 // I2C pins for this board
|
||||
#define I2C_SCL 22
|
||||
|
||||
#define LED_POWER 25 // If defined we will blink this LED
|
||||
#define LED_PIN 25 // If defined we will blink this LED
|
||||
#define BUTTON_PIN 12 // If defined, this will be used for user button presses,
|
||||
|
||||
#define BUTTON_NEED_PULLUP
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#define GPS_RX_PIN 9
|
||||
#define GPS_TX_PIN 10
|
||||
|
||||
#define LED_POWER 13 // 13 red, 2 blue, 15 red
|
||||
#define LED_PIN 13 // 13 red, 2 blue, 15 red
|
||||
|
||||
#define BUTTON_PIN 0
|
||||
#define BUTTON_NEED_PULLUP
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#undef GPS_TX_PIN
|
||||
#define NO_GPS 1
|
||||
#define HAS_GPS 0
|
||||
#define NO_SCREEN
|
||||
#define HAS_SCREEN 0
|
||||
|
||||
// Default SPI1 will be mapped to the display
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#define I2C_SCL SCL
|
||||
|
||||
#define BUTTON_PIN 9 // BOOT button
|
||||
#define LED_POWER 30 // RGB LED
|
||||
#define LED_PIN 30 // RGB LED
|
||||
|
||||
#define USE_RF95
|
||||
#define LORA_SCK 4
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// Hackerboxes LoRa ESP32-C3 OLED Kit
|
||||
// Uses a ESP32-C3 OLED Board and a RA-01SH (SX1262) LoRa Board
|
||||
|
||||
#define LED_POWER 8 // LED
|
||||
#define LED_PIN 8 // LED
|
||||
#define LED_STATE_ON 1 // State when LED is lit
|
||||
|
||||
#define HAS_SCREEN 0
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// LED pin on HT-DEV-ESP_V2 and HT-DEV-ESP_V3
|
||||
// https://resource.heltec.cn/download/HT-CT62/HT-CT62_Reference_Design.pdf
|
||||
// https://resource.heltec.cn/download/HT-DEV-ESP/HT-DEV-ESP_V3_Sch.pdf
|
||||
#define LED_POWER 2 // LED
|
||||
#define LED_PIN 2 // LED
|
||||
#define LED_STATE_ON 1 // State when LED is lit
|
||||
|
||||
#define HAS_SCREEN 0
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#define I2C_SDA 8 // I2C pins for this board
|
||||
#define I2C_SCL 9
|
||||
|
||||
#define LED_POWER 7 // If defined we will blink this LED
|
||||
#define LED_PIN 7 // If defined we will blink this LED
|
||||
#define LED_STATE_ON 0 // State when LED is lit
|
||||
|
||||
#define USE_SX1262
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#define I2C_SDA 34 // I2C pins for this board
|
||||
#define I2C_SCL 36
|
||||
|
||||
#define LED_POWER 15 // If defined we will blink this LED
|
||||
#define LED_PIN 15 // If defined we will blink this LED
|
||||
|
||||
#define HAS_NEOPIXEL // Enable the use of neopixels
|
||||
#define NEOPIXEL_COUNT 3 // How many neopixels are connected
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// EByte EoRA-Hub
|
||||
// Uses E80 (LR1121) LoRa module
|
||||
|
||||
#define LED_POWER 35
|
||||
#define LED_PIN 35
|
||||
|
||||
// Button - user interface
|
||||
#define BUTTON_PIN 0 // BOOT button
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// LED - status indication
|
||||
#define LED_POWER 37
|
||||
#define LED_PIN 37
|
||||
|
||||
// Button - user interface
|
||||
#define BUTTON_PIN 0 // This is the BOOT button, and it has its own pull-up resistor
|
||||
|
||||
@@ -100,7 +100,7 @@
|
||||
*/
|
||||
|
||||
// Status
|
||||
#define LED_POWER 1
|
||||
#define LED_PIN 1
|
||||
#define LED_STATE_ON 1 // State when LED is lit
|
||||
// External notification
|
||||
// FIXME: Check if EXT_NOTIFY_OUT actualy has any effect and removes the need for setting the external notication pin in the
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Status
|
||||
#define LED_POWER 1
|
||||
#define LED_PIN 1
|
||||
|
||||
#define PIN_BUTTON1 47 // 功能键
|
||||
#define PIN_BUTTON2 4 // 电源键
|
||||
|
||||
@@ -8,13 +8,7 @@ void earlyInitVariant()
|
||||
Wire1.begin(48, 47);
|
||||
io.pinMode(PCA_PIN_EINK_EN, OUTPUT);
|
||||
io.pinMode(PCA_PIN_POWER_EN, OUTPUT);
|
||||
io.pinMode(PCA_LED_POWER, OUTPUT);
|
||||
io.pinMode(PCA_LED_USER, OUTPUT);
|
||||
io.pinMode(PCA_LED_ENABLE, OUTPUT);
|
||||
|
||||
io.digitalWrite(PCA_PIN_POWER_EN, HIGH);
|
||||
io.digitalWrite(PCA_LED_USER, LOW);
|
||||
io.digitalWrite(PCA_LED_ENABLE, LOW);
|
||||
}
|
||||
|
||||
void variant_shutdown()
|
||||
|
||||
@@ -8,10 +8,8 @@
|
||||
|
||||
// LED
|
||||
// Both of these are on the GPIO expander
|
||||
#define PCA_LED_USER 1 // the Blue LED
|
||||
#define PCA_LED_ENABLE 2 // the power supply to the LEDs, in an OR arrangement with VBUS power
|
||||
#define PCA_LED_POWER 3 // the Red LED? Seems to have hardware logic to blink when USB is plugged in.
|
||||
#define POWER_LED_HARDWARE_BLINKS_WHILE_CHARGING
|
||||
#define PCA_LED_USER 1 // the Blue LED
|
||||
#define PCA_LED_POWER 3 // the Red LED? Seems to have hardware logic to blink when USB is plugged in.
|
||||
|
||||
// USB_CHECK
|
||||
#define EXT_PWR_DETECT 12
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#define I2C_SDA 12
|
||||
#define I2C_SCL 14
|
||||
|
||||
#define LED_POWER 46
|
||||
#define LED_PIN 46
|
||||
#define LED_STATE_ON 0 // State when LED is litted
|
||||
|
||||
// #define BUTTON_PIN 15 // Pico OLED 1.3 User key 0 - removed User key 1 (17)
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
// #define GPS_RX_PIN 44
|
||||
// #define GPS_TX_PIN 43
|
||||
|
||||
#define LED_POWER 41
|
||||
#define LED_PIN 41
|
||||
#define BUTTON_PIN 2
|
||||
#define BUTTON_NEED_PULLUP
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ upload_speed = 921600
|
||||
lib_deps =
|
||||
${esp32s3_base.lib_deps}
|
||||
# renovate: datasource=custom.pio depName=GxEPD2 packageName=zinggjm/library/GxEPD2
|
||||
zinggjm/GxEPD2@1.6.7
|
||||
zinggjm/GxEPD2@1.6.6
|
||||
# renovate: datasource=custom.pio depName=NeoPixel packageName=adafruit/library/Adafruit NeoPixel
|
||||
adafruit/Adafruit NeoPixel@1.15.3
|
||||
build_unflags =
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#define I2C_SDA 18 // 1 // I2C pins for this board
|
||||
#define I2C_SCL 17 // 2
|
||||
|
||||
// #define LED_POWER 38 // This is a RGB LED not a standard LED
|
||||
// #define LED_PIN 38 // This is a RGB LED not a standard LED
|
||||
#define HAS_NEOPIXEL // Enable the use of neopixels
|
||||
#define NEOPIXEL_COUNT 1 // How many neopixels are connected
|
||||
#define NEOPIXEL_DATA 38 // gpio pin used to send data to the neopixels
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#define I2C_SDA 18 // 1 // I2C pins for this board
|
||||
#define I2C_SCL 17 // 2
|
||||
|
||||
// #define LED_POWER 38 // This is a RGB LED not a standard LED
|
||||
// #define LED_PIN 38 // This is a RGB LED not a standard LED
|
||||
#define HAS_NEOPIXEL // Enable the use of neopixels
|
||||
#define NEOPIXEL_COUNT 1 // How many neopixels are connected
|
||||
#define NEOPIXEL_DATA 38 // gpio pin used to send data to the neopixels
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#define I2C_SDA1 45
|
||||
#define I2C_SCL1 46
|
||||
|
||||
#define LED_POWER 6
|
||||
#define LED_PIN 6
|
||||
#define LED_STATE_ON 1
|
||||
#define BUTTON_PIN 0
|
||||
|
||||
|
||||
@@ -23,6 +23,6 @@ build_flags = ${esp32s3_base.build_flags}
|
||||
|
||||
lib_deps = ${esp32s3_base.lib_deps}
|
||||
# renovate: datasource=custom.pio depName=GxEPD2 packageName=zinggjm/library/GxEPD2
|
||||
zinggjm/GxEPD2@1.6.7
|
||||
zinggjm/GxEPD2@1.6.6
|
||||
# renovate: datasource=custom.pio depName=NeoPixel packageName=adafruit/library/Adafruit NeoPixel
|
||||
adafruit/Adafruit NeoPixel@1.15.3
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#define EXT_NOTIFY_OUT 22
|
||||
#define BUTTON_PIN 0 // 17
|
||||
|
||||
// #define LED_PIN PIN_LED
|
||||
// Board has RGB LED 21
|
||||
#define HAS_NEOPIXEL // Enable the use of neopixels
|
||||
#define NEOPIXEL_COUNT 1 // How many neopixels are connected
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#define LED_POWER 33
|
||||
#define LED_POWER2 34
|
||||
#define LED_PIN 33
|
||||
#define LED_PIN2 34
|
||||
#define EXT_PWR_DETECT 35
|
||||
|
||||
#define BUTTON_PIN 18
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#define LED_POWER LED
|
||||
#define LED_PIN LED
|
||||
|
||||
#define USE_SSD1306 // Heltec_v3 has a SSD1306 display
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ build_flags =
|
||||
${heltec_v4_base.build_flags}
|
||||
-D HELTEC_V4_OLED
|
||||
-D USE_SSD1306 ; Heltec_v4 has an SSD1315 display (compatible with SSD1306 driver)
|
||||
-D LED_POWER=35
|
||||
-D LED_PIN=35
|
||||
-D RESET_OLED=21
|
||||
-D I2C_SDA=17
|
||||
-D I2C_SCL=18
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#define LED_POWER 45 // LED is not populated on earliest board variant
|
||||
#define LED_PIN 45 // LED is not populated on earliest board variant
|
||||
#define BUTTON_PIN 0
|
||||
#define PIN_BUTTON2 21 // Second built-in button
|
||||
#define ALT_BUTTON_PIN PIN_BUTTON2 // Send the up event
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#define LED_POWER 45 // LED is not populated on earliest board variant
|
||||
#define LED_PIN 45 // LED is not populated on earliest board variant
|
||||
#define BUTTON_PIN 0
|
||||
#define PIN_BUTTON2 21 // Second built-in button
|
||||
#define ALT_BUTTON_PIN PIN_BUTTON2 // Send the up event
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user