#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "driver/gpio.h"
#include "driver/i2c.h"
#include "gpio_pins.h"
#include "interrupt_handler.h"
#include "buttons.h"
// #include "driver/gptimer.h"
#include "led_pattern.h"
// Use the correct type for queues
QueueHandle_t gpio_evt_queue = NULL;
struct button_device buttons[NUM_BUTTONS] = {
{{LED_GPIO_1, BUTTON_GPIO_1}, OFF, LED_PATTERN_OFF, 0},
{{LED_GPIO_2, BUTTON_GPIO_2}, OFF, LED_PATTERN_OFF, 0}
};
void app_main() {
printf("Hello, Wokwi!\n");
// Initialising mpu6050 sensor in this
i2c_master_init();
mpu6050_init();
// Set LEDs as outputs
gpio_set_direction(LED_GPIO_1, GPIO_MODE_OUTPUT);
gpio_set_direction(LED_GPIO_2, GPIO_MODE_OUTPUT);
// Initialize the button GPIO with interrupt config
initgpio(BUTTON_GPIO_1);
initgpio(BUTTON_GPIO_2);
gpio_evt_queue = xQueueCreate(20, sizeof(uint32_t));
// Install GPIO ISR service
gpio_install_isr_service(0);
gpio_isr_handler_add(BUTTON_GPIO_1, gpio_isr_handler, (void*) BUTTON_GPIO_1);
gpio_isr_handler_add(BUTTON_GPIO_2, gpio_isr_handler, (void*) BUTTON_GPIO_2);
xTaskCreate(button_task, "button_task", 4096,NULL, 10, NULL);
xTaskCreate(led_task, "led_task", 4096, NULL, 9, NULL);
}