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

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