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_7a_mapping_single-layer.ino 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* keybrd_7a_mapping_single-layer.ino
  2. This sketch:
  3. is modified from keybrd_2_single.ino by swaping readPins numbers with Row-pin numbers
  4. runs on basic breadboard keyboard modified by flipping diodes, anodes towards rows (blue bus)
  5. demonstrates mapping from LAYOUT to MATRIX on a single-layer keyboard
  6. | Layout | **0** | **1** |
  7. |:------:|-------|-------|
  8. | **0** | 1 | 2 |
  9. | **1** | a | b |
  10. */
  11. // ################## GLOBAL ###################
  12. // ================= INCLUDES ==================
  13. #include <Code_Sc.h>
  14. #include <Row.h>
  15. #include <Scanner_uC.h>
  16. #include <ScanDelay.h>
  17. // ============ SPEED CONFIGURATION ============
  18. ScanDelay scanDelay(9000);
  19. // ================== SCANNER ==================
  20. uint8_t readPins[] = {0, 1};
  21. uint8_t readPinCount = sizeof(readPins)/sizeof(*readPins);
  22. Scanner_uC scanner(LOW, readPins, readPinCount);
  23. // =================== CODES ===================
  24. Code_Sc s_a(KEY_A);
  25. Code_Sc s_b(KEY_B);
  26. Code_Sc s_1(KEY_1);
  27. Code_Sc s_2(KEY_2);
  28. /* ================== LAYOUT ===================
  29. Keyboard layout is the placement of keys.
  30. */
  31. Key* const ptrsLayout[2][2] = { //[row][col]
  32. //col0 col1
  33. { &s_1, &s_2 }, //row0
  34. { &s_a, &s_b } //row1
  35. };
  36. /* ================== MATRIX ===================
  37. // --------------- KEY MAPPINGS ----------------
  38. ptrsLayout[row][col] coordinates correspond to the elements in the layout.
  39. The Keys are transposed (layout rows are placed in matrix columns).
  40. */
  41. Key* ptrsKeys_0[] = { ptrsLayout[0][0], ptrsLayout[1][0] };
  42. uint8_t keyCount_0 = sizeof(ptrsKeys_0)/sizeof(*ptrsKeys_0);
  43. Row row_0(scanner, 14, ptrsKeys_0, keyCount_0);
  44. Key* ptrsKeys_1[] = { ptrsLayout[0][1], ptrsLayout[1][1] };
  45. uint8_t keyCount_1 = sizeof(ptrsKeys_1)/sizeof(*ptrsKeys_1);
  46. Row row_1(scanner, 15, ptrsKeys_1, keyCount_1);
  47. // ################### MAIN ####################
  48. void setup()
  49. {
  50. }
  51. void loop()
  52. {
  53. row_0.process();
  54. row_1.process();
  55. scanDelay.delay();
  56. }