qmk_firmware

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

wt60_xt.c (2369B)


      1 /* Copyright 2020 Jason Williams (Wilba)
      2  *
      3  * This program is free software: you can redistribute it and/or modify
      4  * it under the terms of the GNU General Public License as published by
      5  * the Free Software Foundation, either version 2 of the License, or
      6  * (at your option) any later version.
      7  *
      8  * This program is distributed in the hope that it will be useful,
      9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     11  * GNU General Public License for more details.
     12  *
     13  * You should have received a copy of the GNU General Public License
     14  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
     15  */
     16 
     17 #include "quantum.h"
     18 
     19 #ifdef AUDIO_ENABLE
     20 #include "audio.h"
     21 #include "song_list.h"
     22 
     23 float tone_caps_on[][2]    = SONG(CAPS_LOCK_ON_SOUND);
     24 float tone_caps_off[][2]   = SONG(CAPS_LOCK_OFF_SOUND);
     25 float tone_numlk_on[][2]   = SONG(NUM_LOCK_ON_SOUND);
     26 float tone_numlk_off[][2]  = SONG(NUM_LOCK_OFF_SOUND);
     27 float tone_scroll_on[][2]  = SONG(SCROLL_LOCK_ON_SOUND);
     28 float tone_scroll_off[][2] = SONG(SCROLL_LOCK_OFF_SOUND);
     29 float tone_device_indication[][2] = SONG(FANTASIE_IMPROMPTU);
     30 
     31 #endif
     32 
     33 void keyboard_pre_init_kb(void) {
     34     gpio_set_pin_output(F1);
     35 
     36     keyboard_pre_init_user();
     37 }
     38 
     39 bool led_update_kb(led_t led_state) {
     40     if (led_update_user(led_state)) {
     41         gpio_write_pin(F1, led_state.caps_lock);
     42     }
     43 
     44 #ifdef AUDIO_ENABLE
     45     static led_t old_led_state = { .raw = 0 };
     46 
     47     wait_ms(10); // gets rid of tick
     48 
     49     if (led_state.caps_lock && !old_led_state.caps_lock)
     50     {
     51         PLAY_SONG(tone_caps_on);
     52     }
     53     else if (!led_state.caps_lock && old_led_state.caps_lock)
     54     {
     55         PLAY_SONG(tone_caps_off);
     56     }
     57     else if (led_state.num_lock && !old_led_state.num_lock)
     58     {
     59         PLAY_SONG(tone_numlk_on);
     60     }
     61     else if (!led_state.num_lock && old_led_state.num_lock)
     62     {
     63         PLAY_SONG(tone_numlk_off);
     64     }
     65     else if (led_state.scroll_lock && !old_led_state.scroll_lock)
     66     {
     67         PLAY_SONG(tone_scroll_on);
     68     }
     69     else if (!led_state.scroll_lock && old_led_state.scroll_lock)
     70     {
     71         PLAY_SONG(tone_scroll_off);
     72     }
     73 
     74     old_led_state = led_state;
     75 #endif // AUDIO_ENABLE
     76 
     77     return true;
     78 }
     79 
     80 void via_set_device_indication(uint8_t value) {
     81     if ( value == 0 ) {
     82         PLAY_SONG(tone_device_indication);
     83     }
     84 }