Inital HW Test with ONboard LED, Master Input and Taster

This commit is contained in:
simon 2026-04-21 09:47:22 +02:00
commit e5a63c8c7f
6 changed files with 2636 additions and 0 deletions

6
CMakeLists.txt Normal file
View File

@ -0,0 +1,6 @@
# The following five lines of boilerplate have to be in your project's
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.16)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(hw_test)

21
dependencies.lock Normal file
View File

@ -0,0 +1,21 @@
dependencies:
espressif/led_strip:
component_hash: 28621486f77229aaf81c71f5e15d6fbf36c2949cf11094e07090593e659e7639
dependencies:
- name: idf
require: private
version: '>=5.0'
source:
registry_url: https://components.espressif.com/
type: service
version: 3.0.3
idf:
source:
type: idf
version: 5.5.4
direct_dependencies:
- espressif/led_strip
- idf
manifest_hash: 66f0d1a5019d1277f845b61ed7ecd51b2f8a000d6fb5b32b40131928bf590fba
target: esp32s3
version: 2.0.0

2
main/CMakeLists.txt Normal file
View File

@ -0,0 +1,2 @@
idf_component_register(SRCS "hw_test.c"
INCLUDE_DIRS ".")

129
main/hw_test.c Normal file
View File

@ -0,0 +1,129 @@
#include "driver/gpio.h"
#include "esp_err.h"
#include "esp_log.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "led_strip.h"
#define LED_GPIO 21
#define TASTER_GPIO 12
#define V_LIPO_1 1
#define V_LIPO_2 12
#define TERMAINL_RX 2
#define TERMINAL_TX 3
#define DIP_MASTER 4
#define I2C_SCL 5
#define I2C_SDA
#define TOUCH_1 9
#define TOUCH_2 8
#define LED_RING 7
static const char *TAG = "LED_TASK";
static led_strip_handle_t led_strip;
static led_strip_handle_t led_ring;
/* LED Task */
void vTaskLed(void *pvParameters) {
ESP_LOGI(TAG, "LED task started");
uint8_t state = 0;
while (1) {
if (state) {
// GREEN
led_strip_set_pixel(led_strip, 0, 25, 0, 0);
} else {
led_strip_set_pixel(led_strip, 0, 0, 0, 0);
}
led_strip_refresh(led_strip);
state = !state;
vTaskDelay(pdMS_TO_TICKS(1000));
}
}
void vTaskInput(void *pvParameters) {
ESP_LOGI(TAG, "Input Test");
uint8_t master;
uint8_t taster;
uint8_t lastMaster = 0;
uint8_t lastTaster = 0;
gpio_reset_pin(DIP_MASTER);
gpio_set_direction(DIP_MASTER, GPIO_MODE_INPUT);
gpio_reset_pin(TASTER_GPIO);
gpio_set_direction(TASTER_GPIO, GPIO_MODE_INPUT);
while (1) {
master = gpio_get_level(DIP_MASTER);
taster = gpio_get_level(TASTER_GPIO);
if (master != lastMaster) {
ESP_LOGI(TAG, "Master Pin changed from %d to %d", lastMaster, master);
lastMaster = master;
}
if (taster != lastTaster) {
ESP_LOGI(TAG, "Taster Pin changed from %d to %d", lastTaster, taster);
lastTaster = taster;
}
vTaskDelay(pdMS_TO_TICKS(100));
}
}
void vTaskRingBlink(void *pvParameters) {
ESP_LOGI("GPIO_TASK", "GPIO ring blink task started");
static bool state;
while (1) {
if (state) {
// GREEN
led_strip_set_pixel(led_ring, 0, 25, 0, 0);
} else {
led_strip_set_pixel(led_ring, 0, 0, 0, 0);
}
led_strip_refresh(led_ring);
state = !state;
vTaskDelay(pdMS_TO_TICKS(1000));
}
}
void app_main(void) {
ESP_LOGI(TAG, "Init LED strip");
esp_err_t err;
/* On Board LED Config */
led_strip_config_t strip_config = {
.strip_gpio_num = LED_GPIO,
//.strip_gpio_num = LED_RING,
.max_leds = 1,
};
led_strip_rmt_config_t rmt_config = {
.resolution_hz = 10 * 1000 * 1000, // 10 MHz
};
err = led_strip_new_rmt_device(&strip_config, &rmt_config, &led_strip);
if (err == ESP_OK) {
ESP_LOGI(TAG, "Onboard LED Task started");
xTaskCreate(vTaskLed, "led_task", 2048, NULL, 5, NULL);
}
/* LED Ring config */
led_strip_config_t ring_config = {
.strip_gpio_num = LED_RING,
.max_leds = 94,
};
led_strip_rmt_config_t rmt_ring_config = {
.resolution_hz = 10 * 1000 * 1000, // 10 MHz
};
err = led_strip_new_rmt_device(&ring_config, &rmt_ring_config, &led_ring);
if (err == ESP_OK) {
ESP_LOGI(TAG, "GPIO_RING_TASK started");
xTaskCreate(vTaskRingBlink, "gpio_ring_task", 4096, NULL, 5, NULL);
}
/* Input Monitor Task */
ESP_LOGI(TAG, "Input Monitor Task");
xTaskCreate(vTaskInput, "monitor_input", 4096, NULL, 5, NULL);
}

17
main/idf_component.yml Normal 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: '*'

2461
sdkconfig Normal file

File diff suppressed because it is too large Load Diff