keybrd library is an open source library for creating custom-keyboard firmware.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

keybrd_PCA9655E.ino 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /* keybrd_PCA9655E.ino
  2. Controller 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 <Port_PCA9655E.h>
  17. #include <Scanner_IOE.h>
  18. // ============ SPEED CONFIGURATION ============
  19. ScanDelay scanDelay(9000);
  20. // ================ LEFT SCANNER ===============
  21. uint8_t readPins[] = {0, 1};
  22. uint8_t readPinCount = sizeof(readPins)/sizeof(*readPins);
  23. Scanner_uC scanner_L(HIGH, readPins, readPinCount);
  24. // =============== RIGHT SCANNER ===============
  25. const uint8_t IOE_ADDR = 0x18;
  26. Port_PCA9655E port1(IOE_ADDR, 1, 0); //for strobe
  27. Port_PCA9655E port0(IOE_ADDR, 0, 1<<0 | 1<<1 ); //for read
  28. Scanner_IOE scanner_R(HIGH, port1, port0);
  29. // =================== CODES ===================
  30. Code_Sc s_a(KEY_A);
  31. Code_Sc s_b(KEY_B);
  32. Code_Sc s_c(KEY_C);
  33. Code_Sc s_d(KEY_D);
  34. Code_Sc s_1(KEY_1);
  35. Code_Sc s_2(KEY_2);
  36. Code_Sc s_3(KEY_3);
  37. Code_Sc s_4(KEY_4);
  38. // =================== ROWS ====================
  39. // ---------------- LEFT ROWS ------------------
  40. Key* ptrsKeys_L0[] = { &s_1, &s_2 };
  41. uint8_t KEY_COUNT_L0 = sizeof(ptrsKeys_L0)/sizeof(*ptrsKeys_L0);
  42. Row row_L0(scanner_L, 21, ptrsKeys_L0, KEY_COUNT_L0);
  43. Key* ptrsKeys_L1[] = { &s_a, &s_b };
  44. uint8_t KEY_COUNT_L1 = sizeof(ptrsKeys_L1)/sizeof(*ptrsKeys_L1);
  45. Row row_L1(scanner_L, 20, ptrsKeys_L1, KEY_COUNT_L1);
  46. // ---------------- RIGHT ROWS -----------------
  47. Key* ptrsKeys_R0[] = { &s_3, &s_4 };
  48. uint8_t KEY_COUNT_R0 = sizeof(ptrsKeys_R0)/sizeof(*ptrsKeys_R0);
  49. Row row_R0(scanner_R, 1<<0, ptrsKeys_R0, KEY_COUNT_R0);
  50. Key* ptrsKeys_R1[] = { &s_c, &s_d };
  51. uint8_t KEY_COUNT_R1 = sizeof(ptrsKeys_R1)/sizeof(*ptrsKeys_R1);
  52. Row row_R1(scanner_R, 1<<1, ptrsKeys_R1, KEY_COUNT_R1);
  53. // ################### MAIN ####################
  54. void setup()
  55. {
  56. Keyboard.begin();
  57. scanner_R.begin();
  58. }
  59. void loop()
  60. {
  61. //left matrix
  62. row_L0.process();
  63. row_L1.process();
  64. //right matrix
  65. row_R0.process();
  66. row_R1.process();
  67. scanDelay.delay();
  68. //debug.print_scans_per_second();
  69. //debug.print_microseconds_per_scan();
  70. }