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.

Scanner_IOE.h 1.3KB

1234567891011121314151617181920212223242526272829303132
  1. #ifndef SCANNER_PORT_H
  2. #define SCANNER_PORT_H
  3. #include <Arduino.h>
  4. #include <inttypes.h>
  5. #include <ScannerInterface.h>
  6. #include <PortWriteInterface.h>
  7. #include <PortReadInterface.h>
  8. /* Scanner_IOE uses bit manipulation to read all pins of one port.
  9. The ports are normally from an I/O Expander, but could also be ports from an AVR uC.
  10. The maximum keys per row is 8, because ports have a maximum of 8 pins each.
  11. keybrd_library_developer_guide.md has instructions for ## Active state and diode orientation
  12. */
  13. class Scanner_IOE : public ScannerInterface
  14. {
  15. private:
  16. const bool strobeOn; //logic level of strobe on, HIGH or LOW
  17. const bool strobeOff; //logic level of strobe off, complement of strobeOn
  18. PortWriteInterface& refPortWrite; //the IC port containing the strobePin
  19. PortReadInterface& refPortRead; //the IC's read port
  20. public:
  21. Scanner_IOE(const bool strobeOn,
  22. PortWriteInterface &refPortWrite, PortReadInterface& refPortRead)
  23. : strobeOn(strobeOn), strobeOff(!strobeOn),
  24. refPortWrite(refPortWrite), refPortRead(refPortRead) {}
  25. void init(const uint8_t strobePin);
  26. void begin();
  27. read_pins_t scan(const uint8_t strobePin);
  28. };
  29. #endif