diff options
author | dragonprevost <dragon@dkp.io> | 2018-11-15 12:47:57 -0800 |
---|---|---|
committer | dragonprevost <dragon@dkp.io> | 2018-11-15 12:47:57 -0800 |
commit | f595007692362b15bb8bfdac6ae073a56f3709a0 (patch) | |
tree | e36d6533e6c864ddea348e2bb593d64e1750505d | |
parent | 241513bec363481319dd71b6ad3d2040d0c00f8b (diff) |
adjusted example for returning list of impacts
-rw-r--r-- | readme.md | 49 |
1 files changed, 5 insertions, 44 deletions
@@ -63,54 +63,15 @@ 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]; + 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]); - } -``` - -## Examples -For getting a list of impact information you may follow this example. -``` -double x_arr [array_size]; -double y_arr [array_size]; -double z_arr [array_size]; -uint64 timestamps[array_size]; - -// Fills arrays with x, y, and z acceleration that have been recorded at each impact. - -le_result_t result = getSuddenImpact(x_arr, y_arr, z_arr, timestamps); - -for (int i = 0; i < array_size; i++) - LE_INFO("X: %d - Y: %d - Z: %d - time: %ul", x_arr[i], - y_arr[i], - z_arr[i], - timestamps[i]); -``` -For receiving the current acceleration only - + ``` -double x_val; -double y_val; -double z_val; -le_result_t result = getCurrentAcceleration(x_val, y_val, z_val); - -LE_INFO("Current Acceleration: X: %d - Y: %d - Z: %d"); - -``` |