#ifndef __TOUCH_H
#define __TOUCH_H

#include <stdint.h>
#include "sg_lgpio.h"

// I2C device address for CST816D touch controller
#define CST816D_ADDR 0x15

// GPIO pin definitions (BCM numbering)
#define TOUCH_SDA_PIN  2
#define TOUCH_SCL_PIN  3
#define TOUCH_INT_PIN  17
#define TOUCH_RST_PIN  27

// Register addresses for CST816D
#define CST816D_REG_GESTURE 0x01
#define CST816D_REG_FINGER  0x02
#define CST816D_REG_X_HIGH  0x03
#define CST816D_REG_X_LOW   0x04
#define CST816D_REG_Y_HIGH  0x05
#define CST816D_REG_Y_LOW   0x06

typedef struct {
    uint16_t x;
    uint16_t y;
    uint8_t  pressed;    // 1: pressed, 0: released
} TouchPoint;

// Function declarations
void Touch_Init(void);
uint8_t Touch_Read_Point(TouchPoint *point);

#endif
