Updates implementation and examples to use dynamic-friendly interface

Signed-off-by: deadprogram <ron@hybridgroup.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
deadprogram
2016-03-18 15:28:40 -07:00
committed by Mihai Tudor Panu
parent 3e7fca21ee
commit 83b0512ffb
4 changed files with 108 additions and 32 deletions

View File

@ -326,6 +326,18 @@ CurieImu::getTemperature()
return result;
}
int16_t
CurieImu::getAxis()
{
return m_axis;
}
int16_t
CurieImu::getDirection()
{
return m_direction;
}
void
CurieImu::enableShockDetection(bool enable)
{
@ -355,15 +367,15 @@ CurieImu::isShockDetected()
}
void
CurieImu::getShockDetectData(int *axis, int *direction)
CurieImu::getNextShock()
{
if (m_shockData.size() > 0) {
IMUDataItem* item = m_shockData.front();
*axis = item->axis;
*direction = item->direction;
m_shockData.pop();
delete item;
}
if (m_shockData.size() > 0) {
IMUDataItem* item = m_shockData.front();
m_axis = item->axis;
m_direction = item->direction;
m_shockData.pop();
delete item;
}
}
void
@ -394,13 +406,15 @@ CurieImu::isStepDetected()
return (m_stepData.size() > 0);
}
void
CurieImu::getStepCount(int *count)
int16_t
CurieImu::getStepCount()
{
int16_t count = 0;
if (m_stepData.size() > 0) {
*count = m_stepData.front();
count = m_stepData.front();
m_stepData.pop();
}
return count;
}
void
@ -432,13 +446,13 @@ CurieImu::isTapDetected()
}
void
CurieImu::getTapDetectData(int *axis, int *direction)
CurieImu::getNextTap()
{
if (m_tapData.size() > 0) {
IMUDataItem* item = m_tapData.front();
*axis = item->axis;
*direction = item->direction;
m_tapData.pop();
delete item;
}
if (m_tapData.size() > 0) {
IMUDataItem* item = m_tapData.front();
m_axis = item->axis;
m_direction = item->direction;
m_tapData.pop();
delete item;
}
}

View File

@ -177,6 +177,20 @@ class CurieImu {
*/
int16_t* getMotion();
/**
* Returns last shock or tap axis reading
*
* @return axis value
*/
int16_t getAxis();
/**
* Returns last shock or tap direction reading
*
* @return direction value
*/
int16_t getDirection();
/**
* Turns shock detection notifications on/off
*
@ -192,12 +206,10 @@ class CurieImu {
bool isShockDetected();
/**
* Gets shock detect data from queue
*
* @param axis gets axis data
* @param direction gets direction data
* Gets shock detect data from queue. Then m_axis gets axis data, and
* m_direction gets direction data
*/
void getShockDetectData(int *axis, int *direction);
void getNextShock();
/**
* Turns step counter notifications on/off
@ -216,9 +228,9 @@ class CurieImu {
/**
* Gets step count data from queue
*
* @param count the total number of steps taken
* @return the total number of steps taken
*/
void getStepCount(int *count);
int16_t getStepCount();
/**
* Turns tap detection notifications on/off
@ -235,12 +247,10 @@ class CurieImu {
bool isTapDetected();
/**
* Gets tap detect data from queue
*
* @param axis gets axis data
* @param direction gets direction data
* Gets tap detect data from queue. Then m_axis gets axis data, and
* m_direction gets direction data
*/
void getTapDetectData(int *axis, int *direction);
void getNextTap();
/**
* Locks responses from Firmata
@ -289,6 +299,9 @@ class CurieImu {
int16_t m_accel[3];
int16_t m_gyro[3];
int16_t m_motion[6];
int16_t m_axis;
int16_t m_direction;
};
}