This commit is contained in:
2026-01-25 20:53:24 +03:00
parent 77145e4e27
commit e42dd3b91b
12 changed files with 455 additions and 3 deletions

View File

@@ -0,0 +1,8 @@
# https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html
# 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(main)

View File

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

View File

@@ -0,0 +1,6 @@
dependencies:
idf:
version: '>=4.1.0'
MarcioBulla/menu_manager:
git: https://github.com/MarcioBulla/menu_manager
version: main

View File

@@ -0,0 +1,88 @@
#include "menu_manager.h"
#include <esp_log.h>
#include <esp_system.h>
#include <freertos/FreeRTOS.h>
#include <freertos/queue.h>
#include <freertos/semphr.h>
#include <freertos/task.h>
#include <sdkconfig.h>
#include <stdbool.h>
#include <stdio.h>
static const char *TAG = "main";
void dumb(void *args) {
ESP_LOGI(TAG, "I am dumb");
while (true) {
vTaskDelay(10000 / portTICK_PERIOD_MS);
}
}
menu_node_t submenu[3] = {
{.label = "funcA", .function = &dumb},
{.label = "funcB", .function = &dumb},
{.label = "funcC", .function = &dumb},
};
menu_node_t root = {
.label = "root",
.num_options = 3,
.submenus = (menu_node_t[3]){
{.label = "submenu1", .submenus = submenu, .num_options = 3},
{.label = "submenu2", .submenus = submenu, .num_options = 3},
{.label = "submenu3", .submenus = submenu, .num_options = 3},
}};
void simula_input(void *args) {
Navigate_t teste = NAVIGATE_UP;
vTaskDelay(6000 / portTICK_PERIOD_MS);
ESP_LOGI(TAG, "NEXT");
xQueueSend(qCommands, &teste, portMAX_DELAY);
vTaskDelay(5000 / portTICK_PERIOD_MS);
teste = NAVIGATE_SELECT;
ESP_LOGI(TAG, "SELECT");
xQueueSend(qCommands, &teste, portMAX_DELAY);
vTaskDelay(5000 / portTICK_PERIOD_MS);
teste = NAVIGATE_DOWN;
ESP_LOGI(TAG, "DOWN");
xQueueSend(qCommands, &teste, portMAX_DELAY);
vTaskDelay(5000 / portTICK_PERIOD_MS);
teste = NAVIGATE_SELECT;
ESP_LOGI(TAG, "SELECT");
xQueueSend(qCommands, &teste, portMAX_DELAY);
vTaskDelay(5000 / portTICK_PERIOD_MS);
teste = NAVIGATE_BACK;
ESP_LOGI(TAG, "BACK");
xQueueSend(qCommands, &teste, portMAX_DELAY);
vTaskDelay(5000 / portTICK_PERIOD_MS);
ESP_LOGI(TAG, "BACK");
xQueueSend(qCommands, &teste, portMAX_DELAY);
vTaskDelay(10000 / portTICK_PERIOD_MS);
ESP_LOGI(TAG, "Finalizada");
vTaskDelete(NULL);
}
void display(menu_path_t *current_path) {
ESP_LOGI(TAG, "title: %s, index_select: %d",
current_path->current_menu->label, current_path->current_index);
ESP_LOGI(
TAG, "Option Selected %s",
current_path->current_menu->submenus[current_path->current_index].label);
}
void app_main(void) {
menu_config_t config = {
.root = root,
.loop = true,
.display = &display,
};
xTaskCreatePinnedToCore(&menu_init, "menu_init", 2048, &config, 3, NULL, 0);
vTaskDelay(5000 / portMAX_DELAY);
xTaskCreatePinnedToCore(&simula_input, "simula", 2048, NULL, 1, NULL, 0);
vTaskDelete(NULL);
}