logo

qmk_firmware

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

lfk78.c (1395B)


  1. #include "lfk78.h"
  2. #include <avr/wdt.h>
  3. uint16_t click_hz = CLICK_HZ;
  4. uint16_t click_time = CLICK_MS;
  5. uint8_t click_toggle = CLICK_ENABLED;
  6. void matrix_init_kb(void) {
  7. matrix_init_user();
  8. #ifndef AUDIO_ENABLE
  9. // If we're not using the audio pin, drive it low
  10. gpio_set_pin_output(C6);
  11. gpio_write_pin_low(C6);
  12. #endif
  13. #ifdef WATCHDOG_ENABLE
  14. // This is done after turning the layer LED red, if we're caught in a loop
  15. // we should get a flashing red light
  16. wdt_enable(WDTO_500MS);
  17. #endif
  18. }
  19. void housekeeping_task_kb(void) {
  20. #ifdef WATCHDOG_ENABLE
  21. wdt_reset();
  22. #endif
  23. }
  24. void clicking_notes(uint16_t freq, uint16_t duration) {
  25. #ifdef AUDIO_ENABLE
  26. if (freq >= 100 && freq <= 20000 && duration < 100) {
  27. play_note(freq, 10);
  28. for (uint16_t i = 0; i < duration; i++) {
  29. _delay_ms(1);
  30. }
  31. stop_all_notes();
  32. }
  33. #endif
  34. }
  35. bool process_record_kb(uint16_t keycode, keyrecord_t* record) {
  36. if (click_toggle && record->event.pressed) {
  37. clicking_notes(click_hz, click_time);
  38. }
  39. return process_record_user(keycode, record);
  40. }
  41. bool shutdown_kb(bool jump_to_bootloader) {
  42. #ifdef WATCHDOG_ENABLE
  43. // Unconditionally run so shutdown_user can't mess up watchdog
  44. MCUSR = 0;
  45. wdt_disable();
  46. wdt_reset();
  47. #endif
  48. if (!shutdown_user(jump_to_bootloader)) {
  49. return false;
  50. }
  51. return true;
  52. }