bmx055, bmi055, bmc160, bma250e, bmg150, bmm150: Initial implementation

This module (bmx055) implements support for the following core Bosch
chipsets:

bma250e - accelerometer, 3 variants (chip id's 0x03, 0xf9, and 0xfa)
bmm150 - magnetometer
bmg160 - gyroscope

The other 3 devices are combinations of the above:

bmx055 - accel/gyro/mag
bmc160 - accel/mag
bmi055 - accel/gyro

...for 6 devices total.

For the combination devices, all of the sub-devices appear as
individual independent devices on the I2C/SPI bus.

The combination drivers provide basic configuration and data output.
For more detailed control as well as interrupt support, you should use
the core device drivers (accel/gyro/mag) directly.

These devices support both I2C and SPI communications.  They must be
powered at 3.3vdc.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
This commit is contained in:
Jon Trulson
2016-05-06 17:56:51 -06:00
parent 66bd4ee8c8
commit 8fb7907a4e
42 changed files with 8196 additions and 0 deletions

View File

@ -269,6 +269,7 @@ add_example (ds18b20)
add_example (bmp280)
add_example (bno055)
add_example (l3gd20)
add_example (bmx055)
# These are special cases where you specify example binary, source file and module(s)
include_directories (${PROJECT_SOURCE_DIR}/src)
@ -295,3 +296,8 @@ add_custom_example (adc-example adc-sensor.cxx "ads1x15")
add_custom_example (light-sensor-example light-sensor.cxx "si1132;max44009")
add_custom_example (light-controller-example light-controller.cxx "lp8860;ds1808lc;hlg150h")
add_custom_example (bme280-example bme280.cxx bmp280)
add_custom_example (bma250e-example bma250e.cxx bmx055)
add_custom_example (bmg160-example bmg160.cxx bmx055)
add_custom_example (bmm150-example bmm150.cxx bmx055)
add_custom_example (bmc150-example bmc150.cxx bmx055)
add_custom_example (bmi055-example bmi055.cxx bmx055)

83
examples/c++/bma250e.cxx Normal file
View File

@ -0,0 +1,83 @@
/*
* 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 <signal.h>
#include "bma250e.hpp"
using namespace std;
int shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate an BMA250E using default I2C parameters
upm::BMA250E *sensor = new upm::BMA250E();
// For SPI, bus 0, you would pass -1 as the address, and a valid pin
// for CS: BMA250E(0, -1, 10);
// now output data every 250 milliseconds
while (shouldRun)
{
float x, y, z;
sensor->update();
sensor->getAccelerometer(&x, &y, &z);
cout << "Accelerometer x: " << x
<< " y: " << y
<< " z: " << z
<< " g"
<< endl;
// we show both C and F for temperature
cout << "Compensation Temperature: " << sensor->getTemperature()
<< " C / " << sensor->getTemperature(true) << " F"
<< endl;
cout << endl;
usleep(250000);
}
//! [Interesting]
cout << "Exiting..." << endl;
delete sensor;
return 0;
}

82
examples/c++/bmc150.cxx Normal file
View File

@ -0,0 +1,82 @@
/*
* 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 <signal.h>
#include "bmc150.hpp"
using namespace std;
int shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate an BMC150 using default I2C parameters
upm::BMC150 *sensor = new upm::BMC150();
// now output data every 250 milliseconds
while (shouldRun)
{
float x, y, z;
sensor->update();
sensor->getAccelerometer(&x, &y, &z);
cout << "Accelerometer x: " << x
<< " y: " << y
<< " z: " << z
<< " g"
<< endl;
sensor->getMagnetometer(&x, &y, &z);
cout << "Magnetometer x: " << x
<< " y: " << y
<< " z: " << z
<< " uT"
<< endl;
cout << endl;
usleep(250000);
}
//! [Interesting]
cout << "Exiting..." << endl;
delete sensor;
return 0;
}

83
examples/c++/bmg160.cxx Normal file
View File

@ -0,0 +1,83 @@
/*
* 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 <signal.h>
#include "bmg160.hpp"
using namespace std;
int shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate an BMG160 using default I2C parameters
upm::BMG160 *sensor = new upm::BMG160();
// For SPI, bus 0, you would pass -1 as the address, and a valid pin
// for CS: BMG160(0, -1, 10);
// now output data every 250 milliseconds
while (shouldRun)
{
float x, y, z;
sensor->update();
sensor->getGyroscope(&x, &y, &z);
cout << "Gyroscope x: " << x
<< " y: " << y
<< " z: " << z
<< " degrees/s"
<< endl;
// we show both C and F for temperature
cout << "Compensation Temperature: " << sensor->getTemperature()
<< " C / " << sensor->getTemperature(true) << " F"
<< endl;
cout << endl;
usleep(250000);
}
//! [Interesting]
cout << "Exiting..." << endl;
delete sensor;
return 0;
}

82
examples/c++/bmi055.cxx Normal file
View File

@ -0,0 +1,82 @@
/*
* 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 <signal.h>
#include "bmi055.hpp"
using namespace std;
int shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate an BMI055 using default I2C parameters
upm::BMI055 *sensor = new upm::BMI055();
// now output data every 250 milliseconds
while (shouldRun)
{
float x, y, z;
sensor->update();
sensor->getAccelerometer(&x, &y, &z);
cout << "Accelerometer x: " << x
<< " y: " << y
<< " z: " << z
<< " g"
<< endl;
sensor->getGyroscope(&x, &y, &z);
cout << "Gyroscope x: " << x
<< " y: " << y
<< " z: " << z
<< " degrees/s"
<< endl;
cout << endl;
usleep(250000);
}
//! [Interesting]
cout << "Exiting..." << endl;
delete sensor;
return 0;
}

78
examples/c++/bmm150.cxx Normal file
View File

@ -0,0 +1,78 @@
/*
* 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 <signal.h>
#include "bmm150.hpp"
using namespace std;
int shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate an BMM150 using default I2C parameters
upm::BMM150 *sensor = new upm::BMM150();
// For SPI, bus 0, you would pass -1 as the address, and a valid pin
// for CS: BMM150(0, -1, 10);
// now output data every 250 milliseconds
while (shouldRun)
{
float x, y, z;
sensor->update();
sensor->getMagnetometer(&x, &y, &z);
cout << "Magnetometer x: " << x
<< " y: " << y
<< " z: " << z
<< " uT"
<< endl;
cout << endl;
usleep(250000);
}
//! [Interesting]
cout << "Exiting..." << endl;
delete sensor;
return 0;
}

89
examples/c++/bmx055.cxx Normal file
View File

@ -0,0 +1,89 @@
/*
* 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 <signal.h>
#include "bmx055.hpp"
using namespace std;
int shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate an BMX055 using default I2C parameters
upm::BMX055 *sensor = new upm::BMX055();
// now output data every 250 milliseconds
while (shouldRun)
{
float x, y, z;
sensor->update();
sensor->getAccelerometer(&x, &y, &z);
cout << "Accelerometer x: " << x
<< " y: " << y
<< " z: " << z
<< " g"
<< endl;
sensor->getGyroscope(&x, &y, &z);
cout << "Gyroscope x: " << x
<< " y: " << y
<< " z: " << z
<< " degrees/s"
<< endl;
sensor->getMagnetometer(&x, &y, &z);
cout << "Magnetometer x: " << x
<< " y: " << y
<< " z: " << z
<< " uT"
<< endl;
cout << endl;
usleep(250000);
}
//! [Interesting]
cout << "Exiting..." << endl;
delete sensor;
return 0;
}

View File

@ -0,0 +1,64 @@
/*
* 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.
*/
import upm_bmx055.BMA250E;
public class BMA250E_Example
{
public static void main(String[] args) throws InterruptedException
{
// ! [Interesting]
// Instantiate a BMA250E instance using default i2c bus and address
BMA250E sensor = new BMA250E();
// For SPI, bus 0, you would pass -1 as the address, and a
// valid pin for CS:
// BMA250E(0, -1, 10);
while (true)
{
// update our values from the sensor
sensor.update();
float dataA[] = sensor.getAccelerometer();
System.out.println("Accelerometer x: " + dataA[0]
+ " y: " + dataA[1]
+ " z: " + dataA[2]
+ " g");
System.out.println("Compensation Temperature: "
+ sensor.getTemperature()
+ " C / "
+ sensor.getTemperature(true)
+ " F");
System.out.println();
Thread.sleep(250);
}
// ! [Interesting]
}
}

View File

@ -0,0 +1,61 @@
/*
* 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.
*/
import upm_bmx055.BMC150;
public class BMC150_Example
{
public static void main(String[] args) throws InterruptedException
{
// ! [Interesting]
// Instantiate a BMC150 instance using default i2c bus and address
BMC150 sensor = new BMC150();
while (true)
{
// update our values from the sensor
sensor.update();
float data[] = sensor.getAccelerometer();
System.out.println("Accelerometer x: " + data[0]
+ " y: " + data[1]
+ " z: " + data[2]
+ " g");
data = sensor.getMagnetometer();
System.out.println("Magnetometer x: " + data[0]
+ " y: " + data[1]
+ " z: " + data[2]
+ " uT");
System.out.println();
Thread.sleep(250);
}
// ! [Interesting]
}
}

View File

@ -0,0 +1,64 @@
/*
* 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.
*/
import upm_bmx055.BMG160;
public class BMG160_Example
{
public static void main(String[] args) throws InterruptedException
{
// ! [Interesting]
// Instantiate a BMG160 instance using default i2c bus and address
BMG160 sensor = new BMG160();
// For SPI, bus 0, you would pass -1 as the address, and a
// valid pin for CS:
// BMG160(0, -1, 10);
while (true)
{
// update our values from the sensor
sensor.update();
float dataA[] = sensor.getGyroscope();
System.out.println("Gyroscope x: " + dataA[0]
+ " y: " + dataA[1]
+ " z: " + dataA[2]
+ " degrees/s");
System.out.println("Compensation Temperature: "
+ sensor.getTemperature()
+ " C / "
+ sensor.getTemperature(true)
+ " F");
System.out.println();
Thread.sleep(250);
}
// ! [Interesting]
}
}

View File

@ -0,0 +1,61 @@
/*
* 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.
*/
import upm_bmx055.BMI055;
public class BMI055_Example
{
public static void main(String[] args) throws InterruptedException
{
// ! [Interesting]
// Instantiate a BMI055 instance using default i2c bus and address
BMI055 sensor = new BMI055();
while (true)
{
// update our values from the sensor
sensor.update();
float data[] = sensor.getAccelerometer();
System.out.println("Accelerometer x: " + data[0]
+ " y: " + data[1]
+ " z: " + data[2]
+ " g");
data = sensor.getGyroscope();
System.out.println("Gyroscope x: " + data[0]
+ " y: " + data[1]
+ " z: " + data[2]
+ " degrees/s");
System.out.println();
Thread.sleep(250);
}
// ! [Interesting]
}
}

View File

@ -0,0 +1,58 @@
/*
* 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.
*/
import upm_bmx055.BMM150;
public class BMM150_Example
{
public static void main(String[] args) throws InterruptedException
{
// ! [Interesting]
// Instantiate a BMM150 instance using default i2c bus and address
BMM150 sensor = new BMM150();
// For SPI, bus 0, you would pass -1 as the address, and a
// valid pin for CS:
// BMM150(0, -1, 10);
while (true)
{
// update our values from the sensor
sensor.update();
float dataA[] = sensor.getMagnetometer();
System.out.println("Magnetometer x: " + dataA[0]
+ " y: " + dataA[1]
+ " z: " + dataA[2]
+ " uT");
System.out.println();
Thread.sleep(250);
}
// ! [Interesting]
}
}

View File

@ -0,0 +1,69 @@
/*
* 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.
*/
import upm_bmx055.BMX055;
public class BMX055_Example
{
public static void main(String[] args) throws InterruptedException
{
// ! [Interesting]
// Instantiate a BMX055 instance using default i2c bus and address
BMX055 sensor = new BMX055();
while (true)
{
// update our values from the sensor
sensor.update();
float data[] = sensor.getAccelerometer();
System.out.println("Accelerometer x: " + data[0]
+ " y: " + data[1]
+ " z: " + data[2]
+ " g");
data = sensor.getGyroscope();
System.out.println("Gyroscope x: " + data[0]
+ " y: " + data[1]
+ " z: " + data[2]
+ " degrees/s");
data = sensor.getMagnetometer();
System.out.println("Magnetometer x: " + data[0]
+ " y: " + data[1]
+ " z: " + data[2]
+ " uT");
System.out.println();
Thread.sleep(250);
}
// ! [Interesting]
}
}

View File

@ -128,6 +128,7 @@ endif()
add_example(VCAP_Example vcap)
add_example(BMP280_Example bmp280)
add_example(BNO055_Example bno055)
add_example(BMX055_Example bmx055)
add_example_with_path(Jhd1313m1_lcdSample lcd i2clcd)
add_example_with_path(Jhd1313m1Sample lcd i2clcd)
@ -136,4 +137,9 @@ add_example_with_path(Lcm1602_parallelSample lcd i2clcd)
add_example_with_path(SSD1308_oledSample lcd i2clcd)
add_example_with_path(SSD1327_oledSample lcd i2clcd)
add_example_with_path(BME280_Example bmp280 bmp280)
add_example_with_path(BMA250E_Example bmx055 bmx055)
add_example_with_path(BMG160_Example bmx055 bmx055)
add_example_with_path(BMM150_Example bmx055 bmx055)
add_example_with_path(BMC150_Example bmx055 bmx055)
add_example_with_path(BMI055_Example bmx055 bmx055)

View File

@ -0,0 +1,72 @@
/*jslint node:true, vars:true, bitwise:true, unparam:true */
/*jshint unused:true */
/*
* 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.
*/
var sensorObj = require('jsupm_bmx055');
// Instantiate a BMA250E instance using default i2c bus and address
var sensor = new sensorObj.BMA250E();
// For SPI, bus 0, you would pass -1 as the address, and a valid pin for CS:
// BMA250E(0, -1, 10);
var x = new sensorObj.new_floatp();
var y = new sensorObj.new_floatp();
var z = new sensorObj.new_floatp();
// now output data every 250 milliseconds
setInterval(function()
{
// update our values from the sensor
sensor.update();
sensor.getAccelerometer(x, y, z);
console.log("Accelerometer x: "
+ sensorObj.floatp_value(x)
+ " y: " + sensorObj.floatp_value(y)
+ " z: " + sensorObj.floatp_value(z)
+ " g");
// we show both C and F for temperature
console.log("Compensation Temperature: "
+ sensor.getTemperature()
+ " C / "
+ sensor.getTemperature(true)
+ " F");
console.log();
}, 250);
// exit on ^C
process.on('SIGINT', function()
{
sensor = null;
sensorObj.cleanUp();
sensorObj = null;
console.log("Exiting.");
process.exit(0);
});

View File

@ -0,0 +1,69 @@
/*jslint node:true, vars:true, bitwise:true, unparam:true */
/*jshint unused:true */
/*
* 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.
*/
var sensorObj = require('jsupm_bmx055');
// Instantiate a BMC150 instance using default i2c bus and address
var sensor = new sensorObj.BMC150();
var x = new sensorObj.new_floatp();
var y = new sensorObj.new_floatp();
var z = new sensorObj.new_floatp();
// now output data every 250 milliseconds
setInterval(function()
{
// update our values from the sensor
sensor.update();
sensor.getAccelerometer(x, y, z);
console.log("Accelerometer x: "
+ sensorObj.floatp_value(x)
+ " y: " + sensorObj.floatp_value(y)
+ " z: " + sensorObj.floatp_value(z)
+ " g");
sensor.getMagnetometer(x, y, z);
console.log("Magnetometer x: "
+ sensorObj.floatp_value(x)
+ " y: " + sensorObj.floatp_value(y)
+ " z: " + sensorObj.floatp_value(z)
+ " uT");
console.log();
}, 250);
// exit on ^C
process.on('SIGINT', function()
{
sensor = null;
sensorObj.cleanUp();
sensorObj = null;
console.log("Exiting.");
process.exit(0);
});

View File

@ -0,0 +1,72 @@
/*jslint node:true, vars:true, bitwise:true, unparam:true */
/*jshint unused:true */
/*
* 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.
*/
var sensorObj = require('jsupm_bmx055');
// Instantiate a BMG160 instance using default i2c bus and address
var sensor = new sensorObj.BMG160();
// For SPI, bus 0, you would pass -1 as the address, and a valid pin for CS:
// BMG160(0, -1, 10);
var x = new sensorObj.new_floatp();
var y = new sensorObj.new_floatp();
var z = new sensorObj.new_floatp();
// now output data every 250 milliseconds
setInterval(function()
{
// update our values from the sensor
sensor.update();
sensor.getGyroscope(x, y, z);
console.log("Gyroscope x: "
+ sensorObj.floatp_value(x)
+ " y: " + sensorObj.floatp_value(y)
+ " z: " + sensorObj.floatp_value(z)
+ " degrees/s");
// we show both C and F for temperature
console.log("Compensation Temperature: "
+ sensor.getTemperature()
+ " C / "
+ sensor.getTemperature(true)
+ " F");
console.log();
}, 250);
// exit on ^C
process.on('SIGINT', function()
{
sensor = null;
sensorObj.cleanUp();
sensorObj = null;
console.log("Exiting.");
process.exit(0);
});

View File

@ -0,0 +1,69 @@
/*jslint node:true, vars:true, bitwise:true, unparam:true */
/*jshint unused:true */
/*
* 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.
*/
var sensorObj = require('jsupm_bmx055');
// Instantiate a BMI055 instance using default i2c bus and address
var sensor = new sensorObj.BMI055();
var x = new sensorObj.new_floatp();
var y = new sensorObj.new_floatp();
var z = new sensorObj.new_floatp();
// now output data every 250 milliseconds
setInterval(function()
{
// update our values from the sensor
sensor.update();
sensor.getAccelerometer(x, y, z);
console.log("Accelerometer x: "
+ sensorObj.floatp_value(x)
+ " y: " + sensorObj.floatp_value(y)
+ " z: " + sensorObj.floatp_value(z)
+ " g");
sensor.getGyroscope(x, y, z);
console.log("Gyroscope x: "
+ sensorObj.floatp_value(x)
+ " y: " + sensorObj.floatp_value(y)
+ " z: " + sensorObj.floatp_value(z)
+ " degrees/s");
console.log();
}, 250);
// exit on ^C
process.on('SIGINT', function()
{
sensor = null;
sensorObj.cleanUp();
sensorObj = null;
console.log("Exiting.");
process.exit(0);
});

View File

@ -0,0 +1,65 @@
/*jslint node:true, vars:true, bitwise:true, unparam:true */
/*jshint unused:true */
/*
* 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.
*/
var sensorObj = require('jsupm_bmx055');
// Instantiate a BMM150 instance using default i2c bus and address
var sensor = new sensorObj.BMM150();
// For SPI, bus 0, you would pass -1 as the address, and a valid pin for CS:
// BMM150(0, -1, 10);
var x = new sensorObj.new_floatp();
var y = new sensorObj.new_floatp();
var z = new sensorObj.new_floatp();
// now output data every 250 milliseconds
setInterval(function()
{
// update our values from the sensor
sensor.update();
sensor.getMagnetometer(x, y, z);
console.log("Magnetometer x: "
+ sensorObj.floatp_value(x)
+ " y: " + sensorObj.floatp_value(y)
+ " z: " + sensorObj.floatp_value(z)
+ " uT");
console.log();
}, 250);
// exit on ^C
process.on('SIGINT', function()
{
sensor = null;
sensorObj.cleanUp();
sensorObj = null;
console.log("Exiting.");
process.exit(0);
});

View File

@ -0,0 +1,76 @@
/*jslint node:true, vars:true, bitwise:true, unparam:true */
/*jshint unused:true */
/*
* 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.
*/
var sensorObj = require('jsupm_bmx055');
// Instantiate a BMX055 instance using default i2c bus and address
var sensor = new sensorObj.BMX055();
var x = new sensorObj.new_floatp();
var y = new sensorObj.new_floatp();
var z = new sensorObj.new_floatp();
// now output data every 250 milliseconds
setInterval(function()
{
// update our values from the sensor
sensor.update();
sensor.getAccelerometer(x, y, z);
console.log("Accelerometer x: "
+ sensorObj.floatp_value(x)
+ " y: " + sensorObj.floatp_value(y)
+ " z: " + sensorObj.floatp_value(z)
+ " g");
sensor.getGyroscope(x, y, z);
console.log("Gyroscope x: "
+ sensorObj.floatp_value(x)
+ " y: " + sensorObj.floatp_value(y)
+ " z: " + sensorObj.floatp_value(z)
+ " degrees/s");
sensor.getMagnetometer(x, y, z);
console.log("Magnetometer x: "
+ sensorObj.floatp_value(x)
+ " y: " + sensorObj.floatp_value(y)
+ " z: " + sensorObj.floatp_value(z)
+ " uT");
console.log();
}, 250);
// exit on ^C
process.on('SIGINT', function()
{
sensor = null;
sensorObj.cleanUp();
sensorObj = null;
console.log("Exiting.");
process.exit(0);
});

View File

@ -0,0 +1,66 @@
#!/usr/bin/python
# 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.
import time, sys, signal, atexit
import pyupm_bmx055 as sensorObj
# Instantiate a BMP250E instance using default i2c bus and address
sensor = sensorObj.BMA250E()
# For SPI, bus 0, you would pass -1 as the address, and a valid pin for CS:
# BMA250E(0, -1, 10);
## Exit handlers ##
# This function stops python from printing a stacktrace when you hit control-C
def SIGINTHandler(signum, frame):
raise SystemExit
# This function lets you run code on exit
def exitHandler():
print "Exiting"
sys.exit(0)
# Register exit handlers
atexit.register(exitHandler)
signal.signal(signal.SIGINT, SIGINTHandler)
x = sensorObj.new_floatp()
y = sensorObj.new_floatp()
z = sensorObj.new_floatp()
# now output data every 250 milliseconds
while (1):
sensor.update()
sensor.getAccelerometer(x, y, z)
print "Accelerometer x:", sensorObj.floatp_value(x),
print " y:", sensorObj.floatp_value(y),
print " z:", sensorObj.floatp_value(z),
print " g"
# we show both C and F for temperature
print "Compensation Temperature:", sensor.getTemperature(), "C /",
print sensor.getTemperature(True), "F"
print
time.sleep(.250)

65
examples/python/bmc150.py Normal file
View File

@ -0,0 +1,65 @@
#!/usr/bin/python
# 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.
import time, sys, signal, atexit
import pyupm_bmx055 as sensorObj
# Instantiate a BMC150 instance using default i2c bus and address
sensor = sensorObj.BMC150()
## Exit handlers ##
# This function stops python from printing a stacktrace when you hit control-C
def SIGINTHandler(signum, frame):
raise SystemExit
# This function lets you run code on exit
def exitHandler():
print "Exiting"
sys.exit(0)
# Register exit handlers
atexit.register(exitHandler)
signal.signal(signal.SIGINT, SIGINTHandler)
x = sensorObj.new_floatp()
y = sensorObj.new_floatp()
z = sensorObj.new_floatp()
# now output data every 250 milliseconds
while (1):
sensor.update()
sensor.getAccelerometer(x, y, z)
print "Accelerometer x:", sensorObj.floatp_value(x),
print " y:", sensorObj.floatp_value(y),
print " z:", sensorObj.floatp_value(z),
print " g"
sensor.getMagnetometer(x, y, z)
print "Magnetometer x:", sensorObj.floatp_value(x),
print " y:", sensorObj.floatp_value(y),
print " z:", sensorObj.floatp_value(z),
print " uT"
print
time.sleep(.250)

66
examples/python/bmg160.py Normal file
View File

@ -0,0 +1,66 @@
#!/usr/bin/python
# 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.
import time, sys, signal, atexit
import pyupm_bmx055 as sensorObj
# Instantiate a BMP250E instance using default i2c bus and address
sensor = sensorObj.BMG160()
# For SPI, bus 0, you would pass -1 as the address, and a valid pin for CS:
# BMG160(0, -1, 10);
## Exit handlers ##
# This function stops python from printing a stacktrace when you hit control-C
def SIGINTHandler(signum, frame):
raise SystemExit
# This function lets you run code on exit
def exitHandler():
print "Exiting"
sys.exit(0)
# Register exit handlers
atexit.register(exitHandler)
signal.signal(signal.SIGINT, SIGINTHandler)
x = sensorObj.new_floatp()
y = sensorObj.new_floatp()
z = sensorObj.new_floatp()
# now output data every 250 milliseconds
while (1):
sensor.update()
sensor.getGyroscope(x, y, z)
print "Gyroscope x:", sensorObj.floatp_value(x),
print " y:", sensorObj.floatp_value(y),
print " z:", sensorObj.floatp_value(z),
print " degrees/s"
# we show both C and F for temperature
print "Compensation Temperature:", sensor.getTemperature(), "C /",
print sensor.getTemperature(True), "F"
print
time.sleep(.250)

65
examples/python/bmi055.py Normal file
View File

@ -0,0 +1,65 @@
#!/usr/bin/python
# 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.
import time, sys, signal, atexit
import pyupm_bmx055 as sensorObj
# Instantiate a BMI055 instance using default i2c bus and address
sensor = sensorObj.BMI055()
## Exit handlers ##
# This function stops python from printing a stacktrace when you hit control-C
def SIGINTHandler(signum, frame):
raise SystemExit
# This function lets you run code on exit
def exitHandler():
print "Exiting"
sys.exit(0)
# Register exit handlers
atexit.register(exitHandler)
signal.signal(signal.SIGINT, SIGINTHandler)
x = sensorObj.new_floatp()
y = sensorObj.new_floatp()
z = sensorObj.new_floatp()
# now output data every 250 milliseconds
while (1):
sensor.update()
sensor.getAccelerometer(x, y, z)
print "Accelerometer x:", sensorObj.floatp_value(x),
print " y:", sensorObj.floatp_value(y),
print " z:", sensorObj.floatp_value(z),
print " g"
sensor.getGyroscope(x, y, z)
print "Gyroscope x:", sensorObj.floatp_value(x),
print " y:", sensorObj.floatp_value(y),
print " z:", sensorObj.floatp_value(z),
print " degrees/s"
print
time.sleep(.250)

62
examples/python/bmm150.py Normal file
View File

@ -0,0 +1,62 @@
#!/usr/bin/python
# 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.
import time, sys, signal, atexit
import pyupm_bmx055 as sensorObj
# Instantiate a BMP250E instance using default i2c bus and address
sensor = sensorObj.BMM150()
# For SPI, bus 0, you would pass -1 as the address, and a valid pin for CS:
# BMM150(0, -1, 10);
## Exit handlers ##
# This function stops python from printing a stacktrace when you hit control-C
def SIGINTHandler(signum, frame):
raise SystemExit
# This function lets you run code on exit
def exitHandler():
print "Exiting"
sys.exit(0)
# Register exit handlers
atexit.register(exitHandler)
signal.signal(signal.SIGINT, SIGINTHandler)
x = sensorObj.new_floatp()
y = sensorObj.new_floatp()
z = sensorObj.new_floatp()
# now output data every 250 milliseconds
while (1):
sensor.update()
sensor.getMagnetometer(x, y, z)
print "Magnetometer x:", sensorObj.floatp_value(x),
print " y:", sensorObj.floatp_value(y),
print " z:", sensorObj.floatp_value(z),
print " uT"
print
time.sleep(.250)

71
examples/python/bmx055.py Normal file
View File

@ -0,0 +1,71 @@
#!/usr/bin/python
# 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.
import time, sys, signal, atexit
import pyupm_bmx055 as sensorObj
# Instantiate a BMX055 instance using default i2c bus and address
sensor = sensorObj.BMX055()
## Exit handlers ##
# This function stops python from printing a stacktrace when you hit control-C
def SIGINTHandler(signum, frame):
raise SystemExit
# This function lets you run code on exit
def exitHandler():
print "Exiting"
sys.exit(0)
# Register exit handlers
atexit.register(exitHandler)
signal.signal(signal.SIGINT, SIGINTHandler)
x = sensorObj.new_floatp()
y = sensorObj.new_floatp()
z = sensorObj.new_floatp()
# now output data every 250 milliseconds
while (1):
sensor.update()
sensor.getAccelerometer(x, y, z)
print "Accelerometer x:", sensorObj.floatp_value(x),
print " y:", sensorObj.floatp_value(y),
print " z:", sensorObj.floatp_value(z),
print " g"
sensor.getGyroscope(x, y, z)
print "Gyroscope x:", sensorObj.floatp_value(x),
print " y:", sensorObj.floatp_value(y),
print " z:", sensorObj.floatp_value(z),
print " degrees/s"
sensor.getMagnetometer(x, y, z)
print "Magnetometer x:", sensorObj.floatp_value(x),
print " y:", sensorObj.floatp_value(y),
print " z:", sensorObj.floatp_value(z),
print " uT"
print
time.sleep(.250)