Skip to content

Commit

Permalink
Merge pull request #5 from cparata/master
Browse files Browse the repository at this point in the history
Update examples to the new APIs
  • Loading branch information
cparata authored Jan 26, 2021
2 parents aa7e317 + 8dbc6eb commit aa3d41c
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
#define SerialPort Serial

// Components.
LSM6DS3Sensor *AccGyr;
LSM6DS3Sensor AccGyr(&DEV_I2C, LSM6DS3_ACC_GYRO_I2C_ADDRESS_LOW);

//Interrupts.
volatile int mems_event = 0;
Expand All @@ -74,20 +74,20 @@ void setup() {
//Interrupts.
attachInterrupt(A2, INT1Event_cb, RISING);

// Initlialize Components.
AccGyr = new LSM6DS3Sensor(&DEV_I2C, LSM6DS3_ACC_GYRO_I2C_ADDRESS_LOW);
AccGyr->Enable_X();
// Initialize Components.
AccGyr.begin();
AccGyr.Enable_X();

// Enable 6D Orientation.
AccGyr->Enable_6D_Orientation();
AccGyr.Enable_6D_Orientation();
}

void loop() {
if (mems_event)
{
mems_event = 0;
LSM6DS3_Event_Status_t status;
AccGyr->Get_Event_Status(&status);
AccGyr.Get_Event_Status(&status);
if (status.D6DOrientationStatus)
{
// Send 6D Orientation
Expand Down Expand Up @@ -115,12 +115,12 @@ void sendOrientation()
uint8_t zl = 0;
uint8_t zh = 0;

AccGyr->Get_6D_Orientation_XL(&xl);
AccGyr->Get_6D_Orientation_XH(&xh);
AccGyr->Get_6D_Orientation_YL(&yl);
AccGyr->Get_6D_Orientation_YH(&yh);
AccGyr->Get_6D_Orientation_ZL(&zl);
AccGyr->Get_6D_Orientation_ZH(&zh);
AccGyr.Get_6D_Orientation_XL(&xl);
AccGyr.Get_6D_Orientation_XH(&xh);
AccGyr.Get_6D_Orientation_YL(&yl);
AccGyr.Get_6D_Orientation_YH(&yh);
AccGyr.Get_6D_Orientation_ZL(&zl);
AccGyr.Get_6D_Orientation_ZH(&zh);

if ( xl == 0 && yl == 0 && zl == 0 && xh == 0 && yh == 1 && zh == 0 )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
#define SerialPort Serial

// Components.
LSM6DS3Sensor *AccGyr;
LSM6DS3Sensor AccGyr(&DEV_I2C, LSM6DS3_ACC_GYRO_I2C_ADDRESS_LOW);

//Interrupts.
volatile int mems_event = 0;
Expand All @@ -71,19 +71,19 @@ void setup() {
//Interrupts.
attachInterrupt(A2, INT1Event_cb, RISING);

// Initlialize Components.
AccGyr = new LSM6DS3Sensor(&DEV_I2C, LSM6DS3_ACC_GYRO_I2C_ADDRESS_LOW);
AccGyr->Enable_X();
// Initialize Components.
AccGyr.begin();
AccGyr.Enable_X();

// Enable Double Tap Detection.
AccGyr->Enable_Double_Tap_Detection();
AccGyr.Enable_Double_Tap_Detection();
}

void loop() {
if (mems_event) {
mems_event = 0;
LSM6DS3_Event_Status_t status;
AccGyr->Get_Event_Status(&status);
AccGyr.Get_Event_Status(&status);
if (status.DoubleTapStatus)
{
// Led blinking.
Expand Down
12 changes: 6 additions & 6 deletions examples/X_NUCLEO_IKS01A1_FreeFall/X_NUCLEO_IKS01A1_FreeFall.ino
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
#define SerialPort Serial

// Components.
LSM6DS3Sensor *AccGyr;
LSM6DS3Sensor AccGyr(&DEV_I2C, LSM6DS3_ACC_GYRO_I2C_ADDRESS_LOW);

//Interrupts.
volatile int mems_event = 0;
Expand All @@ -71,19 +71,19 @@ void setup() {
//Interrupts.
attachInterrupt(A2, INT1Event_cb, RISING);

// Initlialize Components.
AccGyr = new LSM6DS3Sensor(&DEV_I2C, LSM6DS3_ACC_GYRO_I2C_ADDRESS_LOW);
AccGyr->Enable_X();
// Initialize Components.
AccGyr.begin();
AccGyr.Enable_X();

// Enable Free Fall Detection.
AccGyr->Enable_Free_Fall_Detection();
AccGyr.Enable_Free_Fall_Detection();
}

void loop() {
if (mems_event) {
mems_event = 0;
LSM6DS3_Event_Status_t status;
AccGyr->Get_Event_Status(&status);
AccGyr.Get_Event_Status(&status);
if (status.FreeFallStatus)
{
// Led blinking.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@
#define SerialPort Serial

// Components.
HTS221Sensor *HumTemp;
LPS25HBSensor *PressTemp;
LSM6DS0Sensor *AccGyr;
LIS3MDLSensor *Magneto;
HTS221Sensor HumTemp(&DEV_I2C);
LPS25HBSensor PressTemp(&DEV_I2C);
LSM6DS0Sensor AccGyr(&DEV_I2C);
LIS3MDLSensor Magneto(&DEV_I2C);

void setup() {
// Led.
Expand All @@ -63,16 +63,16 @@ void setup() {
// Initialize I2C bus.
DEV_I2C.begin();

// Initlialize components.
HumTemp = new HTS221Sensor (&DEV_I2C);
HumTemp->Enable();
PressTemp = new LPS25HBSensor(&DEV_I2C);
PressTemp->Enable();
AccGyr = new LSM6DS0Sensor(&DEV_I2C);
AccGyr->Enable_X();
AccGyr->Enable_G();
Magneto = new LIS3MDLSensor(&DEV_I2C);
Magneto->Enable();
// Initialize components.
HumTemp.begin();
HumTemp.Enable();
PressTemp.begin();
PressTemp.Enable();
AccGyr.begin();
AccGyr.Enable_X();
AccGyr.Enable_G();
Magneto.begin();
Magneto.Enable();
}

void loop() {
Expand All @@ -84,24 +84,24 @@ void loop() {

// Read humidity and temperature.
float humidity, temperature;
HumTemp->GetHumidity(&humidity);
HumTemp->GetTemperature(&temperature);
HumTemp.GetHumidity(&humidity);
HumTemp.GetTemperature(&temperature);

// Read pressure.
float pressure, temperature2;
PressTemp->GetPressure(&pressure);
PressTemp->GetTemperature(&temperature2);
PressTemp.GetPressure(&pressure);
PressTemp.GetTemperature(&temperature2);


// Read accelerometer and gyroscope.
int32_t accelerometer[3];
int32_t gyroscope[3];
AccGyr->Get_X_Axes(accelerometer);
AccGyr->Get_G_Axes(gyroscope);
AccGyr.Get_X_Axes(accelerometer);
AccGyr.Get_G_Axes(gyroscope);

// Read magnetometer.
int32_t magnetometer[3];
Magneto->GetAxes(magnetometer);
Magneto.GetAxes(magnetometer);

// Output data.
SerialPort.print("| Hum[%]: ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
#define SerialPort Serial

// Components.
LSM6DS3Sensor *AccGyr;
LSM6DS3Sensor AccGyr(&DEV_I2C, LSM6DS3_ACC_GYRO_I2C_ADDRESS_LOW);

//Interrupts.
volatile int mems_event = 0;
Expand All @@ -75,31 +75,31 @@ void setup() {
attachInterrupt(A2, INT1Event_cb, RISING);
attachInterrupt(A3, INT2Event_cb, RISING);

// Initlialize Components.
AccGyr = new LSM6DS3Sensor(&DEV_I2C, LSM6DS3_ACC_GYRO_I2C_ADDRESS_LOW);
AccGyr->Enable_X();
// Initialize Components.
AccGyr.begin();
AccGyr.Enable_X();

// Enable all HW events.
AccGyr->Enable_Pedometer();
AccGyr->Enable_Tilt_Detection();
AccGyr->Enable_Free_Fall_Detection();
AccGyr->Enable_Single_Tap_Detection();
AccGyr->Enable_Double_Tap_Detection();
AccGyr->Enable_6D_Orientation();
AccGyr->Enable_Wake_Up_Detection();
AccGyr.Enable_Pedometer();
AccGyr.Enable_Tilt_Detection();
AccGyr.Enable_Free_Fall_Detection();
AccGyr.Enable_Single_Tap_Detection();
AccGyr.Enable_Double_Tap_Detection();
AccGyr.Enable_6D_Orientation();
AccGyr.Enable_Wake_Up_Detection();
}

void loop() {
if (mems_event)
{
mems_event = 0;
LSM6DS3_Event_Status_t status;
AccGyr->Get_Event_Status(&status);
AccGyr.Get_Event_Status(&status);

if (status.StepStatus)
{
// New step detected, so print the step counter
AccGyr->Get_Step_Counter(&step_count);
AccGyr.Get_Step_Counter(&step_count);
snprintf(report, sizeof(report), "Step counter: %d", step_count);
SerialPort.println(report);
}
Expand Down Expand Up @@ -161,12 +161,12 @@ void sendOrientation()
uint8_t zl = 0;
uint8_t zh = 0;

AccGyr->Get_6D_Orientation_XL(&xl);
AccGyr->Get_6D_Orientation_XH(&xh);
AccGyr->Get_6D_Orientation_YL(&yl);
AccGyr->Get_6D_Orientation_YH(&yh);
AccGyr->Get_6D_Orientation_ZL(&zl);
AccGyr->Get_6D_Orientation_ZH(&zh);
AccGyr.Get_6D_Orientation_XL(&xl);
AccGyr.Get_6D_Orientation_XH(&xh);
AccGyr.Get_6D_Orientation_YL(&yl);
AccGyr.Get_6D_Orientation_YH(&yh);
AccGyr.Get_6D_Orientation_ZL(&zl);
AccGyr.Get_6D_Orientation_ZH(&zh);

if ( xl == 0 && yl == 0 && zl == 0 && xh == 0 && yh == 1 && zh == 0 )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
#define SerialPort Serial

// Components.
LSM6DS3Sensor *AccGyr;
LSM6DS3Sensor AccGyr(&DEV_I2C, LSM6DS3_ACC_GYRO_I2C_ADDRESS_LOW);

//Interrupts.
volatile int mems_event = 0;
Expand All @@ -76,12 +76,12 @@ void setup() {
//Interrupts.
attachInterrupt(A2, INT1Event_cb, RISING);

// Initlialize Components.
AccGyr = new LSM6DS3Sensor(&DEV_I2C, LSM6DS3_ACC_GYRO_I2C_ADDRESS_LOW);
AccGyr->Enable_X();
// Initialize Components.
AccGyr.begin();
AccGyr.Enable_X();

// Enable Pedometer.
AccGyr->Enable_Pedometer();
AccGyr.Enable_Pedometer();

previous_tick = millis();
}
Expand All @@ -91,11 +91,11 @@ void loop() {
{
mems_event = 0;
LSM6DS3_Event_Status_t status;
AccGyr->Get_Event_Status(&status);
AccGyr.Get_Event_Status(&status);
if (status.StepStatus)
{
// New step detected, so print the step counter
AccGyr->Get_Step_Counter(&step_count);
AccGyr.Get_Step_Counter(&step_count);
snprintf(report, sizeof(report), "Step counter: %d", step_count);
SerialPort.println(report);

Expand All @@ -110,7 +110,7 @@ void loop() {
current_tick = millis();
if((current_tick - previous_tick) >= 3000)
{
AccGyr->Get_Step_Counter(&step_count);
AccGyr.Get_Step_Counter(&step_count);
snprintf(report, sizeof(report), "Step counter: %d", step_count);
SerialPort.println(report);
previous_tick = millis();
Expand Down
12 changes: 6 additions & 6 deletions examples/X_NUCLEO_IKS01A1_Tap/X_NUCLEO_IKS01A1_Tap.ino
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
#define SerialPort Serial

// Components.
LSM6DS3Sensor *AccGyr;
LSM6DS3Sensor AccGyr(&DEV_I2C, LSM6DS3_ACC_GYRO_I2C_ADDRESS_LOW);

//Interrupts.
volatile int mems_event = 0;
Expand All @@ -71,19 +71,19 @@ void setup() {
//Interrupts.
attachInterrupt(A2, INT1Event_cb, RISING);

// Initlialize Components.
AccGyr = new LSM6DS3Sensor(&DEV_I2C, LSM6DS3_ACC_GYRO_I2C_ADDRESS_LOW);
AccGyr->Enable_X();
// Initialize Components.
AccGyr.begin();
AccGyr.Enable_X();

// Enable Single Tap Detection.
AccGyr->Enable_Single_Tap_Detection();
AccGyr.Enable_Single_Tap_Detection();
}

void loop() {
if (mems_event) {
mems_event = 0;
LSM6DS3_Event_Status_t status;
AccGyr->Get_Event_Status(&status);
AccGyr.Get_Event_Status(&status);
if (status.TapStatus)
{
// Led blinking.
Expand Down
12 changes: 6 additions & 6 deletions examples/X_NUCLEO_IKS01A1_Tilt/X_NUCLEO_IKS01A1_Tilt.ino
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
#define SerialPort Serial

// Components.
LSM6DS3Sensor *AccGyr;
LSM6DS3Sensor AccGyr(&DEV_I2C, LSM6DS3_ACC_GYRO_I2C_ADDRESS_LOW);

//Interrupts.
volatile int mems_event = 0;
Expand All @@ -71,19 +71,19 @@ void setup() {
//Interrupts.
attachInterrupt(A2, INT1Event_cb, RISING);

// Initlialize Components.
AccGyr = new LSM6DS3Sensor(&DEV_I2C, LSM6DS3_ACC_GYRO_I2C_ADDRESS_LOW);
AccGyr->Enable_X();
// Initialize Components.
AccGyr.begin();
AccGyr.Enable_X();

// Enable Tilt Detection.
AccGyr->Enable_Tilt_Detection();
AccGyr.Enable_Tilt_Detection();
}

void loop() {
if (mems_event) {
mems_event = 0;
LSM6DS3_Event_Status_t status;
AccGyr->Get_Event_Status(&status);
AccGyr.Get_Event_Status(&status);
if (status.TiltStatus)
{
// Led blinking.
Expand Down
Loading

0 comments on commit aa3d41c

Please sign in to comment.