From 6980ace9e41f48b2e109257404eba0bb76b332af Mon Sep 17 00:00:00 2001 From: audiobird Date: Wed, 2 Apr 2025 13:16:19 -0700 Subject: [PATCH] Add simple rising edge detector . --- util/edge_detector.hh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/util/edge_detector.hh b/util/edge_detector.hh index 141fd36..70a1253 100644 --- a/util/edge_detector.hh +++ b/util/edge_detector.hh @@ -38,3 +38,14 @@ struct EdgeStateDetector { last_state_ = false; } }; + +class RisingEdgeDetector { + bool last_state_ = false; + +public: + bool update(bool state) { + const auto out = state && last_state_ != state; + last_state_ = state; + return out; + } +};