mirror of
https://github.com/MrUnknownDE/OpenIris-ESPIDF.git
synced 2026-04-26 01:23:45 +02:00
Refactor configuration settings: rename UVC delay to startup delay, add enable wireless option, and update LED GPIO configuration
This commit is contained in:
@@ -23,13 +23,21 @@ menu "OpenIris: General Configuration"
|
|||||||
default device streaming mode will be UVC unless overridden by a
|
default device streaming mode will be UVC unless overridden by a
|
||||||
saved preference. When disabled, the default mode is AUTO.
|
saved preference. When disabled, the default mode is AUTO.
|
||||||
|
|
||||||
config GENERAL_UVC_DELAY
|
config GENERAL_STARTUP_DELAY
|
||||||
int "UVC delay (s)"
|
int "UVC delay (s)"
|
||||||
default 30
|
default 30
|
||||||
range 10 10000
|
range 10 10000
|
||||||
help
|
help
|
||||||
Delay in seconds before the ESP reports itself as a UVC device.
|
Delay in seconds before the ESP reports itself as a UVC device.
|
||||||
|
|
||||||
|
config GENERAL_ENABLE_WIRELESS
|
||||||
|
bool "Enable wireless (WiFi/Bluetooth)"
|
||||||
|
default y
|
||||||
|
help
|
||||||
|
When disabled, the firmware will not start WiFi or related services (mDNS/REST),
|
||||||
|
and any Bluetooth memory (if present on the SoC) should be left released. This can
|
||||||
|
reduce power consumption when operating solely in UVC mode or without networking.
|
||||||
|
|
||||||
endmenu
|
endmenu
|
||||||
|
|
||||||
menu "OpenIris: Camera Configuration"
|
menu "OpenIris: Camera Configuration"
|
||||||
@@ -76,12 +84,12 @@ endmenu
|
|||||||
|
|
||||||
menu "OpenIris: LED Configuration"
|
menu "OpenIris: LED Configuration"
|
||||||
|
|
||||||
config LED_BLINK_GPIO
|
config LED_DEBUG_GPIO
|
||||||
int "Blink GPIO number"
|
int "Debug LED GPIO number"
|
||||||
range ENV_GPIO_RANGE_MIN ENV_GPIO_OUT_RANGE_MAX
|
range ENV_GPIO_RANGE_MIN ENV_GPIO_OUT_RANGE_MAX
|
||||||
default 8
|
default 8
|
||||||
help
|
help
|
||||||
GPIO number (IOxx) used to blink an onboard LED.
|
GPIO number (IOxx) used to drive an onboard debug/status LED.
|
||||||
Some GPIOs are reserved for other functions (e.g. flash) and cannot be used.
|
Some GPIOs are reserved for other functions (e.g. flash) and cannot be used.
|
||||||
|
|
||||||
config LED_EXTERNAL_GPIO
|
config LED_EXTERNAL_GPIO
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
#include "nvs_flash.h"
|
#include "nvs_flash.h"
|
||||||
|
#include "esp_wifi.h"
|
||||||
|
|
||||||
#include <openiris_logo.hpp>
|
#include <openiris_logo.hpp>
|
||||||
#include <wifiManager.hpp>
|
#include <wifiManager.hpp>
|
||||||
@@ -27,7 +28,7 @@
|
|||||||
#include <UVCStream.hpp>
|
#include <UVCStream.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define BLINK_GPIO (gpio_num_t) CONFIG_LED_BLINK_GPIO
|
#define BLINK_GPIO (gpio_num_t) CONFIG_LED_DEBUG_GPIO
|
||||||
#define CONFIG_LED_C_PIN_GPIO (gpio_num_t) CONFIG_LED_EXTERNAL_GPIO
|
#define CONFIG_LED_C_PIN_GPIO (gpio_num_t) CONFIG_LED_EXTERNAL_GPIO
|
||||||
|
|
||||||
TaskHandle_t serialManagerHandle;
|
TaskHandle_t serialManagerHandle;
|
||||||
@@ -206,7 +207,7 @@ void startWiFiMode(bool shouldCloseSerialManager)
|
|||||||
ESP_LOGI("[MAIN]", "Closing serial manager task.");
|
ESP_LOGI("[MAIN]", "Closing serial manager task.");
|
||||||
vTaskDelete(serialManagerHandle);
|
vTaskDelete(serialManagerHandle);
|
||||||
}
|
}
|
||||||
|
#ifdef CONFIG_GENERAL_ENABLE_WIRELESS
|
||||||
wifiManager->Begin();
|
wifiManager->Begin();
|
||||||
mdnsManager.start();
|
mdnsManager.start();
|
||||||
restAPI->begin();
|
restAPI->begin();
|
||||||
@@ -218,16 +219,20 @@ void startWiFiMode(bool shouldCloseSerialManager)
|
|||||||
restAPI,
|
restAPI,
|
||||||
1, // it's the rest API, we only serve commands over it so we don't really need a higher priority
|
1, // it's the rest API, we only serve commands over it so we don't really need a higher priority
|
||||||
nullptr);
|
nullptr);
|
||||||
|
#else
|
||||||
|
ESP_LOGW("[MAIN]", "Wireless is disabled by configuration; skipping WiFi/mDNS/REST startup.");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void startSetupMode()
|
void startSetupMode()
|
||||||
{
|
{
|
||||||
// If we're in SETUP 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
|
// during this time we await any commands
|
||||||
|
const int startup_delay_s = CONFIG_GENERAL_STARTUP_DELAY;
|
||||||
ESP_LOGI("[MAIN]", "=====================================");
|
ESP_LOGI("[MAIN]", "=====================================");
|
||||||
ESP_LOGI("[MAIN]", "STARTUP: 20-SECOND DELAY MODE ACTIVE");
|
ESP_LOGI("[MAIN]", "STARTUP: %d-SECOND DELAY MODE ACTIVE", startup_delay_s);
|
||||||
ESP_LOGI("[MAIN]", "=====================================");
|
ESP_LOGI("[MAIN]", "=====================================");
|
||||||
ESP_LOGI("[MAIN]", "Device will wait 20 seconds for commands...");
|
ESP_LOGI("[MAIN]", "Device will wait %d seconds for commands...", startup_delay_s);
|
||||||
|
|
||||||
// Create a one-shot timer for 20 seconds
|
// Create a one-shot timer for 20 seconds
|
||||||
const esp_timer_create_args_t startup_timer_args = {
|
const esp_timer_create_args_t startup_timer_args = {
|
||||||
@@ -238,16 +243,19 @@ void startSetupMode()
|
|||||||
.skip_unhandled_events = false};
|
.skip_unhandled_events = false};
|
||||||
|
|
||||||
ESP_ERROR_CHECK(esp_timer_create(&startup_timer_args, &timerHandle));
|
ESP_ERROR_CHECK(esp_timer_create(&startup_timer_args, &timerHandle));
|
||||||
ESP_ERROR_CHECK(esp_timer_start_once(timerHandle, CONFIG_GENERAL_UVC_DELAY * 1000000));
|
ESP_ERROR_CHECK(esp_timer_start_once(timerHandle, (uint64_t)startup_delay_s * 1000000));
|
||||||
ESP_LOGI("[MAIN]", "Started 20-second startup timer");
|
ESP_LOGI("[MAIN]", "Started %d-second startup timer", startup_delay_s);
|
||||||
ESP_LOGI("[MAIN]", "Send any command within 20 seconds to enter heartbeat mode");
|
ESP_LOGI("[MAIN]", "Send any command within %d seconds to enter heartbeat mode", startup_delay_s);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void app_main(void)
|
extern "C" void app_main(void)
|
||||||
{
|
{
|
||||||
dependencyRegistry->registerService<ProjectConfig>(DependencyType::project_config, deviceConfig);
|
dependencyRegistry->registerService<ProjectConfig>(DependencyType::project_config, deviceConfig);
|
||||||
dependencyRegistry->registerService<CameraManager>(DependencyType::camera_manager, cameraHandler);
|
dependencyRegistry->registerService<CameraManager>(DependencyType::camera_manager, cameraHandler);
|
||||||
|
// Register WiFiManager only when wireless is enabled to avoid exposing WiFi commands in no-wireless builds
|
||||||
|
#ifdef CONFIG_GENERAL_ENABLE_WIRELESS
|
||||||
dependencyRegistry->registerService<WiFiManager>(DependencyType::wifi_manager, wifiManager);
|
dependencyRegistry->registerService<WiFiManager>(DependencyType::wifi_manager, wifiManager);
|
||||||
|
#endif
|
||||||
dependencyRegistry->registerService<LEDManager>(DependencyType::led_manager, ledManager);
|
dependencyRegistry->registerService<LEDManager>(DependencyType::led_manager, ledManager);
|
||||||
dependencyRegistry->registerService<MonitoringManager>(DependencyType::monitoring_manager, std::shared_ptr<MonitoringManager>(&monitoringManager, [](MonitoringManager*){}));
|
dependencyRegistry->registerService<MonitoringManager>(DependencyType::monitoring_manager, std::shared_ptr<MonitoringManager>(&monitoringManager, [](MonitoringManager*){}));
|
||||||
|
|
||||||
@@ -314,7 +322,8 @@ extern "C" void app_main(void)
|
|||||||
{
|
{
|
||||||
// since we're in setup mode, we have to have wireless functionality on,
|
// since we're in setup mode, we have to have wireless functionality on,
|
||||||
// so we can do wifi scanning, test connection etc
|
// so we can do wifi scanning, test connection etc
|
||||||
startWiFiMode(false);
|
// if wireless is disabled by configuration, we will not start WiFi services here
|
||||||
|
startWiFiMode(false);
|
||||||
startSetupMode();
|
startSetupMode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -572,7 +572,8 @@ CONFIG_ENV_GPIO_OUT_RANGE_MAX=48
|
|||||||
#
|
#
|
||||||
# CONFIG_START_IN_UVC_MODE is not set
|
# CONFIG_START_IN_UVC_MODE is not set
|
||||||
CONFIG_GENERAL_INCLUDE_UVC_MODE=y
|
CONFIG_GENERAL_INCLUDE_UVC_MODE=y
|
||||||
CONFIG_GENERAL_UVC_DELAY=30
|
CONFIG_GENERAL_STARTUP_DELAY=30
|
||||||
|
CONFIG_GENERAL_ENABLE_WIRELESS=y
|
||||||
# end of OpenIris: General Configuration
|
# end of OpenIris: General Configuration
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -595,7 +596,7 @@ CONFIG_WIFI_AP_PASSWORD="12345678"
|
|||||||
#
|
#
|
||||||
# OpenIris: LED Configuration
|
# OpenIris: LED Configuration
|
||||||
#
|
#
|
||||||
CONFIG_LED_BLINK_GPIO=8
|
CONFIG_LED_DEBUG_GPIO=8
|
||||||
CONFIG_LED_EXTERNAL_GPIO=9
|
CONFIG_LED_EXTERNAL_GPIO=9
|
||||||
CONFIG_LED_EXTERNAL_CONTROL=y
|
CONFIG_LED_EXTERNAL_CONTROL=y
|
||||||
CONFIG_LED_EXTERNAL_PWM_FREQ=20000
|
CONFIG_LED_EXTERNAL_PWM_FREQ=20000
|
||||||
|
|||||||
@@ -572,7 +572,7 @@ CONFIG_ENV_GPIO_OUT_RANGE_MAX=48
|
|||||||
#
|
#
|
||||||
# CONFIG_GENERAL_INCLUDE_UVC_MODE is not set
|
# CONFIG_GENERAL_INCLUDE_UVC_MODE is not set
|
||||||
# CONFIG_START_IN_UVC_MODE is not set
|
# CONFIG_START_IN_UVC_MODE is not set
|
||||||
# CONFIG_GENERAL_UVC_DELAY is not set
|
# CONFIG_GENERAL_STARTUP_DELAY is not set
|
||||||
# end of OpenIris: General Configuration
|
# end of OpenIris: General Configuration
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -595,7 +595,7 @@ CONFIG_WIFI_AP_PASSWORD="12345678"
|
|||||||
#
|
#
|
||||||
# OpenIris: LED Configuration
|
# OpenIris: LED Configuration
|
||||||
#
|
#
|
||||||
CONFIG_LED_BLINK_GPIO=8
|
CONFIG_LED_DEBUG_GPIO=8
|
||||||
CONFIG_LED_EXTERNAL_GPIO=1
|
CONFIG_LED_EXTERNAL_GPIO=1
|
||||||
CONFIG_LED_EXTERNAL_CONTROL=y
|
CONFIG_LED_EXTERNAL_CONTROL=y
|
||||||
CONFIG_LED_EXTERNAL_PWM_FREQ=5000
|
CONFIG_LED_EXTERNAL_PWM_FREQ=5000
|
||||||
|
|||||||
Reference in New Issue
Block a user