/* Microchip Technology Inc. and its subsidiaries. You may use this software * and any derivatives exclusively with Microchip products. * * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. * * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE * FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS * IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF * ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. * * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE * TERMS. */ /* * File: * Author: * Comments: * Revision history: */ // This is a guard condition so that contents of this file are not included // more than once. #ifndef XPT2046_H #define XPT2046_H #include // include processor files - each processor file is guarded. #include #include #define CAL_MARGIN 0 #define CTRL_LO_DFR 0x03 #define CTRL_LO_SER 0x04 #define CTRL_HI_X 0x90 #define CTRL_HI_Y 0xD0 #define ADC_MAX 0x0fff // 12 bits typedef enum { ROT0, ROT90, ROT180, ROT270 } rotation_t; typedef enum { MODE_SER, MODE_DFR } adc_ref_t; extern int32_t _cal_dx, _cal_dy, _cal_dvi, _cal_dvj; extern uint16_t _cal_vi1, _cal_vj1; extern uint16_t t_width, t_height; extern rotation_t _rot; void begin(uint16_t width, uint16_t height); void setRotationTouch(rotation_t rot); // Calibration needs to be done with no rotation, on both display and touch drivers void getCalibrationPoints(uint16_t *x1, uint16_t *y1, uint16_t *x2, uint16_t *y2); void getPosition(uint16_t *x, uint16_t *y, adc_ref_t mode, uint8_t max_samples); void getRaw(uint16_t *vi, uint16_t *vj, adc_ref_t mode, uint8_t max_samples); void setCalibration(uint16_t vi1, uint16_t vj1, uint16_t vi2, uint16_t vj2); uint16_t _readLoop(uint8_t ctrl, uint8_t max_samples); bool isTouching(); void powerDown(); /* FOR 10 offset * * setCalibration(1863, 457, 263, 1650); * setCalibration(1890, 385, 240, 1632); * **/ /*FOR 5 offset * (1919,336,210,1646) * setCalibration(1920, 340, 210, 1650); */ /*For 0 offset * setCalibration(1943, 320, 171, 1695); * setCalibration(1952, 325, 176, 1696); */ #endif /* XPT2046_H */ /**********************************************************************/