mirror of
https://github.com/MrUnknownDE/OpenIris-ESPIDF.git
synced 2026-04-19 06:23:44 +02:00
- Updated README to reflect changes in device mode terminology from "Auto" to "Setup".
- Changed configuration macros from CONFIG_GENERAL_DEFAULT_WIRED_MODE to CONFIG_GENERAL_INCLUDE_UVC_MODE across multiple files. - Introduced new command for retrieving LED current in CommandManager. - Added MonitoringManager and CurrentMonitor classes to handle LED current monitoring. - Updated Kconfig to include options for LED current monitoring. - Modified main application logic to integrate MonitoringManager and handle new device modes. - Adjusted CMakeLists and source files to include new monitoring components.
This commit is contained in:
@@ -15,7 +15,7 @@ menu "OpenIris: General Configuration"
|
||||
When enabled, the default device streaming mode will be UVC unless overridden by a
|
||||
saved preference. When disabled, the default mode is AUTO.
|
||||
|
||||
config GENERAL_DEFAULT_WIRED_MODE
|
||||
config GENERAL_INCLUDE_UVC_MODE
|
||||
bool "Wired mode"
|
||||
default false
|
||||
help
|
||||
@@ -114,4 +114,54 @@ menu "OpenIris: LED Configuration"
|
||||
Duty cycle of the PWM signal for external IR LEDs, in percent.
|
||||
0 means always off, 100 means always on.
|
||||
|
||||
endmenu
|
||||
|
||||
menu "OpenIris: Monitoring"
|
||||
|
||||
config MONITORING_LED_CURRENT
|
||||
bool "Enable LED current monitoring"
|
||||
default y
|
||||
help
|
||||
Enable sampling LED current via ADC and report it over commands.
|
||||
|
||||
config MONITORING_LED_ADC_GPIO
|
||||
int "ADC GPIO for LED current sense"
|
||||
depends on MONITORING_LED_CURRENT
|
||||
range 0 48
|
||||
default 3
|
||||
help
|
||||
GPIO connected to the current sense input (ADC1 on ESP32-S3: 1..10 supported).
|
||||
|
||||
config MONITORING_LED_GAIN
|
||||
int "Analog front-end gain/divider"
|
||||
depends on MONITORING_LED_CURRENT
|
||||
range 1 1024
|
||||
default 11
|
||||
help
|
||||
Divider or amplifier gain between shunt and ADC. The measured mV are divided by this value.
|
||||
|
||||
config MONITORING_LED_SHUNT_MILLIOHM
|
||||
int "Shunt resistance (milli-ohms)"
|
||||
depends on MONITORING_LED_CURRENT
|
||||
range 1 1000000
|
||||
default 22000
|
||||
help
|
||||
Shunt resistor value in milli-ohms. Current[mA] = 1000 * Vshunt[mV] / R[mΩ].
|
||||
|
||||
config MONITORING_LED_SAMPLES
|
||||
int "Filter window size (samples)"
|
||||
depends on MONITORING_LED_CURRENT
|
||||
range 1 200
|
||||
default 10
|
||||
help
|
||||
Moving-average window length for voltage filtering.
|
||||
|
||||
config MONITORING_LED_INTERVAL_MS
|
||||
int "Sampling interval (ms)"
|
||||
depends on MONITORING_LED_CURRENT
|
||||
range 10 60000
|
||||
default 500
|
||||
help
|
||||
Period between samples when background monitoring is active.
|
||||
|
||||
endmenu
|
||||
@@ -21,8 +21,9 @@
|
||||
#include <SerialManager.hpp>
|
||||
#include <RestAPI.hpp>
|
||||
#include <main_globals.hpp>
|
||||
#include <MonitoringManager.hpp>
|
||||
|
||||
#ifdef CONFIG_GENERAL_DEFAULT_WIRED_MODE
|
||||
#ifdef CONFIG_GENERAL_INCLUDE_UVC_MODE
|
||||
#include <UVCStream.hpp>
|
||||
#endif
|
||||
|
||||
@@ -52,12 +53,13 @@ StreamServer streamServer(80, stateManager);
|
||||
|
||||
auto *restAPI = new RestAPI("http://0.0.0.0:81", commandManager);
|
||||
|
||||
#ifdef CONFIG_GENERAL_DEFAULT_WIRED_MODE
|
||||
#ifdef CONFIG_GENERAL_INCLUDE_UVC_MODE
|
||||
UVCStreamManager uvcStream;
|
||||
#endif
|
||||
|
||||
auto ledManager = std::make_shared<LEDManager>(BLINK_GPIO, CONFIG_LED_C_PIN_GPIO, ledStateQueue, deviceConfig);
|
||||
auto *serialManager = new SerialManager(commandManager, &timerHandle, deviceConfig);
|
||||
MonitoringManager monitoringManager;
|
||||
|
||||
void startWiFiMode(bool shouldCloseSerialManager);
|
||||
void startWiredMode(bool shouldCloseSerialManager);
|
||||
@@ -81,14 +83,14 @@ int websocket_logger(const char *format, va_list args)
|
||||
|
||||
void launch_streaming()
|
||||
{
|
||||
// Note, when switching and later right away activating UVC mode when we were previously in WiFi or Auto mode, the WiFi
|
||||
// Note, when switching and later right away activating UVC mode when we were previously in WiFi or Setup mode, the WiFi
|
||||
// utilities will still be running since we've launched them with startAutoMode() -> startWiFiMode()
|
||||
// we could add detection of this case, but it's probably not worth it since the next start of the device literally won't launch them
|
||||
// and we're telling folks to just reboot the device anyway
|
||||
// same case goes for when switching from UVC to WiFi
|
||||
|
||||
StreamingMode deviceMode = deviceConfig->getDeviceMode();
|
||||
// if we've changed the mode from auto to something else, we can clean up serial manager
|
||||
// if we've changed the mode from setup to something else, we can clean up serial manager
|
||||
// either the API endpoints or CDC will take care of further configuration
|
||||
if (deviceMode == StreamingMode::WIFI)
|
||||
{
|
||||
@@ -98,10 +100,10 @@ void launch_streaming()
|
||||
{
|
||||
startWiredMode(true);
|
||||
}
|
||||
else if (deviceMode == StreamingMode::AUTO)
|
||||
else if (deviceMode == StreamingMode::SETUP)
|
||||
{
|
||||
// we're still in auto, the user didn't select anything yet, let's give a bit of time for them to make a choice
|
||||
ESP_LOGI("[MAIN]", "No mode was selected, staying in AUTO mode. WiFi streaming will be enabled still. \nPlease select another mode if you'd like.");
|
||||
// we're still in setup, the user didn't select anything yet, let's give a bit of time for them to make a choice
|
||||
ESP_LOGI("[MAIN]", "No mode was selected, staying in SETUP mode. WiFi streaming will be enabled still. \nPlease select another mode if you'd like.");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -150,7 +152,7 @@ void force_activate_streaming()
|
||||
|
||||
void startWiredMode(bool shouldCloseSerialManager)
|
||||
{
|
||||
#ifndef CONFIG_GENERAL_DEFAULT_WIRED_MODE
|
||||
#ifndef CONFIG_GENERAL_INCLUDE_UVC_MODE
|
||||
ESP_LOGE("[MAIN]", "UVC mode selected but the board likely does not support it.");
|
||||
ESP_LOGI("[MAIN]", "Falling back to WiFi mode if credentials available");
|
||||
deviceMode = StreamingMode::WIFI;
|
||||
@@ -220,7 +222,7 @@ void startWiFiMode(bool shouldCloseSerialManager)
|
||||
|
||||
void startSetupMode()
|
||||
{
|
||||
// If we're in an auto mode - Device starts with a 20-second delay before deciding on what to do
|
||||
// If we're in SETUP mode - Device starts with a 20-second delay before deciding on what to do
|
||||
// during this time we await any commands
|
||||
ESP_LOGI("[MAIN]", "=====================================");
|
||||
ESP_LOGI("[MAIN]", "STARTUP: 20-SECOND DELAY MODE ACTIVE");
|
||||
@@ -247,6 +249,7 @@ extern "C" void app_main(void)
|
||||
dependencyRegistry->registerService<CameraManager>(DependencyType::camera_manager, cameraHandler);
|
||||
dependencyRegistry->registerService<WiFiManager>(DependencyType::wifi_manager, wifiManager);
|
||||
dependencyRegistry->registerService<LEDManager>(DependencyType::led_manager, ledManager);
|
||||
dependencyRegistry->registerService<MonitoringManager>(DependencyType::monitoring_manager, std::shared_ptr<MonitoringManager>(&monitoringManager, [](MonitoringManager*){}));
|
||||
|
||||
// add endpoint to check firmware version
|
||||
// add firmware version somewhere
|
||||
@@ -259,6 +262,8 @@ extern "C" void app_main(void)
|
||||
initNVSStorage();
|
||||
deviceConfig->load();
|
||||
ledManager->setup();
|
||||
monitoringManager.setup();
|
||||
monitoringManager.start();
|
||||
|
||||
xTaskCreate(
|
||||
HandleStateManagerTask,
|
||||
|
||||
Reference in New Issue
Block a user