WPILibC++  unspecified
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
DigitalGlitchFilter.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) FIRST 2015-2017. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #pragma once
9 
10 #include <array>
11 
12 #include "DigitalSource.h"
13 #include "HAL/cpp/priority_mutex.h"
14 
15 namespace frc {
16 
17 class Encoder;
18 class Counter;
19 
27  public:
30 
31  void Add(DigitalSource* input);
32  void Add(Encoder* input);
33  void Add(Counter* input);
34 
35  void Remove(DigitalSource* input);
36  void Remove(Encoder* input);
37  void Remove(Counter* input);
38 
39  void SetPeriodCycles(int fpga_cycles);
40  void SetPeriodNanoSeconds(uint64_t nanoseconds);
41 
42  int GetPeriodCycles();
43  uint64_t GetPeriodNanoSeconds();
44 
45  private:
46  // Sets the filter for the input to be the requested index. A value of 0
47  // disables the filter, and the filter value must be between 1 and 3,
48  // inclusive.
49  void DoAdd(DigitalSource* input, int requested_index);
50 
51  int m_channelIndex = -1;
52  static priority_mutex m_mutex;
53  static ::std::array<bool, 3> m_filterAllocated;
54 };
55 
56 } // namespace frc
void SetPeriodCycles(int fpga_cycles)
Sets the number of cycles that the input must not change state for.
Definition: DigitalGlitchFilter.cpp:153
Base class for all sensors.
Definition: SensorBase.h:22
Class to read quad encoders.
Definition: Encoder.h:39
void SetPeriodNanoSeconds(uint64_t nanoseconds)
Sets the number of nanoseconds that the input must not change state for.
Definition: DigitalGlitchFilter.cpp:164
Class to enable glitch filtering on a set of digital inputs.
Definition: DigitalGlitchFilter.h:26
Class for counting the number of ticks on a digital input channel.
Definition: Counter.h:33
uint64_t GetPeriodNanoSeconds()
Gets the number of nanoseconds that the input must not change state for.
Definition: DigitalGlitchFilter.cpp:192
DigitalSource Interface.
Definition: DigitalSource.h:25
Definition: priority_mutex.h:53
void Remove(DigitalSource *input)
Removes a digital input from this filter.
Definition: DigitalGlitchFilter.cpp:114
int GetPeriodCycles()
Gets the number of cycles that the input must not change state for.
Definition: DigitalGlitchFilter.cpp:178
void Add(DigitalSource *input)
Assigns the DigitalSource to this glitch filter.
Definition: DigitalGlitchFilter.cpp:51