mirror of
https://github.com/MrUnknownDE/OpenIris-ESPIDF.git
synced 2026-04-13 11:43:44 +02:00
- 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.
59 lines
1.3 KiB
C++
59 lines
1.3 KiB
C++
#include "MonitoringManager.hpp"
|
|
#include <esp_log.h>
|
|
#include "sdkconfig.h"
|
|
|
|
static const char* TAG_MM = "[MonitoringManager]";
|
|
|
|
void MonitoringManager::setup()
|
|
{
|
|
#if CONFIG_MONITORING_LED_CURRENT
|
|
cm_.setup();
|
|
ESP_LOGI(TAG_MM, "Monitoring enabled. Interval=%dms, Samples=%d, Gain=%d, R=%dmΩ",
|
|
CONFIG_MONITORING_LED_INTERVAL_MS,
|
|
CONFIG_MONITORING_LED_SAMPLES,
|
|
CONFIG_MONITORING_LED_GAIN,
|
|
CONFIG_MONITORING_LED_SHUNT_MILLIOHM);
|
|
#else
|
|
ESP_LOGI(TAG_MM, "Monitoring disabled by Kconfig");
|
|
#endif
|
|
}
|
|
|
|
void MonitoringManager::start()
|
|
{
|
|
#if CONFIG_MONITORING_LED_CURRENT
|
|
if (task_ == nullptr)
|
|
{
|
|
xTaskCreate(&MonitoringManager::taskEntry, "MonitoringTask", 2048, this, 1, &task_);
|
|
}
|
|
#endif
|
|
}
|
|
|
|
void MonitoringManager::stop()
|
|
{
|
|
if (task_)
|
|
{
|
|
TaskHandle_t toDelete = task_;
|
|
task_ = nullptr;
|
|
vTaskDelete(toDelete);
|
|
}
|
|
}
|
|
|
|
void MonitoringManager::taskEntry(void* arg)
|
|
{
|
|
static_cast<MonitoringManager*>(arg)->run();
|
|
}
|
|
|
|
void MonitoringManager::run()
|
|
{
|
|
#if CONFIG_MONITORING_LED_CURRENT
|
|
while (true)
|
|
{
|
|
float ma = cm_.pollAndGetMilliAmps();
|
|
last_current_ma_.store(ma);
|
|
vTaskDelay(pdMS_TO_TICKS(CONFIG_MONITORING_LED_INTERVAL_MS));
|
|
}
|
|
#else
|
|
vTaskDelete(nullptr);
|
|
#endif
|
|
}
|