mirror of
https://github.com/eclipse/upm.git
synced 2025-07-01 09:21:12 +03:00
kx122: Small fix-ups for kx122 addition
A few small changes for the kx122 library. Signed-off-by: Noel Eck <noel.eck@intel.com>
This commit is contained in:
@ -27,6 +27,7 @@
|
||||
#include <signal.h>
|
||||
|
||||
#include "kx122.h"
|
||||
#include "upm_utilities.h"
|
||||
|
||||
bool shouldRun = true;
|
||||
|
||||
@ -40,6 +41,8 @@ void sig_handler(int signo)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
signal(SIGINT,sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
kx122_context sensor = kx122_init(0,-1,24);
|
||||
if (!sensor)
|
||||
{
|
||||
@ -51,15 +54,18 @@ int main(int argc, char **argv)
|
||||
kx122_device_init(sensor,KX122_ODR_50,HIGH_RES,KX122_RANGE_2G);
|
||||
|
||||
float x,y,z;
|
||||
float wait_time = (kx122_get_sample_period(sensor) * MICRO_S);
|
||||
int wait_time = (kx122_get_sample_period(sensor) * MICRO_S);
|
||||
if (wait_time < 0) wait_time = 1000;
|
||||
|
||||
while(shouldRun){
|
||||
kx122_get_acceleration_data(sensor,&x,&y,&z);
|
||||
|
||||
printf("%.02f | %.02f | %.02f\n",x,y,z);
|
||||
usleep(wait_time);
|
||||
upm_delay_us(wait_time);
|
||||
}
|
||||
|
||||
kx122_close(sensor);
|
||||
//! [Interesting]
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user