mirror of
https://github.com/eclipse/upm.git
synced 2025-03-15 04:57:30 +03:00
bmx055: remove bma250e, use new bma250e library
Signed-off-by: Jon Trulson <jtrulson@ics.com>
This commit is contained in:
parent
5aed632782
commit
3d0461b40a
@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2016 Intel Corporation.
|
||||
* Copyright (c) 2016-2017 Intel Corporation.
|
||||
*
|
||||
* The MIT License
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
@ -38,14 +40,14 @@ public class BMC150_Example
|
||||
// update our values from the sensor
|
||||
sensor.update();
|
||||
|
||||
float data[] = sensor.getAccelerometer();
|
||||
upm_bmx055.floatVector dataA = sensor.getAccelerometer();
|
||||
|
||||
System.out.println("Accelerometer x: " + data[0]
|
||||
+ " y: " + data[1]
|
||||
+ " z: " + data[2]
|
||||
System.out.println("Accelerometer x: " + dataA.get(0)
|
||||
+ " y: " + dataA.get(1)
|
||||
+ " z: " + dataA.get(2)
|
||||
+ " g");
|
||||
|
||||
data = sensor.getMagnetometer();
|
||||
float data[] = sensor.getMagnetometer();
|
||||
|
||||
System.out.println("Magnetometer x: " + data[0]
|
||||
+ " y: " + data[1]
|
||||
|
@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2016 Intel Corporation.
|
||||
* Copyright (c) 2016-2017 Intel Corporation.
|
||||
*
|
||||
* The MIT License
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
@ -38,18 +40,18 @@ public class BMI055_Example
|
||||
// update our values from the sensor
|
||||
sensor.update();
|
||||
|
||||
float data[] = sensor.getAccelerometer();
|
||||
upm_bmx055.floatVector data = sensor.getAccelerometer();
|
||||
|
||||
System.out.println("Accelerometer x: " + data[0]
|
||||
+ " y: " + data[1]
|
||||
+ " z: " + data[2]
|
||||
System.out.println("Accelerometer x: " + data.get(0)
|
||||
+ " y: " + data.get(1)
|
||||
+ " z: " + data.get(2)
|
||||
+ " g");
|
||||
|
||||
upm_bmx055.floatVector dataG = sensor.getGyroscope();
|
||||
data = sensor.getGyroscope();
|
||||
|
||||
System.out.println("Gyroscope x: " + dataG.get(0)
|
||||
+ " y: " + dataG.get(1)
|
||||
+ " z: " + dataG.get(2)
|
||||
System.out.println("Gyroscope x: " + data.get(0)
|
||||
+ " y: " + data.get(1)
|
||||
+ " z: " + data.get(2)
|
||||
+ " degrees/s");
|
||||
|
||||
System.out.println();
|
||||
|
@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2016 Intel Corporation.
|
||||
* Copyright (c) 2016-2017 Intel Corporation.
|
||||
*
|
||||
* The MIT License
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
@ -38,25 +40,25 @@ public class BMX055_Example
|
||||
// update our values from the sensor
|
||||
sensor.update();
|
||||
|
||||
float data[] = sensor.getAccelerometer();
|
||||
upm_bmx055.floatVector data = sensor.getAccelerometer();
|
||||
|
||||
System.out.println("Accelerometer x: " + data[0]
|
||||
+ " y: " + data[1]
|
||||
+ " z: " + data[2]
|
||||
System.out.println("Accelerometer x: " + data.get(0)
|
||||
+ " y: " + data.get(1)
|
||||
+ " z: " + data.get(2)
|
||||
+ " g");
|
||||
|
||||
upm_bmx055.floatVector dataG = sensor.getGyroscope();
|
||||
data = sensor.getGyroscope();
|
||||
|
||||
System.out.println("Gyroscope x: " + dataG.get(0)
|
||||
+ " y: " + dataG.get(1)
|
||||
+ " z: " + dataG.get(2)
|
||||
System.out.println("Gyroscope x: " + data.get(0)
|
||||
+ " y: " + data.get(1)
|
||||
+ " z: " + data.get(2)
|
||||
+ " degrees/s");
|
||||
|
||||
data = sensor.getMagnetometer();
|
||||
float dataM[] = sensor.getMagnetometer();
|
||||
|
||||
System.out.println("Magnetometer x: " + data[0]
|
||||
+ " y: " + data[1]
|
||||
+ " z: " + data[2]
|
||||
System.out.println("Magnetometer x: " + dataM[0]
|
||||
+ " y: " + dataM[1]
|
||||
+ " z: " + dataM[2]
|
||||
+ " uT");
|
||||
|
||||
System.out.println();
|
||||
|
@ -1,5 +1,5 @@
|
||||
upm_mixed_module_init (NAME bmx055
|
||||
DESCRIPTION "Bosch IMU Sensor Library"
|
||||
CPP_HDR bmx055.hpp bma250e.hpp bmm150.hpp bmc150.cxx bmi055.hpp
|
||||
CPP_SRC bmx055.cxx bma250e.cxx bmm150.cxx bmc150.cxx bmi055.cxx
|
||||
REQUIRES mraa bmg160)
|
||||
CPP_HDR bmx055.hpp bmm150.hpp bmc150.cxx bmi055.hpp
|
||||
CPP_SRC bmx055.cxx bmm150.cxx bmc150.cxx bmi055.cxx
|
||||
REQUIRES mraa bmg160 bma250e)
|
||||
|
@ -1,741 +0,0 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2016 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <string.h>
|
||||
|
||||
#include "bma250e.hpp"
|
||||
|
||||
using namespace upm;
|
||||
using namespace std;
|
||||
|
||||
// conversion from celsius to fahrenheit
|
||||
|
||||
static float c2f(float c)
|
||||
{
|
||||
return (c * (9.0 / 5.0) + 32.0);
|
||||
}
|
||||
|
||||
BMA250E::BMA250E(int bus, int addr, int cs) :
|
||||
m_i2c(0), m_spi(0), m_gpioIntr1(0), m_gpioIntr2(0), m_gpioCS(0)
|
||||
{
|
||||
m_accX = 0;
|
||||
m_accY = 0;
|
||||
m_accZ = 0;
|
||||
m_accScale = 0;
|
||||
m_temperature = 0.0;
|
||||
|
||||
if (addr < 0)
|
||||
{
|
||||
m_addr = 0;
|
||||
m_isSPI = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_addr = uint8_t(addr);
|
||||
m_isSPI = false;
|
||||
}
|
||||
|
||||
if (m_isSPI)
|
||||
{
|
||||
m_spi = new mraa::Spi(bus);
|
||||
|
||||
// Only create cs context if we are actually using a valid pin.
|
||||
// A hardware controlled pin should specify cs as -1.
|
||||
if (cs >= 0)
|
||||
{
|
||||
m_gpioCS = new mraa::Gpio(cs);
|
||||
m_gpioCS->dir(mraa::DIR_OUT);
|
||||
}
|
||||
|
||||
m_spi->mode(mraa::SPI_MODE0);
|
||||
m_spi->frequency(5000000);
|
||||
}
|
||||
else
|
||||
{
|
||||
// I2C
|
||||
m_i2c = new mraa::I2c(bus);
|
||||
|
||||
mraa::Result rv;
|
||||
if ((rv = m_i2c->address(m_addr)) != mraa::SUCCESS)
|
||||
{
|
||||
throw std::runtime_error(string(__FUNCTION__) +
|
||||
": I2c.address() failed");
|
||||
}
|
||||
}
|
||||
|
||||
// check the chip id
|
||||
|
||||
uint8_t chipID = getChipID();
|
||||
|
||||
m_useFIFO = false;
|
||||
|
||||
// check the various chips id's and set appropriate capabilities.
|
||||
// Bail if the chip id is unknown.
|
||||
switch (chipID)
|
||||
{
|
||||
case 0xf9: // standalone bma250e
|
||||
m_resolution = RESOLUTION_10BITS;
|
||||
m_fifoAvailable = true;
|
||||
|
||||
break;
|
||||
|
||||
case 0xfa: // bmx055, bmi055 variants, 12b resolution
|
||||
m_resolution = RESOLUTION_12BITS;
|
||||
m_fifoAvailable = true;
|
||||
|
||||
break;
|
||||
|
||||
case 0x03: // bmc050 variant, no FIFO, 12b resolution
|
||||
m_resolution = RESOLUTION_12BITS;
|
||||
m_fifoAvailable = false;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
throw std::runtime_error(string(__FUNCTION__)
|
||||
+ ": invalid chip ID. Expected "
|
||||
+ "3, 249, or 250 "
|
||||
+ ", got "
|
||||
+ std::to_string(int(chipID)));
|
||||
}
|
||||
|
||||
// call init with default options
|
||||
init();
|
||||
}
|
||||
|
||||
BMA250E::~BMA250E()
|
||||
{
|
||||
uninstallISR(INTERRUPT_INT1);
|
||||
uninstallISR(INTERRUPT_INT2);
|
||||
|
||||
if (m_i2c)
|
||||
delete m_i2c;
|
||||
if (m_spi)
|
||||
delete m_spi;
|
||||
if(m_gpioCS)
|
||||
delete m_gpioCS;
|
||||
}
|
||||
|
||||
void BMA250E::init(POWER_MODE_T pwr, RANGE_T range, BW_T bw)
|
||||
{
|
||||
setPowerMode(pwr);
|
||||
usleep(50000); // 50ms, in case we are waking up
|
||||
|
||||
// set our range and bandwidth
|
||||
setRange(range);
|
||||
setBandwidth(bw);
|
||||
|
||||
// make sure register shadowing is enabled
|
||||
enableRegisterShadowing(true);
|
||||
|
||||
// enable output filtering
|
||||
enableOutputFiltering(true);
|
||||
|
||||
// use the FIFO by default, if we have one
|
||||
fifoConfig(FIFO_MODE_BYPASS, FIFO_DATA_SEL_XYZ);
|
||||
enableFIFO(true);
|
||||
|
||||
// make sure low power mode LPM2 is enabled in case we go to low
|
||||
// power or suspend mode. LPM1 mode (the default) requires register
|
||||
// writes to be drastically slowed down when enabled, which we
|
||||
// cannot handle.
|
||||
setLowPowerMode2();
|
||||
|
||||
// settle
|
||||
usleep(50000);
|
||||
}
|
||||
|
||||
void BMA250E::update()
|
||||
{
|
||||
int bufLen = 7; // max, non-FIFO
|
||||
uint8_t startReg = REG_ACCD_X_LSB;
|
||||
|
||||
if (m_useFIFO)
|
||||
{
|
||||
bufLen = 6;
|
||||
startReg = REG_FIFO_DATA;
|
||||
}
|
||||
|
||||
uint8_t buf[bufLen];
|
||||
|
||||
if (readRegs(startReg, buf, bufLen) != bufLen)
|
||||
{
|
||||
throw std::runtime_error(string(__FUNCTION__)
|
||||
+ ": readRegs() failed to read "
|
||||
+ std::to_string(bufLen)
|
||||
+ " bytes");
|
||||
}
|
||||
|
||||
uint8_t mask, shift;
|
||||
float divisor;
|
||||
|
||||
switch (m_resolution)
|
||||
{
|
||||
case RESOLUTION_10BITS:
|
||||
mask = _ACCD10_LSB_MASK;
|
||||
shift = _ACCD10_LSB_SHIFT;
|
||||
divisor = 64.0;
|
||||
|
||||
break;
|
||||
|
||||
case RESOLUTION_12BITS:
|
||||
mask = _ACCD12_LSB_MASK;
|
||||
shift = _ACCD12_LSB_SHIFT;
|
||||
divisor = 16.0;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
throw std::logic_error(string(__FUNCTION__)
|
||||
+ ": internal error: invalid resolution "
|
||||
+ std::to_string(int(m_resolution)));
|
||||
}
|
||||
|
||||
int16_t val;
|
||||
|
||||
// x
|
||||
val = int16_t(buf[1] << 8 | (buf[0] & (mask << shift)));
|
||||
m_accX = float(val / divisor);
|
||||
|
||||
// y
|
||||
val = int16_t(buf[3] << 8 | (buf[2] & (mask << shift)));
|
||||
m_accY = float(val / divisor);
|
||||
|
||||
// z
|
||||
val = int16_t(buf[5] << 8 | (buf[4] & (mask << shift)));
|
||||
m_accZ = float(val / divisor);
|
||||
|
||||
// get the temperature...
|
||||
|
||||
uint8_t temp = 0;
|
||||
if (m_useFIFO)
|
||||
{
|
||||
// we have to read temperature separately...
|
||||
temp = readReg(REG_TEMP);
|
||||
}
|
||||
else
|
||||
{
|
||||
// we've already got it
|
||||
temp = buf[6];
|
||||
}
|
||||
|
||||
// .5K/LSB, 23C center point
|
||||
m_temperature = (float(temp) / 2.0) + 23.0;
|
||||
}
|
||||
|
||||
void BMA250E::enableFIFO(bool useFIFO)
|
||||
{
|
||||
if (m_fifoAvailable)
|
||||
m_useFIFO = useFIFO;
|
||||
}
|
||||
|
||||
uint8_t BMA250E::readReg(uint8_t reg)
|
||||
{
|
||||
if (m_isSPI)
|
||||
{
|
||||
reg |= 0x80; // needed for read
|
||||
uint8_t pkt[2] = {reg, 0};
|
||||
|
||||
csOn();
|
||||
if (m_spi->transfer(pkt, pkt, 2))
|
||||
{
|
||||
csOff();
|
||||
throw std::runtime_error(string(__FUNCTION__)
|
||||
+ ": Spi.transfer() failed");
|
||||
}
|
||||
csOff();
|
||||
|
||||
return pkt[1];
|
||||
}
|
||||
else
|
||||
return m_i2c->readReg(reg);
|
||||
}
|
||||
|
||||
int BMA250E::readRegs(uint8_t reg, uint8_t *buffer, int len)
|
||||
{
|
||||
if (m_isSPI)
|
||||
{
|
||||
reg |= 0x80; // needed for read
|
||||
|
||||
uint8_t sbuf[len + 1];
|
||||
memset((char *)sbuf, 0, len + 1);
|
||||
sbuf[0] = reg;
|
||||
|
||||
// We need to do it this way for edison - ie: use a single
|
||||
// transfer rather than breaking it up into two like we used to.
|
||||
// This means a buffer copy is now required, but that's the way
|
||||
// it goes.
|
||||
|
||||
csOn();
|
||||
if (m_spi->transfer(sbuf, sbuf, len + 1))
|
||||
{
|
||||
csOff();
|
||||
throw std::runtime_error(string(__FUNCTION__)
|
||||
+ ": Spi.transfer(buf) failed");
|
||||
}
|
||||
csOff();
|
||||
|
||||
// now copy it into user buffer
|
||||
for (int i=0; i<len; i++)
|
||||
buffer[i] = sbuf[i + 1];
|
||||
|
||||
return len;
|
||||
}
|
||||
else
|
||||
return m_i2c->readBytesReg(reg, buffer, len);
|
||||
}
|
||||
|
||||
void BMA250E::writeReg(uint8_t reg, uint8_t val)
|
||||
{
|
||||
if (m_isSPI)
|
||||
{
|
||||
reg &= 0x7f; // mask off 0x80 for writing
|
||||
uint8_t pkt[2] = {reg, val};
|
||||
|
||||
csOn();
|
||||
if (m_spi->transfer(pkt, NULL, 2))
|
||||
{
|
||||
csOff();
|
||||
throw std::runtime_error(string(__FUNCTION__)
|
||||
+ ": Spi.transfer() failed");
|
||||
}
|
||||
csOff();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_i2c->writeReg(reg, val) != mraa::SUCCESS)
|
||||
{
|
||||
throw std::runtime_error(std::string(__FUNCTION__)
|
||||
+ ": I2c.writeReg() failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BMA250E::csOn()
|
||||
{
|
||||
if (m_gpioCS)
|
||||
m_gpioCS->write(0);
|
||||
}
|
||||
|
||||
void BMA250E::csOff()
|
||||
{
|
||||
if (m_gpioCS)
|
||||
m_gpioCS->write(1);
|
||||
}
|
||||
|
||||
uint8_t BMA250E::getChipID()
|
||||
{
|
||||
return readReg(REG_CHIP_ID);
|
||||
}
|
||||
|
||||
void BMA250E::getAccelerometer(float *x, float *y, float *z)
|
||||
{
|
||||
if (x)
|
||||
*x = (m_accX * m_accScale) / 1000.0;
|
||||
|
||||
if (y)
|
||||
*y = (m_accY * m_accScale) / 1000.0;
|
||||
|
||||
if (z)
|
||||
*z = (m_accZ * m_accScale) / 1000.0;
|
||||
}
|
||||
|
||||
float *BMA250E::getAccelerometer()
|
||||
{
|
||||
static float v[3];
|
||||
|
||||
getAccelerometer(&v[0], &v[1], &v[2]);
|
||||
return v;
|
||||
}
|
||||
|
||||
float BMA250E::getTemperature(bool fahrenheit)
|
||||
{
|
||||
if (fahrenheit)
|
||||
return c2f(m_temperature);
|
||||
else
|
||||
return m_temperature;
|
||||
}
|
||||
|
||||
void BMA250E::reset()
|
||||
{
|
||||
writeReg(REG_SOFTRESET, BMA250E_RESET_BYTE);
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
void BMA250E::setRange(RANGE_T range)
|
||||
{
|
||||
switch (m_resolution)
|
||||
{
|
||||
case RESOLUTION_10BITS:
|
||||
switch(range)
|
||||
{
|
||||
case RANGE_2G:
|
||||
m_accScale = 3.91; // milli-gravities
|
||||
break;
|
||||
|
||||
case RANGE_4G:
|
||||
m_accScale = 7.81;
|
||||
break;
|
||||
|
||||
case RANGE_8G:
|
||||
m_accScale = 15.63;
|
||||
break;
|
||||
|
||||
case RANGE_16G:
|
||||
m_accScale = 31.25;
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case RESOLUTION_12BITS:
|
||||
switch(range)
|
||||
{
|
||||
case RANGE_2G:
|
||||
m_accScale = 0.98; // milli-gravities
|
||||
break;
|
||||
|
||||
case RANGE_4G:
|
||||
m_accScale = 1.95;
|
||||
break;
|
||||
|
||||
case RANGE_8G:
|
||||
m_accScale = 3.91;
|
||||
break;
|
||||
|
||||
case RANGE_16G:
|
||||
m_accScale = 7.81;
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
writeReg(REG_PMU_RANGE, range);
|
||||
}
|
||||
|
||||
void BMA250E::setBandwidth(BW_T bw)
|
||||
{
|
||||
writeReg(REG_PMU_BW, bw);
|
||||
}
|
||||
|
||||
void BMA250E::setPowerMode(POWER_MODE_T power)
|
||||
{
|
||||
// mask off reserved bits
|
||||
uint8_t reg = readReg(REG_PMU_LPW) & ~_PMU_LPW_RESERVED_MASK;
|
||||
|
||||
reg &= ~(_PMU_LPW_POWER_MODE_MASK << _PMU_LPW_POWER_MODE_SHIFT);
|
||||
reg |= (power << _PMU_LPW_POWER_MODE_SHIFT);
|
||||
|
||||
writeReg(REG_PMU_LPW, power);
|
||||
}
|
||||
|
||||
void BMA250E::fifoSetWatermark(int wm)
|
||||
{
|
||||
// do nothing if we don't have a FIFO
|
||||
if (!m_fifoAvailable)
|
||||
return;
|
||||
|
||||
// mask off illegal values
|
||||
uint8_t reg = uint8_t(wm) & _FIFO_CONFIG_0_WATER_MARK_MASK;
|
||||
|
||||
writeReg(REG_FIFO_CONFIG_0, reg);
|
||||
}
|
||||
|
||||
void BMA250E::fifoConfig(FIFO_MODE_T mode, FIFO_DATA_SEL_T axes)
|
||||
{
|
||||
// do nothing if we don't have a FIFO
|
||||
if (!m_fifoAvailable)
|
||||
return;
|
||||
|
||||
uint8_t reg = ( (mode << _FIFO_CONFIG_1_FIFO_MODE_SHIFT) |
|
||||
(axes << _FIFO_CONFIG_1_FIFO_DATA_SHIFT) );
|
||||
|
||||
writeReg(REG_FIFO_CONFIG_1, reg);
|
||||
}
|
||||
|
||||
void BMA250E::setSelfTest(bool sign, bool amp, SELFTTEST_AXIS_T axis)
|
||||
{
|
||||
uint8_t reg = (axis << _PMU_SELFTTEST_AXIS_SHIFT);
|
||||
|
||||
if (amp)
|
||||
reg |= PMU_SELFTTEST_AMP;
|
||||
|
||||
if (sign)
|
||||
reg |= PMU_SELFTTEST_SIGN;
|
||||
|
||||
writeReg(REG_PMU_SELFTEST, reg);
|
||||
}
|
||||
|
||||
uint8_t BMA250E::getInterruptEnable0()
|
||||
{
|
||||
return readReg(REG_INT_EN_0) & ~_INT_EN_0_RESERVED_BITS;
|
||||
}
|
||||
|
||||
void BMA250E::setInterruptEnable0(uint8_t bits)
|
||||
{
|
||||
uint8_t reg = bits & ~_INT_EN_0_RESERVED_BITS;
|
||||
|
||||
writeReg(REG_INT_EN_0, reg);
|
||||
}
|
||||
|
||||
uint8_t BMA250E::getInterruptEnable1()
|
||||
{
|
||||
return readReg(REG_INT_EN_1) & ~_INT_EN_1_RESERVED_BITS;
|
||||
}
|
||||
|
||||
void BMA250E::setInterruptEnable1(uint8_t bits)
|
||||
{
|
||||
uint8_t reg = bits & ~_INT_EN_1_RESERVED_BITS;
|
||||
|
||||
writeReg(REG_INT_EN_1, reg);
|
||||
}
|
||||
|
||||
uint8_t BMA250E::getInterruptEnable2()
|
||||
{
|
||||
return readReg(REG_INT_EN_2) & ~_INT_EN_2_RESERVED_BITS;
|
||||
}
|
||||
|
||||
void BMA250E::setInterruptEnable2(uint8_t bits)
|
||||
{
|
||||
uint8_t reg = bits & ~_INT_EN_2_RESERVED_BITS;
|
||||
|
||||
writeReg(REG_INT_EN_2, reg);
|
||||
}
|
||||
|
||||
uint8_t BMA250E::getInterruptMap0()
|
||||
{
|
||||
return readReg(REG_INT_MAP_0);
|
||||
}
|
||||
|
||||
void BMA250E::setInterruptMap0(uint8_t bits)
|
||||
{
|
||||
writeReg(REG_INT_MAP_0, bits);
|
||||
}
|
||||
|
||||
uint8_t BMA250E::getInterruptMap1()
|
||||
{
|
||||
return readReg(REG_INT_MAP_1) & ~_INT_MAP_1_INT1_RESERVED_BITS;
|
||||
}
|
||||
|
||||
void BMA250E::setInterruptMap1(uint8_t bits)
|
||||
{
|
||||
uint8_t reg = bits & ~_INT_MAP_1_INT1_RESERVED_BITS;
|
||||
|
||||
writeReg(REG_INT_MAP_1, reg);
|
||||
}
|
||||
|
||||
uint8_t BMA250E::getInterruptMap2()
|
||||
{
|
||||
return readReg(REG_INT_MAP_2);
|
||||
}
|
||||
|
||||
void BMA250E::setInterruptMap2(uint8_t bits)
|
||||
{
|
||||
writeReg(REG_INT_MAP_2, bits);
|
||||
}
|
||||
|
||||
uint8_t BMA250E::getInterruptSrc()
|
||||
{
|
||||
return readReg(REG_INT_SRC) & ~_INT_SRC_RESERVED_BITS;
|
||||
}
|
||||
|
||||
void BMA250E::setInterruptSrc(uint8_t bits)
|
||||
{
|
||||
uint8_t reg = bits & ~_INT_SRC_RESERVED_BITS;
|
||||
|
||||
writeReg(REG_INT_SRC, reg);
|
||||
}
|
||||
|
||||
uint8_t BMA250E::getInterruptOutputControl()
|
||||
{
|
||||
return readReg(REG_INT_OUT_CTRL) & ~_INT_OUT_CTRL_INT1_RESERVED_BITS;
|
||||
}
|
||||
|
||||
void BMA250E::setInterruptOutputControl(uint8_t bits)
|
||||
{
|
||||
uint8_t reg = bits & ~_INT_OUT_CTRL_INT1_RESERVED_BITS;
|
||||
|
||||
writeReg(REG_INT_OUT_CTRL, reg);
|
||||
}
|
||||
|
||||
void BMA250E::clearInterruptLatches()
|
||||
{
|
||||
uint8_t reg = readReg(REG_INT_RST_LATCH) & ~_INT_RST_LATCH_RESERVED_BITS;
|
||||
|
||||
reg |= INT_RST_LATCH_RESET_INT;
|
||||
|
||||
writeReg(REG_INT_RST_LATCH, reg);
|
||||
}
|
||||
|
||||
BMA250E::RST_LATCH_T BMA250E::getInterruptLatchBehavior()
|
||||
{
|
||||
uint8_t reg = readReg(REG_INT_RST_LATCH) & ~_INT_RST_LATCH_RESERVED_BITS;
|
||||
|
||||
reg &= (_INT_RST_LATCH_MASK << _INT_RST_LATCH_SHIFT);
|
||||
|
||||
return static_cast<RST_LATCH_T>(reg);
|
||||
}
|
||||
|
||||
void BMA250E::setInterruptLatchBehavior(RST_LATCH_T latch)
|
||||
{
|
||||
uint8_t reg = readReg(REG_INT_RST_LATCH) & ~_INT_RST_LATCH_RESERVED_BITS;
|
||||
|
||||
reg &= ~(_INT_RST_LATCH_MASK << _INT_RST_LATCH_SHIFT);
|
||||
reg |= (latch << _INT_RST_LATCH_SHIFT);
|
||||
|
||||
writeReg(REG_INT_RST_LATCH, reg);
|
||||
}
|
||||
|
||||
void BMA250E::enableRegisterShadowing(bool shadow)
|
||||
{
|
||||
uint8_t reg = readReg(REG_ACC_HBW) & ~_ACC_HBW_RESERVED_BITS;
|
||||
|
||||
if (shadow)
|
||||
reg &= ~ACC_HBW_SHADOW_DIS;
|
||||
else
|
||||
reg |= ACC_HBW_SHADOW_DIS;
|
||||
|
||||
writeReg(REG_ACC_HBW, reg);
|
||||
}
|
||||
|
||||
void BMA250E::enableOutputFiltering(bool filter)
|
||||
{
|
||||
uint8_t reg = readReg(REG_ACC_HBW) & ~_ACC_HBW_RESERVED_BITS;
|
||||
|
||||
if (filter)
|
||||
reg &= ~ACC_HBW_DATA_HIGH_BW;
|
||||
else
|
||||
reg |= ACC_HBW_DATA_HIGH_BW;
|
||||
|
||||
writeReg(REG_ACC_HBW, reg);
|
||||
}
|
||||
|
||||
uint8_t BMA250E::getInterruptStatus0()
|
||||
{
|
||||
return readReg(REG_INT_STATUS_0);
|
||||
}
|
||||
|
||||
uint8_t BMA250E::getInterruptStatus1()
|
||||
{
|
||||
return readReg(REG_INT_STATUS_1) & ~_INT_STATUS_1_RESERVED_BITS;
|
||||
}
|
||||
|
||||
uint8_t BMA250E::getInterruptStatus2()
|
||||
{
|
||||
return readReg(REG_INT_STATUS_2);
|
||||
}
|
||||
|
||||
uint8_t BMA250E::getInterruptStatus3Bits()
|
||||
{
|
||||
// filter out the orientation bitfield..
|
||||
return readReg(REG_INT_STATUS_3) &
|
||||
~(_INT_STATUS_3_ORIENT_MASK << _INT_STATUS_3_ORIENT_SHIFT);
|
||||
}
|
||||
|
||||
BMA250E::ORIENT_T BMA250E::getInterruptStatus3Orientation()
|
||||
{
|
||||
// grab just the orientation bitfield
|
||||
uint8_t reg = readReg(REG_INT_STATUS_3) &
|
||||
(_INT_STATUS_3_ORIENT_MASK << _INT_STATUS_3_ORIENT_SHIFT);
|
||||
|
||||
reg >>= _INT_STATUS_3_ORIENT_SHIFT;
|
||||
|
||||
return static_cast<ORIENT_T>(reg);
|
||||
}
|
||||
|
||||
void BMA250E::setLowPowerMode2()
|
||||
{
|
||||
uint8_t reg = readReg(REG_PMU_LOW_POWER) & ~_LOW_POWER_RESERVED_BITS;
|
||||
|
||||
// we simply set the low power mode to 2. Low power mode 1 slows
|
||||
// down register write accesses, and we can't handle that. In the
|
||||
// words of the late Admiral Akbar: "We cannot handle firepower of
|
||||
// that magnitude!" :(
|
||||
|
||||
reg |= LOW_POWER_LOWPOWER_MODE;
|
||||
|
||||
writeReg(REG_PMU_LOW_POWER, reg);
|
||||
}
|
||||
|
||||
#if defined(SWIGJAVA) || (JAVACALLBACK)
|
||||
void BMA250E::installISR(INTERRUPT_PINS_T intr, int gpio, mraa::Edge level,
|
||||
jobject runnable)
|
||||
{
|
||||
// delete any existing ISR and GPIO context
|
||||
uninstallISR(intr);
|
||||
|
||||
// create gpio context
|
||||
getPin(intr) = new mraa::Gpio(gpio);
|
||||
|
||||
getPin(intr)->dir(mraa::DIR_IN);
|
||||
getPin(intr)->isr(level, runnable);
|
||||
}
|
||||
#else
|
||||
void BMA250E::installISR(INTERRUPT_PINS_T intr, int gpio, mraa::Edge level,
|
||||
void (*isr)(void *), void *arg)
|
||||
{
|
||||
// delete any existing ISR and GPIO context
|
||||
uninstallISR(intr);
|
||||
|
||||
// create gpio context
|
||||
getPin(intr) = new mraa::Gpio(gpio);
|
||||
|
||||
getPin(intr)->dir(mraa::DIR_IN);
|
||||
getPin(intr)->isr(level, isr, arg);
|
||||
}
|
||||
#endif
|
||||
|
||||
void BMA250E::uninstallISR(INTERRUPT_PINS_T intr)
|
||||
{
|
||||
if (getPin(intr))
|
||||
{
|
||||
getPin(intr)->isrExit();
|
||||
delete getPin(intr);
|
||||
|
||||
getPin(intr) = 0;
|
||||
}
|
||||
}
|
||||
|
||||
mraa::Gpio*& BMA250E::getPin(INTERRUPT_PINS_T intr)
|
||||
{
|
||||
switch(intr)
|
||||
{
|
||||
case INTERRUPT_INT1:
|
||||
return m_gpioIntr1;
|
||||
break;
|
||||
|
||||
case INTERRUPT_INT2:
|
||||
return m_gpioIntr2;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw std::out_of_range(string(__FUNCTION__) +
|
||||
": Invalid interrupt enum passed");
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2016 Intel Corporation.
|
||||
* Copyright (c) 2016-2017 Intel Corporation.
|
||||
*
|
||||
* The MIT License
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
@ -34,87 +36,84 @@ using namespace std;
|
||||
|
||||
BMC150::BMC150(int accelBus, int accelAddr, int accelCS,
|
||||
int magBus, int magAddr, int magCS) :
|
||||
m_accel(0), m_mag(0)
|
||||
m_accel(0), m_mag(0)
|
||||
{
|
||||
// if -1 is supplied as a bus for any of these, we will not
|
||||
// instantiate them
|
||||
// if -1 is supplied as a bus for any of these, we will not
|
||||
// instantiate them
|
||||
|
||||
if (accelBus >= 0)
|
||||
m_accel = new BMA250E(accelBus, accelAddr, accelCS);
|
||||
if (accelBus >= 0)
|
||||
m_accel = new BMA250E(accelBus, accelAddr, accelCS);
|
||||
|
||||
if (magBus >= 0)
|
||||
m_mag = new BMM150(magBus, magAddr, magCS);
|
||||
if (magBus >= 0)
|
||||
m_mag = new BMM150(magBus, magAddr, magCS);
|
||||
|
||||
// now initialize them...
|
||||
if (m_accel)
|
||||
m_accel->init();
|
||||
// now initialize them...
|
||||
if (m_accel)
|
||||
m_accel->init();
|
||||
|
||||
if (m_mag)
|
||||
m_mag->init();
|
||||
if (m_mag)
|
||||
m_mag->init();
|
||||
}
|
||||
|
||||
BMC150::~BMC150()
|
||||
{
|
||||
if (m_accel)
|
||||
delete m_accel;
|
||||
if (m_accel)
|
||||
delete m_accel;
|
||||
|
||||
if (m_mag)
|
||||
delete m_mag;
|
||||
if (m_mag)
|
||||
delete m_mag;
|
||||
}
|
||||
|
||||
void BMC150::initAccelerometer(BMA250E::POWER_MODE_T pwr,
|
||||
BMA250E::RANGE_T range,
|
||||
BMA250E::BW_T bw)
|
||||
void BMC150::initAccelerometer(BMA250E_POWER_MODE_T pwr,
|
||||
BMA250E_RANGE_T range,
|
||||
BMA250E_BW_T bw)
|
||||
{
|
||||
if (m_accel)
|
||||
m_accel->init(pwr, range, bw);
|
||||
if (m_accel)
|
||||
m_accel->init(pwr, range, bw);
|
||||
}
|
||||
|
||||
void BMC150::initMagnetometer(BMM150::USAGE_PRESETS_T usage)
|
||||
{
|
||||
if (m_mag)
|
||||
m_mag->init(usage);
|
||||
if (m_mag)
|
||||
m_mag->init(usage);
|
||||
}
|
||||
|
||||
void BMC150::update()
|
||||
{
|
||||
if (m_accel)
|
||||
m_accel->update();
|
||||
if (m_accel)
|
||||
m_accel->update();
|
||||
|
||||
if (m_mag)
|
||||
m_mag->update();
|
||||
if (m_mag)
|
||||
m_mag->update();
|
||||
}
|
||||
|
||||
void BMC150::getAccelerometer(float *x, float *y, float *z)
|
||||
{
|
||||
if (m_accel)
|
||||
m_accel->getAccelerometer(x, y, z);
|
||||
if (m_accel)
|
||||
m_accel->getAccelerometer(x, y, z);
|
||||
}
|
||||
|
||||
float *BMC150::getAccelerometer()
|
||||
std::vector<float> BMC150::getAccelerometer()
|
||||
{
|
||||
if (m_accel)
|
||||
return m_accel->getAccelerometer();
|
||||
else
|
||||
{
|
||||
static float v[3] = {0.0f, 0.0f, 0.0f};
|
||||
return v;
|
||||
}
|
||||
if (m_accel)
|
||||
return m_accel->getAccelerometer();
|
||||
else
|
||||
return {0, 0, 0};
|
||||
}
|
||||
|
||||
void BMC150::getMagnetometer(float *x, float *y, float *z)
|
||||
{
|
||||
if (m_mag)
|
||||
m_mag->getMagnetometer(x, y, z);
|
||||
if (m_mag)
|
||||
m_mag->getMagnetometer(x, y, z);
|
||||
}
|
||||
|
||||
float *BMC150::getMagnetometer()
|
||||
{
|
||||
if (m_mag)
|
||||
return m_mag->getMagnetometer();
|
||||
else
|
||||
if (m_mag)
|
||||
return m_mag->getMagnetometer();
|
||||
else
|
||||
{
|
||||
static float v[3] = {0.0f, 0.0f, 0.0f};
|
||||
return v;
|
||||
static float v[3] = {0.0f, 0.0f, 0.0f};
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2016 Intel Corporation.
|
||||
* Copyright (c) 2016-2017 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
@ -24,6 +24,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "bma250e.hpp"
|
||||
#include "bmm150.hpp"
|
||||
@ -34,163 +35,162 @@
|
||||
|
||||
namespace upm {
|
||||
|
||||
/**
|
||||
* @library bmx055
|
||||
* @sensor bmc150
|
||||
* @comname 6-axis Ecompass
|
||||
* @type accelerometer compass
|
||||
* @man bosch
|
||||
* @con i2c gpio spi
|
||||
* @web http://www.bosch-sensortec.com/en/bst/products/all_products/homepage_1_ohne_marginalspalte_52
|
||||
*
|
||||
* @brief API for the BMC150 6-axis eCompass
|
||||
*
|
||||
*
|
||||
* The BMC150 is an integrated electronic compass solution for
|
||||
* consumer market applications. It comprises a 12bit leading edge
|
||||
* triaxial, low-g acceleration sensor and an ultra-low power, high
|
||||
* precision triaxial magnetic field sensor. It allows measurements
|
||||
* of acceleration and magnetic field in three perpendicular
|
||||
* axes. Performance and features of both sensing technologies are
|
||||
* carefully tuned and perfectly match the demanding requirements of
|
||||
* all 6-axis mobile applications such as electronic compass,
|
||||
* navigation or augmented reality.
|
||||
|
||||
* The BMC150 is essentially 2 separate devices in one: the BMA250E
|
||||
* Accelerometer and the BMM150 Magnetometer. They are completely
|
||||
* independant of each other.
|
||||
*
|
||||
* This driver provides a very simple interface to these 2 devices.
|
||||
* If finer control is desired, you should just use the separate
|
||||
* BMA25E and BMM150 device classes directly. This driver simply
|
||||
* initializes both devices, and provides a mechanism to read
|
||||
* accelerometer and magnetometer data from them.
|
||||
*
|
||||
* @snippet bmc150.cxx Interesting
|
||||
*/
|
||||
|
||||
class BMC150 {
|
||||
public:
|
||||
/**
|
||||
* BMC150 constructor.
|
||||
* @library bmx055
|
||||
* @sensor bmc150
|
||||
* @comname 6-axis Ecompass
|
||||
* @type accelerometer compass
|
||||
* @man bosch
|
||||
* @con i2c gpio spi
|
||||
* @web http://www.bosch-sensortec.com/en/bst/products/all_products/homepage_1_ohne_marginalspalte_52
|
||||
*
|
||||
* This device can support both I2C and SPI. For SPI, set the addr
|
||||
* to -1, and specify a positive integer representing the Chip
|
||||
* Select (CS) pin for the cs argument. If you are using a
|
||||
* hardware CS pin (like edison with arduino breakout), then you
|
||||
* can connect the proper pin to the hardware CS pin on your MCU
|
||||
* and supply -1 for cs. The default operating mode is I2C.
|
||||
* @brief API for the BMC150 6-axis eCompass
|
||||
*
|
||||
* @param accelBus I2C or SPI bus to use. -1 to skip initializing
|
||||
* this device.
|
||||
* @param accelAddr The address for this device. -1 for SPI.
|
||||
* @param accelCS The gpio pin to use for the SPI Chip Select. -1 for
|
||||
* I2C or for SPI with a hardware controlled pin.
|
||||
* @param magBus I2C or SPI bus to use. -1 to skip initializing
|
||||
* this device.
|
||||
* @param magAddr The address for this device. -1 for SPI.
|
||||
* @param magCS The gpio pin to use for the SPI Chip Select. -1 for
|
||||
* I2C or for SPI with a hardware controlled pin.
|
||||
*/
|
||||
BMC150(int accelBus=BMC150_DEFAULT_BUS,
|
||||
int accelAddr=BMC150_DEFAULT_ACC_ADDR,
|
||||
int accelCS=-1,
|
||||
int magBus=BMC150_DEFAULT_BUS,
|
||||
int magAddr=BMC150_DEFAULT_MAG_ADDR,
|
||||
int magCS=-1);
|
||||
|
||||
/**
|
||||
* BMC150 Destructor.
|
||||
*/
|
||||
~BMC150();
|
||||
|
||||
/**
|
||||
* Update the internal stored values from sensor data.
|
||||
*/
|
||||
void update();
|
||||
|
||||
/**
|
||||
* Initialize the accelerometer and start operation. This
|
||||
* function is called from the constructor so will not typically
|
||||
* need to be called by a user unless the device is reset or you
|
||||
* want to change these values.
|
||||
*
|
||||
* @param pwr One of the BMA250E::POWER_MODE_T values. The default is
|
||||
* BMA250E::POWER_MODE_NORMAL.
|
||||
* @param range One of the BMA250E::RANGE_T values. The default is
|
||||
* BMA250E::RANGE_2G.
|
||||
* @param bw One of the filtering BMA250E::BW_T values. The default is
|
||||
* BMA250E::BW_250.
|
||||
*/
|
||||
void initAccelerometer(BMA250E::POWER_MODE_T pwr=BMA250E::POWER_MODE_NORMAL,
|
||||
BMA250E::RANGE_T range=BMA250E::RANGE_2G,
|
||||
BMA250E::BW_T bw=BMA250E::BW_250);
|
||||
* The BMC150 is an integrated electronic compass solution for
|
||||
* consumer market applications. It comprises a 12bit leading edge
|
||||
* triaxial, low-g acceleration sensor and an ultra-low power, high
|
||||
* precision triaxial magnetic field sensor. It allows measurements
|
||||
* of acceleration and magnetic field in three perpendicular
|
||||
* axes. Performance and features of both sensing technologies are
|
||||
* carefully tuned and perfectly match the demanding requirements of
|
||||
* all 6-axis mobile applications such as electronic compass,
|
||||
* navigation or augmented reality.
|
||||
|
||||
/**
|
||||
* Initialize the magnetometer and start operation. This function
|
||||
* is called from the constructor so will not typically need to be
|
||||
* called by a user unless the device is reset or you want to
|
||||
* change these values. This method will call
|
||||
* BMM150::setPresetMode() with the passed parameter.
|
||||
* The BMC150 is essentially 2 separate devices in one: the BMA250E
|
||||
* Accelerometer and the BMM150 Magnetometer. They are completely
|
||||
* independant of each other.
|
||||
*
|
||||
* @param usage One of the BMM150::USAGE_PRESETS_T values. The default is
|
||||
* BMM150::USAGE_HIGH_ACCURACY.
|
||||
*/
|
||||
void initMagnetometer(BMM150::USAGE_PRESETS_T usage=BMM150::USAGE_HIGH_ACCURACY);
|
||||
|
||||
/**
|
||||
* Return accelerometer data in gravities. update() must have
|
||||
* been called prior to calling this method.
|
||||
* This driver provides a very simple interface to these 2 devices.
|
||||
* If finer control is desired, you should just use the separate
|
||||
* BMA25E and BMM150 device classes directly. This driver simply
|
||||
* initializes both devices, and provides a mechanism to read
|
||||
* accelerometer and magnetometer data from them.
|
||||
*
|
||||
* @param x Pointer to a floating point value that will have the
|
||||
* current x component placed into it.
|
||||
* @param y Pointer to a floating point value that will have the
|
||||
* current y component placed into it.
|
||||
* @param z Pointer to a floating point value that will have the
|
||||
* current z component placed into it.
|
||||
* @snippet bmc150.cxx Interesting
|
||||
*/
|
||||
void getAccelerometer(float *x, float *y, float *z);
|
||||
|
||||
/**
|
||||
* Return accelerometer data in gravities in the form of a
|
||||
* floating point array. The pointer returned by this function is
|
||||
* statically allocated and will be rewritten on each call.
|
||||
* update() must have been called prior to calling this method.
|
||||
*
|
||||
* @return A floating point array containing x, y, and z in
|
||||
* that order.
|
||||
*/
|
||||
float *getAccelerometer();
|
||||
class BMC150 {
|
||||
public:
|
||||
/**
|
||||
* BMC150 constructor.
|
||||
*
|
||||
* This device can support both I2C and SPI. For SPI, set the addr
|
||||
* to -1, and specify a positive integer representing the Chip
|
||||
* Select (CS) pin for the cs argument. If you are using a
|
||||
* hardware CS pin (like edison with arduino breakout), then you
|
||||
* can connect the proper pin to the hardware CS pin on your MCU
|
||||
* and supply -1 for cs. The default operating mode is I2C.
|
||||
*
|
||||
* @param accelBus I2C or SPI bus to use. -1 to skip initializing
|
||||
* this device.
|
||||
* @param accelAddr The address for this device. -1 for SPI.
|
||||
* @param accelCS The gpio pin to use for the SPI Chip Select. -1 for
|
||||
* I2C or for SPI with a hardware controlled pin.
|
||||
* @param magBus I2C or SPI bus to use. -1 to skip initializing
|
||||
* this device.
|
||||
* @param magAddr The address for this device. -1 for SPI.
|
||||
* @param magCS The gpio pin to use for the SPI Chip Select. -1 for
|
||||
* I2C or for SPI with a hardware controlled pin.
|
||||
*/
|
||||
BMC150(int accelBus=BMC150_DEFAULT_BUS,
|
||||
int accelAddr=BMC150_DEFAULT_ACC_ADDR,
|
||||
int accelCS=-1,
|
||||
int magBus=BMC150_DEFAULT_BUS,
|
||||
int magAddr=BMC150_DEFAULT_MAG_ADDR,
|
||||
int magCS=-1);
|
||||
|
||||
/**
|
||||
* Return magnetometer data in micro-Teslas (uT). update() must
|
||||
* have been called prior to calling this method.
|
||||
*
|
||||
* @param x Pointer to a floating point value that will have the
|
||||
* current x component placed into it.
|
||||
* @param y Pointer to a floating point value that will have the
|
||||
* current y component placed into it.
|
||||
* @param z Pointer to a floating point value that will have the
|
||||
* current z component placed into it.
|
||||
*/
|
||||
void getMagnetometer(float *x, float *y, float *z);
|
||||
/**
|
||||
* BMC150 Destructor.
|
||||
*/
|
||||
~BMC150();
|
||||
|
||||
/**
|
||||
* Return magnetometer data in micro-Teslas (uT) in the form of a
|
||||
* floating point array. The pointer returned by this function is
|
||||
* statically allocated and will be rewritten on each call.
|
||||
* update() must have been called prior to calling this method.
|
||||
*
|
||||
* @return A floating point array containing x, y, and z in
|
||||
* that order.
|
||||
*/
|
||||
float *getMagnetometer();
|
||||
/**
|
||||
* Update the internal stored values from sensor data.
|
||||
*/
|
||||
void update();
|
||||
|
||||
/**
|
||||
* Initialize the accelerometer and start operation. This
|
||||
* function is called from the constructor so will not typically
|
||||
* need to be called by a user unless the device is reset or you
|
||||
* want to change these values.
|
||||
*
|
||||
* @param pwr One of the BMA250E_POWER_MODE_T values. The default is
|
||||
* BMA250E_POWER_MODE_NORMAL.
|
||||
* @param range One of the BMA250E_RANGE_T values. The default is
|
||||
* BMA250E_RANGE_2G.
|
||||
* @param bw One of the filtering BMA250E_BW_T values. The default is
|
||||
* BMA250E_BW_250.
|
||||
*/
|
||||
void initAccelerometer(BMA250E_POWER_MODE_T pwr=BMA250E_POWER_MODE_NORMAL,
|
||||
BMA250E_RANGE_T range=BMA250E_RANGE_2G,
|
||||
BMA250E_BW_T bw=BMA250E_BW_250);
|
||||
|
||||
/**
|
||||
* Initialize the magnetometer and start operation. This function
|
||||
* is called from the constructor so will not typically need to be
|
||||
* called by a user unless the device is reset or you want to
|
||||
* change these values. This method will call
|
||||
* BMM150::setPresetMode() with the passed parameter.
|
||||
*
|
||||
* @param usage One of the BMM150::USAGE_PRESETS_T values. The default is
|
||||
* BMM150::USAGE_HIGH_ACCURACY.
|
||||
*/
|
||||
void initMagnetometer(BMM150::USAGE_PRESETS_T usage=BMM150::USAGE_HIGH_ACCURACY);
|
||||
|
||||
/**
|
||||
* Return accelerometer data in gravities. update() must have
|
||||
* been called prior to calling this method.
|
||||
*
|
||||
* @param x Pointer to a floating point value that will have the
|
||||
* current x component placed into it.
|
||||
* @param y Pointer to a floating point value that will have the
|
||||
* current y component placed into it.
|
||||
* @param z Pointer to a floating point value that will have the
|
||||
* current z component placed into it.
|
||||
*/
|
||||
void getAccelerometer(float *x, float *y, float *z);
|
||||
|
||||
/**
|
||||
* Return accelerometer data in gravities in the form of a
|
||||
* floating point vector. update() must have been called
|
||||
* prior to calling this method.
|
||||
*
|
||||
* @return A floating point vector containing x, y, and z in
|
||||
* that order.
|
||||
*/
|
||||
std::vector<float> getAccelerometer();
|
||||
|
||||
/**
|
||||
* Return magnetometer data in micro-Teslas (uT). update() must
|
||||
* have been called prior to calling this method.
|
||||
*
|
||||
* @param x Pointer to a floating point value that will have the
|
||||
* current x component placed into it.
|
||||
* @param y Pointer to a floating point value that will have the
|
||||
* current y component placed into it.
|
||||
* @param z Pointer to a floating point value that will have the
|
||||
* current z component placed into it.
|
||||
*/
|
||||
void getMagnetometer(float *x, float *y, float *z);
|
||||
|
||||
/**
|
||||
* Return magnetometer data in micro-Teslas (uT) in the form of a
|
||||
* floating point array. The pointer returned by this function is
|
||||
* statically allocated and will be rewritten on each call.
|
||||
* update() must have been called prior to calling this method.
|
||||
*
|
||||
* @return A floating point array containing x, y, and z in
|
||||
* that order.
|
||||
*/
|
||||
float *getMagnetometer();
|
||||
|
||||
|
||||
protected:
|
||||
BMA250E *m_accel;
|
||||
BMM150 *m_mag;
|
||||
protected:
|
||||
BMA250E *m_accel;
|
||||
BMM150 *m_mag;
|
||||
|
||||
private:
|
||||
};
|
||||
private:
|
||||
};
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2016 Intel Corporation.
|
||||
* Copyright (c) 2016-2017 Intel Corporation.
|
||||
*
|
||||
* The MIT License
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
@ -62,9 +64,9 @@ BMI055::~BMI055()
|
||||
delete m_gyro;
|
||||
}
|
||||
|
||||
void BMI055::initAccelerometer(BMA250E::POWER_MODE_T pwr,
|
||||
BMA250E::RANGE_T range,
|
||||
BMA250E::BW_T bw)
|
||||
void BMI055::initAccelerometer(BMA250E_POWER_MODE_T pwr,
|
||||
BMA250E_RANGE_T range,
|
||||
BMA250E_BW_T bw)
|
||||
{
|
||||
if (m_accel)
|
||||
m_accel->init(pwr, range, bw);
|
||||
@ -93,15 +95,12 @@ void BMI055::getAccelerometer(float *x, float *y, float *z)
|
||||
m_accel->getAccelerometer(x, y, z);
|
||||
}
|
||||
|
||||
float *BMI055::getAccelerometer()
|
||||
std::vector<float> BMI055::getAccelerometer()
|
||||
{
|
||||
if (m_accel)
|
||||
return m_accel->getAccelerometer();
|
||||
else
|
||||
{
|
||||
static float v[3] = {0.0f, 0.0f, 0.0f};
|
||||
return v;
|
||||
}
|
||||
return {0, 0, 0};
|
||||
}
|
||||
|
||||
void BMI055::getGyroscope(float *x, float *y, float *z)
|
||||
|
@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2016 Intel Corporation.
|
||||
* Copyright (c) 2016-2017 Intel Corporation.
|
||||
*
|
||||
* The MIT License
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
@ -85,7 +87,7 @@ namespace upm {
|
||||
* @param gyroCS The gpio pin to use for the SPI Chip Select. -1 for
|
||||
* I2C or for SPI with a hardware controlled pin.
|
||||
*/
|
||||
BMI055(int accelBus=BMA250E_I2C_BUS,
|
||||
BMI055(int accelBus=BMA250E_DEFAULT_I2C_BUS,
|
||||
int accelAddr=BMA250E_DEFAULT_ADDR,
|
||||
int accelCS=-1,
|
||||
int gyroBus=BMG160_DEFAULT_I2C_BUS,
|
||||
@ -108,16 +110,16 @@ namespace upm {
|
||||
* need to be called by a user unless the device is reset or you
|
||||
* want to change these values.
|
||||
*
|
||||
* @param pwr One of the BMA250E::POWER_MODE_T values. The default is
|
||||
* BMA250E::POWER_MODE_NORMAL.
|
||||
* @param range One of the BMA250E::RANGE_T values. The default is
|
||||
* BMA250E::RANGE_2G.
|
||||
* @param bw One of the filtering BMA250E::BW_T values. The default is
|
||||
* BMA250E::BW_250.
|
||||
* @param pwr One of the BMA250E_POWER_MODE_T values. The default is
|
||||
* BMA250E_POWER_MODE_NORMAL.
|
||||
* @param range One of the BMA250E_RANGE_T values. The default is
|
||||
* BMA250E_RANGE_2G.
|
||||
* @param bw One of the filtering BMA250E_BW_T values. The default is
|
||||
* BMA250E_BW_250.
|
||||
*/
|
||||
void initAccelerometer(BMA250E::POWER_MODE_T pwr=BMA250E::POWER_MODE_NORMAL,
|
||||
BMA250E::RANGE_T range=BMA250E::RANGE_2G,
|
||||
BMA250E::BW_T bw=BMA250E::BW_250);
|
||||
void initAccelerometer(BMA250E_POWER_MODE_T pwr=BMA250E_POWER_MODE_NORMAL,
|
||||
BMA250E_RANGE_T range=BMA250E_RANGE_2G,
|
||||
BMA250E_BW_T bw=BMA250E_BW_250);
|
||||
|
||||
/**
|
||||
* Initialize the gyroscope and start operation. This function is
|
||||
@ -125,12 +127,12 @@ namespace upm {
|
||||
* called by a user unless the device is reset or you want to
|
||||
* change these values.
|
||||
*
|
||||
* @param pwr One of the BMG160::POWER_MODE_T values. The default is
|
||||
* BMG160::POWER_MODE_NORMAL.
|
||||
* @param range One of the BMG160::RANGE_T values. The default is
|
||||
* BMG160::RANGE_250.
|
||||
* @param bw One of the filtering BMG160::BW_T values. The default is
|
||||
* BMG160::BW_400_47.
|
||||
* @param pwr One of the BMG160_POWER_MODE_T values. The default is
|
||||
* BMG160_POWER_MODE_NORMAL.
|
||||
* @param range One of the BMG160_RANGE_T values. The default is
|
||||
* BMG160_RANGE_250.
|
||||
* @param bw One of the filtering BMG160_BW_T values. The default is
|
||||
* BMG160_BW_400_47.
|
||||
*/
|
||||
void initGyroscope(BMG160_POWER_MODE_T pwr=BMG160_POWER_MODE_NORMAL,
|
||||
BMG160_RANGE_T range=BMG160_RANGE_250,
|
||||
@ -151,14 +153,13 @@ namespace upm {
|
||||
|
||||
/**
|
||||
* Return accelerometer data in gravities in the form of a
|
||||
* floating point array. The pointer returned by this function is
|
||||
* statically allocated and will be rewritten on each call.
|
||||
* update() must have been called prior to calling this method.
|
||||
* floating point vector. update() must have been called prior to
|
||||
* calling this method.
|
||||
*
|
||||
* @return A floating point array containing x, y, and z in
|
||||
* @return A floating point vector containing x, y, and z in
|
||||
* that order.
|
||||
*/
|
||||
float *getAccelerometer();
|
||||
std::vector<float> getAccelerometer();
|
||||
|
||||
/**
|
||||
* Return gyroscope data in degrees per second. update() must
|
||||
|
@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2016 Intel Corporation.
|
||||
* Copyright (c) 2016-2017 Intel Corporation.
|
||||
*
|
||||
* The MIT License
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
@ -35,148 +37,145 @@ using namespace std;
|
||||
BMX055::BMX055(int accelBus, int accelAddr, int accelCS,
|
||||
int gyroBus, int gyroAddr, int gyroCS,
|
||||
int magBus, int magAddr, int magCS) :
|
||||
m_accel(0), m_gyro(0), m_mag(0)
|
||||
m_accel(0), m_gyro(0), m_mag(0)
|
||||
{
|
||||
// if -1 is supplied as a bus for any of these, we will not
|
||||
// instantiate them
|
||||
// if -1 is supplied as a bus for any of these, we will not
|
||||
// instantiate them
|
||||
|
||||
if (accelBus >= 0)
|
||||
m_accel = new BMA250E(accelBus, accelAddr, accelCS);
|
||||
if (accelBus >= 0)
|
||||
m_accel = new BMA250E(accelBus, accelAddr, accelCS);
|
||||
|
||||
if (gyroBus >= 0)
|
||||
m_gyro = new BMG160(gyroBus, gyroAddr, gyroCS);
|
||||
if (gyroBus >= 0)
|
||||
m_gyro = new BMG160(gyroBus, gyroAddr, gyroCS);
|
||||
|
||||
if (magBus >= 0)
|
||||
m_mag = new BMM150(magBus, magAddr, magCS);
|
||||
if (magBus >= 0)
|
||||
m_mag = new BMM150(magBus, magAddr, magCS);
|
||||
|
||||
// now initialize them...
|
||||
if (m_accel)
|
||||
m_accel->init();
|
||||
// now initialize them...
|
||||
if (m_accel)
|
||||
m_accel->init();
|
||||
|
||||
if (m_gyro)
|
||||
m_gyro->init();
|
||||
if (m_gyro)
|
||||
m_gyro->init();
|
||||
|
||||
if (m_mag)
|
||||
m_mag->init();
|
||||
if (m_mag)
|
||||
m_mag->init();
|
||||
}
|
||||
|
||||
BMX055::~BMX055()
|
||||
{
|
||||
if (m_accel)
|
||||
delete m_accel;
|
||||
if (m_accel)
|
||||
delete m_accel;
|
||||
|
||||
if (m_gyro)
|
||||
delete m_gyro;
|
||||
if (m_gyro)
|
||||
delete m_gyro;
|
||||
|
||||
if (m_mag)
|
||||
delete m_mag;
|
||||
if (m_mag)
|
||||
delete m_mag;
|
||||
}
|
||||
|
||||
void BMX055::initAccelerometer(BMA250E::POWER_MODE_T pwr,
|
||||
BMA250E::RANGE_T range,
|
||||
BMA250E::BW_T bw)
|
||||
void BMX055::initAccelerometer(BMA250E_POWER_MODE_T pwr,
|
||||
BMA250E_RANGE_T range,
|
||||
BMA250E_BW_T bw)
|
||||
{
|
||||
if (m_accel)
|
||||
m_accel->init(pwr, range, bw);
|
||||
if (m_accel)
|
||||
m_accel->init(pwr, range, bw);
|
||||
}
|
||||
|
||||
void BMX055::initGyroscope(BMG160_POWER_MODE_T pwr,
|
||||
BMG160_RANGE_T range,
|
||||
BMG160_BW_T bw)
|
||||
{
|
||||
if (m_gyro)
|
||||
m_gyro->init(pwr, range, bw);
|
||||
if (m_gyro)
|
||||
m_gyro->init(pwr, range, bw);
|
||||
}
|
||||
|
||||
void BMX055::initMagnetometer(BMM150::USAGE_PRESETS_T usage)
|
||||
{
|
||||
if (m_mag)
|
||||
m_mag->init(usage);
|
||||
if (m_mag)
|
||||
m_mag->init(usage);
|
||||
}
|
||||
|
||||
void BMX055::update()
|
||||
{
|
||||
if (m_accel)
|
||||
m_accel->update();
|
||||
if (m_accel)
|
||||
m_accel->update();
|
||||
|
||||
if (m_gyro)
|
||||
m_gyro->update();
|
||||
if (m_gyro)
|
||||
m_gyro->update();
|
||||
|
||||
if (m_mag)
|
||||
m_mag->update();
|
||||
if (m_mag)
|
||||
m_mag->update();
|
||||
}
|
||||
|
||||
void BMX055::getAccelerometer(float *x, float *y, float *z)
|
||||
{
|
||||
if (m_accel)
|
||||
m_accel->getAccelerometer(x, y, z);
|
||||
else
|
||||
{
|
||||
if (x)
|
||||
*x = 0;
|
||||
if (y)
|
||||
*y = 0;
|
||||
if (z)
|
||||
*z = 0;
|
||||
}
|
||||
if (m_accel)
|
||||
m_accel->getAccelerometer(x, y, z);
|
||||
else
|
||||
{
|
||||
if (x)
|
||||
*x = 0;
|
||||
if (y)
|
||||
*y = 0;
|
||||
if (z)
|
||||
*z = 0;
|
||||
}
|
||||
}
|
||||
|
||||
float *BMX055::getAccelerometer()
|
||||
std::vector<float> BMX055::getAccelerometer()
|
||||
{
|
||||
if (m_accel)
|
||||
return m_accel->getAccelerometer();
|
||||
else
|
||||
{
|
||||
static float v[3] = {0.0f, 0.0f, 0.0f};
|
||||
return v;
|
||||
}
|
||||
if (m_accel)
|
||||
return m_accel->getAccelerometer();
|
||||
else
|
||||
return {0, 0, 0};
|
||||
}
|
||||
|
||||
void BMX055::getGyroscope(float *x, float *y, float *z)
|
||||
{
|
||||
if (m_gyro)
|
||||
m_gyro->getGyroscope(x, y, z);
|
||||
else
|
||||
{
|
||||
if (x)
|
||||
*x = 0;
|
||||
if (y)
|
||||
*y = 0;
|
||||
if (z)
|
||||
*z = 0;
|
||||
}
|
||||
if (m_gyro)
|
||||
m_gyro->getGyroscope(x, y, z);
|
||||
else
|
||||
{
|
||||
if (x)
|
||||
*x = 0;
|
||||
if (y)
|
||||
*y = 0;
|
||||
if (z)
|
||||
*z = 0;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<float> BMX055::getGyroscope()
|
||||
{
|
||||
if (m_gyro)
|
||||
return m_gyro->getGyroscope();
|
||||
else
|
||||
return {0, 0, 0};
|
||||
if (m_gyro)
|
||||
return m_gyro->getGyroscope();
|
||||
else
|
||||
return {0, 0, 0};
|
||||
}
|
||||
|
||||
void BMX055::getMagnetometer(float *x, float *y, float *z)
|
||||
{
|
||||
if (m_mag)
|
||||
m_mag->getMagnetometer(x, y, z);
|
||||
else
|
||||
{
|
||||
if (x)
|
||||
*x = 0;
|
||||
if (y)
|
||||
*y = 0;
|
||||
if (z)
|
||||
*z = 0;
|
||||
}
|
||||
if (m_mag)
|
||||
m_mag->getMagnetometer(x, y, z);
|
||||
else
|
||||
{
|
||||
if (x)
|
||||
*x = 0;
|
||||
if (y)
|
||||
*y = 0;
|
||||
if (z)
|
||||
*z = 0;
|
||||
}
|
||||
}
|
||||
|
||||
float *BMX055::getMagnetometer()
|
||||
{
|
||||
if (m_mag)
|
||||
return m_mag->getMagnetometer();
|
||||
else
|
||||
if (m_mag)
|
||||
return m_mag->getMagnetometer();
|
||||
else
|
||||
{
|
||||
static float v[3] = {0.0f, 0.0f, 0.0f};
|
||||
return v;
|
||||
static float v[3] = {0.0f, 0.0f, 0.0f};
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Copyright (c) 2016 Intel Corporation.
|
||||
* Copyright (c) 2016-2017 Intel Corporation.
|
||||
*
|
||||
* The MIT License
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
@ -30,6 +32,8 @@
|
||||
#include "bmg160.hpp"
|
||||
#include "bmm150.hpp"
|
||||
|
||||
#define BMX055_DEFAULT_MAG_I2C_ADDR 0x12
|
||||
|
||||
namespace upm {
|
||||
|
||||
/**
|
||||
@ -100,14 +104,14 @@ namespace upm {
|
||||
* @param magCS The gpio pin to use for the SPI Chip Select. -1 for
|
||||
* I2C or for SPI with a hardware controlled pin.
|
||||
*/
|
||||
BMX055(int accelBus=BMA250E_I2C_BUS,
|
||||
BMX055(int accelBus=BMA250E_DEFAULT_I2C_BUS,
|
||||
int accelAddr=BMA250E_DEFAULT_ADDR,
|
||||
int accelCS=-1,
|
||||
int gyroBus=BMG160_DEFAULT_I2C_BUS,
|
||||
int gyroAddr=BMG160_DEFAULT_ADDR,
|
||||
int gyroCS=-1,
|
||||
int magBus=BMM150_I2C_BUS,
|
||||
int magAddr=BMM150_DEFAULT_ADDR,
|
||||
int magAddr=BMX055_DEFAULT_MAG_I2C_ADDR,
|
||||
int magCS=-1);
|
||||
|
||||
/**
|
||||
@ -126,16 +130,16 @@ namespace upm {
|
||||
* need to be called by a user unless the device is reset or you
|
||||
* want to change these values.
|
||||
*
|
||||
* @param pwr One of the BMA250E::POWER_MODE_T values. The default is
|
||||
* BMA250E::POWER_MODE_NORMAL.
|
||||
* @param range One of the BMA250E::RANGE_T values. The default is
|
||||
* BMA250E::RANGE_2G.
|
||||
* @param bw One of the filtering BMA250E::BW_T values. The default is
|
||||
* BMA250E::BW_250.
|
||||
* @param pwr One of the BMA250E_POWER_MODE_T values. The default is
|
||||
* BMA250E_POWER_MODE_NORMAL.
|
||||
* @param range One of the BMA250E_RANGE_T values. The default is
|
||||
* BMA250E_RANGE_2G.
|
||||
* @param bw One of the filtering BMA250E_BW_T values. The default is
|
||||
* BMA250E_BW_250.
|
||||
*/
|
||||
void initAccelerometer(BMA250E::POWER_MODE_T pwr=BMA250E::POWER_MODE_NORMAL,
|
||||
BMA250E::RANGE_T range=BMA250E::RANGE_2G,
|
||||
BMA250E::BW_T bw=BMA250E::BW_250);
|
||||
void initAccelerometer(BMA250E_POWER_MODE_T pwr=BMA250E_POWER_MODE_NORMAL,
|
||||
BMA250E_RANGE_T range=BMA250E_RANGE_2G,
|
||||
BMA250E_BW_T bw=BMA250E_BW_250);
|
||||
|
||||
/**
|
||||
* Initialize the gyroscope and start operation. This function is
|
||||
@ -143,12 +147,12 @@ namespace upm {
|
||||
* called by a user unless the device is reset or you want to
|
||||
* change these values.
|
||||
*
|
||||
* @param pwr One of the BMG160::POWER_MODE_T values. The default is
|
||||
* BMG160::POWER_MODE_NORMAL.
|
||||
* @param range One of the BMG160::RANGE_T values. The default is
|
||||
* BMG160::RANGE_250.
|
||||
* @param bw One of the filtering BMG160::BW_T values. The default is
|
||||
* BMG160::BW_400_47.
|
||||
* @param pwr One of the BMG160_POWER_MODE_T values. The default is
|
||||
* BMG160_POWER_MODE_NORMAL.
|
||||
* @param range One of the BMG160_RANGE_T values. The default is
|
||||
* BMG160_RANGE_250.
|
||||
* @param bw One of the filtering BMG160_BW_T values. The default is
|
||||
* BMG160_BW_400_47.
|
||||
*/
|
||||
void initGyroscope(BMG160_POWER_MODE_T pwr=BMG160_POWER_MODE_NORMAL,
|
||||
BMG160_RANGE_T range=BMG160_RANGE_250,
|
||||
@ -181,14 +185,13 @@ namespace upm {
|
||||
|
||||
/**
|
||||
* Return accelerometer data in gravities in the form of a
|
||||
* floating point array. The pointer returned by this function is
|
||||
* statically allocated and will be rewritten on each call.
|
||||
* update() must have been called prior to calling this method.
|
||||
* floating point vector. update() must have been called prior to
|
||||
* calling this method.
|
||||
*
|
||||
* @return A floating point array containing x, y, and z in
|
||||
* @return A floating point vector containing x, y, and z in
|
||||
* that order.
|
||||
*/
|
||||
float *getAccelerometer();
|
||||
std::vector<float> getAccelerometer();
|
||||
|
||||
/**
|
||||
* Return gyroscope data in degrees per second. update() must
|
||||
|
@ -17,11 +17,6 @@
|
||||
return $jnicall;
|
||||
}
|
||||
|
||||
%typemap(out) float *getAccelerometer {
|
||||
$result = JCALL1(NewFloatArray, jenv, 3);
|
||||
JCALL4(SetFloatArrayRegion, jenv, $result, 0, 3, $1);
|
||||
}
|
||||
|
||||
%typemap(out) float *getMagnetometer {
|
||||
$result = JCALL1(NewFloatArray, jenv, 3);
|
||||
JCALL4(SetFloatArrayRegion, jenv, $result, 0, 3, $1);
|
||||
@ -31,10 +26,8 @@
|
||||
%ignore getMagnetometer(float *, float *, float *);
|
||||
%ignore getGyroscope(float *, float *, float *);
|
||||
|
||||
%include "bma250e.hpp"
|
||||
%{
|
||||
#include "bma250e.hpp"
|
||||
%}
|
||||
%include "bmg160_defs.h"
|
||||
%include "bma250e_defs.h"
|
||||
|
||||
%include "bmm150.hpp"
|
||||
%{
|
||||
|
@ -1,15 +1,14 @@
|
||||
%module jsupm_bmx055
|
||||
%include "../upm.i"
|
||||
%include "cpointer.i"
|
||||
%include "../upm_vectortypes.i"
|
||||
|
||||
/* Send "int *" and "float *" to JavaScript as intp and floatp */
|
||||
%pointer_functions(int, intp);
|
||||
%pointer_functions(float, floatp);
|
||||
|
||||
%include "bma250e.hpp"
|
||||
%{
|
||||
#include "bma250e.hpp"
|
||||
%}
|
||||
%include "bmg160_defs.h"
|
||||
%include "bma250e_defs.h"
|
||||
|
||||
%include "bmm150.hpp"
|
||||
%{
|
||||
|
@ -3,8 +3,7 @@
|
||||
%module pyupm_bmx055
|
||||
%include "../upm.i"
|
||||
%include "cpointer.i"
|
||||
|
||||
%include "stdint.i"
|
||||
%include "../upm_vectortypes.i"
|
||||
|
||||
/* Send "int *" and "float *" to python as intp and floatp */
|
||||
%pointer_functions(int, intp);
|
||||
@ -16,10 +15,8 @@
|
||||
%include "bmx055_doc.i"
|
||||
#endif
|
||||
|
||||
%include "bma250e.hpp"
|
||||
%{
|
||||
#include "bma250e.hpp"
|
||||
%}
|
||||
%include "bmg160_defs.h"
|
||||
%include "bma250e_defs.h"
|
||||
|
||||
%include "bmm150.hpp"
|
||||
%{
|
||||
|
Loading…
x
Reference in New Issue
Block a user