logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

micro.c (3834B)


  1. // Copyright 2022 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #include "micro.h"
  4. #if defined(RGB_MATRIX_ENABLE)
  5. // clang-format off
  6. led_config_t g_led_config = { {
  7. { NO_LED, 10, 11, NO_LED },
  8. { 9 , 8, 7, 6 },
  9. { 2, 3, 4, 5 },
  10. { NO_LED, 1, 0, NO_LED }
  11. }, {
  12. { 122, 64 }, { 103, 64 },
  13. { 84, 45 }, { 103, 45 }, { 133, 45 }, { 152, 45 },
  14. { 152, 26 }, { 122, 26 }, { 103, 26 }, { 84, 26 },
  15. { 103, 7 }, { 122, 7 }
  16. },
  17. {
  18. 4, 4,
  19. 4, 4, 4, 4,
  20. 4, 4, 4, 4,
  21. 4, 4
  22. }
  23. };
  24. // clang-format on
  25. #endif
  26. #if defined(ENCODER_ENABLE)
  27. bool encoder_update_kb(uint8_t index, bool clockwise) {
  28. if (!encoder_update_user(index, clockwise)) {
  29. return false;
  30. }
  31. if (index == 0) {
  32. if (clockwise) {
  33. tap_code_delay(KC_VOLU, 10);
  34. } else {
  35. tap_code_delay(KC_VOLD, 10);
  36. }
  37. } else if (index == 1) {
  38. if (clockwise) {
  39. tap_code_delay(KC_WH_U, 10);
  40. } else {
  41. tap_code_delay(KC_WH_D, 10);
  42. }
  43. }
  44. return true;
  45. }
  46. #endif
  47. void work_louder_micro_led_1_on(void) {
  48. gpio_set_pin_output(WORK_LOUDER_LED_PIN_1);
  49. gpio_write_pin(WORK_LOUDER_LED_PIN_1, true);
  50. }
  51. void work_louder_micro_led_2_on(void) {
  52. gpio_set_pin_output(WORK_LOUDER_LED_PIN_2);
  53. gpio_write_pin(WORK_LOUDER_LED_PIN_2, true);
  54. }
  55. void work_louder_micro_led_3_on(void) {
  56. gpio_set_pin_output(WORK_LOUDER_LED_PIN_3);
  57. gpio_write_pin(WORK_LOUDER_LED_PIN_3, true);
  58. }
  59. void work_louder_micro_led_1_off(void) {
  60. gpio_set_pin_input(WORK_LOUDER_LED_PIN_1);
  61. gpio_write_pin(WORK_LOUDER_LED_PIN_1, false);
  62. }
  63. void work_louder_micro_led_2_off(void) {
  64. gpio_set_pin_input(WORK_LOUDER_LED_PIN_2);
  65. gpio_write_pin(WORK_LOUDER_LED_PIN_2, false);
  66. }
  67. void work_louder_micro_led_3_off(void) {
  68. gpio_set_pin_input(WORK_LOUDER_LED_PIN_3);
  69. gpio_write_pin(WORK_LOUDER_LED_PIN_3, false);
  70. }
  71. void work_louder_micro_led_all_on(void) {
  72. work_louder_micro_led_1_on();
  73. work_louder_micro_led_2_on();
  74. work_louder_micro_led_3_on();
  75. }
  76. void work_louder_micro_led_all_off(void) {
  77. work_louder_micro_led_1_off();
  78. work_louder_micro_led_2_off();
  79. work_louder_micro_led_3_off();
  80. }
  81. void work_louder_micro_led_1_set(uint8_t n) {
  82. #if WORK_LOUDER_LED_PIN_1 == B6
  83. OCR1B = n;
  84. #else
  85. n ? work_louder_micro_led_1_on() : work_louder_micro_led_1_off();
  86. #endif
  87. }
  88. void work_louder_micro_led_2_set(uint8_t n) {
  89. #if WORK_LOUDER_LED_PIN_2 == B7
  90. OCR1C = n;
  91. #else
  92. n ? work_louder_micro_led_2_on() : work_louder_micro_led_2_off();
  93. #endif
  94. }
  95. void work_louder_micro_led_3_set(uint8_t n) {
  96. #if WORK_LOUDER_LED_PIN_3 == B5
  97. OCR1A = n;
  98. #else
  99. n ? work_louder_micro_led_3_on() : work_louder_micro_led_3_off();
  100. #endif
  101. }
  102. void work_louder_micro_led_all_set(uint8_t n) {
  103. work_louder_micro_led_1_set(n);
  104. work_louder_micro_led_2_set(n);
  105. work_louder_micro_led_3_set(n);
  106. }
  107. void keyboard_post_init_kb(void) {
  108. TCCR1A = 0b10101001; // set and configure fast PWM
  109. TCCR1B = 0b00001001; // set and configure fast PWM
  110. keyboard_post_init_user();
  111. }
  112. void work_louder_led_init_animation(void) {
  113. work_louder_micro_led_all_off();
  114. wait_ms(500);
  115. work_louder_micro_led_1_on();
  116. wait_ms(100);
  117. work_louder_micro_led_2_on();
  118. wait_ms(100);
  119. work_louder_micro_led_3_on();
  120. wait_ms(100);
  121. work_louder_micro_led_1_off();
  122. wait_ms(100);
  123. work_louder_micro_led_2_off();
  124. wait_ms(100);
  125. work_louder_micro_led_3_off();
  126. wait_ms(200);
  127. }
  128. void suspend_power_down_kb(void) {
  129. suspend_power_down_user();
  130. work_louder_micro_led_all_off();
  131. }
  132. void suspend_wakeup_init_kb(void) {
  133. work_louder_led_init_animation();
  134. suspend_wakeup_init_user();
  135. }