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.

StrobePort_PCA9655E.cpp 1.2KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #include "StrobePort_PCA9655E.h"
  2. /*
  3. configures column port's configuration and output.
  4. */
  5. StrobePort_PCA9655E::StrobePort_PCA9655E(IOEPort& port)
  6. : port(port), configurationByteCommand(port.num + 6), outputByteCommand(port.num + 2) {}
  7. void StrobePort_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. pin is bitwise, where pin being strobed is 1.
  16. value is HIGH or LOW.
  17. Does not reset the other pins because LEDs could be using some of the pins.
  18. */
  19. void StrobePort_PCA9655E::write(const uint8_t pin, const bool value)
  20. {
  21. if (value == LOW) //if active low
  22. {
  23. port.outputVal &= ~pin; //set pin output to low
  24. }
  25. else //if active high
  26. {
  27. port.outputVal |= pin; //set pin output to high
  28. }
  29. Wire.beginTransmission(port.ADDR);
  30. Wire.write(outputByteCommand);
  31. Wire.write(port.outputVal);
  32. Wire.endTransmission();
  33. }