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 1.0KB

1234567891011121314151617181920212223242526272829303132333435
  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. void 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. portState = Wire.read();
  25. /*if (portState)//todo
  26. {
  27. Keyboard.print(" portState=");
  28. Keyboard.print(portState);
  29. }*/
  30. }