Skip to content

Commit

Permalink
Add released to check if a button was released this frame
Browse files Browse the repository at this point in the history
  • Loading branch information
joewreschnig committed May 1, 2023
1 parent edd9a85 commit 51da2eb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions libraries/hardware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ namespace picosystem {
return !(_io & (1U << b)) && (_lio & (1U << b));
}

bool released(uint32_t b) {
return (_io & (1U << b)) && !(_lio & (1U << b));
}

bool button(uint32_t b) {
return !(_io & (1U << b));
}
Expand Down
1 change: 1 addition & 0 deletions libraries/picosystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ namespace picosystem {

// hardware
bool pressed(uint32_t b);
bool released(uint32_t b);
bool button(uint32_t b);
uint32_t battery();
void led(uint8_t r, uint8_t g, uint8_t b);
Expand Down

0 comments on commit 51da2eb

Please sign in to comment.