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_mapping_bb.ino 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /* keybrd_mapping_bb.ino
  2. Runs on DodoHand hardware or breadboard, using the left matrix, first two rows and columns.
  3. Uses the same variable naming convention as DH_2565.
  4. | Layout | **0** | **1** |
  5. |:------:|-------|-------|
  6. | **0** | a ! | b @ |
  7. | **1** | fn | shift |
  8. */
  9. // ################# GLOBAL ####################
  10. // ================ INCLUDES ===================
  11. //Arudino library files
  12. #include <Wire.h>
  13. //keybrd library files
  14. //#include <objects_scancode.h>
  15. #include <Code_Sc.h>
  16. #include <Code_ScS.h>
  17. #include <Code_Shift.h>
  18. #include <StateLayers.h>
  19. //#include <Code_LayerLock.h>
  20. #include <Code_LayerHold.h>
  21. #include <Key_LayeredKeysArray.h>
  22. #include <RowPort_AVR_Optic.h>
  23. #include <ColPort_AVR.h>
  24. #include <Row.h>
  25. #include <Matrix.h>
  26. #include <Debug.h>
  27. // ================= DEBUG =====================
  28. Debug debug;
  29. // =========== SPEED CONFUGURATIONS ============
  30. const unsigned int Row::DELAY_MICROSECONDS = 1000;
  31. // =============== LEFT PORTS ==================
  32. RowPort_AVR_Optic rowPortF_L(DDRF, PORTF);
  33. ColPort_AVR colPortB_L(DDRB, PORTB, PINB, 1<<0 | 1<<1 );
  34. ColPort* const ptrsColPorts_L[] = { &colPortB_L };
  35. const uint8_t COL_PORT_L_COUNT = sizeof(ptrsColPorts_L)/sizeof(*ptrsColPorts_L);
  36. // ================= CODES =====================
  37. // -------------- LAYER CODES ------------------
  38. StateLayers stateLayer;
  39. //Code_LayerLock l_alpha(0, stateLayer);
  40. Code_LayerHold l_fn(1, stateLayer);
  41. // --------------- SHIFT CODE ------------------
  42. Code_Shift s_shift(MODIFIERKEY_LEFT_SHIFT);
  43. Code_Shift *const ptrsShift[] = { &s_shift };
  44. Code_Shift *const *const Code_AutoShift::ptrsShifts = ptrsShift;
  45. const uint8_t Code_AutoShift::shiftCount = sizeof(ptrsShifts)/sizeof(*ptrsShifts);
  46. // --------------- SCAN CODES ------------------
  47. Code_Sc s_a(KEY_A);
  48. Code_Sc s_b(KEY_B);
  49. Code_ScS s_exclamation(KEY_1);
  50. Code_ScS s_at(KEY_2);
  51. StateLayersInterface& Key_LayeredKeysArray::refStateLayers = stateLayer;
  52. // ============== LEFT MATRIX ==================
  53. // --------------- LEFT KEYS -------------------
  54. Key* const ptrsCodes_L00[] = { &s_a, &s_exclamation };
  55. Key_LayeredKeysArray k_L00(ptrsCodes_L00);
  56. Key* const ptrsCodes_L01[] = { &s_b, &s_at };
  57. Key_LayeredKeysArray k_L01(ptrsCodes_L01);
  58. // -------------- LEFT MAPPING -----------------
  59. // the mapping layout array consumes no additional SRAM
  60. /*
  61. Key* const ptrsLayout[2][2] = { { &k_L00, &k_L01 },
  62. { &l_fn, &s_shift } };
  63. */
  64. Key* const ptrsLayout[2][2] = { { &k_L01, &k_L00 }, //swapped keys a-b
  65. { &l_fn, &s_shift } };
  66. // --------------- LEFT ROWS -------------------
  67. Key* const ptrsKeys_L0[] = { ptrsLayout[0][0], ptrsLayout[0][1] };
  68. Row row_L0(rowPortF_L, 1<<0, ptrsColPorts_L, COL_PORT_L_COUNT, ptrsKeys_L0);
  69. Key* const ptrsKeys_L1[] = { ptrsLayout[1][0], ptrsLayout[1][1] };
  70. Row row_L1(rowPortF_L, 1<<1, ptrsColPorts_L, COL_PORT_L_COUNT, ptrsKeys_L1);
  71. // -------------- LEFT MATRIX ------------------
  72. Row* const ptrsRows_L[] = { &row_L0, &row_L1 };
  73. const uint8_t ROW_L_COUNT = sizeof(ptrsRows_L)/sizeof(*ptrsRows_L);
  74. Matrix matrix_L(ptrsRows_L, ROW_L_COUNT, 1);
  75. // ################## MAIN #####################
  76. void setup()
  77. {
  78. Keyboard.begin();
  79. delay(1000); //time for OS to detect USB before printing
  80. Keyboard.print(F("keybrd_mapping_bb.ino, "));
  81. debug.print_free_RAM();
  82. }
  83. void loop()
  84. {
  85. matrix_L.scan();
  86. }