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_4c_split_with_IOE.ino 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* keybrd_4c_split_with_IOE.ino
  2. | Left | **0** | **1** | | Right | **0** | **1** |
  3. |:-----:|-------|-------| |:-----:|-------|-------|
  4. | **1** | 1 | 2 | | **1** | 3 | 4 |
  5. | **0** | a | b | | **0** | c | d |
  6. */
  7. // ################## GLOBAL ###################
  8. // ================= INCLUDES ==================
  9. #include <ScanDelay.h>
  10. #include <Code_Sc.h>
  11. #include <Row.h>
  12. //left matrix
  13. #include <Scanner_uC.h>
  14. //right matrix
  15. #include <PortIOE.h>
  16. #include <PortWrite_MCP23S17.h>
  17. #include <PortRead_MCP23S17.h>
  18. #include <Scanner_IOE.h>
  19. // ============ SPEED CONFIGURATION ============
  20. ScanDelay scanDelay(9000);
  21. // ================ LEFT SCANNER ===============
  22. uint8_t readPins[] = {14, 15};
  23. uint8_t readPinCount = sizeof(readPins)/sizeof(*readPins);
  24. Scanner_uC scanner_L(LOW, readPins, readPinCount);
  25. // =============== RIGHT SCANNER ===============
  26. const uint8_t PortIOE::DEVICE_ADDR = 0x20; //MCP23S17 address, all 3 ADDR pins are grounded
  27. PortIOE port_A(0);
  28. PortRead_MCP23S17 portRead_A(port_A, 1<<0 | 1<<1 );
  29. PortIOE port_B(1);
  30. //PortWrite_MCP23S17 portWrite_B(port_B); //for LEDs
  31. PortWrite_MCP23S17 portWrite_B(port_B);
  32. Scanner_IOE scanner_R(LOW, portWrite_B, portRead_A);
  33. // =================== CODES ===================
  34. Code_Sc s_a(KEY_A);
  35. Code_Sc s_b(KEY_B);
  36. Code_Sc s_c(KEY_C);
  37. Code_Sc s_d(KEY_D);
  38. Code_Sc s_1(KEY_1);
  39. Code_Sc s_2(KEY_2);
  40. Code_Sc s_3(KEY_3);
  41. Code_Sc s_4(KEY_4);
  42. // =================== ROWS ====================
  43. // ---------------- LEFT ROWS ------------------
  44. Key* ptrsKeys_L0[] = { &s_1, &s_2 };
  45. const uint8_t KEY_COUNT_L0 = sizeof(ptrsKeys_L0)/sizeof(*ptrsKeys_L0);
  46. Row row_L0(scanner_L, 0, ptrsKeys_L0, KEY_COUNT_L0);
  47. Key* ptrsKeys_L1[] = { &s_a, &s_b };
  48. const uint8_t KEY_COUNT_L1 = sizeof(ptrsKeys_L1)/sizeof(*ptrsKeys_L1);
  49. Row row_L1(scanner_L, 1, ptrsKeys_L1, KEY_COUNT_L1);
  50. // ---------------- RIGHT ROWS -----------------
  51. Key* ptrsKeys_R0[] = { &s_3, &s_4 };
  52. const uint8_t KEY_COUNT_R0 = sizeof(ptrsKeys_R0)/sizeof(*ptrsKeys_R0);
  53. Row row_R0(scanner_R, 1<<0, ptrsKeys_R0, KEY_COUNT_R0);
  54. Key* ptrsKeys_R1[] = { &s_c, &s_d };
  55. const uint8_t KEY_COUNT_R1 = sizeof(ptrsKeys_R1)/sizeof(*ptrsKeys_R1);
  56. Row row_R1(scanner_R, 1<<1, ptrsKeys_R1, KEY_COUNT_R1);
  57. // ################### MAIN ####################
  58. void setup()
  59. {
  60. delay(7000); //todo
  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. }