mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-21 18:22:32 +00:00
Use channel as specified in the received packet
This commit is contained in:
@@ -69,7 +69,7 @@ bool ascending = true;
|
|||||||
#endif
|
#endif
|
||||||
#define EXT_NOTIFICATION_MODULE_OUTPUT_MS 1000
|
#define EXT_NOTIFICATION_MODULE_OUTPUT_MS 1000
|
||||||
|
|
||||||
#define EXT_NOTIFICATION_DEFAULT_THREAD_MS 25
|
#define EXT_NOTIFICATION_FAST_THREAD_MS 25
|
||||||
|
|
||||||
#define ASCII_BELL 0x07
|
#define ASCII_BELL 0x07
|
||||||
|
|
||||||
@@ -88,12 +88,13 @@ int32_t ExternalNotificationModule::runOnce()
|
|||||||
if (!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 {
|
||||||
|
uint32_t delay = EXT_NOTIFICATION_MODULE_OUTPUT_MS;
|
||||||
bool isPlaying = rtttl::isPlaying();
|
bool isRtttlPlaying = rtttl::isPlaying();
|
||||||
#ifdef HAS_I2S
|
#ifdef HAS_I2S
|
||||||
isPlaying = rtttl::isPlaying() || audioThread->isPlaying();
|
// audioThread->isPlaying() also handles actually playing the RTTTL, needs to be called in loop
|
||||||
|
isRtttlPlaying = isRtttlPlaying || audioThread->isPlaying();
|
||||||
#endif
|
#endif
|
||||||
if ((nagCycleCutoff < millis()) && !isPlaying) {
|
if ((nagCycleCutoff < millis()) && !isRtttlPlaying) {
|
||||||
// let the song finish if we reach timeout
|
// let the song finish if we reach timeout
|
||||||
nagCycleCutoff = UINT32_MAX;
|
nagCycleCutoff = UINT32_MAX;
|
||||||
LOG_INFO("Turning off external notification: ");
|
LOG_INFO("Turning off external notification: ");
|
||||||
@@ -116,21 +117,16 @@ int32_t ExternalNotificationModule::runOnce()
|
|||||||
|
|
||||||
// If the output is turned on, turn it back off after the given period of time.
|
// If the output is turned on, turn it back off after the given period of time.
|
||||||
if (isNagging) {
|
if (isNagging) {
|
||||||
if (externalTurnedOn[0] + (moduleConfig.external_notification.output_ms ? moduleConfig.external_notification.output_ms
|
delay = (moduleConfig.external_notification.output_ms ? moduleConfig.external_notification.output_ms
|
||||||
: EXT_NOTIFICATION_MODULE_OUTPUT_MS) <
|
: EXT_NOTIFICATION_MODULE_OUTPUT_MS);
|
||||||
millis()) {
|
if (externalTurnedOn[0] + delay < millis()) {
|
||||||
setExternalState(0, !getExternal(0));
|
setExternalState(0, !getExternal(0));
|
||||||
}
|
}
|
||||||
if (externalTurnedOn[1] + (moduleConfig.external_notification.output_ms ? moduleConfig.external_notification.output_ms
|
if (externalTurnedOn[1] + delay < millis()) {
|
||||||
: EXT_NOTIFICATION_MODULE_OUTPUT_MS) <
|
|
||||||
millis()) {
|
|
||||||
setExternalState(1, !getExternal(1));
|
setExternalState(1, !getExternal(1));
|
||||||
}
|
}
|
||||||
// Only toggle buzzer output if not using PWM mode (to avoid conflict with RTTTL)
|
// Only toggle buzzer output if not using PWM mode (to avoid conflict with RTTTL)
|
||||||
if (!moduleConfig.external_notification.use_pwm &&
|
if (!moduleConfig.external_notification.use_pwm && externalTurnedOn[2] + delay < millis()) {
|
||||||
externalTurnedOn[2] + (moduleConfig.external_notification.output_ms ? moduleConfig.external_notification.output_ms
|
|
||||||
: EXT_NOTIFICATION_MODULE_OUTPUT_MS) <
|
|
||||||
millis()) {
|
|
||||||
LOG_DEBUG("EXTERNAL 2 %d compared to %d", externalTurnedOn[2] + moduleConfig.external_notification.output_ms,
|
LOG_DEBUG("EXTERNAL 2 %d compared to %d", externalTurnedOn[2] + moduleConfig.external_notification.output_ms,
|
||||||
millis());
|
millis());
|
||||||
setExternalState(2, !getExternal(2));
|
setExternalState(2, !getExternal(2));
|
||||||
@@ -181,6 +177,8 @@ int32_t ExternalNotificationModule::runOnce()
|
|||||||
colorState = 1;
|
colorState = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// we need fast updates for the color change
|
||||||
|
delay = EXT_NOTIFICATION_FAST_THREAD_MS;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef T_WATCH_S3
|
#ifdef T_WATCH_S3
|
||||||
@@ -190,12 +188,14 @@ int32_t ExternalNotificationModule::runOnce()
|
|||||||
|
|
||||||
// Play RTTTL over i2s audio interface if enabled as buzzer
|
// Play RTTTL over i2s audio interface if enabled as buzzer
|
||||||
#ifdef HAS_I2S
|
#ifdef HAS_I2S
|
||||||
if (moduleConfig.external_notification.use_i2s_as_buzzer && canBuzz()) {
|
if (moduleConfig.external_notification.use_i2s_as_buzzer) {
|
||||||
if (audioThread->isPlaying()) {
|
if (audioThread->isPlaying()) {
|
||||||
// Continue playing
|
// Continue playing
|
||||||
} else if (isNagging && (nagCycleCutoff >= millis())) {
|
} else if (isNagging && (nagCycleCutoff >= millis())) {
|
||||||
audioThread->beginRttl(rtttlConfig.ringtone, strlen_P(rtttlConfig.ringtone));
|
audioThread->beginRttl(rtttlConfig.ringtone, strlen_P(rtttlConfig.ringtone));
|
||||||
}
|
}
|
||||||
|
// we need fast updates to play the RTTTL
|
||||||
|
delay = EXT_NOTIFICATION_FAST_THREAD_MS;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
// now let the PWM buzzer play
|
// now let the PWM buzzer play
|
||||||
@@ -206,9 +206,11 @@ int32_t ExternalNotificationModule::runOnce()
|
|||||||
// start the song again if we have time left
|
// start the song again if we have time left
|
||||||
rtttl::begin(config.device.buzzer_gpio, rtttlConfig.ringtone);
|
rtttl::begin(config.device.buzzer_gpio, rtttlConfig.ringtone);
|
||||||
}
|
}
|
||||||
|
// we need fast updates to play the RTTTL
|
||||||
|
delay = EXT_NOTIFICATION_FAST_THREAD_MS;
|
||||||
}
|
}
|
||||||
|
|
||||||
return EXT_NOTIFICATION_DEFAULT_THREAD_MS;
|
return delay;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -457,9 +459,7 @@ ProcessMessage ExternalNotificationModule::handleReceived(const meshtastic_MeshP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
meshtastic_NodeInfoLite *sender = nodeDB->getMeshNode(mp.from);
|
meshtastic_Channel ch = channels.getByIndex(mp.channel ? mp.channel : channels.getPrimaryIndex());
|
||||||
meshtastic_Channel ch = channels.getByIndex(sender->channel ? sender->channel : channels.getPrimaryIndex());
|
|
||||||
|
|
||||||
if (moduleConfig.external_notification.alert_bell) {
|
if (moduleConfig.external_notification.alert_bell) {
|
||||||
if (containsBell) {
|
if (containsBell) {
|
||||||
LOG_INFO("externalNotificationModule - Notification Bell");
|
LOG_INFO("externalNotificationModule - Notification Bell");
|
||||||
|
|||||||
Reference in New Issue
Block a user