projets de S3 s4 2021
Dependencies: mbed TFT_fonts SPI_TFT_ILI9341
Diff: main.cpp
- Revision:
- 5:80791250acb2
- Parent:
- 4:87b40e5986e7
- Child:
- 6:13d0de9e679c
diff -r 87b40e5986e7 -r 80791250acb2 main.cpp --- a/main.cpp Thu Jan 10 03:48:37 2019 +0000 +++ b/main.cpp Thu Jan 10 04:31:29 2019 +0000 @@ -7,8 +7,8 @@ #define PIN_XP PTB3 -#define PIN_XM PTB2 -#define PIN_YP PTB1 +#define PIN_XM PTB1 +#define PIN_YP PTB2 #define PIN_YM PTB0 #define PIN_MOSI PTD2 #define PIN_MISO PTD3 @@ -49,118 +49,14 @@ return p; } -int Read_X(){ - AnalogIn _yp(PTB2); - AnalogIn _ym(PTB0); - DigitalOut _xp(PTB3); - DigitalOut _xm(PTB1); - //uint16_t x1=1; - //uint16_t x2=0; - int x1=1; - int x2=0; - _xp = 1; - _xm = 0; - wait_us(50); - //while(x1 != x2){ - x1 = _yp.read_u16(); - wait_us(50); - x2 = _yp.read_u16(); - wait_us(50); - //} - _xp=0; - return (x1+x2)/2; -} - -int Read_Y(){ - AnalogIn _xp(PTB3); - AnalogIn _xm(PTB1); - DigitalOut _yp(PTB2); - DigitalOut _ym(PTB0); - //uint16_t y1=1; - //uint16_t y2=0; - int y1=1; - int y2=0; - _yp = 1; - _ym = 0; - wait_us(50); - //while(y1 != y2){ - y1 = _xp.read_u16(); - wait_us(50); - y2 = _xp.read_u16(); - wait_us(50); - //} - _yp=0; - return (y1+y2)/2; -} - -int Read_Z1(){ - AnalogIn _ym(PTB0); - AnalogIn _xp(PTB3); - DigitalOut _yp(PTB2); - DigitalOut _xm(PTB1); - //uint16_t y1=1; - //uint16_t y2=0; - int y1=1; - int y2=0; - _yp = 1; - _xm = 0; - wait_us(50); - //while(y1 != y2){ - int z1 = _xp.read_u16(); - wait_us(50); - int z2 = _xp.read_u16(); - wait_us(50); - //} - _yp=0; - return (z1+z2)/2; -} - -int Read_Z2(){ - AnalogIn _ym(PTB0); - AnalogIn _xp(PTB3); - DigitalOut _yp(PTB2); - DigitalOut _xm(PTB1); - //uint16_t y1=1; - //uint16_t y2=0; - int y1=1; - int y2=0; - _yp = 1; - _xm = 0; - wait_us(50); - //while(y1 != y2){ - int z1 = _ym.read_u16(); - wait_us(50); - int z2 = _ym.read_u16(); - wait_us(50); - //} - _yp=0; - return (z1+z2)/2; -} - Point getPoint(){ - //PinName _yp, _ym, _xm, _xp; float z; - - //int y2 = Read_Y(); - int x2 = Read_X(); - int z1 = Read_Z1(); - int z2 = Read_Z2(); - - //int y2 = tft.readTouch(); - int y2 = tft.readTouch(PTB3, PTB1, PTB2, PTB0); - //int y2 = tft.readTouch(_yp,_ym,_xp,_xm); - /*int x2 = tft.readTouch(_xp,_xm,_yp,_ym); - int y1 = tft.readTouch(_yp,_ym,_xm,_xp); - int x1 = tft.readTouch(_xp,_xm,_ym,_yp); - int z2 = tft.readTouch(_yp,_xm,_ym,_xp); - int z1 = tft.readTouch(_yp,_xm,_xp,_ym);*/ - - //int y2 = 700; - //int x2 = 600; - //int z2 = 110; - //int z1 = 100; + int y2 = tft.readTouch(PTB3,PTB1,PTB2,PTB0); //a(analog),i(analog),n(digital),m(digital) + int x2 = tft.readTouch(PTB2,PTB0,PTB3,PTB1); + int z2 = tft.readTouch(PTB0,PTB3,PTB2,PTB1); + int z1 = tft.readTouch(PTB3,PTB0,PTB2,PTB1); if (z1!=0){ z = (float)z2/(float)z1; @@ -172,6 +68,7 @@ return point(x,y,z); } + int main(){ TFT.claim(stdout); // send stdout to the TFT display TFT.set_orientation(0);