Here

Dependencies:   Hexi_KW40Z Hexi_OLED_SSD1351 nRF24L01

Committer:
group-Hexiwear-Alert-System
Date:
Mon Mar 06 17:19:51 2017 +0000
Revision:
0:b90e36f56a80
Initial commit

Who changed what in which revision?

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