Files
ESPDocs/public/exemplos/en/esp-iot-solution.c
T
Lucas RayanandAntigravity c1bd2c7e11
CI / Lint e auditorias (push) Successful in 1m51s
CI / Trivy (dependências e segredos) (push) Successful in 15s
CI / Imagem Docker (linux/arm64) (push) Successful in 2m41s
feat(i18n): English localization (phase 3)
- Translate content to English across messages/en.json, data/en, lib/data/en, and public/exemplos/en
- Implement localized routing, slugs, and language negotiation with fallback to en
- Build dedicated search index for English with strict book exclusion
- Update components and pages to dynamically render localized strings and datasets
- Verify full structural parity and exact 1:1 match on Portuguese pages via comparator

Co-Authored-By: Antigravity <noreply@google.com>
2026-11-01 14:17:13 -03:00

73 lines
2.1 KiB
C

/*
* ESP-IoT-Solution Example para ESP32
* Initialization de Botão Inteligente com Callbacks e Driver de Display/Sensores
*
* Dependência (idf_component.yml):
* espressif/button: "^3.3.0"
* espressif/led_indicator: "^1.2.0"
*/
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_log.h"
#include "iot_button.h"
#include "led_indicator.h"
static const char *TAG = "iot_solution_app";
#define BUTTON_GPIO_NUM 0 // Botão BOOT nativo
#define LED_INDICATOR_GPIO 2 // LED indicador
static led_indicator_handle_t led_handle = NULL;
/* Callback para clique único do botão */
static void button_single_click_cb(void *arg, void *data)
{
ESP_LOGI(TAG, "Evento: Clique Único detectado!");
led_indicator_start(led_handle, BLINK_DOUBLE_FAST);
}
/* Callback para clique longo (> 3 segundos) */
static void button_long_press_cb(void *arg, void *data)
{
ESP_LOGW(TAG, "Evento: Pressionamento Longo! Acionando modo de reset de fábrica.");
led_indicator_start(led_handle, BLINK_BREATHE_FAST);
}
void app_main(void)
{
ESP_LOGI(TAG, "Iniciando ESP-IoT-Solution Component Suite");
// 1. Configuration do LED Indicator
led_indicator_gpio_config_t led_cfg = {
.is_active_level_high = true,
.gpio_num = LED_INDICATOR_GPIO,
};
led_handle = led_indicator_create(&led_cfg);
// 2. Configuration do Botão com debounce de hardware/software automático
button_config_t btn_cfg = {
.type = BUTTON_TYPE_GPIO,
.long_press_time = 3000,
.short_press_time = 180,
.gpio_button_config = {
.gpio_num = BUTTON_GPIO_NUM,
.active_level = 0,
},
};
button_handle_t btn_handle = iot_button_create(&btn_cfg);
assert(btn_handle != NULL);
// Registra callbacks para diferentes gestos
iot_button_register_cb(btn_handle, BUTTON_SINGLE_CLICK, button_single_click_cb, NULL);
iot_button_register_cb(btn_handle, BUTTON_LONG_PRESS_START, button_long_press_cb, NULL);
ESP_LOGI(TAG, "Drivers inicializados com sucesso! Pressione o botão GPIO 0.");
while (1) {
vTaskDelay(pdMS_TO_TICKS(1000));
}
}