![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Started a gui menuflow
Dependencies: LCD_DISCO_F429ZI mbed TS_DISCO_F429ZI BSP_DISCO_F429ZI
Touch.cpp@3:b029a3f73a9e, 2020-06-11 (annotated)
- Committer:
- ahaas92
- Date:
- Thu Jun 11 22:55:06 2020 +0000
- Revision:
- 3:b029a3f73a9e
Init of gui structure ;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ahaas92 | 3:b029a3f73a9e | 1 | #include "Touch.h" |
ahaas92 | 3:b029a3f73a9e | 2 | #include "main.h" |
ahaas92 | 3:b029a3f73a9e | 3 | #include "Screens.h" |
ahaas92 | 3:b029a3f73a9e | 4 | |
ahaas92 | 3:b029a3f73a9e | 5 | // in Bigbutton position same as draw big button position |
ahaas92 | 3:b029a3f73a9e | 6 | // out 1 touch detected 0 no touch detected |
ahaas92 | 3:b029a3f73a9e | 7 | |
ahaas92 | 3:b029a3f73a9e | 8 | uint16_t x, y = 0; |
ahaas92 | 3:b029a3f73a9e | 9 | uint16_t touch_x, touch_y = 0; |
ahaas92 | 3:b029a3f73a9e | 10 | bool press_detected = false; |
ahaas92 | 3:b029a3f73a9e | 11 | |
ahaas92 | 3:b029a3f73a9e | 12 | TS_StateTypeDef TS_State; |
ahaas92 | 3:b029a3f73a9e | 13 | TS_StateTypeDef Old_TS_State; |
ahaas92 | 3:b029a3f73a9e | 14 | |
ahaas92 | 3:b029a3f73a9e | 15 | void CheckTs() |
ahaas92 | 3:b029a3f73a9e | 16 | { |
ahaas92 | 3:b029a3f73a9e | 17 | ts.GetState(&TS_State); |
ahaas92 | 3:b029a3f73a9e | 18 | if (TS_State.TouchDetected) |
ahaas92 | 3:b029a3f73a9e | 19 | { |
ahaas92 | 3:b029a3f73a9e | 20 | x = TS_State.X; |
ahaas92 | 3:b029a3f73a9e | 21 | y = TS_State.Y; |
ahaas92 | 3:b029a3f73a9e | 22 | } |
ahaas92 | 3:b029a3f73a9e | 23 | if ((Old_TS_State.TouchDetected) && (!TS_State.TouchDetected)) |
ahaas92 | 3:b029a3f73a9e | 24 | { |
ahaas92 | 3:b029a3f73a9e | 25 | touch_x = x; |
ahaas92 | 3:b029a3f73a9e | 26 | touch_y = y; |
ahaas92 | 3:b029a3f73a9e | 27 | press_detected = true; |
ahaas92 | 3:b029a3f73a9e | 28 | } |
ahaas92 | 3:b029a3f73a9e | 29 | Old_TS_State = TS_State; |
ahaas92 | 3:b029a3f73a9e | 30 | } |
ahaas92 | 3:b029a3f73a9e | 31 | |
ahaas92 | 3:b029a3f73a9e | 32 | |
ahaas92 | 3:b029a3f73a9e | 33 | bool CheckBigButtonTouch (uint8_t position) |
ahaas92 | 3:b029a3f73a9e | 34 | { |
ahaas92 | 3:b029a3f73a9e | 35 | bool result = false; |
ahaas92 | 3:b029a3f73a9e | 36 | if((touch_x >= BigButtonX) && (touch_x<=(BigButtonX + BigButtonWidth))) |
ahaas92 | 3:b029a3f73a9e | 37 | { |
ahaas92 | 3:b029a3f73a9e | 38 | switch(position) |
ahaas92 | 3:b029a3f73a9e | 39 | { |
ahaas92 | 3:b029a3f73a9e | 40 | case 1: |
ahaas92 | 3:b029a3f73a9e | 41 | if((touch_y >= BigButton1Y)&&(touch_y <= (BigButton1Y+BigButtonHeight))) |
ahaas92 | 3:b029a3f73a9e | 42 | { |
ahaas92 | 3:b029a3f73a9e | 43 | result = true; |
ahaas92 | 3:b029a3f73a9e | 44 | press_detected = false; |
ahaas92 | 3:b029a3f73a9e | 45 | } |
ahaas92 | 3:b029a3f73a9e | 46 | break; |
ahaas92 | 3:b029a3f73a9e | 47 | case 2: |
ahaas92 | 3:b029a3f73a9e | 48 | if((touch_y >= BigButton1Y)&&(touch_y <= (BigButton2Y+BigButtonHeight))) |
ahaas92 | 3:b029a3f73a9e | 49 | { |
ahaas92 | 3:b029a3f73a9e | 50 | result = true; |
ahaas92 | 3:b029a3f73a9e | 51 | press_detected = false; |
ahaas92 | 3:b029a3f73a9e | 52 | } |
ahaas92 | 3:b029a3f73a9e | 53 | break; |
ahaas92 | 3:b029a3f73a9e | 54 | case 3: |
ahaas92 | 3:b029a3f73a9e | 55 | if((touch_y >= BigButton3Y)&&(touch_y <= (BigButton3Y+BigButtonHeight))) |
ahaas92 | 3:b029a3f73a9e | 56 | { |
ahaas92 | 3:b029a3f73a9e | 57 | result = true; |
ahaas92 | 3:b029a3f73a9e | 58 | press_detected = false; |
ahaas92 | 3:b029a3f73a9e | 59 | } |
ahaas92 | 3:b029a3f73a9e | 60 | break; |
ahaas92 | 3:b029a3f73a9e | 61 | case 4: |
ahaas92 | 3:b029a3f73a9e | 62 | if((touch_y >= BigButton4Y)&&(touch_y <= (BigButton4Y+BigButtonHeight))) |
ahaas92 | 3:b029a3f73a9e | 63 | { |
ahaas92 | 3:b029a3f73a9e | 64 | result = true; |
ahaas92 | 3:b029a3f73a9e | 65 | press_detected = false; |
ahaas92 | 3:b029a3f73a9e | 66 | } |
ahaas92 | 3:b029a3f73a9e | 67 | break; |
ahaas92 | 3:b029a3f73a9e | 68 | |
ahaas92 | 3:b029a3f73a9e | 69 | } |
ahaas92 | 3:b029a3f73a9e | 70 | } |
ahaas92 | 3:b029a3f73a9e | 71 | |
ahaas92 | 3:b029a3f73a9e | 72 | return result; |
ahaas92 | 3:b029a3f73a9e | 73 | } |
ahaas92 | 3:b029a3f73a9e | 74 | |
ahaas92 | 3:b029a3f73a9e | 75 | void CheckPress(ScreenState screen) |
ahaas92 | 3:b029a3f73a9e | 76 | { |
ahaas92 | 3:b029a3f73a9e | 77 | if(press_detected) |
ahaas92 | 3:b029a3f73a9e | 78 | { |
ahaas92 | 3:b029a3f73a9e | 79 | switch(screen) |
ahaas92 | 3:b029a3f73a9e | 80 | { |
ahaas92 | 3:b029a3f73a9e | 81 | case StartUp: |
ahaas92 | 3:b029a3f73a9e | 82 | //Mode Cpap |
ahaas92 | 3:b029a3f73a9e | 83 | if(CheckBigButtonTouch(1)) |
ahaas92 | 3:b029a3f73a9e | 84 | { |
ahaas92 | 3:b029a3f73a9e | 85 | display_screen = CPAPMain; |
ahaas92 | 3:b029a3f73a9e | 86 | refreshScreen = true; |
ahaas92 | 3:b029a3f73a9e | 87 | break; |
ahaas92 | 3:b029a3f73a9e | 88 | } |
ahaas92 | 3:b029a3f73a9e | 89 | // Mode niv |
ahaas92 | 3:b029a3f73a9e | 90 | if(CheckBigButtonTouch (2)) |
ahaas92 | 3:b029a3f73a9e | 91 | { |
ahaas92 | 3:b029a3f73a9e | 92 | display_screen = NIVMain; |
ahaas92 | 3:b029a3f73a9e | 93 | refreshScreen = true; |
ahaas92 | 3:b029a3f73a9e | 94 | break; |
ahaas92 | 3:b029a3f73a9e | 95 | } |
ahaas92 | 3:b029a3f73a9e | 96 | break; |
ahaas92 | 3:b029a3f73a9e | 97 | case CPAPMain : |
ahaas92 | 3:b029a3f73a9e | 98 | //Mode Cpap |
ahaas92 | 3:b029a3f73a9e | 99 | if(CheckBigButtonTouch(1)) |
ahaas92 | 3:b029a3f73a9e | 100 | { |
ahaas92 | 3:b029a3f73a9e | 101 | display_screen = CPAPRunning; // Start CPAP |
ahaas92 | 3:b029a3f73a9e | 102 | refreshScreen = true; |
ahaas92 | 3:b029a3f73a9e | 103 | break; |
ahaas92 | 3:b029a3f73a9e | 104 | } |
ahaas92 | 3:b029a3f73a9e | 105 | // Mode niv |
ahaas92 | 3:b029a3f73a9e | 106 | if(CheckBigButtonTouch (2)) // Settings CPAP |
ahaas92 | 3:b029a3f73a9e | 107 | { |
ahaas92 | 3:b029a3f73a9e | 108 | display_screen = CPAPSettingsMain; |
ahaas92 | 3:b029a3f73a9e | 109 | refreshScreen = true; |
ahaas92 | 3:b029a3f73a9e | 110 | break; |
ahaas92 | 3:b029a3f73a9e | 111 | } |
ahaas92 | 3:b029a3f73a9e | 112 | if(CheckBigButtonTouch (3)) |
ahaas92 | 3:b029a3f73a9e | 113 | { |
ahaas92 | 3:b029a3f73a9e | 114 | display_screen = StartUp; // Back to main screen |
ahaas92 | 3:b029a3f73a9e | 115 | refreshScreen = true; |
ahaas92 | 3:b029a3f73a9e | 116 | break; |
ahaas92 | 3:b029a3f73a9e | 117 | } |
ahaas92 | 3:b029a3f73a9e | 118 | break; |
ahaas92 | 3:b029a3f73a9e | 119 | case NIVMain : |
ahaas92 | 3:b029a3f73a9e | 120 | if(CheckBigButtonTouch(1)) |
ahaas92 | 3:b029a3f73a9e | 121 | { |
ahaas92 | 3:b029a3f73a9e | 122 | display_screen = NIVRunning; // Start NIV |
ahaas92 | 3:b029a3f73a9e | 123 | refreshScreen = true; |
ahaas92 | 3:b029a3f73a9e | 124 | break; |
ahaas92 | 3:b029a3f73a9e | 125 | } |
ahaas92 | 3:b029a3f73a9e | 126 | // Mode niv |
ahaas92 | 3:b029a3f73a9e | 127 | if(CheckBigButtonTouch (2)) // Settings NIV |
ahaas92 | 3:b029a3f73a9e | 128 | { |
ahaas92 | 3:b029a3f73a9e | 129 | display_screen = NIVSettingsMain; |
ahaas92 | 3:b029a3f73a9e | 130 | refreshScreen = true; |
ahaas92 | 3:b029a3f73a9e | 131 | break; |
ahaas92 | 3:b029a3f73a9e | 132 | } |
ahaas92 | 3:b029a3f73a9e | 133 | if(CheckBigButtonTouch (3)) // Back |
ahaas92 | 3:b029a3f73a9e | 134 | { |
ahaas92 | 3:b029a3f73a9e | 135 | display_screen = StartUp; // Back to main screen |
ahaas92 | 3:b029a3f73a9e | 136 | refreshScreen = true; |
ahaas92 | 3:b029a3f73a9e | 137 | break; |
ahaas92 | 3:b029a3f73a9e | 138 | } |
ahaas92 | 3:b029a3f73a9e | 139 | break; |
ahaas92 | 3:b029a3f73a9e | 140 | case CPAPRunning: |
ahaas92 | 3:b029a3f73a9e | 141 | break; |
ahaas92 | 3:b029a3f73a9e | 142 | case CPAPSettingsMain: |
ahaas92 | 3:b029a3f73a9e | 143 | if(CheckBigButtonTouch(1)) |
ahaas92 | 3:b029a3f73a9e | 144 | { |
ahaas92 | 3:b029a3f73a9e | 145 | //display_screen = NIVRunning; // Start NIV |
ahaas92 | 3:b029a3f73a9e | 146 | refreshScreen = true; |
ahaas92 | 3:b029a3f73a9e | 147 | break; |
ahaas92 | 3:b029a3f73a9e | 148 | } |
ahaas92 | 3:b029a3f73a9e | 149 | // Mode niv |
ahaas92 | 3:b029a3f73a9e | 150 | if(CheckBigButtonTouch (2)) // Settings NIV |
ahaas92 | 3:b029a3f73a9e | 151 | { |
ahaas92 | 3:b029a3f73a9e | 152 | //display_screen = NIVSettingsMain; |
ahaas92 | 3:b029a3f73a9e | 153 | refreshScreen = true; |
ahaas92 | 3:b029a3f73a9e | 154 | break; |
ahaas92 | 3:b029a3f73a9e | 155 | } |
ahaas92 | 3:b029a3f73a9e | 156 | if(CheckBigButtonTouch (4)) // Back |
ahaas92 | 3:b029a3f73a9e | 157 | { |
ahaas92 | 3:b029a3f73a9e | 158 | display_screen = CPAPMain; // Back to main screen |
ahaas92 | 3:b029a3f73a9e | 159 | refreshScreen = true; |
ahaas92 | 3:b029a3f73a9e | 160 | break; |
ahaas92 | 3:b029a3f73a9e | 161 | } |
ahaas92 | 3:b029a3f73a9e | 162 | break; |
ahaas92 | 3:b029a3f73a9e | 163 | case CPAPSettingsDetailView: |
ahaas92 | 3:b029a3f73a9e | 164 | break; |
ahaas92 | 3:b029a3f73a9e | 165 | case NIVRunning: |
ahaas92 | 3:b029a3f73a9e | 166 | break; |
ahaas92 | 3:b029a3f73a9e | 167 | case NIVSettingsMain: |
ahaas92 | 3:b029a3f73a9e | 168 | break; |
ahaas92 | 3:b029a3f73a9e | 169 | case NIVSettingsDetailView: |
ahaas92 | 3:b029a3f73a9e | 170 | break; |
ahaas92 | 3:b029a3f73a9e | 171 | default: |
ahaas92 | 3:b029a3f73a9e | 172 | break; |
ahaas92 | 3:b029a3f73a9e | 173 | } |
ahaas92 | 3:b029a3f73a9e | 174 | } |
ahaas92 | 3:b029a3f73a9e | 175 | |
ahaas92 | 3:b029a3f73a9e | 176 | } |