keybrd library is an open source library for creating custom-keyboard firmware.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
Repozitorijs ir arhivēts. Tam var aplūkot failus un to var klonēt, bet nevar iesūtīt jaunas izmaiņas, kā arī atvērt jaunas problēmas/izmaiņu pieprasījumus.

PortPCA9655E.h 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #ifndef PORTPCA9655E_H
  2. #define PORTPCA9655E_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. PortPCA9655E portB(IOE_ADDR, 1, 0); //all pins are set to output for strobes and LEDs
  22. PortPCA9655E portA(IOE_ADDR, 0, 1<<0 | 1<<1 ); //first two pins 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 PortPCA9655E : 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. PortPCA9655E(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 strobeOn);
  43. virtual void write(const uint8_t pin, const bool logicLevel);
  44. virtual uint8_t read();
  45. };
  46. #endif