Package rstem :: Module accel
[hide private]
[frames] | no frames]

Module accel

Functions [hide private]
3 value tuple
angles(...)
This function returns the latest acceleration data from the accelerometer converted into angles.
 
enable_data_ready(...)
This functions enables the data ready interrupt which fires when new data is avaiable from the accelerometer.
 
enable_freefall_motion(...)
This function enables the freefall or motion interrupt on a given interrupt pin.
 
freefall_motion_debounce(...)
This function sets the debounce counter for the freefall/motion detect interrupt.
 
freefall_motion_threshold(...)
This function sets the debounce mode and threshold in Gs for freefall and motion detection.
 
init(...)
This function initializes the accelerometer on the i2c bus.
3 value tuple
read(...)
This function returns the latest acceleration data from the accelerometer.
 
set_range(...)
This function sets the full scale range of the accelerometer, larger values mean more range but less precision.
 
set_sample_rate_prescaler(...)
This function controls the sample rate of the accelerometer by setting the sample rate prescaler.
 
use_radians(...)
This function sets the return units of the angles function.
Variables [hide private]
  __package__ = None
Function Details [hide private]

angles(...)

 

This function returns the latest acceleration data from the accelerometer converted into angles.

Returns: 3 value tuple
A tuple of the form (Roll, Pitch, Elevation).

Roll: Left/Right rotation

Pitch: Forward/Backward rotation

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

enable_data_ready(...)

 

This functions enables the data ready interrupt which fires when new data is avaiable from the accelerometer.

Parameters:
  • pin - Pin to enable the interrupt on.

enable_freefall_motion(...)

 

This function enables the freefall or motion interrupt on a given interrupt pin.

Parameters:
  • mode (int) - This is either a 0 or a 1 which selects between freefall and motion detect mode. 0 for freefall, 1 for motion detect.
  • pin (int) - This is either a 1 or a 2 corresponding to the interrupt pin to be used.

freefall_motion_debounce(...)

 

This function sets the debounce counter for the freefall/motion detect interrupt.

Parameters:
  • counts (int) - A number ranging from 0-255 representing the number of samples that must be taken with the threshold condition met before the interrupt fires

freefall_motion_threshold(...)

 

This function sets the debounce mode and threshold in Gs for freefall and motion detection.

Parameters:
  • debounce (int) - 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.
  • threshold (float) - Threshold in Gs ranging from 0-8.
Notes:
  • When in freefall mode the interrupt will trigger when the acceleration is BELOW input threshold.
  • When in motion detect mode the interrupt will trigger when the acceleration is ABOVE threshold.

init(...)

 

This function initializes the accelerometer on the i2c bus.

Parameters:
  • bus (int) - 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.

read(...)

 

This function returns the latest acceleration data from the accelerometer.

Returns: 3 value tuple
A tuple of the acceleration on the seperate axes in form (X, Y, Z).

set_range(...)

 

This function sets the full scale range of the accelerometer, larger values mean more range but less precision.

Parameters:
  • range (int) - Value for the full scale range, valid options are 2, 4, or 8.

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

Parameters:
  • prescaler (int) - The prescaler to be used, valid numbers are 1, 2, 4, 8, 16, 64, 128, and 512.

use_radians(...)

 

This function sets the return units of the angles function.

Parameters:
  • radians (boolean) - True to have angles return values in radians, False to have angles return values in degrees