WPILibC++ 2027.0.0-alpha-5
Loading...
Searching...
No Matches
CounterBase.hpp
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 "wpi/units/time.hpp"
8
9namespace wpi {
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 /** The number of edges for the CounterBase to increment or decrement on. */
23 enum class EncodingType { X1, X2, X4 };
24
25 CounterBase() = default;
26 virtual ~CounterBase() = default;
27
30
31 virtual int Get() const = 0;
32 virtual void Reset() = 0;
33 virtual wpi::units::second_t GetPeriod() const = 0;
34 virtual void SetMaxPeriod(wpi::units::second_t maxPeriod) = 0;
35 virtual bool GetStopped() const = 0;
36 virtual bool GetDirection() const = 0;
37};
38
39} // namespace wpi
virtual wpi::units::second_t GetPeriod() const =0
virtual bool GetStopped() const =0
virtual ~CounterBase()=default
virtual void SetMaxPeriod(wpi::units::second_t maxPeriod)=0
virtual void Reset()=0
virtual int Get() const =0
EncodingType
The number of edges for the CounterBase to increment or decrement on.
Definition CounterBase.hpp:23
@ X2
Definition CounterBase.hpp:23
@ X4
Definition CounterBase.hpp:23
@ X1
Definition CounterBase.hpp:23
virtual bool GetDirection() const =0
CounterBase(CounterBase &&)=default
CounterBase & operator=(CounterBase &&)=default
CounterBase()=default
Definition CvSource.hpp:15