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-24
- Revision:
- 11:1da15361a35b
- Parent:
- 10:9d9b3b9b28b8
- Child:
- 13:e74e09de81e4
File content as of revision 11:1da15361a35b:
#include "stdio.h" #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(PTD6, PTD7, PTD5, 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 readX() { int delta = 0, xv1 = 0, xv2 = 0, k = 0; int temp1 = 0, temp2 = 0; AnalogIn yp(PTB3); AnalogIn ym(PTB2); DigitalOut xp(PTB0); DigitalOut xm(PTB1); 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 readY() { DigitalOut yp(PTB3); DigitalOut ym(PTB2); AnalogIn xp(PTB0); AnalogIn xm(PTB1); 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 - (320 * ((yv2) / 1 / 10 - 3000)) / 58300); // returns Y // return(yval); } void poll() { int xp,yp = 0; xp=readX(); yp=readY(); }