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.cpp 947B

12345678910111213141516171819202122232425262728293031
  1. #include "PortRead_PCA9655E.h"
  2. /*
  3. configures column port's configuration, input, and pins.
  4. */
  5. PortRead_PCA9655E::PortRead_PCA9655E (PortIOE& port, const uint8_t readPins)
  6. : PortRead(readPins), port(port),
  7. configurationByteCommand(port.num + 6), inputByteCommand(port.num)
  8. {}
  9. void PortRead_PCA9655E::begin()
  10. {
  11. Wire.beginTransmission(port.ADDR);
  12. Wire.write(configurationByteCommand);
  13. Wire.write(readPins); //0=configure as output (for LED), 1=configure as input (for read)
  14. Wire.endTransmission();
  15. }
  16. /*
  17. returns port value
  18. */
  19. uint8_t PortRead_PCA9655E::read()
  20. {
  21. Wire.beginTransmission(port.ADDR);
  22. Wire.write(inputByteCommand); //input immediately before requestFrom
  23. Wire.endTransmission(false); //PCA9655E needs false to send a restart
  24. Wire.requestFrom(port.ADDR, 1u); //request one byte from input port
  25. return Wire.read();
  26. }