Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
LIS302i2c Class Reference
An interface for the LIS302 triple axis I2C accelerometer. More...
#include <LIS302i2c.h>
Public Member Functions | |
| LIS302i2c (int addr, PinName sda, PinName scl) | |
| Create an LIS302 interface, connected to the specified pins. | |
| float | getX () |
| Read the X axis acceleration. | |
| float | getY () |
| Read the Y axis acceleration. | |
| float | getZ () |
| Read the Z axis acceleration. | |
| void | range (int g) |
| Select the range of the accelerometer. | |
| void | calibrate (float maxx=1, float minx=-1, float maxy=1, float miny=-1, float maxz=1, float minz=-1) |
| Configure the minima and maxima for the axes to linearise the readings. | |
Detailed Description
An interface for the LIS302 triple axis I2C accelerometer.
// Print out the Z axis acceleration #include "mbed.h" #include "LIS302i2c.h" LIS302i2c acc(p28, p27); // sda, scl int main() { while(1) { printf("Z axis acceleration = %.2f\n", acc.getZ()); wait(0.1); } }
Definition at line 46 of file LIS302i2c.h.
Constructor & Destructor Documentation
| LIS302i2c | ( | int | addr, |
| PinName | sda, | ||
| PinName | scl | ||
| ) |
Create an LIS302 interface, connected to the specified pins.
- Parameters:
-
sda I2C data line pin scl I2C clock line pin
Definition at line 59 of file LIS302i2c.cpp.
Member Function Documentation
| void calibrate | ( | float | maxx = 1, |
| float | minx = -1, |
||
| float | maxy = 1, |
||
| float | miny = -1, |
||
| float | maxz = 1, |
||
| float | minz = -1 |
||
| ) |
Configure the minima and maxima for the axes to linearise the readings.
- Parameters:
-
maxx float defining the maximum X value minx float defining the minimum X value maxy float defining the maximum Y value miny float defining the minimum Y value maxz float defining the maximum Z value minz float defining the minimum Z value
Definition at line 163 of file LIS302i2c.cpp.
| float getX | ( | ) |
Read the X axis acceleration.
- Returns:
- A floating-point value representing acceleration in g
Definition at line 99 of file LIS302i2c.cpp.
| float getY | ( | ) |
Read the Y axis acceleration.
- Returns:
- A floating-point value representing acceleration in g
Definition at line 113 of file LIS302i2c.cpp.
| float getZ | ( | ) |
Read the Z axis acceleration.
- Returns:
- - A floating-point value representing acceleration in g
Definition at line 127 of file LIS302i2c.cpp.
| void range | ( | int | g ) |
Select the range of the accelerometer.
- Parameters:
-
range 0 = 2g, 1 = 8g
Definition at line 141 of file LIS302i2c.cpp.
Generated on Thu Jul 14 2022 16:48:00 by
1.7.2