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.ino 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /* this works on Teensy LC 1*bb, active low and active high
  2. MCP23018 is not working, MCP23018::begin() hangs, details in setup()
  3. | Layout | **0** | **1** |
  4. |:------:|-------|-------|
  5. | **0** | a | b |
  6. | **1** | c | d |
  7. */
  8. // ################## GLOBAL ###################
  9. // ================= INCLUDES ==================
  10. #include <Debug.h>
  11. //LEDs
  12. #include <LED_PinNumber.h>
  13. #include "classes/Code_Sc_LED.h" //symlink: ln -s ../classes classes
  14. //IOE Ports
  15. #include "IOExpanderPort.h"
  16. #include <RowPort_MCP23018.h>
  17. #include <ColPort_MCP23018.h>
  18. //Codes
  19. #include <Code_Sc.h>
  20. //Matrix
  21. #include <Row_uC.h>
  22. #include <SPI.h>
  23. #include <Row_ShiftRegisters.h>
  24. // =============== CONFIGURATION ===============
  25. const unsigned int RowBase::DELAY_MICROSECONDS = 500;
  26. //activeLow has diode cathode (band) on row
  27. //activeHigh has diode cathode (band) on col, and pull down resistors on cols
  28. //0=active low, 1= active high
  29. const bool RowScanner_PinsArray::activeHigh = 0;
  30. Debug debug;
  31. // ================= LEFT PINS =================
  32. uint8_t readPins[] = {14, 15};
  33. uint8_t READ_PIN_COUNT = sizeof(readPins)/sizeof(*readPins);
  34. LED_PinNumber LED1(16); //Teensy LC pins 16, 17 are 20 mA
  35. // =================== CODES ===================
  36. Code_Sc s_a(KEY_A);
  37. Code_Sc s_b(KEY_B);
  38. Code_Sc s_c(KEY_C);
  39. Code_Sc_LED s_d(KEY_D, LED1);
  40. Code_Sc s_0(KEY_0);
  41. Code_Sc s_1(KEY_1);
  42. Code_Sc s_2(KEY_2);
  43. Code_Sc s_3(KEY_3);
  44. Code_Sc s_4(KEY_4);
  45. Code_Sc s_5(KEY_5);
  46. Code_Sc s_6(KEY_6);
  47. Code_Sc s_7(KEY_7);
  48. Code_Sc s_z(KEY_Z);
  49. // ================= LEFT ROWS =================
  50. Key* ptrsKeys_L0[] = { &s_a, &s_b };
  51. Row_uC row_L0(0, readPins, READ_PIN_COUNT, ptrsKeys_L0);
  52. Key* ptrsKeys_L1[] = { &s_c, &s_d };
  53. Row_uC row_L1(1, readPins, READ_PIN_COUNT, ptrsKeys_L1);
  54. // ================= RIGHT ROWS ================
  55. /*
  56. Key* ptrsKeys_R[] = { &s_0, &s_z, &s_z, &s_z,
  57. &s_4, &s_z, &s_z, &s_z,
  58. &s_8, &s_z, &s_z, &s_z }; //the s_z are place holders and should not print
  59. */
  60. Key* ptrsKeys_R[] = { &s_0, &s_1, &s_2, &s_3,
  61. &s_4, &s_5, &s_6, &s_7 }; //the most that 8-bit send() can handle
  62. const uint8_t KEY_COUNT = sizeof(ptrsKeys_R)/sizeof(*ptrsKeys_R);
  63. //Row_ShiftRegisters row_R(9, 2, ptrsKeys_R, KEY_COUNT);
  64. Row_ShiftRegisters row_R(9, 1, ptrsKeys_R, KEY_COUNT); // (SS, BYTE_COUNT,,)
  65. // ################### MAIN ####################
  66. void setup()
  67. {
  68. Keyboard.begin();
  69. SPI.begin();
  70. row_R.begin();
  71. //delay(1000); //time for OS to detect USB before printing
  72. Keyboard.print(F("activeState.ino "));
  73. debug.print_free_RAM();
  74. }
  75. //uint16_t next = 0;
  76. //elapsedMillis elapsed;
  77. void loop()
  78. {
  79. row_L0.process();
  80. row_L1.process();
  81. row_R.process();
  82. //row_R0.process();
  83. //row_R1.process();
  84. //delay(100);
  85. //Keyboard.println("");
  86. }