Top

rstem.accel module

Functions

def angles(

...)

This function returns the latest acceleration data from the accelerometer converted into angles. @return: A tuple of the form (Roll, Pitch, Elevation).

    B{Roll}: Left/Right rotation

    B{Pitch}: Forward/Backward rotation

    B{Elevation}: The angle of the normal of the accelerometer from the X-Y plane.

@rtype: 3 value tuple

def enable_data_ready(

...)

This functions enables the I{data ready} interrupt which fires when new data is avaiable from the accelerometer. @param pin: Pin to enable the interrupt on.

def enable_freefall_motion(

...)

This function enables the freefall or motion interrupt on a given interrupt pin. @param mode: This is either a 0 or a 1 which selects between freefall and motion detect mode. 0 for freefall, 1 for motion detect. @type mode: int @param pin: This is either a 1 or a 2 corresponding to the interrupt pin to be used. @type pin: int

def freefall_motion_debounce(

...)

This function sets the debounce counter for the freefall/motion detect interrupt. @param counts: A number ranging from 0-255 representing the number of samples that must be taken with the threshold condition met before the interrupt fires @type counts: int

def freefall_motion_threshold(

...)

This function sets the debounce mode and threshold in Gs for freefall and motion detection. @note: When in freefall mode the interrupt will trigger when the acceleration is B{BELOW} input threshold. @note: When in motion detect mode the interrupt will trigger when the acceleration is B{ABOVE} threshold. @param debounce: Sets the mode for debounce, 0 clears debounce counter when threshold condition is not met, 1 (default) decrements debounce counter when threshold condition is not met. @type debounce: int @param threshold: Threshold in Gs ranging from 0-8. @type threshold: float

def init(

...)

This function initializes the accelerometer on the i2c bus. @param bus: This is the i2c bus the accelerometer is linked to, it will either be a 0 or a 1 depending on which type of Pi the user has. @type bus: int

def read(

...)

This function returns the latest acceleration data from the accelerometer. @returns: A tuple of the acceleration on the seperate axes in form (X, Y, Z). @rtype: 3 value tuple

def set_range(

...)

This function sets the full scale range of the accelerometer, larger values mean more range but less precision. @param range: Value for the full scale range, valid options are 2, 4, or 8. @type range: int

def set_sample_rate_prescaler(

...)

This function controls the sample rate of the accelerometer by setting the sample rate prescaler. The sample rate will be the max sample rate (800hz) divided by the prescaler @param prescaler: The prescaler to be used, valid numbers are 1, 2, 4, 8, 16, 64, 128, and 512. @type prescaler: int

def use_radians(

...)

This function sets the return units of the L{angles} function. @param radians: I{True} to have L{angles} return values in radians, I{False} to have L{angles} return values in degrees @type radians: boolean