Here

Dependencies:   Hexi_KW40Z Hexi_OLED_SSD1351 nRF24L01 FXOS8700

Committer:
DeanBritt
Date:
Mon Mar 13 19:24:23 2017 +0000
Revision:
8:5532a9c895be
Parent:
7:46729d931f26
Child:
9:5e63a3928e43
Alert notification added;

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