TEST
Dependencies: max32630fthr Adafruit_FeatherOLED USBDevice
Diff: Utilities/WatchInterface.h
- Revision:
- 1:f60eafbf009a
- Child:
- 3:2fe2ff1ca0dc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Utilities/WatchInterface.h Wed Apr 10 14:56:25 2019 +0300 @@ -0,0 +1,190 @@ +/* + * WatchInterface.h + * + * Created on: Aug 28, 2018 + * Author: Gokhan.Bektas + */ + +#define BATTERY_GAUGE_COUNT 50 +#define BATTERY_CRITICAL_LEVEL 5 + + + + +#ifndef UTILITIES_WATCHINTERFACE_H_ +#define UTILITIES_WATCHINTERFACE_H_ +#include "mbed.h" +#include "LS013B7DH03.h" +#include "version.h" +#include "BLE_ICARUS.h" + +#include "MAX20303.h" + + + #define DISPLAYMODE_TIME 0 + #define DISPLAYMODE_PPG 1 +#ifdef ENABLE_SPO2 + #define DISPLAYMODE_SPO2_ONESHOT 2 + #define DISPLAYMODE_SPO2_CONTINUOUS 3 +#else + #define DISPLAYMODE_TEMP 4 +#endif + #define DISPLAYMODE_INFO 5 + #define DISPLAYMODE_ECG 6 + #define DISPLAYMODE_TETHERED 7 + #define DISPLAYMODE_TETHERED_USB 8 + #define DISPLAYMODE_LOGO 9 + #define DISPLAYMODE_RECORDING 10 + #define DISPLAYMODE_RECORDING_STOP 11 + #define DISPLAYMODE_AFTERBOOT 12 + + +typedef enum { + + BUTTONEVENT_NONE, + BUTTONEVENT_UP_PRE, + BUTTONEVENT_DOWN_PRE, + BUTTONEVENT_UP, + BUTTONEVENT_DOWN + +} Button_Event; + +class WatchInterface +{ +public: + + + typedef enum { + /** No activity, or very light activity. */ + ACTD_REST_ACTIVITY = 0, + /** Non-rhythmic activities that cannot be classified in the other categories. */ + ACTD_OTHER_ACTIVITY = 1, + /** Walking activity. */ + ACTD_WALK_ACTIVITY = 2, + /** Running activity. */ + ACTD_RUN_ACTIVITY = 3, + /** Biking activity. */ + ACTD_BIKE_ACTIVITY = 4, + /** Rhythmic activities that cannot be classified in the other categories. */ + ACTD_OTHER_RYTHMIC_ACTIVITY = 5, + } actd_ActivityClass_te; + + + typedef enum { + BUTTON_PRESSED = 1, + BUTTON_RELEASED = 0 + + } ButtonStatus; + + + typedef enum { + BUTTON_POWER = 0, + BUTTON_UP = 1, + BUTTON_DOWN = 2 + + } hspButton; + + + /** Create an Watch Interface controller + * + * @param buttonUp PinName UP button + * @param buttonDown PinName DOWN button + * @param buttonPower PinName POWER button + */ + WatchInterface(PinName buttonUp, PinName buttonDown, PinName buttonPower, PinName displayCS, PinName displayEXTCOM, PinName displayDISP, SPI* displaySPI); + + void updateDisplay(int batteryLevelToBeScaled); + void execute(void); + void displayOff(bool off); + void DisplayStatus(); + void DisplayModeUpdated(); + + static void refreshCallback(void); + + unsigned char connection_indicator; + + ButtonStatus getButtonStatus(hspButton button); + + uint16_t heartRate; + uint16_t heartRateConfidence; + volatile bool BLE_Interface_Exists, BLE_Interface_Exists_old; + volatile bool USB_Interface_Exists, USB_Interface_Exists_old; + volatile bool USB_Interface_MSD; + volatile bool recording, recording_old; + + bool recordingStopFlag; + + volatile bool modeUpdated; + + unsigned char batteryLevel; + + volatile Button_Event buttonEvent_down; + volatile Button_Event buttonEvent_up; + + unsigned char displayMode; + unsigned char displayMode_old; + bool isDisplayOff; + + volatile bool BLEWasActive; + volatile bool USBWasActive; + + bool ecg_enabled; + bool ppg_enabled; + + bool bootComplete; + + uint16_t last_good_hr; + uint16_t instant_hr; + uint16_t instant_hr_conf; + uint8_t instant_hr_activityClass; + float instant_temp_celsius; + + char m_mac_addr_[6]; + + MAX20303* m_max20303_; + + + +protected: + +private: + + + + //Ticker m_watchInterface_ticker_; + + InterruptIn btnUp; + InterruptIn btnDown; + DigitalIn btnPower; + DigitalOut dispCS; + PinName dispEXTCOM; + DigitalOut dispDISP; + + PwmOut DisplayPWM; + + Timer interfaceTimer; + + volatile int buttonTimer; + + void isr_buttonup(); + void isr_buttondown(); + + bool display_BLEMode_Active; + bool display_USBMode_Active; + + silabs::LS013B7DH03 display; + + unsigned char ppg_lcd_count; //a variable used to print "MEASURING" while the ppg settling + + static bool refreshed; + + static const uint16_t kHeartRateUpperLimit = 240; + static const uint16_t kHeartRateLowerLimit = 40; + static const uint16_t ConfThresLevelRest = 50; + static const uint16_t ConfThresLevelOther = 10; + + +}; + + +#endif