this is program how build nRF51822 to get ADXL345 data
Dependencies: BLE_API mbed nRF51822
Fork of ADXL345_I2C by
Diff: main.cpp
- Revision:
- 13:e5327d2de406
- Parent:
- 12:58823c0cdf99
- Child:
- 14:afe556cc0a6c
--- a/main.cpp Sat Dec 09 05:48:26 2017 +0000 +++ b/main.cpp Sat Dec 09 06:44:56 2017 +0000 @@ -229,27 +229,27 @@ //formula totvect[i] = sqrt((double)((xaccl[i]-xavg)* (xaccl[i]-xavg))+(double) ((yaccl[i] - yavg)*(yaccl[i] - yavg)) +(double) ((zaccl[i] - zavg)*(zaccl[i] - zavg))); totave[i] = (totvect[i] + totvect[i-1]) / 2 ; - uart1.printf("\t acc: %i\n", (int16_t)totave[i]); + uart1.printf("\tacc:%i", (int16_t)totave[i]); memset(&buffer, 0, sizeof(buffer)); - snprintf(buffer, 20, "\t acc: %d\n", (int16_t)totave[i]); + snprintf(buffer, 20, "\tacc:%d", (int16_t)totave[i]); ble.updateCharacteristicValue(uartServicePtr->getRXCharacteristicHandle(), (uint8_t*)buffer, sizeof(buffer), false); totvel[i]=(totave[i]*0.2); - uart1.printf("\t vel: %i\n", (int16_t)totvel[i]); + uart1.printf("\tvel:%i", (int16_t)totvel[i]); memset(&buffer, 0, sizeof(buffer)); - snprintf(buffer, 20, "\t vel: %d\n", (int16_t)totvel[i]); + snprintf(buffer, 20, "\tvel:%d", (int16_t)totvel[i]); ble.updateCharacteristicValue(uartServicePtr->getRXCharacteristicHandle(), (uint8_t*)buffer, sizeof(buffer), false); totdist[i]=(totvect[i]*(0.2*0.2)/2); - uart1.printf("\t dist: %i\n", (int16_t)totdist[i]); + uart1.printf("\tdist:%i", (int16_t)totdist[i]); memset(&buffer, 0, sizeof(buffer)); - snprintf(buffer, 20, "\tdist: %d\n", (int16_t)totdist[i]); + snprintf(buffer, 20, "\tdist:%d", (int16_t)totdist[i]); ble.updateCharacteristicValue(uartServicePtr->getRXCharacteristicHandle(), (uint8_t*)buffer, sizeof(buffer), false); totheight[i]=sqrt((((xaccl[i]-xavg)* (xaccl[i]-xavg))+ ((yaccl[i] - yavg)*(yaccl[i] - yavg)))*(0.2*0.2)/2); - uart1.printf("\thght: %i\n", (int16_t)totheight[i]); + uart1.printf("\thght:%i", (int16_t)totheight[i]); memset(&buffer, 0, sizeof(buffer)); - snprintf(buffer, 20, "\thght: %d\n", (int16_t)totheight[i]); + snprintf(buffer, 20, "\thght:%d", (int16_t)totheight[i]); ble.updateCharacteristicValue(uartServicePtr->getRXCharacteristicHandle(), (uint8_t*)buffer, sizeof(buffer), false); acc=acc+totave[i]; @@ -268,9 +268,9 @@ } if (totave[i] < threshold && flag == 1) {flag=0;} - uart1.printf("steps: %i\n", (int16_t)steps); + uart1.printf("\nsteps:%i", (int16_t)steps); memset(&buffer, 0, sizeof(buffer)); - snprintf(buffer, 20, "\nsteps: %d\t", (int16_t)steps); + snprintf(buffer, 20, "\nsteps:%d", (int16_t)steps); ble.updateCharacteristicValue(uartServicePtr->getRXCharacteristicHandle(), (uint8_t*)buffer, sizeof(buffer), false); }