Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions examples/c++/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 changes: 83 additions & 0 deletions examples/c++/bma250e.cxx
Original file line number Diff line number Diff line change
@@ -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 changes: 82 additions & 0 deletions examples/c++/bmc150.cxx
Original file line number Diff line number Diff line change
@@ -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 changes: 83 additions & 0 deletions examples/c++/bmg160.cxx
Original file line number Diff line number Diff line change
@@ -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 changes: 82 additions & 0 deletions examples/c++/bmi055.cxx
Original file line number Diff line number Diff line change
@@ -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;
}
Loading