Contains the main execution of the clock uses headers to import functions
Dependencies: RTC-DS1307 SPI_TFT_ILI9341 TFT_fonts mbed tsi_sensor
Fork of TFT_Mikroelectronika_IL9341_sketchpad by
poll.h
- Committer:
- mlin
- Date:
- 2017-05-25
- Revision:
- 31:3255668e6b08
- Parent:
- 13:e74e09de81e4
- Child:
- 40:05798eeadd02
File content as of revision 31:3255668e6b08:
#include "stdio.h" #define PinXm A1 #define PinXp A0 #define PinYm A3 #define PinYp A2 #include "SPI_TFT_ILI9341.h" // example to test the TFT Display from Mikroelectronika // the display has a backlight switch on board //DigitalOut LCD_LED(PTA4); // may not be needed on mikroelectronika board //DigitalOut pwr(PTD7); // ditto // the TFT is connected to SPI pin 5-7 //SPI_TFT_ILI9341 TFT(p5, p6, p7, p8, p9, p10,"TFT"); // mosi, miso, sclk, cs, reset, dc for lpc1768 SPI_TFT_ILI9341 TFT(PTA16, PTA17, PTA15, PTD2, PTD4, PTA13, "TFT"); // mosi, miso, sclk, cs, reset, dc for frdmkl25z //NB better combination to use a coherent 2x4 block for lcd // SPI_TFT_ILI9341 TFT(PTD2, PTD3, PTD1, PTA16, PTA17, PTC16,"TFT"); // mosi, miso, sclk, cs, reset, dc for frdmkl25z // DigitalOut LCD_LED(PTC17); int touching = 0; // Subroutine to read the x location of the touch point // need to set x+ to 3V and ground x- then read analogue voltage on ym //nb need to add a check for actual touch as opposed to random crap int readY() { int delta = 0, xv1 = 0, xv2 = 0, k = 0; int temp1 = 0, temp2 = 0; AnalogIn yp(PinYp); AnalogIn ym(PinYm); DigitalOut xp(PinXp); DigitalOut xm(PinXm); xp = 1; // set positive side of x high xm = 0; // dont need to do anyhting to set low side as it should be fine. // but do need to disconnect yp //yp.PinMode(PullNone) delta = 0; for(k = 0; k < 10; k++) { // make 10 readings to average temp1 = (int)ym.read_u16(); temp2 = (int)yp.read_u16(); xv1 += temp1; // get value xv2 += temp2; // get other value delta += abs(temp1 - temp2) / 10; //gets individual differences // pc.printf("val1 = %d - val2 = %d-diff = %d\n\r",temp1,temp2,temp1-temp2); //observing behaviour when touching / nt touching } //delta=abs(xv2-xv1)/10; if(delta < 300) touching = 1; else touching = 0; //pc.printf("delta=%d \t %d\n\r",delta,touching); xp = 0; xm = 0; return (240 - (240 * ((xv2) / 1 / 10 - 5800)) / 51200); //returns the average of both //return(xv2/10); //maybe better to return the average of both.... } // subroutine to read y values - has different pin functions .. int readX() { DigitalOut yp(PinYp); DigitalOut ym(PinYm); AnalogIn xp(PinXp); AnalogIn xm(PinXm); int delta = 0, yv1 = 0, yv2 = 0, k = 0; int temp1 = 0, temp2 = 0; yp = 1; // set positive sdie of x high ym = 0; // dont need to do anyhting to set low side as it should be fine. // but do need to disconnect yp //yp.PinMode(PullNone) delta = 0; for(k = 0; k < 10; k++) { // make 10 readings to average temp1 = (int)xm.read_u16(); temp2 = (int)xp.read_u16(); yv1 += temp1; // get value yv2 += temp2; // get other value delta += abs(temp1 - temp2) / 10; //pc.printf("val1 = %d - val2 = %d-diff = %d\n\r",temp1,temp2,temp1-temp2); } //int yval=(int)xm.read_u16(); // get value //pc.printf("yval=%d",yval); yp = 0; ym = 0; return ((320 * ((yv2) / 1 / 10 - 3000)) / 58300); // returns X // return(yval); } void poll() { int xp,yp = 0; xp=readX(); yp=readY(); }