Moving into components parts of the provider project

This commit is contained in:
2026-03-26 20:36:27 -04:00
parent cfe19d5e65
commit f483a4d292
12 changed files with 48 additions and 30 deletions
+4 -4
View File
@@ -1,8 +1,8 @@
idf_component_register(SRCS "main.cpp"
PRIV_REQUIRES esp_http_server esp_eth
esp_wifi nvs_flash esp_netif vfs
json app_update esp_timer esp_psram mdns driver network
INCLUDE_DIRS ".")
PRIV_REQUIRES esp_http_server
nvs_flash vfs esp_timer
json app_update esp_psram mdns driver network
INCLUDE_DIRS "." "../../components/shared")
if(CONFIG_CALENDINK_DEPLOY_WEB_PAGES)
set(WEB_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../frontend")
+2
View File
@@ -21,3 +21,5 @@ dependencies:
lvgl/lvgl: "9.4.0"
network:
path: "../../components/network"
led:
path: "../../components/led"
-90
View File
@@ -1,90 +0,0 @@
// Project includes
#include "types.hpp"
// SDK Includes
#include "led_strip.h"
// Could be a config but its the GPIO on my ESP32-S3-ETH
#define LED_GPIO GPIO_NUM_21
enum class led_status : uint8
{
ConnectingEthernet,
ConnectingWifi,
ReadyEthernet,
ReadyWifi,
Failed
};
internal led_strip_handle_t led_strip;
internal void setup_led(void)
{
/* LED strip initialization with the GPIO and pixels number*/
led_strip_config_t strip_config = {};
strip_config.strip_gpio_num = LED_GPIO;
strip_config.max_leds = 1; // at least one LED on board
led_strip_rmt_config_t rmt_config = {};
rmt_config.resolution_hz = 10 * 1000 * 1000; // 10MHz
rmt_config.flags.with_dma = false;
ESP_ERROR_CHECK(
led_strip_new_rmt_device(&strip_config, &rmt_config, &led_strip));
led_strip_clear(led_strip);
}
internal void destroy_led(void) { led_strip_clear(led_strip); }
internal void set_led_status(led_status status)
{
switch (status)
{
case led_status::ConnectingEthernet:
led_strip_set_pixel(led_strip, 0, 255, 165, 0);
break;
case led_status::ConnectingWifi:
led_strip_set_pixel(led_strip, 0, 148, 0, 211);
break;
case led_status::ReadyEthernet:
led_strip_set_pixel(led_strip, 0, 0, 255, 0); // Green
break;
case led_status::ReadyWifi:
led_strip_set_pixel(led_strip, 0, 0, 0, 255); // Blue
break;
case led_status::Failed:
led_strip_set_pixel(led_strip, 0, 255, 0, 0);
break;
}
led_strip_refresh(led_strip);
}
#if CONFIG_CALENDINK_BLINK_IP
internal void led_blink_number(int n, uint8_t r, uint8_t g, uint8_t b)
{
if (n <= 0)
{
for (int i = 0; i < 2; i++)
{
led_strip_set_pixel(led_strip, 0, r, g, b);
led_strip_refresh(led_strip);
vTaskDelay(pdMS_TO_TICKS(50));
led_strip_clear(led_strip);
led_strip_refresh(led_strip);
vTaskDelay(pdMS_TO_TICKS(50));
}
vTaskDelay(pdMS_TO_TICKS(1000));
return;
}
for (int i = 0; i < n; i++)
{
led_strip_set_pixel(led_strip, 0, r, g, b);
led_strip_refresh(led_strip);
vTaskDelay(pdMS_TO_TICKS(300));
led_strip_clear(led_strip);
led_strip_refresh(led_strip);
vTaskDelay(pdMS_TO_TICKS(300));
}
vTaskDelay(pdMS_TO_TICKS(1000));
}
#endif
+3 -3
View File
@@ -18,10 +18,10 @@
// Project headers
#include "types.hpp"
#include "network.hpp"
#include "led.hpp"
// Project cpp (Unity Build entry)
// clang-format off
#include "led_status.cpp"
#include "http_server.cpp"
#include "mdns_service.cpp"
#include "udp_logger.cpp"
@@ -42,7 +42,7 @@ constexpr bool kBlockUntilEthernetEstablished = false;
internal void my_timer_callback(void *arg)
{
ESP_LOGI(kTagMain, "Timer finished! Turning Led Off...");
destroy_led();
turn_off_led();
}
extern "C" void app_main()
@@ -378,7 +378,7 @@ shutdown:
g_Wifi_Initialized = false;
}
destroy_led();
turn_off_led();
ESP_ERROR_CHECK(esp_event_loop_delete_default());
ESP_ERROR_CHECK(nvs_flash_deinit());
-15
View File
@@ -1,15 +0,0 @@
#pragma once
#include <cstdint>
using uint8 = uint8_t;
using uint16 = uint16_t;
using uint32 = uint32_t;
using uint64 = uint64_t;
using int8 = int8_t;
using int16 = int16_t;
using int32 = int32_t;
using int64 = int64_t;
#define internal static