Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Reset_SFLP api, astyle on examples #14

Merged
merged 1 commit into from
Sep 29, 2023
Merged
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
133 changes: 63 additions & 70 deletions examples/LSM6DSV16X_6D_Orientation/LSM6DSV16X_6D_Orientation.ino
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
@file LSM6DSV16X_HelloWorld.ino
@author STMicroelectronics
@author STMicroelectronics
@brief Example to use the LSM6DSV16X 6D Orientation
*******************************************************************************
Copyright (c) 2022, STMicroelectronics
Expand All @@ -24,7 +24,8 @@ char report[256];
void INT1Event_cb();
void sendOrientation();

void setup() {
void setup()
{

// Initlialize serial.
Serial.begin(115200);
Expand All @@ -38,7 +39,7 @@ void setup() {

// Enable INT1 pin.
attachInterrupt(INT1_pin, INT1Event_cb, RISING);

// Initlialize components.
LSM6DSV16X.begin();
LSM6DSV16X.Enable_X();
Expand All @@ -47,18 +48,17 @@ void setup() {
LSM6DSV16XStatusTypeDef ret = LSM6DSV16X.Enable_6D_Orientation(LSM6DSV16X_INT1_PIN);
}

void loop() {
if (mems_event)
{
void loop()
{
if (mems_event) {
mems_event = 0;
LSM6DSV16X_Event_Status_t status;
LSM6DSV16X.Get_X_Event_Status(&status);

if (status.D6DOrientationStatus)
{
if (status.D6DOrientationStatus) {
// Send 6D Orientation
sendOrientation();

// Led blinking.
digitalWrite(LED_BUILTIN, HIGH);
delay(100);
Expand All @@ -80,79 +80,72 @@ void sendOrientation()
uint8_t yh = 0;
uint8_t zl = 0;
uint8_t zh = 0;

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

if ( xl == 1 && yl == 0 && zl == 0 && xh == 0 && yh == 0 && zh == 0 )
{
sprintf( report, "\r\n ________________ " \
"\r\n | | " \
"\r\n | * | " \
"\r\n | | " \
"\r\n | | " \
"\r\n | | " \
"\r\n | | " \
"\r\n |________________| \r\n" );

if (xl == 1 && yl == 0 && zl == 0 && xh == 0 && yh == 0 && zh == 0) {
sprintf(report, "\r\n ________________ " \
"\r\n | | " \
"\r\n | * | " \
"\r\n | | " \
"\r\n | | " \
"\r\n | | " \
"\r\n | | " \
"\r\n |________________| \r\n");
}

else if ( xl == 0 && yl == 1 && zl == 0 && xh == 0 && yh == 0 && zh == 0 )
{
sprintf( report, "\r\n ________________ " \
"\r\n | | " \
"\r\n | * | " \
"\r\n | | " \
"\r\n | | " \
"\r\n | | " \
"\r\n | | " \
"\r\n |________________| \r\n" );

else if (xl == 0 && yl == 1 && zl == 0 && xh == 0 && yh == 0 && zh == 0) {
sprintf(report, "\r\n ________________ " \
"\r\n | | " \
"\r\n | * | " \
"\r\n | | " \
"\r\n | | " \
"\r\n | | " \
"\r\n | | " \
"\r\n |________________| \r\n");
}

else if ( xl == 0 && yl == 0 && zl == 0 && xh == 0 && yh == 1 && zh == 0 )
{
sprintf( report, "\r\n ________________ " \
"\r\n | | " \
"\r\n | | " \
"\r\n | | " \
"\r\n | | " \
"\r\n | | " \
"\r\n | * | " \
"\r\n |________________| \r\n" );

else if (xl == 0 && yl == 0 && zl == 0 && xh == 0 && yh == 1 && zh == 0) {
sprintf(report, "\r\n ________________ " \
"\r\n | | " \
"\r\n | | " \
"\r\n | | " \
"\r\n | | " \
"\r\n | | " \
"\r\n | * | " \
"\r\n |________________| \r\n");
}

else if ( xl == 0 && yl == 0 && zl == 0 && xh == 1 && yh == 0 && zh == 0 )
{
sprintf( report, "\r\n ________________ " \
"\r\n | | " \
"\r\n | | " \
"\r\n | | " \
"\r\n | | " \
"\r\n | | " \
"\r\n | * | " \
"\r\n |________________| \r\n" );

else if (xl == 0 && yl == 0 && zl == 0 && xh == 1 && yh == 0 && zh == 0) {
sprintf(report, "\r\n ________________ " \
"\r\n | | " \
"\r\n | | " \
"\r\n | | " \
"\r\n | | " \
"\r\n | | " \
"\r\n | * | " \
"\r\n |________________| \r\n");
}

else if ( xl == 0 && yl == 0 && zl == 0 && xh == 0 && yh == 0 && zh == 1 )
{
sprintf( report, "\r\n __*_____________ " \
"\r\n |________________| \r\n" );

else if (xl == 0 && yl == 0 && zl == 0 && xh == 0 && yh == 0 && zh == 1) {
sprintf(report, "\r\n __*_____________ " \
"\r\n |________________| \r\n");
}

else if ( xl == 0 && yl == 0 && zl == 1 && xh == 0 && yh == 0 && zh == 0 )
{
sprintf( report, "\r\n ________________ " \
"\r\n |________________| " \
"\r\n * \r\n" );

else if (xl == 0 && yl == 0 && zl == 1 && xh == 0 && yh == 0 && zh == 0) {
sprintf(report, "\r\n ________________ " \
"\r\n |________________| " \
"\r\n * \r\n");
}

else
{
sprintf( report, "None of the 6D orientation axes is set in accelrometer.\r\n" );

else {
sprintf(report, "None of the 6D orientation axes is set in accelrometer.\r\n");
}

Serial.print(report);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@

#include <LSM6DSV16XSensor.h>

LSM6DSV16XSensor sensor (&Wire);
LSM6DSV16XSensor sensor(&Wire);
int32_t accel[3], angrate[3];

void setup() {
void setup()
{
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(115200);
Wire.begin();
Expand All @@ -26,7 +27,8 @@ void setup() {
sensor.Enable_G();
}

void loop() {
void loop()
{
sensor.Get_X_Axes(accel);
sensor.Get_G_Axes(angrate);

Expand All @@ -47,7 +49,8 @@ void loop() {
blink(LED_BUILTIN);
}

inline void blink(int pin) {
inline void blink(int pin)
{
digitalWrite(pin, HIGH);
delay(25);
digitalWrite(pin, LOW);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
@file LSM6DSV16X_Double_Tap_Detection.ino
@author STMicroelectronics
@author STMicroelectronics
@brief Example to use the LSM6DSV16X Double Tap Detection
*******************************************************************************
Copyright (c) 2022, STMicroelectronics
Expand All @@ -21,7 +21,8 @@ LSM6DSV16XSensor LSM6DSV16X(&Wire);
volatile int mems_event = 0;
void INT1Event_cb();

void setup() {
void setup()
{

// Initlialize serial.
Serial.begin(115200);
Expand All @@ -44,15 +45,14 @@ void setup() {
LSM6DSV16X.Enable_Double_Tap_Detection(LSM6DSV16X_INT1_PIN);
}

void loop() {
if (mems_event)
{
void loop()
{
if (mems_event) {
mems_event = 0;
LSM6DSV16X_Event_Status_t status;
LSM6DSV16X.Get_X_Event_Status(&status);

if (status.DoubleTapStatus)
{
if (status.DoubleTapStatus) {
// Led blinking.
digitalWrite(LED_BUILTIN, HIGH);
delay(100);
Expand Down
Loading