another silly error

This commit is contained in:
Gareth Coleman 2024-04-21 08:59:40 +01:00
parent fb7a878d94
commit cf65661c7c
2 changed files with 37 additions and 51 deletions

View File

@ -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();
}

View File

@ -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) {