blob: 683b681c43b0b351931ee91ffffac9710ed77f8e [file] [log] [blame]
Brian Silverman26e4e522015-12-17 01:56:40 -05001/*----------------------------------------------------------------------------*/
Brian Silverman1a675112016-02-20 20:42:49 -05002/* Copyright (c) FIRST 2008-2016. All Rights Reserved. */
Brian Silverman26e4e522015-12-17 01:56:40 -05003/* Open Source Software - may be modified and shared by FRC teams. The code */
Brian Silverman1a675112016-02-20 20:42:49 -05004/* must be accompanied by the FIRST BSD license file in the root directory of */
5/* the project. */
Brian Silverman26e4e522015-12-17 01:56:40 -05006/*----------------------------------------------------------------------------*/
Brian Silverman1a675112016-02-20 20:42:49 -05007
Brian Silverman26e4e522015-12-17 01:56:40 -05008#pragma once
9
10/**
11 * Interface for counting the number of ticks on a digital input channel.
12 * Encoders, Gear tooth sensors, and counters should all subclass this so it can be used to
13 * build more advanced classes for control and driving.
14 *
15 * All counters will immediately start counting - Reset() them if you need them
16 * to be zeroed before use.
17 */
18class CounterBase
19{
20public:
21 enum EncodingType
22 {
23 k1X,
24 k2X,
25 k4X
26 };
27
28 virtual ~CounterBase() = default;
29 virtual int32_t Get() const = 0;
30 virtual void Reset() = 0;
31 virtual double GetPeriod() const = 0;
32 virtual void SetMaxPeriod(double maxPeriod) = 0;
33 virtual bool GetStopped() const = 0;
34 virtual bool GetDirection() const = 0;
35};