Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 1 | /*----------------------------------------------------------------------------*/ |
| 2 | /* Copyright (c) FIRST 2008-2017. 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 the root directory of */ |
| 5 | /* the project. */ |
| 6 | /*----------------------------------------------------------------------------*/ |
| 7 | |
| 8 | #pragma once |
| 9 | |
Tyler Chatow | bf0609c | 2021-07-31 16:13:27 -0700 | [diff] [blame^] | 10 | #include <cstdint> |
Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 11 | |
| 12 | namespace frc { |
| 13 | |
| 14 | /** |
| 15 | * Interface for counting the number of ticks on a digital input channel. |
| 16 | * Encoders, Gear tooth sensors, and counters should all subclass this so it can |
| 17 | * be used to build more advanced classes for control and driving. |
| 18 | * |
| 19 | * All counters will immediately start counting - Reset() them if you need them |
| 20 | * to be zeroed before use. |
| 21 | */ |
| 22 | class CounterBase { |
| 23 | public: |
| 24 | enum EncodingType { k1X, k2X, k4X }; |
| 25 | |
| 26 | virtual ~CounterBase() = default; |
| 27 | virtual int 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 | }; |
| 34 | |
| 35 | } // namespace frc |