Skip to content

Commit a65892a

Browse files
committed
Fix reg file struct for compatibility and add CI
1 parent 6a1ca86 commit a65892a

14 files changed

Lines changed: 2124 additions & 2691 deletions

File tree

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: LSM6DSO32 Continuous Integration
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths-ignore:
7+
- '*'
8+
- '**.md'
9+
- '**.txt'
10+
pull_request:
11+
paths-ignore:
12+
- '*'
13+
- '**.md'
14+
- '**.txt'
15+
# Allows you to run this workflow manually from the Actions tab
16+
workflow_dispatch:
17+
jobs:
18+
astyle_check:
19+
runs-on: ubuntu-latest
20+
name: AStyle check
21+
steps:
22+
# First of all, clone the repo using the checkout action.
23+
- name: Checkout
24+
uses: actions/checkout@main
25+
26+
- name: Astyle check
27+
id: Astyle
28+
uses: stm32duino/actions/astyle-check@main
29+
30+
# Use the output from the `Astyle` step
31+
- name: Astyle Errors
32+
if: failure()
33+
run: |
34+
cat ${{ steps.Astyle.outputs.astyle-result }}
35+
exit 1
36+
codespell:
37+
name: Check for spelling errors
38+
runs-on: ubuntu-latest
39+
steps:
40+
- name: Checkout
41+
uses: actions/checkout@main
42+
43+
# See: https://github.com/codespell-project/actions-codespell/blob/master/README.md
44+
- name: Spell check
45+
uses: codespell-project/actions-codespell@master
46+
with:
47+
check_filenames: true
48+
check_hidden: true
49+
# In the event of a false positive, add the word in all lower case to this file:
50+
ignore_words_file: ./extras/codespell-ignore-words-list.txt
51+
lib_build:
52+
runs-on: ubuntu-latest
53+
name: Library compilation
54+
steps:
55+
# First of all, clone the repo using the checkout action.
56+
- name: Checkout
57+
uses: actions/checkout@main
58+
59+
- name: Compilation
60+
id: Compile
61+
uses: stm32duino/actions/compile-examples@main
62+
with:
63+
board-pattern: "NUCLEO_L476RG"
64+
65+
# Use the output from the `Compile` step
66+
- name: Compilation Errors
67+
if: failure()
68+
run: |
69+
cat ${{ steps.Compile.outputs.compile-result }}
70+
exit 1

examples/LSM6DSO32_6DOrientation/LSM6DSO32_6DOrientation.ino

Lines changed: 59 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
#include <LSM6DSO32Sensor.h>
1515

1616
#ifdef ARDUINO_SAM_DUE
17-
#define DEV_I2C Wire1
17+
#define DEV_I2C Wire1
1818
#elif defined(ARDUINO_ARCH_STM32)
19-
#define DEV_I2C Wire
19+
#define DEV_I2C Wire
2020
#elif defined(ARDUINO_ARCH_AVR)
21-
#define DEV_I2C Wire
21+
#define DEV_I2C Wire
2222
#else
23-
#define DEV_I2C Wire
23+
#define DEV_I2C Wire
2424
#endif
2525
#define SerialPort Serial
2626

@@ -36,15 +36,16 @@ char report[256];
3636
void INT1Event_cb();
3737
void sendOrientation();
3838

39-
void setup() {
39+
void setup()
40+
{
4041
// Led.
4142
pinMode(LED_BUILTIN, OUTPUT);
4243
// Initialize serial for output.
4344
SerialPort.begin(115200);
4445

4546
// Initialize I2C bus.
4647
DEV_I2C.begin();
47-
48+
4849
//Int1 pin input
4950
pinMode(IMU_INT_1, INPUT);
5051

@@ -53,26 +54,24 @@ void setup() {
5354
accGyr.Enable_6D_Orientation(LSM6DSO32_INT1_PIN);
5455
}
5556

56-
void loop() {
57+
void loop()
58+
{
5759

5860
int int_val = digitalRead(IMU_INT_1);
59-
if(int_val && !mems_event)
60-
{
61+
if (int_val && !mems_event) {
6162
mems_event = 1;
6263
}
6364

64-
if (mems_event)
65-
{
66-
mems_event=0;
65+
if (mems_event) {
66+
mems_event = 0;
6767
LSM6DSO32_Event_Status_t status;
6868
accGyr.Get_X_Event_Status(&status);
69-
if (status.D6DOrientationStatus)
70-
{
69+
if (status.D6DOrientationStatus) {
7170
sendOrientation();
7271
// Led blinking.
7372
digitalWrite(LED_BUILTIN, HIGH);
7473
delay(100);
75-
digitalWrite(LED_BUILTIN, LOW);
74+
digitalWrite(LED_BUILTIN, LOW);
7675
}
7776
}
7877
}
@@ -93,70 +92,63 @@ void sendOrientation()
9392
accGyr.Get_6D_Orientation_ZL(&zl);
9493
accGyr.Get_6D_Orientation_ZH(&zh);
9594

96-
if ( xl == 0 && yl == 0 && zl == 0 && xh == 0 && yh == 1 && zh == 0 )
97-
{
98-
sprintf( report, "\r\n ________________ " \
99-
"\r\n | | " \
100-
"\r\n | * | " \
101-
"\r\n | | " \
102-
"\r\n | | " \
103-
"\r\n | | " \
104-
"\r\n | | " \
105-
"\r\n |________________| \r\n" );
95+
if (xl == 0 && yl == 0 && zl == 0 && xh == 0 && yh == 1 && zh == 0) {
96+
sprintf(report, "\r\n ________________ " \
97+
"\r\n | | " \
98+
"\r\n | * | " \
99+
"\r\n | | " \
100+
"\r\n | | " \
101+
"\r\n | | " \
102+
"\r\n | | " \
103+
"\r\n |________________| \r\n");
106104
}
107105

108-
else if ( xl == 1 && yl == 0 && zl == 0 && xh == 0 && yh == 0 && zh == 0 )
109-
{
110-
sprintf( report, "\r\n ________________ " \
111-
"\r\n | | " \
112-
"\r\n | * | " \
113-
"\r\n | | " \
114-
"\r\n | | " \
115-
"\r\n | | " \
116-
"\r\n | | " \
117-
"\r\n |________________| \r\n" );
106+
else if (xl == 1 && yl == 0 && zl == 0 && xh == 0 && yh == 0 && zh == 0) {
107+
sprintf(report, "\r\n ________________ " \
108+
"\r\n | | " \
109+
"\r\n | * | " \
110+
"\r\n | | " \
111+
"\r\n | | " \
112+
"\r\n | | " \
113+
"\r\n | | " \
114+
"\r\n |________________| \r\n");
118115
}
119116

120-
else if ( xl == 0 && yl == 0 && zl == 0 && xh == 1 && yh == 0 && zh == 0 )
121-
{
122-
sprintf( report, "\r\n ________________ " \
123-
"\r\n | | " \
124-
"\r\n | | " \
125-
"\r\n | | " \
126-
"\r\n | | " \
127-
"\r\n | | " \
128-
"\r\n | * | " \
129-
"\r\n |________________| \r\n" );
117+
else if (xl == 0 && yl == 0 && zl == 0 && xh == 1 && yh == 0 && zh == 0) {
118+
sprintf(report, "\r\n ________________ " \
119+
"\r\n | | " \
120+
"\r\n | | " \
121+
"\r\n | | " \
122+
"\r\n | | " \
123+
"\r\n | | " \
124+
"\r\n | * | " \
125+
"\r\n |________________| \r\n");
130126
}
131127

132-
else if ( xl == 0 && yl == 1 && zl == 0 && xh == 0 && yh == 0 && zh == 0 )
133-
{
134-
sprintf( report, "\r\n ________________ " \
135-
"\r\n | | " \
136-
"\r\n | | " \
137-
"\r\n | | " \
138-
"\r\n | | " \
139-
"\r\n | | " \
140-
"\r\n | * | " \
141-
"\r\n |________________| \r\n" );
128+
else if (xl == 0 && yl == 1 && zl == 0 && xh == 0 && yh == 0 && zh == 0) {
129+
sprintf(report, "\r\n ________________ " \
130+
"\r\n | | " \
131+
"\r\n | | " \
132+
"\r\n | | " \
133+
"\r\n | | " \
134+
"\r\n | | " \
135+
"\r\n | * | " \
136+
"\r\n |________________| \r\n");
142137
}
143138

144-
else if ( xl == 0 && yl == 0 && zl == 0 && xh == 0 && yh == 0 && zh == 1 )
145-
{
146-
sprintf( report, "\r\n __*_____________ " \
147-
"\r\n |________________| \r\n" );
139+
else if (xl == 0 && yl == 0 && zl == 0 && xh == 0 && yh == 0 && zh == 1) {
140+
sprintf(report, "\r\n __*_____________ " \
141+
"\r\n |________________| \r\n");
148142
}
149143

150-
else if ( xl == 0 && yl == 0 && zl == 1 && xh == 0 && yh == 0 && zh == 0 )
151-
{
152-
sprintf( report, "\r\n ________________ " \
153-
"\r\n |________________| " \
154-
"\r\n * \r\n" );
144+
else if (xl == 0 && yl == 0 && zl == 1 && xh == 0 && yh == 0 && zh == 0) {
145+
sprintf(report, "\r\n ________________ " \
146+
"\r\n |________________| " \
147+
"\r\n * \r\n");
155148
}
156149

157-
else
158-
{
159-
sprintf( report, "None of the 6D orientation axes is set in LSM6DSO - accelerometer.\r\n" );
150+
else {
151+
sprintf(report, "None of the 6D orientation axes is set in LSM6DSO - accelerometer.\r\n");
160152
}
161153

162154
SerialPort.print(report);

examples/LSM6DSO32_DoubleTap/LSM6DSO32_DoubleTap.ino

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
#include <LSM6DSO32Sensor.h>
1515

1616
#ifdef ARDUINO_SAM_DUE
17-
#define DEV_I2C Wire1
17+
#define DEV_I2C Wire1
1818
#elif defined(ARDUINO_ARCH_STM32)
19-
#define DEV_I2C Wire
19+
#define DEV_I2C Wire
2020
#elif defined(ARDUINO_ARCH_AVR)
21-
#define DEV_I2C Wire
21+
#define DEV_I2C Wire
2222
#else
23-
#define DEV_I2C Wire
23+
#define DEV_I2C Wire
2424
#endif
2525
#define SerialPort Serial
2626

@@ -31,15 +31,16 @@ LSM6DSO32Sensor accGyr(&DEV_I2C);
3131
//Interrupts.
3232
volatile int mems_event = 0;
3333

34-
void setup() {
34+
void setup()
35+
{
3536
// Led.
3637
pinMode(LED_BUILTIN, OUTPUT);
3738
// Initialize serial for output.
3839
SerialPort.begin(115200);
3940

4041
// Initialize I2C bus.
4142
DEV_I2C.begin();
42-
43+
4344
//Int1 pin input
4445
pinMode(IMU_INT_1, INPUT);
4546

@@ -48,21 +49,19 @@ void setup() {
4849
accGyr.Enable_Double_Tap_Detection(LSM6DSO32_INT1_PIN);
4950
}
5051

51-
void loop() {
52+
void loop()
53+
{
5254

5355
int int_val = digitalRead(IMU_INT_1);
54-
if(int_val && !mems_event)
55-
{
56+
if (int_val && !mems_event) {
5657
mems_event = 1;
5758
}
5859

59-
if (mems_event)
60-
{
61-
mems_event=0;
60+
if (mems_event) {
61+
mems_event = 0;
6262
LSM6DSO32_Event_Status_t status;
6363
accGyr.Get_X_Event_Status(&status);
64-
if (status.DoubleTapStatus)
65-
{
64+
if (status.DoubleTapStatus) {
6665
// Output data.
6766
SerialPort.println("Double Tap Detected!");
6867

examples/LSM6DSO32_FreeFallDetection/LSM6DSO32_FreeFallDetection.ino

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515

1616

1717
#ifdef ARDUINO_SAM_DUE
18-
#define DEV_I2C Wire1
18+
#define DEV_I2C Wire1
1919
#elif defined(ARDUINO_ARCH_STM32)
20-
#define DEV_I2C Wire
20+
#define DEV_I2C Wire
2121
#elif defined(ARDUINO_ARCH_AVR)
22-
#define DEV_I2C Wire
22+
#define DEV_I2C Wire
2323
#else
24-
#define DEV_I2C Wire
24+
#define DEV_I2C Wire
2525
#endif
2626
#define SerialPort Serial
2727

@@ -32,15 +32,16 @@ LSM6DSO32Sensor accGyr(&DEV_I2C);
3232
//Interrupts.
3333
volatile int mems_event = 0;
3434

35-
void setup() {
35+
void setup()
36+
{
3637
// Led.
3738
pinMode(LED_BUILTIN, OUTPUT);
3839
// Initialize serial for output.
3940
SerialPort.begin(115200);
4041

4142
// Initialize I2C bus.
4243
DEV_I2C.begin();
43-
44+
4445
//Int1 pin input
4546
pinMode(IMU_INT_1, INPUT);
4647

@@ -49,27 +50,25 @@ void setup() {
4950
accGyr.Enable_Free_Fall_Detection(LSM6DSO32_INT1_PIN);
5051
}
5152

52-
void loop() {
53+
void loop()
54+
{
5355

5456
int int_val = digitalRead(IMU_INT_1);
55-
if(int_val && !mems_event)
56-
{
57+
if (int_val && !mems_event) {
5758
mems_event = 1;
5859
}
5960

60-
if (mems_event)
61-
{
62-
mems_event=0;
61+
if (mems_event) {
62+
mems_event = 0;
6363
LSM6DSO32_Event_Status_t status;
6464
accGyr.Get_X_Event_Status(&status);
65-
if (status.FreeFallStatus)
66-
{
65+
if (status.FreeFallStatus) {
6766
// Led blinking.
6867
digitalWrite(LED_BUILTIN, HIGH);
6968
delay(200);
7069
digitalWrite(LED_BUILTIN, LOW);
7170
// Output data.
72-
SerialPort.println("Free Fall Detected!");
71+
SerialPort.println("Free Fall Detected!");
7372
}
7473
}
7574
}

0 commit comments

Comments
 (0)