kopia lustrzana https://github.com/meshtastic/firmware
Updates to external notification and radiolib for SX128x. Rip out Godmode again for these
rodzic
430908f5d6
commit
e25d05689b
|
@ -66,7 +66,8 @@ lib_deps =
|
|||
https://github.com/meshtastic/ArduinoThread.git#72921ac222eed6f526ba1682023cee290d9aa1b3
|
||||
nanopb/Nanopb@^0.4.6
|
||||
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
|
||||
check_tool = cppcheck
|
||||
|
@ -82,6 +83,7 @@ framework = arduino
|
|||
lib_deps =
|
||||
${env.lib_deps}
|
||||
mprograms/QMC5883LCompass@^1.1.1
|
||||
end2endzone/NonBlockingRTTTL@^1.3.0
|
||||
https://github.com/meshtastic/SparkFun_ATECCX08a_Arduino_Library.git#52b5282639d08a8cbd4b748363089eed6102dc76
|
||||
|
||||
build_flags = ${env.build_flags} -Os -DRADIOLIB_SPI_PARANOID=0
|
||||
|
|
|
@ -1073,9 +1073,11 @@ int32_t Screen::runOnce()
|
|||
case Cmd::ON_PRESS:
|
||||
// If a nag notification is running, stop it
|
||||
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;
|
||||
case Cmd::START_BLUETOOTH_PIN_SCREEN:
|
||||
handleStartBluetoothPinScreen(cmd.bluetooth_pin);
|
||||
|
|
|
@ -66,10 +66,5 @@ class RadioLibRF95: public SX1278 {
|
|||
// since default current limit for SX126x/127x in updated RadioLib is 60mA
|
||||
// use the previous value
|
||||
float currentLimit = 100;
|
||||
|
||||
#ifndef RADIOLIB_GODMODE
|
||||
private:
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -238,13 +238,9 @@ bool SX128xInterface<T>::isChannelActive()
|
|||
template<typename T>
|
||||
bool SX128xInterface<T>::isActivelyReceiving()
|
||||
{
|
||||
#ifdef RADIOLIB_GODMODE
|
||||
uint16_t irq = lora.getIrqStatus();
|
||||
bool hasPreamble = (irq & RADIOLIB_SX128X_IRQ_HEADER_VALID);
|
||||
return hasPreamble;
|
||||
#else
|
||||
return isChannelActive();
|
||||
#endif
|
||||
}
|
||||
|
||||
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.
|
||||
virtual bool sleep() override;
|
||||
|
||||
#ifdef RADIOLIB_GODMODE
|
||||
bool isIRQPending() override { return lora.getIrqStatus() != 0; }
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -34,11 +34,10 @@ uint32_t externalTurnedOn[3] = {};
|
|||
|
||||
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...
|
||||
} else {
|
||||
|
||||
if (nagCycleCutoff < millis()) {
|
||||
if ((nagCycleCutoff < millis()) && !rtttl::isPlaying()) {
|
||||
nagCycleCutoff = UINT32_MAX;
|
||||
DEBUG_MSG("Turning off external notification: ");
|
||||
for (int i = 0; i < 2; i++) {
|
||||
|
@ -70,6 +69,16 @@ int32_t ExternalNotificationModule::runOnce()
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
@ -119,7 +128,11 @@ bool ExternalNotificationModule::getExternal(uint8_t index)
|
|||
return externalCurrentState[index];
|
||||
}
|
||||
|
||||
// --------
|
||||
void ExternalNotificationModule::stopNow() {
|
||||
rtttl::stop();
|
||||
nagCycleCutoff = 1; // small value
|
||||
setIntervalFromNow(0);
|
||||
}
|
||||
|
||||
ExternalNotificationModule::ExternalNotificationModule()
|
||||
: SinglePortModule("ExternalNotificationModule", PortNum_TEXT_MESSAGE_APP), concurrency::OSThread(
|
||||
|
@ -151,31 +164,30 @@ ExternalNotificationModule::ExternalNotificationModule()
|
|||
? moduleConfig.external_notification.output
|
||||
: EXT_NOTIFICATION_MODULE_OUTPUT;
|
||||
|
||||
if (!moduleConfig.external_notification.use_pwm) {
|
||||
// Set the direction of a pin
|
||||
DEBUG_MSG("Using Pin %i in digital mode\n", output);
|
||||
pinMode(output, OUTPUT);
|
||||
setExternalOff(0);
|
||||
externalTurnedOn[0] = 0;
|
||||
if(moduleConfig.external_notification.output_vibra) {
|
||||
DEBUG_MSG("Using Pin %i for vibra motor\n", moduleConfig.external_notification.output_vibra);
|
||||
pinMode(moduleConfig.external_notification.output_vibra, OUTPUT);
|
||||
setExternalOff(1);
|
||||
externalTurnedOn[1] = 0;
|
||||
}
|
||||
if(moduleConfig.external_notification.output_buzzer) {
|
||||
// Set the direction of a pin
|
||||
DEBUG_MSG("Using Pin %i in digital mode\n", output);
|
||||
pinMode(output, OUTPUT);
|
||||
setExternalOff(0);
|
||||
externalTurnedOn[0] = 0;
|
||||
if(moduleConfig.external_notification.output_vibra) {
|
||||
DEBUG_MSG("Using Pin %i for vibra motor\n", moduleConfig.external_notification.output_vibra);
|
||||
pinMode(moduleConfig.external_notification.output_vibra, OUTPUT);
|
||||
setExternalOff(1);
|
||||
externalTurnedOn[1] = 0;
|
||||
}
|
||||
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);
|
||||
pinMode(moduleConfig.external_notification.output_buzzer, OUTPUT);
|
||||
setExternalOff(2);
|
||||
externalTurnedOn[2] = 0;
|
||||
} else {
|
||||
config.device.buzzer_gpio = config.device.buzzer_gpio
|
||||
? config.device.buzzer_gpio
|
||||
: PIN_BUZZER;
|
||||
// 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);
|
||||
}
|
||||
} else {
|
||||
config.device.buzzer_gpio = config.device.buzzer_gpio
|
||||
? config.device.buzzer_gpio
|
||||
: PIN_BUZZER;
|
||||
|
||||
// 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);
|
||||
}
|
||||
} else {
|
||||
DEBUG_MSG("External Notification Module Disabled\n");
|
||||
|
@ -201,57 +213,50 @@ ProcessMessage ExternalNotificationModule::handleReceived(const MeshPacket &mp)
|
|||
if (moduleConfig.external_notification.alert_bell) {
|
||||
if (containsBell) {
|
||||
DEBUG_MSG("externalNotificationModule - Notification Bell\n");
|
||||
if (!moduleConfig.external_notification.use_pwm) {
|
||||
setExternalOn(0);
|
||||
if (moduleConfig.external_notification.nag_timeout) {
|
||||
nagCycleCutoff = millis() + moduleConfig.external_notification.nag_timeout * 1000;
|
||||
} else {
|
||||
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 (containsBell) {
|
||||
DEBUG_MSG("externalNotificationModule - Notification Bell (Vibra)\n");
|
||||
setExternalOn(1);
|
||||
if (moduleConfig.external_notification.nag_timeout) {
|
||||
nagCycleCutoff = millis() + moduleConfig.external_notification.nag_timeout * 1000;
|
||||
} else {
|
||||
nagCycleCutoff = millis() + moduleConfig.external_notification.output_ms;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (moduleConfig.external_notification.alert_bell_buzzer) {
|
||||
if (containsBell) {
|
||||
DEBUG_MSG("externalNotificationModule - Notification Bell (Buzzer)\n");
|
||||
setExternalOn(2);
|
||||
if (moduleConfig.external_notification.nag_timeout) {
|
||||
nagCycleCutoff = millis() + moduleConfig.external_notification.nag_timeout * 1000;
|
||||
} else {
|
||||
nagCycleCutoff = millis() + moduleConfig.external_notification.output_ms;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (moduleConfig.external_notification.alert_message) {
|
||||
DEBUG_MSG("externalNotificationModule - Notification Module\n");
|
||||
if (!moduleConfig.external_notification.use_pwm) {
|
||||
setExternalOn(0);
|
||||
if (moduleConfig.external_notification.nag_timeout) {
|
||||
nagCycleCutoff = millis() + moduleConfig.external_notification.nag_timeout * 1000;
|
||||
} else {
|
||||
nagCycleCutoff = millis() + moduleConfig.external_notification.output_ms;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (moduleConfig.external_notification.alert_bell_vibra) {
|
||||
if (containsBell) {
|
||||
DEBUG_MSG("externalNotificationModule - Notification Bell (Vibra)\n");
|
||||
setExternalOn(1);
|
||||
if (moduleConfig.external_notification.nag_timeout) {
|
||||
nagCycleCutoff = millis() + moduleConfig.external_notification.nag_timeout * 1000;
|
||||
} else {
|
||||
nagCycleCutoff = millis() + moduleConfig.external_notification.output_ms;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (moduleConfig.external_notification.alert_bell_buzzer) {
|
||||
if (containsBell) {
|
||||
DEBUG_MSG("externalNotificationModule - Notification Bell (Buzzer)\n");
|
||||
if (!moduleConfig.external_notification.use_pwm) {
|
||||
setExternalOn(2);
|
||||
} else {
|
||||
rtttl::begin(config.device.buzzer_gpio, pwmRingtone);
|
||||
}
|
||||
if (moduleConfig.external_notification.nag_timeout) {
|
||||
nagCycleCutoff = millis() + moduleConfig.external_notification.nag_timeout * 1000;
|
||||
} else {
|
||||
nagCycleCutoff = millis() + moduleConfig.external_notification.output_ms;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (moduleConfig.external_notification.alert_message) {
|
||||
DEBUG_MSG("externalNotificationModule - Notification Module\n");
|
||||
setExternalOn(0);
|
||||
if (moduleConfig.external_notification.nag_timeout) {
|
||||
nagCycleCutoff = millis() + moduleConfig.external_notification.nag_timeout * 1000;
|
||||
} else {
|
||||
playBeep();
|
||||
nagCycleCutoff = millis() + moduleConfig.external_notification.output_ms;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -268,7 +273,11 @@ ProcessMessage ExternalNotificationModule::handleReceived(const MeshPacket &mp)
|
|||
|
||||
if (moduleConfig.external_notification.alert_message_buzzer) {
|
||||
DEBUG_MSG("externalNotificationModule - Notification Module (Buzzer)\n");
|
||||
setExternalOn(2);
|
||||
if (!moduleConfig.external_notification.use_pwm) {
|
||||
setExternalOn(2);
|
||||
} else {
|
||||
rtttl::begin(config.device.buzzer_gpio, pwmRingtone);
|
||||
}
|
||||
if (moduleConfig.external_notification.nag_timeout) {
|
||||
nagCycleCutoff = millis() + moduleConfig.external_notification.nag_timeout * 1000;
|
||||
} else {
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "SinglePortModule.h"
|
||||
#include "concurrency/OSThread.h"
|
||||
#include "configuration.h"
|
||||
#include <NonBlockingRtttl.h>
|
||||
#include <Arduino.h>
|
||||
#include <functional>
|
||||
|
||||
|
@ -23,6 +24,10 @@ class ExternalNotificationModule : public SinglePortModule, private concurrency:
|
|||
void setExternalOff(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:
|
||||
/** 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
|
||||
|
|
|
@ -5,7 +5,5 @@ lib_deps =
|
|||
${esp32_base.lib_deps}
|
||||
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 =
|
||||
${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
|
Ładowanie…
Reference in New Issue