Skip to content

Commit 86c804e

Browse files
authored
Merge pull request #5 from canchebagur/add-docs
Add docs folder
2 parents c9d19b3 + ac9b1b0 commit 86c804e

File tree

2 files changed

+357
-0
lines changed

2 files changed

+357
-0
lines changed

docs/api.md

Lines changed: 340 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,340 @@
1+
# ArduinoLSM6DSOX library
2+
3+
## Methods
4+
5+
### `begin()`
6+
7+
Initialize the IMU.
8+
9+
#### Syntax
10+
11+
```
12+
IMU.begin()
13+
```
14+
15+
#### Parameters
16+
17+
None.
18+
19+
#### Returns
20+
21+
1 on success, 0 on failure.
22+
23+
#### Example
24+
25+
```
26+
if (!IMU.begin()) {
27+
Serial.println("Failed to initialize IMU!");
28+
while (1);
29+
}
30+
```
31+
32+
#### See also
33+
34+
* [end()](#end)
35+
* [readAcceleration()](#readAcceleration)
36+
* [readGyroscope()](#readGyroscope)
37+
* [accelerationAvailable()](#accelerationAvailable)
38+
* [gyroscopeAvailable()](#gyroscopeAvailable)
39+
* [accelerationSampleRate()](#accelerationSampleRate)
40+
* [gyroscopeSampleRate()](#gyroscopeSampleRate)
41+
42+
### `end()`
43+
44+
De-initialize the IMU.
45+
46+
#### Syntax
47+
48+
```
49+
IMU.end()
50+
```
51+
52+
#### Parameters
53+
54+
None.
55+
56+
#### Returns
57+
58+
None.
59+
60+
#### Example
61+
62+
```
63+
if (!IMU.begin()) {
64+
Serial.println("Failed to initialize IMU!");
65+
while (1);
66+
}
67+
68+
// Read IMU data...
69+
70+
// Done with the IMU readings
71+
IMU.end();
72+
```
73+
74+
#### See also
75+
76+
* [begin()](#begin)
77+
* [readAcceleration()](#readAcceleration)
78+
* [readGyroscope()](#readGyroscope)
79+
* [accelerationAvailable()](#accelerationAvailable)
80+
* [gyroscopeAvailable()](#gyroscopeAvailable)
81+
* [accelerationSampleRate()](#accelerationSampleRate)
82+
* [gyroscopeSampleRate()](#gyroscopeSampleRate)
83+
84+
### `readAcceleration()`
85+
86+
Query the IMU's accelerometer and return the acceleration in g's.
87+
88+
#### Syntax
89+
90+
```
91+
IMU.readAcceleration(x,y,z)
92+
```
93+
94+
#### Parameters
95+
96+
* _x_: float variable where the acceleration value in the IMU's x-axis will be stored.
97+
* _y_: float variable where the acceleration value in the IMU's y-axis will be stored.
98+
* _z_: float variable where the acceleration value in the IMU's z-axis will be stored.
99+
100+
#### Returns
101+
102+
1 on success, 0 on failure.
103+
104+
#### Example
105+
106+
```
107+
float x, y, z;
108+
109+
if (IMU.accelerationAvailable()) {
110+
IMU.readAcceleration(x, y, z);
111+
112+
Serial.print(x);
113+
Serial.print('\t');
114+
Serial.print(y);
115+
Serial.print('\t');
116+
Serial.println(z);
117+
}
118+
```
119+
120+
#### See also
121+
122+
* [begin()](#begin)
123+
* [end()](#end)
124+
* [readGyroscope()](#readGyroscope)
125+
* [accelerationAvailable()](#accelerationAvailable)
126+
* [gyroscopeAvailable()](#gyroscopeAvailable)
127+
* [accelerationSampleRate()](#accelerationSampleRate)
128+
* [gyroscopeSampleRate()](#gyroscopeSampleRate)
129+
130+
### `readGyroscope()`
131+
132+
Query the IMU's gyroscope and return the angular speed in dps (degrees per second).
133+
134+
#### Syntax
135+
136+
```
137+
IMU.readGyroscope(x,y,z)
138+
```
139+
140+
#### Parameters
141+
142+
* _x_: float variable where the gyroscope value in the IMU's x-axis will be stored.
143+
* _y_: float variable where the gyroscope value in the IMU's y-axis will be stored.
144+
* _z_: float variable where the gyroscope value in the IMU's z-axis will be stored.
145+
146+
#### Returns
147+
148+
1 on success, 0 on failure.
149+
150+
#### Example
151+
152+
```
153+
float x, y, z;
154+
155+
if (IMU.gyroscopeAvailable()) {
156+
IMU.readGyroscope(x, y, z);
157+
158+
Serial.print(x);
159+
Serial.print('\t');
160+
Serial.print(y);
161+
Serial.print('\t');
162+
Serial.println(z);
163+
}
164+
```
165+
166+
#### See also
167+
168+
* [begin()](#begin)
169+
* [end()](#end)
170+
* [readAcceleration()](#readAcceleration)
171+
* [accelerationAvailable()](#accelerationAvailable)
172+
* [gyroscopeAvailable()](#gyroscopeAvailable)
173+
* [accelerationSampleRate()](#accelerationSampleRate)
174+
* [gyroscopeSampleRate()](#gyroscopeSampleRate)
175+
176+
### `accelerationAvailable()`
177+
178+
Query if new acceleration data from the IMU is available.
179+
180+
#### Syntax
181+
182+
```
183+
IMU.accelerationAvailable()
184+
```
185+
186+
#### Parameters
187+
188+
None.
189+
190+
#### Returns
191+
192+
0 if no new acceleration data is available, 1 if new acceleration data is available.
193+
194+
#### Example
195+
196+
```
197+
float x, y, z;
198+
199+
if (IMU.accelerationAvailable()) {
200+
IMU.readAcceleration(x, y, z);
201+
202+
Serial.print(x);
203+
Serial.print('\t');
204+
Serial.print(y);
205+
Serial.print('\t');
206+
Serial.println(z);
207+
}
208+
```
209+
210+
#### See also
211+
212+
* [begin()](#begin)
213+
* [end()](#end)
214+
* [readAcceleration()](#readAcceleration)
215+
* [readGyroscope()](#readGyroscope)
216+
* [gyroscopeAvailable()](#gyroscopeAvailable)
217+
* [accelerationSampleRate()](#accelerationSampleRate)
218+
* [gyroscopeSampleRate()](#gyroscopeSampleRate)
219+
220+
### `gyroscopeAvailable()`
221+
222+
Query if new gyroscope data from the IMU is available.
223+
224+
#### Syntax
225+
226+
```
227+
IMU.gyroscopeAvailable()
228+
```
229+
230+
#### Parameters
231+
232+
None.
233+
234+
#### Returns
235+
236+
0 if no new gyroscope data is available, 1 if new gyroscope data is available.
237+
238+
#### Example
239+
240+
```
241+
float x, y, z;
242+
243+
if (IMU.gyroscopeAvailable()) {
244+
IMU.readGyroscope(x, y, z);
245+
246+
Serial.print(x);
247+
Serial.print('\t');
248+
Serial.print(y);
249+
Serial.print('\t');
250+
Serial.println(z);
251+
}
252+
```
253+
254+
#### See also
255+
256+
* [begin()](#begin)
257+
* [end()](#end)
258+
* [readAcceleration()](#readAcceleration)
259+
* [readGyroscope()](#readGyroscope)
260+
* [accelerationAvailable()](#accelerationAvailable)
261+
* [accelerationSampleRate()](#accelerationSampleRate)
262+
* [gyroscopeSampleRate()](#gyroscopeSampleRate)
263+
264+
### `accelerationSampleRate()`
265+
266+
Return the IMU's accelerometer sample rate.
267+
268+
#### Syntax
269+
270+
```
271+
IMU.accelerationSampleRate()
272+
```
273+
274+
#### Parameters
275+
276+
None.
277+
278+
#### Returns
279+
280+
The IMU's accelerometer sample rate in Hz.
281+
282+
#### Example
283+
284+
```
285+
Serial.print("Accelerometer sample rate = ");
286+
Serial.print(IMU.accelerationSampleRate());
287+
Serial.println(" Hz");
288+
Serial.println();
289+
Serial.println("Acceleration in g's");
290+
Serial.println("X\tY\tZ");
291+
```
292+
293+
#### See also
294+
295+
* [begin()](#begin)
296+
* [end()](#end)
297+
* [readAcceleration()](#readAcceleration)
298+
* [readGyroscope()](#readGyroscope)
299+
* [accelerationAvailable()](#accelerationAvailable)
300+
* [gyroscopeAvailable()](#gyroscopeAvailable)
301+
* [gyroscopeSampleRate()](#gyroscopeSampleRate)
302+
303+
### `gyroscopeSampleRate()`
304+
305+
Return the IMU's gyroscope sample rate.
306+
307+
#### Syntax
308+
309+
```
310+
IMU.gyroscopeSampleRate()
311+
```
312+
313+
#### Parameters
314+
315+
None.
316+
317+
#### Returns
318+
319+
The IMU's gyroscope sample rate in Hz.
320+
321+
#### Example
322+
323+
```
324+
Serial.print("Gyroscope sample rate = ");
325+
Serial.print(IMU.gyroscopeSampleRate());
326+
Serial.println(" Hz");
327+
Serial.println();
328+
Serial.println("Angular speed in degrees/second");
329+
Serial.println("X\tY\tZ");
330+
```
331+
332+
#### See also
333+
334+
* [begin()](#begin)
335+
* [end()](#end)
336+
* [readAcceleration()](#readAcceleration)
337+
* [readGyroscope()](#readGyroscope)
338+
* [accelerationAvailable()](#accelerationAvailable)
339+
* [gyroscopeAvailable()](#gyroscopeAvailable)
340+
* [accelerationSampleRate()](#accelerationSampleRate)

docs/readme.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# ArduinoLSM6DSOX library
2+
3+
4+
The ArduinoLSM6DSOX library allows you to use the inertial measurement unit (IMU) available on the Arduino® Nano RP2040 Connect board. The IMU is a LSM6DSOX, it is a 3-axis accelerometer and 3-axis gyroscope. The IMU is connected to the Nano RP2040 Connect board's microcontroller through I2C. The values returned are signed floats.
5+
6+
To use this library:
7+
8+
```
9+
#include <Arduino_LSM6DSOX.h>
10+
```
11+
12+
The ArduinoLSM6DSOX library takes care of the sensor initialization and sets its values as follows:
13+
14+
- Accelerometer range is set at ±4 g with a resolution of 0.122 mg.
15+
- Gyroscope range is set at ±2000 dps with a resolution of 70 mdps.
16+
- Accelerometer and gyrospcope output data rate is fixed at 104 Hz.
17+

0 commit comments

Comments
 (0)