Example of using Hexiwear buttons and declaring screens.
Dependencies: FXOS8700 FXAS21002 Hexi_KW40Z Hexi_OLED_SSD1351
main.cpp@2:824ed4ae8d52, 2018-02-05 (annotated)
- Committer:
- asong
- Date:
- Mon Feb 05 16:14:13 2018 +0000
- Revision:
- 2:824ed4ae8d52
- Parent:
- 1:e4b38d6918ba
- Child:
- 3:53c096a80151
Newest version with cleaned up code and more heart rate logic ; ; -Alex
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
asong | 1:e4b38d6918ba | 1 | /********************************************************************** |
asong | 1:e4b38d6918ba | 2 | Texas State University Senior Project - HexiHeart |
nbaker | 0:d1d36a3da39b | 3 | Team Zeta: Alex Song, Jasmine Rounsaville, Issam Hichami, Neil Baker |
nbaker | 0:d1d36a3da39b | 4 | Version: HexiHeart_1st 11/12/17 |
nbaker | 0:d1d36a3da39b | 5 | This version has basic menu layout and screen timeout feature. The menu |
asong | 1:e4b38d6918ba | 6 | are just placeholders (for the most part) and will be either adjusted or |
nbaker | 0:d1d36a3da39b | 7 | replaced with graphic images. |
nbaker | 0:d1d36a3da39b | 8 | |
nbaker | 0:d1d36a3da39b | 9 | ***********************************************************************/ |
nbaker | 0:d1d36a3da39b | 10 | |
nbaker | 0:d1d36a3da39b | 11 | #include "mbed.h" |
nbaker | 0:d1d36a3da39b | 12 | #include "Hexi_KW40Z.h" // Button and BLE fuctions |
nbaker | 0:d1d36a3da39b | 13 | #include "FXOS8700.h" // 3D Accelorometer & Mag |
nbaker | 0:d1d36a3da39b | 14 | #include "FXAS21002.h" // 3-Axis Gyroscope |
nbaker | 0:d1d36a3da39b | 15 | #include "Hexi_OLED_SSD1351.h" // OLED fuctions |
nbaker | 0:d1d36a3da39b | 16 | #include "OLED_types.h" // Text attributs |
nbaker | 0:d1d36a3da39b | 17 | #include "string.h" |
nbaker | 0:d1d36a3da39b | 18 | #include "OpenSans_Font.h" |
asong | 1:e4b38d6918ba | 19 | #include "MAX30101.h" |
asong | 1:e4b38d6918ba | 20 | |
asong | 2:824ed4ae8d52 | 21 | |
asong | 1:e4b38d6918ba | 22 | /* We need to confirm whether it's better to include and |
asong | 1:e4b38d6918ba | 23 | configure every module for lowest power, or whether it's |
nbaker | 0:d1d36a3da39b | 24 | better to save memory by not doing that |
nbaker | 0:d1d36a3da39b | 25 | */ |
nbaker | 0:d1d36a3da39b | 26 | |
nbaker | 0:d1d36a3da39b | 27 | // Definitions |
asong | 2:824ed4ae8d52 | 28 | #define LED_ON 0 |
asong | 2:824ed4ae8d52 | 29 | #define LED_OFF 1 |
asong | 2:824ed4ae8d52 | 30 | #define SCRN_TIME 10.0 |
asong | 2:824ed4ae8d52 | 31 | #define Debug 1 // If "Debug" is defined, our code will compile for debug. Comment out for Production code. |
asong | 2:824ed4ae8d52 | 32 | #define HIGHEST_ZONE 4 |
asong | 2:824ed4ae8d52 | 33 | #define LOWEST_ZONE 1 |
asong | 2:824ed4ae8d52 | 34 | #define ENTER_BELOW 25 |
asong | 2:824ed4ae8d52 | 35 | #define ENTER_ABOVE 50 |
asong | 2:824ed4ae8d52 | 36 | #define EXIT_BELOW 75 |
asong | 2:824ed4ae8d52 | 37 | #define EXIT_ABOVE 100 |
asong | 2:824ed4ae8d52 | 38 | #define VIB_OPT_2 75 |
asong | 2:824ed4ae8d52 | 39 | |
asong | 1:e4b38d6918ba | 40 | |
nbaker | 0:d1d36a3da39b | 41 | void StartHaptic(void); |
asong | 1:e4b38d6918ba | 42 | void StartHaptic(int x); |
nbaker | 0:d1d36a3da39b | 43 | void StopHaptic(void const *n); |
nbaker | 0:d1d36a3da39b | 44 | void error_screen(void); |
nbaker | 0:d1d36a3da39b | 45 | void update_display(void); |
asong | 2:824ed4ae8d52 | 46 | void Decrement_Age(); |
asong | 2:824ed4ae8d52 | 47 | void Set_Max_Bpm(); |
asong | 2:824ed4ae8d52 | 48 | void Set_Zone_Boundaries(); |
asong | 2:824ed4ae8d52 | 49 | void Increment_Age(); |
asong | 2:824ed4ae8d52 | 50 | void Increment_Target_Zone(); |
asong | 2:824ed4ae8d52 | 51 | void Decrement_Target_Zone(); |
asong | 2:824ed4ae8d52 | 52 | void Increment_HR_Vibr_Pref(); |
asong | 2:824ed4ae8d52 | 53 | void Decrement_HR_Vibr_Pref(); |
asong | 2:824ed4ae8d52 | 54 | void Determine_Current_Zone(); |
asong | 2:824ed4ae8d52 | 55 | void Heart_Rate_Vibrations(); |
asong | 2:824ed4ae8d52 | 56 | void Increment_Heart_Rate(); |
asong | 2:824ed4ae8d52 | 57 | void Decrement_Heart_Rate(); |
asong | 2:824ed4ae8d52 | 58 | void Enable_Heart_Rate(); |
asong | 2:824ed4ae8d52 | 59 | void Disable_Heart_Rate(); |
asong | 2:824ed4ae8d52 | 60 | void Led_Zone_Indicator(); |
nbaker | 0:d1d36a3da39b | 61 | |
asong | 1:e4b38d6918ba | 62 | |
nbaker | 0:d1d36a3da39b | 63 | // ***************** Global variables *********************** |
nbaker | 0:d1d36a3da39b | 64 | char text_1[20]; // Text buffer - Do we need more? |
asong | 2:824ed4ae8d52 | 65 | char display_buff[30]; //Buffer for conversion to char to display |
asong | 2:824ed4ae8d52 | 66 | bool Led_Zones = 1; |
asong | 1:e4b38d6918ba | 67 | bool HR_Enable = 0; |
nbaker | 0:d1d36a3da39b | 68 | bool OLED_ON = 1; // Turn OLED power on/off |
nbaker | 0:d1d36a3da39b | 69 | bool Fall_Alert = 0; // Initialize as no active alert |
nbaker | 0:d1d36a3da39b | 70 | bool Panic_Alert = 0; // Initialize as no active alert |
asong | 1:e4b38d6918ba | 71 | bool Fall_Alert_Mode = 1; // Initialize with fall alert mode on |
asong | 1:e4b38d6918ba | 72 | bool Heart_Rate_Mode = 0; // Initialize with Heart rate off |
nbaker | 0:d1d36a3da39b | 73 | float Accel_Mag=0.0; // Vector magnitude calculated from sensor data |
nbaker | 0:d1d36a3da39b | 74 | float Accel_Data[3]; // Accel Data from sensor |
nbaker | 0:d1d36a3da39b | 75 | float Gyro_Mag=0.0; // Vector magnitude calculated from sensor data |
nbaker | 0:d1d36a3da39b | 76 | float Gyro_Data[3]; // Gyro data from sensor |
nbaker | 0:d1d36a3da39b | 77 | float Fall_Thresh=0.5; // Initialize Fall detect Threshold |
nbaker | 0:d1d36a3da39b | 78 | float Impact_Thresh=3.0; // Initialize Impact detect Threshold |
nbaker | 0:d1d36a3da39b | 79 | float Movement_Thresh=50.0; // Initialize Movement detect Threshold |
asong | 2:824ed4ae8d52 | 80 | uint8_t Current_Zone = 1; |
asong | 2:824ed4ae8d52 | 81 | uint8_t Prev_Zone = 1; |
asong | 2:824ed4ae8d52 | 82 | uint8_t Heart_Rate = 100; |
asong | 1:e4b38d6918ba | 83 | uint8_t HR_buff[250]; |
asong | 1:e4b38d6918ba | 84 | uint8_t *HR_return; |
asong | 1:e4b38d6918ba | 85 | uint8_t Age = 50; // Initialize age |
asong | 2:824ed4ae8d52 | 86 | uint8_t Max_Bpm = 220 - Age; // Initialize Max BPM |
nbaker | 0:d1d36a3da39b | 87 | uint8_t Screen_Num = 0; // Initialize to main screen |
asong | 1:e4b38d6918ba | 88 | uint8_t Error_Num = 0; // Error num for debug |
asong | 2:824ed4ae8d52 | 89 | uint8_t HR_Vibration = 2; //Choose Heart Rate Vibration Options |
asong | 2:824ed4ae8d52 | 90 | uint8_t Target_Zone = 2; //Initialize Target Heart Rate Zone to Zone 3 |
asong | 2:824ed4ae8d52 | 91 | uint8_t HR_Zone1[2] = {Max_Bpm * .50, Max_Bpm * .60}; //Heart Rate Zone 1 |
asong | 2:824ed4ae8d52 | 92 | uint8_t HR_Zone2[2] = {HR_Zone1[1] + 1, Max_Bpm * .70}; //Heart Rate Zone 2 |
asong | 2:824ed4ae8d52 | 93 | uint8_t HR_Zone3[2] = {HR_Zone2[1] + 1, Max_Bpm * .80}; //Heart Rate Zone 3 |
asong | 2:824ed4ae8d52 | 94 | uint8_t HR_Zone4[2] = {HR_Zone3[1] + 1, Max_Bpm}; //Heart Rate Zone 4 |
nbaker | 0:d1d36a3da39b | 95 | // ***************** Define pins ***************************** |
nbaker | 0:d1d36a3da39b | 96 | FXAS21002 gyro(PTC11,PTC10); // Gyroscope |
nbaker | 0:d1d36a3da39b | 97 | SSD1351 oled(PTB22,PTB21,PTC13,PTB20,PTE6, PTD15); // SSD1351 OLED Driver (MOSI,SCLK,POWER,CS,RST,DC) |
nbaker | 0:d1d36a3da39b | 98 | FXOS8700 accel(PTC11, PTC10); // Accelorometer |
nbaker | 0:d1d36a3da39b | 99 | FXOS8700 mag(PTC11, PTC10); // Mag (same chip as Accel) |
asong | 1:e4b38d6918ba | 100 | //MAX30101 heart(PTB1, PTB0); //Heart Rate Chip |
nbaker | 0:d1d36a3da39b | 101 | |
nbaker | 0:d1d36a3da39b | 102 | DigitalOut RED_Led(LED1); |
nbaker | 0:d1d36a3da39b | 103 | DigitalOut GRN_Led(LED2); |
nbaker | 0:d1d36a3da39b | 104 | DigitalOut BLU_Led(LED3); |
nbaker | 0:d1d36a3da39b | 105 | DigitalOut haptic(PTB9); |
nbaker | 0:d1d36a3da39b | 106 | |
asong | 1:e4b38d6918ba | 107 | /* Instantiate the Hexi KW40Z Driver (UART TX, UART RX) */ |
nbaker | 0:d1d36a3da39b | 108 | KW40Z kw40z_device(PTE24, PTE25); |
nbaker | 0:d1d36a3da39b | 109 | |
nbaker | 0:d1d36a3da39b | 110 | /* Define timer for haptic feedback */ |
nbaker | 0:d1d36a3da39b | 111 | RtosTimer hapticTimer(StopHaptic, osTimerOnce); |
nbaker | 0:d1d36a3da39b | 112 | |
nbaker | 0:d1d36a3da39b | 113 | //***************** Tickers and Timers ***************** |
nbaker | 0:d1d36a3da39b | 114 | Ticker Screen_Timer;// use ticker to turn off OLED |
nbaker | 0:d1d36a3da39b | 115 | |
asong | 1:e4b38d6918ba | 116 | void timout_timer() // turn off display mode |
asong | 1:e4b38d6918ba | 117 | { |
asong | 1:e4b38d6918ba | 118 | oled.FillScreen(COLOR_BLACK); // Clear screen.. is there a better command for this? |
asong | 1:e4b38d6918ba | 119 | OLED_ON = 0; // set flag to off |
asong | 1:e4b38d6918ba | 120 | Screen_Timer.detach(); |
asong | 1:e4b38d6918ba | 121 | }//end routine |
asong | 1:e4b38d6918ba | 122 | |
nbaker | 0:d1d36a3da39b | 123 | void ButtonUp(void) |
nbaker | 0:d1d36a3da39b | 124 | { |
asong | 1:e4b38d6918ba | 125 | Screen_Timer.attach(&timout_timer,(SCRN_TIME));//Is this sufficient to reset/restart ticker timer for OLED? |
asong | 1:e4b38d6918ba | 126 | if (OLED_ON == 0) { |
asong | 1:e4b38d6918ba | 127 | OLED_ON = 1; // Scree was off, set to On |
asong | 1:e4b38d6918ba | 128 | update_display(); |
asong | 1:e4b38d6918ba | 129 | } else { |
asong | 1:e4b38d6918ba | 130 | switch(Screen_Num) { |
asong | 1:e4b38d6918ba | 131 | case 0: {// We're in Main Screen |
asong | 1:e4b38d6918ba | 132 | // do nothing, wrong button |
asong | 1:e4b38d6918ba | 133 | break; |
asong | 1:e4b38d6918ba | 134 | } |
asong | 1:e4b38d6918ba | 135 | case 1: {// Panic Alert option |
asong | 1:e4b38d6918ba | 136 | StartHaptic(); |
asong | 1:e4b38d6918ba | 137 | Screen_Num = 26; //Change to screen 5 |
nbaker | 0:d1d36a3da39b | 138 | #ifdef Debug // in debug show debug/diagnostic screens |
asong | 1:e4b38d6918ba | 139 | Screen_Num = 26; //Change to screen 20 |
nbaker | 0:d1d36a3da39b | 140 | #endif |
nbaker | 0:d1d36a3da39b | 141 | |
asong | 1:e4b38d6918ba | 142 | update_display(); |
asong | 1:e4b38d6918ba | 143 | break; |
asong | 1:e4b38d6918ba | 144 | } |
asong | 1:e4b38d6918ba | 145 | case 2: {// Fall Alert option |
asong | 1:e4b38d6918ba | 146 | StartHaptic(); |
asong | 1:e4b38d6918ba | 147 | Screen_Num = 1; //Change to screen 1 |
asong | 1:e4b38d6918ba | 148 | update_display(); |
asong | 1:e4b38d6918ba | 149 | break; |
asong | 1:e4b38d6918ba | 150 | } |
asong | 1:e4b38d6918ba | 151 | case 3: {// Heart Rate Monitoring option |
asong | 1:e4b38d6918ba | 152 | StartHaptic(); |
asong | 1:e4b38d6918ba | 153 | Screen_Num = 2; //Change to screen 2 |
asong | 1:e4b38d6918ba | 154 | update_display(); |
asong | 1:e4b38d6918ba | 155 | break; |
asong | 1:e4b38d6918ba | 156 | } |
asong | 1:e4b38d6918ba | 157 | case 4: {// Alert History option |
asong | 1:e4b38d6918ba | 158 | StartHaptic(); |
asong | 1:e4b38d6918ba | 159 | Screen_Num = 3; //Change to screen 3 |
asong | 1:e4b38d6918ba | 160 | update_display(); |
asong | 1:e4b38d6918ba | 161 | break; |
asong | 1:e4b38d6918ba | 162 | } |
asong | 1:e4b38d6918ba | 163 | case 5: {// About HexiHeart |
asong | 1:e4b38d6918ba | 164 | StartHaptic(); |
asong | 1:e4b38d6918ba | 165 | Screen_Num = 4; //Change to screen 4 |
asong | 1:e4b38d6918ba | 166 | update_display(); |
asong | 1:e4b38d6918ba | 167 | break; |
asong | 1:e4b38d6918ba | 168 | } |
asong | 1:e4b38d6918ba | 169 | case 6: {// Panic Alert |
asong | 1:e4b38d6918ba | 170 | StartHaptic(); |
asong | 1:e4b38d6918ba | 171 | Panic_Alert = !Panic_Alert; |
asong | 1:e4b38d6918ba | 172 | update_display(); |
asong | 1:e4b38d6918ba | 173 | break; |
asong | 1:e4b38d6918ba | 174 | } |
asong | 1:e4b38d6918ba | 175 | case 7: {// Heart Rate Zone |
asong | 1:e4b38d6918ba | 176 | StartHaptic(50); |
asong | 2:824ed4ae8d52 | 177 | Enable_Heart_Rate(); |
asong | 1:e4b38d6918ba | 178 | //heart.enable(); |
asong | 1:e4b38d6918ba | 179 | //HR_Enable = 1; |
asong | 1:e4b38d6918ba | 180 | //while(HR_Enable == 1) |
asong | 1:e4b38d6918ba | 181 | // heart.readRawData(HR_buff, HR_return); |
asong | 1:e4b38d6918ba | 182 | //update_display(); |
asong | 1:e4b38d6918ba | 183 | break; |
asong | 1:e4b38d6918ba | 184 | } |
asong | 1:e4b38d6918ba | 185 | case 8: {// Alert History |
asong | 1:e4b38d6918ba | 186 | StartHaptic(); |
asong | 1:e4b38d6918ba | 187 | //Increment alert index |
asong | 1:e4b38d6918ba | 188 | break; |
asong | 1:e4b38d6918ba | 189 | } |
asong | 1:e4b38d6918ba | 190 | case 20: {// Diagnostic/Debug Screens |
asong | 1:e4b38d6918ba | 191 | StartHaptic(); |
asong | 1:e4b38d6918ba | 192 | Screen_Num = 5; //Change to screen 5 |
asong | 1:e4b38d6918ba | 193 | update_display(); |
asong | 1:e4b38d6918ba | 194 | break; |
asong | 1:e4b38d6918ba | 195 | } |
asong | 1:e4b38d6918ba | 196 | case 21: {// Fall Diagnostic |
asong | 1:e4b38d6918ba | 197 | StartHaptic(); |
asong | 1:e4b38d6918ba | 198 | Screen_Num = 25; //Change to screen 25 |
asong | 1:e4b38d6918ba | 199 | update_display(); |
asong | 1:e4b38d6918ba | 200 | break; |
asong | 1:e4b38d6918ba | 201 | } |
asong | 1:e4b38d6918ba | 202 | case 22: {// Fall Debug |
asong | 1:e4b38d6918ba | 203 | StartHaptic(); |
asong | 1:e4b38d6918ba | 204 | Screen_Num = 21; //Change to screen 21 |
asong | 1:e4b38d6918ba | 205 | update_display(); |
asong | 1:e4b38d6918ba | 206 | break; |
asong | 1:e4b38d6918ba | 207 | } |
asong | 1:e4b38d6918ba | 208 | case 23: {// Heart Rate Diagnostic |
asong | 1:e4b38d6918ba | 209 | StartHaptic(); |
asong | 1:e4b38d6918ba | 210 | Screen_Num = 22; //Change to screen 22 |
asong | 1:e4b38d6918ba | 211 | update_display(); |
asong | 1:e4b38d6918ba | 212 | break; |
asong | 1:e4b38d6918ba | 213 | } |
asong | 1:e4b38d6918ba | 214 | case 24: {// Heart Rate Debug |
asong | 1:e4b38d6918ba | 215 | StartHaptic(); |
asong | 1:e4b38d6918ba | 216 | Screen_Num = 23; //Change to screen 23 |
asong | 1:e4b38d6918ba | 217 | update_display(); |
asong | 1:e4b38d6918ba | 218 | break; |
asong | 1:e4b38d6918ba | 219 | } |
asong | 1:e4b38d6918ba | 220 | case 25: {// Heat Index Diagnostic |
asong | 1:e4b38d6918ba | 221 | StartHaptic(); |
asong | 1:e4b38d6918ba | 222 | Screen_Num = 24; //Change to screen 24 |
asong | 1:e4b38d6918ba | 223 | update_display(); |
asong | 1:e4b38d6918ba | 224 | break; |
asong | 1:e4b38d6918ba | 225 | } |
asong | 1:e4b38d6918ba | 226 | case 26: {//Heart Rate Config Option |
asong | 1:e4b38d6918ba | 227 | StartHaptic(); |
asong | 1:e4b38d6918ba | 228 | Screen_Num = 20; |
asong | 1:e4b38d6918ba | 229 | update_display(); |
asong | 1:e4b38d6918ba | 230 | break; |
asong | 1:e4b38d6918ba | 231 | } |
asong | 1:e4b38d6918ba | 232 | case 27: {//Incrementing Age |
asong | 2:824ed4ae8d52 | 233 | Increment_Age(); |
asong | 2:824ed4ae8d52 | 234 | Set_Zone_Boundaries(); |
asong | 1:e4b38d6918ba | 235 | update_display(); |
asong | 1:e4b38d6918ba | 236 | break; |
asong | 1:e4b38d6918ba | 237 | } |
asong | 1:e4b38d6918ba | 238 | case 28: {//Changing Heart Rate Vibration Preferences |
asong | 2:824ed4ae8d52 | 239 | Increment_HR_Vibr_Pref(); |
asong | 1:e4b38d6918ba | 240 | update_display(); |
asong | 1:e4b38d6918ba | 241 | break; |
asong | 1:e4b38d6918ba | 242 | } |
asong | 1:e4b38d6918ba | 243 | case 30: {//Change Target Heart Rate Zone Preference |
asong | 2:824ed4ae8d52 | 244 | Increment_Target_Zone(); |
asong | 2:824ed4ae8d52 | 245 | update_display(); |
asong | 2:824ed4ae8d52 | 246 | break; |
asong | 2:824ed4ae8d52 | 247 | } |
asong | 2:824ed4ae8d52 | 248 | case 31: { //Manually Increment Heart Rate by 1 |
asong | 2:824ed4ae8d52 | 249 | Increment_Heart_Rate(); |
asong | 2:824ed4ae8d52 | 250 | Determine_Current_Zone(); |
asong | 1:e4b38d6918ba | 251 | update_display(); |
asong | 1:e4b38d6918ba | 252 | break; |
asong | 1:e4b38d6918ba | 253 | } |
asong | 1:e4b38d6918ba | 254 | default: { |
asong | 1:e4b38d6918ba | 255 | break; |
asong | 1:e4b38d6918ba | 256 | } |
asong | 1:e4b38d6918ba | 257 | } |
nbaker | 0:d1d36a3da39b | 258 | } |
asong | 1:e4b38d6918ba | 259 | |
nbaker | 0:d1d36a3da39b | 260 | } |
nbaker | 0:d1d36a3da39b | 261 | |
nbaker | 0:d1d36a3da39b | 262 | void ButtonDown(void) |
nbaker | 0:d1d36a3da39b | 263 | { |
asong | 1:e4b38d6918ba | 264 | Screen_Timer.attach(&timout_timer,(SCRN_TIME));//Is this sufficient to reset/restart ticker timer for OLED? |
asong | 1:e4b38d6918ba | 265 | if (OLED_ON == 0) { |
asong | 1:e4b38d6918ba | 266 | OLED_ON = 1; // Screen was off, set to On |
asong | 1:e4b38d6918ba | 267 | update_display(); |
asong | 1:e4b38d6918ba | 268 | } else { |
nbaker | 0:d1d36a3da39b | 269 | |
asong | 1:e4b38d6918ba | 270 | switch(Screen_Num) { |
asong | 1:e4b38d6918ba | 271 | case 0: {// We're in Main Screen |
asong | 1:e4b38d6918ba | 272 | // do nothing, wrong button |
asong | 1:e4b38d6918ba | 273 | break; |
asong | 1:e4b38d6918ba | 274 | } |
asong | 1:e4b38d6918ba | 275 | case 1: {// Panic Alert option |
asong | 1:e4b38d6918ba | 276 | StartHaptic(); |
asong | 1:e4b38d6918ba | 277 | Screen_Num = 2; //Change to screen 2 |
asong | 1:e4b38d6918ba | 278 | update_display(); |
asong | 1:e4b38d6918ba | 279 | break; |
asong | 1:e4b38d6918ba | 280 | } |
asong | 1:e4b38d6918ba | 281 | case 2: {// Fall Alert option |
asong | 1:e4b38d6918ba | 282 | StartHaptic(); |
asong | 1:e4b38d6918ba | 283 | Screen_Num = 3; //Change to screen 3 |
asong | 1:e4b38d6918ba | 284 | update_display(); |
asong | 1:e4b38d6918ba | 285 | break; |
asong | 1:e4b38d6918ba | 286 | } |
asong | 1:e4b38d6918ba | 287 | case 3: {// Heart Rate Monitoring option |
asong | 1:e4b38d6918ba | 288 | StartHaptic(); |
asong | 1:e4b38d6918ba | 289 | Screen_Num = 4; //Change to screen 4 |
asong | 1:e4b38d6918ba | 290 | update_display(); |
asong | 1:e4b38d6918ba | 291 | break; |
asong | 1:e4b38d6918ba | 292 | } |
asong | 1:e4b38d6918ba | 293 | case 4: {// Alert History option |
asong | 1:e4b38d6918ba | 294 | StartHaptic(); |
asong | 1:e4b38d6918ba | 295 | Screen_Num = 5; //Change to screen 5 |
asong | 1:e4b38d6918ba | 296 | update_display(); |
asong | 1:e4b38d6918ba | 297 | break; |
asong | 1:e4b38d6918ba | 298 | } |
asong | 1:e4b38d6918ba | 299 | case 5: {// About HexiHeart option |
asong | 1:e4b38d6918ba | 300 | StartHaptic(); |
asong | 1:e4b38d6918ba | 301 | Screen_Num = 26; //Change to screen 1 |
nbaker | 0:d1d36a3da39b | 302 | #ifdef Debug // in debug show debug/diagnostic screens |
asong | 1:e4b38d6918ba | 303 | Screen_Num = 20; //Change to screen 20 |
nbaker | 0:d1d36a3da39b | 304 | #endif |
asong | 1:e4b38d6918ba | 305 | update_display(); |
asong | 1:e4b38d6918ba | 306 | break; |
asong | 1:e4b38d6918ba | 307 | } |
asong | 1:e4b38d6918ba | 308 | case 6: {// Panic Alert |
asong | 1:e4b38d6918ba | 309 | // do nothing, wrong button |
asong | 1:e4b38d6918ba | 310 | break; |
asong | 1:e4b38d6918ba | 311 | } |
asong | 1:e4b38d6918ba | 312 | case 7: {// Heart Rate Zone |
asong | 1:e4b38d6918ba | 313 | StartHaptic(100); |
asong | 2:824ed4ae8d52 | 314 | Disable_Heart_Rate(); |
asong | 1:e4b38d6918ba | 315 | break; |
asong | 1:e4b38d6918ba | 316 | } |
asong | 1:e4b38d6918ba | 317 | case 8: {// Alert History |
asong | 1:e4b38d6918ba | 318 | StartHaptic(); |
asong | 1:e4b38d6918ba | 319 | //decriment alert index |
asong | 1:e4b38d6918ba | 320 | break; |
asong | 1:e4b38d6918ba | 321 | } |
asong | 1:e4b38d6918ba | 322 | case 20: {// Diagnostic/Debug Screens |
asong | 1:e4b38d6918ba | 323 | StartHaptic(); |
asong | 1:e4b38d6918ba | 324 | Screen_Num = 26; //Change to screen 1 |
asong | 1:e4b38d6918ba | 325 | update_display(); |
asong | 1:e4b38d6918ba | 326 | break; |
asong | 1:e4b38d6918ba | 327 | } |
asong | 1:e4b38d6918ba | 328 | case 21: {// Fall Diagnostic |
asong | 1:e4b38d6918ba | 329 | StartHaptic(); |
asong | 1:e4b38d6918ba | 330 | Screen_Num = 22; //Change to screen 22 |
asong | 1:e4b38d6918ba | 331 | update_display(); |
asong | 1:e4b38d6918ba | 332 | break; |
asong | 1:e4b38d6918ba | 333 | } |
asong | 1:e4b38d6918ba | 334 | case 22: {// Fall Debug |
asong | 1:e4b38d6918ba | 335 | StartHaptic(); |
asong | 1:e4b38d6918ba | 336 | Screen_Num = 23; //Change to screen 23 |
asong | 1:e4b38d6918ba | 337 | update_display(); |
asong | 1:e4b38d6918ba | 338 | break; |
asong | 1:e4b38d6918ba | 339 | } |
asong | 1:e4b38d6918ba | 340 | case 23: {// Heart Rate Diagnostic |
asong | 1:e4b38d6918ba | 341 | StartHaptic(); |
asong | 1:e4b38d6918ba | 342 | Screen_Num = 24; //Change to screen 24 |
asong | 1:e4b38d6918ba | 343 | update_display(); |
asong | 1:e4b38d6918ba | 344 | break; |
asong | 1:e4b38d6918ba | 345 | } |
asong | 1:e4b38d6918ba | 346 | case 24: {// Heart Rate Debug |
asong | 1:e4b38d6918ba | 347 | StartHaptic(); |
asong | 1:e4b38d6918ba | 348 | Screen_Num = 25; //Change to screen 25 |
asong | 1:e4b38d6918ba | 349 | update_display(); |
asong | 1:e4b38d6918ba | 350 | break; |
asong | 1:e4b38d6918ba | 351 | } |
asong | 1:e4b38d6918ba | 352 | case 25: {// Heat Index Diagnostic |
asong | 1:e4b38d6918ba | 353 | StartHaptic(); |
asong | 1:e4b38d6918ba | 354 | Screen_Num = 21; //Change to screen 21 |
asong | 1:e4b38d6918ba | 355 | update_display(); |
asong | 1:e4b38d6918ba | 356 | break; |
asong | 1:e4b38d6918ba | 357 | } |
asong | 1:e4b38d6918ba | 358 | case 26: {//Heart Rate Configs |
asong | 1:e4b38d6918ba | 359 | StartHaptic(); |
asong | 1:e4b38d6918ba | 360 | Screen_Num = 1; |
asong | 1:e4b38d6918ba | 361 | update_display(); |
asong | 1:e4b38d6918ba | 362 | break; |
asong | 1:e4b38d6918ba | 363 | } |
asong | 1:e4b38d6918ba | 364 | case 27: { //Decrement Age |
asong | 2:824ed4ae8d52 | 365 | Decrement_Age(); |
asong | 2:824ed4ae8d52 | 366 | Set_Zone_Boundaries(); |
asong | 1:e4b38d6918ba | 367 | update_display(); |
asong | 1:e4b38d6918ba | 368 | break; |
asong | 1:e4b38d6918ba | 369 | |
asong | 1:e4b38d6918ba | 370 | } |
asong | 1:e4b38d6918ba | 371 | case 28: { //Changing Heart Rate Vibration Preference |
asong | 2:824ed4ae8d52 | 372 | /* |
asong | 2:824ed4ae8d52 | 373 | StartHaptic(); |
asong | 2:824ed4ae8d52 | 374 | if(HR_Vibration == 1) { |
asong | 2:824ed4ae8d52 | 375 | HR_Vibration = 3; |
asong | 2:824ed4ae8d52 | 376 | } else { |
asong | 2:824ed4ae8d52 | 377 | HR_Vibration -= 1; |
asong | 2:824ed4ae8d52 | 378 | } |
asong | 2:824ed4ae8d52 | 379 | */ |
asong | 2:824ed4ae8d52 | 380 | Decrement_HR_Vibr_Pref(); |
asong | 1:e4b38d6918ba | 381 | update_display(); |
asong | 1:e4b38d6918ba | 382 | break; |
asong | 1:e4b38d6918ba | 383 | } |
asong | 1:e4b38d6918ba | 384 | case 30: {//Change Target Heart Rate Zone Preference |
asong | 2:824ed4ae8d52 | 385 | Decrement_Target_Zone(); |
asong | 2:824ed4ae8d52 | 386 | update_display(); |
asong | 2:824ed4ae8d52 | 387 | break; |
asong | 2:824ed4ae8d52 | 388 | } |
asong | 2:824ed4ae8d52 | 389 | case 31: { //Manually decrement heart rate by 1 |
asong | 2:824ed4ae8d52 | 390 | Decrement_Heart_Rate(); |
asong | 2:824ed4ae8d52 | 391 | Determine_Current_Zone(); |
asong | 1:e4b38d6918ba | 392 | update_display(); |
asong | 1:e4b38d6918ba | 393 | break; |
asong | 1:e4b38d6918ba | 394 | } |
asong | 1:e4b38d6918ba | 395 | default: { |
asong | 1:e4b38d6918ba | 396 | break; |
asong | 1:e4b38d6918ba | 397 | } |
asong | 1:e4b38d6918ba | 398 | } |
nbaker | 0:d1d36a3da39b | 399 | } |
nbaker | 0:d1d36a3da39b | 400 | } |
nbaker | 0:d1d36a3da39b | 401 | |
nbaker | 0:d1d36a3da39b | 402 | void ButtonRight(void) |
nbaker | 0:d1d36a3da39b | 403 | { |
asong | 1:e4b38d6918ba | 404 | Screen_Timer.attach(&timout_timer,(SCRN_TIME));//Is this sufficient to reset/restart ticker timer for OLED? |
asong | 1:e4b38d6918ba | 405 | if (OLED_ON == 0) { |
asong | 1:e4b38d6918ba | 406 | OLED_ON = 1; // Screen was off, set to On |
asong | 1:e4b38d6918ba | 407 | update_display(); |
asong | 1:e4b38d6918ba | 408 | } else { |
asong | 1:e4b38d6918ba | 409 | switch(Screen_Num) { |
asong | 1:e4b38d6918ba | 410 | case 0: {// We're in Main Screen |
asong | 1:e4b38d6918ba | 411 | StartHaptic(); |
asong | 1:e4b38d6918ba | 412 | Screen_Num = 1; //Change to screen 1 |
asong | 1:e4b38d6918ba | 413 | update_display(); |
asong | 1:e4b38d6918ba | 414 | break; |
asong | 1:e4b38d6918ba | 415 | } |
asong | 1:e4b38d6918ba | 416 | case 1: {// Panic Alert option |
asong | 1:e4b38d6918ba | 417 | StartHaptic(); |
asong | 1:e4b38d6918ba | 418 | Screen_Num = 6; //Change to screen 6 |
asong | 1:e4b38d6918ba | 419 | update_display(); |
asong | 1:e4b38d6918ba | 420 | break; |
asong | 1:e4b38d6918ba | 421 | } |
asong | 1:e4b38d6918ba | 422 | case 2: {// Fall Alert option |
asong | 1:e4b38d6918ba | 423 | StartHaptic(); |
asong | 1:e4b38d6918ba | 424 | // toggle on/off |
asong | 1:e4b38d6918ba | 425 | break; |
asong | 1:e4b38d6918ba | 426 | } |
asong | 1:e4b38d6918ba | 427 | case 3: {// Heart Rate Monitoring option |
asong | 1:e4b38d6918ba | 428 | StartHaptic(); |
asong | 1:e4b38d6918ba | 429 | Screen_Num = 7; //Change to screen 7 |
asong | 1:e4b38d6918ba | 430 | update_display(); |
asong | 1:e4b38d6918ba | 431 | break; |
asong | 1:e4b38d6918ba | 432 | } |
asong | 1:e4b38d6918ba | 433 | case 4: {// Alert History option |
asong | 1:e4b38d6918ba | 434 | StartHaptic(); |
asong | 1:e4b38d6918ba | 435 | Screen_Num = 8; //Change to screen 8 |
asong | 1:e4b38d6918ba | 436 | update_display(); |
asong | 1:e4b38d6918ba | 437 | break; |
asong | 1:e4b38d6918ba | 438 | } |
asong | 1:e4b38d6918ba | 439 | case 5: {// About HexiHeart option |
asong | 1:e4b38d6918ba | 440 | StartHaptic(); |
asong | 1:e4b38d6918ba | 441 | Screen_Num = 9; //Change to screen 9 |
asong | 1:e4b38d6918ba | 442 | update_display(); |
asong | 1:e4b38d6918ba | 443 | break; |
asong | 1:e4b38d6918ba | 444 | } |
nbaker | 0:d1d36a3da39b | 445 | |
asong | 1:e4b38d6918ba | 446 | case 6: {// Panic Alert |
asong | 1:e4b38d6918ba | 447 | // do nothing, wrong button |
asong | 1:e4b38d6918ba | 448 | break; |
asong | 1:e4b38d6918ba | 449 | } |
asong | 1:e4b38d6918ba | 450 | case 7: {// Heart Rate Zone |
asong | 1:e4b38d6918ba | 451 | StartHaptic(); |
asong | 2:824ed4ae8d52 | 452 | Screen_Num = 31; |
asong | 2:824ed4ae8d52 | 453 | update_display(); |
asong | 1:e4b38d6918ba | 454 | break; |
asong | 1:e4b38d6918ba | 455 | } |
asong | 1:e4b38d6918ba | 456 | case 20: {// Diagnostic/Debug Screens |
asong | 1:e4b38d6918ba | 457 | StartHaptic(); |
asong | 1:e4b38d6918ba | 458 | Screen_Num = 21; //Change to screen 21 |
asong | 1:e4b38d6918ba | 459 | update_display(); |
asong | 1:e4b38d6918ba | 460 | break; |
asong | 1:e4b38d6918ba | 461 | } |
asong | 1:e4b38d6918ba | 462 | case 26: {//Change to Heart Rate Config Screen |
asong | 1:e4b38d6918ba | 463 | StartHaptic(); |
asong | 1:e4b38d6918ba | 464 | Screen_Num = 27; |
asong | 1:e4b38d6918ba | 465 | update_display(); |
asong | 1:e4b38d6918ba | 466 | break; |
asong | 1:e4b38d6918ba | 467 | } |
asong | 1:e4b38d6918ba | 468 | case 27: {//Change to Heart Rate Vibration Preferences |
asong | 1:e4b38d6918ba | 469 | StartHaptic(); |
asong | 1:e4b38d6918ba | 470 | Screen_Num = 28; |
asong | 1:e4b38d6918ba | 471 | update_display(); |
asong | 1:e4b38d6918ba | 472 | break; |
asong | 1:e4b38d6918ba | 473 | } |
asong | 1:e4b38d6918ba | 474 | case 28: {//Change to Heart Rate Zone Boundary Info |
asong | 1:e4b38d6918ba | 475 | StartHaptic(); |
asong | 1:e4b38d6918ba | 476 | Screen_Num = 29; |
asong | 1:e4b38d6918ba | 477 | update_display(); |
asong | 1:e4b38d6918ba | 478 | break; |
asong | 1:e4b38d6918ba | 479 | } |
asong | 2:824ed4ae8d52 | 480 | case 29: {//Change Target Heart Rate Zone Preference |
asong | 1:e4b38d6918ba | 481 | StartHaptic(); |
asong | 1:e4b38d6918ba | 482 | Screen_Num = 30; |
asong | 1:e4b38d6918ba | 483 | update_display(); |
asong | 1:e4b38d6918ba | 484 | break; |
asong | 1:e4b38d6918ba | 485 | } |
asong | 1:e4b38d6918ba | 486 | case 30: {//Change to Heart Rate Config Screen |
asong | 1:e4b38d6918ba | 487 | StartHaptic(); |
asong | 1:e4b38d6918ba | 488 | Screen_Num = 27; |
asong | 1:e4b38d6918ba | 489 | update_display(); |
asong | 1:e4b38d6918ba | 490 | break; |
asong | 1:e4b38d6918ba | 491 | } |
asong | 2:824ed4ae8d52 | 492 | case 31: { |
asong | 2:824ed4ae8d52 | 493 | StartHaptic(); |
asong | 2:824ed4ae8d52 | 494 | Screen_Num = 32; |
asong | 2:824ed4ae8d52 | 495 | update_display(); |
asong | 2:824ed4ae8d52 | 496 | break; |
asong | 2:824ed4ae8d52 | 497 | } |
asong | 2:824ed4ae8d52 | 498 | case 32: { |
asong | 2:824ed4ae8d52 | 499 | StartHaptic(); |
asong | 2:824ed4ae8d52 | 500 | Screen_Num = 7; |
asong | 2:824ed4ae8d52 | 501 | update_display(); |
asong | 2:824ed4ae8d52 | 502 | break; |
asong | 2:824ed4ae8d52 | 503 | } |
asong | 1:e4b38d6918ba | 504 | default: { |
asong | 1:e4b38d6918ba | 505 | break; |
asong | 1:e4b38d6918ba | 506 | } |
asong | 1:e4b38d6918ba | 507 | } |
nbaker | 0:d1d36a3da39b | 508 | } |
nbaker | 0:d1d36a3da39b | 509 | } |
nbaker | 0:d1d36a3da39b | 510 | |
nbaker | 0:d1d36a3da39b | 511 | void ButtonLeft(void) |
nbaker | 0:d1d36a3da39b | 512 | { |
asong | 1:e4b38d6918ba | 513 | Screen_Timer.attach(&timout_timer,(SCRN_TIME));//Is this sufficient to reset/restart ticker timer for OLED? |
asong | 1:e4b38d6918ba | 514 | if (OLED_ON == 0) { |
asong | 1:e4b38d6918ba | 515 | OLED_ON = 1; // Screen was off, set to On |
asong | 1:e4b38d6918ba | 516 | update_display(); |
asong | 1:e4b38d6918ba | 517 | } else { |
asong | 1:e4b38d6918ba | 518 | switch(Screen_Num) { |
asong | 1:e4b38d6918ba | 519 | case 0: {// We're in Main Screen |
asong | 1:e4b38d6918ba | 520 | // do nothing, wrong button |
asong | 1:e4b38d6918ba | 521 | break; |
asong | 1:e4b38d6918ba | 522 | } |
asong | 1:e4b38d6918ba | 523 | case 1: {// Panic Alert option |
asong | 1:e4b38d6918ba | 524 | StartHaptic(); |
asong | 1:e4b38d6918ba | 525 | Screen_Num = 0; //Change to screen 0 |
asong | 1:e4b38d6918ba | 526 | update_display(); |
asong | 1:e4b38d6918ba | 527 | break; |
asong | 1:e4b38d6918ba | 528 | } |
asong | 1:e4b38d6918ba | 529 | case 2: {// Fall Alert option |
asong | 1:e4b38d6918ba | 530 | StartHaptic(); |
asong | 1:e4b38d6918ba | 531 | Screen_Num = 0; //Change to screen 0 |
asong | 1:e4b38d6918ba | 532 | update_display(); |
asong | 1:e4b38d6918ba | 533 | break; |
asong | 1:e4b38d6918ba | 534 | } |
asong | 1:e4b38d6918ba | 535 | case 3: {// Heart Rate Monitoring option |
asong | 1:e4b38d6918ba | 536 | StartHaptic(); |
asong | 1:e4b38d6918ba | 537 | Screen_Num = 0; //Change to screen 0 |
asong | 1:e4b38d6918ba | 538 | update_display(); |
asong | 1:e4b38d6918ba | 539 | break; |
asong | 1:e4b38d6918ba | 540 | } |
asong | 1:e4b38d6918ba | 541 | case 4: {// Alert History option |
asong | 1:e4b38d6918ba | 542 | StartHaptic(); |
asong | 1:e4b38d6918ba | 543 | Screen_Num = 0; //Change to screen 0 |
asong | 1:e4b38d6918ba | 544 | update_display(); |
asong | 1:e4b38d6918ba | 545 | break; |
asong | 1:e4b38d6918ba | 546 | } |
asong | 1:e4b38d6918ba | 547 | case 5: {// About HexiHeart option |
asong | 1:e4b38d6918ba | 548 | StartHaptic(); |
asong | 1:e4b38d6918ba | 549 | Screen_Num = 0; //Change to screen 0 |
asong | 1:e4b38d6918ba | 550 | update_display(); |
asong | 1:e4b38d6918ba | 551 | break; |
asong | 1:e4b38d6918ba | 552 | } |
asong | 1:e4b38d6918ba | 553 | case 6: {// Panic Alert |
asong | 1:e4b38d6918ba | 554 | StartHaptic(); |
asong | 1:e4b38d6918ba | 555 | Screen_Num = 1; //Change to screen 1 |
asong | 1:e4b38d6918ba | 556 | update_display(); |
asong | 1:e4b38d6918ba | 557 | break; |
asong | 1:e4b38d6918ba | 558 | } |
asong | 1:e4b38d6918ba | 559 | case 7: {// Heart Rate Zone |
asong | 1:e4b38d6918ba | 560 | StartHaptic(); |
asong | 1:e4b38d6918ba | 561 | Screen_Num = 3; //Change to screen 3 |
asong | 1:e4b38d6918ba | 562 | update_display(); |
asong | 1:e4b38d6918ba | 563 | break; |
asong | 1:e4b38d6918ba | 564 | } |
asong | 1:e4b38d6918ba | 565 | case 8: {// Alert History |
asong | 1:e4b38d6918ba | 566 | StartHaptic(); |
asong | 1:e4b38d6918ba | 567 | Screen_Num = 4; //Change to screen 4 |
asong | 1:e4b38d6918ba | 568 | update_display(); |
asong | 1:e4b38d6918ba | 569 | break; |
asong | 1:e4b38d6918ba | 570 | } |
asong | 1:e4b38d6918ba | 571 | case 20: {// Diagnostic/Debug Screens |
asong | 1:e4b38d6918ba | 572 | StartHaptic(); |
asong | 1:e4b38d6918ba | 573 | Screen_Num = 0; //Change to screen 0 |
asong | 1:e4b38d6918ba | 574 | update_display(); |
asong | 1:e4b38d6918ba | 575 | break; |
asong | 1:e4b38d6918ba | 576 | } |
asong | 1:e4b38d6918ba | 577 | case 21: {// Fall Diagnostic |
asong | 1:e4b38d6918ba | 578 | StartHaptic(); |
asong | 1:e4b38d6918ba | 579 | Screen_Num = 20; //Change to screen 20 |
asong | 1:e4b38d6918ba | 580 | update_display(); |
asong | 1:e4b38d6918ba | 581 | break; |
asong | 1:e4b38d6918ba | 582 | } |
asong | 1:e4b38d6918ba | 583 | case 22: {// Fall Debug |
asong | 1:e4b38d6918ba | 584 | StartHaptic(); |
asong | 1:e4b38d6918ba | 585 | Screen_Num = 20; //Change to screen 20 |
asong | 1:e4b38d6918ba | 586 | update_display(); |
asong | 1:e4b38d6918ba | 587 | break; |
asong | 1:e4b38d6918ba | 588 | } |
asong | 1:e4b38d6918ba | 589 | case 23: {// Heart Rate Diagnostic |
asong | 1:e4b38d6918ba | 590 | StartHaptic(); |
asong | 1:e4b38d6918ba | 591 | Screen_Num = 20; //Change to screen 20 |
asong | 1:e4b38d6918ba | 592 | update_display(); |
asong | 1:e4b38d6918ba | 593 | break; |
asong | 1:e4b38d6918ba | 594 | } |
asong | 1:e4b38d6918ba | 595 | case 24: {// Heart Rate Debug |
asong | 1:e4b38d6918ba | 596 | StartHaptic(); |
asong | 1:e4b38d6918ba | 597 | Screen_Num = 20; //Change to screen 20 |
asong | 1:e4b38d6918ba | 598 | update_display(); |
asong | 1:e4b38d6918ba | 599 | break; |
asong | 1:e4b38d6918ba | 600 | } |
asong | 1:e4b38d6918ba | 601 | case 25: {// Heat Index Diagnostic |
asong | 1:e4b38d6918ba | 602 | StartHaptic(); |
asong | 1:e4b38d6918ba | 603 | Screen_Num = 20; //Change to screen 20 |
asong | 1:e4b38d6918ba | 604 | update_display(); |
asong | 1:e4b38d6918ba | 605 | break; |
asong | 1:e4b38d6918ba | 606 | } |
asong | 1:e4b38d6918ba | 607 | case 26: {//Heart Rate Config Option |
asong | 1:e4b38d6918ba | 608 | StartHaptic(); |
asong | 1:e4b38d6918ba | 609 | Screen_Num = 0; |
asong | 1:e4b38d6918ba | 610 | update_display(); |
asong | 1:e4b38d6918ba | 611 | break; |
asong | 1:e4b38d6918ba | 612 | } |
asong | 1:e4b38d6918ba | 613 | case 27: {//Enter Age |
asong | 1:e4b38d6918ba | 614 | StartHaptic(); |
asong | 1:e4b38d6918ba | 615 | Screen_Num = 26; |
asong | 1:e4b38d6918ba | 616 | update_display(); |
asong | 1:e4b38d6918ba | 617 | break; |
asong | 1:e4b38d6918ba | 618 | } |
asong | 1:e4b38d6918ba | 619 | case 28: {//Heart Rate Vibration Preference Screen |
asong | 1:e4b38d6918ba | 620 | StartHaptic(); |
asong | 1:e4b38d6918ba | 621 | Screen_Num = 27; |
asong | 1:e4b38d6918ba | 622 | update_display(); |
asong | 1:e4b38d6918ba | 623 | break; |
asong | 1:e4b38d6918ba | 624 | } |
asong | 1:e4b38d6918ba | 625 | case 29: {//Heart Rate Zone Boundary Info |
asong | 1:e4b38d6918ba | 626 | StartHaptic(); |
asong | 1:e4b38d6918ba | 627 | Screen_Num = 28; |
asong | 1:e4b38d6918ba | 628 | update_display(); |
asong | 1:e4b38d6918ba | 629 | break; |
asong | 1:e4b38d6918ba | 630 | } |
asong | 2:824ed4ae8d52 | 631 | case 30: {//Change Target Heart Rate Zone Preference |
asong | 1:e4b38d6918ba | 632 | StartHaptic(); |
asong | 1:e4b38d6918ba | 633 | Screen_Num = 29; |
asong | 1:e4b38d6918ba | 634 | update_display(); |
asong | 1:e4b38d6918ba | 635 | break; |
asong | 1:e4b38d6918ba | 636 | } |
asong | 2:824ed4ae8d52 | 637 | case 31: { |
asong | 2:824ed4ae8d52 | 638 | StartHaptic(); |
asong | 2:824ed4ae8d52 | 639 | Screen_Num = 7; |
asong | 2:824ed4ae8d52 | 640 | update_display(); |
asong | 2:824ed4ae8d52 | 641 | break; |
asong | 2:824ed4ae8d52 | 642 | } |
asong | 2:824ed4ae8d52 | 643 | case 32: { |
asong | 2:824ed4ae8d52 | 644 | StartHaptic(); |
asong | 2:824ed4ae8d52 | 645 | Screen_Num = 31; |
asong | 2:824ed4ae8d52 | 646 | update_display(); |
asong | 2:824ed4ae8d52 | 647 | break; |
asong | 2:824ed4ae8d52 | 648 | } |
asong | 1:e4b38d6918ba | 649 | default: { |
asong | 1:e4b38d6918ba | 650 | break; |
asong | 1:e4b38d6918ba | 651 | } |
asong | 1:e4b38d6918ba | 652 | } |
nbaker | 0:d1d36a3da39b | 653 | } |
nbaker | 0:d1d36a3da39b | 654 | } |
nbaker | 0:d1d36a3da39b | 655 | |
nbaker | 0:d1d36a3da39b | 656 | |
nbaker | 0:d1d36a3da39b | 657 | void ButtonSlide(void) // What is this Slide button??? |
nbaker | 0:d1d36a3da39b | 658 | { |
asong | 1:e4b38d6918ba | 659 | Screen_Timer.attach(&timout_timer,(SCRN_TIME));//Is this sufficient to reset/restart ticker timer for OLED? |
asong | 1:e4b38d6918ba | 660 | if (OLED_ON == 0) { |
asong | 1:e4b38d6918ba | 661 | OLED_ON = 1; // Screen was off, set to On |
asong | 1:e4b38d6918ba | 662 | } |
nbaker | 0:d1d36a3da39b | 663 | StartHaptic(); |
nbaker | 0:d1d36a3da39b | 664 | oled.FillScreen(COLOR_BLACK); // Clear screen |
nbaker | 0:d1d36a3da39b | 665 | strcpy((char *) text_1,"Slide Button"); |
nbaker | 0:d1d36a3da39b | 666 | oled.Label((uint8_t *)text_1,0,40); |
nbaker | 0:d1d36a3da39b | 667 | } |
asong | 1:e4b38d6918ba | 668 | |
nbaker | 0:d1d36a3da39b | 669 | int main() |
nbaker | 0:d1d36a3da39b | 670 | { |
nbaker | 0:d1d36a3da39b | 671 | oled.FillScreen(COLOR_BLACK); // Clear screen |
asong | 1:e4b38d6918ba | 672 | // ***************** Local variables *********************** |
asong | 1:e4b38d6918ba | 673 | // float accel_data[3]; float accel_rms=0.0; |
asong | 1:e4b38d6918ba | 674 | |
nbaker | 0:d1d36a3da39b | 675 | // ************** configure sensor modules ****************** |
nbaker | 0:d1d36a3da39b | 676 | accel.accel_config(); |
nbaker | 0:d1d36a3da39b | 677 | mag.mag_config(); |
nbaker | 0:d1d36a3da39b | 678 | // gyro.gyro_config(); |
asong | 1:e4b38d6918ba | 679 | |
nbaker | 0:d1d36a3da39b | 680 | RED_Led = LED_OFF; |
nbaker | 0:d1d36a3da39b | 681 | GRN_Led = LED_OFF; |
nbaker | 0:d1d36a3da39b | 682 | BLU_Led = LED_OFF; |
nbaker | 0:d1d36a3da39b | 683 | // ***** Register callbacks/interupts to application functions ********* |
nbaker | 0:d1d36a3da39b | 684 | kw40z_device.attach_buttonUp(&ButtonUp); |
nbaker | 0:d1d36a3da39b | 685 | kw40z_device.attach_buttonDown(&ButtonDown); |
nbaker | 0:d1d36a3da39b | 686 | kw40z_device.attach_buttonLeft(&ButtonLeft); |
nbaker | 0:d1d36a3da39b | 687 | kw40z_device.attach_buttonRight(&ButtonRight); |
nbaker | 0:d1d36a3da39b | 688 | kw40z_device.attach_buttonSlide(&ButtonSlide); |
nbaker | 0:d1d36a3da39b | 689 | |
nbaker | 0:d1d36a3da39b | 690 | // **** Get OLED Class Default Text Properties **************** |
asong | 1:e4b38d6918ba | 691 | oled_text_properties_t textProperties = {0}; |
asong | 1:e4b38d6918ba | 692 | oled.GetTextProperties(&textProperties); |
asong | 1:e4b38d6918ba | 693 | |
nbaker | 0:d1d36a3da39b | 694 | // *********Set text color and screen alignment ************** |
asong | 1:e4b38d6918ba | 695 | textProperties.fontColor = COLOR_WHITE; |
asong | 1:e4b38d6918ba | 696 | textProperties.alignParam = OLED_TEXT_ALIGN_LEFT; |
asong | 1:e4b38d6918ba | 697 | oled.SetTextProperties(&textProperties); |
asong | 1:e4b38d6918ba | 698 | |
nbaker | 0:d1d36a3da39b | 699 | // ************** Display spash screen ********************** |
nbaker | 0:d1d36a3da39b | 700 | |
nbaker | 0:d1d36a3da39b | 701 | oled.Label((uint8_t *)"Hexi",20,5); // Display white "Hexi" at x,y |
nbaker | 0:d1d36a3da39b | 702 | textProperties.fontColor = COLOR_RED; |
asong | 1:e4b38d6918ba | 703 | oled.SetTextProperties(&textProperties); |
asong | 1:e4b38d6918ba | 704 | oled.Label((uint8_t *)"Heart",45,5); // Display red "Heart" at x,y |
nbaker | 0:d1d36a3da39b | 705 | |
asong | 1:e4b38d6918ba | 706 | #ifdef Debug // if this is non-production version - do this |
nbaker | 0:d1d36a3da39b | 707 | strcpy((char *) text_1,"This is Debug Ver"); |
nbaker | 0:d1d36a3da39b | 708 | oled.Label((uint8_t *)text_1,0,60); // text_1 at x,y |
nbaker | 0:d1d36a3da39b | 709 | StartHaptic(); |
asong | 1:e4b38d6918ba | 710 | #endif |
nbaker | 0:d1d36a3da39b | 711 | textProperties.fontColor = COLOR_WHITE; |
nbaker | 0:d1d36a3da39b | 712 | oled.SetTextProperties(&textProperties); |
nbaker | 0:d1d36a3da39b | 713 | wait(3); // wait 3 seconds |
asong | 1:e4b38d6918ba | 714 | update_display(); // Displays current screen (screen 0) |
nbaker | 0:d1d36a3da39b | 715 | Screen_Timer.attach(&timout_timer,(SCRN_TIME));//start ticker timer for turning off LCD |
asong | 1:e4b38d6918ba | 716 | // ******************* Main Loop ************************* |
nbaker | 0:d1d36a3da39b | 717 | while (true) { |
nbaker | 0:d1d36a3da39b | 718 | |
asong | 1:e4b38d6918ba | 719 | Thread::wait(500); // wait half a sec in each loop |
nbaker | 0:d1d36a3da39b | 720 | } |
nbaker | 0:d1d36a3da39b | 721 | } |
nbaker | 0:d1d36a3da39b | 722 | // ************** end of main() |
nbaker | 0:d1d36a3da39b | 723 | |
nbaker | 0:d1d36a3da39b | 724 | void update_display(void) |
nbaker | 0:d1d36a3da39b | 725 | { |
asong | 1:e4b38d6918ba | 726 | oled_text_properties_t textProperties = {0}; // Need these to change font color |
asong | 1:e4b38d6918ba | 727 | oled.GetTextProperties(&textProperties); // Need these to change font color |
asong | 1:e4b38d6918ba | 728 | switch(Screen_Num) { |
asong | 1:e4b38d6918ba | 729 | case 0: {// Main Screen |
asong | 1:e4b38d6918ba | 730 | oled.FillScreen(COLOR_BLACK); // Clear screen |
asong | 1:e4b38d6918ba | 731 | oled.Label((uint8_t *)"Batt",60,0); // Display "Batt" at x,y |
asong | 1:e4b38d6918ba | 732 | oled.Label((uint8_t *)"Date",35,20); // Display "Date" at x,y |
asong | 1:e4b38d6918ba | 733 | oled.Label((uint8_t *)"Time",35,40); // Display "Time" at x,y |
asong | 1:e4b38d6918ba | 734 | oled.Label((uint8_t *)"H.I.",10,80); // Display "H.I." at x,y |
asong | 1:e4b38d6918ba | 735 | oled.Label((uint8_t *)"BT",40,80); //Display "BT" at x,y |
asong | 1:e4b38d6918ba | 736 | oled.Label((uint8_t *)"Menu",60,80); //Display "Menu" at x,y |
asong | 1:e4b38d6918ba | 737 | if(Heart_Rate_Mode == 1) { |
asong | 1:e4b38d6918ba | 738 | oled.Label((uint8_t *)"BPM",35,60); // Display "H.I." at x,y |
asong | 1:e4b38d6918ba | 739 | } |
asong | 1:e4b38d6918ba | 740 | break; |
asong | 1:e4b38d6918ba | 741 | } |
asong | 1:e4b38d6918ba | 742 | case 1: {// Panic Alert option |
asong | 1:e4b38d6918ba | 743 | oled.FillScreen(COLOR_BLACK); // Clear screen |
asong | 1:e4b38d6918ba | 744 | oled.Label((uint8_t *)"Panic Alert",20,5); // Display at x,y |
asong | 1:e4b38d6918ba | 745 | oled.Label((uint8_t *)"*",85,15); // "*" at x,y |
asong | 1:e4b38d6918ba | 746 | oled.Label((uint8_t *)"*",85,60); // "*" at x,y |
asong | 1:e4b38d6918ba | 747 | oled.Label((uint8_t *)"Back",10,80); // Display "Back" at x,y |
asong | 1:e4b38d6918ba | 748 | oled.Label((uint8_t *)"Enter",60,80); //Display "enter" at x,y |
asong | 1:e4b38d6918ba | 749 | break; |
asong | 1:e4b38d6918ba | 750 | } |
asong | 1:e4b38d6918ba | 751 | case 2: {// Fall Alert option |
asong | 1:e4b38d6918ba | 752 | oled.FillScreen(COLOR_BLACK); // Clear screen |
asong | 1:e4b38d6918ba | 753 | oled.Label((uint8_t *)"Fall Alert",20,5); // Display at x,y |
asong | 1:e4b38d6918ba | 754 | oled.Label((uint8_t *)"*",85,15); // "*" at x,y |
asong | 1:e4b38d6918ba | 755 | oled.Label((uint8_t *)"*",85,60); // "*" at x,y |
asong | 1:e4b38d6918ba | 756 | oled.Label((uint8_t *)"Back",10,80); // Display "Back" at x,y |
asong | 1:e4b38d6918ba | 757 | oled.Label((uint8_t *)"Toggle",60,80); //Display "Toggle" at x,y |
asong | 1:e4b38d6918ba | 758 | break; |
asong | 1:e4b38d6918ba | 759 | } |
asong | 1:e4b38d6918ba | 760 | case 3: {// Heart Rate Monitoring option |
asong | 1:e4b38d6918ba | 761 | oled.FillScreen(COLOR_BLACK); // Clear screen |
asong | 1:e4b38d6918ba | 762 | oled.Label((uint8_t *)"Heart Rate",20,5); // Display at x,y |
asong | 1:e4b38d6918ba | 763 | oled.Label((uint8_t *)"*",85,15); // "*" at x,y |
asong | 1:e4b38d6918ba | 764 | oled.Label((uint8_t *)"*",85,60); // "*" at x,y |
asong | 1:e4b38d6918ba | 765 | oled.Label((uint8_t *)"Back",10,80); // Display "Back" at x,y |
asong | 1:e4b38d6918ba | 766 | oled.Label((uint8_t *)"Enter",60,80); //Display at x,y |
asong | 1:e4b38d6918ba | 767 | break; |
asong | 1:e4b38d6918ba | 768 | } |
asong | 1:e4b38d6918ba | 769 | case 4: {// Alert History option |
asong | 1:e4b38d6918ba | 770 | oled.FillScreen(COLOR_BLACK); // Clear screen |
asong | 1:e4b38d6918ba | 771 | oled.Label((uint8_t *)"Alert History",5,5); // Display at x,y |
asong | 1:e4b38d6918ba | 772 | oled.Label((uint8_t *)"*",85,15); // "*" at x,y |
asong | 1:e4b38d6918ba | 773 | oled.Label((uint8_t *)"*",85,60); // "*" at x,y |
asong | 1:e4b38d6918ba | 774 | oled.Label((uint8_t *)"Back",10,80); // Display "Back" at x,y |
asong | 1:e4b38d6918ba | 775 | oled.Label((uint8_t *)"Enter",60,80); //Display at x,y |
asong | 1:e4b38d6918ba | 776 | break; |
asong | 1:e4b38d6918ba | 777 | } |
asong | 1:e4b38d6918ba | 778 | case 5: {// About HexiHeart Screen |
nbaker | 0:d1d36a3da39b | 779 | |
asong | 1:e4b38d6918ba | 780 | oled.FillScreen(COLOR_BLACK); // Clear screen |
asong | 1:e4b38d6918ba | 781 | oled.Label((uint8_t *)"Hexi",20,20); // Display white "Hexi" at x,y |
asong | 1:e4b38d6918ba | 782 | textProperties.fontColor = COLOR_RED; |
asong | 1:e4b38d6918ba | 783 | oled.SetTextProperties(&textProperties); |
asong | 1:e4b38d6918ba | 784 | oled.Label((uint8_t *)"Heart",45,20); // Display red "Heart" at x,y |
asong | 1:e4b38d6918ba | 785 | textProperties.fontColor = COLOR_WHITE; |
asong | 1:e4b38d6918ba | 786 | oled.SetTextProperties(&textProperties); |
asong | 1:e4b38d6918ba | 787 | strcpy((char *) text_1,"About"); |
asong | 1:e4b38d6918ba | 788 | oled.Label((uint8_t *)text_1,30,5); // text_1 at x,y |
asong | 1:e4b38d6918ba | 789 | oled.Label((uint8_t *)"*",85,15); // "*" at x,y |
asong | 1:e4b38d6918ba | 790 | oled.Label((uint8_t *)"*",85,60); // "*" at x,y |
asong | 1:e4b38d6918ba | 791 | oled.Label((uint8_t *)" Back ",9,80); // Display "Back" at x,y |
asong | 1:e4b38d6918ba | 792 | oled.Label((uint8_t *)" Enter ",59,80); //Display at x,y |
asong | 1:e4b38d6918ba | 793 | break; |
asong | 1:e4b38d6918ba | 794 | } |
asong | 1:e4b38d6918ba | 795 | |
asong | 1:e4b38d6918ba | 796 | case 6: {// Panic Alert |
asong | 1:e4b38d6918ba | 797 | oled.FillScreen(COLOR_BLACK); // Clear screen |
asong | 1:e4b38d6918ba | 798 | if (Panic_Alert == 0) { |
asong | 1:e4b38d6918ba | 799 | oled.Label((uint8_t *)"Send ",20,10); // Display at x,y |
asong | 1:e4b38d6918ba | 800 | } else { |
asong | 1:e4b38d6918ba | 801 | oled.Label((uint8_t *)"Dismiss ",17,10); // Display at x,y |
asong | 1:e4b38d6918ba | 802 | } |
asong | 1:e4b38d6918ba | 803 | oled.Label((uint8_t *)"Panic Alert",15,40); // Display at x,y |
asong | 1:e4b38d6918ba | 804 | oled.Label((uint8_t *)"-->",80,15); // "*" at x,y |
asong | 1:e4b38d6918ba | 805 | oled.Label((uint8_t *)"Back",10,80); // Display "Back" at x,y |
asong | 1:e4b38d6918ba | 806 | break; |
asong | 1:e4b38d6918ba | 807 | } |
asong | 1:e4b38d6918ba | 808 | case 7: {// Heart Rate Zone |
asong | 1:e4b38d6918ba | 809 | |
asong | 1:e4b38d6918ba | 810 | oled.FillScreen(COLOR_BLACK); // Clear screen |
asong | 1:e4b38d6918ba | 811 | oled.Label((uint8_t *)"Heart Rate",15,5); // Display at x,y |
asong | 1:e4b38d6918ba | 812 | oled.Label((uint8_t *)"HR:",15,25); // Display at x,y |
asong | 2:824ed4ae8d52 | 813 | sprintf(display_buff, "%u", Heart_Rate); |
asong | 2:824ed4ae8d52 | 814 | textProperties.fontColor = COLOR_RED; //Change font to red |
asong | 2:824ed4ae8d52 | 815 | oled.SetTextProperties(&textProperties);//Implement color change |
asong | 2:824ed4ae8d52 | 816 | oled.Label((uint8_t *)display_buff,43,25); // Display at x,y |
asong | 2:824ed4ae8d52 | 817 | textProperties.fontColor = COLOR_WHITE; |
asong | 2:824ed4ae8d52 | 818 | oled.SetTextProperties(&textProperties); |
asong | 1:e4b38d6918ba | 819 | oled.Label((uint8_t *)"Age: ",15,45); // Display at x,y |
asong | 1:e4b38d6918ba | 820 | textProperties.fontColor = COLOR_GREEN; |
asong | 1:e4b38d6918ba | 821 | oled.SetTextProperties(&textProperties); //implements the color change |
asong | 1:e4b38d6918ba | 822 | sprintf(display_buff, "%u", Age); //Convert int to char array for displaying user age |
asong | 1:e4b38d6918ba | 823 | oled.Label((uint8_t *)display_buff,43,45); // Display at x,y |
asong | 1:e4b38d6918ba | 824 | textProperties.fontColor = COLOR_WHITE; |
asong | 1:e4b38d6918ba | 825 | oled.SetTextProperties(&textProperties); |
asong | 2:824ed4ae8d52 | 826 | oled.Label((uint8_t *)"On",80,15); // "+" at x,y |
asong | 2:824ed4ae8d52 | 827 | oled.Label((uint8_t *)"Off",78,60); // "-" at x,y |
asong | 1:e4b38d6918ba | 828 | oled.Label((uint8_t *)"Back",10,80); // Display "Back" at x,y |
asong | 1:e4b38d6918ba | 829 | oled.Label((uint8_t *)"Next",59,80); // Display "Next" at x,y |
asong | 2:824ed4ae8d52 | 830 | |
asong | 1:e4b38d6918ba | 831 | //heart.enable(); |
asong | 1:e4b38d6918ba | 832 | //sprintf(display_buff, "%u", heart.getRevisionID()); //Convert int to char array for displaying user age |
asong | 1:e4b38d6918ba | 833 | //oled.Label((uint8_t *)display_buff,45,25); // Display at x,y |
asong | 1:e4b38d6918ba | 834 | //update_display(); |
asong | 1:e4b38d6918ba | 835 | break; |
asong | 1:e4b38d6918ba | 836 | } |
asong | 1:e4b38d6918ba | 837 | case 8: {// Alert History |
asong | 1:e4b38d6918ba | 838 | oled.FillScreen(COLOR_BLACK); // Clear screen |
asong | 1:e4b38d6918ba | 839 | oled.Label((uint8_t *)"Alert History",5,5); // Display at x,y |
asong | 1:e4b38d6918ba | 840 | oled.Label((uint8_t *)"Date - Time",20,40); // Display at x,y |
asong | 1:e4b38d6918ba | 841 | oled.Label((uint8_t *)"Alert Type:",20,60); // Display at x,y |
asong | 1:e4b38d6918ba | 842 | oled.Label((uint8_t *)"+",85,15); // "*" at x,y |
asong | 1:e4b38d6918ba | 843 | oled.Label((uint8_t *)"-",85,60); // "*" at x,y |
asong | 1:e4b38d6918ba | 844 | oled.Label((uint8_t *)"Back",10,80); // Display "Back" at x,y |
asong | 1:e4b38d6918ba | 845 | break; |
asong | 1:e4b38d6918ba | 846 | } |
asong | 1:e4b38d6918ba | 847 | #ifdef Debug // if this is non-production/debug version - do this |
asong | 1:e4b38d6918ba | 848 | case 20: {// Diagnostic/Debug Screens |
asong | 1:e4b38d6918ba | 849 | oled.FillScreen(COLOR_BLACK); // Clear screen |
asong | 1:e4b38d6918ba | 850 | textProperties.fontColor = COLOR_RED; |
asong | 1:e4b38d6918ba | 851 | oled.SetTextProperties(&textProperties); |
asong | 1:e4b38d6918ba | 852 | oled.Label((uint8_t *)"Diagnostics",10,5); // Display at x,y |
asong | 1:e4b38d6918ba | 853 | oled.Label((uint8_t *)" Enter ",59,80); //Display at x,y |
asong | 1:e4b38d6918ba | 854 | textProperties.fontColor = COLOR_WHITE; |
asong | 1:e4b38d6918ba | 855 | oled.SetTextProperties(&textProperties); |
asong | 1:e4b38d6918ba | 856 | oled.Label((uint8_t *)"*",85,15); // "*" at x,y |
asong | 1:e4b38d6918ba | 857 | oled.Label((uint8_t *)"*",85,60); // "*" at x,y |
asong | 1:e4b38d6918ba | 858 | oled.Label((uint8_t *)" Back ",9,80); // Display "Back" at x,y |
nbaker | 0:d1d36a3da39b | 859 | |
asong | 1:e4b38d6918ba | 860 | break; |
asong | 1:e4b38d6918ba | 861 | } |
asong | 1:e4b38d6918ba | 862 | case 21: {// Fall Alert Diagnostic Screen |
asong | 1:e4b38d6918ba | 863 | oled.FillScreen(COLOR_BLACK); // Clear screen |
asong | 1:e4b38d6918ba | 864 | textProperties.fontColor = COLOR_RED; |
asong | 1:e4b38d6918ba | 865 | oled.SetTextProperties(&textProperties); |
asong | 1:e4b38d6918ba | 866 | oled.Label((uint8_t *)"Fall",30,5); // Display at x,y |
asong | 1:e4b38d6918ba | 867 | oled.Label((uint8_t *)"Diagnostic",25,5); // Display at x,y |
asong | 1:e4b38d6918ba | 868 | textProperties.fontColor = COLOR_WHITE; |
asong | 1:e4b38d6918ba | 869 | oled.SetTextProperties(&textProperties); |
asong | 1:e4b38d6918ba | 870 | accel.acquire_accel_data_g(Accel_Data); |
asong | 1:e4b38d6918ba | 871 | // gyro.acquire_gyro_data_g(Gyro_Data); |
asong | 1:e4b38d6918ba | 872 | Accel_Mag = sqrt(((Accel_Data[0]*Accel_Data[0])+(Accel_Data[1]*Accel_Data[1])+(Accel_Data[2]*Accel_Data[2]))); |
asong | 1:e4b38d6918ba | 873 | // Gyro_Mag = (abs(Gyro_Data[0])+abs(Gyro_Data[1])+abs(Gyro_Data[3])); |
asong | 1:e4b38d6918ba | 874 | sprintf(text_1," Accel:%2.2f g ",Accel_Mag); |
asong | 1:e4b38d6918ba | 875 | oled.Label((uint8_t *)text_1,10,40);// text_1 at x,y |
asong | 1:e4b38d6918ba | 876 | sprintf(text_1," Gyro:%4.0f D/S ",Gyro_Mag); |
asong | 1:e4b38d6918ba | 877 | oled.Label((uint8_t *)text_1,10,60);// text_1 at x,y |
asong | 1:e4b38d6918ba | 878 | oled.Label((uint8_t *)"Back",10,80); // Display "Back" at x,y |
asong | 1:e4b38d6918ba | 879 | break; |
asong | 1:e4b38d6918ba | 880 | } |
asong | 1:e4b38d6918ba | 881 | case 22: {// Fall Alert Debug Screen |
asong | 1:e4b38d6918ba | 882 | oled.FillScreen(COLOR_BLACK); // Clear screen |
asong | 1:e4b38d6918ba | 883 | textProperties.fontColor = COLOR_RED; |
asong | 1:e4b38d6918ba | 884 | oled.SetTextProperties(&textProperties); |
asong | 1:e4b38d6918ba | 885 | oled.Label((uint8_t *)"Fall Debug",15,5); // Display at x,y |
asong | 1:e4b38d6918ba | 886 | textProperties.fontColor = COLOR_GREEN; |
asong | 1:e4b38d6918ba | 887 | oled.SetTextProperties(&textProperties); |
asong | 1:e4b38d6918ba | 888 | sprintf(text_1," %1.1f g ",Fall_Thresh); |
asong | 1:e4b38d6918ba | 889 | oled.Label((uint8_t *)text_1,35,20);// text_1 at x,y |
asong | 1:e4b38d6918ba | 890 | sprintf(text_1," %2.1f g ",Impact_Thresh); |
asong | 1:e4b38d6918ba | 891 | oled.Label((uint8_t *)text_1,35,35);// text_1 at x,y |
asong | 1:e4b38d6918ba | 892 | sprintf(text_1," %3.0f D/S ",Movement_Thresh); |
asong | 1:e4b38d6918ba | 893 | oled.Label((uint8_t *)text_1,35,50);// text_1 at x,y |
asong | 1:e4b38d6918ba | 894 | textProperties.fontColor = COLOR_WHITE; |
asong | 1:e4b38d6918ba | 895 | oled.SetTextProperties(&textProperties); |
asong | 1:e4b38d6918ba | 896 | oled.Label((uint8_t *)"F-Th:",5,20); // "*" at x,y |
asong | 1:e4b38d6918ba | 897 | oled.Label((uint8_t *)"I-Th:",5,35); // "*" at x,y |
asong | 1:e4b38d6918ba | 898 | oled.Label((uint8_t *)"M-Th:",5,50); // "*" at x,y |
asong | 1:e4b38d6918ba | 899 | oled.Label((uint8_t *)"*",85,15); // "*" at x,y |
asong | 1:e4b38d6918ba | 900 | oled.Label((uint8_t *)"*",85,60); // "*" at x,y |
asong | 1:e4b38d6918ba | 901 | oled.Label((uint8_t *)" Back ",9,80); // Display "Back" at x,y |
asong | 1:e4b38d6918ba | 902 | // oled.Label((uint8_t *)" Enter ",59,80); //Display at x,y |
asong | 1:e4b38d6918ba | 903 | break; |
asong | 1:e4b38d6918ba | 904 | } |
asong | 1:e4b38d6918ba | 905 | case 23: {// Heart Rate Diagnostic Screen |
asong | 1:e4b38d6918ba | 906 | oled.FillScreen(COLOR_BLACK); // Clear screen |
asong | 1:e4b38d6918ba | 907 | textProperties.fontColor = COLOR_RED; |
asong | 1:e4b38d6918ba | 908 | oled.SetTextProperties(&textProperties); |
asong | 1:e4b38d6918ba | 909 | oled.Label((uint8_t *)"H.R. Diagnostic",5,5); // Display at x,y |
asong | 1:e4b38d6918ba | 910 | textProperties.fontColor = COLOR_WHITE; |
asong | 1:e4b38d6918ba | 911 | oled.SetTextProperties(&textProperties); |
asong | 1:e4b38d6918ba | 912 | oled.Label((uint8_t *)"*",85,15); // "*" at x,y |
asong | 1:e4b38d6918ba | 913 | oled.Label((uint8_t *)"*",85,60); // "*" at x,y |
asong | 1:e4b38d6918ba | 914 | oled.Label((uint8_t *)" Back ",9,80); // Display "Back" at x,y |
asong | 1:e4b38d6918ba | 915 | // oled.Label((uint8_t *)" Enter ",59,80); //Display at x,y |
asong | 1:e4b38d6918ba | 916 | break; |
asong | 1:e4b38d6918ba | 917 | } |
asong | 1:e4b38d6918ba | 918 | case 24: {// Heart Rate Debug Screen |
asong | 1:e4b38d6918ba | 919 | oled.FillScreen(COLOR_BLACK); // Clear screen |
asong | 1:e4b38d6918ba | 920 | textProperties.fontColor = COLOR_RED; |
asong | 1:e4b38d6918ba | 921 | oled.SetTextProperties(&textProperties); |
asong | 1:e4b38d6918ba | 922 | oled.Label((uint8_t *)"H.R. Debug",10,5); // Display at x,y |
asong | 1:e4b38d6918ba | 923 | textProperties.fontColor = COLOR_WHITE; |
asong | 1:e4b38d6918ba | 924 | oled.SetTextProperties(&textProperties); |
asong | 1:e4b38d6918ba | 925 | oled.Label((uint8_t *)"*",85,15); // "*" at x,y |
asong | 1:e4b38d6918ba | 926 | oled.Label((uint8_t *)"*",85,60); // "*" at x,y |
asong | 1:e4b38d6918ba | 927 | oled.Label((uint8_t *)" Back ",9,80); // Display "Back" at x,y |
asong | 1:e4b38d6918ba | 928 | // oled.Label((uint8_t *)" Enter ",59,80); //Display at x,y |
asong | 1:e4b38d6918ba | 929 | break; |
asong | 1:e4b38d6918ba | 930 | } |
asong | 1:e4b38d6918ba | 931 | case 25: {// Heat Index Diagnostic Screen |
asong | 1:e4b38d6918ba | 932 | oled.FillScreen(COLOR_BLACK); // Clear screen |
asong | 1:e4b38d6918ba | 933 | textProperties.fontColor = COLOR_RED; |
asong | 1:e4b38d6918ba | 934 | oled.SetTextProperties(&textProperties); |
asong | 1:e4b38d6918ba | 935 | oled.Label((uint8_t *)"H.I. Diagnostic",5,5); // Display at x,y |
asong | 1:e4b38d6918ba | 936 | textProperties.fontColor = COLOR_WHITE; |
asong | 1:e4b38d6918ba | 937 | oled.SetTextProperties(&textProperties); |
asong | 1:e4b38d6918ba | 938 | oled.Label((uint8_t *)"*",85,15); // "*" at x,y |
asong | 1:e4b38d6918ba | 939 | oled.Label((uint8_t *)"*",85,60); // "*" at x,y |
asong | 1:e4b38d6918ba | 940 | oled.Label((uint8_t *)" Back ",9,80); // Display "Back" at x,y |
asong | 1:e4b38d6918ba | 941 | // oled.Label((uint8_t *)" Enter ",59,80); //Display at x,y |
asong | 1:e4b38d6918ba | 942 | break; |
asong | 1:e4b38d6918ba | 943 | } |
asong | 1:e4b38d6918ba | 944 | case 26: {//Heart Rate Config Option |
asong | 1:e4b38d6918ba | 945 | oled.FillScreen(COLOR_BLACK); // Clear screen |
asong | 1:e4b38d6918ba | 946 | oled.Label((uint8_t *)"HR Config",10,5); // Display at x,y |
asong | 1:e4b38d6918ba | 947 | oled.Label((uint8_t *)"*",85,15); // "*" at x,y |
asong | 1:e4b38d6918ba | 948 | oled.Label((uint8_t *)"*",85,60); // "*" at x,y |
asong | 1:e4b38d6918ba | 949 | oled.Label((uint8_t *)"Back",10,80); // Display "Back" at x,y |
asong | 1:e4b38d6918ba | 950 | oled.Label((uint8_t *)"Enter",60,80); //Display "enter" at x,y |
asong | 1:e4b38d6918ba | 951 | break; |
asong | 1:e4b38d6918ba | 952 | } |
asong | 1:e4b38d6918ba | 953 | case 27: { //Enter Age Screen |
asong | 1:e4b38d6918ba | 954 | oled.FillScreen(COLOR_BLACK); |
asong | 1:e4b38d6918ba | 955 | oled.Label((uint8_t *)"Input Age", 10, 5); |
asong | 1:e4b38d6918ba | 956 | sprintf(display_buff, "%u", Age); //Convert int to char array for displaying user age |
asong | 1:e4b38d6918ba | 957 | oled.Label((uint8_t *)"Age:", 10, 30); |
asong | 1:e4b38d6918ba | 958 | oled.Label((uint8_t *)"+",85,15); // "*" at x,y |
asong | 1:e4b38d6918ba | 959 | oled.Label((uint8_t *)"-",85,60); // "*" at x,y |
asong | 1:e4b38d6918ba | 960 | oled.Label((uint8_t *)"Menu",10,80); // Display "Menu" at x,y |
asong | 1:e4b38d6918ba | 961 | oled.Label((uint8_t *)"Next",60,80); //Display "Next" at x,y |
asong | 1:e4b38d6918ba | 962 | textProperties.fontColor = COLOR_GREEN; |
asong | 1:e4b38d6918ba | 963 | oled.SetTextProperties(&textProperties); |
asong | 1:e4b38d6918ba | 964 | oled.Label((uint8_t *)display_buff,43,30); // Display at x,y |
asong | 1:e4b38d6918ba | 965 | textProperties.fontColor = COLOR_WHITE; |
asong | 1:e4b38d6918ba | 966 | oled.SetTextProperties(&textProperties); |
asong | 1:e4b38d6918ba | 967 | oled.Label((uint8_t *)"Max bpm:",10,50); |
asong | 1:e4b38d6918ba | 968 | textProperties.fontColor = COLOR_RED; |
asong | 1:e4b38d6918ba | 969 | oled.SetTextProperties(&textProperties); //implements the color change |
asong | 2:824ed4ae8d52 | 970 | sprintf(display_buff, "%u", Max_Bpm); //Convert int to char array for displaying user max bpm |
asong | 1:e4b38d6918ba | 971 | oled.Label((uint8_t *)display_buff, 65, 50); |
asong | 1:e4b38d6918ba | 972 | textProperties.fontColor = COLOR_WHITE; |
asong | 1:e4b38d6918ba | 973 | oled.SetTextProperties(&textProperties); |
asong | 1:e4b38d6918ba | 974 | break; |
asong | 1:e4b38d6918ba | 975 | } |
asong | 1:e4b38d6918ba | 976 | case 28: {//Choose Heart Rate Vibration Option |
asong | 1:e4b38d6918ba | 977 | oled.FillScreen(COLOR_BLACK); |
asong | 1:e4b38d6918ba | 978 | oled.Label((uint8_t *)"Vibrate Pref", 10, 10); |
asong | 1:e4b38d6918ba | 979 | oled.Label((uint8_t *)"Option:", 10, 25); |
asong | 1:e4b38d6918ba | 980 | oled.Label((uint8_t *)"+",85,15); // "+" at x,y |
asong | 1:e4b38d6918ba | 981 | oled.Label((uint8_t *)"-",85,60); // "-" at x,y |
asong | 1:e4b38d6918ba | 982 | oled.Label((uint8_t *)"Back",10,80); // Display "Back" at x,y |
asong | 1:e4b38d6918ba | 983 | oled.Label((uint8_t *)"Next",60,80); //Display "Next" at x,y |
asong | 1:e4b38d6918ba | 984 | sprintf(display_buff, "%u", HR_Vibration); //Convert int to char array for displaying user preference |
asong | 1:e4b38d6918ba | 985 | textProperties.fontColor = COLOR_GREEN; //Change font to green |
asong | 1:e4b38d6918ba | 986 | oled.SetTextProperties(&textProperties);//Implement color change |
asong | 1:e4b38d6918ba | 987 | oled.Label((uint8_t *)display_buff,55,25); // Display at x,y |
asong | 1:e4b38d6918ba | 988 | if(HR_Vibration == 1) { |
asong | 1:e4b38d6918ba | 989 | textProperties.fontColor = COLOR_RED; //Change font to red |
asong | 1:e4b38d6918ba | 990 | oled.SetTextProperties(&textProperties); //Implement color change |
asong | 1:e4b38d6918ba | 991 | oled.Label((uint8_t *)"All On",10,45); // Display at x,y |
asong | 1:e4b38d6918ba | 992 | } else if(HR_Vibration == 2) { |
asong | 1:e4b38d6918ba | 993 | textProperties.fontColor = COLOR_RED; //Change font to red |
asong | 1:e4b38d6918ba | 994 | oled.SetTextProperties(&textProperties);//Implement color change |
asong | 1:e4b38d6918ba | 995 | oled.Label((uint8_t *)"Only Entering",10,38);// Display at x,y |
asong | 1:e4b38d6918ba | 996 | oled.Label((uint8_t *)"And Exiting",10,53);// Display at x,y |
asong | 1:e4b38d6918ba | 997 | oled.Label((uint8_t *)"Target Zone",10,68);// Display at x,y |
nbaker | 0:d1d36a3da39b | 998 | |
asong | 1:e4b38d6918ba | 999 | } else if(HR_Vibration == 3) { |
asong | 1:e4b38d6918ba | 1000 | textProperties.fontColor = COLOR_RED; //Change font to red |
asong | 1:e4b38d6918ba | 1001 | oled.SetTextProperties(&textProperties); //Implement color change |
asong | 1:e4b38d6918ba | 1002 | oled.Label((uint8_t *)"All Off",10,45);// Display at x,y |
asong | 1:e4b38d6918ba | 1003 | } |
asong | 1:e4b38d6918ba | 1004 | textProperties.fontColor = COLOR_WHITE; |
asong | 1:e4b38d6918ba | 1005 | oled.SetTextProperties(&textProperties); |
asong | 1:e4b38d6918ba | 1006 | break; |
asong | 1:e4b38d6918ba | 1007 | } |
asong | 1:e4b38d6918ba | 1008 | case 29: { //Zone Boundary Info |
asong | 1:e4b38d6918ba | 1009 | oled.FillScreen(COLOR_BLACK); |
asong | 1:e4b38d6918ba | 1010 | oled.Label((uint8_t *)"HR Zone Info", 10, 5);// Display at x,y |
asong | 1:e4b38d6918ba | 1011 | textProperties.fontColor = COLOR_YELLOW; //Change font to yellow |
asong | 1:e4b38d6918ba | 1012 | oled.SetTextProperties(&textProperties);//Implement color change |
asong | 1:e4b38d6918ba | 1013 | oled.Label((uint8_t *)"Z1:", 10, 20);// Display at x,y |
asong | 1:e4b38d6918ba | 1014 | sprintf(display_buff, "%u", HR_Zone1[0]); // Convert int to char to display |
asong | 1:e4b38d6918ba | 1015 | oled.Label((uint8_t *)display_buff, 30, 20);// Display at x,y |
asong | 1:e4b38d6918ba | 1016 | oled.Label((uint8_t *)"-", 52, 20);// Display at x,y |
asong | 1:e4b38d6918ba | 1017 | sprintf(display_buff, "%u", HR_Zone1[1]); // Convert int to char to display |
asong | 1:e4b38d6918ba | 1018 | oled.Label((uint8_t *)display_buff, 60, 20);// Display at x,y |
asong | 1:e4b38d6918ba | 1019 | textProperties.fontColor = COLOR_BLUE; //Change font to blue |
asong | 1:e4b38d6918ba | 1020 | oled.SetTextProperties(&textProperties);//Implement color change |
asong | 1:e4b38d6918ba | 1021 | oled.Label((uint8_t *)"Z2:", 10, 35);// Display at x,y |
asong | 1:e4b38d6918ba | 1022 | sprintf(display_buff, "%u", HR_Zone2[0]); // Convert int to char to display |
asong | 1:e4b38d6918ba | 1023 | oled.Label((uint8_t *)display_buff, 30, 35);// Display at x,y |
asong | 1:e4b38d6918ba | 1024 | oled.Label((uint8_t *)"-", 52, 35);// Display at x,y |
asong | 1:e4b38d6918ba | 1025 | sprintf(display_buff, "%u", HR_Zone2[1]); // Convert int to char to display |
asong | 1:e4b38d6918ba | 1026 | oled.Label((uint8_t *)display_buff, 60, 35);// Display at x,y |
asong | 1:e4b38d6918ba | 1027 | textProperties.fontColor = COLOR_GREEN; //Change font to green |
asong | 1:e4b38d6918ba | 1028 | oled.SetTextProperties(&textProperties);//Implement color change |
asong | 1:e4b38d6918ba | 1029 | oled.Label((uint8_t *)"Z3:", 10, 50);// Display at x,y |
asong | 1:e4b38d6918ba | 1030 | sprintf(display_buff, "%u", HR_Zone3[0]); // Convert int to char to display |
asong | 1:e4b38d6918ba | 1031 | oled.Label((uint8_t *)display_buff, 30, 50);// Display at x,y |
asong | 1:e4b38d6918ba | 1032 | oled.Label((uint8_t *)"-", 52, 50);// Display at x,y |
asong | 1:e4b38d6918ba | 1033 | sprintf(display_buff, "%u", HR_Zone3[1]); // Convert int to char to display |
asong | 1:e4b38d6918ba | 1034 | oled.Label((uint8_t *)display_buff, 60, 50);// Display at x,y |
asong | 1:e4b38d6918ba | 1035 | textProperties.fontColor = COLOR_RED; //Change font to red |
asong | 1:e4b38d6918ba | 1036 | oled.SetTextProperties(&textProperties);//Implement color change |
asong | 1:e4b38d6918ba | 1037 | oled.Label((uint8_t *)"Z4:", 10, 65);// Display at x,y |
asong | 1:e4b38d6918ba | 1038 | sprintf(display_buff, "%u", HR_Zone4[0]); // Convert int to char to display |
asong | 1:e4b38d6918ba | 1039 | oled.Label((uint8_t *)display_buff, 30, 65);// Display at x,y |
asong | 1:e4b38d6918ba | 1040 | oled.Label((uint8_t *)"-", 52, 65);// Display at x,y |
asong | 1:e4b38d6918ba | 1041 | sprintf(display_buff, "%u", HR_Zone4[1]); // Convert int to char to display |
asong | 1:e4b38d6918ba | 1042 | oled.Label((uint8_t *)display_buff, 60, 65);// Display at x,y |
asong | 1:e4b38d6918ba | 1043 | textProperties.fontColor = COLOR_WHITE; //Change font to white |
asong | 1:e4b38d6918ba | 1044 | oled.SetTextProperties(&textProperties);//Implement color change |
asong | 1:e4b38d6918ba | 1045 | oled.Label((uint8_t *)"Back",10,80); // Display "Back" at x,y |
asong | 1:e4b38d6918ba | 1046 | oled.Label((uint8_t *)"Next",60,80); //Display "Next" at x,y |
asong | 1:e4b38d6918ba | 1047 | break; |
asong | 2:824ed4ae8d52 | 1048 | } |
asong | 2:824ed4ae8d52 | 1049 | case 30: { //Enter Target Heart Rate Zone Preference |
asong | 1:e4b38d6918ba | 1050 | oled.FillScreen(COLOR_BLACK); |
asong | 1:e4b38d6918ba | 1051 | oled.Label((uint8_t *)"Zone Pref", 10, 5);// Display at x,y |
asong | 1:e4b38d6918ba | 1052 | oled.Label((uint8_t *)"Back",10,80); // Display "Back" at x,y |
asong | 1:e4b38d6918ba | 1053 | oled.Label((uint8_t *)"Next",60,80); //Display "Next" at x,y |
asong | 1:e4b38d6918ba | 1054 | oled.Label((uint8_t *)"+",85,15); // "+" at x,y |
asong | 1:e4b38d6918ba | 1055 | oled.Label((uint8_t *)"-",85,60); // "-" at x,y |
asong | 1:e4b38d6918ba | 1056 | oled.Label((uint8_t *)"Target:", 10, 25);// Display at x,y |
asong | 1:e4b38d6918ba | 1057 | sprintf(display_buff, "%u", Target_Zone); // Convert int to char to display |
asong | 2:824ed4ae8d52 | 1058 | if(Target_Zone == 1) { |
asong | 1:e4b38d6918ba | 1059 | textProperties.fontColor = COLOR_YELLOW; //Change font to yellow |
asong | 1:e4b38d6918ba | 1060 | oled.SetTextProperties(&textProperties);//Implement color change |
asong | 2:824ed4ae8d52 | 1061 | } else if(Target_Zone == 2) { |
asong | 1:e4b38d6918ba | 1062 | textProperties.fontColor = COLOR_BLUE; //Change font to blue |
asong | 1:e4b38d6918ba | 1063 | oled.SetTextProperties(&textProperties);//Implement color change |
asong | 2:824ed4ae8d52 | 1064 | } else if(Target_Zone == 3) { |
asong | 1:e4b38d6918ba | 1065 | textProperties.fontColor = COLOR_GREEN; //Change font to green |
asong | 1:e4b38d6918ba | 1066 | oled.SetTextProperties(&textProperties);//Implement color change |
asong | 2:824ed4ae8d52 | 1067 | } else if(Target_Zone == 4) { |
asong | 1:e4b38d6918ba | 1068 | textProperties.fontColor = COLOR_RED; //Change font to red |
asong | 1:e4b38d6918ba | 1069 | oled.SetTextProperties(&textProperties);//Implement color change |
asong | 1:e4b38d6918ba | 1070 | } |
asong | 1:e4b38d6918ba | 1071 | oled.Label((uint8_t *)display_buff, 55, 25);// Display at x,y |
asong | 1:e4b38d6918ba | 1072 | textProperties.fontColor = COLOR_WHITE; //Change font to white |
asong | 1:e4b38d6918ba | 1073 | oled.SetTextProperties(&textProperties);//Implement color change |
asong | 1:e4b38d6918ba | 1074 | oled.Label((uint8_t *)"Bounds:", 10, 45);// Display at x,y |
asong | 2:824ed4ae8d52 | 1075 | if(Target_Zone == 1) { |
asong | 1:e4b38d6918ba | 1076 | textProperties.fontColor = COLOR_YELLOW; //Change font to yellow |
asong | 1:e4b38d6918ba | 1077 | oled.SetTextProperties(&textProperties);//Implement color change |
asong | 1:e4b38d6918ba | 1078 | sprintf(display_buff, "%u", HR_Zone1[0]); // Convert int to char to display |
asong | 1:e4b38d6918ba | 1079 | oled.Label((uint8_t *)display_buff, 10, 60);// Display at x,y |
asong | 1:e4b38d6918ba | 1080 | oled.Label((uint8_t *)"-", 32, 60);// Display at x,y |
asong | 1:e4b38d6918ba | 1081 | sprintf(display_buff, "%u", HR_Zone1[1]); // Convert int to char to display |
asong | 1:e4b38d6918ba | 1082 | oled.Label((uint8_t *)display_buff, 40, 60);// Display at x,y |
asong | 2:824ed4ae8d52 | 1083 | } else if(Target_Zone == 2) { |
asong | 1:e4b38d6918ba | 1084 | textProperties.fontColor = COLOR_BLUE; //Change font to blue |
asong | 1:e4b38d6918ba | 1085 | oled.SetTextProperties(&textProperties);//Implement color change |
asong | 1:e4b38d6918ba | 1086 | sprintf(display_buff, "%u", HR_Zone2[0]); // Convert int to char to display |
asong | 1:e4b38d6918ba | 1087 | oled.Label((uint8_t *)display_buff, 10, 60);// Display at x,y |
asong | 1:e4b38d6918ba | 1088 | oled.Label((uint8_t *)"-", 32, 60);// Display at x,y |
asong | 1:e4b38d6918ba | 1089 | sprintf(display_buff, "%u", HR_Zone2[1]); // Convert int to char to display |
asong | 1:e4b38d6918ba | 1090 | oled.Label((uint8_t *)display_buff, 40, 60);// Display at x,y |
asong | 2:824ed4ae8d52 | 1091 | } else if(Target_Zone == 3) { |
asong | 1:e4b38d6918ba | 1092 | textProperties.fontColor = COLOR_GREEN; //Change font to green |
asong | 1:e4b38d6918ba | 1093 | oled.SetTextProperties(&textProperties);//Implement color change |
asong | 1:e4b38d6918ba | 1094 | sprintf(display_buff, "%u", HR_Zone3[0]); // Convert int to char to display |
asong | 1:e4b38d6918ba | 1095 | oled.Label((uint8_t *)display_buff, 10, 60); // Display at x,y |
asong | 1:e4b38d6918ba | 1096 | oled.Label((uint8_t *)"-", 32, 60); // Display at x,y |
asong | 1:e4b38d6918ba | 1097 | sprintf(display_buff, "%u", HR_Zone3[1]); // Convert int to char to display |
asong | 1:e4b38d6918ba | 1098 | oled.Label((uint8_t *)display_buff, 40, 60);// Display at x,y |
asong | 2:824ed4ae8d52 | 1099 | } else if(Target_Zone == 4) { |
asong | 1:e4b38d6918ba | 1100 | textProperties.fontColor = COLOR_RED; //Change font to red |
asong | 1:e4b38d6918ba | 1101 | oled.SetTextProperties(&textProperties);//Implement color change |
asong | 1:e4b38d6918ba | 1102 | sprintf(display_buff, "%u", HR_Zone4[0]); // Convert int to char to display |
asong | 1:e4b38d6918ba | 1103 | oled.Label((uint8_t *)display_buff, 10, 60); // Display at x,y |
asong | 1:e4b38d6918ba | 1104 | oled.Label((uint8_t *)"-", 32, 60); // Display at x,y |
asong | 1:e4b38d6918ba | 1105 | sprintf(display_buff, "%u", HR_Zone4[1]); // Convert int to char to display |
asong | 1:e4b38d6918ba | 1106 | oled.Label((uint8_t *)display_buff, 40, 60); // Display at x,y |
asong | 1:e4b38d6918ba | 1107 | } |
asong | 1:e4b38d6918ba | 1108 | textProperties.fontColor = COLOR_WHITE; //Change font to white |
asong | 1:e4b38d6918ba | 1109 | oled.SetTextProperties(&textProperties);//Implement color change |
asong | 2:824ed4ae8d52 | 1110 | break; |
asong | 2:824ed4ae8d52 | 1111 | } |
asong | 2:824ed4ae8d52 | 1112 | case 31: { |
asong | 2:824ed4ae8d52 | 1113 | oled.FillScreen(COLOR_BLACK); |
asong | 2:824ed4ae8d52 | 1114 | Heart_Rate_Vibrations(); |
asong | 2:824ed4ae8d52 | 1115 | oled.Label((uint8_t *)"Enter HR", 10, 5);// Display at x,y |
asong | 2:824ed4ae8d52 | 1116 | oled.Label((uint8_t *)"Back",10,80); // Display "Back" at x,y |
asong | 2:824ed4ae8d52 | 1117 | oled.Label((uint8_t *)"Next",60,80); //Display "Next" at x,y |
asong | 2:824ed4ae8d52 | 1118 | oled.Label((uint8_t *)"+",85,15); // "+" at x,y |
asong | 2:824ed4ae8d52 | 1119 | oled.Label((uint8_t *)"-",85,60); // "-" at x,y |
asong | 2:824ed4ae8d52 | 1120 | oled.Label((uint8_t *)"HR:", 10, 25); |
asong | 2:824ed4ae8d52 | 1121 | sprintf(display_buff, "%u", Heart_Rate); // Convert int to char to display |
asong | 2:824ed4ae8d52 | 1122 | textProperties.fontColor = COLOR_RED; //Change font to red |
asong | 2:824ed4ae8d52 | 1123 | oled.SetTextProperties(&textProperties);//Implement color change |
asong | 2:824ed4ae8d52 | 1124 | oled.Label((uint8_t *)display_buff, 40, 25); |
asong | 2:824ed4ae8d52 | 1125 | textProperties.fontColor = COLOR_WHITE; //Change font to white |
asong | 2:824ed4ae8d52 | 1126 | oled.SetTextProperties(&textProperties);//Implement color change |
asong | 2:824ed4ae8d52 | 1127 | oled.Label((uint8_t *)"Cur Zone:", 10, 45); |
asong | 2:824ed4ae8d52 | 1128 | if(Current_Zone == 1) { |
asong | 2:824ed4ae8d52 | 1129 | textProperties.fontColor = COLOR_YELLOW; |
asong | 2:824ed4ae8d52 | 1130 | oled.SetTextProperties(&textProperties); |
asong | 2:824ed4ae8d52 | 1131 | } else if(Current_Zone == 2) { |
asong | 2:824ed4ae8d52 | 1132 | textProperties.fontColor = COLOR_BLUE; |
asong | 2:824ed4ae8d52 | 1133 | oled.SetTextProperties(&textProperties); |
asong | 2:824ed4ae8d52 | 1134 | } else if(Current_Zone == 3) { |
asong | 2:824ed4ae8d52 | 1135 | textProperties.fontColor = COLOR_GREEN; |
asong | 2:824ed4ae8d52 | 1136 | oled.SetTextProperties(&textProperties); |
asong | 2:824ed4ae8d52 | 1137 | } else if(Current_Zone == 4) { |
asong | 2:824ed4ae8d52 | 1138 | textProperties.fontColor = COLOR_RED; |
asong | 2:824ed4ae8d52 | 1139 | oled.SetTextProperties(&textProperties); |
asong | 2:824ed4ae8d52 | 1140 | } |
asong | 2:824ed4ae8d52 | 1141 | sprintf(display_buff, "%u", Current_Zone); // Convert int to char to display |
asong | 2:824ed4ae8d52 | 1142 | oled.Label((uint8_t *)display_buff, 71, 45); |
asong | 2:824ed4ae8d52 | 1143 | textProperties.fontColor = COLOR_WHITE; //Change font to white |
asong | 2:824ed4ae8d52 | 1144 | oled.SetTextProperties(&textProperties);//Implement color change |
asong | 2:824ed4ae8d52 | 1145 | oled.Label((uint8_t *)"Prev Zone:", 10, 60); |
asong | 2:824ed4ae8d52 | 1146 | if(Prev_Zone == 1) { |
asong | 2:824ed4ae8d52 | 1147 | textProperties.fontColor = COLOR_YELLOW; |
asong | 2:824ed4ae8d52 | 1148 | oled.SetTextProperties(&textProperties); |
asong | 2:824ed4ae8d52 | 1149 | } else if(Prev_Zone == 2) { |
asong | 2:824ed4ae8d52 | 1150 | textProperties.fontColor = COLOR_BLUE; |
asong | 2:824ed4ae8d52 | 1151 | oled.SetTextProperties(&textProperties); |
asong | 2:824ed4ae8d52 | 1152 | } else if(Prev_Zone == 3) { |
asong | 2:824ed4ae8d52 | 1153 | textProperties.fontColor = COLOR_GREEN; |
asong | 2:824ed4ae8d52 | 1154 | oled.SetTextProperties(&textProperties); |
asong | 2:824ed4ae8d52 | 1155 | } else if(Prev_Zone == 4) { |
asong | 2:824ed4ae8d52 | 1156 | textProperties.fontColor = COLOR_RED; |
asong | 2:824ed4ae8d52 | 1157 | oled.SetTextProperties(&textProperties); |
asong | 2:824ed4ae8d52 | 1158 | } |
asong | 2:824ed4ae8d52 | 1159 | sprintf(display_buff, "%u", Prev_Zone); // Convert int to char to display |
asong | 2:824ed4ae8d52 | 1160 | oled.Label((uint8_t *)display_buff, 71, 60); |
asong | 2:824ed4ae8d52 | 1161 | textProperties.fontColor = COLOR_WHITE; //Change font to white |
asong | 2:824ed4ae8d52 | 1162 | oled.SetTextProperties(&textProperties);//Implement color change |
asong | 2:824ed4ae8d52 | 1163 | Led_Zone_Indicator(); |
asong | 2:824ed4ae8d52 | 1164 | break; |
asong | 2:824ed4ae8d52 | 1165 | } |
asong | 2:824ed4ae8d52 | 1166 | case 32: { |
asong | 2:824ed4ae8d52 | 1167 | //Zone Boundary Info |
asong | 2:824ed4ae8d52 | 1168 | oled.FillScreen(COLOR_BLACK); |
asong | 2:824ed4ae8d52 | 1169 | oled.Label((uint8_t *)"HR Zone Info", 10, 5);// Display at x,y |
asong | 2:824ed4ae8d52 | 1170 | textProperties.fontColor = COLOR_YELLOW; //Change font to yellow |
asong | 2:824ed4ae8d52 | 1171 | oled.SetTextProperties(&textProperties);//Implement color change |
asong | 2:824ed4ae8d52 | 1172 | oled.Label((uint8_t *)"Z1:", 10, 20);// Display at x,y |
asong | 2:824ed4ae8d52 | 1173 | sprintf(display_buff, "%u", HR_Zone1[0]); // Convert int to char to display |
asong | 2:824ed4ae8d52 | 1174 | oled.Label((uint8_t *)display_buff, 30, 20);// Display at x,y |
asong | 2:824ed4ae8d52 | 1175 | oled.Label((uint8_t *)"-", 52, 20);// Display at x,y |
asong | 2:824ed4ae8d52 | 1176 | sprintf(display_buff, "%u", HR_Zone1[1]); // Convert int to char to display |
asong | 2:824ed4ae8d52 | 1177 | oled.Label((uint8_t *)display_buff, 60, 20);// Display at x,y |
asong | 2:824ed4ae8d52 | 1178 | textProperties.fontColor = COLOR_BLUE; //Change font to blue |
asong | 2:824ed4ae8d52 | 1179 | oled.SetTextProperties(&textProperties);//Implement color change |
asong | 2:824ed4ae8d52 | 1180 | oled.Label((uint8_t *)"Z2:", 10, 35);// Display at x,y |
asong | 2:824ed4ae8d52 | 1181 | sprintf(display_buff, "%u", HR_Zone2[0]); // Convert int to char to display |
asong | 2:824ed4ae8d52 | 1182 | oled.Label((uint8_t *)display_buff, 30, 35);// Display at x,y |
asong | 2:824ed4ae8d52 | 1183 | oled.Label((uint8_t *)"-", 52, 35);// Display at x,y |
asong | 2:824ed4ae8d52 | 1184 | sprintf(display_buff, "%u", HR_Zone2[1]); // Convert int to char to display |
asong | 2:824ed4ae8d52 | 1185 | oled.Label((uint8_t *)display_buff, 60, 35);// Display at x,y |
asong | 2:824ed4ae8d52 | 1186 | textProperties.fontColor = COLOR_GREEN; //Change font to green |
asong | 2:824ed4ae8d52 | 1187 | oled.SetTextProperties(&textProperties);//Implement color change |
asong | 2:824ed4ae8d52 | 1188 | oled.Label((uint8_t *)"Z3:", 10, 50);// Display at x,y |
asong | 2:824ed4ae8d52 | 1189 | sprintf(display_buff, "%u", HR_Zone3[0]); // Convert int to char to display |
asong | 2:824ed4ae8d52 | 1190 | oled.Label((uint8_t *)display_buff, 30, 50);// Display at x,y |
asong | 2:824ed4ae8d52 | 1191 | oled.Label((uint8_t *)"-", 52, 50);// Display at x,y |
asong | 2:824ed4ae8d52 | 1192 | sprintf(display_buff, "%u", HR_Zone3[1]); // Convert int to char to display |
asong | 2:824ed4ae8d52 | 1193 | oled.Label((uint8_t *)display_buff, 60, 50);// Display at x,y |
asong | 2:824ed4ae8d52 | 1194 | textProperties.fontColor = COLOR_RED; //Change font to red |
asong | 2:824ed4ae8d52 | 1195 | oled.SetTextProperties(&textProperties);//Implement color change |
asong | 2:824ed4ae8d52 | 1196 | oled.Label((uint8_t *)"Z4:", 10, 65);// Display at x,y |
asong | 2:824ed4ae8d52 | 1197 | sprintf(display_buff, "%u", HR_Zone4[0]); // Convert int to char to display |
asong | 2:824ed4ae8d52 | 1198 | oled.Label((uint8_t *)display_buff, 30, 65);// Display at x,y |
asong | 2:824ed4ae8d52 | 1199 | oled.Label((uint8_t *)"-", 52, 65);// Display at x,y |
asong | 2:824ed4ae8d52 | 1200 | sprintf(display_buff, "%u", HR_Zone4[1]); // Convert int to char to display |
asong | 2:824ed4ae8d52 | 1201 | oled.Label((uint8_t *)display_buff, 60, 65);// Display at x,y |
asong | 2:824ed4ae8d52 | 1202 | textProperties.fontColor = COLOR_WHITE; //Change font to white |
asong | 2:824ed4ae8d52 | 1203 | oled.SetTextProperties(&textProperties);//Implement color change |
asong | 2:824ed4ae8d52 | 1204 | oled.Label((uint8_t *)"Back",10,80); // Display "Back" at x,y |
asong | 2:824ed4ae8d52 | 1205 | oled.Label((uint8_t *)"Next",60,80); //Display "Next" at x,y |
asong | 2:824ed4ae8d52 | 1206 | break; |
asong | 1:e4b38d6918ba | 1207 | } |
nbaker | 0:d1d36a3da39b | 1208 | #endif // end of non-production/debug version code |
asong | 1:e4b38d6918ba | 1209 | default: { |
asong | 2:824ed4ae8d52 | 1210 | Error_Num=1; |
asong | 2:824ed4ae8d52 | 1211 | error_screen(); // Clear screen |
asong | 2:824ed4ae8d52 | 1212 | break; |
asong | 2:824ed4ae8d52 | 1213 | } |
nbaker | 0:d1d36a3da39b | 1214 | } |
nbaker | 0:d1d36a3da39b | 1215 | } |
asong | 1:e4b38d6918ba | 1216 | void error_screen(void) |
asong | 1:e4b38d6918ba | 1217 | { |
asong | 1:e4b38d6918ba | 1218 | oled.FillScreen(COLOR_RED); // Clear screen |
asong | 1:e4b38d6918ba | 1219 | oled.Label((uint8_t *)"Error! ",30,30); // Display error at x,y |
asong | 1:e4b38d6918ba | 1220 | sprintf(text_1," %i ",Error_Num); |
asong | 1:e4b38d6918ba | 1221 | oled.Label((uint8_t *)text_1,30,60); // Display error at x,y |
asong | 1:e4b38d6918ba | 1222 | wait(3); // wait 3 seconds |
asong | 1:e4b38d6918ba | 1223 | oled.FillScreen(COLOR_BLACK); // Clear screen |
nbaker | 0:d1d36a3da39b | 1224 | } |
asong | 2:824ed4ae8d52 | 1225 | |
asong | 2:824ed4ae8d52 | 1226 | /***************************************************************************** |
asong | 2:824ed4ae8d52 | 1227 | Name: StartHaptic |
asong | 2:824ed4ae8d52 | 1228 | Purpose: Cause the HexiHeart device to vibrate for a predetermined amount of |
asong | 2:824ed4ae8d52 | 1229 | time |
asong | 2:824ed4ae8d52 | 1230 | Inputs: None |
asong | 2:824ed4ae8d52 | 1231 | Returns: None |
asong | 2:824ed4ae8d52 | 1232 | ******************************************************************************/ |
nbaker | 0:d1d36a3da39b | 1233 | void StartHaptic(void) |
nbaker | 0:d1d36a3da39b | 1234 | { |
nbaker | 0:d1d36a3da39b | 1235 | hapticTimer.start(30); // was originaly 50 |
nbaker | 0:d1d36a3da39b | 1236 | haptic = 1; |
nbaker | 0:d1d36a3da39b | 1237 | } |
nbaker | 0:d1d36a3da39b | 1238 | |
asong | 2:824ed4ae8d52 | 1239 | /***************************************************************************** |
asong | 2:824ed4ae8d52 | 1240 | Name: StartHaptic |
asong | 2:824ed4ae8d52 | 1241 | Purpose: Cause the HexiHeart device to vibrate for x amount of time |
asong | 2:824ed4ae8d52 | 1242 | Inputs: An int representing the duration of the vibration |
asong | 2:824ed4ae8d52 | 1243 | Returns: None |
asong | 2:824ed4ae8d52 | 1244 | ******************************************************************************/ |
asong | 1:e4b38d6918ba | 1245 | void StartHaptic(int x) |
asong | 1:e4b38d6918ba | 1246 | { |
asong | 1:e4b38d6918ba | 1247 | hapticTimer.start(x); |
asong | 2:824ed4ae8d52 | 1248 | haptic = 1; |
asong | 1:e4b38d6918ba | 1249 | } |
asong | 1:e4b38d6918ba | 1250 | |
asong | 1:e4b38d6918ba | 1251 | void StopHaptic(void const *n) |
asong | 1:e4b38d6918ba | 1252 | { |
nbaker | 0:d1d36a3da39b | 1253 | haptic = 0; |
nbaker | 0:d1d36a3da39b | 1254 | hapticTimer.stop(); |
nbaker | 0:d1d36a3da39b | 1255 | } |
asong | 2:824ed4ae8d52 | 1256 | |
asong | 2:824ed4ae8d52 | 1257 | /***************************************************************************** |
asong | 2:824ed4ae8d52 | 1258 | Name: Increment_Age |
asong | 2:824ed4ae8d52 | 1259 | Purpose: Increment the user's age by 1 |
asong | 2:824ed4ae8d52 | 1260 | Inputs: None |
asong | 2:824ed4ae8d52 | 1261 | Returns: None |
asong | 2:824ed4ae8d52 | 1262 | ******************************************************************************/ |
asong | 2:824ed4ae8d52 | 1263 | void Increment_Age() |
asong | 2:824ed4ae8d52 | 1264 | { |
asong | 2:824ed4ae8d52 | 1265 | StartHaptic(); |
asong | 2:824ed4ae8d52 | 1266 | if(Age < 100) { |
asong | 2:824ed4ae8d52 | 1267 | Age += 1; |
asong | 2:824ed4ae8d52 | 1268 | Screen_Num = 27; |
asong | 2:824ed4ae8d52 | 1269 | } else { |
asong | 2:824ed4ae8d52 | 1270 | Age = 1; |
asong | 2:824ed4ae8d52 | 1271 | } |
asong | 2:824ed4ae8d52 | 1272 | } |
asong | 2:824ed4ae8d52 | 1273 | |
asong | 2:824ed4ae8d52 | 1274 | /***************************************************************************** |
asong | 2:824ed4ae8d52 | 1275 | Name: Decrement_Age |
asong | 2:824ed4ae8d52 | 1276 | Purpose: Decrement the user's age by 1 |
asong | 2:824ed4ae8d52 | 1277 | Inputs: None |
asong | 2:824ed4ae8d52 | 1278 | Returns: None |
asong | 2:824ed4ae8d52 | 1279 | ******************************************************************************/ |
asong | 2:824ed4ae8d52 | 1280 | void Decrement_Age() |
asong | 2:824ed4ae8d52 | 1281 | { |
asong | 2:824ed4ae8d52 | 1282 | StartHaptic(); |
asong | 2:824ed4ae8d52 | 1283 | if(Age == 1) { |
asong | 2:824ed4ae8d52 | 1284 | Age = 100; |
asong | 2:824ed4ae8d52 | 1285 | } else { |
asong | 2:824ed4ae8d52 | 1286 | Age -= 1; |
asong | 2:824ed4ae8d52 | 1287 | Screen_Num = 27; |
asong | 2:824ed4ae8d52 | 1288 | } |
asong | 2:824ed4ae8d52 | 1289 | } |
asong | 2:824ed4ae8d52 | 1290 | |
asong | 2:824ed4ae8d52 | 1291 | /***************************************************************************** |
asong | 2:824ed4ae8d52 | 1292 | Name: Set_Max_Bpm |
asong | 2:824ed4ae8d52 | 1293 | Purpose: Calculates the user's maximum heart rate based on their age |
asong | 2:824ed4ae8d52 | 1294 | Inputs: None |
asong | 2:824ed4ae8d52 | 1295 | Returns: None |
asong | 2:824ed4ae8d52 | 1296 | ******************************************************************************/ |
asong | 2:824ed4ae8d52 | 1297 | void Set_Max_Bpm() |
asong | 2:824ed4ae8d52 | 1298 | { |
asong | 2:824ed4ae8d52 | 1299 | Max_Bpm = 220 - Age; |
asong | 2:824ed4ae8d52 | 1300 | } |
asong | 2:824ed4ae8d52 | 1301 | |
asong | 2:824ed4ae8d52 | 1302 | /***************************************************************************** |
asong | 2:824ed4ae8d52 | 1303 | Name: Set_Zone_Boundaries |
asong | 2:824ed4ae8d52 | 1304 | Purpose: Calculates the user's heart rate zones' boundaries based on the user's |
asong | 2:824ed4ae8d52 | 1305 | maximum heart rate |
asong | 2:824ed4ae8d52 | 1306 | Inputs: None |
asong | 2:824ed4ae8d52 | 1307 | Returns: None |
asong | 2:824ed4ae8d52 | 1308 | ******************************************************************************/ |
asong | 2:824ed4ae8d52 | 1309 | void Set_Zone_Boundaries() |
asong | 2:824ed4ae8d52 | 1310 | { |
asong | 2:824ed4ae8d52 | 1311 | Set_Max_Bpm(); |
asong | 2:824ed4ae8d52 | 1312 | HR_Zone1[0] = Max_Bpm * .50; //Set Heart Rate Zone 1 |
asong | 2:824ed4ae8d52 | 1313 | HR_Zone1[1] = Max_Bpm * .60; //Set Heart Rate Zone 1 |
asong | 2:824ed4ae8d52 | 1314 | HR_Zone2[0] = HR_Zone1[1] + 1; //Set Heart Rate Zone 2 |
asong | 2:824ed4ae8d52 | 1315 | HR_Zone2[1] = Max_Bpm * .70; //Set Heart Rate Zone 2 |
asong | 2:824ed4ae8d52 | 1316 | HR_Zone3[0] = HR_Zone2[1] + 1; //Set Heart Rate Zone 3 |
asong | 2:824ed4ae8d52 | 1317 | HR_Zone3[1] = Max_Bpm * .80; //Set Heart Rate Zone 3 |
asong | 2:824ed4ae8d52 | 1318 | HR_Zone4[0] = HR_Zone3[1] + 1; //Set Heart Rate Zone 4 |
asong | 2:824ed4ae8d52 | 1319 | HR_Zone4[1] = Max_Bpm; //Set Heart Rate Zone 4 |
asong | 2:824ed4ae8d52 | 1320 | } |
asong | 2:824ed4ae8d52 | 1321 | |
asong | 2:824ed4ae8d52 | 1322 | /***************************************************************************** |
asong | 2:824ed4ae8d52 | 1323 | Name: Increment_Target_Zone |
asong | 2:824ed4ae8d52 | 1324 | Purpose: Imcrements the user's target heart rate zone preference by 1 |
asong | 2:824ed4ae8d52 | 1325 | Inputs: None |
asong | 2:824ed4ae8d52 | 1326 | Returns: None |
asong | 2:824ed4ae8d52 | 1327 | ******************************************************************************/ |
asong | 2:824ed4ae8d52 | 1328 | void Increment_Target_Zone() |
asong | 2:824ed4ae8d52 | 1329 | { |
asong | 2:824ed4ae8d52 | 1330 | StartHaptic(); |
asong | 2:824ed4ae8d52 | 1331 | if(Target_Zone == 4) { |
asong | 2:824ed4ae8d52 | 1332 | Target_Zone = 1; |
asong | 2:824ed4ae8d52 | 1333 | } else { |
asong | 2:824ed4ae8d52 | 1334 | Target_Zone += 1; |
asong | 2:824ed4ae8d52 | 1335 | } |
asong | 2:824ed4ae8d52 | 1336 | } |
asong | 2:824ed4ae8d52 | 1337 | |
asong | 2:824ed4ae8d52 | 1338 | /***************************************************************************** |
asong | 2:824ed4ae8d52 | 1339 | Name: Decrement_Target_Zone |
asong | 2:824ed4ae8d52 | 1340 | Purpose: Decrements the user's target heart rate zone preference by 1 |
asong | 2:824ed4ae8d52 | 1341 | Inputs: None |
asong | 2:824ed4ae8d52 | 1342 | Returns: None |
asong | 2:824ed4ae8d52 | 1343 | ******************************************************************************/ |
asong | 2:824ed4ae8d52 | 1344 | void Decrement_Target_Zone() |
asong | 2:824ed4ae8d52 | 1345 | { |
asong | 2:824ed4ae8d52 | 1346 | StartHaptic(); |
asong | 2:824ed4ae8d52 | 1347 | if(Target_Zone == 1) { |
asong | 2:824ed4ae8d52 | 1348 | Target_Zone = 4; |
asong | 2:824ed4ae8d52 | 1349 | } else { |
asong | 2:824ed4ae8d52 | 1350 | Target_Zone -= 1; |
asong | 2:824ed4ae8d52 | 1351 | } |
asong | 2:824ed4ae8d52 | 1352 | } |
asong | 2:824ed4ae8d52 | 1353 | |
asong | 2:824ed4ae8d52 | 1354 | /***************************************************************************** |
asong | 2:824ed4ae8d52 | 1355 | Name: Increment_HR_Vibr_Pref |
asong | 2:824ed4ae8d52 | 1356 | Purpose: Increment the user's heart rate vibration preference by 1 |
asong | 2:824ed4ae8d52 | 1357 | Inputs: None |
asong | 2:824ed4ae8d52 | 1358 | Returns: None |
asong | 2:824ed4ae8d52 | 1359 | ******************************************************************************/ |
asong | 2:824ed4ae8d52 | 1360 | void Increment_HR_Vibr_Pref() |
asong | 2:824ed4ae8d52 | 1361 | { |
asong | 2:824ed4ae8d52 | 1362 | StartHaptic(); |
asong | 2:824ed4ae8d52 | 1363 | if(HR_Vibration == 3) { |
asong | 2:824ed4ae8d52 | 1364 | HR_Vibration = 1; |
asong | 2:824ed4ae8d52 | 1365 | } else { |
asong | 2:824ed4ae8d52 | 1366 | HR_Vibration += 1; |
asong | 2:824ed4ae8d52 | 1367 | } |
asong | 2:824ed4ae8d52 | 1368 | } |
asong | 2:824ed4ae8d52 | 1369 | |
asong | 2:824ed4ae8d52 | 1370 | /***************************************************************************** |
asong | 2:824ed4ae8d52 | 1371 | Name: Decrement_HR_Vibr_Pref |
asong | 2:824ed4ae8d52 | 1372 | Purpose: Decrement the user's heart rate vibration preference by 1 |
asong | 2:824ed4ae8d52 | 1373 | Inputs: None |
asong | 2:824ed4ae8d52 | 1374 | Returns: None |
asong | 2:824ed4ae8d52 | 1375 | ******************************************************************************/ |
asong | 2:824ed4ae8d52 | 1376 | void Decrement_HR_Vibr_Pref() |
asong | 2:824ed4ae8d52 | 1377 | { |
asong | 2:824ed4ae8d52 | 1378 | StartHaptic(); |
asong | 2:824ed4ae8d52 | 1379 | if(HR_Vibration == 1) { |
asong | 2:824ed4ae8d52 | 1380 | HR_Vibration = 3; |
asong | 2:824ed4ae8d52 | 1381 | } else { |
asong | 2:824ed4ae8d52 | 1382 | HR_Vibration -= 1; |
asong | 2:824ed4ae8d52 | 1383 | } |
asong | 2:824ed4ae8d52 | 1384 | } |
asong | 2:824ed4ae8d52 | 1385 | |
asong | 2:824ed4ae8d52 | 1386 | /***************************************************************************** |
asong | 2:824ed4ae8d52 | 1387 | Name: Enable_Heart_Rate |
asong | 2:824ed4ae8d52 | 1388 | Purpose: Turn on the HexiHeart heart rate function |
asong | 2:824ed4ae8d52 | 1389 | Inputs: None |
asong | 2:824ed4ae8d52 | 1390 | Returns: None |
asong | 2:824ed4ae8d52 | 1391 | ******************************************************************************/ |
asong | 2:824ed4ae8d52 | 1392 | void Enable_Heart_Rate() |
asong | 2:824ed4ae8d52 | 1393 | { |
asong | 2:824ed4ae8d52 | 1394 | Heart_Rate_Mode = true; |
asong | 2:824ed4ae8d52 | 1395 | Heart_Rate_Vibrations(); |
asong | 2:824ed4ae8d52 | 1396 | } |
asong | 2:824ed4ae8d52 | 1397 | |
asong | 2:824ed4ae8d52 | 1398 | /***************************************************************************** |
asong | 2:824ed4ae8d52 | 1399 | Name: Disable_Heart_Rate |
asong | 2:824ed4ae8d52 | 1400 | Purpose: Turn off the HexiHeart heart rate function |
asong | 2:824ed4ae8d52 | 1401 | Inputs: None |
asong | 2:824ed4ae8d52 | 1402 | Returns: None |
asong | 2:824ed4ae8d52 | 1403 | ******************************************************************************/ |
asong | 2:824ed4ae8d52 | 1404 | void Disable_Heart_Rate() |
asong | 2:824ed4ae8d52 | 1405 | { |
asong | 2:824ed4ae8d52 | 1406 | Heart_Rate_Mode = false; |
asong | 2:824ed4ae8d52 | 1407 | Heart_Rate_Vibrations(); |
asong | 2:824ed4ae8d52 | 1408 | } |
asong | 2:824ed4ae8d52 | 1409 | |
asong | 2:824ed4ae8d52 | 1410 | /***************************************************************************** |
asong | 2:824ed4ae8d52 | 1411 | Name: Determine_Current_Zone |
asong | 2:824ed4ae8d52 | 1412 | Purpose: Determines which zone the heart rate is in and assigns the curent |
asong | 2:824ed4ae8d52 | 1413 | zone and previous zone |
asong | 2:824ed4ae8d52 | 1414 | Inputs: None |
asong | 2:824ed4ae8d52 | 1415 | Returns: None |
asong | 2:824ed4ae8d52 | 1416 | ******************************************************************************/ |
asong | 2:824ed4ae8d52 | 1417 | void Determine_Current_Zone() |
asong | 2:824ed4ae8d52 | 1418 | { |
asong | 2:824ed4ae8d52 | 1419 | Prev_Zone = Current_Zone; |
asong | 2:824ed4ae8d52 | 1420 | |
asong | 2:824ed4ae8d52 | 1421 | if(Heart_Rate >= HR_Zone1[0] && Heart_Rate <= HR_Zone1[1]) { |
asong | 2:824ed4ae8d52 | 1422 | Current_Zone = 1; |
asong | 2:824ed4ae8d52 | 1423 | } else if(Heart_Rate >= HR_Zone2[0] && Heart_Rate <= HR_Zone2[1]) { |
asong | 2:824ed4ae8d52 | 1424 | Current_Zone = 2; |
asong | 2:824ed4ae8d52 | 1425 | } else if(Heart_Rate >= HR_Zone3[0] && Heart_Rate <= HR_Zone3[1]) { |
asong | 2:824ed4ae8d52 | 1426 | Current_Zone = 3; |
asong | 2:824ed4ae8d52 | 1427 | } else if(Heart_Rate >= HR_Zone4[0] && Heart_Rate <= HR_Zone4[1]) { |
asong | 2:824ed4ae8d52 | 1428 | Current_Zone = 4; |
asong | 2:824ed4ae8d52 | 1429 | } else { |
asong | 2:824ed4ae8d52 | 1430 | //error reading, don't change anything |
asong | 2:824ed4ae8d52 | 1431 | } |
asong | 2:824ed4ae8d52 | 1432 | |
asong | 2:824ed4ae8d52 | 1433 | |
asong | 2:824ed4ae8d52 | 1434 | } |
asong | 2:824ed4ae8d52 | 1435 | /***************************************************************************** |
asong | 2:824ed4ae8d52 | 1436 | Name: Run_Heart_Vibrations |
asong | 2:824ed4ae8d52 | 1437 | Purpose: Performs the HexiHeart heart rate function |
asong | 2:824ed4ae8d52 | 1438 | Inputs: None |
asong | 2:824ed4ae8d52 | 1439 | Returns: None |
asong | 2:824ed4ae8d52 | 1440 | ******************************************************************************/ |
asong | 2:824ed4ae8d52 | 1441 | void Heart_Rate_Vibrations() |
asong | 2:824ed4ae8d52 | 1442 | { |
asong | 2:824ed4ae8d52 | 1443 | if(Heart_Rate_Mode == true) { |
asong | 2:824ed4ae8d52 | 1444 | if(HR_Vibration == 1) { |
asong | 2:824ed4ae8d52 | 1445 | //All Pre-loaded vibrations enabled |
asong | 2:824ed4ae8d52 | 1446 | if(Current_Zone == Prev_Zone) { |
asong | 2:824ed4ae8d52 | 1447 | // Do nothing if no zone change |
asong | 2:824ed4ae8d52 | 1448 | } else if(Current_Zone == Target_Zone) { //Changed to target zone |
asong | 2:824ed4ae8d52 | 1449 | if(Target_Zone == LOWEST_ZONE || Prev_Zone > Target_Zone) { //must have entered from above |
asong | 2:824ed4ae8d52 | 1450 | StartHaptic(ENTER_ABOVE); |
asong | 2:824ed4ae8d52 | 1451 | } else if(Target_Zone == HIGHEST_ZONE || Prev_Zone < Target_Zone) { //must have entered from below |
asong | 2:824ed4ae8d52 | 1452 | StartHaptic(ENTER_BELOW); |
asong | 2:824ed4ae8d52 | 1453 | } |
asong | 2:824ed4ae8d52 | 1454 | } else if(Current_Zone != Target_Zone && Prev_Zone == Target_Zone) { |
asong | 2:824ed4ae8d52 | 1455 | if(Target_Zone == HIGHEST_ZONE || Current_Zone < Target_Zone) { //must have exited below |
asong | 2:824ed4ae8d52 | 1456 | StartHaptic(EXIT_BELOW); |
asong | 2:824ed4ae8d52 | 1457 | } else if(Target_Zone == LOWEST_ZONE || Current_Zone > Target_Zone) { //must have exited above |
asong | 2:824ed4ae8d52 | 1458 | StartHaptic(EXIT_ABOVE); |
asong | 2:824ed4ae8d52 | 1459 | } |
asong | 2:824ed4ae8d52 | 1460 | } |
asong | 2:824ed4ae8d52 | 1461 | } else if(HR_Vibration == 2) { |
asong | 2:824ed4ae8d52 | 1462 | //Only Entering and Exiting target zone |
asong | 2:824ed4ae8d52 | 1463 | if(Current_Zone == Prev_Zone) { |
asong | 2:824ed4ae8d52 | 1464 | //do nothing |
asong | 2:824ed4ae8d52 | 1465 | } else if(Current_Zone == Target_Zone) { |
asong | 2:824ed4ae8d52 | 1466 | StartHaptic(VIB_OPT_2); |
asong | 2:824ed4ae8d52 | 1467 | wait(0.1); |
asong | 2:824ed4ae8d52 | 1468 | StartHaptic(VIB_OPT_2); |
asong | 2:824ed4ae8d52 | 1469 | } else if(Current_Zone != Target_Zone && Prev_Zone == Target_Zone) { |
asong | 2:824ed4ae8d52 | 1470 | StartHaptic(VIB_OPT_2); |
asong | 2:824ed4ae8d52 | 1471 | wait(0.1); |
asong | 2:824ed4ae8d52 | 1472 | StartHaptic(VIB_OPT_2); |
asong | 2:824ed4ae8d52 | 1473 | wait(0.1); |
asong | 2:824ed4ae8d52 | 1474 | StartHaptic(VIB_OPT_2); |
asong | 2:824ed4ae8d52 | 1475 | } |
asong | 2:824ed4ae8d52 | 1476 | |
asong | 2:824ed4ae8d52 | 1477 | } else if(HR_Vibration == 3) { |
asong | 2:824ed4ae8d52 | 1478 | //No Vibrations |
asong | 2:824ed4ae8d52 | 1479 | |
asong | 2:824ed4ae8d52 | 1480 | } else { |
asong | 2:824ed4ae8d52 | 1481 | //Error, can only be choices 1-3 |
asong | 2:824ed4ae8d52 | 1482 | error_screen(); |
asong | 2:824ed4ae8d52 | 1483 | } |
asong | 2:824ed4ae8d52 | 1484 | } |
asong | 2:824ed4ae8d52 | 1485 | } |
asong | 2:824ed4ae8d52 | 1486 | |
asong | 2:824ed4ae8d52 | 1487 | /***************************************************************************** |
asong | 2:824ed4ae8d52 | 1488 | Name: Increment_Heart_Rate |
asong | 2:824ed4ae8d52 | 1489 | Purpose: Manually increment the the heart rate measurement by 1 for testing |
asong | 2:824ed4ae8d52 | 1490 | purposes |
asong | 2:824ed4ae8d52 | 1491 | Inputs: None |
asong | 2:824ed4ae8d52 | 1492 | Returns: None |
asong | 2:824ed4ae8d52 | 1493 | ******************************************************************************/ |
asong | 2:824ed4ae8d52 | 1494 | void Increment_Heart_Rate() |
asong | 2:824ed4ae8d52 | 1495 | { |
asong | 2:824ed4ae8d52 | 1496 | //StartHaptic(); |
asong | 2:824ed4ae8d52 | 1497 | if(Heart_Rate == HR_Zone4[1]) { |
asong | 2:824ed4ae8d52 | 1498 | Heart_Rate = HR_Zone1[0]; |
asong | 2:824ed4ae8d52 | 1499 | } else { |
asong | 2:824ed4ae8d52 | 1500 | Heart_Rate += 1; |
asong | 2:824ed4ae8d52 | 1501 | } |
asong | 2:824ed4ae8d52 | 1502 | } |
asong | 2:824ed4ae8d52 | 1503 | |
asong | 2:824ed4ae8d52 | 1504 | /***************************************************************************** |
asong | 2:824ed4ae8d52 | 1505 | Name: Decrement_Heart_Rate |
asong | 2:824ed4ae8d52 | 1506 | Purpose: Manually decrement the the heart rate measurement by 1 for testing |
asong | 2:824ed4ae8d52 | 1507 | purposes |
asong | 2:824ed4ae8d52 | 1508 | Inputs: None |
asong | 2:824ed4ae8d52 | 1509 | Returns: None |
asong | 2:824ed4ae8d52 | 1510 | ******************************************************************************/ |
asong | 2:824ed4ae8d52 | 1511 | void Decrement_Heart_Rate() |
asong | 2:824ed4ae8d52 | 1512 | { |
asong | 2:824ed4ae8d52 | 1513 | //StartHaptic(); |
asong | 2:824ed4ae8d52 | 1514 | if(Heart_Rate == HR_Zone1[0]) { |
asong | 2:824ed4ae8d52 | 1515 | Heart_Rate = HR_Zone4[1]; |
asong | 2:824ed4ae8d52 | 1516 | } else { |
asong | 2:824ed4ae8d52 | 1517 | Heart_Rate -= 1; |
asong | 2:824ed4ae8d52 | 1518 | } |
asong | 2:824ed4ae8d52 | 1519 | } |
asong | 2:824ed4ae8d52 | 1520 | |
asong | 2:824ed4ae8d52 | 1521 | void Led_Zone_Indicator() |
asong | 2:824ed4ae8d52 | 1522 | { |
asong | 2:824ed4ae8d52 | 1523 | if(Led_Zones == true) |
asong | 2:824ed4ae8d52 | 1524 | { |
asong | 2:824ed4ae8d52 | 1525 | if(Current_Zone == 1) |
asong | 2:824ed4ae8d52 | 1526 | { |
asong | 2:824ed4ae8d52 | 1527 | BLU_Led = LED_OFF; |
asong | 2:824ed4ae8d52 | 1528 | RED_Led = LED_ON; |
asong | 2:824ed4ae8d52 | 1529 | GRN_Led = LED_ON; |
asong | 2:824ed4ae8d52 | 1530 | //wait(0.5); |
asong | 2:824ed4ae8d52 | 1531 | //RED_Led = LED_OFF; |
asong | 2:824ed4ae8d52 | 1532 | //GRN_Led = LED_OFF; |
asong | 2:824ed4ae8d52 | 1533 | } |
asong | 2:824ed4ae8d52 | 1534 | else if(Current_Zone == 2) |
asong | 2:824ed4ae8d52 | 1535 | { |
asong | 2:824ed4ae8d52 | 1536 | if(Prev_Zone == 1) |
asong | 2:824ed4ae8d52 | 1537 | { |
asong | 2:824ed4ae8d52 | 1538 | RED_Led = LED_OFF; |
asong | 2:824ed4ae8d52 | 1539 | GRN_Led = LED_OFF; |
asong | 2:824ed4ae8d52 | 1540 | } |
asong | 2:824ed4ae8d52 | 1541 | else if(Prev_Zone == 3) |
asong | 2:824ed4ae8d52 | 1542 | { |
asong | 2:824ed4ae8d52 | 1543 | GRN_Led = LED_OFF; |
asong | 2:824ed4ae8d52 | 1544 | } |
asong | 2:824ed4ae8d52 | 1545 | BLU_Led = LED_ON; |
asong | 2:824ed4ae8d52 | 1546 | //wait(0.5); |
asong | 2:824ed4ae8d52 | 1547 | //BLU_Led = LED_OFF; |
asong | 2:824ed4ae8d52 | 1548 | } |
asong | 2:824ed4ae8d52 | 1549 | else if(Current_Zone == 3) |
asong | 2:824ed4ae8d52 | 1550 | { |
asong | 2:824ed4ae8d52 | 1551 | if(Prev_Zone == 2) |
asong | 2:824ed4ae8d52 | 1552 | { |
asong | 2:824ed4ae8d52 | 1553 | BLU_Led = LED_OFF; |
asong | 2:824ed4ae8d52 | 1554 | } |
asong | 2:824ed4ae8d52 | 1555 | else if(Prev_Zone == 4) |
asong | 2:824ed4ae8d52 | 1556 | { |
asong | 2:824ed4ae8d52 | 1557 | RED_Led = LED_OFF; |
asong | 2:824ed4ae8d52 | 1558 | } |
asong | 2:824ed4ae8d52 | 1559 | GRN_Led = LED_ON; |
asong | 2:824ed4ae8d52 | 1560 | //wait(0.5); |
asong | 2:824ed4ae8d52 | 1561 | //GRN_Led = LED_OFF; |
asong | 2:824ed4ae8d52 | 1562 | } |
asong | 2:824ed4ae8d52 | 1563 | else if(Current_Zone == 4) |
asong | 2:824ed4ae8d52 | 1564 | { |
asong | 2:824ed4ae8d52 | 1565 | GRN_Led = LED_OFF; |
asong | 2:824ed4ae8d52 | 1566 | RED_Led = LED_ON; |
asong | 2:824ed4ae8d52 | 1567 | //wait(0.5); |
asong | 2:824ed4ae8d52 | 1568 | //RED_Led = LED_OFF; |
asong | 2:824ed4ae8d52 | 1569 | } |
asong | 2:824ed4ae8d52 | 1570 | } |
asong | 2:824ed4ae8d52 | 1571 | |
asong | 2:824ed4ae8d52 | 1572 | } |