upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
Public Member Functions

API for the Curie IMU via Firmata. More...

Detailed Description

Curie IMU is a 6-axis accelerometer

This module has been tested on an Arduino/Genuino 101 running ConfigurableFirmata with CurieIMU

mraa_init();
mraa_add_subplatform(MRAA_GENERIC_FIRMATA, "/dev/ttyACM0");
upm::CurieImu sensor;
std::cout << "temperature is: " << (sensor.getTemperature() * pow(0.5, 9) + 23) << std::endl;
sensor.updateAccel();
int x = sensor.getAccelX(), y = sensor.getAccelY(), z = sensor.getAccelZ();
printf("accelerometer is: %d, %d, %d\n", x, y, z);
sensor.updateGyro();
int a = sensor.getGyroX(), b = sensor.getGyroY(), c = sensor.getGyroZ();
printf("gyroscope is: %d, %d, %d\n", a, b, c);
int axis, direction;
sensor.enableShockDetection(true);
for (int i = 0; i < 300; i++) {
if (sensor.isShockDetected()) {
sensor.getNextShock();
axis = sensor.getAxis();
direction = sensor.getDirection();
printf("shock data is: %d, %d\n", axis, direction);
}
upm_delay_us(10000);
}
sensor.updateMotion();
int m = sensor.getAccelX(), n = sensor.getAccelY(), o = sensor.getAccelZ(),
p = sensor.getGyroX(), q = sensor.getGyroY(), r = sensor.getGyroZ();
printf("motion is: %d, %d, %d, %d, %d, %d\n", m, n, o, p, q, r);

Public Member Functions

 CurieImu (int subplatform_offset=512)
 
 ~CurieImu ()
 
void updateAccel ()
 
void updateGyro ()
 
void updateMotion ()
 
int16_t * getAccel ()
 
int16_t getAccelX ()
 
int16_t getAccelY ()
 
int16_t getAccelZ ()
 
int16_t * getGyro ()
 
int16_t getGyroX ()
 
int16_t getGyroY ()
 
int16_t getGyroZ ()
 
int16_t getTemperature ()
 
int16_t * getMotion ()
 
int16_t getAxis ()
 
int16_t getDirection ()
 
void enableShockDetection (bool enable)
 
bool isShockDetected ()
 
void getNextShock ()
 
void enableStepCounter (bool enable)
 
bool isStepDetected ()
 
int16_t getStepCount ()
 
void enableTapDetection (bool enable)
 
bool isTapDetected ()
 
void getNextTap ()
 
void lock ()
 
void unlock ()
 
void waitForResponse ()
 
void proceed ()
 
void setResults (uint8_t *buf, int length)
 
void processResponse ()
 

Constructor & Destructor Documentation

CurieImu ( int  subplatform_offset = 512)

Instantiates a CurieImu object

Parameters
subplatform_offsetSubplatform offset
~CurieImu ( )

Destructor for CurieImu object

Member Function Documentation

void updateAccel ( )

Updates the latest accelerometer readings by calling Firmata

Here is the call graph for this function:

void updateGyro ( )

Updates the latest gyroscope readings by calling Firmata

Here is the call graph for this function:

void updateMotion ( )

Updates the both the latest accelerometer & gyroscope readings by calling Firmata

Here is the call graph for this function:

int16_t * getAccel ( )

Returns last accelerometer reading X, Y, and Z axis

Returns
pointer to array with X-axis, Y-axis & Z-axis value
int16_t getAccelX ( )

Returns last accelerometer reading X axis

Returns
X-axis value
int16_t getAccelY ( )

Returns last accelerometer reading Y axis

Returns
Y-axis value
int16_t getAccelZ ( )

Returns last accelerometer reading Z axis

Returns
Z-axis value
int16_t * getGyro ( )

Read gyroscope X, Y, and Z axis

Returns
pointer to array with X-axis, Y-axis & Z-axis value
int16_t getGyroX ( )

Returns last gyroscope reading X axis

Returns
X-axis value
int16_t getGyroY ( )

Returns last gyroscope reading Y axis

Returns
Y-axis value
int16_t getGyroZ ( )

Returns last gyroscope reading Z axis

Returns
Z-axis value
int16_t getTemperature ( void  )

Reads the internal temperature

Returns
16-bit integer containing the scaled temperature reading

Here is the call graph for this function:

int16_t * getMotion ( )

Reads the X, Y, and Z axis of both gyroscope and accelerometer

Returns
pointer to array with X-axis, Y-axis & Z-axis values for accelerometer, and then X-axis, Y-axis & Z-axis values for gyroscope
int16_t getAxis ( )

Returns last shock or tap axis reading

Returns
axis value
int16_t getDirection ( )

Returns last shock or tap direction reading

Returns
direction value
void enableShockDetection ( bool  enable)

Turns shock detection notifications on/off

Parameters
enableenables/disables notifications

Here is the call graph for this function:

bool isShockDetected ( )

Has there been a shock detected?

Returns
true if any unprocessed shock notifications are in the queue
void getNextShock ( )

Gets shock detect data from queue. Then m_axis gets axis data, and m_direction gets direction data

void enableStepCounter ( bool  enable)

Turns step counter notifications on/off

Parameters
enableenables/disables notifications

Here is the call graph for this function:

bool isStepDetected ( )

Has there been a step detected?

Returns
true if any unprocessed step notifications are in the queue
int16_t getStepCount ( )

Gets step count data from queue

Returns
the total number of steps taken
void enableTapDetection ( bool  enable)

Turns tap detection notifications on/off

Parameters
enableenables/disables notifications

Here is the call graph for this function:

bool isTapDetected ( )

Has there been a tap detected?

Returns
true if any unprocessed tap notifications are in the queue
void getNextTap ( )

Gets tap detect data from queue. Then m_axis gets axis data, and m_direction gets direction data

void lock ( )

Locks responses from Firmata

Here is the caller graph for this function:

void unlock ( )

Unlocks responses from Firmata

Here is the caller graph for this function:

void waitForResponse ( )

Wait for a response from Firmata before proceeding

Here is the caller graph for this function:

void proceed ( )

Proceed with original function call now that response from Firmata has been received

Here is the caller graph for this function:

void setResults ( uint8_t *  buf,
int  length 
)

Set results being returned from Firmata for processing

Parameters
bufis the buffer
lengthis the length of results buffer

Here is the call graph for this function:

Here is the caller graph for this function:

void processResponse ( )

Processes asyncronous responses returned from Firmata

Here is the caller graph for this function:


The documentation for this class was generated from the following files: