Valor 6800 1.0
Loading...
Searching...
No Matches
DebounceSensor.h
1
2#pragma once
3
4#include <functional>
5#include <string>
6
7#include <frc/TimedRobot.h>
8
9#include "valkyrie/sensors/BaseSensor.h"
10
11namespace valor {
12
22class DebounceSensor : public BaseSensor<bool> {
23 public:
29 explicit DebounceSensor(frc::TimedRobot& robot);
30
36 void setEdgeCallback(std::function<void()> _lambda);
37
43 void setRisingEdgeCallback(std::function<void()> _lambda);
44
50 void setFallingEdgeCallback(std::function<void()> _lambda);
51
52 protected:
53 DebounceSensor() = default;
54
60 void calculate() override;
61
62 private:
63 std::function<void()> edge;
64 std::function<void()> fallingEdge;
65 std::function<void()> risingEdge;
66};
67
68} // namespace valor
Abstract class that all Valor sensors should implement.
Definition BaseSensor.h:27
Sensor for debouncing and detecting rising/falling edges of boolean inputs.
Definition DebounceSensor.h:22
void setFallingEdgeCallback(std::function< void()> _lambda)
Set a callback function for detecting a falling edge.
DebounceSensor(frc::TimedRobot &robot)
Construct a new DebounceSensor object.
void setRisingEdgeCallback(std::function< void()> _lambda)
Set a callback function for detecting a rising edge.
void setEdgeCallback(std::function< void()> _lambda)
Set a callback function for detecting any edge (rising or falling).
void calculate() override
Perform debounce-specific calculations.
T ReadLog(std::string_view field, const T &defaultValue={})
Read a value from NetworkTables for the given field.
Definition Loggable.h:343