blob: 8fac9c2fe4d07dc0b3eca2295c66fd55050c7c27 [file] [log] [blame]
jerrymf1579332013-02-07 01:56:28 +00001/*----------------------------------------------------------------------------*/
2/* Copyright (c) FIRST 2008. All Rights Reserved. */
3/* Open Source Software - may be modified and shared by FRC teams. The code */
4/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
5/*----------------------------------------------------------------------------*/
6
7#include "GearTooth.h"
8#include "LiveWindow/LiveWindow.h"
9
10const double GearTooth::kGearToothThreshold;
11
12/**
13 * Common code called by the constructors.
14 */
15void GearTooth::EnableDirectionSensing(bool directionSensitive)
16{
17 if (directionSensitive)
18 {
19 SetPulseLengthMode(kGearToothThreshold);
20 }
21}
22
23/**
24 * Construct a GearTooth sensor given a channel.
25 *
26 * The default module is assumed.
27 *
28 * @param channel The GPIO channel on the digital module that the sensor is connected to.
29 * @param directionSensitive Enable the pulse length decoding in hardware to specify count direction.
30 */
31GearTooth::GearTooth(UINT32 channel, bool directionSensitive)
32 : Counter(channel)
33{
34 EnableDirectionSensing(directionSensitive);
35}
36
37/**
38 * Construct a GearTooth sensor given a channel and module.
39 *
40 * @param moduleNumber The digital module (1 or 2).
41 * @param channel The GPIO channel on the digital module that the sensor is connected to.
42 * @param directionSensitive Enable the pulse length decoding in hardware to specify count direction.
43 */
44GearTooth::GearTooth(UINT8 moduleNumber, UINT32 channel, bool directionSensitive)
45 : Counter(moduleNumber, channel)
46{
47 EnableDirectionSensing(directionSensitive);
48 LiveWindow::GetInstance()->AddSensor("GearTooth", moduleNumber, channel, this);
49}
50
51/**
52 * Construct a GearTooth sensor given a digital input.
53 * This should be used when sharing digial inputs.
54 *
55 * @param source An object that fully descibes the input that the sensor is connected to.
56 * @param directionSensitive Enable the pulse length decoding in hardware to specify count direction.
57 */
58GearTooth::GearTooth(DigitalSource *source, bool directionSensitive)
59 : Counter(source)
60{
61 EnableDirectionSensing(directionSensitive);
62}
63
64GearTooth::GearTooth(DigitalSource &source, bool directionSensitive): Counter(source)
65{
66 EnableDirectionSensing(directionSensitive);
67}
68
69/**
70 * Free the resources associated with a gear tooth sensor.
71 */
72GearTooth::~GearTooth()
73{
74}
75
76
77std::string GearTooth::GetSmartDashboardType() {
78 return "GearTooth";
79}
80