Skip to content

Commit 8a4f166

Browse files
authored
Merge pull request #13 from 4ms/rising-edge
2 parents 7dddb74 + 6980ace commit 8a4f166

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

util/edge_detector.hh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,14 @@ struct EdgeStateDetector {
3838
last_state_ = false;
3939
}
4040
};
41+
42+
class RisingEdgeDetector {
43+
bool last_state_ = false;
44+
45+
public:
46+
bool update(bool state) {
47+
const auto out = state && last_state_ != state;
48+
last_state_ = state;
49+
return out;
50+
}
51+
};

0 commit comments

Comments
 (0)