|
upm
0.2.0
Sensor/Actuator repository for libmraa (v0.6.1)
|
C++ API for the MMA7660 I2C 3-axis digital accelerometer. More...
UPM module for the MMA7660 I2C 3-axis digital accelerometer. This device supports a variety of capabilities, including the generation of interrupts for various conditions, tilt and basic gesture detection, and of course X/Y/Z measurements of g-forces being applied (up to 1.5g)
This module was tested with the Grove 3-Axis Digital Accelerometer (1.5g)
Public Member Functions | |
| MMA7660 (int bus, uint8_t address=MMA7660_DEFAULT_I2C_ADDR) | |
| ~MMA7660 () | |
| bool | writeByte (uint8_t reg, uint8_t byte) |
| uint8_t | readByte (uint8_t reg) |
| void | getRawValues (int *x, int *y, int *z) |
| void | getAcceleration (float *ax, float *ay, float *az) |
| int | getVerifiedAxis (MMA7660_REG_T axis) |
| uint8_t | getVerifiedTilt () |
| void | setModeActive () |
| void | setModeStandby () |
| uint8_t | tiltBackFront () |
| uint8_t | tiltLandscapePortrait () |
| bool | tiltTap () |
| bool | tiltShake () |
| void | installISR (int pin, void(*isr)(void *), void *arg) |
| void | uninstallISR () |
| bool | setInterruptBits (uint8_t ibits) |
| bool | setSampleRate (MMA7660_AUTOSLEEP_T sr) |
| MMA7660 | ( | int | bus, |
| uint8_t | address = MMA7660_DEFAULT_I2C_ADDR |
||
| ) |
mma7660 constructor
| bus | i2c bus to use |
| address | the address for this sensor; default is 0x55 |
| bool writeByte | ( | uint8_t | reg, |
| uint8_t | byte | ||
| ) |
Write byte value into register
| reg | register location to write into |
| byte | byte to write |
| uint8_t readByte | ( | uint8_t | reg | ) |
Read byte value from register
| reg | register location to read from |
| void getRawValues | ( | int * | x, |
| int * | y, | ||
| int * | z | ||
| ) |
Read current value of conversion
| x | returned x value |
| y | returned y value |
| z | returned z value |
| void getAcceleration | ( | float * | ax, |
| float * | ay, | ||
| float * | az | ||
| ) |
Get the computed acceleration
| ax | returned computed acceleration of X axis |
| ay | returned computed acceleration of Y axis |
| az | returned computed acceleration of Z axis |
| int getVerifiedAxis | ( | MMA7660_REG_T | axis | ) |
Read an axis, verifying it's validity. The value passed must be one of REG_XOUT, REG_YOUT, or REG_ZOUT.
| axis | axis to read |
| uint8_t getVerifiedTilt | ( | ) |
Read the tilt register, verifying it's validity.
| void setModeActive | ( | ) |
Put the device into active mode. In active mode, register write are not allowed. Place the device in Standby mode before attempting to write registers.
| void setModeStandby | ( | ) |
Put the device into Standby (power saving) mode. Note, when in standby mode, there will be no valid data in the registers. In addition, the only way to write a register is to place the device in standby mode.
| uint8_t tiltBackFront | ( | ) |
Read tilt BackFront bits
The value returned will be one of the MMA7660_TILT_BF_T values
| uint8_t tiltLandscapePortrait | ( | ) |
Read tilt LandscapePortrait bits
The value returned will be one of the MMA7660_TILT_LP_T values
| bool tiltTap | ( | ) |
read the tilt Tap status
| bool tiltShake | ( | ) |
read the tilt Shake status
| void installISR | ( | int | pin, |
| void(*)(void *) | isr, | ||
| void * | arg | ||
| ) |
Install an Interrupt Service Routine (ISR) to be called when an interrupt occurs
| pin | gpio pin to use as interrupt pin |
| fptr | function pointer to function to be called on interrupt |
| arg | pointer to an object that will be supplied as an argument to the ISR. |
| void uninstallISR | ( | ) |
Uninstall the previously installed Interrupt Service Routine (ISR)
| bool setInterruptBits | ( | uint8_t | ibits | ) |
Enable interrupt generation based on the passed interrupt bits. The bits are a bit mask of the requested MMA7660_INTR_T values. Note: The device must be in standby mode to set this register.
| ibits | set the requested interrupt bits |
| bool setSampleRate | ( | MMA7660_AUTOSLEEP_T | sr | ) |
Set the sampling rate of the sensor. The value supplied must be one of the MMA7660_AUTOSLEEP_T values.
| sr | one of the MMA7660_AUTOSLEEP_T values |
1.8.9.1