mirror of
https://github.com/eclipse/upm.git
synced 2025-07-03 02:11:15 +03:00
bma250e,bmc150,bmg160,bmi055,bmm150,bmx055: C++ examples: use instance rather than allocation
Signed-off-by: Jon Trulson <jtrulson@ics.com>
This commit is contained in:
@ -44,30 +44,30 @@ int main(int argc, char **argv)
|
||||
//! [Interesting]
|
||||
|
||||
// Instantiate an BMX055 using default I2C parameters
|
||||
upm::BMX055 *sensor = new upm::BMX055();
|
||||
upm::BMX055 sensor;
|
||||
|
||||
// now output data every 250 milliseconds
|
||||
while (shouldRun)
|
||||
{
|
||||
float x, y, z;
|
||||
|
||||
sensor->update();
|
||||
sensor.update();
|
||||
|
||||
sensor->getAccelerometer(&x, &y, &z);
|
||||
sensor.getAccelerometer(&x, &y, &z);
|
||||
cout << "Accelerometer x: " << x
|
||||
<< " y: " << y
|
||||
<< " z: " << z
|
||||
<< " g"
|
||||
<< endl;
|
||||
|
||||
sensor->getGyroscope(&x, &y, &z);
|
||||
sensor.getGyroscope(&x, &y, &z);
|
||||
cout << "Gyroscope x: " << x
|
||||
<< " y: " << y
|
||||
<< " z: " << z
|
||||
<< " degrees/s"
|
||||
<< endl;
|
||||
|
||||
sensor->getMagnetometer(&x, &y, &z);
|
||||
sensor.getMagnetometer(&x, &y, &z);
|
||||
cout << "Magnetometer x: " << x
|
||||
<< " y: " << y
|
||||
<< " z: " << z
|
||||
@ -83,7 +83,5 @@ int main(int argc, char **argv)
|
||||
|
||||
cout << "Exiting..." << endl;
|
||||
|
||||
delete sensor;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user