mirror of
https://github.com/MrUnknownDE/OpenIris-ESPIDF.git
synced 2026-04-18 22:13:45 +02:00
Add initial version of the Build and release action
This commit is contained in:
@@ -1,6 +1,34 @@
|
||||
idf_component_register(SRCS
|
||||
"Monitoring/CurrentMonitor.cpp"
|
||||
"Monitoring/MonitoringManager.cpp"
|
||||
INCLUDE_DIRS "Monitoring"
|
||||
REQUIRES driver esp_adc Helpers
|
||||
set(
|
||||
requires
|
||||
Helpers
|
||||
)
|
||||
|
||||
if ("$ENV{IDF_TARGET}" STREQUAL "esp32s3")
|
||||
list(APPEND requires
|
||||
driver
|
||||
esp_adc
|
||||
)
|
||||
endif()
|
||||
|
||||
set(
|
||||
source_files
|
||||
""
|
||||
)
|
||||
|
||||
if ("$ENV{IDF_TARGET}" STREQUAL "esp32s3")
|
||||
list(APPEND source_files
|
||||
"Monitoring/CurrentMonitor_esp32s3.cpp"
|
||||
"Monitoring/MonitoringManager_esp32s3.cpp"
|
||||
)
|
||||
else()
|
||||
list(APPEND source_files
|
||||
"Monitoring/CurrentMonitor_esp32.cpp"
|
||||
"Monitoring/MonitoringManager_esp32.cpp"
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
idf_component_register(SRCS ${source_files}
|
||||
INCLUDE_DIRS "Monitoring"
|
||||
REQUIRES ${requires}
|
||||
)
|
||||
@@ -6,7 +6,8 @@
|
||||
#include <vector>
|
||||
#include "sdkconfig.h"
|
||||
|
||||
class CurrentMonitor {
|
||||
class CurrentMonitor
|
||||
{
|
||||
public:
|
||||
CurrentMonitor();
|
||||
~CurrentMonitor() = default;
|
||||
@@ -25,15 +26,15 @@ public:
|
||||
// Whether monitoring is enabled by Kconfig
|
||||
static constexpr bool isEnabled()
|
||||
{
|
||||
#ifdef CONFIG_MONITORING_LED_CURRENT
|
||||
#ifdef CONFIG_MONITORING_LED_CURRENT
|
||||
return true;
|
||||
#else
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
#if CONFIG_MONITORING_LED_CURRENT
|
||||
#ifdef CONFIG_MONITORING_LED_CURRENT
|
||||
void init_adc();
|
||||
int read_mv_once();
|
||||
int gpio_to_adc_channel(int gpio);
|
||||
|
||||
42
components/Monitoring/Monitoring/CurrentMonitor_esp32.cpp
Normal file
42
components/Monitoring/Monitoring/CurrentMonitor_esp32.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
#include "CurrentMonitor.hpp"
|
||||
#include <esp_log.h>
|
||||
|
||||
static const char *TAG_CM = "[CurrentMonitor]";
|
||||
|
||||
CurrentMonitor::CurrentMonitor()
|
||||
{
|
||||
// empty as esp32 doesn't support this
|
||||
// but without a separate implementation, the linker will complain :c
|
||||
}
|
||||
|
||||
void CurrentMonitor::setup()
|
||||
{
|
||||
ESP_LOGI(TAG_CM, "LED current monitoring disabled");
|
||||
}
|
||||
|
||||
float CurrentMonitor::getCurrentMilliAmps() const
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
float CurrentMonitor::pollAndGetMilliAmps()
|
||||
{
|
||||
sampleOnce();
|
||||
return getCurrentMilliAmps();
|
||||
}
|
||||
|
||||
void CurrentMonitor::sampleOnce()
|
||||
{
|
||||
(void)0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_MONITORING_LED_CURRENT
|
||||
void CurrentMonitor::init_adc()
|
||||
{
|
||||
}
|
||||
|
||||
int CurrentMonitor::read_mv_once()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <esp_log.h>
|
||||
#include <cmath>
|
||||
|
||||
#if CONFIG_MONITORING_LED_CURRENT
|
||||
#ifdef CONFIG_MONITORING_LED_CURRENT
|
||||
#include "esp_adc/adc_oneshot.h"
|
||||
#include "esp_adc/adc_cali.h"
|
||||
#include "esp_adc/adc_cali_scheme.h"
|
||||
@@ -12,14 +12,14 @@ static const char *TAG_CM = "[CurrentMonitor]";
|
||||
|
||||
CurrentMonitor::CurrentMonitor()
|
||||
{
|
||||
#if CONFIG_MONITORING_LED_CURRENT
|
||||
#ifdef CONFIG_MONITORING_LED_CURRENT
|
||||
samples_.assign(CONFIG_MONITORING_LED_SAMPLES, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
void CurrentMonitor::setup()
|
||||
{
|
||||
#if CONFIG_MONITORING_LED_CURRENT
|
||||
#ifdef CONFIG_MONITORING_LED_CURRENT
|
||||
init_adc();
|
||||
#else
|
||||
ESP_LOGI(TAG_CM, "LED current monitoring disabled");
|
||||
@@ -28,7 +28,7 @@ void CurrentMonitor::setup()
|
||||
|
||||
float CurrentMonitor::getCurrentMilliAmps() const
|
||||
{
|
||||
#if CONFIG_MONITORING_LED_CURRENT
|
||||
#ifdef CONFIG_MONITORING_LED_CURRENT
|
||||
const int shunt_milliohm = CONFIG_MONITORING_LED_SHUNT_MILLIOHM; // mΩ
|
||||
if (shunt_milliohm <= 0)
|
||||
return 0.0f;
|
||||
@@ -48,7 +48,7 @@ float CurrentMonitor::pollAndGetMilliAmps()
|
||||
|
||||
void CurrentMonitor::sampleOnce()
|
||||
{
|
||||
#if CONFIG_MONITORING_LED_CURRENT
|
||||
#ifdef CONFIG_MONITORING_LED_CURRENT
|
||||
int mv = read_mv_once();
|
||||
// Divide by analog gain/divider factor to get shunt voltage
|
||||
if (CONFIG_MONITORING_LED_GAIN > 0)
|
||||
@@ -76,7 +76,7 @@ void CurrentMonitor::sampleOnce()
|
||||
#endif
|
||||
}
|
||||
|
||||
#if CONFIG_MONITORING_LED_CURRENT
|
||||
#ifdef CONFIG_MONITORING_LED_CURRENT
|
||||
|
||||
static adc_oneshot_unit_handle_t s_adc_handle = nullptr;
|
||||
static adc_cali_handle_t s_cali_handle = nullptr;
|
||||
@@ -4,9 +4,9 @@
|
||||
#include <atomic>
|
||||
#include "CurrentMonitor.hpp"
|
||||
|
||||
class MonitoringManager {
|
||||
class MonitoringManager
|
||||
{
|
||||
public:
|
||||
|
||||
void setup();
|
||||
void start();
|
||||
void stop();
|
||||
@@ -15,7 +15,7 @@ public:
|
||||
float getCurrentMilliAmps() const { return last_current_ma_.load(); }
|
||||
|
||||
private:
|
||||
static void taskEntry(void* arg);
|
||||
static void taskEntry(void *arg);
|
||||
void run();
|
||||
|
||||
TaskHandle_t task_{nullptr};
|
||||
|
||||
25
components/Monitoring/Monitoring/MonitoringManager_esp32.cpp
Normal file
25
components/Monitoring/Monitoring/MonitoringManager_esp32.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#include "MonitoringManager.hpp"
|
||||
#include <esp_log.h>
|
||||
|
||||
static const char *TAG_MM = "[MonitoringManager]";
|
||||
|
||||
void MonitoringManager::setup()
|
||||
{
|
||||
ESP_LOGI(TAG_MM, "Monitoring disabled by Kconfig");
|
||||
}
|
||||
|
||||
void MonitoringManager::start()
|
||||
{
|
||||
}
|
||||
|
||||
void MonitoringManager::stop()
|
||||
{
|
||||
}
|
||||
|
||||
void MonitoringManager::taskEntry(void *arg)
|
||||
{
|
||||
}
|
||||
|
||||
void MonitoringManager::run()
|
||||
{
|
||||
}
|
||||
@@ -2,11 +2,11 @@
|
||||
#include <esp_log.h>
|
||||
#include "sdkconfig.h"
|
||||
|
||||
static const char* TAG_MM = "[MonitoringManager]";
|
||||
static const char *TAG_MM = "[MonitoringManager]";
|
||||
|
||||
void MonitoringManager::setup()
|
||||
{
|
||||
#if CONFIG_MONITORING_LED_CURRENT
|
||||
#ifdef 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,
|
||||
@@ -20,7 +20,7 @@ void MonitoringManager::setup()
|
||||
|
||||
void MonitoringManager::start()
|
||||
{
|
||||
#if CONFIG_MONITORING_LED_CURRENT
|
||||
#ifdef CONFIG_MONITORING_LED_CURRENT
|
||||
if (task_ == nullptr)
|
||||
{
|
||||
xTaskCreate(&MonitoringManager::taskEntry, "MonitoringTask", 2048, this, 1, &task_);
|
||||
@@ -38,14 +38,14 @@ void MonitoringManager::stop()
|
||||
}
|
||||
}
|
||||
|
||||
void MonitoringManager::taskEntry(void* arg)
|
||||
void MonitoringManager::taskEntry(void *arg)
|
||||
{
|
||||
static_cast<MonitoringManager*>(arg)->run();
|
||||
static_cast<MonitoringManager *>(arg)->run();
|
||||
}
|
||||
|
||||
void MonitoringManager::run()
|
||||
{
|
||||
#if CONFIG_MONITORING_LED_CURRENT
|
||||
#ifdef CONFIG_MONITORING_LED_CURRENT
|
||||
while (true)
|
||||
{
|
||||
float ma = cm_.pollAndGetMilliAmps();
|
||||
@@ -16,7 +16,7 @@ void SerialManager::setup()
|
||||
#endif
|
||||
}
|
||||
|
||||
usb_serial_jtag_write_bytes_chunked(const char *data, size_t len, size_t timeout)
|
||||
void usb_serial_jtag_write_bytes_chunked(const char *data, size_t len, size_t timeout)
|
||||
{
|
||||
#ifndef CONFIG_USE_UART_FOR_COMMUNICATION
|
||||
while (len > 0)
|
||||
|
||||
@@ -7,8 +7,8 @@ set (
|
||||
Helpers
|
||||
)
|
||||
|
||||
if ("$ENV{IDF_ETARGET}" STREQUAL "esp32s3")
|
||||
list(APPEND required
|
||||
if ("$ENV{IDF_TARGET}" STREQUAL "esp32s3")
|
||||
list(APPEND requires
|
||||
usb_device_uvc
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#ifdef CONFIG_GENERAL_INCLUDE_UVC_MODE
|
||||
|
||||
#include "UVCStream.hpp"
|
||||
|
||||
#ifdef CONFIG_GENERAL_INCLUDE_UVC_MODE
|
||||
#include <cstdio> // for snprintf
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
#ifdef CONFIG_GENERAL_INCLUDE_UVC_MODE
|
||||
#pragma once
|
||||
#ifndef UVCSTREAM_HPP
|
||||
#define UVCSTREAM_HPP
|
||||
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#ifdef CONFIG_GENERAL_INCLUDE_UVC_MODE
|
||||
#include "esp_timer.h"
|
||||
#include "esp_mac.h"
|
||||
#include "esp_camera.h"
|
||||
|
||||
Reference in New Issue
Block a user