![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Here
Dependencies: Hexi_KW40Z Hexi_OLED_SSD1351 nRF24L01 FXOS8700
main.cpp@3:065e8a7824d4, 2017-03-09 (annotated)
- Committer:
- tdh50
- Date:
- Thu Mar 09 20:33:10 2017 +0000
- Revision:
- 3:065e8a7824d4
- Parent:
- 2:172492c41c48
- Child:
- 5:09837d22b28f
Created Images and Movements to and from screens
Who changed what in which revision?
User | Revision | Line number | New 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 |
tdh50 | 3:065e8a7824d4 | 14 | #define NUM_OF_SCREENS 4 |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 15 | #define TRANSFER_SIZE 4 |
tdh50 | 3:065e8a7824d4 | 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 | |
tdh50 | 3:065e8a7824d4 | 21 | void displayHome(); |
tdh50 | 3:065e8a7824d4 | 22 | void screenHandler(uint8_t screen); |
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 | |
tdh50 | 3:065e8a7824d4 | 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 | |
tdh50 | 3:065e8a7824d4 | 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 | |
tdh50 | 3:065e8a7824d4 | 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 | |
tdh50 | 3:065e8a7824d4 | 42 | /* Text Buffer */ |
tdh50 | 3:065e8a7824d4 | 43 | char text[20]; |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 44 | |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 45 | uint8_t screenNum=0; |
tdh50 | 3:065e8a7824d4 | 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 | |
tdh50 | 3:065e8a7824d4 | 51 | /* Pointer for the image to be displayed */ |
DeanBritt | 2:172492c41c48 | 52 | const uint8_t *SafeBMP = HexiSafe96_bmp; |
tdh50 | 3:065e8a7824d4 | 53 | const uint8_t *HeartBMP = HeartRate_bmp; |
tdh50 | 3:065e8a7824d4 | 54 | const uint8_t *FallBMP = FallDet_bmp; |
tdh50 | 3:065e8a7824d4 | 55 | const uint8_t *FallPageBMP = FallDetPage_bmp; |
tdh50 | 3:065e8a7824d4 | 56 | const uint8_t *HomeBMP = Home_bmp; |
tdh50 | 3:065e8a7824d4 | 57 | const uint8_t *HeartPageBMP = HeartRatePage_bmp; |
DeanBritt | 2:172492c41c48 | 58 | |
tdh50 | 3:065e8a7824d4 | 59 | |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 60 | /****************************Call Back Functions*******************************/ |
tdh50 | 3:065e8a7824d4 | 61 | /*Enter Button */ |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 62 | void ButtonRight(void) |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 63 | { |
tdh50 | 3:065e8a7824d4 | 64 | // All screens other than 1 have either and enter button |
tdh50 | 3:065e8a7824d4 | 65 | // or a home buttom. |
tdh50 | 3:065e8a7824d4 | 66 | if(screenNum != 1) { |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 67 | StartHaptic(); |
tdh50 | 3:065e8a7824d4 | 68 | switch(screenNum) { |
tdh50 | 3:065e8a7824d4 | 69 | case 0: { |
tdh50 | 3:065e8a7824d4 | 70 | screenNum++; |
tdh50 | 3:065e8a7824d4 | 71 | screenHandler(screenNum); |
tdh50 | 3:065e8a7824d4 | 72 | break; |
tdh50 | 3:065e8a7824d4 | 73 | } |
tdh50 | 3:065e8a7824d4 | 74 | case 2: { |
tdh50 | 3:065e8a7824d4 | 75 | screenNum = screenNum + 2; |
tdh50 | 3:065e8a7824d4 | 76 | screenHandler(screenNum); |
tdh50 | 3:065e8a7824d4 | 77 | break; |
tdh50 | 3:065e8a7824d4 | 78 | } |
tdh50 | 3:065e8a7824d4 | 79 | case 3: { |
tdh50 | 3:065e8a7824d4 | 80 | screenNum = screenNum + 2; |
tdh50 | 3:065e8a7824d4 | 81 | screenHandler(screenNum); |
tdh50 | 3:065e8a7824d4 | 82 | break; |
tdh50 | 3:065e8a7824d4 | 83 | } |
tdh50 | 3:065e8a7824d4 | 84 | case 4: |
tdh50 | 3:065e8a7824d4 | 85 | case 5: { |
tdh50 | 3:065e8a7824d4 | 86 | displayHome(); |
tdh50 | 3:065e8a7824d4 | 87 | screenNum = 0; |
tdh50 | 3:065e8a7824d4 | 88 | break; |
tdh50 | 3:065e8a7824d4 | 89 | } |
tdh50 | 3:065e8a7824d4 | 90 | default: { |
tdh50 | 3:065e8a7824d4 | 91 | break; |
tdh50 | 3:065e8a7824d4 | 92 | } |
tdh50 | 3:065e8a7824d4 | 93 | } |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 94 | } |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 95 | } |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 96 | |
tdh50 | 3:065e8a7824d4 | 97 | /*Back Button */ |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 98 | void ButtonLeft(void) |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 99 | { |
tdh50 | 3:065e8a7824d4 | 100 | if(screenNum > 0) { |
tdh50 | 3:065e8a7824d4 | 101 | StartHaptic(); |
tdh50 | 3:065e8a7824d4 | 102 | //Allow user to go back to correct screen based on srceen number |
tdh50 | 3:065e8a7824d4 | 103 | //Refer to screenHandler for screen numbers |
tdh50 | 3:065e8a7824d4 | 104 | if(screenNum == 3 || screenNum == 4 || screenNum == 5) { |
tdh50 | 3:065e8a7824d4 | 105 | screenNum = screenNum - 2; |
tdh50 | 3:065e8a7824d4 | 106 | } else { |
tdh50 | 3:065e8a7824d4 | 107 | screenNum--; |
tdh50 | 3:065e8a7824d4 | 108 | } |
tdh50 | 3:065e8a7824d4 | 109 | screenHandler(screenNum); |
tdh50 | 3:065e8a7824d4 | 110 | } |
tdh50 | 3:065e8a7824d4 | 111 | |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 112 | } |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 113 | |
tdh50 | 3:065e8a7824d4 | 114 | /*Advances to Heartrate only when user |
tdh50 | 3:065e8a7824d4 | 115 | is on Hexisafe screen */ |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 116 | void ButtonUp(void) |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 117 | { |
tdh50 | 3:065e8a7824d4 | 118 | if (screenNum == 1) { |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 119 | StartHaptic(); |
tdh50 | 3:065e8a7824d4 | 120 | screenNum++; |
tdh50 | 3:065e8a7824d4 | 121 | screenHandler(screenNum); |
tdh50 | 3:065e8a7824d4 | 122 | } |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 123 | |
tdh50 | 3:065e8a7824d4 | 124 | |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 125 | } |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 126 | |
tdh50 | 3:065e8a7824d4 | 127 | /*Advances to Fall Detection only when user |
tdh50 | 3:065e8a7824d4 | 128 | is on Hexisafe screen */ |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 129 | void ButtonDown(void) |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 130 | { |
tdh50 | 3:065e8a7824d4 | 131 | if (screenNum == 1) { |
tdh50 | 3:065e8a7824d4 | 132 | StartHaptic(); |
tdh50 | 3:065e8a7824d4 | 133 | screenNum= screenNum + 2; |
tdh50 | 3:065e8a7824d4 | 134 | screenHandler(screenNum); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 135 | } |
tdh50 | 3:065e8a7824d4 | 136 | |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 137 | } |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 138 | |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 139 | |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 140 | /***********************End of Call Back Functions*****************************/ |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 141 | |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 142 | /********************************Main******************************************/ |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 143 | |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 144 | int main() |
tdh50 | 3:065e8a7824d4 | 145 | { |
tdh50 | 3:065e8a7824d4 | 146 | /* Wait Sequence in the beginning for board to be reset then placed in mini docking station*/ |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 147 | blueLed=1; |
tdh50 | 3:065e8a7824d4 | 148 | |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 149 | |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 150 | /* NRF24l0p Setup */ |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 151 | my_nrf24l01p.init(); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 152 | my_nrf24l01p.powerUp(); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 153 | my_nrf24l01p.setAirDataRate(NRF24L01P_DATARATE_250_KBPS); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 154 | my_nrf24l01p.setRfOutputPower(NRF24L01P_TX_PWR_ZERO_DB); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 155 | my_nrf24l01p.setRxAddress(0xE7E7E7E7E8); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 156 | my_nrf24l01p.setTxAddress(0xE7E7E7E7E8); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 157 | my_nrf24l01p.setTransferSize( TRANSFER_SIZE ); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 158 | my_nrf24l01p.setReceiveMode(); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 159 | my_nrf24l01p.enable(); |
tdh50 | 3:065e8a7824d4 | 160 | |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 161 | /* Get OLED Class Default Text Properties */ |
tdh50 | 3:065e8a7824d4 | 162 | oled.GetTextProperties(&textProperties); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 163 | |
tdh50 | 3:065e8a7824d4 | 164 | /* Fills the screen with solid black */ |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 165 | oled.FillScreen(COLOR_BLACK); |
tdh50 | 3:065e8a7824d4 | 166 | |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 167 | /* Register callbacks to application functions */ |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 168 | kw40z_device.attach_buttonLeft(&ButtonLeft); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 169 | kw40z_device.attach_buttonRight(&ButtonRight); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 170 | kw40z_device.attach_buttonUp(&ButtonUp); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 171 | kw40z_device.attach_buttonDown(&ButtonDown); |
tdh50 | 3:065e8a7824d4 | 172 | |
tdh50 | 3:065e8a7824d4 | 173 | /* Change font color to white */ |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 174 | textProperties.fontColor = COLOR_WHITE; |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 175 | textProperties.alignParam = OLED_TEXT_ALIGN_CENTER; |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 176 | oled.SetTextProperties(&textProperties); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 177 | |
tdh50 | 3:065e8a7824d4 | 178 | /*Displays the Home Screen*/ |
tdh50 | 3:065e8a7824d4 | 179 | displayHome(); |
tdh50 | 3:065e8a7824d4 | 180 | |
tdh50 | 3:065e8a7824d4 | 181 | while (true) { |
tdh50 | 3:065e8a7824d4 | 182 | |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 183 | // If we've received anything in the nRF24L01+... |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 184 | if ( my_nrf24l01p.readable() ) { |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 185 | |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 186 | // ...read the data into the receive buffer |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 187 | my_nrf24l01p.read( NRF24L01P_PIPE_P0, rxData, sizeof(rxData)); |
tdh50 | 3:065e8a7824d4 | 188 | |
tdh50 | 3:065e8a7824d4 | 189 | //Set a flag that a message has been received |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 190 | sentMessageDisplayedFlag=1; |
tdh50 | 3:065e8a7824d4 | 191 | |
tdh50 | 3:065e8a7824d4 | 192 | //Turn on Green LED to indicate received message |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 193 | greenLed = !sentMessageDisplayedFlag; |
tdh50 | 3:065e8a7824d4 | 194 | //Turn area black to get rid of Send Button |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 195 | oled.DrawBox (53,81,43,15,COLOR_BLACK); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 196 | |
tdh50 | 3:065e8a7824d4 | 197 | |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 198 | char name[7]; |
tdh50 | 3:065e8a7824d4 | 199 | |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 200 | name[0] = rxData[2]; |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 201 | name[1] = rxData[3]; |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 202 | name[2] = ' '; |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 203 | name[3] = 's'; |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 204 | name[4] = 'e'; |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 205 | name[5] = 'n'; |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 206 | name[6] = 't'; |
tdh50 | 3:065e8a7824d4 | 207 | |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 208 | oled.TextBox((uint8_t *)name,0,20,95,18); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 209 | |
tdh50 | 3:065e8a7824d4 | 210 | switch (rxData[0]) { |
tdh50 | 3:065e8a7824d4 | 211 | case 'M': { |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 212 | oled.TextBox("Meet",0,35,95,18); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 213 | break; |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 214 | } |
tdh50 | 3:065e8a7824d4 | 215 | case 'I': { |
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 | |
tdh50 | 3:065e8a7824d4 | 220 | default: { |
tdh50 | 3:065e8a7824d4 | 221 | break; |
tdh50 | 3:065e8a7824d4 | 222 | } |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 223 | |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 224 | } |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 225 | |
tdh50 | 3:065e8a7824d4 | 226 | switch (rxData[1]) { |
tdh50 | 3:065e8a7824d4 | 227 | case '0': { |
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 | } |
tdh50 | 3:065e8a7824d4 | 231 | case '1': { |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 232 | oled.TextBox("@ Stage 1",0,50,95,18); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 233 | break; |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 234 | } |
tdh50 | 3:065e8a7824d4 | 235 | case '2': { |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 236 | oled.TextBox("@ Stage 2",0,50,95,18); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 237 | break; |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 238 | } |
tdh50 | 3:065e8a7824d4 | 239 | case '3': { |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 240 | oled.TextBox("@ Stage 3",0,50,95,18); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 241 | break; |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 242 | } |
tdh50 | 3:065e8a7824d4 | 243 | case '4': { |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 244 | oled.TextBox("@ Stage 4",0,50,95,18); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 245 | break; |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 246 | } |
tdh50 | 3:065e8a7824d4 | 247 | case '5': { |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 248 | oled.TextBox("@ Stage 5",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 | |
tdh50 | 3:065e8a7824d4 | 252 | default: { |
tdh50 | 3:065e8a7824d4 | 253 | break; |
tdh50 | 3:065e8a7824d4 | 254 | } |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 255 | } |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 256 | StartHaptic(); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 257 | } |
tdh50 | 3:065e8a7824d4 | 258 | |
tdh50 | 3:065e8a7824d4 | 259 | |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 260 | Thread::wait(50); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 261 | } |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 262 | } |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 263 | |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 264 | /******************************End of Main*************************************/ |
tdh50 | 3:065e8a7824d4 | 265 | //Intiates Vibration |
tdh50 | 3:065e8a7824d4 | 266 | void StartHaptic(void) |
tdh50 | 3:065e8a7824d4 | 267 | { |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 268 | hapticTimer.start(50); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 269 | haptic = 1; |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 270 | } |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 271 | |
tdh50 | 3:065e8a7824d4 | 272 | void StopHaptic(void const *n) |
tdh50 | 3:065e8a7824d4 | 273 | { |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 274 | haptic = 0; |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 275 | hapticTimer.stop(); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 276 | } |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 277 | |
tdh50 | 3:065e8a7824d4 | 278 | void displayHome(void) |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 279 | { |
tdh50 | 3:065e8a7824d4 | 280 | oled.DrawImage(HomeBMP,0,0); |
tdh50 | 3:065e8a7824d4 | 281 | } |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 282 | |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 283 | |
tdh50 | 3:065e8a7824d4 | 284 | void screenHandler(uint8_t screen) |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 285 | { |
tdh50 | 3:065e8a7824d4 | 286 | //Switching screens |
tdh50 | 3:065e8a7824d4 | 287 | switch(screen) { |
tdh50 | 3:065e8a7824d4 | 288 | case 0: { |
tdh50 | 3:065e8a7824d4 | 289 | displayHome(); |
tdh50 | 3:065e8a7824d4 | 290 | break; |
tdh50 | 3:065e8a7824d4 | 291 | } |
tdh50 | 3:065e8a7824d4 | 292 | case 1: { |
tdh50 | 3:065e8a7824d4 | 293 | //Switching to SafeBMP |
tdh50 | 3:065e8a7824d4 | 294 | oled.DrawImage(SafeBMP,0,0); |
tdh50 | 3:065e8a7824d4 | 295 | break; |
tdh50 | 3:065e8a7824d4 | 296 | } |
tdh50 | 3:065e8a7824d4 | 297 | case 2: { |
tdh50 | 3:065e8a7824d4 | 298 | //Switching to HeartBMP |
tdh50 | 3:065e8a7824d4 | 299 | oled.DrawImage(HeartBMP,0,0); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 300 | break; |
tdh50 | 3:065e8a7824d4 | 301 | } |
tdh50 | 3:065e8a7824d4 | 302 | case 3: { |
tdh50 | 3:065e8a7824d4 | 303 | //Switching to FallBMP |
tdh50 | 3:065e8a7824d4 | 304 | oled.DrawImage(FallBMP,0,0); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 305 | break; |
tdh50 | 3:065e8a7824d4 | 306 | } |
tdh50 | 3:065e8a7824d4 | 307 | case 4: { |
tdh50 | 3:065e8a7824d4 | 308 | //Switching to HeartPageBMP |
tdh50 | 3:065e8a7824d4 | 309 | oled.DrawImage(HeartPageBMP,0,0); |
tdh50 | 3:065e8a7824d4 | 310 | break; |
tdh50 | 3:065e8a7824d4 | 311 | } |
tdh50 | 3:065e8a7824d4 | 312 | case 5: { |
tdh50 | 3:065e8a7824d4 | 313 | //Switching to FallPageBMP |
tdh50 | 3:065e8a7824d4 | 314 | oled.DrawImage(FallPageBMP,0,0); |
tdh50 | 3:065e8a7824d4 | 315 | break; |
tdh50 | 3:065e8a7824d4 | 316 | } |
tdh50 | 3:065e8a7824d4 | 317 | default: { |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 318 | break; |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 319 | } |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 320 | } |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 321 | |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 322 | |
tdh50 | 3:065e8a7824d4 | 323 | //Append Initials to txData[2:3]. |
tdh50 | 3:065e8a7824d4 | 324 | //strcat(txData,NAME); |
tdh50 | 3:065e8a7824d4 | 325 | |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 326 | } |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 327 |