logo

qmk_firmware

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

lfk87.c (1477B)


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