keybrd library is an open source library for creating custom-keyboard firmware.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

Row.cpp 970B

123456789101112131415161718192021222324252627
  1. /* debounce() sets debounced and returns debouncedChanged. All variables are bitwise.
  2. For parameter, 1 means pressed, 0 means released.
  3. For return, 1 means debounced changed.
  4. */
  5. #include "Row.h"
  6. /*
  7. process() scans the row and calls any newly pressed or released keys.
  8. */
  9. void Row::process(const bool activeHigh)
  10. {
  11. //these variables are all bitwise, one bit per key
  12. uint8_t rowState; //1 means pressed, 0 means released
  13. uint16_t rowEnd; //1 bit marks positioned after last key of row
  14. uint8_t debouncedChanged; //1 means debounced changed
  15. wait();
  16. scan(activeHigh); //save column-port-pin values to portState
  17. rowState = getRowState(rowEnd, activeHigh);
  18. debouncedChanged = debounce(rowState);
  19. pressRelease(rowEnd, debouncedChanged);
  20. }
  21. uint8_t Row::debounce(const uint8_t rowState)
  22. {
  23. return debouncer.debounce(rowState, debounced);
  24. }