Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: max32630fthr Adafruit_FeatherOLED USBDevice
WatchInterface.h
00001 /******************************************************************************* 00002 * Copyright (C) Maxim Integrated Products, Inc., All rights Reserved. 00003 * 00004 * This software is protected by copyright laws of the United States and 00005 * of foreign countries. This material may also be protected by patent laws 00006 * and technology transfer regulations of the United States and of foreign 00007 * countries. This software is furnished under a license agreement and/or a 00008 * nondisclosure agreement and may only be used or reproduced in accordance 00009 * with the terms of those agreements. Dissemination of this information to 00010 * any party or parties not specified in the license agreement and/or 00011 * nondisclosure agreement is expressly prohibited. 00012 * 00013 * The above copyright notice and this permission notice shall be included 00014 * in all copies or substantial portions of the Software. 00015 * 00016 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00017 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00018 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00019 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES 00020 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00021 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00022 * OTHER DEALINGS IN THE SOFTWARE. 00023 * 00024 * Except as contained in this notice, the name of Maxim Integrated 00025 * Products, Inc. shall not be used except as stated in the Maxim Integrated 00026 * Products, Inc. Branding Policy. 00027 * 00028 * The mere transfer of this software does not imply any licenses 00029 * of trade secrets, proprietary technology, copyrights, patents, 00030 * trademarks, maskwork rights, or any other form of intellectual 00031 * property whatsoever. Maxim Integrated Products, Inc. retains all 00032 * ownership rights. 00033 ******************************************************************************* 00034 */ 00035 00036 #define BATTERY_GAUGE_COUNT 50 00037 #define BATTERY_CRITICAL_LEVEL 5 00038 00039 00040 00041 00042 #ifndef UTILITIES_WATCHINTERFACE_H_ 00043 #define UTILITIES_WATCHINTERFACE_H_ 00044 #include "mbed.h" 00045 #include "LS013B7DH03.h" 00046 #include "version.h" 00047 #include "BLE_ICARUS.h" 00048 00049 #include "MAX20303.h" 00050 00051 00052 #define DISPLAYMODE_TIME 0 00053 #define DISPLAYMODE_PPG 1 00054 #ifdef ENABLE_SPO2 00055 #define DISPLAYMODE_SPO2_ONESHOT 2 00056 #define DISPLAYMODE_SPO2_CONTINUOUS 3 00057 #else 00058 #define DISPLAYMODE_TEMP 4 00059 #endif 00060 #define DISPLAYMODE_INFO 5 00061 #define DISPLAYMODE_ECG 6 00062 #define DISPLAYMODE_TETHERED 7 00063 #define DISPLAYMODE_TETHERED_USB 8 00064 #define DISPLAYMODE_LOGO 9 00065 #define DISPLAYMODE_RECORDING 10 00066 #define DISPLAYMODE_RECORDING_STOP 11 00067 #define DISPLAYMODE_AFTERBOOT 12 00068 00069 00070 typedef enum { 00071 00072 BUTTONEVENT_NONE, 00073 BUTTONEVENT_UP_PRE, 00074 BUTTONEVENT_DOWN_PRE, 00075 BUTTONEVENT_UP, 00076 BUTTONEVENT_DOWN 00077 00078 } Button_Event; 00079 00080 class WatchInterface 00081 { 00082 public: 00083 00084 00085 typedef enum { 00086 /** No activity, or very light activity. */ 00087 ACTD_REST_ACTIVITY = 0, 00088 /** Non-rhythmic activities that cannot be classified in the other categories. */ 00089 ACTD_OTHER_ACTIVITY = 1, 00090 /** Walking activity. */ 00091 ACTD_WALK_ACTIVITY = 2, 00092 /** Running activity. */ 00093 ACTD_RUN_ACTIVITY = 3, 00094 /** Biking activity. */ 00095 ACTD_BIKE_ACTIVITY = 4, 00096 /** Rhythmic activities that cannot be classified in the other categories. */ 00097 ACTD_OTHER_RYTHMIC_ACTIVITY = 5, 00098 } actd_ActivityClass_te; 00099 00100 00101 typedef enum { 00102 BUTTON_PRESSED = 1, 00103 BUTTON_RELEASED = 0 00104 00105 } ButtonStatus; 00106 00107 00108 typedef enum { 00109 BUTTON_POWER = 0, 00110 BUTTON_UP = 1, 00111 BUTTON_DOWN = 2 00112 00113 } hspButton; 00114 00115 00116 /** Create an Watch Interface controller 00117 * 00118 * @param buttonUp PinName UP button 00119 * @param buttonDown PinName DOWN button 00120 * @param buttonPower PinName POWER button 00121 */ 00122 WatchInterface(PinName buttonUp, PinName buttonDown, PinName buttonPower, PinName displayCS, PinName displayEXTCOM, PinName displayDISP, SPI* displaySPI); 00123 00124 void updateDisplay(int batteryLevelToBeScaled); 00125 void execute(void); 00126 void displayOff(bool off); 00127 void DisplayStatus(); 00128 void DisplayModeUpdated(); 00129 00130 static void refreshCallback(void); 00131 00132 unsigned char connection_indicator; 00133 00134 ButtonStatus getButtonStatus(hspButton button); 00135 00136 uint16_t heartRate; 00137 uint16_t heartRateConfidence; 00138 volatile bool BLE_Interface_Exists, BLE_Interface_Exists_old; 00139 volatile bool USB_Interface_Exists, USB_Interface_Exists_old; 00140 volatile bool USB_Interface_MSD; 00141 volatile bool recording, recording_old; 00142 00143 bool recordingStopFlag; 00144 00145 volatile bool modeUpdated; 00146 00147 unsigned char batteryLevel; 00148 00149 volatile Button_Event buttonEvent_down; 00150 volatile Button_Event buttonEvent_up; 00151 00152 unsigned char displayMode; 00153 unsigned char displayMode_old; 00154 bool isDisplayOff; 00155 00156 volatile bool BLEWasActive; 00157 volatile bool USBWasActive; 00158 00159 bool ecg_enabled; 00160 bool ppg_enabled; 00161 00162 bool bootComplete; 00163 00164 uint16_t last_good_hr; 00165 uint16_t instant_hr; 00166 uint16_t instant_hr_conf; 00167 uint8_t instant_hr_activityClass; 00168 float instant_temp_celsius; 00169 00170 char m_mac_addr_[6]; 00171 00172 MAX20303* m_max20303_; 00173 00174 00175 00176 protected: 00177 00178 private: 00179 00180 00181 00182 //Ticker m_watchInterface_ticker_; 00183 00184 InterruptIn btnUp; 00185 InterruptIn btnDown; 00186 DigitalIn btnPower; 00187 DigitalOut dispCS; 00188 PinName dispEXTCOM; 00189 DigitalOut dispDISP; 00190 00191 PwmOut DisplayPWM; 00192 00193 Timer interfaceTimer; 00194 00195 volatile int buttonTimer; 00196 00197 void isr_buttonup(); 00198 void isr_buttondown(); 00199 00200 bool display_BLEMode_Active; 00201 bool display_USBMode_Active; 00202 00203 silabs::LS013B7DH03 display; 00204 00205 unsigned char ppg_lcd_count; //a variable used to print "MEASURING" while the ppg settling 00206 00207 static bool refreshed; 00208 00209 static const uint16_t kHeartRateUpperLimit = 240; 00210 static const uint16_t kHeartRateLowerLimit = 40; 00211 static const uint16_t ConfThresLevelRest = 50; 00212 static const uint16_t ConfThresLevelOther = 10; 00213 00214 00215 }; 00216 00217 00218 #endif
Generated on Wed Jul 13 2022 22:33:03 by
1.7.2