Misc files
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

pirms 5 gadiem
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #include <HID-Project.h>
  2. #include <HID-Settings.h>
  3. //number of keys
  4. const int keys = 12;
  5. //debounce milliseconds
  6. const int debounce = 5;
  7. //Switch Pins
  8. const byte k[12] = { 5, 6, 7, 8, 21, 20, 19, 18, 15, 14, 16, 10 };
  9. //Switch status
  10. boolean s[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
  11. //M for Media Key, K for Keyboard
  12. const char codetype[12] = { 'K', 'K', 'K', 'K', 'K', 'K', 'K', 'K', 'K', 'K', 'K', 'K' };
  13. //Keycodes
  14. const ConsumerKeycode ccode[keys] = { MEDIA_VOLUME_MUTE,
  15. MEDIA_VOLUME_MUTE,
  16. MEDIA_PLAY_PAUSE,
  17. MEDIA_PLAY_PAUSE,
  18. MEDIA_PLAY_PAUSE,
  19. MEDIA_PLAY_PAUSE,
  20. MEDIA_PLAY_PAUSE,
  21. MEDIA_PLAY_PAUSE,
  22. MEDIA_PLAY_PAUSE,
  23. MEDIA_PLAY_PAUSE,
  24. MEDIA_PLAY_PAUSE,
  25. MEDIA_PLAY_PAUSE
  26. };
  27. const KeyboardKeycode kcode[keys] = { KEY_F1,
  28. KEY_F2,
  29. KEY_F3,
  30. KEY_F4,
  31. KEY_F5,
  32. KEY_F6,
  33. KEY_F7,
  34. KEY_F8,
  35. KEY_F9,
  36. KEY_F10,
  37. KEY_F11,
  38. KEY_F12
  39. };
  40. void setup() {
  41. Keyboard.begin();
  42. Consumer.begin();
  43. //setup inputs, turn on pullups
  44. for (int i = 0; i < keys; i++) {
  45. pinMode(k[i], INPUT);
  46. digitalWrite(k[i], 1);
  47. }
  48. }
  49. void loop() {
  50. CheckKeys();
  51. delay(debounce);
  52. }
  53. void CheckKeys() {
  54. for (int i = 0; i < keys; i++) {
  55. if (codetype[i] == 'M') {
  56. if (digitalRead(k[i]) == 0) {
  57. if (s[i] == 0) {
  58. Consumer.press((ccode[i]));
  59. s[i] = 1;
  60. }
  61. }
  62. else {
  63. if (s[i] == 1) {
  64. s[i] = 0;
  65. Consumer.release((ccode[i]));
  66. }
  67. }
  68. }
  69. if (codetype[i] == 'K') {
  70. if (digitalRead(k[i]) == 0) {
  71. if (s[i] == 0) {
  72. Keyboard.press((kcode[i]));
  73. s[i] = 1;
  74. }
  75. }
  76. else {
  77. if (s[i] == 1) {
  78. s[i] = 0;
  79. Keyboard.release((kcode[i]));
  80. }
  81. }
  82. }
  83. }
  84. }