update: Added button at GPIO 0 for testing.

This commit is contained in:
2025-12-10 19:11:45 +05:30
parent 5960c03684
commit ba96f79d49
4 changed files with 2853 additions and 0 deletions

View File

@@ -17,6 +17,8 @@
#include "lv_conf.h"
#include "lv_demos.h"
#include "esp_lcd_touch_cst816s.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
/* LCD size */
#define EXAMPLE_LCD_H_RES (240)
#define EXAMPLE_LCD_V_RES (280)
@@ -44,6 +46,9 @@
#define TOUCH_HOST I2C_NUM_0
/* Power button */
#define PWR_BUTTON_GPIO (GPIO_NUM_0)
#if EXAMPLE_USE_TOUCH
#define EXAMPLE_PIN_NUM_TOUCH_SCL (GPIO_NUM_10)
#define EXAMPLE_PIN_NUM_TOUCH_SDA (GPIO_NUM_11)
@@ -225,8 +230,36 @@ static void app_main_display(void)
lvgl_port_unlock();
}
static void wait_for_power_button(void)
{
/* Configure power button GPIO */
gpio_config_t pwr_btn_config = {
.mode = GPIO_MODE_INPUT,
.pin_bit_mask = 1ULL << PWR_BUTTON_GPIO,
.pull_up_en = GPIO_PULLUP_ENABLE,
.pull_down_en = GPIO_PULLDOWN_DISABLE,
.intr_type = GPIO_INTR_DISABLE,
};
ESP_ERROR_CHECK(gpio_config(&pwr_btn_config));
ESP_LOGI(TAG, "Waiting for power button press on GPIO %d...", PWR_BUTTON_GPIO);
/* Wait for button press (active low) */
while (gpio_get_level(PWR_BUTTON_GPIO) == 1) {
vTaskDelay(pdMS_TO_TICKS(10));
}
/* Debounce delay */
vTaskDelay(pdMS_TO_TICKS(50));
ESP_LOGI(TAG, "Power button pressed, starting system...");
}
void app_main(void)
{
/* Wait for power button press before starting */
wait_for_power_button();
/* LCD HW initialization */
ESP_ERROR_CHECK(app_lcd_init());