TEST

Dependencies:   max32630fthr Adafruit_FeatherOLED USBDevice

Committer:
gmehmet
Date:
Wed Apr 10 14:56:25 2019 +0300
Revision:
1:f60eafbf009a
Child:
3:2fe2ff1ca0dc
upload from local

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gmehmet 1:f60eafbf009a 1 /*
gmehmet 1:f60eafbf009a 2 * WatchInterface.cpp
gmehmet 1:f60eafbf009a 3 *
gmehmet 1:f60eafbf009a 4 * Created on: Aug 28, 2018
gmehmet 1:f60eafbf009a 5 * Author: Gokhan.Bektas
gmehmet 1:f60eafbf009a 6 */
gmehmet 1:f60eafbf009a 7
gmehmet 1:f60eafbf009a 8
gmehmet 1:f60eafbf009a 9
gmehmet 1:f60eafbf009a 10 #include "WatchInterface.h"
gmehmet 1:f60eafbf009a 11 #include "Peripherals.h"
gmehmet 1:f60eafbf009a 12 #include "LS013B7DH03.h"
gmehmet 1:f60eafbf009a 13 #include "mbed_logo.h"
gmehmet 1:f60eafbf009a 14
gmehmet 1:f60eafbf009a 15 #include "UbuntuCondensed38x47.h"
gmehmet 1:f60eafbf009a 16 #include "ubuntucondensed20x26.h"
gmehmet 1:f60eafbf009a 17 #include "ubuntucondensed16x21.h"
gmehmet 1:f60eafbf009a 18 #include "Arial10x10.h"
gmehmet 1:f60eafbf009a 19 #include "Neu44x36.h"
gmehmet 1:f60eafbf009a 20 #include "mxm_assert.h"
gmehmet 1:f60eafbf009a 21 #include "utils.h"
gmehmet 1:f60eafbf009a 22 #include "../version.h"
gmehmet 1:f60eafbf009a 23
gmehmet 1:f60eafbf009a 24 //Non-const static members must be both declared in the class definition and defined with global scope to properly give the linker something to reference.
gmehmet 1:f60eafbf009a 25 bool WatchInterface::refreshed = true;
gmehmet 1:f60eafbf009a 26
gmehmet 1:f60eafbf009a 27
gmehmet 1:f60eafbf009a 28 WatchInterface::WatchInterface(PinName buttonUp, PinName buttonDown, PinName buttonPower, PinName displayCS, PinName displayEXTCOM, PinName displayDISP, SPI* displaySPI):
gmehmet 1:f60eafbf009a 29 btnUp(buttonUp), btnDown(buttonDown), btnPower(buttonPower), dispCS(displayCS), dispEXTCOM(displayEXTCOM), dispDISP(displayDISP), display(displaySPI, &dispCS), DisplayPWM(displayEXTCOM)
gmehmet 1:f60eafbf009a 30 {
gmehmet 1:f60eafbf009a 31 dispDISP = 0;
gmehmet 1:f60eafbf009a 32
gmehmet 1:f60eafbf009a 33
gmehmet 1:f60eafbf009a 34 buttonEvent_up = BUTTONEVENT_NONE;
gmehmet 1:f60eafbf009a 35 buttonEvent_down = BUTTONEVENT_NONE;
gmehmet 1:f60eafbf009a 36
gmehmet 1:f60eafbf009a 37
gmehmet 1:f60eafbf009a 38 btnUp.fall(callback(this, &WatchInterface::isr_buttonup));
gmehmet 1:f60eafbf009a 39 btnUp.mode(PullUp);
gmehmet 1:f60eafbf009a 40 btnUp.enable_irq();
gmehmet 1:f60eafbf009a 41
gmehmet 1:f60eafbf009a 42 btnDown.fall(callback(this, &WatchInterface::isr_buttondown));
gmehmet 1:f60eafbf009a 43 btnDown.mode(PullUp);
gmehmet 1:f60eafbf009a 44 btnDown.enable_irq();
gmehmet 1:f60eafbf009a 45
gmehmet 1:f60eafbf009a 46 displaySPI->frequency(1000000);
gmehmet 1:f60eafbf009a 47
gmehmet 1:f60eafbf009a 48 DisplayPWM.period_ms(16);
gmehmet 1:f60eafbf009a 49 DisplayPWM.pulsewidth_ms(8);
gmehmet 1:f60eafbf009a 50
gmehmet 1:f60eafbf009a 51 //updateDisplay(4);
gmehmet 1:f60eafbf009a 52
gmehmet 1:f60eafbf009a 53 recording_old = false;
gmehmet 1:f60eafbf009a 54 recording = false;
gmehmet 1:f60eafbf009a 55 recordingStopFlag = false;
gmehmet 1:f60eafbf009a 56 isDisplayOff = false;
gmehmet 1:f60eafbf009a 57
gmehmet 1:f60eafbf009a 58 interfaceTimer.start();
gmehmet 1:f60eafbf009a 59
gmehmet 1:f60eafbf009a 60 displayMode_old = DISPLAYMODE_AFTERBOOT;
gmehmet 1:f60eafbf009a 61 displayMode = DISPLAYMODE_TIME;
gmehmet 1:f60eafbf009a 62
gmehmet 1:f60eafbf009a 63
gmehmet 1:f60eafbf009a 64
gmehmet 1:f60eafbf009a 65 }
gmehmet 1:f60eafbf009a 66
gmehmet 1:f60eafbf009a 67 void WatchInterface::isr_buttonup()
gmehmet 1:f60eafbf009a 68 {
gmehmet 1:f60eafbf009a 69 if (buttonEvent_up == BUTTONEVENT_NONE) {
gmehmet 1:f60eafbf009a 70 buttonEvent_up = BUTTONEVENT_UP_PRE;
gmehmet 1:f60eafbf009a 71 }
gmehmet 1:f60eafbf009a 72 }
gmehmet 1:f60eafbf009a 73
gmehmet 1:f60eafbf009a 74 void WatchInterface::isr_buttondown()
gmehmet 1:f60eafbf009a 75 {
gmehmet 1:f60eafbf009a 76 if (buttonEvent_down == BUTTONEVENT_NONE) {
gmehmet 1:f60eafbf009a 77 buttonEvent_down = BUTTONEVENT_DOWN_PRE;
gmehmet 1:f60eafbf009a 78 }
gmehmet 1:f60eafbf009a 79 }
gmehmet 1:f60eafbf009a 80
gmehmet 1:f60eafbf009a 81 WatchInterface::ButtonStatus WatchInterface::getButtonStatus(WatchInterface::hspButton button)
gmehmet 1:f60eafbf009a 82 {
gmehmet 1:f60eafbf009a 83
gmehmet 1:f60eafbf009a 84 switch (button) {
gmehmet 1:f60eafbf009a 85
gmehmet 1:f60eafbf009a 86 // TODO: fill button power status
gmehmet 1:f60eafbf009a 87 case WatchInterface::BUTTON_POWER :
gmehmet 1:f60eafbf009a 88 return (BUTTON_RELEASED);
gmehmet 1:f60eafbf009a 89 break;
gmehmet 1:f60eafbf009a 90 case WatchInterface::BUTTON_UP:
gmehmet 1:f60eafbf009a 91 if (btnUp.read()) {
gmehmet 1:f60eafbf009a 92 return (WatchInterface::BUTTON_PRESSED);
gmehmet 1:f60eafbf009a 93 } else {
gmehmet 1:f60eafbf009a 94 return (WatchInterface::BUTTON_RELEASED);
gmehmet 1:f60eafbf009a 95 }
gmehmet 1:f60eafbf009a 96 break;
gmehmet 1:f60eafbf009a 97
gmehmet 1:f60eafbf009a 98 case WatchInterface::BUTTON_DOWN:
gmehmet 1:f60eafbf009a 99 if (btnDown.read()) {
gmehmet 1:f60eafbf009a 100 return (WatchInterface::BUTTON_PRESSED);
gmehmet 1:f60eafbf009a 101 } else {
gmehmet 1:f60eafbf009a 102 return (WatchInterface::BUTTON_RELEASED);
gmehmet 1:f60eafbf009a 103 }
gmehmet 1:f60eafbf009a 104 break;
gmehmet 1:f60eafbf009a 105
gmehmet 1:f60eafbf009a 106 }
gmehmet 1:f60eafbf009a 107
gmehmet 1:f60eafbf009a 108 }
gmehmet 1:f60eafbf009a 109
gmehmet 1:f60eafbf009a 110
gmehmet 1:f60eafbf009a 111 void WatchInterface::refreshCallback(void)
gmehmet 1:f60eafbf009a 112 {
gmehmet 1:f60eafbf009a 113 refreshed = true;
gmehmet 1:f60eafbf009a 114 }
gmehmet 1:f60eafbf009a 115
gmehmet 1:f60eafbf009a 116
gmehmet 1:f60eafbf009a 117
gmehmet 1:f60eafbf009a 118 void WatchInterface::execute(void)
gmehmet 1:f60eafbf009a 119 {
gmehmet 1:f60eafbf009a 120 unsigned int current_timer;
gmehmet 1:f60eafbf009a 121 static int tickCount;
gmehmet 1:f60eafbf009a 122 static char tickCount_battery;
gmehmet 1:f60eafbf009a 123 static int firstDetect_up;
gmehmet 1:f60eafbf009a 124 static int firstDetect_down;
gmehmet 1:f60eafbf009a 125
gmehmet 1:f60eafbf009a 126
gmehmet 1:f60eafbf009a 127 // Display is OFF in ECG Mode
gmehmet 1:f60eafbf009a 128 if (ecg_enabled) {
gmehmet 1:f60eafbf009a 129 if (recording & (buttonEvent_down == BUTTONEVENT_DOWN_PRE)) {
gmehmet 1:f60eafbf009a 130 dispDISP = 1;
gmehmet 1:f60eafbf009a 131 if (isDisplayOff) {
gmehmet 1:f60eafbf009a 132 displayOff(false);
gmehmet 1:f60eafbf009a 133 }
gmehmet 1:f60eafbf009a 134 displayMode = DISPLAYMODE_RECORDING_STOP;
gmehmet 1:f60eafbf009a 135 } else {
gmehmet 1:f60eafbf009a 136 displayOff(true);
gmehmet 1:f60eafbf009a 137 }
gmehmet 1:f60eafbf009a 138 } else {
gmehmet 1:f60eafbf009a 139 dispDISP = 1;
gmehmet 1:f60eafbf009a 140 if (isDisplayOff) {
gmehmet 1:f60eafbf009a 141 displayOff(false);
gmehmet 1:f60eafbf009a 142 displayMode = DISPLAYMODE_RECORDING_STOP;
gmehmet 1:f60eafbf009a 143 }
gmehmet 1:f60eafbf009a 144 }
gmehmet 1:f60eafbf009a 145
gmehmet 1:f60eafbf009a 146
gmehmet 1:f60eafbf009a 147 if (isDisplayOff != true) {
gmehmet 1:f60eafbf009a 148 display.executeOnceLCD();
gmehmet 1:f60eafbf009a 149
gmehmet 1:f60eafbf009a 150 if (USB_Interface_MSD) {
gmehmet 1:f60eafbf009a 151 return;
gmehmet 1:f60eafbf009a 152 }
gmehmet 1:f60eafbf009a 153
gmehmet 1:f60eafbf009a 154 current_timer = interfaceTimer.read_ms();
gmehmet 1:f60eafbf009a 155
gmehmet 1:f60eafbf009a 156 // Button Debouncing
gmehmet 1:f60eafbf009a 157 if (current_timer > 50) {
gmehmet 1:f60eafbf009a 158
gmehmet 1:f60eafbf009a 159 interfaceTimer.reset();
gmehmet 1:f60eafbf009a 160 interfaceTimer.start();
gmehmet 1:f60eafbf009a 161
gmehmet 1:f60eafbf009a 162 // Increase tick counter in every 50ms
gmehmet 1:f60eafbf009a 163 tickCount++;
gmehmet 1:f60eafbf009a 164
gmehmet 1:f60eafbf009a 165 // tick counter reset will occur in every 15x50 = 750ms. This is used for display updates
gmehmet 1:f60eafbf009a 166 if (tickCount == 15) {
gmehmet 1:f60eafbf009a 167 tickCount = 0;
gmehmet 1:f60eafbf009a 168 }
gmehmet 1:f60eafbf009a 169
gmehmet 1:f60eafbf009a 170 if (buttonEvent_up == BUTTONEVENT_UP_PRE) {
gmehmet 1:f60eafbf009a 171
gmehmet 1:f60eafbf009a 172 if (firstDetect_up < 2) {
gmehmet 1:f60eafbf009a 173 firstDetect_up++;
gmehmet 1:f60eafbf009a 174 } else {
gmehmet 1:f60eafbf009a 175 firstDetect_up = 0;
gmehmet 1:f60eafbf009a 176 if (btnUp.read() == 0) {
gmehmet 1:f60eafbf009a 177 buttonEvent_up = BUTTONEVENT_UP;
gmehmet 1:f60eafbf009a 178 } else {
gmehmet 1:f60eafbf009a 179 buttonEvent_up = BUTTONEVENT_NONE;
gmehmet 1:f60eafbf009a 180 }
gmehmet 1:f60eafbf009a 181 }
gmehmet 1:f60eafbf009a 182
gmehmet 1:f60eafbf009a 183 } else {
gmehmet 1:f60eafbf009a 184 firstDetect_up = 0;
gmehmet 1:f60eafbf009a 185 }
gmehmet 1:f60eafbf009a 186
gmehmet 1:f60eafbf009a 187 if (buttonEvent_down == BUTTONEVENT_DOWN_PRE) {
gmehmet 1:f60eafbf009a 188
gmehmet 1:f60eafbf009a 189 if (firstDetect_down < 2) {
gmehmet 1:f60eafbf009a 190 firstDetect_down++;
gmehmet 1:f60eafbf009a 191 } else {
gmehmet 1:f60eafbf009a 192
gmehmet 1:f60eafbf009a 193 firstDetect_down = 0;
gmehmet 1:f60eafbf009a 194
gmehmet 1:f60eafbf009a 195 if (btnDown.read() == 0) {
gmehmet 1:f60eafbf009a 196 buttonEvent_down = BUTTONEVENT_DOWN;
gmehmet 1:f60eafbf009a 197
gmehmet 1:f60eafbf009a 198 } else {
gmehmet 1:f60eafbf009a 199 buttonEvent_down = BUTTONEVENT_NONE;
gmehmet 1:f60eafbf009a 200 }
gmehmet 1:f60eafbf009a 201 }
gmehmet 1:f60eafbf009a 202
gmehmet 1:f60eafbf009a 203 } else {
gmehmet 1:f60eafbf009a 204 firstDetect_down = 0;
gmehmet 1:f60eafbf009a 205 }
gmehmet 1:f60eafbf009a 206
gmehmet 1:f60eafbf009a 207 }
gmehmet 1:f60eafbf009a 208
gmehmet 1:f60eafbf009a 209
gmehmet 1:f60eafbf009a 210 switch (displayMode) {
gmehmet 1:f60eafbf009a 211
gmehmet 1:f60eafbf009a 212
gmehmet 1:f60eafbf009a 213 case DISPLAYMODE_TIME:
gmehmet 1:f60eafbf009a 214
gmehmet 1:f60eafbf009a 215 // Detect BLE Connected Event
gmehmet 1:f60eafbf009a 216 if (BLE_Interface_Exists) {
gmehmet 1:f60eafbf009a 217
gmehmet 1:f60eafbf009a 218 BLE_Interface_Exists_old = true;
gmehmet 1:f60eafbf009a 219 display_BLEMode_Active = false;
gmehmet 1:f60eafbf009a 220 displayMode = DISPLAYMODE_TETHERED;
gmehmet 1:f60eafbf009a 221
gmehmet 1:f60eafbf009a 222 tickCount = 8;
gmehmet 1:f60eafbf009a 223
gmehmet 1:f60eafbf009a 224 } else
gmehmet 1:f60eafbf009a 225 // Detect USB Connected Event
gmehmet 1:f60eafbf009a 226 if (USB_Interface_Exists) {
gmehmet 1:f60eafbf009a 227
gmehmet 1:f60eafbf009a 228 USB_Interface_Exists_old = true;
gmehmet 1:f60eafbf009a 229 display_USBMode_Active = false;
gmehmet 1:f60eafbf009a 230 displayMode = DISPLAYMODE_TETHERED_USB;
gmehmet 1:f60eafbf009a 231
gmehmet 1:f60eafbf009a 232 tickCount = 8;
gmehmet 1:f60eafbf009a 233
gmehmet 1:f60eafbf009a 234 } else
gmehmet 1:f60eafbf009a 235 // Next menu item
gmehmet 1:f60eafbf009a 236 if (buttonEvent_up == BUTTONEVENT_UP) {
gmehmet 1:f60eafbf009a 237
gmehmet 1:f60eafbf009a 238 buttonEvent_up = BUTTONEVENT_NONE;
gmehmet 1:f60eafbf009a 239 displayMode = DISPLAYMODE_PPG;
gmehmet 1:f60eafbf009a 240 modeUpdated = true;
gmehmet 1:f60eafbf009a 241 tickCount = 8;
gmehmet 1:f60eafbf009a 242
gmehmet 1:f60eafbf009a 243 } else
gmehmet 1:f60eafbf009a 244 // Next menu item
gmehmet 1:f60eafbf009a 245 if (buttonEvent_down == BUTTONEVENT_DOWN) {
gmehmet 1:f60eafbf009a 246
gmehmet 1:f60eafbf009a 247 buttonEvent_down = BUTTONEVENT_NONE;
gmehmet 1:f60eafbf009a 248 displayMode = DISPLAYMODE_INFO;
gmehmet 1:f60eafbf009a 249 modeUpdated = true;
gmehmet 1:f60eafbf009a 250 tickCount = 8;
gmehmet 1:f60eafbf009a 251
gmehmet 1:f60eafbf009a 252 } else {
gmehmet 1:f60eafbf009a 253
gmehmet 1:f60eafbf009a 254
gmehmet 1:f60eafbf009a 255 }
gmehmet 1:f60eafbf009a 256 break;
gmehmet 1:f60eafbf009a 257
gmehmet 1:f60eafbf009a 258 #ifdef ENABLE_SPO2
gmehmet 1:f60eafbf009a 259 case DISPLAYMODE_PPG: // Handle both PPG and ECG
gmehmet 1:f60eafbf009a 260 case DISPLAYMODE_ECG:
gmehmet 1:f60eafbf009a 261
gmehmet 1:f60eafbf009a 262 // Detect BLE Connected Event
gmehmet 1:f60eafbf009a 263 if (BLE_Interface_Exists) {
gmehmet 1:f60eafbf009a 264
gmehmet 1:f60eafbf009a 265 BLE_Interface_Exists_old = true;
gmehmet 1:f60eafbf009a 266 display_BLEMode_Active = false;
gmehmet 1:f60eafbf009a 267 displayMode = DISPLAYMODE_TETHERED;
gmehmet 1:f60eafbf009a 268
gmehmet 1:f60eafbf009a 269 tickCount = 8;
gmehmet 1:f60eafbf009a 270
gmehmet 1:f60eafbf009a 271 } else
gmehmet 1:f60eafbf009a 272 // Detect USB Connected Event
gmehmet 1:f60eafbf009a 273 if (USB_Interface_Exists) {
gmehmet 1:f60eafbf009a 274
gmehmet 1:f60eafbf009a 275 USB_Interface_Exists_old = true;
gmehmet 1:f60eafbf009a 276 display_USBMode_Active = false;
gmehmet 1:f60eafbf009a 277 displayMode = DISPLAYMODE_TETHERED_USB;
gmehmet 1:f60eafbf009a 278
gmehmet 1:f60eafbf009a 279 tickCount = 8;
gmehmet 1:f60eafbf009a 280
gmehmet 1:f60eafbf009a 281 } else
gmehmet 1:f60eafbf009a 282 // Next menu item
gmehmet 1:f60eafbf009a 283 if (buttonEvent_up == BUTTONEVENT_UP) {
gmehmet 1:f60eafbf009a 284
gmehmet 1:f60eafbf009a 285 buttonEvent_up = BUTTONEVENT_NONE;
gmehmet 1:f60eafbf009a 286 displayMode = DISPLAYMODE_SPO2_ONESHOT;
gmehmet 1:f60eafbf009a 287 modeUpdated = true;
gmehmet 1:f60eafbf009a 288 tickCount = 8;
gmehmet 1:f60eafbf009a 289
gmehmet 1:f60eafbf009a 290 } else
gmehmet 1:f60eafbf009a 291 // Next menu item
gmehmet 1:f60eafbf009a 292 if (buttonEvent_down == BUTTONEVENT_DOWN) {
gmehmet 1:f60eafbf009a 293
gmehmet 1:f60eafbf009a 294 buttonEvent_down = BUTTONEVENT_NONE;
gmehmet 1:f60eafbf009a 295 displayMode = DISPLAYMODE_TIME;
gmehmet 1:f60eafbf009a 296 modeUpdated = true;
gmehmet 1:f60eafbf009a 297 tickCount = 8;
gmehmet 1:f60eafbf009a 298
gmehmet 1:f60eafbf009a 299 }
gmehmet 1:f60eafbf009a 300 break;
gmehmet 1:f60eafbf009a 301
gmehmet 1:f60eafbf009a 302 case DISPLAYMODE_SPO2_ONESHOT:
gmehmet 1:f60eafbf009a 303
gmehmet 1:f60eafbf009a 304 // Detect BLE Connected Event
gmehmet 1:f60eafbf009a 305 if (BLE_Interface_Exists) {
gmehmet 1:f60eafbf009a 306
gmehmet 1:f60eafbf009a 307 BLE_Interface_Exists_old = true;
gmehmet 1:f60eafbf009a 308 display_BLEMode_Active = false;
gmehmet 1:f60eafbf009a 309 displayMode = DISPLAYMODE_TETHERED;
gmehmet 1:f60eafbf009a 310
gmehmet 1:f60eafbf009a 311 tickCount = 8;
gmehmet 1:f60eafbf009a 312
gmehmet 1:f60eafbf009a 313 } else
gmehmet 1:f60eafbf009a 314 // Detect USB Connected Event
gmehmet 1:f60eafbf009a 315 if (USB_Interface_Exists) {
gmehmet 1:f60eafbf009a 316
gmehmet 1:f60eafbf009a 317 USB_Interface_Exists_old = true;
gmehmet 1:f60eafbf009a 318 display_USBMode_Active = false;
gmehmet 1:f60eafbf009a 319 displayMode = DISPLAYMODE_TETHERED_USB;
gmehmet 1:f60eafbf009a 320
gmehmet 1:f60eafbf009a 321 tickCount = 8;
gmehmet 1:f60eafbf009a 322
gmehmet 1:f60eafbf009a 323 } else
gmehmet 1:f60eafbf009a 324 // Next menu item
gmehmet 1:f60eafbf009a 325 if (buttonEvent_up == BUTTONEVENT_UP) {
gmehmet 1:f60eafbf009a 326
gmehmet 1:f60eafbf009a 327 buttonEvent_up = BUTTONEVENT_NONE;
gmehmet 1:f60eafbf009a 328 displayMode = DISPLAYMODE_SPO2_CONTINUOUS;
gmehmet 1:f60eafbf009a 329 modeUpdated = true;
gmehmet 1:f60eafbf009a 330 tickCount = 8;
gmehmet 1:f60eafbf009a 331
gmehmet 1:f60eafbf009a 332 } else
gmehmet 1:f60eafbf009a 333 // Next menu item
gmehmet 1:f60eafbf009a 334 if (buttonEvent_down == BUTTONEVENT_DOWN) {
gmehmet 1:f60eafbf009a 335
gmehmet 1:f60eafbf009a 336 buttonEvent_down = BUTTONEVENT_NONE;
gmehmet 1:f60eafbf009a 337 displayMode = DISPLAYMODE_PPG;
gmehmet 1:f60eafbf009a 338 modeUpdated = true;
gmehmet 1:f60eafbf009a 339 tickCount = 8;
gmehmet 1:f60eafbf009a 340
gmehmet 1:f60eafbf009a 341 }
gmehmet 1:f60eafbf009a 342
gmehmet 1:f60eafbf009a 343 break;
gmehmet 1:f60eafbf009a 344
gmehmet 1:f60eafbf009a 345 case DISPLAYMODE_SPO2_CONTINUOUS:
gmehmet 1:f60eafbf009a 346
gmehmet 1:f60eafbf009a 347 // Detect BLE Connected Event
gmehmet 1:f60eafbf009a 348 if (BLE_Interface_Exists) {
gmehmet 1:f60eafbf009a 349
gmehmet 1:f60eafbf009a 350 BLE_Interface_Exists_old = true;
gmehmet 1:f60eafbf009a 351 display_BLEMode_Active = false;
gmehmet 1:f60eafbf009a 352 displayMode = DISPLAYMODE_TETHERED;
gmehmet 1:f60eafbf009a 353
gmehmet 1:f60eafbf009a 354 tickCount = 8;
gmehmet 1:f60eafbf009a 355
gmehmet 1:f60eafbf009a 356 } else
gmehmet 1:f60eafbf009a 357 // Detect USB Connected Event
gmehmet 1:f60eafbf009a 358 if (USB_Interface_Exists) {
gmehmet 1:f60eafbf009a 359
gmehmet 1:f60eafbf009a 360 USB_Interface_Exists_old = true;
gmehmet 1:f60eafbf009a 361 display_USBMode_Active = false;
gmehmet 1:f60eafbf009a 362 displayMode = DISPLAYMODE_TETHERED_USB;
gmehmet 1:f60eafbf009a 363
gmehmet 1:f60eafbf009a 364 tickCount = 8;
gmehmet 1:f60eafbf009a 365
gmehmet 1:f60eafbf009a 366 } else
gmehmet 1:f60eafbf009a 367 // Next menu item
gmehmet 1:f60eafbf009a 368 if (buttonEvent_up == BUTTONEVENT_UP) {
gmehmet 1:f60eafbf009a 369
gmehmet 1:f60eafbf009a 370 buttonEvent_up = BUTTONEVENT_NONE;
gmehmet 1:f60eafbf009a 371 displayMode = DISPLAYMODE_INFO;
gmehmet 1:f60eafbf009a 372 modeUpdated = true;
gmehmet 1:f60eafbf009a 373 tickCount = 8;
gmehmet 1:f60eafbf009a 374
gmehmet 1:f60eafbf009a 375 } else
gmehmet 1:f60eafbf009a 376 // Next menu item
gmehmet 1:f60eafbf009a 377 if (buttonEvent_down == BUTTONEVENT_DOWN) {
gmehmet 1:f60eafbf009a 378
gmehmet 1:f60eafbf009a 379 buttonEvent_down = BUTTONEVENT_NONE;
gmehmet 1:f60eafbf009a 380 displayMode = DISPLAYMODE_SPO2_ONESHOT;
gmehmet 1:f60eafbf009a 381 modeUpdated = true;
gmehmet 1:f60eafbf009a 382 tickCount = 8;
gmehmet 1:f60eafbf009a 383
gmehmet 1:f60eafbf009a 384 }
gmehmet 1:f60eafbf009a 385
gmehmet 1:f60eafbf009a 386 break;
gmehmet 1:f60eafbf009a 387 #else
gmehmet 1:f60eafbf009a 388 case DISPLAYMODE_PPG: // Handle both PPG and ECG
gmehmet 1:f60eafbf009a 389 case DISPLAYMODE_ECG:
gmehmet 1:f60eafbf009a 390
gmehmet 1:f60eafbf009a 391 // Detect BLE Connected Event
gmehmet 1:f60eafbf009a 392 if (BLE_Interface_Exists) {
gmehmet 1:f60eafbf009a 393
gmehmet 1:f60eafbf009a 394 BLE_Interface_Exists_old = true;
gmehmet 1:f60eafbf009a 395 display_BLEMode_Active = false;
gmehmet 1:f60eafbf009a 396 displayMode = DISPLAYMODE_TETHERED;
gmehmet 1:f60eafbf009a 397
gmehmet 1:f60eafbf009a 398 tickCount = 8;
gmehmet 1:f60eafbf009a 399
gmehmet 1:f60eafbf009a 400 } else
gmehmet 1:f60eafbf009a 401 // Detect USB Connected Event
gmehmet 1:f60eafbf009a 402 if (USB_Interface_Exists) {
gmehmet 1:f60eafbf009a 403
gmehmet 1:f60eafbf009a 404 USB_Interface_Exists_old = true;
gmehmet 1:f60eafbf009a 405 display_USBMode_Active = false;
gmehmet 1:f60eafbf009a 406 displayMode = DISPLAYMODE_TETHERED_USB;
gmehmet 1:f60eafbf009a 407
gmehmet 1:f60eafbf009a 408 tickCount = 8;
gmehmet 1:f60eafbf009a 409
gmehmet 1:f60eafbf009a 410 } else
gmehmet 1:f60eafbf009a 411 // Next menu item
gmehmet 1:f60eafbf009a 412 if (buttonEvent_up == BUTTONEVENT_UP) {
gmehmet 1:f60eafbf009a 413
gmehmet 1:f60eafbf009a 414 buttonEvent_up = BUTTONEVENT_NONE;
gmehmet 1:f60eafbf009a 415 displayMode = DISPLAYMODE_TEMP;
gmehmet 1:f60eafbf009a 416 modeUpdated = true;
gmehmet 1:f60eafbf009a 417 tickCount = 8;
gmehmet 1:f60eafbf009a 418
gmehmet 1:f60eafbf009a 419 } else
gmehmet 1:f60eafbf009a 420 // Next menu item
gmehmet 1:f60eafbf009a 421 if (buttonEvent_down == BUTTONEVENT_DOWN) {
gmehmet 1:f60eafbf009a 422
gmehmet 1:f60eafbf009a 423 buttonEvent_down = BUTTONEVENT_NONE;
gmehmet 1:f60eafbf009a 424 displayMode = DISPLAYMODE_TIME;
gmehmet 1:f60eafbf009a 425 modeUpdated = true;
gmehmet 1:f60eafbf009a 426 tickCount = 8;
gmehmet 1:f60eafbf009a 427
gmehmet 1:f60eafbf009a 428 }
gmehmet 1:f60eafbf009a 429 break;
gmehmet 1:f60eafbf009a 430
gmehmet 1:f60eafbf009a 431 case DISPLAYMODE_TEMP:
gmehmet 1:f60eafbf009a 432
gmehmet 1:f60eafbf009a 433 // Detect BLE Connected Event
gmehmet 1:f60eafbf009a 434 if (BLE_Interface_Exists) {
gmehmet 1:f60eafbf009a 435
gmehmet 1:f60eafbf009a 436 BLE_Interface_Exists_old = true;
gmehmet 1:f60eafbf009a 437 display_BLEMode_Active = false;
gmehmet 1:f60eafbf009a 438 displayMode = DISPLAYMODE_TETHERED;
gmehmet 1:f60eafbf009a 439
gmehmet 1:f60eafbf009a 440 tickCount = 8;
gmehmet 1:f60eafbf009a 441
gmehmet 1:f60eafbf009a 442 } else
gmehmet 1:f60eafbf009a 443 // Detect USB Connected Event
gmehmet 1:f60eafbf009a 444 if (USB_Interface_Exists) {
gmehmet 1:f60eafbf009a 445
gmehmet 1:f60eafbf009a 446 USB_Interface_Exists_old = true;
gmehmet 1:f60eafbf009a 447 display_USBMode_Active = false;
gmehmet 1:f60eafbf009a 448 displayMode = DISPLAYMODE_TETHERED_USB;
gmehmet 1:f60eafbf009a 449
gmehmet 1:f60eafbf009a 450 tickCount = 8;
gmehmet 1:f60eafbf009a 451
gmehmet 1:f60eafbf009a 452 } else
gmehmet 1:f60eafbf009a 453 // Next menu item
gmehmet 1:f60eafbf009a 454 if (buttonEvent_up == BUTTONEVENT_UP) {
gmehmet 1:f60eafbf009a 455
gmehmet 1:f60eafbf009a 456 buttonEvent_up = BUTTONEVENT_NONE;
gmehmet 1:f60eafbf009a 457 displayMode = DISPLAYMODE_INFO;
gmehmet 1:f60eafbf009a 458 modeUpdated = true;
gmehmet 1:f60eafbf009a 459 tickCount = 8;
gmehmet 1:f60eafbf009a 460
gmehmet 1:f60eafbf009a 461 } else
gmehmet 1:f60eafbf009a 462 // Next menu item
gmehmet 1:f60eafbf009a 463 if (buttonEvent_down == BUTTONEVENT_DOWN) {
gmehmet 1:f60eafbf009a 464
gmehmet 1:f60eafbf009a 465 buttonEvent_down = BUTTONEVENT_NONE;
gmehmet 1:f60eafbf009a 466 displayMode = DISPLAYMODE_PPG;
gmehmet 1:f60eafbf009a 467 modeUpdated = true;
gmehmet 1:f60eafbf009a 468 tickCount = 8;
gmehmet 1:f60eafbf009a 469
gmehmet 1:f60eafbf009a 470 }
gmehmet 1:f60eafbf009a 471 break;
gmehmet 1:f60eafbf009a 472 #endif
gmehmet 1:f60eafbf009a 473 case DISPLAYMODE_INFO:
gmehmet 1:f60eafbf009a 474
gmehmet 1:f60eafbf009a 475 // Detect BLE Connected Event
gmehmet 1:f60eafbf009a 476 if (BLE_Interface_Exists) {
gmehmet 1:f60eafbf009a 477
gmehmet 1:f60eafbf009a 478 BLE_Interface_Exists_old = true;
gmehmet 1:f60eafbf009a 479 display_BLEMode_Active = false;
gmehmet 1:f60eafbf009a 480 displayMode = DISPLAYMODE_TETHERED;
gmehmet 1:f60eafbf009a 481
gmehmet 1:f60eafbf009a 482 tickCount = 8;
gmehmet 1:f60eafbf009a 483
gmehmet 1:f60eafbf009a 484 } else
gmehmet 1:f60eafbf009a 485 // Detect USB Connected Event
gmehmet 1:f60eafbf009a 486 if (USB_Interface_Exists) {
gmehmet 1:f60eafbf009a 487
gmehmet 1:f60eafbf009a 488 USB_Interface_Exists_old = true;
gmehmet 1:f60eafbf009a 489 display_USBMode_Active = false;
gmehmet 1:f60eafbf009a 490 displayMode = DISPLAYMODE_TETHERED_USB;
gmehmet 1:f60eafbf009a 491
gmehmet 1:f60eafbf009a 492 tickCount = 8;
gmehmet 1:f60eafbf009a 493
gmehmet 1:f60eafbf009a 494 } else
gmehmet 1:f60eafbf009a 495 // Next menu item
gmehmet 1:f60eafbf009a 496 if (buttonEvent_up == BUTTONEVENT_UP) {
gmehmet 1:f60eafbf009a 497
gmehmet 1:f60eafbf009a 498 buttonEvent_up = BUTTONEVENT_NONE;
gmehmet 1:f60eafbf009a 499 displayMode = DISPLAYMODE_TIME;
gmehmet 1:f60eafbf009a 500 modeUpdated = true;
gmehmet 1:f60eafbf009a 501 tickCount = 8;
gmehmet 1:f60eafbf009a 502
gmehmet 1:f60eafbf009a 503 } else
gmehmet 1:f60eafbf009a 504 // Next menu item
gmehmet 1:f60eafbf009a 505 if (buttonEvent_down == BUTTONEVENT_DOWN) {
gmehmet 1:f60eafbf009a 506
gmehmet 1:f60eafbf009a 507 buttonEvent_down = BUTTONEVENT_NONE;
gmehmet 1:f60eafbf009a 508 #ifdef ENABLE_SPO2
gmehmet 1:f60eafbf009a 509 displayMode = DISPLAYMODE_SPO2_CONTINUOUS;
gmehmet 1:f60eafbf009a 510 #else
gmehmet 1:f60eafbf009a 511 displayMode = DISPLAYMODE_TEMP;
gmehmet 1:f60eafbf009a 512 #endif
gmehmet 1:f60eafbf009a 513 modeUpdated = true;
gmehmet 1:f60eafbf009a 514 tickCount = 8;
gmehmet 1:f60eafbf009a 515
gmehmet 1:f60eafbf009a 516 }
gmehmet 1:f60eafbf009a 517 break;
gmehmet 1:f60eafbf009a 518 case DISPLAYMODE_TETHERED:
gmehmet 1:f60eafbf009a 519
gmehmet 1:f60eafbf009a 520 // Detect Recording start event
gmehmet 1:f60eafbf009a 521 if ((recording) && (!recording_old)) {
gmehmet 1:f60eafbf009a 522
gmehmet 1:f60eafbf009a 523 recording_old = true;
gmehmet 1:f60eafbf009a 524 displayMode = DISPLAYMODE_RECORDING;
gmehmet 1:f60eafbf009a 525
gmehmet 1:f60eafbf009a 526 tickCount = 8;
gmehmet 1:f60eafbf009a 527
gmehmet 1:f60eafbf009a 528 } else
gmehmet 1:f60eafbf009a 529 // Detect BLE Disconnected Event
gmehmet 1:f60eafbf009a 530 if (!BLE_Interface_Exists) {
gmehmet 1:f60eafbf009a 531
gmehmet 1:f60eafbf009a 532 BLE_Interface_Exists_old = false;
gmehmet 1:f60eafbf009a 533 display_BLEMode_Active = false;
gmehmet 1:f60eafbf009a 534 displayMode = DISPLAYMODE_TIME;
gmehmet 1:f60eafbf009a 535
gmehmet 1:f60eafbf009a 536 tickCount = 8;
gmehmet 1:f60eafbf009a 537
gmehmet 1:f60eafbf009a 538 }
gmehmet 1:f60eafbf009a 539
gmehmet 1:f60eafbf009a 540 break;
gmehmet 1:f60eafbf009a 541
gmehmet 1:f60eafbf009a 542 case DISPLAYMODE_TETHERED_USB:
gmehmet 1:f60eafbf009a 543
gmehmet 1:f60eafbf009a 544 // Detect Recording start event
gmehmet 1:f60eafbf009a 545 if ((recording) && (!recording_old)) {
gmehmet 1:f60eafbf009a 546
gmehmet 1:f60eafbf009a 547 printf("START EVENT");
gmehmet 1:f60eafbf009a 548 recording_old = recording;
gmehmet 1:f60eafbf009a 549 displayMode = DISPLAYMODE_RECORDING;
gmehmet 1:f60eafbf009a 550
gmehmet 1:f60eafbf009a 551 tickCount = 8;
gmehmet 1:f60eafbf009a 552
gmehmet 1:f60eafbf009a 553 } else
gmehmet 1:f60eafbf009a 554 // Detect USB Disconnected Event
gmehmet 1:f60eafbf009a 555 if (!USB_Interface_Exists) {
gmehmet 1:f60eafbf009a 556
gmehmet 1:f60eafbf009a 557 USB_Interface_Exists_old = false;
gmehmet 1:f60eafbf009a 558 display_USBMode_Active = false;
gmehmet 1:f60eafbf009a 559 displayMode = DISPLAYMODE_TIME;
gmehmet 1:f60eafbf009a 560
gmehmet 1:f60eafbf009a 561 tickCount = 8;
gmehmet 1:f60eafbf009a 562
gmehmet 1:f60eafbf009a 563 }
gmehmet 1:f60eafbf009a 564
gmehmet 1:f60eafbf009a 565
gmehmet 1:f60eafbf009a 566 break;
gmehmet 1:f60eafbf009a 567
gmehmet 1:f60eafbf009a 568 case DISPLAYMODE_RECORDING: {
gmehmet 1:f60eafbf009a 569 // Detect stop recording
gmehmet 1:f60eafbf009a 570 if ((!recording) && (recording_old)) {
gmehmet 1:f60eafbf009a 571 printf("STOP EVENT");
gmehmet 1:f60eafbf009a 572 recording_old = recording;
gmehmet 1:f60eafbf009a 573 displayMode = DISPLAYMODE_TIME;
gmehmet 1:f60eafbf009a 574 tickCount = 8;
gmehmet 1:f60eafbf009a 575 } else {
gmehmet 1:f60eafbf009a 576 if (buttonEvent_down == BUTTONEVENT_DOWN) {
gmehmet 1:f60eafbf009a 577 buttonEvent_down = BUTTONEVENT_NONE;
gmehmet 1:f60eafbf009a 578 displayMode = DISPLAYMODE_RECORDING_STOP;
gmehmet 1:f60eafbf009a 579 tickCount = 8;
gmehmet 1:f60eafbf009a 580 }
gmehmet 1:f60eafbf009a 581 }
gmehmet 1:f60eafbf009a 582 }
gmehmet 1:f60eafbf009a 583 break;
gmehmet 1:f60eafbf009a 584
gmehmet 1:f60eafbf009a 585 case DISPLAYMODE_RECORDING_STOP: {
gmehmet 1:f60eafbf009a 586 recordingStopFlag = true;
gmehmet 1:f60eafbf009a 587 recording = false;
gmehmet 1:f60eafbf009a 588 recording_old = false;
gmehmet 1:f60eafbf009a 589 displayMode = DISPLAYMODE_TIME;
gmehmet 1:f60eafbf009a 590 }
gmehmet 1:f60eafbf009a 591 break;
gmehmet 1:f60eafbf009a 592 }
gmehmet 1:f60eafbf009a 593
gmehmet 1:f60eafbf009a 594
gmehmet 1:f60eafbf009a 595
gmehmet 1:f60eafbf009a 596 /*
gmehmet 1:f60eafbf009a 597 if ( recording ) {
gmehmet 1:f60eafbf009a 598
gmehmet 1:f60eafbf009a 599 if ( ( buttonEvent_down == BUTTONEVENT_DOWN ) && ( !BLE_Interface_Exists ) && ( !USB_Interface_Exists ) ) {
gmehmet 1:f60eafbf009a 600
gmehmet 1:f60eafbf009a 601
gmehmet 1:f60eafbf009a 602 buttonEvent_down = BUTTONEVENT_NONE;
gmehmet 1:f60eafbf009a 603
gmehmet 1:f60eafbf009a 604 if ( displayMode == DISPLAYMODE_RECORDING )
gmehmet 1:f60eafbf009a 605 displayMode = DISPLAYMODE_RECORDING_STOP;
gmehmet 1:f60eafbf009a 606
gmehmet 1:f60eafbf009a 607 tickCount = 8;
gmehmet 1:f60eafbf009a 608 }
gmehmet 1:f60eafbf009a 609 }
gmehmet 1:f60eafbf009a 610 else {
gmehmet 1:f60eafbf009a 611
gmehmet 1:f60eafbf009a 612 // Handle Up/Down Button press Events
gmehmet 1:f60eafbf009a 613
gmehmet 1:f60eafbf009a 614 // Process DOWN Button Press Event
gmehmet 1:f60eafbf009a 615 if ( ( buttonEvent_down == BUTTONEVENT_DOWN ) && ( !BLE_Interface_Exists ) && ( !USB_Interface_Exists ) ) {
gmehmet 1:f60eafbf009a 616
gmehmet 1:f60eafbf009a 617
gmehmet 1:f60eafbf009a 618 buttonEvent_down = BUTTONEVENT_NONE;
gmehmet 1:f60eafbf009a 619
gmehmet 1:f60eafbf009a 620 if ( displayMode > 0)
gmehmet 1:f60eafbf009a 621 displayMode--;
gmehmet 1:f60eafbf009a 622 else
gmehmet 1:f60eafbf009a 623 displayMode = 3;
gmehmet 1:f60eafbf009a 624
gmehmet 1:f60eafbf009a 625 tickCount = 8;
gmehmet 1:f60eafbf009a 626 }
gmehmet 1:f60eafbf009a 627 else
gmehmet 1:f60eafbf009a 628 // Process UP Button Press Event
gmehmet 1:f60eafbf009a 629 if ( ( buttonEvent_up == BUTTONEVENT_UP ) && ( !BLE_Interface_Exists ) && ( !USB_Interface_Exists ) ) {
gmehmet 1:f60eafbf009a 630
gmehmet 1:f60eafbf009a 631 if ( displayMode < 3)
gmehmet 1:f60eafbf009a 632 displayMode++;
gmehmet 1:f60eafbf009a 633 else
gmehmet 1:f60eafbf009a 634 displayMode = 0;
gmehmet 1:f60eafbf009a 635
gmehmet 1:f60eafbf009a 636 buttonEvent_up = BUTTONEVENT_NONE;
gmehmet 1:f60eafbf009a 637
gmehmet 1:f60eafbf009a 638 tickCount = 8;
gmehmet 1:f60eafbf009a 639 }
gmehmet 1:f60eafbf009a 640
gmehmet 1:f60eafbf009a 641
gmehmet 1:f60eafbf009a 642
gmehmet 1:f60eafbf009a 643
gmehmet 1:f60eafbf009a 644
gmehmet 1:f60eafbf009a 645 // Detect BLE Connected Event
gmehmet 1:f60eafbf009a 646 if ( ( BLEWasActive == false ) && ( BLE_Interface_Exists ) ) {
gmehmet 1:f60eafbf009a 647
gmehmet 1:f60eafbf009a 648 BLEWasActive = true;
gmehmet 1:f60eafbf009a 649 display_BLEMode_Active = false;
gmehmet 1:f60eafbf009a 650 displayMode = DISPLAYMODE_TETHERED;
gmehmet 1:f60eafbf009a 651 modeUpdated = true;
gmehmet 1:f60eafbf009a 652
gmehmet 1:f60eafbf009a 653 tickCount = 8;
gmehmet 1:f60eafbf009a 654
gmehmet 1:f60eafbf009a 655 }
gmehmet 1:f60eafbf009a 656 else
gmehmet 1:f60eafbf009a 657 // Detect BLE Disconnected Event
gmehmet 1:f60eafbf009a 658 if ( ( BLEWasActive == true ) && ( !BLE_Interface_Exists ) ) {
gmehmet 1:f60eafbf009a 659
gmehmet 1:f60eafbf009a 660 BLEWasActive = false;
gmehmet 1:f60eafbf009a 661 display_BLEMode_Active = false;
gmehmet 1:f60eafbf009a 662 displayMode = DISPLAYMODE_TIME;
gmehmet 1:f60eafbf009a 663 //should_stop = true;
gmehmet 1:f60eafbf009a 664 modeUpdated = true;
gmehmet 1:f60eafbf009a 665
gmehmet 1:f60eafbf009a 666 tickCount = 8;
gmehmet 1:f60eafbf009a 667
gmehmet 1:f60eafbf009a 668 }
gmehmet 1:f60eafbf009a 669 else
gmehmet 1:f60eafbf009a 670 // Detect USB Connected Event
gmehmet 1:f60eafbf009a 671 if ( ( USBWasActive == false ) && ( USB_Interface_Exists ) ) {
gmehmet 1:f60eafbf009a 672
gmehmet 1:f60eafbf009a 673 USBWasActive = true;
gmehmet 1:f60eafbf009a 674 display_USBMode_Active = false;
gmehmet 1:f60eafbf009a 675 displayMode = DISPLAYMODE_TETHERED_USB;
gmehmet 1:f60eafbf009a 676 modeUpdated = true;
gmehmet 1:f60eafbf009a 677
gmehmet 1:f60eafbf009a 678 tickCount = 8;
gmehmet 1:f60eafbf009a 679
gmehmet 1:f60eafbf009a 680 }
gmehmet 1:f60eafbf009a 681 else
gmehmet 1:f60eafbf009a 682 // Detect USB Disconnected Event
gmehmet 1:f60eafbf009a 683 if ( ( USBWasActive == true ) && ( !USB_Interface_Exists ) ) {
gmehmet 1:f60eafbf009a 684
gmehmet 1:f60eafbf009a 685 USBWasActive = false;
gmehmet 1:f60eafbf009a 686 display_USBMode_Active = false;
gmehmet 1:f60eafbf009a 687 displayMode = DISPLAYMODE_TIME;
gmehmet 1:f60eafbf009a 688 //should_stop = true;
gmehmet 1:f60eafbf009a 689 modeUpdated = true;
gmehmet 1:f60eafbf009a 690
gmehmet 1:f60eafbf009a 691 tickCount = 8;
gmehmet 1:f60eafbf009a 692
gmehmet 1:f60eafbf009a 693 }
gmehmet 1:f60eafbf009a 694
gmehmet 1:f60eafbf009a 695 }
gmehmet 1:f60eafbf009a 696 */
gmehmet 1:f60eafbf009a 697
gmehmet 1:f60eafbf009a 698 // Update the display in every 500ms (if necessary)
gmehmet 1:f60eafbf009a 699 if (tickCount == 0) {
gmehmet 1:f60eafbf009a 700
gmehmet 1:f60eafbf009a 701 tickCount = 1;
gmehmet 1:f60eafbf009a 702
gmehmet 1:f60eafbf009a 703 if (displayMode_old != displayMode) {
gmehmet 1:f60eafbf009a 704
gmehmet 1:f60eafbf009a 705 modeUpdated = true;
gmehmet 1:f60eafbf009a 706 #ifdef ENABLE_SPO2
gmehmet 1:f60eafbf009a 707 if((displayMode == DISPLAYMODE_SPO2_ONESHOT) || (displayMode == DISPLAYMODE_SPO2_CONTINUOUS))
gmehmet 1:f60eafbf009a 708 {
gmehmet 1:f60eafbf009a 709 instant_spo2_percentage=0;
gmehmet 1:f60eafbf009a 710 }
gmehmet 1:f60eafbf009a 711 #endif
gmehmet 1:f60eafbf009a 712 }
gmehmet 1:f60eafbf009a 713
gmehmet 1:f60eafbf009a 714 //if ( (!display_BLEMode_Active) && (!display_USBMode_Active) ) {
gmehmet 1:f60eafbf009a 715 btnDown.disable_irq();
gmehmet 1:f60eafbf009a 716 btnUp.disable_irq(); // Disable Interrupts
gmehmet 1:f60eafbf009a 717
gmehmet 1:f60eafbf009a 718
gmehmet 1:f60eafbf009a 719 if (tickCount_battery <= 0) {
gmehmet 1:f60eafbf009a 720 m_max20303_->Max20303_BatteryGauge(&batteryLevel);
gmehmet 1:f60eafbf009a 721 tickCount_battery = BATTERY_GAUGE_COUNT;
gmehmet 1:f60eafbf009a 722 }
gmehmet 1:f60eafbf009a 723 tickCount_battery--;
gmehmet 1:f60eafbf009a 724
gmehmet 1:f60eafbf009a 725 updateDisplay(batteryLevel);
gmehmet 1:f60eafbf009a 726
gmehmet 1:f60eafbf009a 727 btnDown.enable_irq();
gmehmet 1:f60eafbf009a 728 btnUp.enable_irq(); // Enable Interrupts
gmehmet 1:f60eafbf009a 729 //}
gmehmet 1:f60eafbf009a 730
gmehmet 1:f60eafbf009a 731 displayMode_old = displayMode;
gmehmet 1:f60eafbf009a 732 }
gmehmet 1:f60eafbf009a 733
gmehmet 1:f60eafbf009a 734 }
gmehmet 1:f60eafbf009a 735 }
gmehmet 1:f60eafbf009a 736
gmehmet 1:f60eafbf009a 737 void WatchInterface::displayOff(bool off)
gmehmet 1:f60eafbf009a 738 {
gmehmet 1:f60eafbf009a 739 if (off) {
gmehmet 1:f60eafbf009a 740 // Display Turned Off
gmehmet 1:f60eafbf009a 741 DisplayPWM.pulsewidth_ms(0);
gmehmet 1:f60eafbf009a 742 dispDISP = 0;
gmehmet 1:f60eafbf009a 743 isDisplayOff = true;
gmehmet 1:f60eafbf009a 744 } else {
gmehmet 1:f60eafbf009a 745 // Display Turned on
gmehmet 1:f60eafbf009a 746 DisplayPWM.pulsewidth_ms(8);
gmehmet 1:f60eafbf009a 747 dispDISP = 1;
gmehmet 1:f60eafbf009a 748 isDisplayOff = false;
gmehmet 1:f60eafbf009a 749 }
gmehmet 1:f60eafbf009a 750 }
gmehmet 1:f60eafbf009a 751
gmehmet 1:f60eafbf009a 752 void WatchInterface::DisplayModeUpdated(){
gmehmet 1:f60eafbf009a 753 ppg_lcd_count = 0;
gmehmet 1:f60eafbf009a 754 }
gmehmet 1:f60eafbf009a 755
gmehmet 1:f60eafbf009a 756 void WatchInterface::updateDisplay(int batteryLevelToBeScaled) {
gmehmet 1:f60eafbf009a 757 char buffer[32];
gmehmet 1:f60eafbf009a 758 time_t seconds;
gmehmet 1:f60eafbf009a 759 int hrDisplay_confidenceThreshold;
gmehmet 1:f60eafbf009a 760 static int hr_timeout;
gmehmet 1:f60eafbf009a 761
gmehmet 1:f60eafbf009a 762 // Clear Entire Screen
gmehmet 1:f60eafbf009a 763 display.cls();
gmehmet 1:f60eafbf009a 764 display.fill(0, 0, 128, 128, Black);
gmehmet 1:f60eafbf009a 765
gmehmet 1:f60eafbf009a 766 // Draw Maxim Integrated Logo
gmehmet 1:f60eafbf009a 767 display.showBMP((uint8_t*)maxim128Bitmaps, 120, 36, 8, 90);
gmehmet 1:f60eafbf009a 768
gmehmet 1:f60eafbf009a 769 if (!bootComplete) {
gmehmet 1:f60eafbf009a 770 return;
gmehmet 1:f60eafbf009a 771 }
gmehmet 1:f60eafbf009a 772
gmehmet 1:f60eafbf009a 773 // Show BLE logo if it is connected
gmehmet 1:f60eafbf009a 774
gmehmet 1:f60eafbf009a 775
gmehmet 1:f60eafbf009a 776 if (displayMode != DISPLAYMODE_TETHERED_USB) {
gmehmet 1:f60eafbf009a 777 // Draw battery outline
gmehmet 1:f60eafbf009a 778 display.fillrect(94, 6, 27, 12, White);
gmehmet 1:f60eafbf009a 779 display.fillrect(97, 9, 21, 6, Black);
gmehmet 1:f60eafbf009a 780 display.fillrect(122, 9, 2, 6, White);
gmehmet 1:f60eafbf009a 781
gmehmet 1:f60eafbf009a 782 if (batteryLevelToBeScaled < 10) {
gmehmet 1:f60eafbf009a 783 batteryLevelToBeScaled = 0;
gmehmet 1:f60eafbf009a 784 } else if (batteryLevelToBeScaled <= 25) {
gmehmet 1:f60eafbf009a 785 batteryLevelToBeScaled = 1;
gmehmet 1:f60eafbf009a 786 } else if (batteryLevelToBeScaled <= 50) {
gmehmet 1:f60eafbf009a 787 batteryLevelToBeScaled = 2;
gmehmet 1:f60eafbf009a 788 } else if (batteryLevelToBeScaled <= 75) {
gmehmet 1:f60eafbf009a 789 batteryLevelToBeScaled = 3;
gmehmet 1:f60eafbf009a 790 } else {
gmehmet 1:f60eafbf009a 791 batteryLevelToBeScaled = 4;
gmehmet 1:f60eafbf009a 792 }
gmehmet 1:f60eafbf009a 793
gmehmet 1:f60eafbf009a 794 // Draw battery level ticks
gmehmet 1:f60eafbf009a 795 for (int i = 0 ; i < batteryLevelToBeScaled ; i++) {
gmehmet 1:f60eafbf009a 796 display.fillrect(99 + (i * 5), 10, 3, 4, White);
gmehmet 1:f60eafbf009a 797 }
gmehmet 1:f60eafbf009a 798 }
gmehmet 1:f60eafbf009a 799
gmehmet 1:f60eafbf009a 800 // Show BLE logo if it is connected
gmehmet 1:f60eafbf009a 801 if (BLE_Interface_Exists) {
gmehmet 1:f60eafbf009a 802 display.showBMP((uint8_t*)BLELogoBitmap, 16, 15, 72, 13);
gmehmet 1:f60eafbf009a 803 //displayMode = DISPLAYMODE_TETHERED;
gmehmet 1:f60eafbf009a 804 //BLEWasActive = true;
gmehmet 1:f60eafbf009a 805 } else {
gmehmet 1:f60eafbf009a 806 // Show USB logo if it is connected
gmehmet 1:f60eafbf009a 807 if (USB_Interface_Exists) {
gmehmet 1:f60eafbf009a 808 display.showBMP((uint8_t*)USBLogoBitmap, 16, 15, 72, 13);
gmehmet 1:f60eafbf009a 809 //displayMode = DISPLAYMODE_TETHERED_USB;
gmehmet 1:f60eafbf009a 810 //USBWasActive = true;
gmehmet 1:f60eafbf009a 811 }
gmehmet 1:f60eafbf009a 812 }
gmehmet 1:f60eafbf009a 813
gmehmet 1:f60eafbf009a 814 display.set_font(UbuntuCondensed20x26);
gmehmet 1:f60eafbf009a 815 display.locate(3, 10);
gmehmet 1:f60eafbf009a 816 display.foreground((uint16_t)Black);
gmehmet 1:f60eafbf009a 817 display.background((uint16_t)White);
gmehmet 1:f60eafbf009a 818
gmehmet 1:f60eafbf009a 819 switch (displayMode) {
gmehmet 1:f60eafbf009a 820
gmehmet 1:f60eafbf009a 821 case DISPLAYMODE_RECORDING:
gmehmet 1:f60eafbf009a 822
gmehmet 1:f60eafbf009a 823 display.fillrect(8, 46, 27, 23, White);
gmehmet 1:f60eafbf009a 824 display.fillrect(9, 45, 25, 25, White);
gmehmet 1:f60eafbf009a 825 display.fillrect(10, 44, 23, 27, White);
gmehmet 1:f60eafbf009a 826
gmehmet 1:f60eafbf009a 827 if (ppg_lcd_count == 0) {
gmehmet 1:f60eafbf009a 828 display.fillellipse(21, 57, 8, 8, (uint16_t) Black);
gmehmet 1:f60eafbf009a 829 }
gmehmet 1:f60eafbf009a 830
gmehmet 1:f60eafbf009a 831 snprintf(buffer, 32, "REC");
gmehmet 1:f60eafbf009a 832 display.set_font(UbuntuCondensed38x47);
gmehmet 1:f60eafbf009a 833 display.locate(40, 36);
gmehmet 1:f60eafbf009a 834 display.foreground((uint16_t)Black);
gmehmet 1:f60eafbf009a 835 display.background((uint16_t)White);
gmehmet 1:f60eafbf009a 836 display.printf(buffer);
gmehmet 1:f60eafbf009a 837
gmehmet 1:f60eafbf009a 838
gmehmet 1:f60eafbf009a 839 ppg_lcd_count++;
gmehmet 1:f60eafbf009a 840 if (ppg_lcd_count > 1) {
gmehmet 1:f60eafbf009a 841 ppg_lcd_count = 0;
gmehmet 1:f60eafbf009a 842 }
gmehmet 1:f60eafbf009a 843
gmehmet 1:f60eafbf009a 844 break;
gmehmet 1:f60eafbf009a 845
gmehmet 1:f60eafbf009a 846
gmehmet 1:f60eafbf009a 847 case DISPLAYMODE_RECORDING_STOP:
gmehmet 1:f60eafbf009a 848 display.printf("CONFIRM");
gmehmet 1:f60eafbf009a 849 snprintf(buffer, 32, "STOP");
gmehmet 1:f60eafbf009a 850 display.set_font(UbuntuCondensed38x47);
gmehmet 1:f60eafbf009a 851 display.locate(5, 36);
gmehmet 1:f60eafbf009a 852 display.foreground((uint16_t)Black);
gmehmet 1:f60eafbf009a 853 display.background((uint16_t)White);
gmehmet 1:f60eafbf009a 854 display.printf(buffer);
gmehmet 1:f60eafbf009a 855
gmehmet 1:f60eafbf009a 856 break;
gmehmet 1:f60eafbf009a 857
gmehmet 1:f60eafbf009a 858 case DISPLAYMODE_INFO:
gmehmet 1:f60eafbf009a 859 display.printf("INFO");
gmehmet 1:f60eafbf009a 860
gmehmet 1:f60eafbf009a 861
gmehmet 1:f60eafbf009a 862 display.set_font(Arial10x10);
gmehmet 1:f60eafbf009a 863
gmehmet 1:f60eafbf009a 864 display.foreground((uint16_t)Black);
gmehmet 1:f60eafbf009a 865 display.background((uint16_t)White);
gmehmet 1:f60eafbf009a 866 snprintf(buffer, 32, "BLE MAC:");
gmehmet 1:f60eafbf009a 867 display.locate(4, 40);
gmehmet 1:f60eafbf009a 868 display.printf(buffer);
gmehmet 1:f60eafbf009a 869 snprintf(buffer, 32, "%02X:%02X:%02X:%02X:%02X:%02X", m_mac_addr_[0], m_mac_addr_[1], m_mac_addr_[2], m_mac_addr_[3], m_mac_addr_[4], m_mac_addr_[5]);
gmehmet 1:f60eafbf009a 870 display.locate(4, 50);
gmehmet 1:f60eafbf009a 871 display.printf(buffer);
gmehmet 1:f60eafbf009a 872
gmehmet 1:f60eafbf009a 873 snprintf(buffer, 32, "FW Version:");
gmehmet 1:f60eafbf009a 874 display.locate(4, 66);
gmehmet 1:f60eafbf009a 875 display.printf(buffer);
gmehmet 1:f60eafbf009a 876
gmehmet 1:f60eafbf009a 877 snprintf(buffer, 32, "%s", FIRMWARE_VERSION);
gmehmet 1:f60eafbf009a 878 display.locate(4, 76);
gmehmet 1:f60eafbf009a 879 display.printf(buffer);
gmehmet 1:f60eafbf009a 880
gmehmet 1:f60eafbf009a 881 break;
gmehmet 1:f60eafbf009a 882
gmehmet 1:f60eafbf009a 883 case DISPLAYMODE_TIME:
gmehmet 1:f60eafbf009a 884 display.printf("TIME");
gmehmet 1:f60eafbf009a 885 seconds = time(NULL);
gmehmet 1:f60eafbf009a 886 strftime(buffer, 32, "%I:%M", localtime(&seconds));
gmehmet 1:f60eafbf009a 887 display.set_font(UbuntuCondensed38x47);
gmehmet 1:f60eafbf009a 888 display.locate(6, 40);
gmehmet 1:f60eafbf009a 889 display.foreground((uint16_t)Black);
gmehmet 1:f60eafbf009a 890 display.background((uint16_t)White);
gmehmet 1:f60eafbf009a 891 display.printf(buffer);
gmehmet 1:f60eafbf009a 892 snprintf(buffer, 32, "MAC:%02X:%02X", m_mac_addr_[4], m_mac_addr_[5]);
gmehmet 1:f60eafbf009a 893 display.set_font(Arial10x10);
gmehmet 1:f60eafbf009a 894 display.locate(60, 20);
gmehmet 1:f60eafbf009a 895 display.foreground((uint16_t)Black);
gmehmet 1:f60eafbf009a 896 display.background((uint16_t)White);
gmehmet 1:f60eafbf009a 897 display.printf(buffer);
gmehmet 1:f60eafbf009a 898
gmehmet 1:f60eafbf009a 899 while (1) {
gmehmet 1:f60eafbf009a 900 if (seconds >= 86400) {
gmehmet 1:f60eafbf009a 901 seconds = seconds % 86400;
gmehmet 1:f60eafbf009a 902 } else {
gmehmet 1:f60eafbf009a 903 break;
gmehmet 1:f60eafbf009a 904 }
gmehmet 1:f60eafbf009a 905 }
gmehmet 1:f60eafbf009a 906
gmehmet 1:f60eafbf009a 907 if (seconds < 43200) {
gmehmet 1:f60eafbf009a 908 display.showBMP((uint8_t*)AM_Bitmap, 16, 9, 104, 45);
gmehmet 1:f60eafbf009a 909 } else {
gmehmet 1:f60eafbf009a 910 display.showBMP((uint8_t*)PM_Bitmap, 16, 9, 104, 45);
gmehmet 1:f60eafbf009a 911 }
gmehmet 1:f60eafbf009a 912
gmehmet 1:f60eafbf009a 913
gmehmet 1:f60eafbf009a 914 break;
gmehmet 1:f60eafbf009a 915
gmehmet 1:f60eafbf009a 916 case DISPLAYMODE_PPG:
gmehmet 1:f60eafbf009a 917 display.printf("PPG");
gmehmet 1:f60eafbf009a 918
gmehmet 1:f60eafbf009a 919 //Blink "MEASURING" for the first 13 seconds (settling time of ppg)
gmehmet 1:f60eafbf009a 920
gmehmet 1:f60eafbf009a 921 display.set_font(UbuntuCondensed16x21);
gmehmet 1:f60eafbf009a 922 display.locate(12, 52);
gmehmet 1:f60eafbf009a 923 display.foreground((uint16_t)Black);
gmehmet 1:f60eafbf009a 924 display.background((uint16_t)White);
gmehmet 1:f60eafbf009a 925
gmehmet 1:f60eafbf009a 926 if(ppg_lcd_count<25)
gmehmet 1:f60eafbf009a 927 {
gmehmet 1:f60eafbf009a 928 if(ppg_lcd_count & 0x01)
gmehmet 1:f60eafbf009a 929 {
gmehmet 1:f60eafbf009a 930 display.printf(" ");
gmehmet 1:f60eafbf009a 931 }
gmehmet 1:f60eafbf009a 932 else
gmehmet 1:f60eafbf009a 933 {
gmehmet 1:f60eafbf009a 934 display.printf("MEASURING");
gmehmet 1:f60eafbf009a 935 }
gmehmet 1:f60eafbf009a 936 }
gmehmet 1:f60eafbf009a 937
gmehmet 1:f60eafbf009a 938 //print the heart rate (it is settled now)
gmehmet 1:f60eafbf009a 939 else {
gmehmet 1:f60eafbf009a 940 if (ppg_lcd_count > 80) {
gmehmet 1:f60eafbf009a 941 ppg_lcd_count = 70;
gmehmet 1:f60eafbf009a 942 }
gmehmet 1:f60eafbf009a 943
gmehmet 1:f60eafbf009a 944 display.set_font(UbuntuCondensed38x47);
gmehmet 1:f60eafbf009a 945 display.locate(8, 40);
gmehmet 1:f60eafbf009a 946 display.foreground((uint16_t)Black);
gmehmet 1:f60eafbf009a 947 display.background((uint16_t)White);
gmehmet 1:f60eafbf009a 948
gmehmet 1:f60eafbf009a 949 if (instant_hr_activityClass == ACTD_REST_ACTIVITY) {
gmehmet 1:f60eafbf009a 950 hrDisplay_confidenceThreshold = ConfThresLevelRest;
gmehmet 1:f60eafbf009a 951 } else {
gmehmet 1:f60eafbf009a 952 hrDisplay_confidenceThreshold = ConfThresLevelOther;
gmehmet 1:f60eafbf009a 953 }
gmehmet 1:f60eafbf009a 954 if ((instant_hr_conf > hrDisplay_confidenceThreshold) && (instant_hr > kHeartRateLowerLimit) && (instant_hr < kHeartRateUpperLimit)) {
gmehmet 1:f60eafbf009a 955 display.printf("%d", instant_hr);
gmehmet 1:f60eafbf009a 956 last_good_hr = instant_hr;
gmehmet 1:f60eafbf009a 957 hr_timeout = 0;
gmehmet 1:f60eafbf009a 958 } else {
gmehmet 1:f60eafbf009a 959 if (hr_timeout < 200) {
gmehmet 1:f60eafbf009a 960 hr_timeout++;
gmehmet 1:f60eafbf009a 961 }
gmehmet 1:f60eafbf009a 962 if (hr_timeout < 12) {
gmehmet 1:f60eafbf009a 963 display.printf("%d", last_good_hr);
gmehmet 1:f60eafbf009a 964 } else {
gmehmet 1:f60eafbf009a 965 display.printf("--");
gmehmet 1:f60eafbf009a 966 }
gmehmet 1:f60eafbf009a 967
gmehmet 1:f60eafbf009a 968 }
gmehmet 1:f60eafbf009a 969
gmehmet 1:f60eafbf009a 970 display.set_font(UbuntuCondensed20x26);
gmehmet 1:f60eafbf009a 971 display.locate(72, 57);
gmehmet 1:f60eafbf009a 972 display.foreground((uint16_t)Black);
gmehmet 1:f60eafbf009a 973 display.background((uint16_t)White);
gmehmet 1:f60eafbf009a 974 display.printf("BPM");
gmehmet 1:f60eafbf009a 975 }
gmehmet 1:f60eafbf009a 976
gmehmet 1:f60eafbf009a 977 ppg_lcd_count++;
gmehmet 1:f60eafbf009a 978
gmehmet 1:f60eafbf009a 979 break;
gmehmet 1:f60eafbf009a 980 #ifdef ENABLE_SPO2
gmehmet 1:f60eafbf009a 981 case DISPLAYMODE_SPO2_ONESHOT:
gmehmet 1:f60eafbf009a 982
gmehmet 1:f60eafbf009a 983 display.printf("SPO2");
gmehmet 1:f60eafbf009a 984 display.set_font(Arial10x10);
gmehmet 1:f60eafbf009a 985 display.locate(60,23);
gmehmet 1:f60eafbf009a 986 display.printf("ONE-SHOT");
gmehmet 1:f60eafbf009a 987 display.set_font(UbuntuCondensed16x21);
gmehmet 1:f60eafbf009a 988 display.locate(12,52);
gmehmet 1:f60eafbf009a 989 display.foreground(Black);
gmehmet 1:f60eafbf009a 990 display.background(White);
gmehmet 1:f60eafbf009a 991 if (instant_spo2_percentage != 100 ) {
gmehmet 1:f60eafbf009a 992 if(ppg_lcd_count & 0x01) {
gmehmet 1:f60eafbf009a 993 display.printf(" ");
gmehmet 1:f60eafbf009a 994 } else {
gmehmet 1:f60eafbf009a 995 if(instant_lowSignalQualityFlag)
gmehmet 1:f60eafbf009a 996 display.printf("LOWSIGNAL");
gmehmet 1:f60eafbf009a 997 else
gmehmet 1:f60eafbf009a 998 display.printf("MEASURING");
gmehmet 1:f60eafbf009a 999 }
gmehmet 1:f60eafbf009a 1000 } else {
gmehmet 1:f60eafbf009a 1001 if(instant_lowSignalQualityFlag){
gmehmet 1:f60eafbf009a 1002 display.printf("LOWSIGNAL");
gmehmet 1:f60eafbf009a 1003 } else {
gmehmet 1:f60eafbf009a 1004 display.set_font(UbuntuCondensed38x47);
gmehmet 1:f60eafbf009a 1005 display.locate(8,40);
gmehmet 1:f60eafbf009a 1006 display.foreground(Black);
gmehmet 1:f60eafbf009a 1007 display.background(White);
gmehmet 1:f60eafbf009a 1008 display.printf("%d", instant_spo2);
gmehmet 1:f60eafbf009a 1009 display.set_font(UbuntuCondensed20x26);
gmehmet 1:f60eafbf009a 1010 display.locate(72,57);
gmehmet 1:f60eafbf009a 1011 display.foreground(Black);
gmehmet 1:f60eafbf009a 1012 display.background(White);
gmehmet 1:f60eafbf009a 1013 display.printf("%%");
gmehmet 1:f60eafbf009a 1014 }
gmehmet 1:f60eafbf009a 1015 }
gmehmet 1:f60eafbf009a 1016 ppg_lcd_count++;
gmehmet 1:f60eafbf009a 1017
gmehmet 1:f60eafbf009a 1018 break;
gmehmet 1:f60eafbf009a 1019 case DISPLAYMODE_SPO2_CONTINUOUS:
gmehmet 1:f60eafbf009a 1020
gmehmet 1:f60eafbf009a 1021 display.printf("SPO2");
gmehmet 1:f60eafbf009a 1022 display.set_font(Arial10x10);
gmehmet 1:f60eafbf009a 1023 display.locate(60,23);
gmehmet 1:f60eafbf009a 1024 display.printf("NON-STOP");
gmehmet 1:f60eafbf009a 1025 display.set_font(UbuntuCondensed16x21);
gmehmet 1:f60eafbf009a 1026 display.locate(12,52);
gmehmet 1:f60eafbf009a 1027 display.foreground(Black);
gmehmet 1:f60eafbf009a 1028 display.background(White);
gmehmet 1:f60eafbf009a 1029 if (instant_spo2 == 0 ) {
gmehmet 1:f60eafbf009a 1030 if(ppg_lcd_count & 0x01) {
gmehmet 1:f60eafbf009a 1031 display.printf(" ");
gmehmet 1:f60eafbf009a 1032 } else {
gmehmet 1:f60eafbf009a 1033 if(instant_lowSignalQualityFlag)
gmehmet 1:f60eafbf009a 1034 display.printf("LOWSIGNAL");
gmehmet 1:f60eafbf009a 1035 else
gmehmet 1:f60eafbf009a 1036 display.printf("MEASURING");
gmehmet 1:f60eafbf009a 1037 }
gmehmet 1:f60eafbf009a 1038 } else {
gmehmet 1:f60eafbf009a 1039 if(instant_lowSignalQualityFlag){
gmehmet 1:f60eafbf009a 1040 display.printf("LOWSIGNAL");
gmehmet 1:f60eafbf009a 1041 } else {
gmehmet 1:f60eafbf009a 1042 display.set_font(UbuntuCondensed38x47);
gmehmet 1:f60eafbf009a 1043 display.locate(8,40);
gmehmet 1:f60eafbf009a 1044 display.foreground(Black);
gmehmet 1:f60eafbf009a 1045 display.background(White);
gmehmet 1:f60eafbf009a 1046 display.printf("%d", instant_spo2);
gmehmet 1:f60eafbf009a 1047 display.set_font(UbuntuCondensed20x26);
gmehmet 1:f60eafbf009a 1048 display.locate(72,57);
gmehmet 1:f60eafbf009a 1049 display.foreground(Black);
gmehmet 1:f60eafbf009a 1050 display.background(White);
gmehmet 1:f60eafbf009a 1051 display.printf("%%");
gmehmet 1:f60eafbf009a 1052 }
gmehmet 1:f60eafbf009a 1053 }
gmehmet 1:f60eafbf009a 1054 ppg_lcd_count++;
gmehmet 1:f60eafbf009a 1055
gmehmet 1:f60eafbf009a 1056 break;
gmehmet 1:f60eafbf009a 1057 #endif
gmehmet 1:f60eafbf009a 1058 case DISPLAYMODE_ECG:
gmehmet 1:f60eafbf009a 1059 display.printf("ECG");
gmehmet 1:f60eafbf009a 1060 display.set_font(UbuntuCondensed38x47);
gmehmet 1:f60eafbf009a 1061 display.locate(8, 40);
gmehmet 1:f60eafbf009a 1062 display.foreground((uint16_t)Black);
gmehmet 1:f60eafbf009a 1063 display.background((uint16_t)White);
gmehmet 1:f60eafbf009a 1064 display.printf("%d", 70);
gmehmet 1:f60eafbf009a 1065
gmehmet 1:f60eafbf009a 1066 display.set_font(UbuntuCondensed20x26);
gmehmet 1:f60eafbf009a 1067 display.locate(72, 57);
gmehmet 1:f60eafbf009a 1068 display.foreground((uint16_t)Black);
gmehmet 1:f60eafbf009a 1069 display.background((uint16_t)White);
gmehmet 1:f60eafbf009a 1070 display.printf("BPM");
gmehmet 1:f60eafbf009a 1071
gmehmet 1:f60eafbf009a 1072 break;
gmehmet 1:f60eafbf009a 1073 #ifndef ENABLE_SPO2
gmehmet 1:f60eafbf009a 1074 case DISPLAYMODE_TEMP:
gmehmet 1:f60eafbf009a 1075 display.printf("TEMP");
gmehmet 1:f60eafbf009a 1076 display.set_font(UbuntuCondensed38x47);
gmehmet 1:f60eafbf009a 1077 display.locate(8, 40);
gmehmet 1:f60eafbf009a 1078 display.foreground((uint16_t)Black);
gmehmet 1:f60eafbf009a 1079 display.background((uint16_t)White);
gmehmet 1:f60eafbf009a 1080 display.printf("%2.1f", instant_temp_celsius);
gmehmet 1:f60eafbf009a 1081
gmehmet 1:f60eafbf009a 1082 display.set_font(UbuntuCondensed20x26);
gmehmet 1:f60eafbf009a 1083 display.locate(92, 55);
gmehmet 1:f60eafbf009a 1084 display.foreground((uint16_t)Black);
gmehmet 1:f60eafbf009a 1085 display.background((uint16_t)White);
gmehmet 1:f60eafbf009a 1086 display.printf("%cC", 127);
gmehmet 1:f60eafbf009a 1087
gmehmet 1:f60eafbf009a 1088
gmehmet 1:f60eafbf009a 1089 break;
gmehmet 1:f60eafbf009a 1090 #endif
gmehmet 1:f60eafbf009a 1091 case DISPLAYMODE_TETHERED:
gmehmet 1:f60eafbf009a 1092 display.printf("CONN");
gmehmet 1:f60eafbf009a 1093 display.set_font(UbuntuCondensed38x47);
gmehmet 1:f60eafbf009a 1094 display.locate(30, 40);
gmehmet 1:f60eafbf009a 1095 display.foreground((uint16_t)Black);
gmehmet 1:f60eafbf009a 1096 display.background((uint16_t)White);
gmehmet 1:f60eafbf009a 1097 display.printf("BLE", 24);
gmehmet 1:f60eafbf009a 1098
gmehmet 1:f60eafbf009a 1099 display_BLEMode_Active = true;
gmehmet 1:f60eafbf009a 1100
gmehmet 1:f60eafbf009a 1101 break;
gmehmet 1:f60eafbf009a 1102
gmehmet 1:f60eafbf009a 1103 case DISPLAYMODE_TETHERED_USB:
gmehmet 1:f60eafbf009a 1104 if (USB_Interface_MSD) {
gmehmet 1:f60eafbf009a 1105 display.printf("MSD");
gmehmet 1:f60eafbf009a 1106 } else {
gmehmet 1:f60eafbf009a 1107 display.printf("CONN");
gmehmet 1:f60eafbf009a 1108 }
gmehmet 1:f60eafbf009a 1109 display.set_font(UbuntuCondensed38x47);
gmehmet 1:f60eafbf009a 1110 display.locate(30, 40);
gmehmet 1:f60eafbf009a 1111 display.foreground((uint16_t)Black);
gmehmet 1:f60eafbf009a 1112 display.background((uint16_t)White);
gmehmet 1:f60eafbf009a 1113 display.printf("USB", 24);
gmehmet 1:f60eafbf009a 1114
gmehmet 1:f60eafbf009a 1115 display_USBMode_Active = true;
gmehmet 1:f60eafbf009a 1116
gmehmet 1:f60eafbf009a 1117 break;
gmehmet 1:f60eafbf009a 1118
gmehmet 1:f60eafbf009a 1119 }
gmehmet 1:f60eafbf009a 1120
gmehmet 1:f60eafbf009a 1121
gmehmet 1:f60eafbf009a 1122 display.showBMP((uint8_t*)maxim128Bitmaps, 120, 36, 8, 90);
gmehmet 1:f60eafbf009a 1123
gmehmet 1:f60eafbf009a 1124
gmehmet 1:f60eafbf009a 1125 if (refreshed) {
gmehmet 1:f60eafbf009a 1126 refreshed = false;
gmehmet 1:f60eafbf009a 1127 display.update(this->refreshCallback);
gmehmet 1:f60eafbf009a 1128 }
gmehmet 1:f60eafbf009a 1129
gmehmet 1:f60eafbf009a 1130
gmehmet 1:f60eafbf009a 1131 }
gmehmet 1:f60eafbf009a 1132
gmehmet 1:f60eafbf009a 1133