Here
Dependencies: Hexi_KW40Z Hexi_OLED_SSD1351 nRF24L01 FXOS8700
main.cpp@14:9e6b87e322a2, 2017-04-10 (annotated)
- Committer:
- DeanBritt
- Date:
- Mon Apr 10 17:25:37 2017 +0000
- Revision:
- 14:9e6b87e322a2
- Parent:
- 12:8db1b8fb5866
- Child:
- 16:b09f27c2dbe7
New screen changes updated
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" |
tdh50 | 5:09837d22b28f | 3 | #include "FXOS8700.h" |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 4 | #include "Hexi_OLED_SSD1351.h" |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 5 | #include "OLED_types.h" |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 6 | #include "OpenSans_Font.h" |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 7 | #include "nRF24L01P.h" |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 8 | #include "string.h" |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 9 | #include "images.h" |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 10 | |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 11 | #define NAME "RB" |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 12 | |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 13 | #define LED_ON 0 |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 14 | #define LED_OFF 1 |
tdh50 | 3:065e8a7824d4 | 15 | #define NUM_OF_SCREENS 4 |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 16 | #define TRANSFER_SIZE 4 |
tdh50 | 3:065e8a7824d4 | 17 | |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 18 | void StartHaptic(void); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 19 | void StopHaptic(void const *n); |
tdh50 | 12:8db1b8fb5866 | 20 | void txTask(void); |
tdh50 | 5:09837d22b28f | 21 | void accelero(void); |
tdh50 | 7:46729d931f26 | 22 | void drawAccel(void); |
tdh50 | 3:065e8a7824d4 | 23 | void displayHome(); |
tdh50 | 3:065e8a7824d4 | 24 | void screenHandler(uint8_t screen); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 25 | |
tdh50 | 12:8db1b8fb5866 | 26 | |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 27 | DigitalOut redLed(LED1,1); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 28 | DigitalOut greenLed(LED2,1); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 29 | DigitalOut blueLed(LED3,1); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 30 | DigitalOut haptic(PTB9); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 31 | |
tdh50 | 11:deecd2b72129 | 32 | // Define timer for haptic feedback |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 33 | RtosTimer hapticTimer(StopHaptic, osTimerOnce); |
tdh50 | 11:deecd2b72129 | 34 | // |
tdh50 | 5:09837d22b28f | 35 | FXOS8700 accel(PTC11, PTC10); |
tdh50 | 11:deecd2b72129 | 36 | // Instantiate the Hexi KW40Z Driver (UART TX, UART RX) |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 37 | KW40Z kw40z_device(PTE24, PTE25); |
tdh50 | 5:09837d22b28f | 38 | Serial pc(USBTX, USBRX); // Serial interface |
tdh50 | 11:deecd2b72129 | 39 | // Instantiate the SSD1351 OLED Driver |
tdh50 | 11:deecd2b72129 | 40 | SSD1351 oled(PTB22,PTB21,PTC13,PTB20,PTE6, PTD15); // (MOSI,SCLK,POWER,CS,RST,DC) |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 41 | oled_text_properties_t textProperties = {0}; |
tdh50 | 12:8db1b8fb5866 | 42 | |
tdh50 | 12:8db1b8fb5866 | 43 | |
tdh50 | 12:8db1b8fb5866 | 44 | /*Create a Thread to handle sending BLE Sensor Data */ |
tdh50 | 12:8db1b8fb5866 | 45 | Thread txThread; |
tdh50 | 12:8db1b8fb5866 | 46 | |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 47 | |
tdh50 | 11:deecd2b72129 | 48 | // Text Buffer |
tdh50 | 5:09837d22b28f | 49 | char text1[20]; // Text Buffer for dynamic value displayed |
tdh50 | 5:09837d22b28f | 50 | char text2[20]; // Text Buffer for dynamic value displayed |
tdh50 | 5:09837d22b28f | 51 | char text3[20]; // Text Buffer for dynamic value displayed |
tdh50 | 12:8db1b8fb5866 | 52 | char text [20]; |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 53 | |
tdh50 | 5:09837d22b28f | 54 | float accel_data[3]; // Storage for the data from the sensor |
tdh50 | 5:09837d22b28f | 55 | float accel_rms=0.0; // RMS value from the sensor |
tdh50 | 5:09837d22b28f | 56 | float ax, ay, az; // Integer value from the sensor to be displayed |
tdh50 | 11:deecd2b72129 | 57 | uint8_t timer = 30; |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 58 | uint8_t screenNum=0; |
tdh50 | 3:065e8a7824d4 | 59 | bool prefix=0; |
tdh50 | 5:09837d22b28f | 60 | bool accelerometer = false; |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 61 | bool sentMessageDisplayedFlag=0; |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 62 | char rxData[TRANSFER_SIZE]; |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 63 | char txData[TRANSFER_SIZE]; |
tdh50 | 12:8db1b8fb5866 | 64 | int16_t x=0,y=0,z=0; |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 65 | |
tdh50 | 11:deecd2b72129 | 66 | // Pointer for the image to be displayed |
DeanBritt | 14:9e6b87e322a2 | 67 | //const uint8_t *SafeBMP = HexiSafe96_bmp; |
tdh50 | 3:065e8a7824d4 | 68 | const uint8_t *HeartBMP = HeartRate_bmp; |
tdh50 | 3:065e8a7824d4 | 69 | const uint8_t *FallBMP = FallDet_bmp; |
tdh50 | 3:065e8a7824d4 | 70 | const uint8_t *FallPageBMP = FallDetPage_bmp; |
tdh50 | 3:065e8a7824d4 | 71 | const uint8_t *HomeBMP = Home_bmp; |
tdh50 | 3:065e8a7824d4 | 72 | const uint8_t *HeartPageBMP = HeartRatePage_bmp; |
DeanBritt | 8:5532a9c895be | 73 | const uint8_t *AlertBMP = Alert_bmp; |
DeanBritt | 2:172492c41c48 | 74 | |
tdh50 | 11:deecd2b72129 | 75 | //***************************Call Back Functions****************************** |
tdh50 | 11:deecd2b72129 | 76 | //Enter Button |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 77 | void ButtonRight(void) |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 78 | { |
tdh50 | 7:46729d931f26 | 79 | // All screens other than 1 have either and enter button |
tdh50 | 7:46729d931f26 | 80 | // or a home buttom. |
DeanBritt | 14:9e6b87e322a2 | 81 | if(screenNum != 0) { |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 82 | StartHaptic(); |
tdh50 | 3:065e8a7824d4 | 83 | switch(screenNum) { |
DeanBritt | 14:9e6b87e322a2 | 84 | case 1: { |
DeanBritt | 14:9e6b87e322a2 | 85 | screenNum=screenNum + 2; |
tdh50 | 3:065e8a7824d4 | 86 | screenHandler(screenNum); |
tdh50 | 3:065e8a7824d4 | 87 | break; |
tdh50 | 3:065e8a7824d4 | 88 | } |
tdh50 | 3:065e8a7824d4 | 89 | case 2: { |
tdh50 | 3:065e8a7824d4 | 90 | screenNum = screenNum + 2; |
tdh50 | 3:065e8a7824d4 | 91 | break; |
tdh50 | 3:065e8a7824d4 | 92 | } |
DeanBritt | 14:9e6b87e322a2 | 93 | case 3: |
DeanBritt | 14:9e6b87e322a2 | 94 | case 4: { |
tdh50 | 3:065e8a7824d4 | 95 | screenNum = 0; |
tdh50 | 3:065e8a7824d4 | 96 | break; |
tdh50 | 3:065e8a7824d4 | 97 | } |
DeanBritt | 14:9e6b87e322a2 | 98 | case 5: { |
tdh50 | 11:deecd2b72129 | 99 | screenNum = 0; |
tdh50 | 11:deecd2b72129 | 100 | break; |
tdh50 | 11:deecd2b72129 | 101 | } |
tdh50 | 3:065e8a7824d4 | 102 | default: { |
tdh50 | 3:065e8a7824d4 | 103 | break; |
tdh50 | 3:065e8a7824d4 | 104 | } |
tdh50 | 3:065e8a7824d4 | 105 | } |
tdh50 | 5:09837d22b28f | 106 | screenHandler(screenNum); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 107 | } |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 108 | } |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 109 | |
tdh50 | 11:deecd2b72129 | 110 | //Back Button |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 111 | void ButtonLeft(void) |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 112 | { |
tdh50 | 11:deecd2b72129 | 113 | StartHaptic(); |
tdh50 | 3:065e8a7824d4 | 114 | if(screenNum > 0) { |
tdh50 | 3:065e8a7824d4 | 115 | //Allow user to go back to correct screen based on srceen number |
tdh50 | 3:065e8a7824d4 | 116 | //Refer to screenHandler for screen numbers |
DeanBritt | 14:9e6b87e322a2 | 117 | if(screenNum == 3 || screenNum == 4 || screenNum == 2) { |
tdh50 | 3:065e8a7824d4 | 118 | screenNum = screenNum - 2; |
tdh50 | 7:46729d931f26 | 119 | } else { |
tdh50 | 3:065e8a7824d4 | 120 | screenNum--; |
tdh50 | 11:deecd2b72129 | 121 | } |
DeanBritt | 14:9e6b87e322a2 | 122 | } |
DeanBritt | 14:9e6b87e322a2 | 123 | if(screenNum == 0) { |
DeanBritt | 14:9e6b87e322a2 | 124 | screenNum = 5; |
DeanBritt | 8:5532a9c895be | 125 | } |
tdh50 | 11:deecd2b72129 | 126 | screenHandler(screenNum); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 127 | } |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 128 | |
tdh50 | 7:46729d931f26 | 129 | //Advances to Heartrate only when user |
tdh50 | 11:deecd2b72129 | 130 | //is on Hexisafe screen |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 131 | void ButtonUp(void) |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 132 | { |
DeanBritt | 14:9e6b87e322a2 | 133 | if (screenNum == 0) { |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 134 | StartHaptic(); |
tdh50 | 3:065e8a7824d4 | 135 | screenNum++; |
tdh50 | 3:065e8a7824d4 | 136 | screenHandler(screenNum); |
tdh50 | 3:065e8a7824d4 | 137 | } |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 138 | |
tdh50 | 3:065e8a7824d4 | 139 | |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 140 | } |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 141 | |
tdh50 | 7:46729d931f26 | 142 | //Advances to Fall Detection only when user |
tdh50 | 11:deecd2b72129 | 143 | //is on Hexisafe screen |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 144 | void ButtonDown(void) |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 145 | { |
DeanBritt | 14:9e6b87e322a2 | 146 | if (screenNum == 0) { |
tdh50 | 3:065e8a7824d4 | 147 | StartHaptic(); |
tdh50 | 3:065e8a7824d4 | 148 | screenNum= screenNum + 2; |
tdh50 | 3:065e8a7824d4 | 149 | screenHandler(screenNum); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 150 | } |
tdh50 | 3:065e8a7824d4 | 151 | |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 152 | } |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 153 | |
tdh50 | 12:8db1b8fb5866 | 154 | void PassKey(void) |
tdh50 | 12:8db1b8fb5866 | 155 | { |
tdh50 | 12:8db1b8fb5866 | 156 | StartHaptic(); |
tdh50 | 12:8db1b8fb5866 | 157 | strcpy((char *) text,"PAIR CODE"); |
tdh50 | 12:8db1b8fb5866 | 158 | oled.TextBox((uint8_t *)text,0,25,95,18); |
tdh50 | 12:8db1b8fb5866 | 159 | |
tdh50 | 12:8db1b8fb5866 | 160 | /* Display Bond Pass Key in a 95px by 18px textbox at x=0,y=40 */ |
tdh50 | 12:8db1b8fb5866 | 161 | sprintf(text,"%d", kw40z_device.GetPassKey()); |
tdh50 | 12:8db1b8fb5866 | 162 | oled.TextBox((uint8_t *)text,0,40,95,18); |
tdh50 | 12:8db1b8fb5866 | 163 | } |
tdh50 | 12:8db1b8fb5866 | 164 | |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 165 | |
tdh50 | 11:deecd2b72129 | 166 | //**********************End of Call Back Functions**************************** |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 167 | |
tdh50 | 11:deecd2b72129 | 168 | //*******************************Main***************************************** |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 169 | |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 170 | int main() |
tdh50 | 3:065e8a7824d4 | 171 | { |
tdh50 | 11:deecd2b72129 | 172 | // Wait Sequence in the beginning for board to be reset then placed in mini docking station |
tdh50 | 11:deecd2b72129 | 173 | accel.accel_config(); |
tdh50 | 3:065e8a7824d4 | 174 | |
tdh50 | 11:deecd2b72129 | 175 | // Get OLED Class Default Text Properties |
tdh50 | 3:065e8a7824d4 | 176 | oled.GetTextProperties(&textProperties); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 177 | |
tdh50 | 11:deecd2b72129 | 178 | // Register callbacks to application functions |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 179 | kw40z_device.attach_buttonLeft(&ButtonLeft); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 180 | kw40z_device.attach_buttonRight(&ButtonRight); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 181 | kw40z_device.attach_buttonUp(&ButtonUp); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 182 | kw40z_device.attach_buttonDown(&ButtonDown); |
tdh50 | 12:8db1b8fb5866 | 183 | oled_text_properties_t textProperties = {0}; |
tdh50 | 12:8db1b8fb5866 | 184 | oled.SetTextProperties(&textProperties); |
tdh50 | 12:8db1b8fb5866 | 185 | |
tdh50 | 12:8db1b8fb5866 | 186 | //Passcode |
tdh50 | 12:8db1b8fb5866 | 187 | kw40z_device.attach_passkey(&PassKey); |
tdh50 | 3:065e8a7824d4 | 188 | |
tdh50 | 11:deecd2b72129 | 189 | // Change font color to white |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 190 | textProperties.fontColor = COLOR_WHITE; |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 191 | textProperties.alignParam = OLED_TEXT_ALIGN_CENTER; |
tdh50 | 12:8db1b8fb5866 | 192 | |
tdh50 | 12:8db1b8fb5866 | 193 | //txThread.start(txTask); /*Start transmitting Sensor Tag Data */ |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 194 | |
tdh50 | 11:deecd2b72129 | 195 | //Displays the Home Screen |
tdh50 | 3:065e8a7824d4 | 196 | displayHome(); |
tdh50 | 12:8db1b8fb5866 | 197 | //bool trigger = 0; |
tdh50 | 3:065e8a7824d4 | 198 | |
tdh50 | 3:065e8a7824d4 | 199 | while (true) { |
tdh50 | 11:deecd2b72129 | 200 | accel.acquire_accel_data_g(accel_data); |
tdh50 | 11:deecd2b72129 | 201 | accel_rms = sqrt(((accel_data[0]*accel_data[0])+(accel_data[1]*accel_data[1])+(accel_data[2]*accel_data[2]))/3); |
tdh50 | 12:8db1b8fb5866 | 202 | x = accel_data[0] *10000; |
tdh50 | 12:8db1b8fb5866 | 203 | y = accel_data[1] *10000; |
tdh50 | 12:8db1b8fb5866 | 204 | z = accel_data[2] *10000; |
tdh50 | 12:8db1b8fb5866 | 205 | printf("x = %4.4f y = %4.4f z = %4.4f\n\rx = %i y = %i z = %i\n\r",accel_data[0],accel_data[1],accel_data[2],x,y,z); |
DeanBritt | 14:9e6b87e322a2 | 206 | if(screenNum == 4) { |
tdh50 | 12:8db1b8fb5866 | 207 | drawAccel(); |
tdh50 | 11:deecd2b72129 | 208 | } |
tdh50 | 11:deecd2b72129 | 209 | Thread::wait(300); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 210 | } |
tdh50 | 12:8db1b8fb5866 | 211 | |
tdh50 | 12:8db1b8fb5866 | 212 | |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 213 | } |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 214 | |
tdh50 | 11:deecd2b72129 | 215 | //*****************************End of Main************************************ |
tdh50 | 3:065e8a7824d4 | 216 | //Intiates Vibration |
tdh50 | 3:065e8a7824d4 | 217 | void StartHaptic(void) |
tdh50 | 3:065e8a7824d4 | 218 | { |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 219 | hapticTimer.start(50); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 220 | haptic = 1; |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 221 | } |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 222 | |
tdh50 | 3:065e8a7824d4 | 223 | void StopHaptic(void const *n) |
tdh50 | 3:065e8a7824d4 | 224 | { |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 225 | haptic = 0; |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 226 | hapticTimer.stop(); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 227 | } |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 228 | |
tdh50 | 3:065e8a7824d4 | 229 | void displayHome(void) |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 230 | { |
tdh50 | 3:065e8a7824d4 | 231 | oled.DrawImage(HomeBMP,0,0); |
tdh50 | 3:065e8a7824d4 | 232 | } |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 233 | |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 234 | |
tdh50 | 3:065e8a7824d4 | 235 | void screenHandler(uint8_t screen) |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 236 | { |
tdh50 | 3:065e8a7824d4 | 237 | //Switching screens |
tdh50 | 3:065e8a7824d4 | 238 | switch(screen) { |
tdh50 | 3:065e8a7824d4 | 239 | case 0: { |
tdh50 | 3:065e8a7824d4 | 240 | displayHome(); |
tdh50 | 3:065e8a7824d4 | 241 | break; |
tdh50 | 3:065e8a7824d4 | 242 | } |
tdh50 | 3:065e8a7824d4 | 243 | case 1: { |
tdh50 | 3:065e8a7824d4 | 244 | //Switching to HeartBMP |
tdh50 | 3:065e8a7824d4 | 245 | oled.DrawImage(HeartBMP,0,0); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 246 | break; |
tdh50 | 3:065e8a7824d4 | 247 | } |
DeanBritt | 14:9e6b87e322a2 | 248 | case 2: { |
tdh50 | 3:065e8a7824d4 | 249 | //Switching to FallBMP |
tdh50 | 3:065e8a7824d4 | 250 | oled.DrawImage(FallBMP,0,0); |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 251 | break; |
tdh50 | 3:065e8a7824d4 | 252 | } |
DeanBritt | 14:9e6b87e322a2 | 253 | case 3: { |
tdh50 | 3:065e8a7824d4 | 254 | //Switching to HeartPageBMP |
tdh50 | 3:065e8a7824d4 | 255 | oled.DrawImage(HeartPageBMP,0,0); |
tdh50 | 3:065e8a7824d4 | 256 | break; |
tdh50 | 3:065e8a7824d4 | 257 | } |
DeanBritt | 14:9e6b87e322a2 | 258 | case 4: { |
tdh50 | 3:065e8a7824d4 | 259 | //Switching to FallPageBMP |
tdh50 | 12:8db1b8fb5866 | 260 | oled.DrawBox (23,18,50 ,50 , COLOR_BLACK); |
tdh50 | 3:065e8a7824d4 | 261 | break; |
tdh50 | 3:065e8a7824d4 | 262 | } |
DeanBritt | 14:9e6b87e322a2 | 263 | case 5: { |
tdh50 | 12:8db1b8fb5866 | 264 | //Switching to alarm |
DeanBritt | 9:5e63a3928e43 | 265 | oled.DrawImage(AlertBMP,0,0); |
tdh50 | 11:deecd2b72129 | 266 | break; |
tdh50 | 11:deecd2b72129 | 267 | } |
tdh50 | 3:065e8a7824d4 | 268 | default: { |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 269 | break; |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 270 | } |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 271 | } |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 272 | |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 273 | |
tdh50 | 3:065e8a7824d4 | 274 | //Append Initials to txData[2:3]. |
tdh50 | 3:065e8a7824d4 | 275 | //strcat(txData,NAME); |
tdh50 | 3:065e8a7824d4 | 276 | |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 277 | } |
group-Hexiwear-Alert-System | 0:6384ad26fe6c | 278 | |
tdh50 | 11:deecd2b72129 | 279 | void drawAccel(void) |
tdh50 | 11:deecd2b72129 | 280 | { |
tdh50 | 5:09837d22b28f | 281 | |
tdh50 | 12:8db1b8fb5866 | 282 | textProperties.fontColor = COLOR_GREEN; |
tdh50 | 11:deecd2b72129 | 283 | textProperties.alignParam = OLED_TEXT_ALIGN_LEFT; |
tdh50 | 11:deecd2b72129 | 284 | oled.SetTextProperties(&textProperties); |
tdh50 | 5:09837d22b28f | 285 | |
tdh50 | 11:deecd2b72129 | 286 | // Display Legends |
tdh50 | 11:deecd2b72129 | 287 | strcpy((char *) text1,"X-Axis (g):"); |
tdh50 | 11:deecd2b72129 | 288 | oled.Label((uint8_t *)text1,5,26); |
tdh50 | 11:deecd2b72129 | 289 | strcpy((char *) text2,"Y-Axis (g):"); |
tdh50 | 11:deecd2b72129 | 290 | oled.Label((uint8_t *)text2,5,43); |
tdh50 | 11:deecd2b72129 | 291 | strcpy((char *) text3,"Z-Axis (g):"); |
tdh50 | 11:deecd2b72129 | 292 | oled.Label((uint8_t *)text3,5,60); |
tdh50 | 7:46729d931f26 | 293 | |
tdh50 | 11:deecd2b72129 | 294 | // Format the value |
tdh50 | 12:8db1b8fb5866 | 295 | sprintf(text1,"%4.2f", accel_data[0]); |
tdh50 | 12:8db1b8fb5866 | 296 | // Display time reading in 35px by 15px textbox at(x=55, y=40) |
tdh50 | 12:8db1b8fb5866 | 297 | oled.TextBox((uint8_t *)text1,70,26,20,15); //Increase textbox for more digits |
tdh50 | 12:8db1b8fb5866 | 298 | |
tdh50 | 12:8db1b8fb5866 | 299 | // Format the value |
tdh50 | 12:8db1b8fb5866 | 300 | sprintf(text2,"%4.2f",accel_data[1]); |
tdh50 | 12:8db1b8fb5866 | 301 | // Display time reading in 35px by 15px textbox at(x=55, y=40) |
tdh50 | 12:8db1b8fb5866 | 302 | oled.TextBox((uint8_t *)text2,70,43,20,15); //Increase textbox for more digits |
tdh50 | 12:8db1b8fb5866 | 303 | |
tdh50 | 12:8db1b8fb5866 | 304 | |
tdh50 | 12:8db1b8fb5866 | 305 | // Format the value |
tdh50 | 12:8db1b8fb5866 | 306 | sprintf(text3,"%4.2f", accel_data[2]); |
tdh50 | 11:deecd2b72129 | 307 | // Display time reading in 35px by 15px textbox at(x=55, y=40) |
tdh50 | 11:deecd2b72129 | 308 | oled.TextBox((uint8_t *)text3,70,60,20,15); //Increase textbox for more digits |
tdh50 | 7:46729d931f26 | 309 | |
tdh50 | 11:deecd2b72129 | 310 | } |
tdh50 | 12:8db1b8fb5866 | 311 | |
tdh50 | 12:8db1b8fb5866 | 312 | // txTask() transmits the sensor data |
tdh50 | 12:8db1b8fb5866 | 313 | void txTask(void) |
tdh50 | 11:deecd2b72129 | 314 | { |
tdh50 | 12:8db1b8fb5866 | 315 | |
tdh50 | 12:8db1b8fb5866 | 316 | while (true) { |
tdh50 | 7:46729d931f26 | 317 | |
tdh50 | 12:8db1b8fb5866 | 318 | //UpdateSensorData(); |
tdh50 | 12:8db1b8fb5866 | 319 | kw40z_device.SendSetApplicationMode(GUI_CURRENT_APP_SENSOR_TAG); |
tdh50 | 12:8db1b8fb5866 | 320 | |
tdh50 | 12:8db1b8fb5866 | 321 | //Send Accel Data. |
tdh50 | 12:8db1b8fb5866 | 322 | kw40z_device.SendAccel(x,y,z); |
tdh50 | 7:46729d931f26 | 323 | } |
tdh50 | 7:46729d931f26 | 324 | } |
tdh50 | 12:8db1b8fb5866 | 325 | |
tdh50 | 12:8db1b8fb5866 | 326 |