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í.

Port_PCA9655E.h 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #ifndef PORT_PCA9655E_H
  2. #define PORT_PCA9655E_H
  3. #include <Arduino.h>
  4. #include <inttypes.h>
  5. #include <Wire.h>
  6. #include <PortInterface.h>
  7. /*
  8. write pins are connected to matrix Row (strobe pin) or LED.
  9. readPins are connected to matrix column to read which keys are pressed.
  10. Be careful with the deviceAddr.
  11. Table 6 in PCA9655E datasheet lists 8-bit versions of I2C addresses.
  12. The Arduino Wire library uses 7-bit addresses throughout, so drop the low bit.
  13. For example, I2C address with AD2=GND AD1=SCL AD0=SCL,
  14. Table 6 lists 8-bit DEVICE_ADDR = 0x30 (b 00110000)
  15. while Arduino uses 7-bit DEVICE_ADDR = 0x18 (b 00011000)
  16. http://playground.arduino.cc/Main/WireLibraryDetailedReference
  17. Instantiation
  18. ------------
  19. Example instantiation:
  20. const uint8_t IOE_ADDR = 0x20; //PCA9655E address, all 3 ADDR pins are grounded
  21. Port_PCA9655E portB(IOE_ADDR, 1, 0); //all pins are set to output for strobes and LEDs
  22. Port_PCA9655E portA(IOE_ADDR, 0, 1<<0 | 1<<1 ); //pin 0 and pin 1 are set to input for reading,
  23. //remaining pins can be used for LEDs
  24. Diode orientation
  25. ----------------
  26. Diode orientation is explained in keybrd_library_user_guide.md > Diode orientation
  27. PCA9655E data sheet
  28. ----------------
  29. http://www.onsemi.com/pub_link/Collateral/PCA9655E-D.PDF
  30. */
  31. class Port_PCA9655E : public PortInterface
  32. {
  33. private:
  34. const uint8_t deviceAddr;
  35. const uint8_t portNum; //port identification number
  36. uint8_t outputVal; //bit pattern for strobe and LEDs
  37. const uint8_t readPins; //bit pattern, IODIR 0=output, 1=input
  38. public:
  39. Port_PCA9655E(const uint8_t deviceAddr, const uint8_t portNum, const uint8_t readPins)
  40. : deviceAddr(deviceAddr), portNum(portNum), outputVal(0), readPins(readPins) {}
  41. void beginProtocol();
  42. void begin(const uint8_t activeState);
  43. virtual void setLow(const uint8_t pin);
  44. virtual void setHigh(const uint8_t pin);
  45. virtual uint8_t read();
  46. };
  47. #endif