2020-12-26 14:12:05 -08:00
|
|
|
// Copyright (c) FIRST and other WPILib contributors.
|
|
|
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
|
|
|
// the WPILib BSD license file in the root directory of this project.
|
2016-01-02 03:02:34 -08:00
|
|
|
|
2014-05-02 17:54:01 -04:00
|
|
|
#pragma once
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2021-05-28 22:06:59 -07:00
|
|
|
#include <units/time.h>
|
|
|
|
|
|
2016-11-01 22:33:12 -07:00
|
|
|
namespace frc {
|
|
|
|
|
|
2013-12-15 18:30:16 -05:00
|
|
|
/**
|
|
|
|
|
* Interface for counting the number of ticks on a digital input channel.
|
2017-11-16 00:33:51 -08:00
|
|
|
*
|
2014-07-29 09:58:15 -07:00
|
|
|
* Encoders, Gear tooth sensors, and counters should all subclass this so it can
|
|
|
|
|
* be used to build more advanced classes for control and driving.
|
|
|
|
|
*
|
|
|
|
|
* All counters will immediately start counting - Reset() them if you need them
|
|
|
|
|
* to be zeroed before use.
|
2013-12-15 18:30:16 -05:00
|
|
|
*/
|
2015-06-25 15:07:55 -04:00
|
|
|
class CounterBase {
|
|
|
|
|
public:
|
|
|
|
|
enum EncodingType { k1X, k2X, k4X };
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2018-09-24 00:08:25 -07:00
|
|
|
CounterBase() = default;
|
2015-06-24 01:06:29 -07:00
|
|
|
virtual ~CounterBase() = default;
|
2018-09-24 00:08:25 -07:00
|
|
|
|
|
|
|
|
CounterBase(CounterBase&&) = default;
|
|
|
|
|
CounterBase& operator=(CounterBase&&) = default;
|
|
|
|
|
|
2016-09-06 00:01:45 -07:00
|
|
|
virtual int Get() const = 0;
|
2015-06-25 15:07:55 -04:00
|
|
|
virtual void Reset() = 0;
|
2021-05-28 22:06:59 -07:00
|
|
|
virtual units::second_t GetPeriod() const = 0;
|
|
|
|
|
virtual void SetMaxPeriod(units::second_t maxPeriod) = 0;
|
2015-06-25 15:07:55 -04:00
|
|
|
virtual bool GetStopped() const = 0;
|
|
|
|
|
virtual bool GetDirection() const = 0;
|
2013-12-15 18:30:16 -05:00
|
|
|
};
|
2016-11-01 22:33:12 -07:00
|
|
|
|
|
|
|
|
} // namespace frc
|