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_ShiftRegisters.h 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #ifndef ROW_SHIFTREGISTERS_H
  2. #define ROW_SHIFTREGISTERS_H
  3. #include <Row.h>
  4. #include <Scanner_ShiftRegs74HC165.h>
  5. #include <Debouncer_Samples.h>
  6. /* Row_ShiftRegisters is a row connected to shift registers.
  7. Instantiation
  8. -------------
  9. Definition of DELAY_MICROSECONDS is explained in Row.cpp.
  10. Example instantiation of a Row_ShiftRegisters:
  11. const uint8_t Scanner_ShiftRegs74HC165::SHIFT_LOAD = 10;
  12. const bool Scanner_ShiftRegs74HC165::STROBE_ON = LOW; //logic level of strobe on, active low
  13. const bool Scanner_ShiftRegs74HC165::STROBE_OFF = HIGH; //logic level of strobe off
  14. Key* const ptrsKeys_0[] = { &k_00, &k_01, &k_02, &k_03, &k_04, &k_05 };
  15. uint8_t READ_PIN_COUNT_0 = sizeof(ptrsKeys_0)/sizeof(*ptrsKeys_0);
  16. Row_ShiftRegisters row_0(1, READ_PIN_COUNT_0, ptrsKeys_0);
  17. call begin() from sketch setup():
  18. void setup()
  19. {
  20. Keyboard.begin();
  21. SPI.begin();
  22. row_0.begin();
  23. }
  24. READ_PIN_COUNT should equal number of keys in ptrsKeys_0[] array.
  25. if READ_PIN_COUNT is too small, a key will be unresposive
  26. if READ_PIN_COUNT is too large, the keyboard will fail in an unpredictable way
  27. */
  28. class Row_ShiftRegisters : public Row
  29. {
  30. private:
  31. Scanner_ShiftRegs74HC165 scanner;
  32. Debouncer_Samples debouncer;
  33. const uint8_t READ_PIN_COUNT; //number of read pins
  34. public:
  35. Row_ShiftRegisters(const uint8_t STROBE_PIN, const uint8_t READ_PIN_COUNT, Key *const ptrsKeys[])
  36. : Row(ptrsKeys), scanner(STROBE_PIN, READ_PIN_COUNT), READ_PIN_COUNT(READ_PIN_COUNT) { }
  37. void begin();
  38. void process();
  39. };
  40. #endif