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