#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"
// Use the correct type for queues
QueueHandle_t gpio_evt_queue = NULL;
volatile enum button_state current_state = OFF;
int64_t last_press_time = 0; // For debounce (in microseconds)
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);
// Create a queue to communicate from ISR to task
gpio_evt_queue = xQueueCreate(10, sizeof(uint32_t));
// Start a task to process button press
xTaskCreate(button_task, "button_task", 2048, (void*)¤t_state, 10, NULL);
// 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);
}