Brian Silverman | 26e4e52 | 2015-12-17 01:56:40 -0500 | [diff] [blame^] | 1 | /*----------------------------------------------------------------------------*/ |
| 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 | #pragma once |
| 7 | |
| 8 | /** |
| 9 | * Interface for counting the number of ticks on a digital input channel. |
| 10 | * Encoders, Gear tooth sensors, and counters should all subclass this so it can be used to |
| 11 | * build more advanced classes for control and driving. |
| 12 | * |
| 13 | * All counters will immediately start counting - Reset() them if you need them |
| 14 | * to be zeroed before use. |
| 15 | */ |
| 16 | class CounterBase |
| 17 | { |
| 18 | public: |
| 19 | enum EncodingType |
| 20 | { |
| 21 | k1X, |
| 22 | k2X, |
| 23 | k4X |
| 24 | }; |
| 25 | |
| 26 | virtual ~CounterBase() = default; |
| 27 | virtual int32_t Get() const = 0; |
| 28 | virtual void Reset() = 0; |
| 29 | virtual double GetPeriod() const = 0; |
| 30 | virtual void SetMaxPeriod(double maxPeriod) = 0; |
| 31 | virtual bool GetStopped() const = 0; |
| 32 | virtual bool GetDirection() const = 0; |
| 33 | }; |