qmk_firmware

QMK firmware for my keyboards (Corne, Sweep Ferris) and trackball (Ploopy Adept)
Log | Files | Refs | Submodules | LICENSE

mini1800.c (1523B)


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