sample/0x00_AccelMagno/AccelMagno.h

Enums

enum AccelFullScaleEnum

Values for controlling accelerometer full scale range.

Values:

ACCEL_2G

Full scale range of 2g

ACCEL_4G

Full scale range of 4g

ACCEL_6G

Full scale range of 6g

ACCEL_8G

Full scale range of 8g

ACCEL_16G

Full scale range of 16g

enum MagnoFullScaleEnum

Values for controlling magnetometer full scale range.

Values:

MAGNO_2GAUSS

Full scale range of 2 gauss

MAGNO_4GAUSS

Full scale range of 4 gauss

MAGNO_8GAUSS

Full scale range of 8 gauss

MAGNO_12GAUSS

Full scale range of 12 gauss

class AccelMagno
#include <AccelMagno.h>

Class for controlling a duinoPRO Accelerometer/Magnetometer module.

Inherits from Module

Public Functions

AccelMagno(int id)

Constructor for AccelMagno.

Parameters
  • id: - the location of the AccelMagno module on the duinoPRO baseboard.

void begin(void)

Begin using the AccelMagno module.

void lowPowerMode(bool lowpower)

Enable or disable low-power mode.

Parameters
  • lowpower: - true to enable low-power mode, false to disable.

uint8_t readRegister(uint8_t addr)

Read the value of a register in the LDM303D chip.

Return
The register value.
Parameters
  • addr: - Address of the register to be read.

void writeRegister(uint8_t addr, uint8_t data)

Write a value to a register in the LDM303D chip.

Parameters
  • addr: - Address of the register to be written.
  • data: - The value to be written to the register.

void enableAccel()

Enable accelerometer.

void disableAccel()

Disable accelerometer.

void setAccelFullScale(uint8_t mode)

Set the full-scale range of the accelerometer. The allowable ranges are from +/-2g to +/-16g. Possible values are listed in AccelFullScaleEnum.

Parameters
  • mode: - Value for full-scale range, from AccelFullScaleEnum.

void enableMagno()

Enable magnetometer.

void disableMagno()

Disable magnetometer.

void setMagnoFullScale(uint8_t mode)

Set the full-scale range of the magnetometer. The allowable ranges are from +/-2 Gauss to +/-12 Gauss. Possible values are listed in MagnoFullScaleEnum.

Parameters
  • mode: - Value for full-scale range, from MagnoFullScaleEnum.

int16_t rawAccelX()

Raw X axis accelerometer reading.

Return
The raw reading.

int16_t rawAccelY()

Raw Y axis accelerometer reading.

Return
The raw reading.

int16_t rawAccelZ()

Raw Z axis accelerometer reading.

Return
The raw reading.

float accelX()

X axis accelerometer reading, expressed as a floating point number in mg. This result is scaled correctly to allow for the accelerometer range in use.

Return
The scaled reading.

float accelY()

Y axis accelerometer reading, expressed as a floating point number in mg. This result is scaled correctly to allow for the accelerometer range in use.

Return
The scaled reading.

float accelZ()

Z axis accelerometer reading, expressed as a floating point number in mg. This result is scaled correctly to allow for the accelerometer range in use.

Return
The scaled reading.

float magnoX()

X axis magnetometer reading, expressed as a floating point number in mgauss. This result is scaled correctly to allow for the magnetometer range in use.

Return
The scaled reading.

float magnoY()

Y axis magnetometer reading, expressed as a floating point number in mgauss. This result is scaled correctly to allow for the magnetometer range in use.

Return
The scaled reading.

float magnoZ()

Z axis magnetometer reading, expressed as a floating point number in mgauss. This result is scaled correctly to allow for the magnetometer range in use.

Return
The scaled reading.

bool intRead(uint8_t intNum)

Read the specified interrupt signal of the LDM303D chip.

Return
The state of the interrupt signal.
Parameters
  • intNum: - Number of the interrupt signal (1 or 2) to be read.

Protected Functions

int16_t read16Bit(uint8_t highAddr, uint8_t lowAddr)

Read a signed 16-bit value from two registers in the Accelerometer/Magnetometer chip.

Return
The 16-bit value.
Parameters
  • highAddr: - Address of the register to be read containing the most significant bits.
  • lowAddr: - Address of the register to be read containing the least significant bits.

Private Members

uint8_t accelFullScale
float accelLsb
uint8_t magnoFullScale
float magnoLsb