#include <zephyr/kernel.h>
#include <zephyr/drivers/gpio.h>
#include "../drivers/sensor/GPIO_Sensor_KY_038/ky_038.h"

void main(void)
{
    int ret;

    printk("Initializing KY-038 Clap Sensor\n");

    ret = ky_038_init();
    if (ret < 0) {
        printk("Failed to initialize KY-038 sensor\n");
        return;
    }

    while (1) {
        int sensor_status = ky_038_check_status();
        if (sensor_status == 1) {
            printk("Sound detected!\n");
        } else if (sensor_status == 0) {
            printk("No sound\n");
        } else {
            printk("Error reading sensor\n");
        }

        k_sleep(K_MSEC(1000));  // Poll every second
    }
}
