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.

RowPort_PCA9655E.cpp 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include "RowPort_PCA9655E.h"
  2. /*
  3. configures column port's configuration and output.
  4. */
  5. RowPort_PCA9655E::RowPort_PCA9655E(IOExpanderPort& port)
  6. : port(port), configurationByteCommand(port.num + 6), outputByteCommand(port.num + 2)
  7. {}
  8. void RowPort_PCA9655E::begin()
  9. {
  10. Wire.beginTransmission(port.ADDR);
  11. Wire.write(configurationByteCommand);
  12. Wire.write(0); //0=configure as output (for strobe pins and LED)
  13. Wire.endTransmission();
  14. }
  15. /*
  16. sets activePin pin output to low, does not reset the other pins because they might be used by LEDs.
  17. activePin is port mask, where active pin is 1.
  18. */
  19. void RowPort_PCA9655E::setActivePinLow(const uint8_t activePin)
  20. {
  21. Wire.beginTransmission(port.ADDR);
  22. Wire.write(outputByteCommand);
  23. Wire.write(port.outputVal &= ~activePin);
  24. Wire.endTransmission();
  25. }
  26. /*
  27. sets activePin pin output to high.
  28. activePin is port mask, where active pin is 1.
  29. */
  30. void RowPort_PCA9655E::setActivePinHigh(const uint8_t activePin)
  31. {
  32. Wire.beginTransmission(port.ADDR);
  33. Wire.write(outputByteCommand);
  34. Wire.write(port.outputVal |= activePin);
  35. Wire.endTransmission();
  36. //todo delayMicroseconds(1500); still 4*bb w/o debouncer prints IOE rows sporadically
  37. }