WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
UpDownCounter.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
8#include "wpi/hal/Counter.h"
9#include "wpi/hal/Types.hpp"
12
13namespace wpi {
14/** Up Down Counter.
15 *
16 * This class can count edges on a single digital input or count up based on an
17 * edge from one digital input and down on an edge from another digital input.
18 *
19 */
21 public wpi::util::SendableHelper<UpDownCounter> {
22 public:
23 /**
24 * Constructs a new UpDown Counter.
25 *
26 * @param channel The DIO channel
27 * @param configuration Edge configuration
28 */
29 UpDownCounter(int channel, EdgeConfiguration configuration);
30
33
34 ~UpDownCounter() override = default;
35
36 /**
37 * Gets the current count.
38 *
39 * @return The current count.
40 */
41 int GetCount() const;
42
43 /** Resets the current count. */
44 void Reset();
45
46 /**
47 * Sets the configuration for the channel.
48 *
49 * @param configuration The channel configuration.
50 */
52
53 protected:
55
56 private:
58 int32_t m_channel;
59};
60} // namespace wpi
void SetEdgeConfiguration(EdgeConfiguration configuration)
Sets the configuration for the channel.
int GetCount() const
Gets the current count.
void Reset()
Resets the current count.
UpDownCounter(int channel, EdgeConfiguration configuration)
Constructs a new UpDown Counter.
UpDownCounter & operator=(UpDownCounter &&)=default
~UpDownCounter() override=default
void InitSendable(wpi::util::SendableBuilder &builder) override
Initializes this Sendable object.
UpDownCounter(UpDownCounter &&)=default
A move-only C++ wrapper around a HAL handle.
Definition Types.hpp:16
Helper class for building Sendable dashboard representations.
Definition SendableBuilder.hpp:21
A helper class for use with objects that add themselves to SendableRegistry.
Definition SendableHelper.hpp:21
Interface for Sendable objects.
Definition Sendable.hpp:16
Definition CvSource.hpp:15
EdgeConfiguration
Edge configuration.
Definition EdgeConfiguration.hpp:11