From c5d0a802c38dbc31a784afbd8f10b919c78c28b4 Mon Sep 17 00:00:00 2001 From: dragonprevost Date: Mon, 22 Oct 2018 14:22:02 -0700 Subject: getSuddenImpact is designed to return 3 arrays that hold impact data --- brnkl_motion.api | 6 ++++-- motionMonitor/motionMonitor.c | 37 +++++++++++++++++++++---------------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/brnkl_motion.api b/brnkl_motion.api index f5d3154..fd7c9b5 100644 --- a/brnkl_motion.api +++ b/brnkl_motion.api @@ -1,3 +1,5 @@ -FUNCTION int8 hasSuddenImpact (); -FUNCTION le_result_t getSuddenImpact (double x OUT, double y OUT, double z OUT); +DEFINE N_CHANGE_BLOCKS = 200; + +FUNCTION le_result_t getSuddenImpact (double x [N_CHANGE_BLOCKS] OUT, double y [N_CHANGE_BLOCKS] OUT, double z [N_CHANGE_BLOCKS] OUT); FUNCTION le_result_t getCurrentAcceleration (double x OUT, double y OUT, double z OUT); + \ No newline at end of file diff --git a/motionMonitor/motionMonitor.c b/motionMonitor/motionMonitor.c index 2d2c24b..cc05a0c 100644 --- a/motionMonitor/motionMonitor.c +++ b/motionMonitor/motionMonitor.c @@ -4,7 +4,7 @@ #include #include -#define MAX_ARRAY_SIZE 200 +#define N_CHANGE_BLOCKS 200 void *impactMonitor(void *); @@ -16,9 +16,9 @@ typedef struct{ -double xAccImpact [MAX_ARRAY_SIZE]; -double yAccImpact [MAX_ARRAY_SIZE]; -double zAccImpact [MAX_ARRAY_SIZE]; +double xAccImpact [N_CHANGE_BLOCKS]; +double yAccImpact [N_CHANGE_BLOCKS]; +double zAccImpact [N_CHANGE_BLOCKS]; @@ -88,13 +88,6 @@ done: return r; } -/* -* Return 1 if hardware has been in a sudden impact. -*/ -int8_t brnkl_motion_hasSuddenImpact() { - return 0; -} - //implement case for full array, or solution to not getting a full array void recordImpact(double* xAcc, double* yAcc, @@ -118,11 +111,23 @@ void recordImpact(double* xAcc, * Return array of sudden impacts(Acceleration) */ -le_result_t brnkl_motion_getSuddenImpact(double* xAcc, - double* yAcc, - double* zAcc) { - //Return Array of Sudden Impacts - //*impactArray = impactArr; +le_result_t brnkl_motion_getSuddenImpact(double* xAcc, size_t *xSize, + double* yAcc, size_t *ySize, + double* zAcc, size_t *zSize) { + + if(!totalImpacts) + LE_INFO("No Sudden Impacts to Report"); + + *xSize = *ySize = *zSize = totalImpacts; + + xAcc = xAccImpact; + yAcc = yAccImpact; + zAcc = zAccImpact; + + //Flush Arrays + + totalImpacts = 0; + return LE_OK; } -- cgit v1.2.3