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.

ReadPort_PCA9655E.cpp 961B

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