blob: 68896a8f338248a8eab35a6f20d7d8167381c7e5 [file] [log] [blame]
Brian Silverman26e4e522015-12-17 01:56:40 -05001/*----------------------------------------------------------------------------*/
2/* Copyright (c) FIRST 2008. All Rights Reserved.
3 */
4/* Open Source Software - may be modified and shared by FRC teams. The code */
5/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
6/*----------------------------------------------------------------------------*/
7#pragma once
8
9#include <stdint.h>
10
11/**
12 * Interface for counting the number of ticks on a digital input channel.
13 * Encoders, Gear tooth sensors, and counters should all subclass this so it can
14 * be used to build more advanced classes for control and driving.
15 *
16 * All counters will immediately start counting - Reset() them if you need them
17 * to be zeroed before use.
18 */
19class CounterBase {
20 public:
21 enum EncodingType { k1X, k2X, k4X };
22
23 virtual ~CounterBase() = default;
24 virtual int32_t Get() const = 0;
25 virtual void Reset() = 0;
26 virtual double GetPeriod() const = 0;
27 virtual void SetMaxPeriod(double maxPeriod) = 0;
28 virtual bool GetStopped() const = 0;
29 virtual bool GetDirection() const = 0;
30};