WPILib 2012
WPILibRoboticsLibraryforFRC
AnalogChannel.h
00001 /*----------------------------------------------------------------------------*/
00002 /* Copyright (c) FIRST 2008. All Rights Reserved.                                                         */
00003 /* Open Source Software - may be modified and shared by FRC teams. The code   */
00004 /* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib.  */
00005 /*----------------------------------------------------------------------------*/
00006 
00007 #ifndef ANALOG_CHANNEL_H_
00008 #define ANALOG_CHANNEL_H_
00009 
00010 #include "ChipObject.h"
00011 #include "SensorBase.h"
00012 #include "PIDSource.h"
00013 
00014 class AnalogModule;
00015 
00028 class AnalogChannel : public SensorBase, public PIDSource
00029 {
00030 public:
00031         static const UINT8 kAccumulatorModuleNumber = 1;
00032         static const UINT32 kAccumulatorNumChannels = 2;
00033         static const UINT32 kAccumulatorChannels[kAccumulatorNumChannels];
00034 
00035         AnalogChannel(UINT8 moduleNumber, UINT32 channel);
00036         explicit AnalogChannel(UINT32 channel);
00037         virtual ~AnalogChannel();
00038 
00039         AnalogModule *GetModule();
00040 
00041         INT16 GetValue();
00042         INT32 GetAverageValue();
00043 
00044         float GetVoltage();
00045         float GetAverageVoltage();
00046 
00047         UINT8 GetModuleNumber();
00048         UINT32 GetChannel();
00049 
00050         void SetAverageBits(UINT32 bits);
00051         UINT32 GetAverageBits();
00052         void SetOversampleBits(UINT32 bits);
00053         UINT32 GetOversampleBits();
00054 
00055         UINT32 GetLSBWeight();
00056         INT32 GetOffset();
00057 
00058         bool IsAccumulatorChannel();
00059         void InitAccumulator();
00060         void SetAccumulatorInitialValue(INT64 value);
00061         void ResetAccumulator();
00062         void SetAccumulatorCenter(INT32 center);
00063         void SetAccumulatorDeadband(INT32 deadband);
00064         INT64 GetAccumulatorValue();
00065         UINT32 GetAccumulatorCount();
00066         void GetAccumulatorOutput(INT64 *value, UINT32 *count);
00067         
00068         double PIDGet();
00069 
00070 private:
00071         void InitChannel(UINT8 moduleNumber, UINT32 channel);
00072         UINT32 m_channel;
00073         AnalogModule *m_module;
00074         tAccumulator *m_accumulator;
00075         INT64 m_accumulatorOffset;
00076 };
00077 
00078 #endif
 All Classes Functions Variables