Engduino
3.1.0
A fun device for learning coding
|
Files | |
file | EngduinoAccelerometer.cpp |
file | EngduinoAccelerometer.h |
Classes | |
class | EngduinoAccelerometerClass |
Functions | |
EngduinoAccelerometerClass::EngduinoAccelerometerClass () | |
Constructor. More... | |
void | EngduinoAccelerometerClass::begin () |
begin function - must be called before using other functions More... | |
void | EngduinoAccelerometerClass::end () |
end function - switch off the button More... | |
void | EngduinoAccelerometerClass::xyz (float buf[3]) |
Read the xyz values in g from the accelerometer. More... | |
void | EngduinoAccelerometerClass::xyzRaw (uint16_t buf[3]) |
Read the raw xyz values from the accelerometer. More... | |
Variables | |
EngduinoAccelerometerClass | EngduinoAccelerometer = EngduinoAccelerometerClass() |
EngduinoAccelerometerClass | EngduinoAccelerometer |
Much of this header file was created by Freescale
This is the driver code for Accelerometer on the Engduino In v1.0 this accelerometer is a freescale MMA8652
void EngduinoAccelerometerClass::begin | ( | ) |
begin function - must be called before using other functions
This function enables the accelerometer. The accelerometer is an I2C device so we initialise the I2C communications, make contact with the accelerometer, and check that it's what we think it is.
We set the accelerometer to its 2G range, and don't use a FIFO. Other options are possible, but will need to be implemented in this driver.
void EngduinoAccelerometerClass::end | ( | ) |
end function - switch off the button
Send the accelerometer to sleep
EngduinoAccelerometerClass::EngduinoAccelerometerClass | ( | ) |
Constructor.
C++ constructor for this class. Empty.
void EngduinoAccelerometerClass::xyz | ( | float | buf[3] | ) |
Read the xyz values in g from the accelerometer.
buf | A buffer of floats to put the accelerometer values in g into |
Get the instantaneous accelerometer values for the xyz axes. Convert the 12 bit digital value to a float value that is expressed in g.
void EngduinoAccelerometerClass::xyzRaw | ( | uint16_t | buf[3] | ) |
Read the raw xyz values from the accelerometer.
buf | A buffer of uint16s to hold the 12 bit raw accelerometer values |
Get the instantaneous accelerometer values for the xyz axes. We return the raw values without converting them into g. To convert to g, if we are using a 2G scale, then simply divide by 16384