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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #include "RowScanner_Arduino.h"
  2. /*
  3. Strobes the row and reads the columns.
  4. Strobe is on for shortest possible time.
  5. */
  6. uint8_t RowScanner_Arduino::scan(uint16_t& rowEnd)
  7. {
  8. uint8_t rowState = 0;
  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. /*
  20. uint8_t col = 1;
  21. //read all the column ports
  22. for (uint8_t i=0; i < readPinCount; i++)
  23. {
  24. if (digitalRead(6))
  25. {
  26. rowState |= col;
  27. //ptrsColPorts[i]->read();
  28. }
  29. col <<= 1;
  30. }
  31. */
  32. if (digitalRead(6) == 0)
  33. {
  34. rowState |= 1<<0;
  35. }
  36. if (digitalRead(7) == 0)
  37. {
  38. rowState |= 1<<1;
  39. }
  40. //strobe row off
  41. if (activeHigh)
  42. {
  43. digitalWrite(0, LOW);
  44. }
  45. else //activeLow
  46. {
  47. digitalWrite(0, HIGH);
  48. }
  49. rowEnd = 4; //only read first two col, a1 b2 4
  50. Keyboard.print(rowState); // prints 2b, not 1a, what happened to col0?
  51. return rowState;
  52. }