A web server for monitoring and controlling a MakerBot Replicator over the USB host and ethernet.
Dependencies: IAP NTPClient RTC mbed-rtos mbed Socket lwip-sys lwip BurstSPI
Fork of LPC1768_Mini-DK by
Touch.h
00001 /****************************************************************** 00002 ***** ***** 00003 ***** Name: Touch.h ***** 00004 ***** Ver.: 1.0 ***** 00005 ***** Date: 04/01/2013 ***** 00006 ***** Auth: Frank Vannieuwkerke ***** 00007 ***** Erik Olieman ***** 00008 ***** Func: Touch driver for use with ADS7843 ***** 00009 ***** ***** 00010 ******************************************************************/ 00011 00012 #ifndef MBED_Touch_H 00013 #define MBED_Touch_H 00014 00015 #include "SPI_TFT_ILI9320.h" 00016 #include "mbed.h" 00017 00018 typedef struct 00019 { 00020 int x; 00021 int y; 00022 } Coordinate; 00023 00024 typedef struct 00025 { 00026 int An, 00027 Bn, 00028 Cn, 00029 Dn, 00030 En, 00031 Fn, 00032 Divider ; 00033 } Matrix; 00034 00035 class TouchScreenADS7843 { 00036 public: 00037 Coordinate display; 00038 Coordinate screen; 00039 00040 /* 00041 * Create a Touchscreen object connected to SPI and two pins 00042 * 00043 * @param mosi,miso,sclk SPI 00044 * @param cs pin connected to CS of ADS7843 00045 * @param irq pin connected to IRQ of ADS7843 00046 * @param pointer to SPI_TFT constructor 00047 * 00048 */ 00049 TouchScreenADS7843(PinName tp_mosi, PinName tp_miso, PinName tp_sclk, PinName tp_cs, PinName tp_irq, SPI_TFT *_LCD); 00050 00051 /* 00052 * Draw a 2 by 2 dot on the LCD screen 00053 * 00054 * @param x (horizontal position) 00055 * @param y (vertical position) 00056 * @param color (16 bit pixel color) 00057 * 00058 */ 00059 void TP_DrawPoint(unsigned int Xpos,unsigned int Ypos,unsigned int color); 00060 00061 /* 00062 * Obtain averaged data from ADS7846 00063 * does 9 consecutive reads and only stores averaged data 00064 * when the 9 points are within the treshold limits. 00065 * 00066 * @param screenPTR (pointer to store data) 00067 * @returns 1 on success 00068 * @returns 0 on failure 00069 * 00070 * If called with screenPTR = NULL - 'screen' variable is used, otherwise (parameter) is used. 00071 * 00072 */ 00073 unsigned char Read_Ads7846(Coordinate * screenPtr = NULL); 00074 00075 /* 00076 * Calibrate the touch panel. 00077 * Three crosshairs are drawn and need to be touched in sequence. 00078 * A calibration matrix is set accordingly. 00079 * 00080 */ 00081 void TouchPanel_Calibrate(void); 00082 00083 /* 00084 * Obtain real x,y coordinates 00085 * The x,y coordinates are calculated using the calibration matrix. 00086 * 00087 */ 00088 unsigned char getDisplayPoint(void); 00089 00090 SPI_TFT *LCD; 00091 SPI _tp_spi; 00092 DigitalOut _tp_cs; 00093 DigitalIn _tp_irq; 00094 00095 protected: 00096 00097 #define SPI_RD_DELAY 1 00098 #define CHX 0xd0 // 12 bit mode 00099 #define CHY 0x90 00100 00101 Coordinate DisplaySample[3]; 00102 Coordinate ScreenSample[3]; 00103 Matrix matrix; 00104 00105 /* 00106 * Obtain raw x,y data from ADS7846 00107 * 00108 * @param pointer to raw x and y coordinates (pointer to store data) 00109 * @returns x (horizontal position) 00110 * @returns y (vertical position) 00111 * 00112 */ 00113 void TP_GetAdXY(int *x,int *y); 00114 00115 /* 00116 * Obtain raw single channel data from ADS7846 (Called by TP_GetADXY) 00117 * 00118 * @param channel to be read (CHX or CHY) 00119 * @returns raw scaled down value (return value range must be between 0 and 1024) 00120 * 00121 */ 00122 int Read_XY(unsigned char XY); 00123 00124 /* 00125 * Draw a calibration crosshair on the LCD screen 00126 * 00127 * @param x (horizontal position) 00128 * @param y (vertical position) 00129 * 00130 */ 00131 void DrawCross(unsigned int Xpos,unsigned int Ypos); 00132 00133 /* 00134 * Set the calibration matrix 00135 * 00136 * @param displayPTR (pointer to display data) 00137 * @param screenPTR (pointer to screen data) 00138 * @param matrixPTR (pointer to calibration matrix) 00139 * 00140 * @returns 0 when matrix.divider != 0 00141 * @returns 1 when matrix.divider = 0 00142 * 00143 */ 00144 unsigned char setCalibrationMatrix( Coordinate * displayPtr,Coordinate * screenPtr,Matrix * matrixPtr); 00145 00146 }; 00147 #endif
Generated on Tue Jul 12 2022 17:52:03 by 1.7.2