keybrd library is an open source library for creating custom-keyboard firmware.
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
Это архивный репозиторий. Вы можете его клонировать или просматривать файлы, но не вносить изменения или открывать задачи/запросы на слияние.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. /* Port_PCA9655E
  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. */
  28. class Port_PCA9655E : public PortInterface
  29. {
  30. private:
  31. const uint8_t deviceAddr;
  32. const uint8_t portNum; //port identification number
  33. uint8_t outputVal; //bit pattern for strobe and LEDs
  34. const uint8_t readPins; //bit pattern, IODIR 0=output, 1=input
  35. public:
  36. Port_PCA9655E(const uint8_t deviceAddr, const uint8_t portNum, const uint8_t readPins)
  37. : deviceAddr(deviceAddr), portNum(portNum), outputVal(0), readPins(readPins) {}
  38. void beginProtocol();
  39. void begin(const uint8_t activeState);
  40. virtual void writeLow(const uint8_t pin);
  41. virtual void writeHigh(const uint8_t pin);
  42. virtual uint8_t read();
  43. };
  44. #endif