From 27dec638c20271b1b8aff084385d11e74bad39c8 Mon Sep 17 00:00:00 2001 From: dragonprevost Date: Thu, 15 Nov 2018 12:24:59 -0800 Subject: added examples to readme --- readme.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'readme.md') diff --git a/readme.md b/readme.md index 2b48970..83dc5a5 100644 --- a/readme.md +++ b/readme.md @@ -46,5 +46,38 @@ requires: ``` ## Example +For getting the current acceleration +``` +struct Acceleration{ + double x; + double y; + double z; +}; + +struct Acceleration v = value; +le_result_t result = brnkl_motion_getCurrentAccleration(&v->x, &v->y, &v->z); +``` +To get a list of all recent impacts. +``` +double xAcc[N_MAX_IMPACT_VALUES], yAcc[N_MAX_IMPACT_VALUES], zAcc[N_MAX_IMPACT_VALUES]; + uint64_t timestamps[N_MAX_IMPACT_VALUES]; + size_t xSize = N_MAX_IMPACT_VALUES, ySize = N_MAX_IMPACT_VALUES, + zSize = N_MAX_IMPACT_VALUES, timestampsSize = N_MAX_IMPACT_VALUES; + le_result_t r = brnkl_motion_getSuddenImpact( + xAcc, &xSize, yAcc, &ySize, zAcc, &zSize, timestamps, ×tampsSize); + if (r != LE_OK) + return r; + // NOTE this assumes that xSize == ySize == zSize == timestampsSize + // TODO could even assert/log this + int j = 0; + for (int i = 0; i < xSize; i++) { + recordRes[j++] = + le_avdata_RecordFloat(ref, "impactx", xAcc[i], timestamps[i]); + recordRes[j++] = + le_avdata_RecordFloat(ref, "impacty", yAcc[i], timestamps[i]); + recordRes[j++] = + le_avdata_RecordFloat(ref, "impactz", zAcc[i], timestamps[i]); + } +``` -- cgit v1.2.3