Add UART multiplexer and INA226 monitoring
This commit is contained in:
28
main/main.c
28
main/main.c
@@ -5,6 +5,8 @@
|
||||
#include "esp_log.h"
|
||||
|
||||
#include "dcdc_controller.h"
|
||||
#include "ina226_monitor.h"
|
||||
#include "uart_mux.h"
|
||||
#include "usb_cdc_cli.h"
|
||||
#include "ws2812_status.h"
|
||||
|
||||
@@ -25,6 +27,19 @@ void app_main(void)
|
||||
ESP_LOGW(TAG, "WS2812 статусний індикатор недоступний");
|
||||
}
|
||||
|
||||
if (ina226_monitor_init() == ESP_OK) {
|
||||
ESP_LOGI(TAG, "INA226 моніторинг активовано");
|
||||
ina226_monitor_sample(NULL);
|
||||
} else {
|
||||
ESP_LOGW(TAG, "Моніторинг навантаження недоступний");
|
||||
}
|
||||
|
||||
if (uart_mux_init() == ESP_OK) {
|
||||
ESP_LOGI(TAG, "UART мультиплексор активовано");
|
||||
} else {
|
||||
ESP_LOGW(TAG, "UART мультиплексор недоступний");
|
||||
}
|
||||
|
||||
if (usb_cdc_cli_init() != ESP_OK) {
|
||||
ESP_LOGW(TAG, "USB CDC CLI недоступний");
|
||||
} else {
|
||||
@@ -48,6 +63,19 @@ void app_main(void)
|
||||
ws2812_status_mark_active(ch);
|
||||
vTaskDelay(on_time);
|
||||
|
||||
ina226_reading_t reading = {0};
|
||||
if (ina226_monitor_sample(&reading) == ESP_OK) {
|
||||
ESP_LOGI(TAG, "Живлення: %.2f В, %.1f мА, %.1f мВт",
|
||||
reading.voltage_v, reading.current_ma, reading.power_mw);
|
||||
}
|
||||
|
||||
if (uart_mux_ready()) {
|
||||
char msg[64];
|
||||
int len = snprintf(msg, sizeof(msg), "PWR %.2fV %.0fmA\r\n",
|
||||
reading.voltage_v, reading.current_ma);
|
||||
uart_mux_write(ch, (const uint8_t *)msg, len, pdMS_TO_TICKS(100));
|
||||
}
|
||||
|
||||
prev_channel = ch;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user