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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. Scanner_ShiftRegs74HC165.h has instructions for hardware and setting active state.
  10. Example instantiation of a Row_ShiftRegisters:
  11. const uint8_t Scanner_ShiftRegs74HC165::SHIFT_LOAD = 10;
  12. const bool Scanner_ShiftRegs74HC165::STROBE_ON = LOW; //active low
  13. const bool Scanner_ShiftRegs74HC165::STROBE_OFF = HIGH;
  14. Key* const ptrsKeys_0[] = { &k_00, &k_01, &k_02, &k_03, &k_04, &k_05 };
  15. uint8_t readPinCount_0 = sizeof(ptrsKeys_0)/sizeof(*ptrsKeys_0);
  16. Row_ShiftRegisters row_0(1, readPinCount_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. readPinCount should equal number of keys in ptrsKeys_0[] array.
  25. if readPinCount is too small, a key will be unresponsive
  26. if readPinCount 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 readPinCount; //number of read pins
  34. public:
  35. Row_ShiftRegisters(const uint8_t strobePin, const uint8_t readPinCount,
  36. Key* const ptrsKeys[])
  37. : Row(ptrsKeys), scanner(strobePin, readPinCount), readPinCount(readPinCount) { }
  38. void begin();
  39. void process();
  40. };
  41. #endif