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_5b_LED_on_IOE.ino 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* keybrd_5b_LED_on_IOE.ino
  2. This sketch:
  3. is a simple 1-layer keyboard with CapsLck indicator LED on I/O expander
  4. runs on two matrices of a breadboard keyboard
  5. modified keybrd_4c_split_keyboard_with_IOE.ino by adding LED_CapsLck
  6. This layout table shows left and right matrices:
  7. | Left | **0** | **1** | | Right | **0** | **1** |
  8. |:-----:|-------|-------|-|:-----:|-------|-------|
  9. | **1** | 1 | 2 | | **1** | 3 |CapsLck|
  10. | **0** | a | b | | **0** | c | d |
  11. */
  12. // ################## GLOBAL ###################
  13. // ================= INCLUDES ==================
  14. #include <ScanDelay.h>
  15. #include <Code_LEDLock.h>
  16. #include <Code_Sc.h>
  17. #include <Row.h>
  18. //left matrix
  19. #include <Scanner_uC.h>
  20. //right matrix
  21. #include <PortIOE.h>
  22. #include <PortMCP23S17.h>
  23. #include <Scanner_IOE.h>
  24. #include <LED_IOE.h>
  25. // ============ SPEED CONFIGURATION ============
  26. ScanDelay scanDelay(9000);
  27. // ================ LEFT SCANNER ===============
  28. uint8_t readPins[] = {14, 15};
  29. const uint8_t READPIN_COUNT = sizeof(readPins)/sizeof(*readPins);
  30. Scanner_uC scanner_L(LOW, readPins, READPIN_COUNT);
  31. // =============== RIGHT SCANNER ===============
  32. const uint8_t PortIOE::DEVICE_ADDR = 0x20; //MCP23S17 address with all 3 ADDR pins are grounded
  33. PortIOE port_A(0);
  34. PortMCP23S17 portRead(port_A, 1<<0 | 1<<1 );
  35. PortIOE port_B(1);
  36. PortMCP23S17 portWrite(port_B, 0);
  37. Scanner_IOE scanner_R(LOW, portWrite, portRead);
  38. // ================ RIGHT LEDs =================
  39. //LED_IOE LED_CapsLck(portRead, 1<<6); //tested LED on port A (read)
  40. //LED_IOE LED_CapsLck(portWrite, 1<<6);//tested LED on port B (write)
  41. // =================== CODES ===================
  42. Code_Sc s_a(KEY_A);
  43. Code_Sc s_b(KEY_B);
  44. Code_Sc s_c(KEY_C);
  45. Code_Sc s_d(KEY_D);
  46. Code_Sc s_1(KEY_1);
  47. Code_Sc s_2(KEY_2);
  48. Code_Sc s_3(KEY_3);
  49. Code_Sc o_capsLock(KEY_4);
  50. //Code_LEDLock o_capsLock(KEY_CAPS_LOCK, LED_CapsLck);
  51. // =================== ROWS ====================
  52. // ---------------- LEFT ROWS ------------------
  53. Key* ptrsKeys_L0[] = { &s_1, &s_2 };
  54. const uint8_t KEY_COUNT_L0 = sizeof(ptrsKeys_L0)/sizeof(*ptrsKeys_L0);
  55. Row row_L0(scanner_L, 0, ptrsKeys_L0, KEY_COUNT_L0);
  56. Key* ptrsKeys_L1[] = { &s_a, &s_b };
  57. const uint8_t KEY_COUNT_L1 = sizeof(ptrsKeys_L1)/sizeof(*ptrsKeys_L1);
  58. Row row_L1(scanner_L, 1, ptrsKeys_L1, KEY_COUNT_L1);
  59. // ---------------- RIGHT ROWS -----------------
  60. Key* ptrsKeys_R0[] = { &s_3, &o_capsLock };
  61. const uint8_t KEY_COUNT_R0 = sizeof(ptrsKeys_R0)/sizeof(*ptrsKeys_R0);
  62. Row row_R0(scanner_R, 1<<0, ptrsKeys_R0, KEY_COUNT_R0);
  63. Key* ptrsKeys_R1[] = { &s_c, &s_d };
  64. const uint8_t KEY_COUNT_R1 = sizeof(ptrsKeys_R1)/sizeof(*ptrsKeys_R1);
  65. Row row_R1(scanner_R, 1<<1, ptrsKeys_R1, KEY_COUNT_R1);
  66. // ################### MAIN ####################
  67. void setup()
  68. {
  69. Keyboard.begin();
  70. delay(7000);
  71. scanner_R.begin();
  72. }
  73. void loop()
  74. {
  75. //left matrix
  76. row_L0.process();
  77. row_L1.process();
  78. //right matrix
  79. row_R0.process();
  80. row_R1.process();
  81. scanDelay.delay();
  82. //debug.print_scans_per_second();
  83. //debug.print_microseconds_per_scan();
  84. }