Brian Silverman | 26e4e52 | 2015-12-17 01:56:40 -0500 | [diff] [blame] | 1 | /*----------------------------------------------------------------------------*/ |
Brian Silverman | 1a67511 | 2016-02-20 20:42:49 -0500 | [diff] [blame^] | 2 | /* Copyright (c) FIRST 2008-2016. All Rights Reserved. */ |
Brian Silverman | 26e4e52 | 2015-12-17 01:56:40 -0500 | [diff] [blame] | 3 | /* Open Source Software - may be modified and shared by FRC teams. The code */ |
Brian Silverman | 1a67511 | 2016-02-20 20:42:49 -0500 | [diff] [blame^] | 4 | /* must be accompanied by the FIRST BSD license file in the root directory of */ |
| 5 | /* the project. */ |
Brian Silverman | 26e4e52 | 2015-12-17 01:56:40 -0500 | [diff] [blame] | 6 | /*----------------------------------------------------------------------------*/ |
Brian Silverman | 1a67511 | 2016-02-20 20:42:49 -0500 | [diff] [blame^] | 7 | |
Brian Silverman | 26e4e52 | 2015-12-17 01:56:40 -0500 | [diff] [blame] | 8 | #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 | */ |
| 18 | class CounterBase |
| 19 | { |
| 20 | public: |
| 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 | }; |