diff options
author | dragonprevost <dragon@dkp.io> | 2018-10-22 17:58:18 -0700 |
---|---|---|
committer | dragonprevost <dragon@dkp.io> | 2018-10-22 17:58:18 -0700 |
commit | ee4498a0e5278526fef99776e06ad77cccbbbeb4 (patch) | |
tree | edd761d9238d787ba701585110f2ff7defb1413b /motionMonitor/motionMonitor.c | |
parent | fe5acb3679efa12cce6bea126cc642037d005ef3 (diff) |
slight clean up to increase readability.
Diffstat (limited to 'motionMonitor/motionMonitor.c')
-rw-r--r-- | motionMonitor/motionMonitor.c | 25 |
1 files changed, 2 insertions, 23 deletions
diff --git a/motionMonitor/motionMonitor.c b/motionMonitor/motionMonitor.c index 0f2771a..0e2fbe5 100644 --- a/motionMonitor/motionMonitor.c +++ b/motionMonitor/motionMonitor.c @@ -14,15 +14,11 @@ typedef struct{ double z; } Acceleration; - - double xAccImpact [N_CHANGE_BLOCKS]; double yAccImpact [N_CHANGE_BLOCKS]; double zAccImpact [N_CHANGE_BLOCKS]; uint64_t timestamps [N_CHANGE_BLOCKS]; - - static const char FormatStr[] = "/sys/devices/i2c-0/0-0068/iio:device0/in_%s_%s"; static const char AccType[] = "accel"; static const char GyroType[] = "anglvel"; @@ -89,25 +85,16 @@ done: return r; } -//implement case for full array, or solution to not getting a full array -void recordImpact(double* xAcc, - double* yAcc, - double* zAcc){ - - //time = (unsigned long)time(NULL) +void recordImpact(double* xAcc, double* yAcc, double* zAcc){ timestamps[totalImpacts] = (unsigned long)time(NULL); xAccImpact[totalImpacts] = *xAcc; yAccImpact[totalImpacts] = *yAcc; zAccImpact[totalImpacts] = *zAcc; - totalImpacts++; + LE_INFO("New Impact, totalImpacts: %d", totalImpacts); } -/* -* Return array of sudden impacts(Acceleration) -*/ - le_result_t brnkl_motion_getSuddenImpact(double* xAcc, size_t *xSize, double* yAcc, size_t *ySize, double* zAcc, size_t *zSize) { @@ -131,11 +118,8 @@ le_result_t brnkl_motion_getSuddenImpact(double* xAcc, size_t *xSize, *Sets hasSuddenImpact flag when accelerometer surpasses threshold */ void *impactMonitor(void * ptr){ - double x, y, z; - for(;;){ - brnkl_motion_getCurrentAcceleration(&x, &y, &z); double euclidian = sqrt(x*x + y*y + z*z); @@ -144,14 +128,9 @@ void *impactMonitor(void * ptr){ LE_INFO("euclidian : %f", euclidian); //3. add x, y, z to impact array sem_wait(&impact_mutex); - LE_INFO("addingImpact"); - recordImpact(&x, &y, &z); - sem_post(&impact_mutex); } - - usleep(100*1000); } |