#include <string.h>
#include <esp_log.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"
#include "esp_task_wdt.h"
//include "driver/uart.h"
//#include "freertos/queue.h"
#include "Led_config.h"
#include "button_config.h"
#include "uart_config.h"
#define LOG_LOCAL_LEVEL ESP_LOG_VERBOSE
static const char *TAG = "UART_MASTER";
void app_main() {
esp_log_level_set("*", ESP_LOG_VERBOSE);
//led_pin_init();
esp_task_wdt_deinit();
button_pin_init();
uart_init();
bool led_state = false;
int last_btn = 1;
while (true) {
int now = gpio_get_level(BUTT_PIN);
if (last_btn == 1 && now == 0) {
vTaskDelay(pdMS_TO_TICKS(30));
if (gpio_get_level(BUTT_PIN) == 0){
led_state = !led_state;
char ch = led_state ? '1' : '0';
uart_send_str("HELLO\n");
ESP_LOGI(TAG, "Button pressed, sent %c\n", ch);
}
}
last_btn = now;
vTaskDelay(pdMS_TO_TICKS(10));
}
}