Here

Dependencies:   Hexi_KW40Z Hexi_OLED_SSD1351 nRF24L01 FXOS8700

Committer:
DeanBritt
Date:
Mon Mar 06 17:51:09 2017 +0000
Revision:
1:ee1a74958b09
Parent:
0:6384ad26fe6c
Child:
2:172492c41c48
added picture for safe elder screen

Who changed what in which revision?

UserRevisionLine numberNew contents of line
group-Hexiwear-Alert-System 0:6384ad26fe6c 1 #include "mbed.h"
group-Hexiwear-Alert-System 0:6384ad26fe6c 2 #include "Hexi_KW40Z.h"
group-Hexiwear-Alert-System 0:6384ad26fe6c 3 #include "Hexi_OLED_SSD1351.h"
group-Hexiwear-Alert-System 0:6384ad26fe6c 4 #include "OLED_types.h"
group-Hexiwear-Alert-System 0:6384ad26fe6c 5 #include "OpenSans_Font.h"
group-Hexiwear-Alert-System 0:6384ad26fe6c 6 #include "nRF24L01P.h"
group-Hexiwear-Alert-System 0:6384ad26fe6c 7 #include "string.h"
group-Hexiwear-Alert-System 0:6384ad26fe6c 8 #include "images.h"
group-Hexiwear-Alert-System 0:6384ad26fe6c 9
group-Hexiwear-Alert-System 0:6384ad26fe6c 10 #define NAME "RB"
group-Hexiwear-Alert-System 0:6384ad26fe6c 11
group-Hexiwear-Alert-System 0:6384ad26fe6c 12 #define LED_ON 0
group-Hexiwear-Alert-System 0:6384ad26fe6c 13 #define LED_OFF 1
group-Hexiwear-Alert-System 0:6384ad26fe6c 14 #define NUM_OF_SCREENS 6
group-Hexiwear-Alert-System 0:6384ad26fe6c 15 #define TRANSFER_SIZE 4
group-Hexiwear-Alert-System 0:6384ad26fe6c 16
group-Hexiwear-Alert-System 0:6384ad26fe6c 17 void StartHaptic(void);
group-Hexiwear-Alert-System 0:6384ad26fe6c 18 void StopHaptic(void const *n);
group-Hexiwear-Alert-System 0:6384ad26fe6c 19 void txTask(void);
group-Hexiwear-Alert-System 0:6384ad26fe6c 20
group-Hexiwear-Alert-System 0:6384ad26fe6c 21 void displayHome();
group-Hexiwear-Alert-System 0:6384ad26fe6c 22 void screenHandler(uint8_t stageNum,uint8_t header);
group-Hexiwear-Alert-System 0:6384ad26fe6c 23
group-Hexiwear-Alert-System 0:6384ad26fe6c 24 DigitalOut redLed(LED1,1);
group-Hexiwear-Alert-System 0:6384ad26fe6c 25 DigitalOut greenLed(LED2,1);
group-Hexiwear-Alert-System 0:6384ad26fe6c 26 DigitalOut blueLed(LED3,1);
group-Hexiwear-Alert-System 0:6384ad26fe6c 27 DigitalOut haptic(PTB9);
group-Hexiwear-Alert-System 0:6384ad26fe6c 28
group-Hexiwear-Alert-System 0:6384ad26fe6c 29 /* Define timer for haptic feedback */
group-Hexiwear-Alert-System 0:6384ad26fe6c 30 RtosTimer hapticTimer(StopHaptic, osTimerOnce);
group-Hexiwear-Alert-System 0:6384ad26fe6c 31
group-Hexiwear-Alert-System 0:6384ad26fe6c 32 /* Instantiate the Hexi KW40Z Driver (UART TX, UART RX) */
group-Hexiwear-Alert-System 0:6384ad26fe6c 33 KW40Z kw40z_device(PTE24, PTE25);
group-Hexiwear-Alert-System 0:6384ad26fe6c 34
group-Hexiwear-Alert-System 0:6384ad26fe6c 35 /* Instantiate the SSD1351 OLED Driver */
group-Hexiwear-Alert-System 0:6384ad26fe6c 36 SSD1351 oled(PTB22,PTB21,PTC13,PTB20,PTE6, PTD15); /* (MOSI,SCLK,POWER,CS,RST,DC) */
group-Hexiwear-Alert-System 0:6384ad26fe6c 37 oled_text_properties_t textProperties = {0};
group-Hexiwear-Alert-System 0:6384ad26fe6c 38
group-Hexiwear-Alert-System 0:6384ad26fe6c 39 /* Instantiate the nRF24L01P Driver */
group-Hexiwear-Alert-System 0:6384ad26fe6c 40 nRF24L01P my_nrf24l01p(PTC6,PTC7,PTC5,PTC4,PTB2,NC); // mosi, miso, sck, csn, ce, irq
group-Hexiwear-Alert-System 0:6384ad26fe6c 41
group-Hexiwear-Alert-System 0:6384ad26fe6c 42 /* Text Buffer */
group-Hexiwear-Alert-System 0:6384ad26fe6c 43 char text[20];
group-Hexiwear-Alert-System 0:6384ad26fe6c 44
group-Hexiwear-Alert-System 0:6384ad26fe6c 45 uint8_t screenNum=0;
group-Hexiwear-Alert-System 0:6384ad26fe6c 46 bool prefix=0;
group-Hexiwear-Alert-System 0:6384ad26fe6c 47 bool sentMessageDisplayedFlag=0;
group-Hexiwear-Alert-System 0:6384ad26fe6c 48 char rxData[TRANSFER_SIZE];
group-Hexiwear-Alert-System 0:6384ad26fe6c 49 char txData[TRANSFER_SIZE];
group-Hexiwear-Alert-System 0:6384ad26fe6c 50
group-Hexiwear-Alert-System 0:6384ad26fe6c 51 /* Pointer for the image to be displayed */
DeanBritt 1:ee1a74958b09 52 const uint8_t *safeBMP = fallbutton_bmp;
DeanBritt 1:ee1a74958b09 53 const uint8_t *heartrateBMP = heartrate_bmp;
DeanBritt 1:ee1a74958b09 54 const uint8_t *safeelderBMP = safeelder_bmp;
group-Hexiwear-Alert-System 0:6384ad26fe6c 55
group-Hexiwear-Alert-System 0:6384ad26fe6c 56 /****************************Call Back Functions*******************************/
group-Hexiwear-Alert-System 0:6384ad26fe6c 57 /*Send Button */
group-Hexiwear-Alert-System 0:6384ad26fe6c 58 void ButtonRight(void)
group-Hexiwear-Alert-System 0:6384ad26fe6c 59 {
group-Hexiwear-Alert-System 0:6384ad26fe6c 60 if (!sentMessageDisplayedFlag)
group-Hexiwear-Alert-System 0:6384ad26fe6c 61 {
group-Hexiwear-Alert-System 0:6384ad26fe6c 62 StartHaptic();
group-Hexiwear-Alert-System 0:6384ad26fe6c 63
group-Hexiwear-Alert-System 0:6384ad26fe6c 64 // Send the transmitbuffer via the nRF24L01+
group-Hexiwear-Alert-System 0:6384ad26fe6c 65 my_nrf24l01p.write( NRF24L01P_PIPE_P0, txData, 4 );
group-Hexiwear-Alert-System 0:6384ad26fe6c 66 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 67 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 68
group-Hexiwear-Alert-System 0:6384ad26fe6c 69 /*Home Button */
group-Hexiwear-Alert-System 0:6384ad26fe6c 70 void ButtonLeft(void)
group-Hexiwear-Alert-System 0:6384ad26fe6c 71 {
group-Hexiwear-Alert-System 0:6384ad26fe6c 72 StartHaptic();
group-Hexiwear-Alert-System 0:6384ad26fe6c 73 screenNum = 0;
group-Hexiwear-Alert-System 0:6384ad26fe6c 74
group-Hexiwear-Alert-System 0:6384ad26fe6c 75 /*Turn off Green LED */
group-Hexiwear-Alert-System 0:6384ad26fe6c 76 sentMessageDisplayedFlag=0;
group-Hexiwear-Alert-System 0:6384ad26fe6c 77 greenLed = !sentMessageDisplayedFlag;
group-Hexiwear-Alert-System 0:6384ad26fe6c 78
group-Hexiwear-Alert-System 0:6384ad26fe6c 79 /*Redraw Send Button*/
DeanBritt 1:ee1a74958b09 80 oled.DrawImage(heartrateBMP,53,81);
group-Hexiwear-Alert-System 0:6384ad26fe6c 81 screenHandler(screenNum,prefix);
group-Hexiwear-Alert-System 0:6384ad26fe6c 82 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 83
group-Hexiwear-Alert-System 0:6384ad26fe6c 84 /*Toggles Between I am @ and Meet @ */
group-Hexiwear-Alert-System 0:6384ad26fe6c 85 void ButtonUp(void)
group-Hexiwear-Alert-System 0:6384ad26fe6c 86 {
group-Hexiwear-Alert-System 0:6384ad26fe6c 87 if (screenNum !=0)
group-Hexiwear-Alert-System 0:6384ad26fe6c 88 {
group-Hexiwear-Alert-System 0:6384ad26fe6c 89 StartHaptic();
group-Hexiwear-Alert-System 0:6384ad26fe6c 90
group-Hexiwear-Alert-System 0:6384ad26fe6c 91 /*Turn off Green LED */
group-Hexiwear-Alert-System 0:6384ad26fe6c 92 sentMessageDisplayedFlag=0;
group-Hexiwear-Alert-System 0:6384ad26fe6c 93 greenLed = !sentMessageDisplayedFlag;
group-Hexiwear-Alert-System 0:6384ad26fe6c 94
group-Hexiwear-Alert-System 0:6384ad26fe6c 95 /*Redraw Send Button*/
DeanBritt 1:ee1a74958b09 96 oled.DrawImage(heartrateBMP,53,81);
group-Hexiwear-Alert-System 0:6384ad26fe6c 97
group-Hexiwear-Alert-System 0:6384ad26fe6c 98 prefix = !prefix;
group-Hexiwear-Alert-System 0:6384ad26fe6c 99 screenHandler(screenNum,prefix);
group-Hexiwear-Alert-System 0:6384ad26fe6c 100 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 101 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 102
group-Hexiwear-Alert-System 0:6384ad26fe6c 103 /*Advances Stage Number */
group-Hexiwear-Alert-System 0:6384ad26fe6c 104 void ButtonDown(void)
group-Hexiwear-Alert-System 0:6384ad26fe6c 105 {
group-Hexiwear-Alert-System 0:6384ad26fe6c 106 StartHaptic();
group-Hexiwear-Alert-System 0:6384ad26fe6c 107
group-Hexiwear-Alert-System 0:6384ad26fe6c 108 /*Turn off Green LED */
group-Hexiwear-Alert-System 0:6384ad26fe6c 109 sentMessageDisplayedFlag=0;
group-Hexiwear-Alert-System 0:6384ad26fe6c 110 greenLed = !sentMessageDisplayedFlag;
group-Hexiwear-Alert-System 0:6384ad26fe6c 111
group-Hexiwear-Alert-System 0:6384ad26fe6c 112 /*Redraw Send Button*/
DeanBritt 1:ee1a74958b09 113 oled.DrawImage(heartrateBMP,53,81);
group-Hexiwear-Alert-System 0:6384ad26fe6c 114
group-Hexiwear-Alert-System 0:6384ad26fe6c 115 if (screenNum < NUM_OF_SCREENS -1) {
group-Hexiwear-Alert-System 0:6384ad26fe6c 116 screenNum++;
group-Hexiwear-Alert-System 0:6384ad26fe6c 117 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 118 else
group-Hexiwear-Alert-System 0:6384ad26fe6c 119 {
group-Hexiwear-Alert-System 0:6384ad26fe6c 120 screenNum = 0;
group-Hexiwear-Alert-System 0:6384ad26fe6c 121 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 122
group-Hexiwear-Alert-System 0:6384ad26fe6c 123 screenHandler(screenNum,prefix);
group-Hexiwear-Alert-System 0:6384ad26fe6c 124 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 125
group-Hexiwear-Alert-System 0:6384ad26fe6c 126
group-Hexiwear-Alert-System 0:6384ad26fe6c 127 /***********************End of Call Back Functions*****************************/
group-Hexiwear-Alert-System 0:6384ad26fe6c 128
group-Hexiwear-Alert-System 0:6384ad26fe6c 129 /********************************Main******************************************/
group-Hexiwear-Alert-System 0:6384ad26fe6c 130
group-Hexiwear-Alert-System 0:6384ad26fe6c 131 int main()
group-Hexiwear-Alert-System 0:6384ad26fe6c 132 {
group-Hexiwear-Alert-System 0:6384ad26fe6c 133 /* Wait Sequence in the beginning for board to be reset then placed in mini docking station*/
group-Hexiwear-Alert-System 0:6384ad26fe6c 134
group-Hexiwear-Alert-System 0:6384ad26fe6c 135 Thread::wait(6000);
group-Hexiwear-Alert-System 0:6384ad26fe6c 136 blueLed=0;
group-Hexiwear-Alert-System 0:6384ad26fe6c 137 Thread::wait(500);
group-Hexiwear-Alert-System 0:6384ad26fe6c 138 blueLed=1;
group-Hexiwear-Alert-System 0:6384ad26fe6c 139
group-Hexiwear-Alert-System 0:6384ad26fe6c 140
group-Hexiwear-Alert-System 0:6384ad26fe6c 141 /* NRF24l0p Setup */
group-Hexiwear-Alert-System 0:6384ad26fe6c 142 my_nrf24l01p.init();
group-Hexiwear-Alert-System 0:6384ad26fe6c 143 my_nrf24l01p.powerUp();
group-Hexiwear-Alert-System 0:6384ad26fe6c 144 my_nrf24l01p.setAirDataRate(NRF24L01P_DATARATE_250_KBPS);
group-Hexiwear-Alert-System 0:6384ad26fe6c 145 my_nrf24l01p.setRfOutputPower(NRF24L01P_TX_PWR_ZERO_DB);
group-Hexiwear-Alert-System 0:6384ad26fe6c 146 my_nrf24l01p.setRxAddress(0xE7E7E7E7E8);
group-Hexiwear-Alert-System 0:6384ad26fe6c 147 my_nrf24l01p.setTxAddress(0xE7E7E7E7E8);
group-Hexiwear-Alert-System 0:6384ad26fe6c 148 my_nrf24l01p.setTransferSize( TRANSFER_SIZE );
group-Hexiwear-Alert-System 0:6384ad26fe6c 149 my_nrf24l01p.setReceiveMode();
group-Hexiwear-Alert-System 0:6384ad26fe6c 150 my_nrf24l01p.enable();
group-Hexiwear-Alert-System 0:6384ad26fe6c 151
group-Hexiwear-Alert-System 0:6384ad26fe6c 152 /* Get OLED Class Default Text Properties */
group-Hexiwear-Alert-System 0:6384ad26fe6c 153 oled.GetTextProperties(&textProperties);
group-Hexiwear-Alert-System 0:6384ad26fe6c 154
group-Hexiwear-Alert-System 0:6384ad26fe6c 155 /* Fills the screen with solid black */
group-Hexiwear-Alert-System 0:6384ad26fe6c 156 oled.FillScreen(COLOR_BLACK);
group-Hexiwear-Alert-System 0:6384ad26fe6c 157
group-Hexiwear-Alert-System 0:6384ad26fe6c 158 /* Register callbacks to application functions */
group-Hexiwear-Alert-System 0:6384ad26fe6c 159 kw40z_device.attach_buttonLeft(&ButtonLeft);
group-Hexiwear-Alert-System 0:6384ad26fe6c 160 kw40z_device.attach_buttonRight(&ButtonRight);
group-Hexiwear-Alert-System 0:6384ad26fe6c 161 kw40z_device.attach_buttonUp(&ButtonUp);
group-Hexiwear-Alert-System 0:6384ad26fe6c 162 kw40z_device.attach_buttonDown(&ButtonDown);
group-Hexiwear-Alert-System 0:6384ad26fe6c 163
group-Hexiwear-Alert-System 0:6384ad26fe6c 164 /* Change font color to white */
group-Hexiwear-Alert-System 0:6384ad26fe6c 165 textProperties.fontColor = COLOR_WHITE;
group-Hexiwear-Alert-System 0:6384ad26fe6c 166 textProperties.alignParam = OLED_TEXT_ALIGN_CENTER;
group-Hexiwear-Alert-System 0:6384ad26fe6c 167 oled.SetTextProperties(&textProperties);
group-Hexiwear-Alert-System 0:6384ad26fe6c 168
group-Hexiwear-Alert-System 0:6384ad26fe6c 169 /*Displays the Home Screen*/
group-Hexiwear-Alert-System 0:6384ad26fe6c 170 displayHome();
group-Hexiwear-Alert-System 0:6384ad26fe6c 171
group-Hexiwear-Alert-System 0:6384ad26fe6c 172 /*Draw Home Button and Send Button*/
DeanBritt 1:ee1a74958b09 173 oled.DrawImage(fallbuttonBMP,0,81);
DeanBritt 1:ee1a74958b09 174 oled.DrawImage(heartrateBMP,53,81);
DeanBritt 1:ee1a74958b09 175 oled.DrawImage(safeelder_bmp,0,0);
group-Hexiwear-Alert-System 0:6384ad26fe6c 176
group-Hexiwear-Alert-System 0:6384ad26fe6c 177 while (true)
group-Hexiwear-Alert-System 0:6384ad26fe6c 178 {
group-Hexiwear-Alert-System 0:6384ad26fe6c 179
group-Hexiwear-Alert-System 0:6384ad26fe6c 180 // If we've received anything in the nRF24L01+...
group-Hexiwear-Alert-System 0:6384ad26fe6c 181 if ( my_nrf24l01p.readable() ) {
group-Hexiwear-Alert-System 0:6384ad26fe6c 182
group-Hexiwear-Alert-System 0:6384ad26fe6c 183 // ...read the data into the receive buffer
group-Hexiwear-Alert-System 0:6384ad26fe6c 184 my_nrf24l01p.read( NRF24L01P_PIPE_P0, rxData, sizeof(rxData));
group-Hexiwear-Alert-System 0:6384ad26fe6c 185
group-Hexiwear-Alert-System 0:6384ad26fe6c 186 //Set a flag that a message has been received
group-Hexiwear-Alert-System 0:6384ad26fe6c 187 sentMessageDisplayedFlag=1;
group-Hexiwear-Alert-System 0:6384ad26fe6c 188
group-Hexiwear-Alert-System 0:6384ad26fe6c 189 //Turn on Green LED to indicate received message
group-Hexiwear-Alert-System 0:6384ad26fe6c 190 greenLed = !sentMessageDisplayedFlag;
group-Hexiwear-Alert-System 0:6384ad26fe6c 191 //Turn area black to get rid of Send Button
group-Hexiwear-Alert-System 0:6384ad26fe6c 192 oled.DrawBox (53,81,43,15,COLOR_BLACK);
group-Hexiwear-Alert-System 0:6384ad26fe6c 193
group-Hexiwear-Alert-System 0:6384ad26fe6c 194
group-Hexiwear-Alert-System 0:6384ad26fe6c 195 char name[7];
group-Hexiwear-Alert-System 0:6384ad26fe6c 196
group-Hexiwear-Alert-System 0:6384ad26fe6c 197 name[0] = rxData[2];
group-Hexiwear-Alert-System 0:6384ad26fe6c 198 name[1] = rxData[3];
group-Hexiwear-Alert-System 0:6384ad26fe6c 199 name[2] = ' ';
group-Hexiwear-Alert-System 0:6384ad26fe6c 200 name[3] = 's';
group-Hexiwear-Alert-System 0:6384ad26fe6c 201 name[4] = 'e';
group-Hexiwear-Alert-System 0:6384ad26fe6c 202 name[5] = 'n';
group-Hexiwear-Alert-System 0:6384ad26fe6c 203 name[6] = 't';
group-Hexiwear-Alert-System 0:6384ad26fe6c 204
group-Hexiwear-Alert-System 0:6384ad26fe6c 205 oled.TextBox((uint8_t *)name,0,20,95,18);
group-Hexiwear-Alert-System 0:6384ad26fe6c 206
group-Hexiwear-Alert-System 0:6384ad26fe6c 207 switch (rxData[0])
group-Hexiwear-Alert-System 0:6384ad26fe6c 208 {
group-Hexiwear-Alert-System 0:6384ad26fe6c 209 case 'M':
group-Hexiwear-Alert-System 0:6384ad26fe6c 210 {
group-Hexiwear-Alert-System 0:6384ad26fe6c 211 oled.TextBox("Meet",0,35,95,18);
group-Hexiwear-Alert-System 0:6384ad26fe6c 212 break;
group-Hexiwear-Alert-System 0:6384ad26fe6c 213 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 214 case 'I':
group-Hexiwear-Alert-System 0:6384ad26fe6c 215 {
group-Hexiwear-Alert-System 0:6384ad26fe6c 216 oled.TextBox(" ",0,35,95,18);
group-Hexiwear-Alert-System 0:6384ad26fe6c 217 break;
group-Hexiwear-Alert-System 0:6384ad26fe6c 218 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 219
group-Hexiwear-Alert-System 0:6384ad26fe6c 220 default: {break;}
group-Hexiwear-Alert-System 0:6384ad26fe6c 221
group-Hexiwear-Alert-System 0:6384ad26fe6c 222 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 223
group-Hexiwear-Alert-System 0:6384ad26fe6c 224 switch (rxData[1])
group-Hexiwear-Alert-System 0:6384ad26fe6c 225 {
group-Hexiwear-Alert-System 0:6384ad26fe6c 226 case '0':
group-Hexiwear-Alert-System 0:6384ad26fe6c 227 {
group-Hexiwear-Alert-System 0:6384ad26fe6c 228 oled.TextBox("Where Yall?",0,50,95,18);
group-Hexiwear-Alert-System 0:6384ad26fe6c 229 break;
group-Hexiwear-Alert-System 0:6384ad26fe6c 230 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 231 case '1':
group-Hexiwear-Alert-System 0:6384ad26fe6c 232 {
group-Hexiwear-Alert-System 0:6384ad26fe6c 233 oled.TextBox("@ Stage 1",0,50,95,18);
group-Hexiwear-Alert-System 0:6384ad26fe6c 234 break;
group-Hexiwear-Alert-System 0:6384ad26fe6c 235 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 236 case '2':
group-Hexiwear-Alert-System 0:6384ad26fe6c 237 {
group-Hexiwear-Alert-System 0:6384ad26fe6c 238 oled.TextBox("@ Stage 2",0,50,95,18);
group-Hexiwear-Alert-System 0:6384ad26fe6c 239 break;
group-Hexiwear-Alert-System 0:6384ad26fe6c 240 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 241 case '3':
group-Hexiwear-Alert-System 0:6384ad26fe6c 242 {
group-Hexiwear-Alert-System 0:6384ad26fe6c 243 oled.TextBox("@ Stage 3",0,50,95,18);
group-Hexiwear-Alert-System 0:6384ad26fe6c 244 break;
group-Hexiwear-Alert-System 0:6384ad26fe6c 245 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 246 case '4':
group-Hexiwear-Alert-System 0:6384ad26fe6c 247 {
group-Hexiwear-Alert-System 0:6384ad26fe6c 248 oled.TextBox("@ Stage 4",0,50,95,18);
group-Hexiwear-Alert-System 0:6384ad26fe6c 249 break;
group-Hexiwear-Alert-System 0:6384ad26fe6c 250 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 251 case '5':
group-Hexiwear-Alert-System 0:6384ad26fe6c 252 {
group-Hexiwear-Alert-System 0:6384ad26fe6c 253 oled.TextBox("@ Stage 5",0,50,95,18);
group-Hexiwear-Alert-System 0:6384ad26fe6c 254 break;
group-Hexiwear-Alert-System 0:6384ad26fe6c 255 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 256
group-Hexiwear-Alert-System 0:6384ad26fe6c 257 default:{break;}
group-Hexiwear-Alert-System 0:6384ad26fe6c 258 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 259 StartHaptic();
group-Hexiwear-Alert-System 0:6384ad26fe6c 260 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 261
group-Hexiwear-Alert-System 0:6384ad26fe6c 262
group-Hexiwear-Alert-System 0:6384ad26fe6c 263 Thread::wait(50);
group-Hexiwear-Alert-System 0:6384ad26fe6c 264 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 265 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 266
group-Hexiwear-Alert-System 0:6384ad26fe6c 267 /******************************End of Main*************************************/
group-Hexiwear-Alert-System 0:6384ad26fe6c 268
group-Hexiwear-Alert-System 0:6384ad26fe6c 269 void StartHaptic(void) {
group-Hexiwear-Alert-System 0:6384ad26fe6c 270 hapticTimer.start(50);
group-Hexiwear-Alert-System 0:6384ad26fe6c 271 haptic = 1;
group-Hexiwear-Alert-System 0:6384ad26fe6c 272 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 273
group-Hexiwear-Alert-System 0:6384ad26fe6c 274 void StopHaptic(void const *n) {
group-Hexiwear-Alert-System 0:6384ad26fe6c 275 haptic = 0;
group-Hexiwear-Alert-System 0:6384ad26fe6c 276 hapticTimer.stop();
group-Hexiwear-Alert-System 0:6384ad26fe6c 277 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 278
group-Hexiwear-Alert-System 0:6384ad26fe6c 279 void displayHome(void)
group-Hexiwear-Alert-System 0:6384ad26fe6c 280 {
group-Hexiwear-Alert-System 0:6384ad26fe6c 281
group-Hexiwear-Alert-System 0:6384ad26fe6c 282 oled.TextBox(" ",0,20,95,18); //Line 1
group-Hexiwear-Alert-System 0:6384ad26fe6c 283 oled.TextBox("Where",0,35,95,18); //Line 2
group-Hexiwear-Alert-System 0:6384ad26fe6c 284 oled.TextBox("Yall At?",0,50,95,18); //Line 3
group-Hexiwear-Alert-System 0:6384ad26fe6c 285 strcpy(txData,"I"); //Packet[0]
group-Hexiwear-Alert-System 0:6384ad26fe6c 286 strcat(txData,"0"); //Packet[1]
group-Hexiwear-Alert-System 0:6384ad26fe6c 287 strcat(txData,NAME); //Packet[2:3]
group-Hexiwear-Alert-System 0:6384ad26fe6c 288 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 289
group-Hexiwear-Alert-System 0:6384ad26fe6c 290
group-Hexiwear-Alert-System 0:6384ad26fe6c 291 void screenHandler(uint8_t stageNum,uint8_t header)
group-Hexiwear-Alert-System 0:6384ad26fe6c 292 {
group-Hexiwear-Alert-System 0:6384ad26fe6c 293
group-Hexiwear-Alert-System 0:6384ad26fe6c 294 //Text for Line 1
group-Hexiwear-Alert-System 0:6384ad26fe6c 295 oled.TextBox(" ",0,20,95,18);
group-Hexiwear-Alert-System 0:6384ad26fe6c 296
group-Hexiwear-Alert-System 0:6384ad26fe6c 297 //Text for Line 2
group-Hexiwear-Alert-System 0:6384ad26fe6c 298 switch(header)
group-Hexiwear-Alert-System 0:6384ad26fe6c 299 {
group-Hexiwear-Alert-System 0:6384ad26fe6c 300 case 0:
group-Hexiwear-Alert-System 0:6384ad26fe6c 301 {
group-Hexiwear-Alert-System 0:6384ad26fe6c 302 //Packet Encoding for I am @
group-Hexiwear-Alert-System 0:6384ad26fe6c 303 strcpy(txData,"I");
group-Hexiwear-Alert-System 0:6384ad26fe6c 304 oled.TextBox("I am",0,35,95,18);
group-Hexiwear-Alert-System 0:6384ad26fe6c 305 break;
group-Hexiwear-Alert-System 0:6384ad26fe6c 306 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 307 case 1:
group-Hexiwear-Alert-System 0:6384ad26fe6c 308 {
group-Hexiwear-Alert-System 0:6384ad26fe6c 309 //Packet Encoding for Meet @
group-Hexiwear-Alert-System 0:6384ad26fe6c 310 strcpy(txData,"M");
group-Hexiwear-Alert-System 0:6384ad26fe6c 311 oled.TextBox("Meet",0,35,95,18);
group-Hexiwear-Alert-System 0:6384ad26fe6c 312 break;
group-Hexiwear-Alert-System 0:6384ad26fe6c 313 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 314 default:
group-Hexiwear-Alert-System 0:6384ad26fe6c 315 {
group-Hexiwear-Alert-System 0:6384ad26fe6c 316 break;
group-Hexiwear-Alert-System 0:6384ad26fe6c 317 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 318 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 319
group-Hexiwear-Alert-System 0:6384ad26fe6c 320 //Text for Line 3
group-Hexiwear-Alert-System 0:6384ad26fe6c 321 switch (stageNum)
group-Hexiwear-Alert-System 0:6384ad26fe6c 322 {
group-Hexiwear-Alert-System 0:6384ad26fe6c 323 case 0:
group-Hexiwear-Alert-System 0:6384ad26fe6c 324 {
group-Hexiwear-Alert-System 0:6384ad26fe6c 325 displayHome();
group-Hexiwear-Alert-System 0:6384ad26fe6c 326 break;
group-Hexiwear-Alert-System 0:6384ad26fe6c 327 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 328
group-Hexiwear-Alert-System 0:6384ad26fe6c 329 case 1:
group-Hexiwear-Alert-System 0:6384ad26fe6c 330 {
group-Hexiwear-Alert-System 0:6384ad26fe6c 331 //Packet Encoding for Stage 1
group-Hexiwear-Alert-System 0:6384ad26fe6c 332 strcat(txData,"1");
group-Hexiwear-Alert-System 0:6384ad26fe6c 333 oled.TextBox("@ Stage 1",0,50,95,18);
group-Hexiwear-Alert-System 0:6384ad26fe6c 334 break;
group-Hexiwear-Alert-System 0:6384ad26fe6c 335 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 336 case 2:
group-Hexiwear-Alert-System 0:6384ad26fe6c 337 {
group-Hexiwear-Alert-System 0:6384ad26fe6c 338 //Packet Encoding for Stage 2
group-Hexiwear-Alert-System 0:6384ad26fe6c 339 strcat(txData,"2");
group-Hexiwear-Alert-System 0:6384ad26fe6c 340 oled.TextBox("@ Stage 2",0,50,95,18);
group-Hexiwear-Alert-System 0:6384ad26fe6c 341 break;
group-Hexiwear-Alert-System 0:6384ad26fe6c 342 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 343 case 3:
group-Hexiwear-Alert-System 0:6384ad26fe6c 344 {
group-Hexiwear-Alert-System 0:6384ad26fe6c 345 //Packet Encoding for Stage 3
group-Hexiwear-Alert-System 0:6384ad26fe6c 346 strcat(txData,"3");
group-Hexiwear-Alert-System 0:6384ad26fe6c 347 oled.TextBox("@ Stage 3",0,50,95,18);
group-Hexiwear-Alert-System 0:6384ad26fe6c 348 break;
group-Hexiwear-Alert-System 0:6384ad26fe6c 349 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 350 case 4:
group-Hexiwear-Alert-System 0:6384ad26fe6c 351 {
group-Hexiwear-Alert-System 0:6384ad26fe6c 352 //Packet Encoding for Stage 4
group-Hexiwear-Alert-System 0:6384ad26fe6c 353 strcat(txData,"4");
group-Hexiwear-Alert-System 0:6384ad26fe6c 354 oled.TextBox("@ Stage 4",0,50,95,18);
group-Hexiwear-Alert-System 0:6384ad26fe6c 355 break;
group-Hexiwear-Alert-System 0:6384ad26fe6c 356 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 357 case 5:
group-Hexiwear-Alert-System 0:6384ad26fe6c 358 {
group-Hexiwear-Alert-System 0:6384ad26fe6c 359 //Packet Encoding for Stage 5
group-Hexiwear-Alert-System 0:6384ad26fe6c 360 strcat(txData,"5");
group-Hexiwear-Alert-System 0:6384ad26fe6c 361 oled.TextBox("@ Stage 5",0,50,95,18);
group-Hexiwear-Alert-System 0:6384ad26fe6c 362 break;
group-Hexiwear-Alert-System 0:6384ad26fe6c 363 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 364 default:
group-Hexiwear-Alert-System 0:6384ad26fe6c 365 {
group-Hexiwear-Alert-System 0:6384ad26fe6c 366 break;
group-Hexiwear-Alert-System 0:6384ad26fe6c 367 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 368 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 369
group-Hexiwear-Alert-System 0:6384ad26fe6c 370 //Append Initials to txData[2:3].
group-Hexiwear-Alert-System 0:6384ad26fe6c 371 strcat(txData,NAME);
group-Hexiwear-Alert-System 0:6384ad26fe6c 372
group-Hexiwear-Alert-System 0:6384ad26fe6c 373 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 374