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.

keybrd_PCA9655E.ino 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* keybrd_PCA9655E.ino
  2. Teensy 2.0 controller PCA9655E I/O expander
  3. | Left | **0** | **1** | | Right | **0** | **1** |
  4. |:-----:|-------|-------| |:-----:|-------|-------|
  5. | **1** | 1 | 2 | | **1** | 3 | 4 |
  6. | **0** | a | b | | **0** | c | d |
  7. */
  8. // ################## GLOBAL ###################
  9. // ================= INCLUDES ==================
  10. #include <ScanDelay.h>
  11. #include <Code_Sc.h>
  12. #include <Row.h>
  13. //left matrix
  14. #include <Scanner_uC.h>
  15. //right matrix
  16. #include <PortIOE.h>
  17. #include <PortWrite_PCA9655E.h>
  18. #include <PortRead_PCA9655E.h>
  19. #include <Scanner_IOE.h>
  20. // ============ SPEED CONFIGURATION ============
  21. ScanDelay scanDelay(9000);
  22. // ================ LEFT SCANNER ===============
  23. uint8_t readPins_L[] = {0, 1};
  24. uint8_t readPinCount_L = sizeof(readPins_L)/sizeof(*readPins_L);
  25. Scanner_uC scanner_L(HIGH, readPins_L, readPinCount_L);
  26. // =============== RIGHT SCANNER ===============
  27. const uint8_t PortIOE::DEVICE_ADDR = 0x18;
  28. PortIOE port_R1(1, 0);
  29. PortWrite_PCA9655E portWrite_R1(port_R1);
  30. PortIOE port_R0(0, 0);
  31. //PortWrite_PCA9655E portWrite_R0(port_R0); //for LEDs
  32. PortRead_PCA9655E portRead_R0(port_R0, 1<<0 | 1<<1 );
  33. Scanner_IOE scanner_R(HIGH, portWrite_R1, portRead_R0);
  34. // =================== CODES ===================
  35. Code_Sc s_a(KEY_A);
  36. Code_Sc s_b(KEY_B);
  37. Code_Sc s_c(KEY_C);
  38. Code_Sc s_d(KEY_D);
  39. Code_Sc s_1(KEY_1);
  40. Code_Sc s_2(KEY_2);
  41. Code_Sc s_3(KEY_3);
  42. Code_Sc s_4(KEY_4);
  43. // =================== ROWS ====================
  44. // ---------------- LEFT ROWS ------------------
  45. Key* ptrsKeys_L0[] = { &s_1, &s_2 };
  46. uint8_t KEY_COUNT_L0 = sizeof(ptrsKeys_L0)/sizeof(*ptrsKeys_L0);
  47. Row row_L0(scanner_L, 21, ptrsKeys_L0, KEY_COUNT_L0);
  48. Key* ptrsKeys_L1[] = { &s_a, &s_b };
  49. uint8_t KEY_COUNT_L1 = sizeof(ptrsKeys_L1)/sizeof(*ptrsKeys_L1);
  50. Row row_L1(scanner_L, 20, ptrsKeys_L1, KEY_COUNT_L1);
  51. // ---------------- RIGHT ROWS -----------------
  52. Key* ptrsKeys_R0[] = { &s_3, &s_4 };
  53. uint8_t KEY_COUNT_R0 = sizeof(ptrsKeys_R0)/sizeof(*ptrsKeys_R0);
  54. Row row_R0(scanner_R, 1<<0, ptrsKeys_R0, KEY_COUNT_R0);
  55. Key* ptrsKeys_R1[] = { &s_c, &s_d };
  56. uint8_t KEY_COUNT_R1 = sizeof(ptrsKeys_R1)/sizeof(*ptrsKeys_R1);
  57. Row row_R1(scanner_R, 1<<1, ptrsKeys_R1, KEY_COUNT_R1);
  58. // ################### MAIN ####################
  59. void setup()
  60. {
  61. Keyboard.begin();
  62. scanner_R.begin();
  63. }
  64. void loop()
  65. {
  66. //left matrix
  67. row_L0.process();
  68. row_L1.process();
  69. //right matrix
  70. row_R0.process();
  71. row_R1.process();
  72. scanDelay.delay();
  73. //debug.print_scans_per_second();
  74. //debug.print_microseconds_per_scan();
  75. }