2023-Robot
Robot code for 2023 FRC season by Argos, FRC team #1756
Loading...
Searching...
No Matches
DebouncedDigitalInput.h
Go to the documentation of this file.
1
4
25
26#pragma once
27
28#include <stdint.h>
29
30#include "MiscConstants.h"
31
33 public:
35 explicit DebouncedDigitalInput(uint8_t pinNumber, bool usePullup = false);
36 DebouncedDigitalInput(uint8_t pinNumber, uint8_t groundPin, bool usePullup = false);
37 DebouncedDigitalInput(uint8_t pinNumber, uint8_t groundPin, uint16_t debounceSamples, bool usePullup = false);
38
40
41 void Initialize();
42
43 bool Update();
44
45 bool GetValue() const;
46
47 bool GetRawValue() const;
48
49 void Reset(bool newValue = false);
50
51 void SetDebounceCount(uint16_t newCount);
52
53 private:
54 const uint8_t m_readPin;
55 const uint8_t m_groundPin;
56 const bool m_usePullup;
59 uint16_t m_debounceCount;
62};
Miscellaneous constants for the operator controller.
Definition DebouncedDigitalInput.h:32
bool GetValue() const
Definition DebouncedDigitalInput.cpp:88
uint16_t m_debounceCount
Number of samples that do not match the current debounced value.
Definition DebouncedDigitalInput.h:59
DebouncedDigitalInput()=delete
DebouncedDigitalInput & operator=(const DebouncedDigitalInput &)=delete
bool Update()
Definition DebouncedDigitalInput.cpp:68
const bool m_usePullup
True uses Arduino internal pullup resistor.
Definition DebouncedDigitalInput.h:56
bool GetRawValue() const
Definition DebouncedDigitalInput.cpp:92
void Initialize()
Definition DebouncedDigitalInput.cpp:55
bool m_initialized
True once initialization has completed.
Definition DebouncedDigitalInput.h:58
bool m_debouncedValue
Active debounced value.
Definition DebouncedDigitalInput.h:61
void SetDebounceCount(uint16_t newCount)
Definition DebouncedDigitalInput.cpp:102
void Reset(bool newValue=false)
Definition DebouncedDigitalInput.cpp:96
const uint8_t m_readPin
Arduino pin number for this input.
Definition DebouncedDigitalInput.h:54
bool m_rawValue
Latest read value without debouncing.
Definition DebouncedDigitalInput.h:60
const uint8_t m_groundPin
Arduino pin number used as a ground source.
Definition DebouncedDigitalInput.h:55
uint16_t m_debounceSamples
Number of samples new value must be held before debounced value changes.
Definition DebouncedDigitalInput.h:57