mbed RPC_Serial for LabVIEW interface: http://mbed.org/cookbook/Interfacing-with-LabVIEW http://mbed.org/cookbook/Interfacing-Using-RPC Steps: *Compile RPC_Serial main *Copy bit file to mbed flash and reset *Run examples in LabVIEW
Dependencies: C12832 MMA7660 RPCInterface mbed
Fork of RPC_Serial by
MMA7660 Class Reference
An interface for the MMA7660 triple axis accelerometer. More...
#include <MMA7660.h>
Public Types | |
enum | Orientation |
The 6 different orientations and unknown. More... | |
Public Member Functions | |
MMA7660 (PinName sda, PinName scl, bool active=true) | |
Creates a new MMA7660 object. | |
bool | testConnection (void) |
Tests if communication is possible with the MMA7660. | |
void | setActive (bool state) |
Sets the active state of the MMA7660. | |
void | readData (int *data) |
Reads acceleration data from the sensor. | |
float | x (void) |
Get X-data. | |
float | y (void) |
Get Y-data. | |
float | z (void) |
Get Z-data. | |
void | setSampleRate (int samplerate) |
Sets the active samplerate. | |
Orientation | getSide (void) |
Returns if it is on its front, back, or unknown side. | |
Orientation | getOrientation (void) |
Returns if it is on it left, right, down or up side. |
Detailed Description
An interface for the MMA7660 triple axis accelerometer.
//Uses the measured z-acceleration to drive leds 2 and 3 of the mbed #include "mbed.h" #include "MMA7660.h" MMA7660 MMA(p28, p27); DigitalOut connectionLed(LED1); PwmOut Zaxis_p(LED2); PwmOut Zaxis_n(LED3); int main() { if (MMA.testConnection()) connectionLed = 1; while(1) { Zaxis_p = MMA.z(); Zaxis_n = -MMA.z(); } }
Definition at line 63 of file MMA7660.h.
Member Enumeration Documentation
enum Orientation |
Constructor & Destructor Documentation
MMA7660 | ( | PinName | sda, |
PinName | scl, | ||
bool | active = true |
||
) |
Creates a new MMA7660 object.
- Parameters:
-
sda - I2C data pin scl - I2C clock pin active - true (default) to enable the device, false to keep it standby
Member Function Documentation
Orientation getOrientation | ( | void | ) |
Returns if it is on it left, right, down or up side.
This is read from MMA7760s registers, page 12 of datasheet
- Parameters:
-
return - Left, Right, Down, Up or Unknown orientation
Orientation getSide | ( | void | ) |
Returns if it is on its front, back, or unknown side.
This is read from MMA7760s registers, page 12 of datasheet
- Parameters:
-
return - Front, Back or Unknown orientation
void readData | ( | int * | data ) |
Reads acceleration data from the sensor.
When the parameter is a pointer to an integer array it will be the raw data. When it is a pointer to a float array it will be the acceleration in g's
- Parameters:
-
data - pointer to array with length 3 where the acceleration data will be stored, X-Y-Z
void setActive | ( | bool | state ) |
Sets the active state of the MMA7660.
Note: This is unrelated to awake/sleep mode
- Parameters:
-
state - true for active, false for standby
void setSampleRate | ( | int | samplerate ) |
Sets the active samplerate.
The entered samplerate will be rounded to nearest supported samplerate. Supported samplerates are: 120 - 64 - 32 - 16 - 8 - 4 - 2 - 1 samples/second.
- Parameters:
-
samplerate - the samplerate that will be set
bool testConnection | ( | void | ) |
float x | ( | void | ) |
Get X-data.
- Parameters:
-
return - X-acceleration in g's
float y | ( | void | ) |
Get Y-data.
- Parameters:
-
return - Y-acceleration in g's
float z | ( | void | ) |
Get Z-data.
- Parameters:
-
return - Z-acceleration in g's
Generated on Wed Jul 13 2022 21:28:32 by 1.7.2