WPILibC++ 2024.3.2
CounterBase.h
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include <units/time.h>
8
9namespace frc {
10
11/**
12 * Interface for counting the number of ticks on a digital input channel.
13 *
14 * Encoders, Gear tooth sensors, and counters should all subclass this so it can
15 * be used to build more advanced classes for control and driving.
16 *
17 * All counters will immediately start counting - Reset() them if you need them
18 * to be zeroed before use.
19 */
21 public:
22 enum EncodingType { k1X, k2X, k4X };
23
24 CounterBase() = default;
25 virtual ~CounterBase() = default;
26
29
30 virtual int Get() const = 0;
31 virtual void Reset() = 0;
32 virtual units::second_t GetPeriod() const = 0;
33 virtual void SetMaxPeriod(units::second_t maxPeriod) = 0;
34 virtual bool GetStopped() const = 0;
35 virtual bool GetDirection() const = 0;
36};
37
38} // namespace frc
Interface for counting the number of ticks on a digital input channel.
Definition: CounterBase.h:20
virtual units::second_t GetPeriod() const =0
virtual int Get() const =0
virtual bool GetStopped() const =0
EncodingType
Definition: CounterBase.h:22
@ k1X
Definition: CounterBase.h:22
@ k4X
Definition: CounterBase.h:22
@ k2X
Definition: CounterBase.h:22
virtual void Reset()=0
virtual bool GetDirection() const =0
CounterBase()=default
virtual void SetMaxPeriod(units::second_t maxPeriod)=0
virtual ~CounterBase()=default
CounterBase & operator=(CounterBase &&)=default
CounterBase(CounterBase &&)=default
Definition: AprilTagPoseEstimator.h:15