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_SPIShiftRegisters.h 1.4KB

123456789101112131415161718192021222324252627282930
  1. #ifndef ROWSCANNER_SPI_SHIFTREGISTERS_H
  2. #define ROWSCANNER_SPI_SHIFTREGISTERS_H
  3. #include <Arduino.h>
  4. #include <inttypes.h>
  5. #include <SPI.h>
  6. #include <RowScannerInterface.h>
  7. #include <RowPort.h>
  8. #include <ColPort.h>
  9. /* RowScanner_SPIShiftRegisters reads all shift registers in a daisy chain.
  10. The maximum keys per row is 31, because Arduino's largest type is 32 bits and rowEnd consumes the last bit.
  11. //todo delete: Assumes only one row of shift registers is connected (no Slave Select).
  12. */
  13. class RowScanner_SPIShiftRegisters : public RowScannerInterface
  14. {
  15. private:
  16. //todo static const bool ACTIVE_HIGH; //logic level of strobe pin: 0=activeLow, 1=activeHigh
  17. const uint8_t STROBE_PIN; //Arduino pin number connected to this row
  18. const uint8_t SHIFT_LOAD; //controller's pin number that is connected to shift register's SHIFT_LOAD pin
  19. const uint8_t BYTE_COUNT; //number of bytes to read from shift registers
  20. const uint8_t KEY_COUNT; //number of keys in row
  21. public:
  22. RowScanner_SPIShiftRegisters(const uint8_t STROBE_PIN, const uint8_t SHIFT_LOAD,
  23. uint8_t BYTE_COUNT, uint8_t KEY_COUNT)
  24. : STROBE_PIN(STROBE_PIN), SHIFT_LOAD(SHIFT_LOAD),
  25. BYTE_COUNT(BYTE_COUNT), KEY_COUNT(KEY_COUNT) {}
  26. virtual read_pins_t scan(read_pins_mask_t& rowEnd);
  27. void begin();
  28. };
  29. #endif