Package jpigpio.sensors
Class GY_271
java.lang.Object
jpigpio.sensors.GY_271
public class GY_271
extends java.lang.Object
The GY-271 is a module that provides a multi axis magnetic field measurement that is typically used to provide a compass. It is based on the Honeywell HMC5883L IC. The module
uses I2C for communications.
This Java class provides a wrapper to its low level functions for use with Pigpio.
author Neil Kolban
date 2015-05-06
-
Field Summary
Fields Modifier and Type Field Description static intGAIN_0230static intGAIN_0330static intGAIN_0390static intGAIN_0440static intGAIN_0660static intGAIN_0820static intGAIN_1090static intGAIN_1370static intMODE_CONTINUOUSstatic intMODE_IDLEstatic intMODE_SINGLEstatic intOUTPUT_RATE_0_75static intOUTPUT_RATE_1_5static intOUTPUT_RATE_15static intOUTPUT_RATE_3static intOUTPUT_RATE_30static intOUTPUT_RATE_7_5static intOUTPUT_RATE_75static intSAMPLES_1static intSAMPLES_2static intSAMPLES_4static intSAMPLES_8 -
Constructor Summary
-
Method Summary
Modifier and Type Method Description voidclose()Close our usage of the I2C bus.java.lang.StringgetId()Get the device id.bytegetStatus()intgetX()intgetY()intgetZ()voidinitialize()Initialize the GY-271voidreadValue()voidsetGain(int value)voidsetMode(int value)voidsetOutputRate(int value)voidsetSamples(int value)java.lang.StringtoString()
-
Field Details
-
SAMPLES_1
public static final int SAMPLES_1- See Also:
- Constant Field Values
-
SAMPLES_2
public static final int SAMPLES_2- See Also:
- Constant Field Values
-
SAMPLES_4
public static final int SAMPLES_4- See Also:
- Constant Field Values
-
SAMPLES_8
public static final int SAMPLES_8- See Also:
- Constant Field Values
-
OUTPUT_RATE_0_75
public static final int OUTPUT_RATE_0_75- See Also:
- Constant Field Values
-
OUTPUT_RATE_1_5
public static final int OUTPUT_RATE_1_5- See Also:
- Constant Field Values
-
OUTPUT_RATE_3
public static final int OUTPUT_RATE_3- See Also:
- Constant Field Values
-
OUTPUT_RATE_7_5
public static final int OUTPUT_RATE_7_5- See Also:
- Constant Field Values
-
OUTPUT_RATE_15
public static final int OUTPUT_RATE_15- See Also:
- Constant Field Values
-
OUTPUT_RATE_30
public static final int OUTPUT_RATE_30- See Also:
- Constant Field Values
-
OUTPUT_RATE_75
public static final int OUTPUT_RATE_75- See Also:
- Constant Field Values
-
GAIN_1370
public static final int GAIN_1370- See Also:
- Constant Field Values
-
GAIN_1090
public static final int GAIN_1090- See Also:
- Constant Field Values
-
GAIN_0820
public static final int GAIN_0820- See Also:
- Constant Field Values
-
GAIN_0660
public static final int GAIN_0660- See Also:
- Constant Field Values
-
GAIN_0440
public static final int GAIN_0440- See Also:
- Constant Field Values
-
GAIN_0390
public static final int GAIN_0390- See Also:
- Constant Field Values
-
GAIN_0330
public static final int GAIN_0330- See Also:
- Constant Field Values
-
GAIN_0230
public static final int GAIN_0230- See Also:
- Constant Field Values
-
MODE_CONTINUOUS
public static final int MODE_CONTINUOUS- See Also:
- Constant Field Values
-
MODE_SINGLE
public static final int MODE_SINGLE- See Also:
- Constant Field Values
-
MODE_IDLE
public static final int MODE_IDLE- See Also:
- Constant Field Values
-
-
Constructor Details
-
GY_271
Construct the object for this class.- Parameters:
pigpio- The reference to the Pigpio controller
-
-
Method Details
-
initialize
Initialize the GY-271- Throws:
PigpioException- on pigpiod error
-
close
Close our usage of the I2C bus.- Throws:
PigpioException- on pigpiod error
-
readValue
- Throws:
PigpioException
-
getX
public int getX() -
getY
public int getY() -
getZ
public int getZ() -
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-
getId
Get the device id. A normal device will have an id of "H43".- Returns:
- The string representation of the device
- Throws:
PigpioException- on pigpiod error
-
setGain
- Throws:
PigpioException
-
setMode
- Throws:
PigpioException
-
setSamples
- Throws:
PigpioException
-
setOutputRate
- Throws:
PigpioException
-
getStatus
- Throws:
PigpioException
-