The HexiHeart is a demo project product that takes advantage of many of the onboard Hexiwear sensors and capabilities to create a multifunctional fitness and safety watch.

Dependencies:   FXAS21002 FXOS8700 Hexi_KW40Z Hexi_OLED_SSD1351 MAXIM W25Q64FVSSIG HTU21D MPL3115A2 TSL2561

Fork of HexiHeart_Alex by Hexiwear_zeta

Files at this revision

API Documentation at this revision

Comitter:
nbaker
Date:
Thu Mar 29 16:55:40 2018 +0000
Parent:
11:ccda4d44bd8e
Child:
13:37cd579208e9
Commit message:
v2.11 - Added Send_Alert(0) to turn off alerts by sending amb_light=0, ; added WDT and added WDT testing screens, changed fall Min_Movement_duration from 60s to 10s, added subtle vibration after impact for diagnostic purposes.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed Mar 28 21:47:04 2018 +0000
+++ b/main.cpp	Thu Mar 29 16:55:40 2018 +0000
@@ -2,12 +2,12 @@
 HexiHeart
 Texas State University Senior Project - Fall 2017/Spring 2018 
 
-Team Zeta: 
+Team Zeta:
 Alex Song           - https://www.linkedin.com/in/alex-song-a12632134/
 Jasmine Rounsaville - https://www.linkedin.com/in/jasmine-rounsaville/
 Issam Hichami       - https://www.linkedin.com/in/issam-hichami-06878aa3/
 Neil Baker          - https://www.linkedin.com/in/neil-baker-41602a23/
-
+You can find more about Team Zeta here: https://os.mbed.com/teams/Hexiwear_zeta/
  ****** Program layout********
 Declarations
 Up Button routines
@@ -16,12 +16,16 @@
 Left Button routines 
 Main()
 Main display screen routines
-Function and interupt routines
+Function and interrupt routines
 Display data screen update routines
 
 **************   Versions  ****************
+v2.11 - Added Send_Alert(0) to turn off alerts by sending amb_light=0, 
+added WDT and added WDT testing screens, changed fall Min_Movement_duration 
+from 60s to 10s, added subtle vibration after impact for diagnostic purposes.
+
 v2.10 - Adding BLE pairing code, spoofing amb light sensor data for alert status 
-light=10 =>Panic Alert, 20=Fall+asked for help, 30=Fall+No responce, 40=?...
+light=10 =>Panic Alert, 20=Fall+asked for help, 30=Fall+No response, 40=?...
 
 v2.09 - Added final fall mode (full sequential fall algorithm), including alert screen 
 and dismiss alert screen.  Added FAP (Fall Alert Protection) to main screen. fixed "aggressive Haptic" problem by using a Ticker to 
@@ -59,18 +63,19 @@
 
 
 //***************  Definitions
-#define SW_Ver          2.10    // For displaying software version
+#define SW_Ver          2.11    // For displaying software version
 #define LED_ON          0
 #define LED_OFF         1
-#define SCRN_TIME       10.0
-#define Debug           1 // If "Debug" is defined, our code will compile for debug.  Comment out for Production code.
-#define HIGHEST_ZONE    4
+#define SCRN_TIME       10.0    // Set OLED screen turn off time to 10.0 seconds
+#define WDT_TIME        1.5     // Set Watch Dog timer to 1.5 seconds (1.0s reset in certain subroutines)
+#define Debug           1       // If "Debug" is defined, our code will compile for debug.  Comment out for Production code.
+#define HIGHEST_ZONE    4       // Highest heart rate zone
 #define LOWEST_ZONE     1
 #define ENTER_BELOW     25
 #define ENTER_ABOVE     50
 #define EXIT_BELOW      75
 #define EXIT_ABOVE      100
-#define VIB_OPT_2       75
+#define VIB_OPT_2       75      // Haptic vibration pattern option for heart rate functions
 #define FXOS8700_I2C_ADDRESS_ (0x1E<<1) //pins SA0,SA1=0 
 #define FXAS21002_I2C_ADDRESS_ 0x40      //
 //#define TSL2561_I2C_ADDRESS_  (0x29 << 1) // Address select line is grounded
@@ -145,7 +150,7 @@
 float Impact_Thresh=3.0;        // Initialize Impact detect Threshold
 float Movement_Thresh=50.0;     // Initialize Movement detect Threshold
 float Min_Movement_Time=5.0;    // Initialize Movement minimum movement time to 5 sec
-float Min_Movement_duration=60.0;    // Initialize Movement min-movement testing duration to 60 sec
+float Min_Movement_duration=10.0;    // Initialize Movement min-movement testing duration to 60 sec
 float Do_You_Need_Help_Time=10.0; // Time to dismiss "Do you need Help" screen
 uint8_t Current_Zone = 1;
 uint8_t Prev_Zone = 1;
@@ -237,8 +242,15 @@
 Ticker chk_fall; // Ticker used to check on active fall
 Ticker chk_motion; // Ticker used to check on post fall motion
 Ticker Haptic_Timer;
-Ticker WDT;
+Ticker WDT_Timer;
+
 
+/*****************************************************************************
+Name: timout_timer()
+Purpose: Used to turn the OLED screen off after 10s to save power
+Inputs: None
+Returns: None
+******************************************************************************/
 void timout_timer(){ // turn off display mode
 #ifdef Debug    // in debug keep screens on for demo  
         HexiwearBattery battery;
@@ -257,9 +269,55 @@
 #ifdef Debug    // in debug keep screens on for demo  
      } // endelse
 #endif   
-}//end routine
+}//end timout_timer routine
 
-void PassKey(void)
+/*****************************************************************************
+Name: WDT_Timeout()
+Purpose: Interrupt routine used by Watch Dog timer Ticker. 
+Note that there are a few ways to implement a WDT. The best would be an external 
+circuit that resets the K46 if it became unresponsive. The next best would be using 
+the internal WDT that is built into microprocessor. And lastly there is this 
+method, using a Ticker/timer.
+Inputs: None
+Returns: None
+******************************************************************************/
+void WDT_Timeout(){ // turn off display mode
+    Screen_Timer.attach(&timout_timer,(SCRN_TIME));//Is this sufficient to reset/restart ticker timer for OLED?
+    if (OLED_ON == 0) {
+        OLED_ON = 1; // Screen was off, set to On
+    }
+    oled_text_properties_t textProperties = {0};  // Need these to change font color
+    oled.GetTextProperties(&textProperties);      // Need these to change font color
+    oled.FillScreen(COLOR_BLACK); // Clear screen
+    textProperties.font = OpenSans_12x18_Regular;  //  Max Width of Character  = 12px, Max Height of Character = 18px 
+    textProperties.fontColor = COLOR_WHITE;
+    oled.SetTextProperties(&textProperties); 
+    oled.Label((uint8_t *)"WatchDog",10,30); // Display "Back" at x,y
+    oled.Label((uint8_t *)" Reset!",20,55); // Display "Back" at x,y
+    wait(0.1);// display for 100ms
+
+    NVIC_SystemReset(); // software reset
+}//end WDT_Timeout routine
+
+
+/*****************************************************************************
+Name: CLRWDT()
+Purpose: Routine to clear/reset Watch Dog timer Ticker
+Inputs: None
+Returns: None
+******************************************************************************/
+void CLRWDT(){ // turn off display mode
+    WDT_Timer.attach(&WDT_Timeout,(WDT_TIME));//re-attach/reset WDT
+}//end WDT_Timeout routine
+
+
+/*****************************************************************************
+Name: PassKey()
+Purpose: Interrupt routine called when MK46 recieves Passkey from KW40
+Inputs: None
+Returns: None
+******************************************************************************/
+void PassKey(void)// 
 {
     Screen_Timer.attach(&timout_timer,(SCRN_TIME));//Is this sufficient to reset/restart ticker timer for OLED?
     if (OLED_ON == 0) {
@@ -270,6 +328,12 @@
         update_display();
 }// PassKey
 
+/*****************************************************************************
+Name: ButtonUp()
+Purpose: Routine called when MK46 recieves a ButtonUP interrupt from KW40
+Inputs: Uses global Screen_Num value and other status varibles
+Returns: None
+******************************************************************************/
 void ButtonUp(void)
 {
     Screen_Timer.attach(&timout_timer,(SCRN_TIME));//Is this sufficient to reset/restart ticker timer for OLED?
@@ -312,7 +376,7 @@
             }
             case 5: {// About HexiHeart
                 StartHaptic();
-                Screen_Num = 4; //Change to screen 4
+                Screen_Num = 3; //Change to screen 3, skip 4
                 update_display();
                 break;
             }
@@ -322,6 +386,9 @@
                 if(Panic_Alert == 1){
                 Send_Alert(10); // send/store alert type zero
                 }//endif
+                else{
+                 Send_Alert(0);   
+                    }
                 update_display();
                 break;
             }
@@ -366,7 +433,7 @@
             }
             case 21: {// Fall Diagnostic
                 StartHaptic();
-                Screen_Num = 25;  //Change to screen 25
+                Screen_Num = 49;  //Change to screen 49
                 update_display();
                 break;
             }
@@ -488,7 +555,12 @@
                 update_display();
                 break;
             }      
-            
+            case 49: {// WDT debug test screen
+                StartHaptic();
+                Screen_Num = 25;  //Change to screen 25
+                update_display();
+                break;
+            }
             case 71: {// BLE
                 StartHaptic();
                 Screen_Num = 1; //Change to screen 1
@@ -502,11 +574,17 @@
             default: {
                 break;
             }
-        }
-    }
+        }// end case switch
+    }// end if
+}// end ButtonUp
+
 
-}
-
+/*****************************************************************************
+Name: ButtonDown()
+Purpose: Routine called when MK46 recieves a ButtonDown interrupt from KW40
+Inputs: Uses global Screen_Num value and other status varibles
+Returns: None
+******************************************************************************/
 void ButtonDown(void)
 {
     Screen_Timer.attach(&timout_timer,(SCRN_TIME));//Is this sufficient to reset/restart ticker timer for OLED?
@@ -534,7 +612,7 @@
             }
             case 3: {// Heart Rate Monitoring option
                 StartHaptic();
-                Screen_Num = 4;  //Change to screen 4
+                Screen_Num = 5;  //Change to screen 5, skip 4
                 update_display();
                 break;
             }
@@ -617,7 +695,7 @@
             }
             case 25: {// Heat Index Diagnostic
                 StartHaptic();
-                Screen_Num = 21;  //Change to screen 21
+                Screen_Num = 49;  //Change to screen 49
                 update_display();
                 break;
             }
@@ -723,7 +801,12 @@
                 update_display();
                 break;
             }
-
+            case 49: {// WDT diagnostic test screen
+                StartHaptic();
+                Screen_Num = 21;  //Change to screen 21
+                update_display();
+                break;
+            }
             case 71: {// BLE
                 StartHaptic();
                 Screen_Num = 2; //Change to screen 2
@@ -738,10 +821,17 @@
             default: {
                 break;
             }
-        }
-    }
-}
+        }//end case switch
+    }//end if
+}// end ButtonDown()
+
 
+/*****************************************************************************
+Name: ButtonRight()
+Purpose: Routine called when MK46 recieves a ButtonRight interrupt from KW40
+Inputs: Uses global Screen_Num value and other status varibles
+Returns: None
+******************************************************************************/
 void ButtonRight(void)
 {
     Screen_Timer.attach(&timout_timer,(SCRN_TIME));//Is this sufficient to reset/restart ticker timer for OLED?
@@ -895,11 +985,17 @@
             }         
             case 47: {// Fall-Detected screen "are you ok?"
                 StartHaptic();
-                Send_Alert(20); // send/store alert type one
+                Send_Alert(20); // send/store alert type 20
                 Screen_Num = 48;  //Change to screen 48 (send alert screen)
                 update_display();
                 break;
             }     
+            case 49: {// start WDT test
+                StartHaptic();
+                Screen_Num = 50;  //Change to screen 50
+                update_display();
+                break;
+            }     
              case 71: {// BLE
                 StartHaptic();
                 Screen_Num = 72;  //Change to screen 72
@@ -917,10 +1013,17 @@
             default: {
                 break;
             }
-        }
-    }
-}
+        }//end case switch
+    }//end if
+}//end ButtonRight
+
 
+/*****************************************************************************
+Name: ButtonLeft()
+Purpose: Routine called when MK46 recieves a ButtonLeft interrupt from KW40
+Inputs: Uses global Screen_Num value and other status varibles
+Returns: None
+******************************************************************************/
 void ButtonLeft(void)
 {
     Screen_Timer.attach(&timout_timer,(SCRN_TIME));//Is this sufficient to reset/restart ticker timer for OLED?
@@ -1126,6 +1229,7 @@
                 Led_clk1 = 0;  // Turn off LED1, on docking station
                 Led_clk2 = 0;  // Turn off LED2, on docking station
                 // stop/dismiss alert
+                Send_Alert(0);
                 Screen_Num = 0;  //Change to screen 0
                 update_display();
                 break;
@@ -1148,11 +1252,17 @@
             default: {
                 break;
             }
-        }
-    }
-}
+        }// end case switch
+    }// end if
+}// end ButtonLeft
 
-
+/*****************************************************************************
+Name: ButtonSlide()
+Purpose: Routine called when MK46 recieves a ButtonSlide interrupt from KW40, which
+we never get.
+Inputs: None
+Returns: None
+******************************************************************************/
 void ButtonSlide(void)  // What is this Slide button???
 {
     Screen_Timer.attach(&timout_timer,(SCRN_TIME));//Is this sufficient to reset/restart ticker timer for OLED?
@@ -1163,7 +1273,7 @@
     oled.FillScreen(COLOR_BLACK); // Clear screen
     strcpy((char *) text_1,"Slide Button");
     oled.Label((uint8_t *)text_1,0,40);
-}
+}// end ButtonSlide
 
 int main()
 {
@@ -1251,20 +1361,27 @@
     wait(0.5);  // wait 3 seconds
 */
     oled.FillScreen(COLOR_BLACK); // Clear screen
-    oled.Label((uint8_t *)"Hexi",20,5); // Display white "Hexi" at x,y
+    
+    textProperties.font = OpenSans_12x18_Regular;  //  Max Width of Character  = 12px, Max Height of Character = 18px 
+    oled.SetTextProperties(&textProperties); 
+    oled.Label((uint8_t *)"Hexi",18,5); // Display white "Hexi" at x,y
     textProperties.fontColor = COLOR_RED;
     oled.SetTextProperties(&textProperties);
-    oled.Label((uint8_t *)"Heart",45,5); // Display red "Heart" at x,y
+    oled.Label((uint8_t *)"Heart",47,5); // Display red "Heart" at x,y
+    textProperties.font = OpenSans_10x15_Regular;  //  Max Width of Character  = 10px, Max Height of Character = 15px 
+    oled.SetTextProperties(&textProperties);
 
-#ifdef Debug  // if this is non-production version - do this
-    strcpy((char *) text_1,"This is Debug");
-    oled.Label((uint8_t *)text_1,15,45);  // text_1 at x,y
-    strcpy((char *) text_1,"Ver:");
-    oled.Label((uint8_t *)text_1,15,60);  // text_1 at x,y
+    strcpy((char *) text_1,"This is a");
+    oled.Label((uint8_t *)text_1,19,25);  // text_1 at x,y
+    strcpy((char *) text_1,"Demo Proj");
+    oled.Label((uint8_t *)text_1,15,40);  // text_1 at x,y
+    strcpy((char *) text_1,"SW_Ver:");
+    oled.Label((uint8_t *)text_1,10,70);  // text_1 at x,y
+    textProperties.fontColor = COLOR_MAGENTA;
+    oled.SetTextProperties(&textProperties);
     sprintf(text_1,"%2.2f  ",SW_Ver);
-    oled.Label((uint8_t *)text_1,60,60);// text_1 at x,y
+    oled.Label((uint8_t *)text_1,60,70);// text_1 at x,y
     StartHaptic(); 
-    #endif
     
     textProperties.fontColor = COLOR_WHITE;
     oled.SetTextProperties(&textProperties);
@@ -1273,21 +1390,21 @@
    // txThread.start(txTask); /*Start transmitting Sensor Tag Data */
     
     update_display(); // Displays current screen (screen 0)
-    Screen_Timer.attach(&timout_timer,(SCRN_TIME));//start ticker timer for turning off LCD
+    Screen_Timer.attach(&timout_timer,(SCRN_TIME)); //start ticker timer for turning off LCD
+    WDT_Timer.attach(&WDT_Timeout,(WDT_TIME));      //attach/start WDT
 //  ******************* Main Loop *************************
     while (true) {
             i=0;
     while (i<20)// used for "Heart beat flash and updated any displayed data)
     {
     Thread::wait(500);          // wait 0.5 sec each loop
+    CLRWDT();
     if(OLED_PWR==1){
     update_display_date();     // refresh display date w/o updating entire display 
         }// end if
           
     i++;
     }// end while(i<20)
-        
-//    wait(10);          // wait 10 sec each loop, was orig half sec
     RED_Led = LED_ON;    // Used only for diagnostic of wait command
     Led_clk3 = 1;         // Used only for diagnostic of wait command
     wait(0.01);          // BLIP led 1/10 sec each loop
@@ -1295,7 +1412,7 @@
     RED_Led = LED_OFF;    // Used only for diagnostic of wait command
     Led_clk3 = 0; 
     Thread::wait(490);    // keep up the pace, at 0.5 sec (0.01s+0.49s) update date 
-    
+    CLRWDT();
     } // end of while(true)
 
 }
@@ -1390,7 +1507,7 @@
         }
         case 1: {// Panic Alert option
             oled.FillScreen(COLOR_BLACK); // Clear screen
-            oled.Label((uint8_t *)"Panic Alert",20,5); // Display at x,y
+            oled.Label((uint8_t *)"Panic Alert",18,5); // Display at x,y
             oled.Label((uint8_t *)"*",85,15); // "*" at x,y
             oled.Label((uint8_t *)"*",85,60); // "*" at x,y
             oled.Label((uint8_t *)"Back",10,80); // Display "Back" at x,y
@@ -1424,7 +1541,7 @@
         }
         case 3: {// Heart Rate Monitoring option
             oled.FillScreen(COLOR_BLACK); // Clear screen
-            oled.Label((uint8_t *)"Heart Rate",20,5); // Display at x,y
+            oled.Label((uint8_t *)"Heart Rate",18,5); // Display at x,y
             oled.Label((uint8_t *)"*",85,15); // "*" at x,y
             oled.Label((uint8_t *)"*",85,60); // "*" at x,y
             oled.Label((uint8_t *)"Back",10,80); // Display "Back" at x,y
@@ -1473,7 +1590,7 @@
         case 7: {// Heart Rate Zone
 
             oled.FillScreen(COLOR_BLACK); // Clear screen
-            oled.Label((uint8_t *)"Heart Rate",15,5); // Display at x,y
+            oled.Label((uint8_t *)"Heart Rate",18,5); // Display at x,y
             oled.Label((uint8_t *)"HR:",15,25); // Display at x,y
             sprintf(display_buff, "%u", Heart_Rate);
             textProperties.fontColor = COLOR_RED; //Change font to red
@@ -1521,8 +1638,8 @@
                     oled.Label((uint8_t *)"Senior Proj",5,15); //
                     oled.Label((uint8_t *)"Team Zeta E2.7",5,30); //
                     oled.Label((uint8_t *)"Texas State Univ",0,45); //        
-                    oled.Label((uint8_t *)"+",85,15); // "*" at x,y
-                    oled.Label((uint8_t *)"-",85,60); // "*" at x,y
+                    oled.Label((uint8_t *)"*",85,15); // "*" at x,y
+                    oled.Label((uint8_t *)"*",85,60); // "*" at x,y
                     oled.Label((uint8_t *)"Back",10,80); // Display "Back" at x,y                  
                         break;
                 }
@@ -1542,37 +1659,38 @@
                     oled.Label((uint8_t *)"Issam Hichami",5,51); // 
                     oled.Label((uint8_t *)"Neil Baker",5,64); //           
 
-                    oled.Label((uint8_t *)"+",85,15); // "*" at x,y
-                    oled.Label((uint8_t *)"-",85,60); // "*" at x,y
+                    oled.Label((uint8_t *)"*",85,15); // "*" at x,y
+                    oled.Label((uint8_t *)"*",85,60); // "*" at x,y
                     oled.Label((uint8_t *)"Back",10,80); // Display "Back" at x,y                  
                         break;
                 }
                     
             case 11: {// About HexiHeart info3
                     oled.FillScreen(COLOR_BLACK); // Clear screen
-                    oled.Label((uint8_t *)"Hexi",20,0); // Display white "Hexi" at x,y
+                    
+                    textProperties.font = OpenSans_12x18_Regular;  //  Max Width of Character  = 12px, Max Height of Character = 18px 
+                    oled.SetTextProperties(&textProperties); 
+                    oled.Label((uint8_t *)"Hexi",17,5); // Display white "Hexi" at x,y
                     textProperties.fontColor = COLOR_RED;
-                    oled.SetTextProperties(&textProperties);  
-                    oled.Label((uint8_t *)"Heart",45,0); // Display red "Heart" at x,y  
-                // *********get screen alignment  **************
-                    oled_text_properties_t textProperties = {0};
-                    oled.GetTextProperties(&textProperties); 
-                // *********Set text color and screen alignment  **************
-                    textProperties.alignParam = OLED_TEXT_ALIGN_CENTER;
-                    oled.SetTextProperties(&textProperties);   
-  
-                    #ifdef Debug  // if this is non-production version - do this
-                        oled.Label((uint8_t *)"This is Debug",0,25);  // text_1 at X=10,y=25
-                        oled.Label((uint8_t *)"Ver of SW",0,40);  // text_1 at x=20,y=40
-                    #endif
+                    oled.SetTextProperties(&textProperties);
+                    oled.Label((uint8_t *)"Heart",46,5); // Display red "Heart" at x,y
+                    textProperties.font = OpenSans_10x15_Regular;  //  Max Width of Character  = 10px, Max Height of Character = 15px 
+                    oled.SetTextProperties(&textProperties);
+
+                    strcpy((char *) text_1,"This is a");
+                    oled.Label((uint8_t *)text_1,19,25);  // text_1 at x,y
+                    strcpy((char *) text_1,"Demo Proj");
+                    oled.Label((uint8_t *)text_1,15,40);  // text_1 at x,y
+                    strcpy((char *) text_1,"SW_Ver:");
+                    oled.Label((uint8_t *)text_1,10,65);  // text_1 at x,y
+                    textProperties.fontColor = COLOR_MAGENTA;
+                    oled.SetTextProperties(&textProperties);
+                    sprintf(text_1,"%2.2f  ",SW_Ver);
+                    oled.Label((uint8_t *)text_1,60,65);// text_1 at x,y
                     textProperties.fontColor = COLOR_WHITE;
-                    oled.SetTextProperties(&textProperties);  
-                    sprintf(text_1," SW_Ver:%2.2f  ",SW_Ver);
-                    oled.Label((uint8_t *)text_1,0,55);// text_1 at x=10,y
-                    textProperties.alignParam = OLED_TEXT_ALIGN_LEFT;
-                    oled.SetTextProperties(&textProperties);  
-                    oled.Label((uint8_t *)"+",85,15); // "*" at x,y
-                    oled.Label((uint8_t *)"-",85,60); // "*" at x,y
+                    oled.SetTextProperties(&textProperties);                
+                    oled.Label((uint8_t *)"*",85,15); // "*" at x,y
+                    oled.Label((uint8_t *)"*",85,60); // "*" at x,y
                     oled.Label((uint8_t *)"Back",10,80); // Display "Back" at x,y                  
                         break;
                 }       
@@ -1582,7 +1700,7 @@
             oled.FillScreen(COLOR_BLACK); // Clear screen
             textProperties.fontColor = COLOR_RED;
             oled.SetTextProperties(&textProperties);
-            oled.Label((uint8_t *)"Diagnostics",10,5); // Display at x,y
+            oled.Label((uint8_t *)"Diagnostics",18,5); // Display at x,y
             oled.Label((uint8_t *)"Enter",60,80);  //Display at x,y
             textProperties.fontColor = COLOR_WHITE;
             oled.SetTextProperties(&textProperties);
@@ -1754,7 +1872,7 @@
         }
         case 26: {//Heart Rate Config Option
             oled.FillScreen(COLOR_BLACK); // Clear screen
-            oled.Label((uint8_t *)"HR Config",10,5); // Display at x,y
+            oled.Label((uint8_t *)"HR Config",18,5); // Display at x,y
             oled.Label((uint8_t *)"*",85,15); // "*" at x,y
             oled.Label((uint8_t *)"*",85,60); // "*" at x,y
             oled.Label((uint8_t *)"Back",10,80); // Display "Back" at x,y
@@ -2150,6 +2268,46 @@
             oled.SetTextProperties(&textProperties);
             break;
         }//end case 48
+        
+        case 49: { //Testing WDT diagnostic screen
+            oled.FillScreen(COLOR_BLACK); // Clear screen
+            textProperties.fontColor = COLOR_RED;
+            oled.SetTextProperties(&textProperties);
+            oled.Label((uint8_t *)"WDT Test",15,5); // Display at x,y
+            textProperties.fontColor = COLOR_WHITE;
+            oled.SetTextProperties(&textProperties);        
+            oled.Label((uint8_t *)"This will",16,25); // Display at x,y
+            oled.Label((uint8_t *)"Cause a",17,40); // Display at x,y
+            oled.Label((uint8_t *)"SW Reset",15,55); // Display at x,y
+            
+            oled.Label((uint8_t *)"*",85,15); // "*" at x,y
+            oled.Label((uint8_t *)"*",85,60); // "*" at x,y
+            oled.Label((uint8_t *)"Back",10,80); // Display "Back" at x,y
+            oled.Label((uint8_t *)"Enter",60,80);  //Display at x,y
+            break;
+        }//end case 49
+        
+        case 50: { //WDT timeout screen
+            CLRWDT();
+            oled.FillScreen(COLOR_BLACK); // Clear screen
+            textProperties.fontColor = COLOR_RED;
+            oled.SetTextProperties(&textProperties);
+            oled.Label((uint8_t *)"WDT Test",15,5); // Display at x,y
+            textProperties.fontColor = COLOR_WHITE;
+            oled.SetTextProperties(&textProperties);        
+            oled.Label((uint8_t *)"Reset in",17,25); // Display at x,y
+            
+            sprintf(display_buff, "%2.1f Sec", WDT_TIME); //Convert int to char array for displaying mode
+            oled.Label((uint8_t *)display_buff,18,40); // Display at x,y
+            
+            //oled.Label((uint8_t *)"*",85,15); // "*" at x,y
+            //oled.Label((uint8_t *)"*",85,60); // "*" at x,y
+            //oled.Label((uint8_t *)"Back",10,80); // Display "Back" at x,y
+            //oled.Label((uint8_t *)"Enter",60,80);  //Display at x,y
+            haptic = 0;
+            wait(WDT_TIME+1.0);
+            break;
+        }//end case 50
 
 #endif  // end of non-production/debug version code
 
@@ -2157,7 +2315,7 @@
             oled.FillScreen(COLOR_BLACK); // Clear screen
             textProperties.fontColor = COLOR_BLUE;
             oled.SetTextProperties(&textProperties);
-            oled.Label((uint8_t *)"BLUETOOTH",10,5); // Display at x,y
+            oled.Label((uint8_t *)"BLUETOOTH",15,5); // Display at x,y
             textProperties.fontColor = COLOR_WHITE;
             oled.SetTextProperties(&textProperties);
             oled.Label((uint8_t *)"Enter",60,80);  //Display at x,y
@@ -2843,8 +3001,11 @@
  }  // endif    
     Accel_Mag = 2*sqrt(((Accel_Data_Event[0]*Accel_Data_Event[0])+(Accel_Data_Event[1]*Accel_Data_Event[1])+(Accel_Data_Event[2]*Accel_Data_Event[2])));
     if(Accel_Mag>Fall_Event_Data[2]){
-        Fall_Event_Data[2] = Accel_Mag; // if impact accel is higher than last measured, update
+        Fall_Event_Data[2] = Accel_Mag; // if impact accel is higher than last measured, update   
     }//endif
+    haptic = 1;// vibrate a little
+    wait_ms(50);
+    haptic = 0;
     //wait(0.1);
     //Led_clk3 = 1;  // Turn on LED3, on docking station  - we're looking for motion  
 }//end impact_detect interupt routine
@@ -2883,16 +3044,18 @@
          }  // endif 
         update_display(); //
         chk_motion.attach(&chk_help_needed,(Do_You_Need_Help_Time)); //initialize ticker to send automatic alert 
+        CLRWDT();
         haptic = 1;
-        wait(0.2);// very aggressive hapic
+        wait(0.2);// aggressive hapic
         haptic = 0;
         wait(0.2);
         haptic = 1;
-        wait(0.2);// very aggressive hapic
+        wait(0.2);// aggressive hapic
+        CLRWDT();
         haptic = 0;
         wait(0.2);
         haptic = 1;
-        wait(0.2);// very aggressive hapic
+        wait(0.2);// aggressive hapic
         haptic = 0;
         
     }//end of chkmotion ticker interupt routine
@@ -2917,19 +3080,22 @@
         oled.GetTextProperties(&textProperties);
         textProperties.fontColor = COLOR_RED;
         oled.SetTextProperties(&textProperties);
-        oled.Label((uint8_t *)"No responce!", 5, 20);
+        oled.Label((uint8_t *)"No response!", 5, 20);
         textProperties.fontColor = COLOR_WHITE;
         oled.SetTextProperties(&textProperties);
-        Send_Alert(30); // send alert type two     
+        Send_Alert(30); // send alert type two 
+        CLRWDT();    
         haptic = 1;
         wait(0.5);// very aggressive hapic
         haptic = 0;
         wait(0.2);
         haptic = 1;
+        CLRWDT();
         wait(0.5);// very aggressive hapic
         haptic = 0;
         wait(0.2);
         haptic = 1;
+        CLRWDT();
         wait(0.5);// very aggressive hapic
         haptic = 0;
     }  // endif   
@@ -2941,7 +3107,7 @@
 Name: Send_Alert()
 Purpose: routine used to store and send alert
 Inputs: int value from 0 to 256
-10=Panic, 20=Fall+asked for help, 30=Fall+No responce, 40=?...
+10=Panic, 20=Fall+asked for help, 30=Fall+No response, 40=?...
 Returns: None
 ******************************************************************************/
 void Send_Alert(uint8_t Num){
@@ -2954,7 +3120,7 @@
         kw40z_device.SendSetApplicationMode(GUI_CURRENT_APP_SENSOR_TAG);
                
         /*Send Ambient Light Level at with aler number */ 
-        //10=Panic, 20=Fall+asked for help, 30=Fall+No responce, 40=?...
+        //10=Panic, 20=Fall+asked for help, 30=Fall+No response, 40=?...
         kw40z_device.SendAmbientLight(Num);
     
     }//end Send_Alert routine