From cf65661c7ca9bce3e470d7f744df219c6af0d525 Mon Sep 17 00:00:00 2001 From: Gareth Coleman Date: Sun, 21 Apr 2024 08:59:40 +0100 Subject: [PATCH] another silly error --- src/AmbientLightingThread.h | 40 ++++++------------ src/modules/ExternalNotificationModule.cpp | 48 +++++++++++----------- 2 files changed, 37 insertions(+), 51 deletions(-) diff --git a/src/AmbientLightingThread.h b/src/AmbientLightingThread.h index 81c9c85c7..2febc3d8c 100644 --- a/src/AmbientLightingThread.h +++ b/src/AmbientLightingThread.h @@ -32,56 +32,42 @@ class AmbientLightingThread : public concurrency::OSThread disable(); return; } +#endif +#if defined(HAS_NCP5623) || defined(UNPHONE) || defined(RGBLED_RED) if (!moduleConfig.ambient_lighting.led_state) { LOG_DEBUG("AmbientLightingThread disabling due to moduleConfig.ambient_lighting.led_state OFF\n"); disable(); return; } LOG_DEBUG("AmbientLightingThread initializing\n"); +#ifdef HAS_NCP5623 if (_type == ScanI2C::NCP5623) { rgb.begin(); - setLighting(); - } -#endif -#ifdef UNPHONE - if (!moduleConfig.ambient_lighting.led_state) { - LOG_DEBUG("AmbientLightingThread disabling due to moduleConfig.ambient_lighting.led_state OFF\n"); - disable(); - return; - } - LOG_DEBUG("AmbientLightingThread initializing\n"); - setLighting(); #endif #ifdef RGBLED_RED - if (!moduleConfig.ambient_lighting.led_state) { - LOG_DEBUG("AmbientLightingThread disabling due to moduleConfig.ambient_lighting.led_state OFF\n"); - disable(); - return; + pinMode(RGBLED_RED, OUTPUT); + pinMode(RGBLED_GREEN, OUTPUT); + pinMode(RGBLED_BLUE, OUTPUT); +#endif + setLighting(); +#endif +#ifdef HAS_NCP5623 } - LOG_DEBUG("AmbientLightingThread initializing\n"); - pinMode(RGBLED_RED, OUTPUT); - pinMode(RGBLED_GREEN, OUTPUT); - pinMode(RGBLED_BLUE, OUTPUT); - setLighting(); #endif } protected: int32_t runOnce() override { +#if defined(HAS_NCP5623) || defined(UNPHONE) || defined(RGBLED_RED) #ifdef HAS_NCP5623 if (_type == ScanI2C::NCP5623 && moduleConfig.ambient_lighting.led_state) { +#endif setLighting(); return 30000; // 30 seconds to reset from any animations that may have been running from Ext. Notification +#ifdef HAS_NCP5623 } #endif -#ifdef UNPHONE - setLighting(); - return 30000; // 30 seconds to reset from any animations that may have been running from Ext. Notification -#endif -#ifdef RGBLED_RED - setLighting(); - return 30000; // 30 seconds to reset from any animations that may have been running from Ext. Notification #endif return disable(); } diff --git a/src/modules/ExternalNotificationModule.cpp b/src/modules/ExternalNotificationModule.cpp index bc48e419b..236178498 100644 --- a/src/modules/ExternalNotificationModule.cpp +++ b/src/modules/ExternalNotificationModule.cpp @@ -151,35 +151,35 @@ int32_t ExternalNotificationModule::runOnce() colorState = 1; } } - } #endif #ifdef T_WATCH_S3 - drv.go(); + drv.go(); #endif - } + } - // Play RTTTL over i2s audio interface if enabled as buzzer + // Play RTTTL over i2s audio interface if enabled as buzzer #ifdef HAS_I2S - if (moduleConfig.external_notification.use_i2s_as_buzzer) { - if (audioThread->isPlaying()) { - // Continue playing - } else if (isNagging && (nagCycleCutoff >= millis())) { - audioThread->beginRttl(rtttlConfig.ringtone, strlen_P(rtttlConfig.ringtone)); + if (moduleConfig.external_notification.use_i2s_as_buzzer) { + if (audioThread->isPlaying()) { + // Continue playing + } else if (isNagging && (nagCycleCutoff >= millis())) { + audioThread->beginRttl(rtttlConfig.ringtone, strlen_P(rtttlConfig.ringtone)); + } } - } #endif - // now let the PWM buzzer play - if (moduleConfig.external_notification.use_pwm) { - if (rtttl::isPlaying()) { - rtttl::play(); - } else if (isNagging && (nagCycleCutoff >= millis())) { - // start the song again if we have time left - rtttl::begin(config.device.buzzer_gpio, rtttlConfig.ringtone); + // now let the PWM buzzer play + if (moduleConfig.external_notification.use_pwm) { + if (rtttl::isPlaying()) { + rtttl::play(); + } else if (isNagging && (nagCycleCutoff >= millis())) { + // start the song again if we have time left + rtttl::begin(config.device.buzzer_gpio, rtttlConfig.ringtone); + } } - } - return EXT_NOTIFICATION_DEFAULT_THREAD_MS; + return EXT_NOTIFICATION_DEFAULT_THREAD_MS; + } } bool ExternalNotificationModule::wantPacket(const meshtastic_MeshPacket *p) @@ -228,9 +228,9 @@ void ExternalNotificationModule::setExternalOn(uint8_t index) analogWrite(RGBLED_GREEN, 255 - green); analogWrite(RGBLED_BLUE, 255 - blue); #elif defined(RGBLED_RED) - analogWrite(RGBLED_RED, red); - analogWrite(RGBLED_GREEN, green); - analogWrite(RGBLED_BLUE, blue); + analogWrite(RGBLED_RED, red); + analogWrite(RGBLED_GREEN, green); + analogWrite(RGBLED_BLUE, blue); #endif #ifdef T_WATCH_S3 drv.go(); @@ -458,7 +458,7 @@ ProcessMessage ExternalNotificationModule::handleReceived(const meshtastic_MeshP #ifdef HAS_I2S audioThread->beginRttl(rtttlConfig.ringtone, strlen_P(rtttlConfig.ringtone)); #else - rtttl::begin(config.device.buzzer_gpio, rtttlConfig.ringtone); + rtttl::begin(config.device.buzzer_gpio, rtttlConfig.ringtone); #endif } if (moduleConfig.external_notification.nag_timeout) { @@ -502,7 +502,7 @@ ProcessMessage ExternalNotificationModule::handleReceived(const meshtastic_MeshP audioThread->beginRttl(rtttlConfig.ringtone, strlen_P(rtttlConfig.ringtone)); } #else - rtttl::begin(config.device.buzzer_gpio, rtttlConfig.ringtone); + rtttl::begin(config.device.buzzer_gpio, rtttlConfig.ringtone); #endif } if (moduleConfig.external_notification.nag_timeout) {