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 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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(stobePin, HIGH);
  13. }
  14. else //activeLow
  15. {
  16. digitalWrite(stobePin, 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. /*
  27. Keyboard.print(" stobePin");
  28. Keyboard.print(stobePin);
  29. Keyboard.print(" readPins[");
  30. Keyboard.print(i);
  31. Keyboard.print("]");
  32. Keyboard.print((int)readPins[i]);
  33. Keyboard.print(" col");
  34. Keyboard.print(col);
  35. Keyboard.print(" ");
  36. */
  37. col <<= 1;
  38. }
  39. //strobe row off
  40. if (activeHigh)
  41. {
  42. digitalWrite(0, LOW);
  43. }
  44. else //activeLow
  45. {
  46. digitalWrite(0, HIGH);
  47. }
  48. rowEnd = 4; //only read first two col, a1 b2 4
  49. //Keyboard.print(rowState);
  50. return rowState;
  51. }