#pragma once

#include <stdbool.h>
#include <stdint.h>

#include "esp_err.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef struct {
    int x_min;
    int x_max;
    int y_min;
    int y_max;
    bool invert_x;
    bool invert_y;
} touch_calib_t;

esp_err_t touch_init(void);
bool touch_read_raw(uint16_t *x, uint16_t *y, uint16_t *z);
bool touch_read_screen(int *x, int *y, uint16_t *z);
esp_err_t touch_calibrate(void);

const touch_calib_t *touch_get_calibration(void);
esp_err_t touch_set_calibration(const touch_calib_t *calib);

#ifdef __cplusplus
}
#endif
