logo

qmk_firmware

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

mini1800.c (1523B)


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