myWRIO
C++ framework for NationalInstruments myRIO
myRIO::Gyro Class Reference

Helper class to use with a L3G4200D gyro sensor. More...

#include <Gyro.h>

Public Member Functions

 Gyro ()
 Constructs a helper for sensor L3G4200D. More...
 
 ~Gyro ()
 Close the thread if it was running. More...
 
void calibrate (short samples=100)
 Compute the offset from error of the last X samples The gyro must be on a plane surface. More...
 
void readGyro (double &vx, double &vy, double &vz)
 Read all X, Y and Z values from the gyro registers. More...
 
void startFreeRunningMode (std::function< void(double &, double &)> func)
 Start a thread to run infinitely that will check the gyro values. More...
 
void stopFreeRunningMode ()
 Stop the running thread. More...
 

Private Attributes

uint8_t * regs
 
uint8_t gyroStatusVal
 
I2Cgyro
 
double xOff
 
double yOff
 
double zOff
 
std::thread * th
 
bool * run
 

Detailed Description

Helper class to use with a L3G4200D gyro sensor.

Examples
project_angle.cpp, and project_pendulum.cpp.

Definition at line 39 of file Gyro.h.

Constructor & Destructor Documentation

◆ Gyro()

Gyro::Gyro ( )

Constructs a helper for sensor L3G4200D.

Definition at line 9 of file Gyro.cpp.

◆ ~Gyro()

Gyro::~Gyro ( )

Close the thread if it was running.

Definition at line 151 of file Gyro.cpp.

Member Function Documentation

◆ calibrate()

void Gyro::calibrate ( short  samples = 100)

Compute the offset from error of the last X samples The gyro must be on a plane surface.

Parameters
samplesthe number of samples to average the offset from
Examples
project_angle.cpp, and project_pendulum.cpp.

Definition at line 32 of file Gyro.cpp.

◆ readGyro()

void Gyro::readGyro ( double &  vx,
double &  vy,
double &  vz 
)

Read all X, Y and Z values from the gyro registers.

Parameters
vxx value
vyy value
vzz value

Definition at line 70 of file Gyro.cpp.

◆ startFreeRunningMode()

void Gyro::startFreeRunningMode ( std::function< void(double &, double &)>  func)

Start a thread to run infinitely that will check the gyro values.

Parameters
funccallback function, that will receive the elapsed time and the x value
Examples
project_angle.cpp, and project_pendulum.cpp.

Definition at line 95 of file Gyro.cpp.

◆ stopFreeRunningMode()

void Gyro::stopFreeRunningMode ( )

Stop the running thread.

Definition at line 144 of file Gyro.cpp.

Member Data Documentation

◆ gyro

I2C* myRIO::Gyro::gyro
private

Definition at line 51 of file Gyro.h.

◆ gyroStatusVal

uint8_t myRIO::Gyro::gyroStatusVal
private

Definition at line 50 of file Gyro.h.

◆ regs

uint8_t* myRIO::Gyro::regs
private

Definition at line 49 of file Gyro.h.

◆ run

bool* myRIO::Gyro::run
private

Definition at line 54 of file Gyro.h.

◆ th

std::thread* myRIO::Gyro::th
private

Definition at line 53 of file Gyro.h.

◆ xOff

double myRIO::Gyro::xOff
private

Definition at line 52 of file Gyro.h.

◆ yOff

double myRIO::Gyro::yOff
private

Definition at line 52 of file Gyro.h.

◆ zOff

double myRIO::Gyro::zOff
private

Definition at line 52 of file Gyro.h.


The documentation for this class was generated from the following files: