mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-31 15:10:40 +00:00
Merge branch 'master' into BSEC2
This commit is contained in:
@@ -8,6 +8,17 @@
|
||||
#include "mesh/generated/meshtastic/rtttl.pb.h"
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "main.h"
|
||||
|
||||
#ifdef RAK4630
|
||||
#include <NCP5623.h>
|
||||
NCP5623 rgb;
|
||||
|
||||
uint8_t red = 0;
|
||||
uint8_t green = 0;
|
||||
uint8_t blue = 0;
|
||||
#endif
|
||||
|
||||
#ifndef PIN_BUZZER
|
||||
#define PIN_BUZZER false
|
||||
#endif
|
||||
@@ -73,6 +84,15 @@ int32_t ExternalNotificationModule::runOnce()
|
||||
millis()) {
|
||||
getExternal(2) ? setExternalOff(2) : setExternalOn(2);
|
||||
}
|
||||
#ifdef RAK4630
|
||||
if (rgb_found.type == ScanI2C::NCP5623) {
|
||||
green = (green + 50) % 255;
|
||||
red = abs(red - green) % 255;
|
||||
blue = abs(blue / red) % 255;
|
||||
|
||||
rgb.setColor(red, green, blue);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// now let the PWM buzzer play
|
||||
@@ -84,6 +104,7 @@ int32_t ExternalNotificationModule::runOnce()
|
||||
rtttl::begin(config.device.buzzer_gpio, rtttlConfig.ringtone);
|
||||
}
|
||||
}
|
||||
|
||||
return 25;
|
||||
}
|
||||
}
|
||||
@@ -106,6 +127,11 @@ void ExternalNotificationModule::setExternalOn(uint8_t index)
|
||||
digitalWrite(output, (moduleConfig.external_notification.active ? true : false));
|
||||
break;
|
||||
}
|
||||
#ifdef RAK4630
|
||||
if (rgb_found.type == ScanI2C::NCP5623) {
|
||||
rgb.setColor(red, green, blue);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ExternalNotificationModule::setExternalOff(uint8_t index)
|
||||
@@ -126,6 +152,15 @@ void ExternalNotificationModule::setExternalOff(uint8_t index)
|
||||
digitalWrite(output, (moduleConfig.external_notification.active ? false : true));
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef RAK4630
|
||||
if (rgb_found.type == ScanI2C::NCP5623) {
|
||||
red = 0;
|
||||
green = 0;
|
||||
blue = 0;
|
||||
rgb.setColor(red, green, blue);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool ExternalNotificationModule::getExternal(uint8_t index)
|
||||
@@ -200,6 +235,12 @@ ExternalNotificationModule::ExternalNotificationModule()
|
||||
LOG_INFO("Using Pin %i in PWM mode\n", config.device.buzzer_gpio);
|
||||
}
|
||||
}
|
||||
#ifdef RAK4630
|
||||
if (rgb_found.type == ScanI2C::NCP5623) {
|
||||
rgb.begin();
|
||||
rgb.setCurrent(10);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
LOG_INFO("External Notification Module Disabled\n");
|
||||
disable();
|
||||
@@ -300,7 +341,6 @@ ProcessMessage ExternalNotificationModule::handleReceived(const meshtastic_MeshP
|
||||
nagCycleCutoff = millis() + moduleConfig.external_notification.output_ms;
|
||||
}
|
||||
}
|
||||
|
||||
setIntervalFromNow(0); // run once so we know if we should do something
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user