Updated with option to return from BP screen to main screen, resolved screen navigation issues
Dependencies: SDFileSystem TFTLCD_8bit ds3231 program mbed
Fork of poc_dis_5 by
Diff: touch_modules.cpp
- Revision:
- 0:c47fb0c1bbf6
- Child:
- 1:8316c23ec6b9
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/touch_modules.cpp Tue Dec 27 10:30:48 2016 +0000 @@ -0,0 +1,234 @@ +#include "mbed.h" +#include "ili9325.h" +#include "lcd_base.h" +#include "display_modules.h" +#include "touch_modules.h" +InterruptIn Touch_D(PTD6); +int i; +unsigned int xt; +unsigned int yt; + + + +void touch1() //determining the touch co-ordinates +{ + xt = (X_MAX*readTouchX()/TOTAL1); + yt = (Y_MAX*readTouchY()/TOTAL1); + } + + +void detect_touch() // detect the touch //debounce +{ + +while(i==1) +{ + while(Touch_D)//touch detection + { + wait_ms(200); ///wait for debounce check + if (Touch_D) + { + Touch_D.fall(&touch1); //determine the touch co-ordinates + break; + } + DisableTouch(); + + } + } + } + + + +unsigned char touch_main() //determining the touch for home screen +{ + + unsigned char state; + + if ( ((xt >=35) && (xt<=100)) && ( (yt>= 135) && (yt<= 185) ) ) // GLC + { + + state=1; + } + + else if ( ((xt >=130) && (xt<=195)) && ( (yt>= 135) && (yt<= 185) ) ) // ECG + { + state=2; + + + } + else if ( ((xt >= 35) && (xt<=100)) && ( (yt>= 65) && (yt<= 118) ) ) // BP + { + state=3; + + } + else if ( ((xt >= 130) && (xt<=195)) && ( (yt>= 65) && (yt<= 118) ) ) // SET + { + state=4; + + } + + return state; + } + + + +unsigned char touch_ecg() // determining the touch for ecg screen +{ + + unsigned char state; +if ( ((xt >=28) && (xt<=125)) && ( (yt>= 225) && (yt<= 285) ) ) // home screen + { + + state=5; + } + + if ( ((xt >=35) && (xt<=100)) && ( (yt>= 135) && (yt<= 185) ) ) // SET + { + state=6; + + } + + else if ( ((xt >=150) && (xt<=195)) && ( (yt>= 80) && (yt<= 190) ) ) // start + { + state=7; + } + + else if ( ((xt >= 35) && (xt<=100)) && ( (yt>= 65) && (yt<= 118) ) ) // history + { + state=8; + + } + + return state; + } + + + +unsigned char touch_bp() // //determining the touch for bp screen + +{ + unsigned char state; +if ( ((xt >=28) && (xt<=125)) && ( (yt>= 225) && (yt<= 285) ) ) + { + state=1; + + } + + else if ( ((xt >=35) && (xt<=100)) && ( (yt>= 135) && (yt<= 185) ) ) + { + + state=2; + + } + + else if ( ((xt >=130) && (xt<=195)) && ( (yt>= 135) && (yt<= 185) ) ) + { + state=3; + + + } + else if ( ((xt >= 35) && (xt<=100)) && ( (yt>= 65) && (yt<= 118) ) ) + { + state=4; + + } + else if ( ((xt >= 130) && (xt<=195)) && ( (yt>= 65) && (yt<= 118) ) ) + { + state=5; + + } + + + return state; + } + + + +unsigned char touch_glc() ////determining the touch for home screen + { + unsigned char state; +if ( ((xt >=28) && (xt<=125)) && ( (yt>= 225) && (yt<= 285) ) ) + { + state=1; + } + + else if ( ((xt >=35) && (xt<=100)) && ( (yt>= 135) && (yt<= 185) ) ) + { + + state=2; + + } + + else if ( ((xt >=130) && (xt<=195)) && ( (yt>= 135) && (yt<= 185) ) ) + { + state=3; + + + } + else if ( ((xt >= 35) && (xt<=100)) && ( (yt>= 65) && (yt<= 118) ) ) + { + state=4; + + } + else if ( ((xt >= 130) && (xt<=195)) && ( (yt>= 65) && (yt<= 118) ) ) // SET + { + state=5; + + } + + + return state; + } + + + + +int readTouchY(void) { + DigitalOut YD(PTD6); + DigitalIn XL(PTD7); + DigitalOut YU(PTC0); + YU = 1; + YD = 0; + AnalogIn XR(PTB0); + XL.mode(PullNone); + return XR.read_u16(); +} + +int readTouchX(void) { + DigitalOut XR(PTB0); + DigitalIn YD(PTD6); + DigitalOut XL(PTD7); + + XR = 1; + XL = 0; + AnalogIn YU(PTC0); + YD.mode(PullNone); + return YU.read_u16(); +} + +void EnableTouch(void){ + + DigitalIn YD(PTD6); + DigitalOut XL(PTD7); + DigitalIn YU(PTC0); + DigitalIn XR(PTB0); + XL=0; + YD.mode(PullUp); + YU.mode(PullNone); + XR.mode(PullNone); + i=1; + Touch_D.fall(&touch1); + Touch_D.enable_irq(); + + } +void DisableTouch (void){ + Touch_D.disable_irq(); + i=0; + DigitalOut YD(PTD6); + DigitalOut XL(PTD7); + DigitalOut YU(PTC0); + DigitalOut XR(PTB0); + } + + + + \ No newline at end of file