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.

RowScanner_Arduino.cpp 818B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include "RowScanner_Arduino.h"
  2. /*
  3. Strobes the row and reads the columns.
  4. */
  5. uint8_t RowScanner_Arduino::scan(uint16_t& rowEnd)
  6. {
  7. uint8_t rowState = 0;
  8. uint8_t col = 1;
  9. //strobe row on
  10. if (activeHigh)
  11. {
  12. digitalWrite(strobePin, HIGH);
  13. }
  14. else //activeLow
  15. {
  16. digitalWrite(strobePin, LOW);
  17. }
  18. delayMicroseconds(3); //time to stablize voltage
  19. //read all the column ports
  20. for (uint8_t i=0; i < READ_PIN_COUNT; i++)
  21. {
  22. if ( digitalRead(readPins[i]) == activeHigh )
  23. {
  24. rowState |= col;
  25. }
  26. col <<= 1;
  27. }
  28. //strobe row off
  29. if (activeHigh)
  30. {
  31. digitalWrite(strobePin, LOW);
  32. }
  33. else //activeLow
  34. {
  35. digitalWrite(strobePin, HIGH);
  36. }
  37. rowEnd = col;
  38. return rowState;
  39. }