WPILibC++  unspecified
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
DigitalGlitchFilter.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) FIRST 2015-2016. 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 "HAL/cpp/priority_mutex.h"
13 #include "DigitalSource.h"
14 
15 class Encoder;
16 class Counter;
17 
25  public:
28 
29  void Add(DigitalSource *input);
30  void Add(Encoder *input);
31  void Add(Counter *input);
32 
33  void Remove(DigitalSource *input);
34  void Remove(Encoder *input);
35  void Remove(Counter *input);
36 
37  void SetPeriodCycles(uint32_t fpga_cycles);
38  void SetPeriodNanoSeconds(uint64_t nanoseconds);
39 
40  uint32_t GetPeriodCycles();
41  uint64_t GetPeriodNanoSeconds();
42 
43  private:
44  // Sets the filter for the input to be the requested index. A value of 0
45  // disables the filter, and the filter value must be between 1 and 3,
46  // inclusive.
47  void DoAdd(DigitalSource *input, int requested_index);
48 
49  int m_channelIndex = -1;
50  static priority_mutex m_mutex;
51  static ::std::array<bool, 3> m_filterAllocated;
52 };
Class to enable glitch filtering on a set of digital inputs.
Definition: DigitalGlitchFilter.h:24
DigitalSource Interface.
Definition: DigitalSource.h:22
void SetPeriodCycles(uint32_t fpga_cycles)
Sets the number of cycles that the input must not change state for.
Definition: DigitalGlitchFilter.cpp:144
Class to read quad encoders.
Definition: Encoder.h:40
uint32_t GetPeriodCycles()
Gets the number of cycles that the input must not change state for.
Definition: DigitalGlitchFilter.cpp:169
Base class for all sensors.
Definition: SensorBase.h:20
uint64_t GetPeriodNanoSeconds()
Gets the number of nanoseconds that the input must not change state for.
Definition: DigitalGlitchFilter.cpp:183
Definition: priority_mutex.h:53
void Remove(DigitalSource *input)
Removes a digital input from this filter.
Definition: DigitalGlitchFilter.cpp:103
Class for counting the number of ticks on a digital input channel.
Definition: Counter.h:31
void Add(DigitalSource *input)
Assigns the DigitalSource to this glitch filter.
Definition: DigitalGlitchFilter.cpp:46
void SetPeriodNanoSeconds(uint64_t nanoseconds)
Sets the number of nanoseconds that the input must not change state for.
Definition: DigitalGlitchFilter.cpp:155