keybrd library is an open source library for creating custom-keyboard firmware.
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

keybrd_AVR.ino 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /* this works on DH 4*bb, top-left buttons
  2. demo RowScanner_PinsBitwise
  3. | Left | **0** | **1** | | Right | **0** | **1** |
  4. |:-----:|-------|-------| |:-----:|-------|-------|
  5. | **0** | a | b | | **0** | 0 | 1 |
  6. | **1** | c | d | | **1** | 2 | 3 |
  7. */
  8. // ################## GLOBAL ###################
  9. // ================= INCLUDES ==================
  10. #include <Debug.h>
  11. //Ports
  12. #include <RowPort_AVR_Optic.h>
  13. #include <ColPort_AVR.h>
  14. //LEDs
  15. #include <LED_AVR.h>
  16. #include <LED_PCA9655E.h>
  17. #include "classes/Code_Sc_LED.h" //symlink: ln -s ../classes classes
  18. //Codes
  19. #include <Code_Sc.h>
  20. //Matrix
  21. #include <Row_IOE.h>
  22. #include <Matrix.h>
  23. // =============== CONFIGURATION ===============
  24. const unsigned int RowBase::DELAY_MICROSECONDS = 500;
  25. const bool RowScanner_PinsBitwise::activeHigh = 1;
  26. Debug debug;
  27. // ================ LEFT PORTS =================
  28. RowPort_AVR_Optic rowPort_L(DDRF, PORTF);
  29. ColPort_AVR colPort_L(DDRB, PORTB, PINB, 1<<0 | 1<<1 );
  30. //LED
  31. LED_AVR LED_L1(PORTB, 1<<6); //green
  32. // ================ RIGHT PORTS ================
  33. #include <IOExpanderPort.h>
  34. #include <RowPort_PCA9655E.h>
  35. #include <ColPort_PCA9655E.h>
  36. const uint8_t IOExpanderPort::ADDR = 0x18;
  37. //row port
  38. IOExpanderPort port1(1, 0);
  39. RowPort_PCA9655E rowPort_R(port1);
  40. //column and pin numbers on schematic_switch_matrix.png and schematic_pca9655_pin_assignments.png
  41. //col port
  42. IOExpanderPort port0(0, 0);
  43. ColPort_PCA9655E colPort_R(port0, 1<<0 | 1<<1 );
  44. //LED
  45. LED_PCA9655E LED_R1(port1, 1<<5); //blue
  46. // =================== CODES ===================
  47. Code_Sc s_a(KEY_A);
  48. Code_Sc s_b(KEY_B);
  49. Code_Sc s_c(KEY_C);
  50. //Code_Sc s_d(KEY_D);
  51. Code_Sc_LED s_d(KEY_D, LED_L1);
  52. Code_Sc s_0(KEY_0);
  53. Code_Sc s_1(KEY_1);
  54. Code_Sc s_2(KEY_2);
  55. //Code_Sc s_3(KEY_3);
  56. Code_Sc_LED s_3(KEY_3, LED_R1);
  57. // ================= LEFT ROWS =================
  58. Key* const ptrsKeys_L0[] = { &s_a, &s_b };
  59. Row_IOE row_L0(rowPort_L, 1<<0, colPort_L, ptrsKeys_L0); //strobe F0
  60. Key* const ptrsKeys_L1[] = { &s_c, &s_d };
  61. Row_IOE row_L1(rowPort_L, 1<<1, colPort_L, ptrsKeys_L1); //strobe F1
  62. // ================= RIGHT ROWS ================
  63. Key* ptrsKeys_R0[] = { &s_0, &s_1 };
  64. Row_IOE row_R0(rowPort_R, 1<<0, colPort_R, ptrsKeys_R0);
  65. Key* ptrsKeys_R1[] = { &s_2, &s_3 };
  66. Row_IOE row_R1(rowPort_R, 1<<1, colPort_R, ptrsKeys_R1);
  67. // ################### MAIN ####################
  68. void setup()
  69. {
  70. Keyboard.begin();
  71. Wire.begin();
  72. delay(1000); //time for OS to detect USB before printing
  73. Keyboard.print(F("activeState_AVR.ino "));
  74. debug.print_free_RAM();
  75. rowPort_R.begin();
  76. colPort_R.begin();
  77. }
  78. void loop()
  79. {
  80. row_L0.process();
  81. row_L1.process();
  82. row_R0.process();
  83. row_R1.process();
  84. //delay(500);
  85. //Keyboard.println(F(""));
  86. }