Here

Dependencies:   Hexi_KW40Z Hexi_OLED_SSD1351 nRF24L01 FXOS8700

Committer:
tdh50
Date:
Tue Apr 11 21:35:19 2017 +0000
Revision:
18:9e23169b297a
Parent:
16:b09f27c2dbe7
Child:
19:195a0891e8e9
Added Blinking red LED when alarm is triggered; Converted back to FallPageBMP to allow home button to show

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"
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
tdh50 16:b09f27c2dbe7 11
group-Hexiwear-Alert-System 0:6384ad26fe6c 12 #define NAME "RB"
group-Hexiwear-Alert-System 0:6384ad26fe6c 13
group-Hexiwear-Alert-System 0:6384ad26fe6c 14 #define LED_ON 0
group-Hexiwear-Alert-System 0:6384ad26fe6c 15 #define LED_OFF 1
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 16:b09f27c2dbe7 24
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 16:b09f27c2dbe7 34 // Instantiates the FX0S8700 accelerometer driver
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
tdh50 11:deecd2b72129 47 // Text Buffer
tdh50 5:09837d22b28f 48 char text1[20]; // Text Buffer for dynamic value displayed
tdh50 5:09837d22b28f 49 char text2[20]; // Text Buffer for dynamic value displayed
tdh50 5:09837d22b28f 50 char text3[20]; // Text Buffer for dynamic value displayed
tdh50 16:b09f27c2dbe7 51 char pass [20]; // Passcode
group-Hexiwear-Alert-System 0:6384ad26fe6c 52
tdh50 5:09837d22b28f 53 float accel_data[3]; // Storage for the data from the sensor
tdh50 18:9e23169b297a 54 double accel_rms=0.0; // RMS value from the sensor
group-Hexiwear-Alert-System 0:6384ad26fe6c 55 uint8_t screenNum=0;
tdh50 16:b09f27c2dbe7 56 bool alert = false; //Sets alarm to zero
tdh50 16:b09f27c2dbe7 57 uint8_t previous; //Keeps track of previous screen
tdh50 16:b09f27c2dbe7 58 bool trigger = false;
group-Hexiwear-Alert-System 0:6384ad26fe6c 59 bool sentMessageDisplayedFlag=0;
group-Hexiwear-Alert-System 0:6384ad26fe6c 60 char rxData[TRANSFER_SIZE];
tdh50 16:b09f27c2dbe7 61 char txData[TRANSFER_SIZE];//Data send via BLE
tdh50 16:b09f27c2dbe7 62 int16_t x=0,y=0,z=0;
group-Hexiwear-Alert-System 0:6384ad26fe6c 63
tdh50 11:deecd2b72129 64 // Pointer for the image to be displayed
tdh50 3:065e8a7824d4 65 const uint8_t *HeartBMP = HeartRate_bmp;
tdh50 3:065e8a7824d4 66 const uint8_t *FallBMP = FallDet_bmp;
tdh50 3:065e8a7824d4 67 const uint8_t *FallPageBMP = FallDetPage_bmp;
tdh50 3:065e8a7824d4 68 const uint8_t *HomeBMP = Home_bmp;
tdh50 3:065e8a7824d4 69 const uint8_t *HeartPageBMP = HeartRatePage_bmp;
DeanBritt 8:5532a9c895be 70 const uint8_t *AlertBMP = Alert_bmp;
DeanBritt 2:172492c41c48 71
tdh50 11:deecd2b72129 72 //***************************Call Back Functions******************************
tdh50 11:deecd2b72129 73 //Enter Button
group-Hexiwear-Alert-System 0:6384ad26fe6c 74 void ButtonRight(void)
group-Hexiwear-Alert-System 0:6384ad26fe6c 75 {
tdh50 7:46729d931f26 76 // All screens other than 1 have either and enter button
tdh50 7:46729d931f26 77 // or a home buttom.
DeanBritt 14:9e6b87e322a2 78 if(screenNum != 0) {
group-Hexiwear-Alert-System 0:6384ad26fe6c 79 StartHaptic();
tdh50 3:065e8a7824d4 80 switch(screenNum) {
DeanBritt 14:9e6b87e322a2 81 case 1: {
tdh50 16:b09f27c2dbe7 82 screenNum = screenNum + 2;
tdh50 3:065e8a7824d4 83 break;
tdh50 3:065e8a7824d4 84 }
tdh50 3:065e8a7824d4 85 case 2: {
tdh50 3:065e8a7824d4 86 screenNum = screenNum + 2;
tdh50 16:b09f27c2dbe7 87 trigger = true;
tdh50 3:065e8a7824d4 88 break;
tdh50 3:065e8a7824d4 89 }
DeanBritt 14:9e6b87e322a2 90 case 3:
DeanBritt 14:9e6b87e322a2 91 case 4: {
tdh50 3:065e8a7824d4 92 screenNum = 0;
tdh50 3:065e8a7824d4 93 break;
tdh50 3:065e8a7824d4 94 }
DeanBritt 14:9e6b87e322a2 95 case 5: {
tdh50 16:b09f27c2dbe7 96 screenNum = previous;
tdh50 16:b09f27c2dbe7 97 alert = false;
tdh50 11:deecd2b72129 98 break;
tdh50 11:deecd2b72129 99 }
tdh50 3:065e8a7824d4 100 default: {
tdh50 3:065e8a7824d4 101 break;
tdh50 3:065e8a7824d4 102 }
tdh50 3:065e8a7824d4 103 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 104 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 105 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 106
tdh50 11:deecd2b72129 107 //Back Button
group-Hexiwear-Alert-System 0:6384ad26fe6c 108 void ButtonLeft(void)
group-Hexiwear-Alert-System 0:6384ad26fe6c 109 {
tdh50 16:b09f27c2dbe7 110
tdh50 16:b09f27c2dbe7 111 if(screenNum > 0 && screenNum != 5) {
tdh50 16:b09f27c2dbe7 112 StartHaptic();
tdh50 3:065e8a7824d4 113 //Allow user to go back to correct screen based on srceen number
tdh50 16:b09f27c2dbe7 114 if(screenNum == 2 || screenNum == 3 || screenNum == 4) {
tdh50 3:065e8a7824d4 115 screenNum = screenNum - 2;
tdh50 7:46729d931f26 116 } else {
tdh50 3:065e8a7824d4 117 screenNum--;
tdh50 11:deecd2b72129 118 }
tdh50 16:b09f27c2dbe7 119 } else {
tdh50 16:b09f27c2dbe7 120 StartHaptic();
DeanBritt 14:9e6b87e322a2 121 screenNum = 5;
DeanBritt 8:5532a9c895be 122 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 123 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 124
tdh50 7:46729d931f26 125 //Advances to Heartrate only when user
tdh50 11:deecd2b72129 126 //is on Hexisafe screen
group-Hexiwear-Alert-System 0:6384ad26fe6c 127 void ButtonUp(void)
group-Hexiwear-Alert-System 0:6384ad26fe6c 128 {
DeanBritt 14:9e6b87e322a2 129 if (screenNum == 0) {
group-Hexiwear-Alert-System 0:6384ad26fe6c 130 StartHaptic();
tdh50 3:065e8a7824d4 131 screenNum++;
tdh50 3:065e8a7824d4 132 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 133
tdh50 3:065e8a7824d4 134
group-Hexiwear-Alert-System 0:6384ad26fe6c 135 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 136
tdh50 7:46729d931f26 137 //Advances to Fall Detection only when user
tdh50 11:deecd2b72129 138 //is on Hexisafe screen
group-Hexiwear-Alert-System 0:6384ad26fe6c 139 void ButtonDown(void)
group-Hexiwear-Alert-System 0:6384ad26fe6c 140 {
DeanBritt 14:9e6b87e322a2 141 if (screenNum == 0) {
tdh50 3:065e8a7824d4 142 StartHaptic();
tdh50 3:065e8a7824d4 143 screenNum= screenNum + 2;
tdh50 16:b09f27c2dbe7 144
group-Hexiwear-Alert-System 0:6384ad26fe6c 145 }
tdh50 3:065e8a7824d4 146
group-Hexiwear-Alert-System 0:6384ad26fe6c 147 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 148
tdh50 12:8db1b8fb5866 149 void PassKey(void)
tdh50 12:8db1b8fb5866 150 {
tdh50 12:8db1b8fb5866 151 StartHaptic();
tdh50 16:b09f27c2dbe7 152 strcpy((char *) pass,"PAIR CODE");
tdh50 16:b09f27c2dbe7 153 oled.TextBox((uint8_t *)pass,0,25,95,18);
tdh50 12:8db1b8fb5866 154
tdh50 12:8db1b8fb5866 155 /* Display Bond Pass Key in a 95px by 18px textbox at x=0,y=40 */
tdh50 16:b09f27c2dbe7 156 sprintf(pass,"%d", kw40z_device.GetPassKey());
tdh50 16:b09f27c2dbe7 157 oled.TextBox((uint8_t *)pass,0,40,95,18);
tdh50 12:8db1b8fb5866 158 }
tdh50 12:8db1b8fb5866 159
group-Hexiwear-Alert-System 0:6384ad26fe6c 160
tdh50 11:deecd2b72129 161 //**********************End of Call Back Functions****************************
group-Hexiwear-Alert-System 0:6384ad26fe6c 162
tdh50 11:deecd2b72129 163 //*******************************Main*****************************************
group-Hexiwear-Alert-System 0:6384ad26fe6c 164
group-Hexiwear-Alert-System 0:6384ad26fe6c 165 int main()
tdh50 3:065e8a7824d4 166 {
tdh50 11:deecd2b72129 167 accel.accel_config();
tdh50 3:065e8a7824d4 168
tdh50 16:b09f27c2dbe7 169 // Get & set OLED Class Default Text Properties
tdh50 3:065e8a7824d4 170 oled.GetTextProperties(&textProperties);
tdh50 16:b09f27c2dbe7 171 oled_text_properties_t textProperties = {0};
tdh50 16:b09f27c2dbe7 172 oled.SetTextProperties(&textProperties);
tdh50 16:b09f27c2dbe7 173
tdh50 11:deecd2b72129 174 // Register callbacks to application functions
group-Hexiwear-Alert-System 0:6384ad26fe6c 175 kw40z_device.attach_buttonLeft(&ButtonLeft);
group-Hexiwear-Alert-System 0:6384ad26fe6c 176 kw40z_device.attach_buttonRight(&ButtonRight);
group-Hexiwear-Alert-System 0:6384ad26fe6c 177 kw40z_device.attach_buttonUp(&ButtonUp);
group-Hexiwear-Alert-System 0:6384ad26fe6c 178 kw40z_device.attach_buttonDown(&ButtonDown);
tdh50 16:b09f27c2dbe7 179
tdh50 16:b09f27c2dbe7 180 uint8_t num = 0;
tdh50 16:b09f27c2dbe7 181 displayHome();
tdh50 12:8db1b8fb5866 182
tdh50 12:8db1b8fb5866 183 //Passcode
tdh50 12:8db1b8fb5866 184 kw40z_device.attach_passkey(&PassKey);
tdh50 3:065e8a7824d4 185
tdh50 16:b09f27c2dbe7 186 //Change font color to white
group-Hexiwear-Alert-System 0:6384ad26fe6c 187 textProperties.fontColor = COLOR_WHITE;
group-Hexiwear-Alert-System 0:6384ad26fe6c 188 textProperties.alignParam = OLED_TEXT_ALIGN_CENTER;
tdh50 12:8db1b8fb5866 189
tdh50 16:b09f27c2dbe7 190 txThread.start(txTask); //Start transmitting Sensor Tag Data
tdh50 3:065e8a7824d4 191
tdh50 3:065e8a7824d4 192 while (true) {
tdh50 11:deecd2b72129 193 accel.acquire_accel_data_g(accel_data);
tdh50 11:deecd2b72129 194 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 195 x = accel_data[0] *10000;
tdh50 12:8db1b8fb5866 196 y = accel_data[1] *10000;
tdh50 12:8db1b8fb5866 197 z = accel_data[2] *10000;
tdh50 18:9e23169b297a 198
tdh50 18:9e23169b297a 199 // Check screen, alert and num values
tdh50 18:9e23169b297a 200 //printf("Screen = %i Num = %i alert = %d\n\r",screenNum,num,alert);
tdh50 18:9e23169b297a 201 // Check Fall Data
tdh50 16:b09f27c2dbe7 202 //printf("%4.4f\n\r",accel_rms);
tdh50 18:9e23169b297a 203 if(accel_rms*10 > 12.4)//Triggers AlertBMP if fall is detected
tdh50 16:b09f27c2dbe7 204 {
tdh50 16:b09f27c2dbe7 205 oled.DrawImage(AlertBMP,0,0);
tdh50 16:b09f27c2dbe7 206 previous = screenNum;//Allows to return to previous screen.
tdh50 16:b09f27c2dbe7 207 num = screenNum - 1;//^
tdh50 16:b09f27c2dbe7 208 screenNum = 5;
tdh50 16:b09f27c2dbe7 209 alert = true;
tdh50 18:9e23169b297a 210
tdh50 18:9e23169b297a 211 }
tdh50 18:9e23169b297a 212 //Trigger Blinking Red LED when alarm is set off
tdh50 18:9e23169b297a 213 if(alert == true)
tdh50 18:9e23169b297a 214 {
tdh50 18:9e23169b297a 215 redLed = !redLed;
tdh50 11:deecd2b72129 216 }
tdh50 16:b09f27c2dbe7 217 if((screenNum != num && alert == false) || screenNum == 4) {
tdh50 16:b09f27c2dbe7 218 switch(screenNum) {
tdh50 16:b09f27c2dbe7 219 case 0: {
tdh50 16:b09f27c2dbe7 220 displayHome();
tdh50 16:b09f27c2dbe7 221 num = screenNum;
tdh50 16:b09f27c2dbe7 222 break;
tdh50 16:b09f27c2dbe7 223 }
tdh50 16:b09f27c2dbe7 224 case 1: {
tdh50 16:b09f27c2dbe7 225 //Switching to HeartBMP
tdh50 16:b09f27c2dbe7 226 oled.DrawImage(HeartBMP,0,0);
tdh50 16:b09f27c2dbe7 227 num = screenNum;
tdh50 16:b09f27c2dbe7 228 break;
tdh50 16:b09f27c2dbe7 229 }
tdh50 16:b09f27c2dbe7 230 case 2: {
tdh50 16:b09f27c2dbe7 231 //Switching to FallBMP
tdh50 16:b09f27c2dbe7 232 oled.DrawImage(FallBMP,0,0);
tdh50 16:b09f27c2dbe7 233 num = screenNum;
tdh50 16:b09f27c2dbe7 234 break;
tdh50 16:b09f27c2dbe7 235 }
tdh50 16:b09f27c2dbe7 236 case 3: {
tdh50 16:b09f27c2dbe7 237 //Switching to HeartPageBMP
tdh50 16:b09f27c2dbe7 238 oled.DrawImage(HeartPageBMP,0,0);
tdh50 16:b09f27c2dbe7 239 num = screenNum;
tdh50 16:b09f27c2dbe7 240 break;
tdh50 16:b09f27c2dbe7 241 }
tdh50 16:b09f27c2dbe7 242 case 4: {
tdh50 16:b09f27c2dbe7 243 //Switching to FallPageBMP
tdh50 16:b09f27c2dbe7 244 if(trigger == true) {
tdh50 18:9e23169b297a 245 oled.DrawImage(FallPageBMP,0,0);
tdh50 18:9e23169b297a 246 //Only allows draw image to occur once
tdh50 16:b09f27c2dbe7 247 trigger = false;
tdh50 16:b09f27c2dbe7 248 }
tdh50 18:9e23169b297a 249 num = screenNum;
tdh50 16:b09f27c2dbe7 250 drawAccel();
tdh50 16:b09f27c2dbe7 251 break;
tdh50 16:b09f27c2dbe7 252 }
tdh50 16:b09f27c2dbe7 253 case 5: {
tdh50 16:b09f27c2dbe7 254 //Switching to alarm
tdh50 16:b09f27c2dbe7 255 oled.DrawImage(AlertBMP,0,0);
tdh50 16:b09f27c2dbe7 256 num = screenNum;
tdh50 16:b09f27c2dbe7 257 break;
tdh50 16:b09f27c2dbe7 258 }
tdh50 16:b09f27c2dbe7 259 default: {
tdh50 16:b09f27c2dbe7 260 break;
tdh50 16:b09f27c2dbe7 261 }
tdh50 16:b09f27c2dbe7 262 }
tdh50 16:b09f27c2dbe7 263 }
tdh50 16:b09f27c2dbe7 264 Thread::wait(100);
group-Hexiwear-Alert-System 0:6384ad26fe6c 265 }
tdh50 12:8db1b8fb5866 266
tdh50 12:8db1b8fb5866 267
group-Hexiwear-Alert-System 0:6384ad26fe6c 268 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 269
tdh50 11:deecd2b72129 270 //*****************************End of Main************************************
tdh50 3:065e8a7824d4 271 //Intiates Vibration
tdh50 3:065e8a7824d4 272 void StartHaptic(void)
tdh50 3:065e8a7824d4 273 {
group-Hexiwear-Alert-System 0:6384ad26fe6c 274 hapticTimer.start(50);
group-Hexiwear-Alert-System 0:6384ad26fe6c 275 haptic = 1;
group-Hexiwear-Alert-System 0:6384ad26fe6c 276 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 277
tdh50 3:065e8a7824d4 278 void StopHaptic(void const *n)
tdh50 3:065e8a7824d4 279 {
group-Hexiwear-Alert-System 0:6384ad26fe6c 280 haptic = 0;
group-Hexiwear-Alert-System 0:6384ad26fe6c 281 hapticTimer.stop();
group-Hexiwear-Alert-System 0:6384ad26fe6c 282 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 283
tdh50 18:9e23169b297a 284
tdh50 3:065e8a7824d4 285 void displayHome(void)
group-Hexiwear-Alert-System 0:6384ad26fe6c 286 {
tdh50 3:065e8a7824d4 287 oled.DrawImage(HomeBMP,0,0);
tdh50 3:065e8a7824d4 288 }
group-Hexiwear-Alert-System 0:6384ad26fe6c 289
tdh50 18:9e23169b297a 290 // drawAccel() Draws the accelerometer values to screen
tdh50 11:deecd2b72129 291 void drawAccel(void)
tdh50 11:deecd2b72129 292 {
tdh50 5:09837d22b28f 293
tdh50 12:8db1b8fb5866 294 textProperties.fontColor = COLOR_GREEN;
tdh50 11:deecd2b72129 295 textProperties.alignParam = OLED_TEXT_ALIGN_LEFT;
tdh50 11:deecd2b72129 296 oled.SetTextProperties(&textProperties);
tdh50 5:09837d22b28f 297
tdh50 11:deecd2b72129 298 // Display Legends
tdh50 11:deecd2b72129 299 strcpy((char *) text1,"X-Axis (g):");
tdh50 11:deecd2b72129 300 oled.Label((uint8_t *)text1,5,26);
tdh50 11:deecd2b72129 301 strcpy((char *) text2,"Y-Axis (g):");
tdh50 11:deecd2b72129 302 oled.Label((uint8_t *)text2,5,43);
tdh50 11:deecd2b72129 303 strcpy((char *) text3,"Z-Axis (g):");
tdh50 11:deecd2b72129 304 oled.Label((uint8_t *)text3,5,60);
tdh50 7:46729d931f26 305
tdh50 11:deecd2b72129 306 // Format the value
tdh50 12:8db1b8fb5866 307 sprintf(text1,"%4.2f", accel_data[0]);
tdh50 12:8db1b8fb5866 308 // Display time reading in 35px by 15px textbox at(x=55, y=40)
tdh50 12:8db1b8fb5866 309 oled.TextBox((uint8_t *)text1,70,26,20,15); //Increase textbox for more digits
tdh50 12:8db1b8fb5866 310
tdh50 12:8db1b8fb5866 311 // Format the value
tdh50 12:8db1b8fb5866 312 sprintf(text2,"%4.2f",accel_data[1]);
tdh50 12:8db1b8fb5866 313 // Display time reading in 35px by 15px textbox at(x=55, y=40)
tdh50 12:8db1b8fb5866 314 oled.TextBox((uint8_t *)text2,70,43,20,15); //Increase textbox for more digits
tdh50 12:8db1b8fb5866 315
tdh50 12:8db1b8fb5866 316
tdh50 12:8db1b8fb5866 317 // Format the value
tdh50 12:8db1b8fb5866 318 sprintf(text3,"%4.2f", accel_data[2]);
tdh50 11:deecd2b72129 319 // Display time reading in 35px by 15px textbox at(x=55, y=40)
tdh50 11:deecd2b72129 320 oled.TextBox((uint8_t *)text3,70,60,20,15); //Increase textbox for more digits
tdh50 7:46729d931f26 321
tdh50 11:deecd2b72129 322 }
tdh50 12:8db1b8fb5866 323
tdh50 12:8db1b8fb5866 324 // txTask() transmits the sensor data
tdh50 12:8db1b8fb5866 325 void txTask(void)
tdh50 11:deecd2b72129 326 {
tdh50 12:8db1b8fb5866 327 while (true) {
tdh50 12:8db1b8fb5866 328 //UpdateSensorData();
tdh50 12:8db1b8fb5866 329 kw40z_device.SendSetApplicationMode(GUI_CURRENT_APP_SENSOR_TAG);
tdh50 12:8db1b8fb5866 330 //Send Accel Data.
tdh50 12:8db1b8fb5866 331 kw40z_device.SendAccel(x,y,z);
tdh50 16:b09f27c2dbe7 332 Thread::wait(1000);
tdh50 7:46729d931f26 333 }
tdh50 16:b09f27c2dbe7 334 }