Here

Dependencies:   Hexi_KW40Z Hexi_OLED_SSD1351 nRF24L01 FXOS8700

Committer:
tdh50
Date:
Wed Apr 12 21:02:58 2017 +0000
Revision:
19:195a0891e8e9
Parent:
18:9e23169b297a
Child:
21:6d54edeb2f33
Added ability to turn pod oled screen off and on when right bottom button is pressed.

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