View Single Post
  #2   Spotlight this post!  
Unread 29-01-2009, 02:29
MattD's Avatar
MattD MattD is offline
Registered User
AKA: Matthew Douglas
FRC #0228 (GUS Robotics)
Team Role: Alumni
 
Join Date: Feb 2006
Rookie Year: 2005
Location: Indianapolis, IN
Posts: 185
MattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to behold
Send a message via AIM to MattD
Re: AnalogChannel as both an accumulator AND a normal input?

You should be able to do this. The Gyro class has a constructor that accepts an existing AnalogChannel object.

Code:
/**
 * Gyro constructor with a precreated analog channel object.
 * Use this constructor when the analog channel needs to be shared. There
 * is no reference counting when an AnalogChannel is passed to the gyro.
 * @param channel The AnalogChannel object that the gyro is connected to.
 */
Gyro::Gyro(AnalogChannel *channel)
You can create an AnalogChannel and use the standard methods on it, while using the accumulator information via the Gyro class at the same time.

Code:
AnalogChannel *channel = new AnalogChannel(1);
Gyro *gyro = new Gyro(channel);

float value = channel->GetVoltage();
float angle = gyro->GetAngle();
Alternatively, you could modify the Gyro class to provide access to this information.
__________________
GUS Robotics Team 228

2010 WPI Engineering Inspiration Award
2010 WPI Regional Champions (Thanks 230 & 20!)
2010 CT VEX Champions
2010 CT VEX Innovate Award
2009 QCC VEX Champions
2009 CT Motorola Quality Award
2007 CT J&J Sportsmanship Award
2006 CT Best Website Award
Reply With Quote