Class for interfacing with an L3G4200D gyroscope, using the Adafruit Unified Sensor API. Most common methods: L4G4200D_Unified::begin and L3G4200D_Unified::getEvent.
More...
#include <L3G4200D_U.h>
Class for interfacing with an L3G4200D gyroscope, using the Adafruit Unified Sensor API. Most common methods: L4G4200D_Unified::begin and L3G4200D_Unified::getEvent.
◆ L3G4200D_Unified()
| L3G4200D_Unified::L3G4200D_Unified |
( |
int32_t |
sensorId | ) |
|
Create a new object representing an L3G4200D gyroscope.
- Parameters
-
| sensorId | A number to uniquely identify this sensor. This number can be arbitrarily chosen by you, but should not be shared with any other sensors in your sketch. |
◆ begin()
Initializes this L3G4200D gyroscope using SPI.
- Parameters
-
| spiChipSelect | The pin number on your board that you have connected to the SPI CS (Chip Select) pin on the L3G4200D. For example, on the Digilent PmodGYRO, CS is pin 1 on the J1 (the first jumper). If you connected that pin to pin 10 on your Arduino board, then you would call L4G4200D_Unified::begin like this:
|
- Parameters
-
| range | One of the gyroRange_t values to use for this gyroscope. Defaults to 4.36 rad/s. |
| spi | The SPI interface to use when communicating to this gyroscope. Defaults to SPI, the default SPI interface on Arduino boards. This is often connected to pins labeled SCK, MOSI, and MISO on the physical board. For example, on Arduino Uno the MISO of the default SPI interface is pin 12.
|
| spiFrequency | The clock frequency for the SPI peripheral. Defaults to 5 MHz if not specified. Must be lower than 10 MHz, per the L3G4200D datasheet. |
- Returns
- True if this sensor was successfully activated, false if it was not. If false, you can use enableDebugLogging to potentially get information on why logged in your serial console.
◆ enableAutoRange()
| void L3G4200D_Unified::enableAutoRange |
( |
bool |
enabled | ) |
|
Enables automatic range increasing if the sensor seems to be saturating its current range.
The range will not automatically decrease after being increased.
- Parameters
-
| enabled | Set to true to enable auto range, false to disable it. |
◆ enableDebugLogging()
| void L3G4200D_Unified::enableDebugLogging |
( |
bool |
enabled | ) |
|
Enables or disables debug logging to the Serial console.
- Parameters
-
| enabled | Set to true to enable debug logging, false to disable it. |
◆ getEvent()
| bool L3G4200D_Unified::getEvent |
( |
sensors_event_t * |
event | ) |
|
The Unified Sensor API method to get data from this sensor.
- Parameters
-
| event | [out] A pointer to a sensors_event_t object for this method to populate with the X, Y, and Z gyro data. |
After this function is called, event->gyro.x, event->gyro.y, and event->gyro.z are set to the values from the sensor. For example:
L3G4200D_U gyro;
gyro.begin(10);
sensors_event_t event;
gyro.getEvent(&event);
Serial.print("X, Y, Z: ");
Serial.print(event.gyro.x);
Serial.print(", ");
Serial.print(event.gyro.y);
Serial.print(", ");
Serial.println(event.gyro.z);
- Returns
- True if this sensor was successfully read from, false if it was not.
◆ getSensor()
| void L3G4200D_Unified::getSensor |
( |
sensor_t * |
sensor | ) |
|
The Unified Sensor API method to get information about this sensor.
- Parameters
-
| sensor | [out] A pointer to a sensor_t object for this method to populate with information about this sensor. |
◆ setRange()
Sets the range for this gyroscope.
- Parameters
-
| range | One of the values of gyroRange_t to set as the new range for this gyroscope. |
◆ rangeInRadians()
| float L3G4200D_Unified::rangeInRadians |
( |
| ) |
|
Returns the full scale of the current range in the SI unit rad/s.
- Returns
- The current range, in radians.
◆ rawReadReg()
| uint8_t L3G4200D_Unified::rawReadReg |
( |
uint8_t |
regAddress | ) |
|
Advanced functionality: reads a raw value from a raw address. See Registers for more information.
- Parameters
-
| regAddress | The address of the gyroscope register to read from. One of the values of register addresses. |
- Returns
- The raw value of the register that was read.
◆ rawWriteReg()
| void L3G4200D_Unified::rawWriteReg |
( |
uint8_t |
regAddress, |
|
|
uint8_t |
newValue |
|
) |
| |
Advanced functionality: writes a raw value to a raw address. See Registers for more information.
- Parameters
-
| regAddress | The address of the gyroscope register to read from. One of the values of register addresses. |
| newValue | The raw value to write to the register specified in regAddress. |
The documentation for this class was generated from the following files: