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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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.begin() should only be called once https://www.arduino.cc/en/Reference/WireBegin
  11. #ifndef WIRE_BEGIN
  12. #define WIRE_BEGIN
  13. Wire.begin();
  14. #endif
  15. Wire.beginTransmission(port.ADDR);
  16. Wire.write(configurationByteCommand);
  17. Wire.write(0); //0=configure as output (for strobe pins and LED)
  18. Wire.endTransmission();
  19. }
  20. /*
  21. sets activePin pin output to low, does not reset the other pins because they might be used by LEDs.
  22. activePin is port mask, where active pin is 1.
  23. */
  24. void RowPort_PCA9655E::setActivePinLow(const uint8_t activePin)
  25. {
  26. Wire.beginTransmission(port.ADDR);
  27. Wire.write(outputByteCommand);
  28. Wire.write(port.outputVal &= ~activePin);
  29. Wire.endTransmission();
  30. }
  31. /*
  32. sets activePin pin output to high.
  33. activePin is port mask, where active pin is 1.
  34. */
  35. void RowPort_PCA9655E::setActivePinHigh(const uint8_t activePin)
  36. {
  37. Wire.beginTransmission(port.ADDR);
  38. Wire.write(outputByteCommand);
  39. Wire.write(port.outputVal |= activePin);
  40. Wire.endTransmission();
  41. }