hello world
Dependencies: BSP_DISCO_F429ZI LCD_DISCO_F429ZI TS_DISCO_F429ZI mbed
main.cpp@0:be79e80adffc, 2018-07-03 (annotated)
- Committer:
- asifcse14
- Date:
- Tue Jul 03 06:50:43 2018 +0000
- Revision:
- 0:be79e80adffc
testing purpose
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
asifcse14 | 0:be79e80adffc | 1 | #include "mbed.h" |
asifcse14 | 0:be79e80adffc | 2 | #include "TS_DISCO_F429ZI.h" |
asifcse14 | 0:be79e80adffc | 3 | #include "LCD_DISCO_F429ZI.h" |
asifcse14 | 0:be79e80adffc | 4 | #include "math.h" |
asifcse14 | 0:be79e80adffc | 5 | #define PI 3.14159265 |
asifcse14 | 0:be79e80adffc | 6 | LCD_DISCO_F429ZI lcd; |
asifcse14 | 0:be79e80adffc | 7 | TS_DISCO_F429ZI ts; |
asifcse14 | 0:be79e80adffc | 8 | |
asifcse14 | 0:be79e80adffc | 9 | int main() |
asifcse14 | 0:be79e80adffc | 10 | { |
asifcse14 | 0:be79e80adffc | 11 | TS_StateTypeDef TS_State; |
asifcse14 | 0:be79e80adffc | 12 | uint16_t x, y; |
asifcse14 | 0:be79e80adffc | 13 | uint8_t text[30]; |
asifcse14 | 0:be79e80adffc | 14 | uint8_t status; |
asifcse14 | 0:be79e80adffc | 15 | int p = 0; |
asifcse14 | 0:be79e80adffc | 16 | BSP_LCD_SetFont(&Font20); |
asifcse14 | 0:be79e80adffc | 17 | |
asifcse14 | 0:be79e80adffc | 18 | //lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"Special Thanks", CENTER_MODE); |
asifcse14 | 0:be79e80adffc | 19 | //lcd.DisplayStringAt(0, LINE(6), (uint8_t *)"To", CENTER_MODE); |
asifcse14 | 0:be79e80adffc | 20 | //lcd.DisplayStringAt(0, LINE(7), (uint8_t *)"Ejaz Jamil Sir", CENTER_MODE); |
asifcse14 | 0:be79e80adffc | 21 | //wait(2); |
asifcse14 | 0:be79e80adffc | 22 | |
asifcse14 | 0:be79e80adffc | 23 | status = ts.Init(lcd.GetXSize(), lcd.GetYSize()); |
asifcse14 | 0:be79e80adffc | 24 | |
asifcse14 | 0:be79e80adffc | 25 | if (status != TS_OK) |
asifcse14 | 0:be79e80adffc | 26 | { |
asifcse14 | 0:be79e80adffc | 27 | lcd.Clear(LCD_COLOR_RED); |
asifcse14 | 0:be79e80adffc | 28 | lcd.SetBackColor(LCD_COLOR_RED); |
asifcse14 | 0:be79e80adffc | 29 | lcd.SetTextColor(LCD_COLOR_WHITE); |
asifcse14 | 0:be79e80adffc | 30 | lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN", CENTER_MODE); |
asifcse14 | 0:be79e80adffc | 31 | lcd.DisplayStringAt(0, LINE(6), (uint8_t *)"DRIVER FAIL", CENTER_MODE); |
asifcse14 | 0:be79e80adffc | 32 | } |
asifcse14 | 0:be79e80adffc | 33 | else |
asifcse14 | 0:be79e80adffc | 34 | { |
asifcse14 | 0:be79e80adffc | 35 | lcd.Clear(LCD_COLOR_GREEN); |
asifcse14 | 0:be79e80adffc | 36 | lcd.SetBackColor(LCD_COLOR_GREEN); |
asifcse14 | 0:be79e80adffc | 37 | lcd.SetTextColor(LCD_COLOR_WHITE); |
asifcse14 | 0:be79e80adffc | 38 | lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN", CENTER_MODE); |
asifcse14 | 0:be79e80adffc | 39 | lcd.DisplayStringAt(0, LINE(6), (uint8_t *)"DRIVER OK", CENTER_MODE); |
asifcse14 | 0:be79e80adffc | 40 | } |
asifcse14 | 0:be79e80adffc | 41 | |
asifcse14 | 0:be79e80adffc | 42 | //wait(2); |
asifcse14 | 0:be79e80adffc | 43 | |
asifcse14 | 0:be79e80adffc | 44 | |
asifcse14 | 0:be79e80adffc | 45 | lcd.Clear(LCD_COLOR_WHITE); |
asifcse14 | 0:be79e80adffc | 46 | lcd.SetBackColor(LCD_COLOR_WHITE); |
asifcse14 | 0:be79e80adffc | 47 | lcd.SetTextColor(LCD_COLOR_BLACK); |
asifcse14 | 0:be79e80adffc | 48 | |
asifcse14 | 0:be79e80adffc | 49 | BSP_LCD_SetFont(&Font24); |
asifcse14 | 0:be79e80adffc | 50 | lcd.DisplayStringAt(0, 10, (uint8_t *)"obaak App", CENTER_MODE); |
asifcse14 | 0:be79e80adffc | 51 | |
asifcse14 | 0:be79e80adffc | 52 | BSP_LCD_SetFont(&Font20); |
asifcse14 | 0:be79e80adffc | 53 | lcd.DisplayStringAt(0, 44, (uint8_t *)"Select Menu", CENTER_MODE); |
asifcse14 | 0:be79e80adffc | 54 | |
asifcse14 | 0:be79e80adffc | 55 | BSP_LCD_SetFont(&Font16); |
asifcse14 | 0:be79e80adffc | 56 | lcd.SetTextColor(LCD_COLOR_GREEN); |
asifcse14 | 0:be79e80adffc | 57 | lcd.FillRect(75, 83, 80, 30); |
asifcse14 | 0:be79e80adffc | 58 | lcd.SetBackColor(LCD_COLOR_GREEN); |
asifcse14 | 0:be79e80adffc | 59 | lcd.SetTextColor(LCD_COLOR_WHITE); |
asifcse14 | 0:be79e80adffc | 60 | lcd.DisplayStringAt(0, 90, (uint8_t *)"sin(x)", CENTER_MODE); |
asifcse14 | 0:be79e80adffc | 61 | |
asifcse14 | 0:be79e80adffc | 62 | BSP_LCD_SetFont(&Font16); |
asifcse14 | 0:be79e80adffc | 63 | lcd.SetTextColor(LCD_COLOR_GREEN); |
asifcse14 | 0:be79e80adffc | 64 | lcd.FillRect(75, 120, 80, 30); |
asifcse14 | 0:be79e80adffc | 65 | lcd.SetBackColor(LCD_COLOR_GREEN); |
asifcse14 | 0:be79e80adffc | 66 | lcd.SetTextColor(LCD_COLOR_WHITE); |
asifcse14 | 0:be79e80adffc | 67 | lcd.DisplayStringAt(0, 127, (uint8_t *)"cos(x)", CENTER_MODE); |
asifcse14 | 0:be79e80adffc | 68 | /* |
asifcse14 | 0:be79e80adffc | 69 | BSP_LCD_SetFont(&Font16); |
asifcse14 | 0:be79e80adffc | 70 | lcd.SetTextColor(LCD_COLOR_RED); |
asifcse14 | 0:be79e80adffc | 71 | lcd.FillRect(30, 160, 170, 30); |
asifcse14 | 0:be79e80adffc | 72 | lcd.SetBackColor(LCD_COLOR_RED); |
asifcse14 | 0:be79e80adffc | 73 | lcd.SetTextColor(LCD_COLOR_WHITE); |
asifcse14 | 0:be79e80adffc | 74 | lcd.DisplayStringAt(0, 167, (uint8_t *)"sin(x) & cos(x)", CENTER_MODE); |
asifcse14 | 0:be79e80adffc | 75 | */ |
asifcse14 | 0:be79e80adffc | 76 | BSP_LCD_SetFont(&Font16); |
asifcse14 | 0:be79e80adffc | 77 | lcd.SetTextColor(LCD_COLOR_BLUE); |
asifcse14 | 0:be79e80adffc | 78 | lcd.FillRect(75, 160, 80, 30); |
asifcse14 | 0:be79e80adffc | 79 | lcd.SetBackColor(LCD_COLOR_BLUE); |
asifcse14 | 0:be79e80adffc | 80 | lcd.SetTextColor(LCD_COLOR_WHITE); |
asifcse14 | 0:be79e80adffc | 81 | lcd.DisplayStringAt(0, 167, (uint8_t *)"ECG", CENTER_MODE); |
asifcse14 | 0:be79e80adffc | 82 | |
asifcse14 | 0:be79e80adffc | 83 | lcd.SetTextColor(LCD_COLOR_BLACK); |
asifcse14 | 0:be79e80adffc | 84 | lcd.DrawLine(10, 250, 30, 250); |
asifcse14 | 0:be79e80adffc | 85 | lcd.DrawLine(30, 250, 30, 270); |
asifcse14 | 0:be79e80adffc | 86 | lcd.DrawLine(30, 252, 15, 261); |
asifcse14 | 0:be79e80adffc | 87 | lcd.DrawLine(15, 261, 30, 270); |
asifcse14 | 0:be79e80adffc | 88 | lcd.DrawLine(30, 250, 35, 250); |
asifcse14 | 0:be79e80adffc | 89 | lcd.DrawLine(35, 250, 35, 270); |
asifcse14 | 0:be79e80adffc | 90 | lcd.DrawCircle(43, 255, 5); |
asifcse14 | 0:be79e80adffc | 91 | lcd.DrawLine(37, 261, 47, 270); |
asifcse14 | 0:be79e80adffc | 92 | |
asifcse14 | 0:be79e80adffc | 93 | lcd.DrawLine(50, 250, 70, 250); |
asifcse14 | 0:be79e80adffc | 94 | lcd.DrawLine(70, 250, 70, 270); |
asifcse14 | 0:be79e80adffc | 95 | //lcd.DrawLine(30, 252, 15, 261); |
asifcse14 | 0:be79e80adffc | 96 | //lcd.DrawLine(15, 261, 30, 270); |
asifcse14 | 0:be79e80adffc | 97 | lcd.DrawLine(70, 250, 75, 250); |
asifcse14 | 0:be79e80adffc | 98 | lcd.DrawLine(75, 250, 75, 270); |
asifcse14 | 0:be79e80adffc | 99 | //lcd.DrawPixel(64, 259, LCD_COLOR_RED); |
asifcse14 | 0:be79e80adffc | 100 | lcd.DrawPixel(69, 263, LCD_COLOR_BLACK); |
asifcse14 | 0:be79e80adffc | 101 | lcd.DrawPixel(68, 262, LCD_COLOR_BLACK); |
asifcse14 | 0:be79e80adffc | 102 | lcd.DrawPixel(67, 261, LCD_COLOR_BLACK); |
asifcse14 | 0:be79e80adffc | 103 | lcd.DrawPixel(66, 260, LCD_COLOR_BLACK); |
asifcse14 | 0:be79e80adffc | 104 | lcd.DrawPixel(65, 260, LCD_COLOR_BLACK); |
asifcse14 | 0:be79e80adffc | 105 | lcd.DrawPixel(64, 260, LCD_COLOR_BLACK); |
asifcse14 | 0:be79e80adffc | 106 | lcd.DrawPixel(63, 261, LCD_COLOR_BLACK); |
asifcse14 | 0:be79e80adffc | 107 | lcd.DrawPixel(62, 262, LCD_COLOR_BLACK); |
asifcse14 | 0:be79e80adffc | 108 | lcd.DrawPixel(61, 263, LCD_COLOR_BLACK); |
asifcse14 | 0:be79e80adffc | 109 | lcd.DrawLine(61, 263, 61, 267); |
asifcse14 | 0:be79e80adffc | 110 | lcd.DrawPixel(60, 263, LCD_COLOR_BLACK); |
asifcse14 | 0:be79e80adffc | 111 | lcd.DrawPixel(59, 262, LCD_COLOR_BLACK); |
asifcse14 | 0:be79e80adffc | 112 | lcd.DrawPixel(58, 261, LCD_COLOR_BLACK); |
asifcse14 | 0:be79e80adffc | 113 | lcd.DrawPixel(57, 260, LCD_COLOR_BLACK); |
asifcse14 | 0:be79e80adffc | 114 | lcd.DrawPixel(56, 260, LCD_COLOR_BLACK); |
asifcse14 | 0:be79e80adffc | 115 | lcd.DrawPixel(55, 260, LCD_COLOR_BLACK); |
asifcse14 | 0:be79e80adffc | 116 | lcd.DrawPixel(54, 261, LCD_COLOR_BLACK); |
asifcse14 | 0:be79e80adffc | 117 | lcd.DrawPixel(53, 262, LCD_COLOR_BLACK); |
asifcse14 | 0:be79e80adffc | 118 | lcd.DrawPixel(52, 263, LCD_COLOR_BLACK); |
asifcse14 | 0:be79e80adffc | 119 | lcd.DrawLine(52, 263, 52, 268); |
asifcse14 | 0:be79e80adffc | 120 | lcd.DrawCircle(54, 267, 2); |
asifcse14 | 0:be79e80adffc | 121 | |
asifcse14 | 0:be79e80adffc | 122 | lcd.DrawLine(75, 250, 85, 250); |
asifcse14 | 0:be79e80adffc | 123 | lcd.DrawPixel(84, 251, LCD_COLOR_BLACK); |
asifcse14 | 0:be79e80adffc | 124 | lcd.DrawPixel(83, 252, LCD_COLOR_BLACK); |
asifcse14 | 0:be79e80adffc | 125 | lcd.DrawPixel(82, 253, LCD_COLOR_BLACK); |
asifcse14 | 0:be79e80adffc | 126 | lcd.DrawPixel(81, 254, LCD_COLOR_BLACK); |
asifcse14 | 0:be79e80adffc | 127 | lcd.DrawPixel(80, 255, LCD_COLOR_BLACK); |
asifcse14 | 0:be79e80adffc | 128 | lcd.DrawPixel(79.5, 256, LCD_COLOR_BLACK); |
asifcse14 | 0:be79e80adffc | 129 | lcd.DrawPixel(79, 257, LCD_COLOR_BLACK); |
asifcse14 | 0:be79e80adffc | 130 | lcd.DrawPixel(78.5, 258, LCD_COLOR_BLACK); |
asifcse14 | 0:be79e80adffc | 131 | lcd.DrawPixel(78, 259, LCD_COLOR_BLACK); |
asifcse14 | 0:be79e80adffc | 132 | lcd.DrawPixel(77.5, 260, LCD_COLOR_BLACK); |
asifcse14 | 0:be79e80adffc | 133 | lcd.DrawPixel(77.5, 261, LCD_COLOR_BLACK); |
asifcse14 | 0:be79e80adffc | 134 | lcd.DrawPixel(78, 262, LCD_COLOR_BLACK); |
asifcse14 | 0:be79e80adffc | 135 | lcd.DrawPixel(78.5, 263, LCD_COLOR_BLACK); |
asifcse14 | 0:be79e80adffc | 136 | lcd.DrawPixel(79, 264, LCD_COLOR_BLACK); |
asifcse14 | 0:be79e80adffc | 137 | lcd.DrawPixel(79.5, 265, LCD_COLOR_BLACK); |
asifcse14 | 0:be79e80adffc | 138 | lcd.DrawPixel(80, 266, LCD_COLOR_BLACK); |
asifcse14 | 0:be79e80adffc | 139 | lcd.DrawPixel(81, 267, LCD_COLOR_BLACK); |
asifcse14 | 0:be79e80adffc | 140 | lcd.DrawPixel(82, 268, LCD_COLOR_BLACK); |
asifcse14 | 0:be79e80adffc | 141 | lcd.DrawPixel(83, 269, LCD_COLOR_BLACK); |
asifcse14 | 0:be79e80adffc | 142 | lcd.DrawPixel(84, 270, LCD_COLOR_BLACK); |
asifcse14 | 0:be79e80adffc | 143 | lcd.DrawCircle(86, 268, 2); |
asifcse14 | 0:be79e80adffc | 144 | |
asifcse14 | 0:be79e80adffc | 145 | while(1) |
asifcse14 | 0:be79e80adffc | 146 | { |
asifcse14 | 0:be79e80adffc | 147 | |
asifcse14 | 0:be79e80adffc | 148 | ts.GetState(&TS_State); |
asifcse14 | 0:be79e80adffc | 149 | if (TS_State.TouchDetected) |
asifcse14 | 0:be79e80adffc | 150 | { |
asifcse14 | 0:be79e80adffc | 151 | x = TS_State.X; |
asifcse14 | 0:be79e80adffc | 152 | y = TS_State.Y; |
asifcse14 | 0:be79e80adffc | 153 | if(x>74 && x<156){ |
asifcse14 | 0:be79e80adffc | 154 | if(y>82 && y<114){ |
asifcse14 | 0:be79e80adffc | 155 | //sin |
asifcse14 | 0:be79e80adffc | 156 | p = 1;break; |
asifcse14 | 0:be79e80adffc | 157 | } |
asifcse14 | 0:be79e80adffc | 158 | else if(y>119 && y<151){ |
asifcse14 | 0:be79e80adffc | 159 | //cos |
asifcse14 | 0:be79e80adffc | 160 | p = 2;break; |
asifcse14 | 0:be79e80adffc | 161 | } |
asifcse14 | 0:be79e80adffc | 162 | else if(y>159 && y<191){ |
asifcse14 | 0:be79e80adffc | 163 | //ecg |
asifcse14 | 0:be79e80adffc | 164 | p = 4;break; |
asifcse14 | 0:be79e80adffc | 165 | } |
asifcse14 | 0:be79e80adffc | 166 | }/*else if(x>29 && x<201 && y>159 && y<191){ |
asifcse14 | 0:be79e80adffc | 167 | //sin & cos |
asifcse14 | 0:be79e80adffc | 168 | p = 3;break; |
asifcse14 | 0:be79e80adffc | 169 | }*/ |
asifcse14 | 0:be79e80adffc | 170 | //sprintf((char*)text, "x=%d y=%d ", x, y); |
asifcse14 | 0:be79e80adffc | 171 | //lcd.DisplayStringAt(0, LINE(0), (uint8_t *)&text, LEFT_MODE); |
asifcse14 | 0:be79e80adffc | 172 | } |
asifcse14 | 0:be79e80adffc | 173 | } |
asifcse14 | 0:be79e80adffc | 174 | lcd.SetBackColor(LCD_COLOR_WHITE); |
asifcse14 | 0:be79e80adffc | 175 | if(p==1){ |
asifcse14 | 0:be79e80adffc | 176 | while(1){ |
asifcse14 | 0:be79e80adffc | 177 | lcd.Clear(LCD_COLOR_WHITE); |
asifcse14 | 0:be79e80adffc | 178 | |
asifcse14 | 0:be79e80adffc | 179 | lcd.SetTextColor(LCD_COLOR_BLUE); |
asifcse14 | 0:be79e80adffc | 180 | lcd.DrawLine(10, 50, 10, 200); |
asifcse14 | 0:be79e80adffc | 181 | //lcd.DrawLine(20, 0, 20, 320); |
asifcse14 | 0:be79e80adffc | 182 | //lcd.DrawLine(30, 0, 30, 320); |
asifcse14 | 0:be79e80adffc | 183 | lcd.DrawLine(10, 125, 235, 125); |
asifcse14 | 0:be79e80adffc | 184 | //lcd.DrawLine(0, 20, 240, 20); |
asifcse14 | 0:be79e80adffc | 185 | //lcd.DrawLine(0, 30, 240, 30); |
asifcse14 | 0:be79e80adffc | 186 | BSP_LCD_SetFont(&Font8); |
asifcse14 | 0:be79e80adffc | 187 | lcd.DisplayStringAt(0, 50, (uint8_t *)"+1", LEFT_MODE); |
asifcse14 | 0:be79e80adffc | 188 | lcd.DisplayStringAt(0, 123, (uint8_t *)" 0", LEFT_MODE); |
asifcse14 | 0:be79e80adffc | 189 | lcd.DisplayStringAt(0, 198, (uint8_t *)"-1", LEFT_MODE); |
asifcse14 | 0:be79e80adffc | 190 | |
asifcse14 | 0:be79e80adffc | 191 | double val, out; |
asifcse14 | 0:be79e80adffc | 192 | int b = 0; |
asifcse14 | 0:be79e80adffc | 193 | for(double y = 0; y<225; y=y+0.625){ |
asifcse14 | 0:be79e80adffc | 194 | val = PI / 180.0; |
asifcse14 | 0:be79e80adffc | 195 | val = val * b; |
asifcse14 | 0:be79e80adffc | 196 | out = sin(-val)*75.0; |
asifcse14 | 0:be79e80adffc | 197 | double temp = out*1.33*(-1); |
asifcse14 | 0:be79e80adffc | 198 | out+=125; |
asifcse14 | 0:be79e80adffc | 199 | double c = cos(val)*75.0; |
asifcse14 | 0:be79e80adffc | 200 | c+=125; |
asifcse14 | 0:be79e80adffc | 201 | double ttt = y + 10.0; |
asifcse14 | 0:be79e80adffc | 202 | lcd.DrawPixel(ttt, out, LCD_COLOR_RED); |
asifcse14 | 0:be79e80adffc | 203 | //lcd.DrawPixel(ttt, c, LCD_COLOR_RED); |
asifcse14 | 0:be79e80adffc | 204 | b++; |
asifcse14 | 0:be79e80adffc | 205 | BSP_LCD_SetFont(&Font12); |
asifcse14 | 0:be79e80adffc | 206 | uint8_t text[30]; |
asifcse14 | 0:be79e80adffc | 207 | sprintf((char*)text, "x:%d(deg) sin(x):%.2lf", b, temp/100); |
asifcse14 | 0:be79e80adffc | 208 | lcd.DisplayStringAt(0, 280, (uint8_t *)&text, LEFT_MODE); |
asifcse14 | 0:be79e80adffc | 209 | //x++; |
asifcse14 | 0:be79e80adffc | 210 | wait(0.1); |
asifcse14 | 0:be79e80adffc | 211 | b++; |
asifcse14 | 0:be79e80adffc | 212 | } |
asifcse14 | 0:be79e80adffc | 213 | wait(2); |
asifcse14 | 0:be79e80adffc | 214 | |
asifcse14 | 0:be79e80adffc | 215 | |
asifcse14 | 0:be79e80adffc | 216 | |
asifcse14 | 0:be79e80adffc | 217 | |
asifcse14 | 0:be79e80adffc | 218 | } |
asifcse14 | 0:be79e80adffc | 219 | }else if(p==2){ |
asifcse14 | 0:be79e80adffc | 220 | while(1){ |
asifcse14 | 0:be79e80adffc | 221 | lcd.Clear(LCD_COLOR_WHITE); |
asifcse14 | 0:be79e80adffc | 222 | |
asifcse14 | 0:be79e80adffc | 223 | lcd.SetTextColor(LCD_COLOR_BLUE); |
asifcse14 | 0:be79e80adffc | 224 | lcd.DrawLine(10, 50, 10, 200); |
asifcse14 | 0:be79e80adffc | 225 | //lcd.DrawLine(20, 0, 20, 320); |
asifcse14 | 0:be79e80adffc | 226 | //lcd.DrawLine(30, 0, 30, 320); |
asifcse14 | 0:be79e80adffc | 227 | lcd.DrawLine(10, 125, 235, 125); |
asifcse14 | 0:be79e80adffc | 228 | //lcd.DrawLine(0, 20, 240, 20); |
asifcse14 | 0:be79e80adffc | 229 | //lcd.DrawLine(0, 30, 240, 30); |
asifcse14 | 0:be79e80adffc | 230 | BSP_LCD_SetFont(&Font8); |
asifcse14 | 0:be79e80adffc | 231 | lcd.DisplayStringAt(0, 50, (uint8_t *)"+1", LEFT_MODE); |
asifcse14 | 0:be79e80adffc | 232 | lcd.DisplayStringAt(0, 123, (uint8_t *)" 0", LEFT_MODE); |
asifcse14 | 0:be79e80adffc | 233 | lcd.DisplayStringAt(0, 198, (uint8_t *)"-1", LEFT_MODE); |
asifcse14 | 0:be79e80adffc | 234 | |
asifcse14 | 0:be79e80adffc | 235 | double val, out; |
asifcse14 | 0:be79e80adffc | 236 | int b = 0; |
asifcse14 | 0:be79e80adffc | 237 | for(double y = 0; y<450; y=y+0.3125){ |
asifcse14 | 0:be79e80adffc | 238 | val = PI / 180.0; |
asifcse14 | 0:be79e80adffc | 239 | val = val * b; |
asifcse14 | 0:be79e80adffc | 240 | out = cos(val)*75.0*(-1); |
asifcse14 | 0:be79e80adffc | 241 | double temp = out*1.33*(-1); |
asifcse14 | 0:be79e80adffc | 242 | out+=125; |
asifcse14 | 0:be79e80adffc | 243 | double c = cos(val)*75.0; |
asifcse14 | 0:be79e80adffc | 244 | c+=125; |
asifcse14 | 0:be79e80adffc | 245 | double ttt = y + 10.0; |
asifcse14 | 0:be79e80adffc | 246 | lcd.DrawPixel(ttt, out, LCD_COLOR_RED); |
asifcse14 | 0:be79e80adffc | 247 | //lcd.DrawPixel(ttt, c, LCD_COLOR_RED); |
asifcse14 | 0:be79e80adffc | 248 | b++; |
asifcse14 | 0:be79e80adffc | 249 | BSP_LCD_SetFont(&Font12); |
asifcse14 | 0:be79e80adffc | 250 | uint8_t text[30]; |
asifcse14 | 0:be79e80adffc | 251 | sprintf((char*)text, "x:%d(deg) cos(x):%.2lf", b, temp/100); |
asifcse14 | 0:be79e80adffc | 252 | lcd.DisplayStringAt(0, 280, (uint8_t *)&text, LEFT_MODE); |
asifcse14 | 0:be79e80adffc | 253 | //x++; |
asifcse14 | 0:be79e80adffc | 254 | wait(0.1); |
asifcse14 | 0:be79e80adffc | 255 | b++; |
asifcse14 | 0:be79e80adffc | 256 | } |
asifcse14 | 0:be79e80adffc | 257 | wait(2); |
asifcse14 | 0:be79e80adffc | 258 | |
asifcse14 | 0:be79e80adffc | 259 | |
asifcse14 | 0:be79e80adffc | 260 | |
asifcse14 | 0:be79e80adffc | 261 | |
asifcse14 | 0:be79e80adffc | 262 | } |
asifcse14 | 0:be79e80adffc | 263 | }else if(p==3){ |
asifcse14 | 0:be79e80adffc | 264 | while(1){ |
asifcse14 | 0:be79e80adffc | 265 | |
asifcse14 | 0:be79e80adffc | 266 | } |
asifcse14 | 0:be79e80adffc | 267 | }else if(p==4){ |
asifcse14 | 0:be79e80adffc | 268 | // ECG Demo |
asifcse14 | 0:be79e80adffc | 269 | lcd.SetTextColor(LCD_COLOR_RED); |
asifcse14 | 0:be79e80adffc | 270 | while(1){ |
asifcse14 | 0:be79e80adffc | 271 | lcd.Clear(LCD_COLOR_WHITE); |
asifcse14 | 0:be79e80adffc | 272 | |
asifcse14 | 0:be79e80adffc | 273 | /* |
asifcse14 | 0:be79e80adffc | 274 | lcd.DrawLine(10, 160, 20, 160);lcd.DrawLine(10, 161, 20, 161);wait(0.1); |
asifcse14 | 0:be79e80adffc | 275 | lcd.DrawLine(20, 160, 45, 85);lcd.DrawLine(21, 160, 46, 85);wait(0.1); |
asifcse14 | 0:be79e80adffc | 276 | lcd.DrawLine(45, 85, 70, 235);lcd.DrawLine(46, 85, 71, 235);wait(0.1); |
asifcse14 | 0:be79e80adffc | 277 | lcd.DrawLine(70, 235, 95, 140);lcd.DrawLine(71, 235, 96, 140);wait(0.1); |
asifcse14 | 0:be79e80adffc | 278 | lcd.DrawLine(95, 140, 100, 170);lcd.DrawLine(96, 140, 101, 170);wait(0.1); |
asifcse14 | 0:be79e80adffc | 279 | lcd.DrawLine(100, 170, 105, 160);lcd.DrawLine(101, 170, 106, 160);wait(0.1); |
asifcse14 | 0:be79e80adffc | 280 | lcd.DrawLine( 105, 160, 115, 160);lcd.DrawLine( 106, 160, 116, 160);wait(0.1); |
asifcse14 | 0:be79e80adffc | 281 | |
asifcse14 | 0:be79e80adffc | 282 | lcd.DrawLine(10+105, 160, 20+105, 160);lcd.DrawLine(11+105, 161, 21+105, 161);wait(0.1); |
asifcse14 | 0:be79e80adffc | 283 | lcd.DrawLine(20+105, 160, 45+105, 85);lcd.DrawLine(21+105, 161, 46+105, 86);wait(0.1); |
asifcse14 | 0:be79e80adffc | 284 | lcd.DrawLine(45+105, 85, 70+105, 235);lcd.DrawLine(46+105, 86, 71+105, 236);wait(0.1); |
asifcse14 | 0:be79e80adffc | 285 | lcd.DrawLine(70+105, 235, 95+105, 140);lcd.DrawLine(71+105, 236, 96+105, 141);wait(0.1); |
asifcse14 | 0:be79e80adffc | 286 | lcd.DrawLine(95+105, 140, 100+105, 170);lcd.DrawLine(96, 141, 101, 171);wait(0.1); |
asifcse14 | 0:be79e80adffc | 287 | lcd.DrawLine(100+105, 170, 105+105, 160);lcd.DrawLine(101, 171, 106, 161);wait(0.1); |
asifcse14 | 0:be79e80adffc | 288 | lcd.DrawLine( 105+105, 160, 115+105, 160);lcd.DrawLine( 106, 161, 116, 161);wait(0.1); |
asifcse14 | 0:be79e80adffc | 289 | */ |
asifcse14 | 0:be79e80adffc | 290 | |
asifcse14 | 0:be79e80adffc | 291 | lcd.DrawLine(10, 160, 20, 160);wait(0.1); |
asifcse14 | 0:be79e80adffc | 292 | lcd.DrawLine(20, 160, 45, 85);wait(0.1); |
asifcse14 | 0:be79e80adffc | 293 | lcd.DrawLine(45, 85, 70, 235);wait(0.1); |
asifcse14 | 0:be79e80adffc | 294 | lcd.DrawLine(70, 235, 95, 140);wait(0.1); |
asifcse14 | 0:be79e80adffc | 295 | lcd.DrawLine(95, 140, 100, 170);wait(0.1); |
asifcse14 | 0:be79e80adffc | 296 | lcd.DrawLine(100, 170, 105, 160);wait(0.1); |
asifcse14 | 0:be79e80adffc | 297 | lcd.DrawLine( 105, 160, 115, 160);wait(0.1); |
asifcse14 | 0:be79e80adffc | 298 | |
asifcse14 | 0:be79e80adffc | 299 | lcd.DrawLine(10+105, 160, 20+105, 160);wait(0.1); |
asifcse14 | 0:be79e80adffc | 300 | lcd.DrawLine(20+105, 160, 45+105, 85);wait(0.1); |
asifcse14 | 0:be79e80adffc | 301 | lcd.DrawLine(45+105, 85, 70+105, 235);wait(0.1); |
asifcse14 | 0:be79e80adffc | 302 | lcd.DrawLine(70+105, 235, 95+105, 140);wait(0.1); |
asifcse14 | 0:be79e80adffc | 303 | lcd.DrawLine(95+105, 140, 100+105, 170);wait(0.1); |
asifcse14 | 0:be79e80adffc | 304 | lcd.DrawLine(100+105, 170, 105+105, 160);wait(0.1); |
asifcse14 | 0:be79e80adffc | 305 | lcd.DrawLine( 105+105, 160, 115+105, 160);wait(0.1); |
asifcse14 | 0:be79e80adffc | 306 | |
asifcse14 | 0:be79e80adffc | 307 | wait(0.5); |
asifcse14 | 0:be79e80adffc | 308 | |
asifcse14 | 0:be79e80adffc | 309 | } |
asifcse14 | 0:be79e80adffc | 310 | } |
asifcse14 | 0:be79e80adffc | 311 | } |