keybrd library is an open source library for creating custom-keyboard firmware.
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
Tento repozitář je archivovaný. Můžete prohlížet soubory, klonovat, ale nemůžete nahrávat a vytvářet nové úkoly a požadavky na natažení.

PortWrite_PCA9655E.cpp 1.1KB

123456789101112131415161718192021222324252627282930313233343536
  1. #include "PortWrite_PCA9655E.h"
  2. /* begin() is called from Scanner_IOE::begin().
  3. Configures write pins to output.
  4. */
  5. void PortWrite_PCA9655E::begin()
  6. {
  7. Wire.begin();
  8. Wire.beginTransmission(port.DEVICE_ADDR);
  9. Wire.write(port.num + 6); //configuration byte command
  10. Wire.write(0); //configure all pins as output
  11. Wire.endTransmission();
  12. }
  13. /* write() sets pin output to logicLevel.
  14. pin is bitwise, where pin being strobed is 1.
  15. logicLevel is HIGH or LOW.
  16. write() does not overwrite the other pins.
  17. */
  18. void PortWrite_PCA9655E::write(const uint8_t pin, const bool logicLevel)
  19. {
  20. if (logicLevel == LOW) //if pin low
  21. {
  22. port.outputVal &= ~pin; //set pin output to low
  23. }
  24. else //if strobestrobe high
  25. {
  26. port.outputVal |= pin; //set pin output to high
  27. }
  28. Wire.beginTransmission(port.DEVICE_ADDR);
  29. Wire.write(port.num + 2); //output Byte command
  30. Wire.write(port.outputVal);
  31. Wire.endTransmission();
  32. }