First submit, make led blink

This commit is contained in:
2026-03-01 19:52:25 -05:00
parent 3b2b0a5078
commit d27b6e702f
12 changed files with 247 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
idf_component_register(SRCS "main.cpp"
INCLUDE_DIRS ".")

View File

View File

@@ -0,0 +1,17 @@
## IDF Component Manager Manifest File
dependencies:
## Required IDF version
idf:
version: '>=4.1.0'
# # Put list of dependencies here
# # For components maintained by Espressif:
# component: "~1.0.0"
# # For 3rd party components:
# username/component: ">=1.0.0,<2.0.0"
# username2/component2:
# version: "~1.0.0"
# # For transient dependencies `public` flag can be set.
# # `public` flag doesn't have an effect dependencies of the `main` component.
# # All dependencies of `main` are public by default.
# public: true
espressif/led_strip: ^3.0.3

View File

@@ -0,0 +1,44 @@
// Project includes
#include "types.hpp"
// SDK Includes
#include "led_strip.h"
enum class led_status : uint8 { Connecting, Ready, Failed };
// Could be a config but its the GPIO on my ESP32-S3-ETH
#define LED_GPIO GPIO_NUM_21
static led_strip_handle_t led_strip;
static 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);
}
static void destroy_led(void) { led_strip_clear(led_strip); }
void set_led_status(led_status status) {
switch (status) {
case led_status::Connecting:
led_strip_set_pixel(led_strip, 0, 0, 0, 255);
break;
case led_status::Ready:
led_strip_set_pixel(led_strip, 0, 0, 255, 0);
break;
case led_status::Failed:
led_strip_set_pixel(led_strip, 0, 255, 0, 0);
break;
}
led_strip_refresh(led_strip);
}

32
Provider/main/main.cpp Normal file
View File

@@ -0,0 +1,32 @@
// STD Lib
#include <stdio.h>
// SDK
#include "driver/gpio.h"
#include "esp_log.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "sdkconfig.h"
#include "soc/gpio_num.h"
// Project cpp
#include "connect.cpp"
#include "led_status.cpp"
extern "C" void app_main() {
setup_led();
printf("Hello, Worldi!\n");
set_led_status(led_status::Connecting);
vTaskDelay(1000 / portTICK_PERIOD_MS);
set_led_status(led_status::Ready);
vTaskDelay(1000 / portTICK_PERIOD_MS);
set_led_status(led_status::Failed);
vTaskDelay(1000 / portTICK_PERIOD_MS);
destroy_led();
}

13
Provider/main/types.hpp Normal file
View File

@@ -0,0 +1,13 @@
#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;