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