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.0KB

1234567891011121314151617181920212223242526
  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. const uint8_t SS; //Slave Select, pin on master
  17. const uint8_t BYTE_COUNT; //number of shift registers
  18. const uint8_t KEY_COUNT; //number of keys in row
  19. public:
  20. RowScanner_SPIShiftRegisters(const uint8_t SS, uint8_t BYTE_COUNT, uint8_t KEY_COUNT)
  21. : SS(SS), BYTE_COUNT(BYTE_COUNT), KEY_COUNT(KEY_COUNT) {}
  22. virtual read_pins_t scan(read_pins_mask_t& rowEnd);
  23. void begin();
  24. };
  25. #endif