mirror of
https://github.com/meshtastic/firmware.git
synced 2025-08-13 08:45:04 +00:00
Updates to external notification and radiolib for SX128x. Rip out Godmode again for these
This commit is contained in:
parent
430908f5d6
commit
e25d05689b
@ -66,7 +66,8 @@ lib_deps =
|
|||||||
https://github.com/meshtastic/ArduinoThread.git#72921ac222eed6f526ba1682023cee290d9aa1b3
|
https://github.com/meshtastic/ArduinoThread.git#72921ac222eed6f526ba1682023cee290d9aa1b3
|
||||||
nanopb/Nanopb@^0.4.6
|
nanopb/Nanopb@^0.4.6
|
||||||
erriez/ErriezCRC32@^1.0.1
|
erriez/ErriezCRC32@^1.0.1
|
||||||
jgromes/RadioLib@^5.5.0
|
; jgromes/RadioLib@^5.5.1
|
||||||
|
https://github.com/jgromes/RadioLib.git#395844922c5d88d5db0481a9c91479931172428d
|
||||||
|
|
||||||
; Used for the code analysis in PIO Home / Inspect
|
; Used for the code analysis in PIO Home / Inspect
|
||||||
check_tool = cppcheck
|
check_tool = cppcheck
|
||||||
@ -82,6 +83,7 @@ framework = arduino
|
|||||||
lib_deps =
|
lib_deps =
|
||||||
${env.lib_deps}
|
${env.lib_deps}
|
||||||
mprograms/QMC5883LCompass@^1.1.1
|
mprograms/QMC5883LCompass@^1.1.1
|
||||||
|
end2endzone/NonBlockingRTTTL@^1.3.0
|
||||||
https://github.com/meshtastic/SparkFun_ATECCX08a_Arduino_Library.git#52b5282639d08a8cbd4b748363089eed6102dc76
|
https://github.com/meshtastic/SparkFun_ATECCX08a_Arduino_Library.git#52b5282639d08a8cbd4b748363089eed6102dc76
|
||||||
|
|
||||||
build_flags = ${env.build_flags} -Os -DRADIOLIB_SPI_PARANOID=0
|
build_flags = ${env.build_flags} -Os -DRADIOLIB_SPI_PARANOID=0
|
||||||
|
@ -1073,9 +1073,11 @@ int32_t Screen::runOnce()
|
|||||||
case Cmd::ON_PRESS:
|
case Cmd::ON_PRESS:
|
||||||
// If a nag notification is running, stop it
|
// If a nag notification is running, stop it
|
||||||
if (externalNotificationModule->nagCycleCutoff != UINT32_MAX) {
|
if (externalNotificationModule->nagCycleCutoff != UINT32_MAX) {
|
||||||
externalNotificationModule->nagCycleCutoff = 0;
|
externalNotificationModule->stopNow();
|
||||||
}
|
} else {
|
||||||
|
// Don't advance the screen if we just wanted to switch off the nag notification
|
||||||
handleOnPress();
|
handleOnPress();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case Cmd::START_BLUETOOTH_PIN_SCREEN:
|
case Cmd::START_BLUETOOTH_PIN_SCREEN:
|
||||||
handleStartBluetoothPinScreen(cmd.bluetooth_pin);
|
handleStartBluetoothPinScreen(cmd.bluetooth_pin);
|
||||||
|
@ -66,10 +66,5 @@ class RadioLibRF95: public SX1278 {
|
|||||||
// since default current limit for SX126x/127x in updated RadioLib is 60mA
|
// since default current limit for SX126x/127x in updated RadioLib is 60mA
|
||||||
// use the previous value
|
// use the previous value
|
||||||
float currentLimit = 100;
|
float currentLimit = 100;
|
||||||
|
|
||||||
#ifndef RADIOLIB_GODMODE
|
|
||||||
private:
|
|
||||||
#endif
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -238,13 +238,9 @@ bool SX128xInterface<T>::isChannelActive()
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
bool SX128xInterface<T>::isActivelyReceiving()
|
bool SX128xInterface<T>::isActivelyReceiving()
|
||||||
{
|
{
|
||||||
#ifdef RADIOLIB_GODMODE
|
|
||||||
uint16_t irq = lora.getIrqStatus();
|
uint16_t irq = lora.getIrqStatus();
|
||||||
bool hasPreamble = (irq & RADIOLIB_SX128X_IRQ_HEADER_VALID);
|
bool hasPreamble = (irq & RADIOLIB_SX128X_IRQ_HEADER_VALID);
|
||||||
return hasPreamble;
|
return hasPreamble;
|
||||||
#else
|
|
||||||
return isChannelActive();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -27,9 +27,7 @@ class SX128xInterface : public RadioLibInterface
|
|||||||
/// Prepare hardware for sleep. Call this _only_ for deep sleep, not needed for light sleep.
|
/// Prepare hardware for sleep. Call this _only_ for deep sleep, not needed for light sleep.
|
||||||
virtual bool sleep() override;
|
virtual bool sleep() override;
|
||||||
|
|
||||||
#ifdef RADIOLIB_GODMODE
|
|
||||||
bool isIRQPending() override { return lora.getIrqStatus() != 0; }
|
bool isIRQPending() override { return lora.getIrqStatus() != 0; }
|
||||||
#endif
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -34,11 +34,10 @@ uint32_t externalTurnedOn[3] = {};
|
|||||||
|
|
||||||
int32_t ExternalNotificationModule::runOnce()
|
int32_t ExternalNotificationModule::runOnce()
|
||||||
{
|
{
|
||||||
if (moduleConfig.external_notification.use_pwm || !moduleConfig.external_notification.enabled) {
|
if (!moduleConfig.external_notification.enabled) {
|
||||||
return INT32_MAX; // we don't need this thread here...
|
return INT32_MAX; // we don't need this thread here...
|
||||||
} else {
|
} else {
|
||||||
|
if ((nagCycleCutoff < millis()) && !rtttl::isPlaying()) {
|
||||||
if (nagCycleCutoff < millis()) {
|
|
||||||
nagCycleCutoff = UINT32_MAX;
|
nagCycleCutoff = UINT32_MAX;
|
||||||
DEBUG_MSG("Turning off external notification: ");
|
DEBUG_MSG("Turning off external notification: ");
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
@ -70,6 +69,16 @@ int32_t ExternalNotificationModule::runOnce()
|
|||||||
getExternal(2) ? setExternalOff(2) : setExternalOn(2);
|
getExternal(2) ? setExternalOff(2) : setExternalOn(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// now let the PWM buzzer play
|
||||||
|
if (moduleConfig.external_notification.use_pwm) {
|
||||||
|
if (rtttl::isPlaying()) {
|
||||||
|
rtttl::play();
|
||||||
|
} else if (nagCycleCutoff >= millis()) {
|
||||||
|
// start the song again if we have time left
|
||||||
|
rtttl::begin(config.device.buzzer_gpio, pwmRingtone);
|
||||||
|
}
|
||||||
|
}
|
||||||
return 25;
|
return 25;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -119,7 +128,11 @@ bool ExternalNotificationModule::getExternal(uint8_t index)
|
|||||||
return externalCurrentState[index];
|
return externalCurrentState[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------
|
void ExternalNotificationModule::stopNow() {
|
||||||
|
rtttl::stop();
|
||||||
|
nagCycleCutoff = 1; // small value
|
||||||
|
setIntervalFromNow(0);
|
||||||
|
}
|
||||||
|
|
||||||
ExternalNotificationModule::ExternalNotificationModule()
|
ExternalNotificationModule::ExternalNotificationModule()
|
||||||
: SinglePortModule("ExternalNotificationModule", PortNum_TEXT_MESSAGE_APP), concurrency::OSThread(
|
: SinglePortModule("ExternalNotificationModule", PortNum_TEXT_MESSAGE_APP), concurrency::OSThread(
|
||||||
@ -151,7 +164,6 @@ ExternalNotificationModule::ExternalNotificationModule()
|
|||||||
? moduleConfig.external_notification.output
|
? moduleConfig.external_notification.output
|
||||||
: EXT_NOTIFICATION_MODULE_OUTPUT;
|
: EXT_NOTIFICATION_MODULE_OUTPUT;
|
||||||
|
|
||||||
if (!moduleConfig.external_notification.use_pwm) {
|
|
||||||
// Set the direction of a pin
|
// Set the direction of a pin
|
||||||
DEBUG_MSG("Using Pin %i in digital mode\n", output);
|
DEBUG_MSG("Using Pin %i in digital mode\n", output);
|
||||||
pinMode(output, OUTPUT);
|
pinMode(output, OUTPUT);
|
||||||
@ -164,19 +176,19 @@ ExternalNotificationModule::ExternalNotificationModule()
|
|||||||
externalTurnedOn[1] = 0;
|
externalTurnedOn[1] = 0;
|
||||||
}
|
}
|
||||||
if(moduleConfig.external_notification.output_buzzer) {
|
if(moduleConfig.external_notification.output_buzzer) {
|
||||||
|
if (!moduleConfig.external_notification.use_pwm) {
|
||||||
DEBUG_MSG("Using Pin %i for buzzer\n", moduleConfig.external_notification.output_buzzer);
|
DEBUG_MSG("Using Pin %i for buzzer\n", moduleConfig.external_notification.output_buzzer);
|
||||||
pinMode(moduleConfig.external_notification.output_buzzer, OUTPUT);
|
pinMode(moduleConfig.external_notification.output_buzzer, OUTPUT);
|
||||||
setExternalOff(2);
|
setExternalOff(2);
|
||||||
externalTurnedOn[2] = 0;
|
externalTurnedOn[2] = 0;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
config.device.buzzer_gpio = config.device.buzzer_gpio
|
config.device.buzzer_gpio = config.device.buzzer_gpio
|
||||||
? config.device.buzzer_gpio
|
? config.device.buzzer_gpio
|
||||||
: PIN_BUZZER;
|
: PIN_BUZZER;
|
||||||
|
|
||||||
// in PWM Mode we force the buzzer pin if it is set
|
// in PWM Mode we force the buzzer pin if it is set
|
||||||
DEBUG_MSG("Using Pin %i in PWM mode\n", config.device.buzzer_gpio);
|
DEBUG_MSG("Using Pin %i in PWM mode\n", config.device.buzzer_gpio);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
DEBUG_MSG("External Notification Module Disabled\n");
|
DEBUG_MSG("External Notification Module Disabled\n");
|
||||||
enabled = false;
|
enabled = false;
|
||||||
@ -201,21 +213,15 @@ ProcessMessage ExternalNotificationModule::handleReceived(const MeshPacket &mp)
|
|||||||
if (moduleConfig.external_notification.alert_bell) {
|
if (moduleConfig.external_notification.alert_bell) {
|
||||||
if (containsBell) {
|
if (containsBell) {
|
||||||
DEBUG_MSG("externalNotificationModule - Notification Bell\n");
|
DEBUG_MSG("externalNotificationModule - Notification Bell\n");
|
||||||
if (!moduleConfig.external_notification.use_pwm) {
|
|
||||||
setExternalOn(0);
|
setExternalOn(0);
|
||||||
if (moduleConfig.external_notification.nag_timeout) {
|
if (moduleConfig.external_notification.nag_timeout) {
|
||||||
nagCycleCutoff = millis() + moduleConfig.external_notification.nag_timeout * 1000;
|
nagCycleCutoff = millis() + moduleConfig.external_notification.nag_timeout * 1000;
|
||||||
} else {
|
} else {
|
||||||
nagCycleCutoff = millis() + moduleConfig.external_notification.output_ms;
|
nagCycleCutoff = millis() + moduleConfig.external_notification.output_ms;
|
||||||
}
|
}
|
||||||
// run_once now
|
|
||||||
} else {
|
|
||||||
playBeep();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!moduleConfig.external_notification.use_pwm) {
|
|
||||||
if (moduleConfig.external_notification.alert_bell_vibra) {
|
if (moduleConfig.external_notification.alert_bell_vibra) {
|
||||||
if (containsBell) {
|
if (containsBell) {
|
||||||
DEBUG_MSG("externalNotificationModule - Notification Bell (Vibra)\n");
|
DEBUG_MSG("externalNotificationModule - Notification Bell (Vibra)\n");
|
||||||
@ -231,7 +237,11 @@ ProcessMessage ExternalNotificationModule::handleReceived(const MeshPacket &mp)
|
|||||||
if (moduleConfig.external_notification.alert_bell_buzzer) {
|
if (moduleConfig.external_notification.alert_bell_buzzer) {
|
||||||
if (containsBell) {
|
if (containsBell) {
|
||||||
DEBUG_MSG("externalNotificationModule - Notification Bell (Buzzer)\n");
|
DEBUG_MSG("externalNotificationModule - Notification Bell (Buzzer)\n");
|
||||||
|
if (!moduleConfig.external_notification.use_pwm) {
|
||||||
setExternalOn(2);
|
setExternalOn(2);
|
||||||
|
} else {
|
||||||
|
rtttl::begin(config.device.buzzer_gpio, pwmRingtone);
|
||||||
|
}
|
||||||
if (moduleConfig.external_notification.nag_timeout) {
|
if (moduleConfig.external_notification.nag_timeout) {
|
||||||
nagCycleCutoff = millis() + moduleConfig.external_notification.nag_timeout * 1000;
|
nagCycleCutoff = millis() + moduleConfig.external_notification.nag_timeout * 1000;
|
||||||
} else {
|
} else {
|
||||||
@ -239,20 +249,15 @@ ProcessMessage ExternalNotificationModule::handleReceived(const MeshPacket &mp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (moduleConfig.external_notification.alert_message) {
|
if (moduleConfig.external_notification.alert_message) {
|
||||||
DEBUG_MSG("externalNotificationModule - Notification Module\n");
|
DEBUG_MSG("externalNotificationModule - Notification Module\n");
|
||||||
if (!moduleConfig.external_notification.use_pwm) {
|
|
||||||
setExternalOn(0);
|
setExternalOn(0);
|
||||||
if (moduleConfig.external_notification.nag_timeout) {
|
if (moduleConfig.external_notification.nag_timeout) {
|
||||||
nagCycleCutoff = millis() + moduleConfig.external_notification.nag_timeout * 1000;
|
nagCycleCutoff = millis() + moduleConfig.external_notification.nag_timeout * 1000;
|
||||||
} else {
|
} else {
|
||||||
nagCycleCutoff = millis() + moduleConfig.external_notification.output_ms;
|
nagCycleCutoff = millis() + moduleConfig.external_notification.output_ms;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
playBeep();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!moduleConfig.external_notification.use_pwm) {
|
if (!moduleConfig.external_notification.use_pwm) {
|
||||||
@ -268,7 +273,11 @@ ProcessMessage ExternalNotificationModule::handleReceived(const MeshPacket &mp)
|
|||||||
|
|
||||||
if (moduleConfig.external_notification.alert_message_buzzer) {
|
if (moduleConfig.external_notification.alert_message_buzzer) {
|
||||||
DEBUG_MSG("externalNotificationModule - Notification Module (Buzzer)\n");
|
DEBUG_MSG("externalNotificationModule - Notification Module (Buzzer)\n");
|
||||||
|
if (!moduleConfig.external_notification.use_pwm) {
|
||||||
setExternalOn(2);
|
setExternalOn(2);
|
||||||
|
} else {
|
||||||
|
rtttl::begin(config.device.buzzer_gpio, pwmRingtone);
|
||||||
|
}
|
||||||
if (moduleConfig.external_notification.nag_timeout) {
|
if (moduleConfig.external_notification.nag_timeout) {
|
||||||
nagCycleCutoff = millis() + moduleConfig.external_notification.nag_timeout * 1000;
|
nagCycleCutoff = millis() + moduleConfig.external_notification.nag_timeout * 1000;
|
||||||
} else {
|
} else {
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include "SinglePortModule.h"
|
#include "SinglePortModule.h"
|
||||||
#include "concurrency/OSThread.h"
|
#include "concurrency/OSThread.h"
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
|
#include <NonBlockingRtttl.h>
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
@ -23,6 +24,10 @@ class ExternalNotificationModule : public SinglePortModule, private concurrency:
|
|||||||
void setExternalOff(uint8_t index = 0);
|
void setExternalOff(uint8_t index = 0);
|
||||||
bool getExternal(uint8_t index = 0);
|
bool getExternal(uint8_t index = 0);
|
||||||
|
|
||||||
|
void stopNow();
|
||||||
|
|
||||||
|
char pwmRingtone[Constants_DATA_PAYLOAD_LEN] = "a:d=8,o=5,b=125:4d#6,a#,2d#6,16p,g#,4a#,4d#.,p,16g,16a#,d#6,a#,f6,2d#6,16p,c#.6,16c6,16a#,g#.,2a#";
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** Called to handle a particular incoming message
|
/** Called to handle a particular incoming message
|
||||||
@return ProcessMessage::STOP if you've guaranteed you've handled this message and no other handlers should be considered for it
|
@return ProcessMessage::STOP if you've guaranteed you've handled this message and no other handlers should be considered for it
|
||||||
|
@ -5,7 +5,5 @@ lib_deps =
|
|||||||
${esp32_base.lib_deps}
|
${esp32_base.lib_deps}
|
||||||
caveman99/ESP32 Codec2@^1.0.1
|
caveman99/ESP32 Codec2@^1.0.1
|
||||||
|
|
||||||
; the RADIOLIB_GODMODE flag can be removed once the next version of RadioLib is released. (>5.5.0)
|
|
||||||
|
|
||||||
build_flags =
|
build_flags =
|
||||||
${esp32_base.build_flags} -D TLORA_V2_1_18 -I variants/tlora_v2_1_18 -D RADIOLIB_GODMODE
|
${esp32_base.build_flags} -D TLORA_V2_1_18 -I variants/tlora_v2_1_18
|
Loading…
Reference in New Issue
Block a user