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.

PortRead_PCA9655E.h 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #ifndef PORTREAD_PCA9655E_H
  2. #define PORTREAD_PCA9655E_H
  3. #include <Arduino.h>
  4. #include <inttypes.h>
  5. #include <Wire.h>
  6. #include <PortReadInterface.h>
  7. #include "PortIOE.h"
  8. /* One PCA9655E I/O expander port connected to matrix columns.
  9. PCA9655E does not have internal pull-up resistors (PCA9535E does).
  10. Instantiation
  11. ------------
  12. readPins parameter is bit pattern for port's pin configuration
  13. 1=configure as input (for pins connected to column)
  14. 0=configure as output (for LED or not connected to a column)
  15. readPins are read from pin 0 on up.
  16. Example instantiation for column port 1, with pins 2 and 3 connected to columns:
  17. const uint8_t PortIOE::DEVICE_ADDR = 0x20; //PCA9655E address, all 3 ADDR pins are grounded
  18. PortIOE port1(1);
  19. PortRead_PCA9655E colPort1(port1, 1<<2 | 1<<3 );
  20. Diode orientation
  21. ----------------
  22. Diode orientation is explained in keybrd_library_user_guide.md > Diode orientation
  23. PCA9655E data sheet
  24. ----------------
  25. http://www.onsemi.com/pub_link/Collateral/PCA9655E-D.PDF
  26. */
  27. class PortRead_PCA9655E : public PortReadInterface
  28. {
  29. private:
  30. PortIOE& port;
  31. const uint8_t readPins; //bit pattern, pin configuration, 1 means read pin
  32. public:
  33. PortRead_PCA9655E (PortIOE& port, const uint8_t readPins)
  34. : port(port), readPins(readPins) {}
  35. void begin(const uint8_t strobeOn);
  36. virtual uint8_t read();
  37. };
  38. #endif