Example #1
0
void setLayer(int layer) {
    if (layer == _COLEMAK) {
        #ifdef AUDIO_ENABLE
            stop_all_notes();
            PLAY_SONG(marioe);
        #endif
        set_single_persistent_default_layer(_COLEMAK);
        #ifdef BACKLIGHT_ENABLE
            backlight_set(0);
        #endif
    } else if (layer == _GAME) {
        #ifdef AUDIO_ENABLE
            stop_all_notes();
            PLAY_SONG(mario);
        #endif
        set_single_persistent_default_layer(_GAME);
        #ifdef BACKLIGHT_ENABLE
            backlight_set(15);
        #endif
    } else if (layer == _MUSIC) {
        #ifdef AUDIO_ENABLE
            stop_all_notes();
            PLAY_SONG(guitar);
        #endif
        set_single_persistent_default_layer(_MUSIC);
        #ifdef BACKLIGHT_ENABLE
            backlight_set(1);
        #endif
    }
}
Example #2
0
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
    switch (keycode) {
        case S_BSKTC:
            if (record->event.pressed) {
                stop_all_notes();
                PLAY_SONG(song_basketcase);
            }
            return false;
        case S_ODEJY:
            if (record->event.pressed) {
                stop_all_notes();
                PLAY_SONG(song_ode_to_joy);
            }
            return false;
        case S_RCKBY:
            if (record->event.pressed) {
                stop_all_notes();
                PLAY_SONG(song_rock_a_bye_baby);
            }
            return false;
        case S_DOEDR:
            if (record->event.pressed) {
                stop_all_notes();
                PLAY_SONG(song_doe_a_deer);
            }
            return false;
        case S_SCALE:
            if (record->event.pressed) {
                stop_all_notes();
                PLAY_SONG(song_scale);
            }
            return false;
        case S_ONEUP:
            if (record->event.pressed) {
                stop_all_notes();
                PLAY_SONG(song_one_up);
            }
            return false;
        case S_COIN:
            if (record->event.pressed) {
                stop_all_notes();
                PLAY_SONG(song_coin);
            }
            return false;
        case S_SONIC:
            if (record->event.pressed) {
                stop_all_notes();
                PLAY_SONG(song_sonic_ring);
            }
            return false;
        case S_ZELDA:
            if (record->event.pressed) {
                stop_all_notes();
                PLAY_SONG(song_zelda_puzzle);
            }
            return false;
    }
    return true;
}
Example #3
0
void shutdown_user() {
#ifdef AUDIO_ENABLE
  PLAY_SONG(tone_goodbye);
  _delay_ms(150);
  stop_all_notes();
#endif
}
Example #4
0
void shutdown_user(void) {
    #ifdef AUDIO_ENABLE
        PLAY_NOTE_ARRAY(tone_goodbye, false, 0);
	_delay_ms(150);
	stop_all_notes();
    #endif
}
Example #5
0
void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat, float n_rest)
{

    if (!audio_initialized) {
        audio_init();
    }

	if (audio_config.enable) {

	    DISABLE_AUDIO_COUNTER_3_ISR;

		// Cancel note if a note is playing
	    if (playing_note)
	        stop_all_notes();

	    playing_notes = true;

	    notes_pointer = np;
	    notes_count = n_count;
	    notes_repeat = n_repeat;
	    notes_rest = n_rest;

	    place = 0;
	    current_note = 0;

        note_frequency = (*notes_pointer)[current_note][0];
        note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100);
	    note_position = 0;


        ENABLE_AUDIO_COUNTER_3_ISR;
        ENABLE_AUDIO_COUNTER_3_OUTPUT;
	}

}
Example #6
0
void play_note(float freq, int vol) {

    if (!audio_initialized) {
        audio_init();
    }

	if (audio_config.enable && voices < 8) {
	    DISABLE_AUDIO_COUNTER_3_ISR;

	    // Cancel notes if notes are playing
	    if (playing_notes)
	        stop_all_notes();

	    playing_note = true;

	    envelope_index = 0;

	    if (freq > 0) {
	        frequencies[voices] = freq;
	        volumes[voices] = vol;
	        voices++;
	    }

        ENABLE_AUDIO_COUNTER_3_ISR;
        ENABLE_AUDIO_COUNTER_3_OUTPUT;
	}

}
Example #7
0
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  switch (keycode) {
    case LOWER:
      if (record->event.pressed) {
        layer_on(_LOWER);
        update_tri_layer(_LOWER, _RAISE, _ADJUST);
      } else {
        layer_off(_LOWER);
        update_tri_layer(_LOWER, _RAISE, _ADJUST);
      }
      return false;
      break;
    case RAISE:
      if (record->event.pressed) {
        layer_on(_RAISE);
        update_tri_layer(_LOWER, _RAISE, _ADJUST);
      } else {
        layer_off(_RAISE);
        update_tri_layer(_LOWER, _RAISE, _ADJUST);
      }
      return false;
      break;
    case FUNC:
      if (record->event.pressed) {
        layer_on(_FUNC);
      } else {
        layer_off(_FUNC);
      }
      return false;
      break;
    case PLOVER:
      if (!record->event.pressed) {
        #ifdef AUDIO_ENABLE
          stop_all_notes();
          PLAY_SONG(plover_song);
        #endif
        layer_on(_PLOVER);
      }
      return false;
      break;
    case EXT_PLV:
      if (record->event.pressed) {
        #ifdef AUDIO_ENABLE
          PLAY_SONG(plover_gb_song);
        #endif
        layer_off(_PLOVER);
      }
      return false;
      break;
    case MOUSE:
      if (record->event.pressed) {
        layer_on(_MOUSE);
      } else {
        layer_off(_MOUSE);
      }
      return false;
      break;
  }
  return true;
}
Example #8
0
void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat) {

  if (!audio_initialized) {
    audio_init();
  }

  if (audio_config.enable) {

    // Cancel note if a note is playing
    if (playing_note) {
      stop_all_notes();
    }

    playing_notes = true;

    notes_pointer = np;
    notes_count = n_count;
    notes_repeat = n_repeat;

    place = 0;
    current_note = 0;

    note_frequency = (*notes_pointer)[current_note][0];
    note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100);
    note_position = 0;

    gptStart(&GPTD8, &gpt8cfg1);
    gptStartContinuous(&GPTD8, 2U);
    RESTART_CHANNEL_1();
    RESTART_CHANNEL_2();
  }
}
Example #9
0
void play_note(float freq, int vol) {

  dprintf("audio play note freq=%d vol=%d", (int)freq, vol);

  if (!audio_initialized) {
      audio_init();
  }

  if (audio_config.enable && voices < 8) {

     // Cancel notes if notes are playing
    if (playing_notes) {
      stop_all_notes();
    }

    playing_note = true;

    envelope_index = 0;

    if (freq > 0) {
      frequencies[voices] = freq;
      volumes[voices] = vol;
      voices++;
    }

    gptStart(&GPTD8, &gpt8cfg1);
    gptStartContinuous(&GPTD8, 2U);
    RESTART_CHANNEL_1();
    RESTART_CHANNEL_2();
  }

}
Example #10
0
void dip_update(uint8_t index, bool active) {
  switch (index) {
    case 0:
      if (active) {
        #ifdef AUDIO_ENABLE
          PLAY_SONG(plover_song);
        #endif
        layer_on(_ADJUST);
      } else {
        #ifdef AUDIO_ENABLE
          PLAY_SONG(plover_gb_song);
        #endif
        layer_off(_ADJUST);
      }
      break;
    case 1:
      if (active) {
        muse_mode = true;
      } else {
        muse_mode = false;
        #ifdef AUDIO_ENABLE
          stop_all_notes();
        #endif
      }
      break;
    case 3:
      if (active) {
        clicky_on();
      } else {
        clicky_off();
      }
   }
}
Example #11
0
void reset_keyboard(void) {
  clear_keyboard();
#if defined(MIDI_ENABLE) && defined(MIDI_BASIC)
  process_midi_all_notes_off();
#endif
#ifdef AUDIO_ENABLE
  #ifndef NO_MUSIC_MODE
    music_all_notes_off();
  #endif
  uint16_t timer_start = timer_read();
  PLAY_SONG(goodbye_song);
  shutdown_user();
  while(timer_elapsed(timer_start) < 250)
    wait_ms(1);
  stop_all_notes();
#else
  shutdown_user();
  wait_ms(250);
#endif
// this is also done later in bootloader.c - not sure if it's neccesary here
#ifdef BOOTLOADER_CATERINA
  *(uint16_t *)0x0800 = 0x7777; // these two are a-star-specific
#endif
  bootloader_jump();
}
Example #12
0
void audio_off(void) {
    PLAY_SONG(audio_off_song);
    wait_ms(100);
    stop_all_notes();
    audio_config.enable = 0;
    eeconfig_update_audio(audio_config.raw);
}
Example #13
0
void set_qwerty(void) {
#ifdef AUDIO_ENABLE
    stop_all_notes();
    PLAY_SONG(qwerty_song);
#endif
    set_single_persistent_default_layer(_QWERTY);
}
Example #14
0
void set_colemak(void) {
#ifdef AUDIO_ENABLE
    stop_all_notes();
    PLAY_SONG(colemak_song);
#endif
    set_single_persistent_default_layer(_COLEMAK);
}
Example #15
0
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  switch (keycode) {
    case DVORAK:
      if (record->event.pressed) {
        set_single_persistent_default_layer(_DVORAK);
      }
      return false;
      break;
    case BACKLIT:
      if (record->event.pressed) {
        register_code(KC_RSFT);
        #ifdef BACKLIGHT_ENABLE
          backlight_step();
        #endif
        #ifdef KEYBOARD_planck_rev5
          PORTE &= ~(1<<6);
        #endif
      } else {
        unregister_code(KC_RSFT);
        #ifdef KEYBOARD_planck_rev5
          PORTE |= (1<<6);
        #endif
      }
      return false;
      break;
    case PLOVER:
      if (record->event.pressed) {
        #ifdef AUDIO_ENABLE
          stop_all_notes();
          PLAY_SONG(plover_song);
        #endif
        layer_off(_CUSTOM);
        layer_off(_RAISE);
        layer_off(_LOWER);
        layer_off(_ADJUST);
        layer_on(_PLOVER);
        if (!eeconfig_is_enabled()) {
            eeconfig_init();
        }
        keymap_config.raw = eeconfig_read_keymap();
        keymap_config.nkro = 1;
        eeconfig_update_keymap(keymap_config.raw);
      }
      return false;
      break;
    case EXT_PLV:
      if (record->event.pressed) {
        #ifdef AUDIO_ENABLE
          PLAY_SONG(plover_gb_song);
        #endif
        layer_off(_PLOVER);
      }
      return false;
      break;
  }
  return true;
}
Example #16
0
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  switch (keycode) {
    case QWERTY:
      if (record->event.pressed) {
        print("mode just switched to qwerty and this is a huge string\n");
        set_single_persistent_default_layer(_QWERTY);
      }
      return false; break;
    case LOWER:
      if (record->event.pressed) {
        layer_on(_LOWER);
        update_tri_layer(_LOWER, _RAISE, _ADJUST);
      } else {
        layer_off(_LOWER);
        update_tri_layer(_LOWER, _RAISE, _ADJUST);
      }
      return false; break;
    case RAISE:
      if (record->event.pressed) {
        layer_on(_RAISE);
        update_tri_layer(_LOWER, _RAISE, _ADJUST);
      } else {
        layer_off(_RAISE);
        update_tri_layer(_LOWER, _RAISE, _ADJUST);
      }
      return false; break;
    case PLOVER:
      if (record->event.pressed) {
        #ifdef AUDIO_ENABLE
          stop_all_notes();
          PLAY_SONG(plover_song);
        #endif
        layer_off(_RAISE);
        layer_off(_LOWER);
        layer_off(_ADJUST);
        layer_on(_PLOVER);
        if (!eeconfig_is_enabled()) {
            eeconfig_init();
        }
        keymap_config.raw = eeconfig_read_keymap();
        keymap_config.nkro = 1;
        eeconfig_update_keymap(keymap_config.raw);
      }
      return false; break;
    case EXT_PLV:
      if (record->event.pressed) {
        #ifdef AUDIO_ENABLE
          PLAY_SONG(plover_gb_song);
        #endif
        layer_off(_PLOVER);
      }
      return false; break;
  }
  return true;
}
Example #17
0
void click(uint16_t freq, uint16_t duration){
#ifdef AUDIO_ENABLE
    if(freq >= 100 && freq <= 20000 && duration < 100){
        play_note(freq, 10);
        for (uint16_t i = 0; i < duration; i++){
            _delay_ms(1);
        }
        stop_all_notes();
    }
#endif
}
Example #18
0
void reset_keyboard(void) {
  clear_keyboard();
#ifdef AUDIO_ENABLE
  stop_all_notes();
  shutdown_user();
#endif
  wait_ms(250);
#ifdef CATERINA_BOOTLOADER
  *(uint16_t *)0x0800 = 0x7777; // these two are a-star-specific
#endif
  bootloader_jump();
}
Example #19
0
void audio_init() {

  if (audio_initialized) {
    return;
  }

  // Check EEPROM
  #if defined(STM32_EEPROM_ENABLE) || defined(PROTOCOL_ARM_ATSAM) || defined(EEPROM_SIZE)
    if (!eeconfig_is_enabled()) {
      eeconfig_init();
    }
    audio_config.raw = eeconfig_read_audio();
#else // ARM EEPROM
    audio_config.enable = true;
  #ifdef AUDIO_CLICKY_ON
    audio_config.clicky_enable = true;
  #endif
#endif // ARM EEPROM

  /*
   * Starting DAC1 driver, setting up the output pin as analog as suggested
   * by the Reference Manual.
   */
  palSetPadMode(GPIOA, 4, PAL_MODE_INPUT_ANALOG);
  palSetPadMode(GPIOA, 5, PAL_MODE_INPUT_ANALOG);
  dacStart(&DACD1, &dac1cfg1);
  dacStart(&DACD2, &dac1cfg2);

  /*
   * Starting GPT6/7 driver, it is used for triggering the DAC.
   */
  START_CHANNEL_1();
  START_CHANNEL_2();

  /*
   * Starting a continuous conversion.
   */
  dacStartConversion(&DACD1, &dacgrpcfg1, (dacsample_t *)dac_buffer, DAC_BUFFER_SIZE);
  dacStartConversion(&DACD2, &dacgrpcfg2, (dacsample_t *)dac_buffer_2, DAC_BUFFER_SIZE);

  audio_initialized = true;

  if (audio_config.enable) {
    PLAY_SONG(startup_song);
  } else {
    stop_all_notes();
  }

}
Example #20
0
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  switch (keycode) {
    case STENO:
      if (record->event.pressed) {
#ifdef AUDIO_ENABLE
        stop_all_notes();
        PLAY_SONG(plover_song);
#endif
        layer_off(RAISE_LAYER);
        layer_off(LOWER_LAYER);
        layer_off(ADJUST_LAYER);
        layer_on(STENO_LAYER);
        if (!eeconfig_is_enabled()) {
          eeconfig_init();
        }
        keymap_config.raw = eeconfig_read_keymap();
        keymap_config.nkro = 1;
        eeconfig_update_keymap(keymap_config.raw);
        plover_resume();
      }
      return false;
    case PV_EXIT:
      if (record->event.pressed) {
#ifdef AUDIO_ENABLE
        PLAY_SONG(plover_gb_song);
#endif
        plover_suspend();
        layer_off(STENO_LAYER);
      }
      return false;
    case PV_LOOK:
      if (record->event.pressed) {
        plover_lookup();
      }
      return false;
    case SEND_VERSION:
      if (record->event.pressed) {
        SEND_STRING(QMK_KEYBOARD "/" QMK_KEYMAP "@" QMK_VERSION " (" QMK_BUILDDATE ")");
      }
      return false;
    case SEND_MAKE:
      if (record->event.pressed) {
        SEND_STRING("make " QMK_KEYBOARD ":" QMK_KEYMAP ":dfu\n");
      }
      return false;
  }
  return true;
}
Example #21
0
void play_note(float freq, int vol) {

    dprintf("audio play note freq=%d vol=%d", (int)freq, vol);

    if (!audio_initialized) {
        audio_init();
    }

    if (audio_config.enable && voices < 8) {
        #ifdef CPIN_AUDIO
            DISABLE_AUDIO_COUNTER_3_ISR;
        #endif
        #ifdef BPIN_AUDIO
            DISABLE_AUDIO_COUNTER_1_ISR;
        #endif

        // Cancel notes if notes are playing
        if (playing_notes)
            stop_all_notes();

        playing_note = true;

        envelope_index = 0;

        if (freq > 0) {
            frequencies[voices] = freq;
            volumes[voices] = vol;
            voices++;
        }

        #ifdef CPIN_AUDIO
            ENABLE_AUDIO_COUNTER_3_ISR;
            ENABLE_AUDIO_COUNTER_3_OUTPUT;
        #endif
        #ifdef BPIN_AUDIO
            #ifdef CPIN_AUDIO
            if (voices > 1) {
                ENABLE_AUDIO_COUNTER_1_ISR;
                ENABLE_AUDIO_COUNTER_1_OUTPUT;
            }
            #else
            ENABLE_AUDIO_COUNTER_1_ISR;
            ENABLE_AUDIO_COUNTER_1_OUTPUT;
            #endif
        #endif
    }

}
Example #22
0
void reset_keyboard(void) {
  clear_keyboard();
#if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_ENABLE_BASIC))
  music_all_notes_off();
  uint16_t timer_start = timer_read();
  PLAY_SONG(goodbye_song);
  shutdown_user();
  while(timer_elapsed(timer_start) < 250) 
    wait_ms(1);
  stop_all_notes();
#else
  wait_ms(250);
#endif
#ifdef CATERINA_BOOTLOADER
  *(uint16_t *)0x0800 = 0x7777; // these two are a-star-specific
#endif
  bootloader_jump();
}
Example #23
0
void CAD_finished (qk_tap_dance_state_t *state, void *user_data) {
  CADtap_state.state = cur_dance(state);
  switch (CADtap_state.state) {
    case SINGLE_TAP:
		//register_code(KC_SPC);
		SEND_STRING(SS_LGUI("l"));
		#ifdef BACKLIGHT_ENABLE
    backlight_level(3);
		#endif
		break;
    case SINGLE_HOLD:
		//register_code(KC_NO);
		//take a screenshot of a single window, open Paint and paste
		SEND_STRING(SS_LALT(SS_TAP(X_PSCREEN)) SS_LGUI("r"));
        _delay_ms(500);
        SEND_STRING("mspaint" SS_TAP(X_ENTER));
        _delay_ms(700);
        SEND_STRING(SS_LCTRL("v"));
		break; //register this keycode when button is held
    case DOUBLE_TAP:
		//register_code(KC_ENT);
		SEND_STRING(SS_LCTRL(SS_LALT(SS_TAP(X_DELETE))));
		#ifdef BACKLIGHT_ENABLE
    backlight_level(0);
		#endif
		break;
    //case DOUBLE_HOLD: register_code(KC_NO); break; //register this keycode when button is tapped and then held
	case DOUBLE_HOLD:
		reset_keyboard();
		break; //register this keycode when button is tapped and then held
	case TRIPLE_TAP:
		SEND_STRING("*****@*****.**");
		break;
	case TRIPLE_HOLD:
  set_single_persistent_default_layer(1);
  #ifdef AUDIO_ENABLE
    stop_all_notes();
    PLAY_SONG(lyrup_song);
  #endif
  break;
  }
}
Example #24
0
void dip_update(uint8_t index, bool active) {
  switch (index) {
    case 0:
      if (active) {
        layer_on(_ADJUST);
      } else {
        layer_off(_ADJUST);
      }
      break;
    case 1:
      if (active) {
        muse_mode = true;
      } else {
        muse_mode = false;
        #ifdef AUDIO_ENABLE
          stop_all_notes();
        #endif
      }
   }
}
Example #25
0
void BSW_finished (qk_tap_dance_state_t *state, void *user_data) {
  BSWtap_state.state = cur_dance(state);
  switch (BSWtap_state.state) {
    case SINGLE_TAP: register_code(KC_ENTER); break;
    case SINGLE_HOLD:
      set_single_persistent_default_layer(0);
      #ifdef AUDIO_ENABLE
        stop_all_notes();
        PLAY_SONG(lyrdown_song);
      #endif
      break;
    case DOUBLE_TAP:
	  register_code(KC_LCTRL);
      register_code(KC_C);
	  break;
	case DOUBLE_HOLD:
	  reset_keyboard();
	  break; //register this keycode when button is tapped and then held
  }
}
Example #26
0
void shutdown_user()
{cc
    PLAY_SONG(tone_goodbye);
    _delay_ms(150);
    stop_all_notes();
}
Example #27
0
void shutdown_user()
{
    PLAY_NOTE_ARRAY(tone_goodbye, false, 0);
    _delay_ms(150);
    stop_all_notes();
}
Example #28
0
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  switch (keycode) {
        case QWERTY:
          if (record->event.pressed) {
            #ifdef AUDIO_ENABLE
              PLAY_NOTE_ARRAY(tone_qwerty, false, 0);
            #endif
            persistent_default_layer_set(1UL<<_QWERTY);
          }
          break;
      return false;
        case COLEMAK:
          if (record->event.pressed) {
            #ifdef AUDIO_ENABLE
              PLAY_NOTE_ARRAY(tone_colemak, false, 0);
            #endif
            persistent_default_layer_set(1UL<<_COLEMAK);
          }
          break;
      return false;
        case DVORAK:
          if (record->event.pressed) {
            #ifdef AUDIO_ENABLE
              PLAY_NOTE_ARRAY(tone_dvorak, false, 0);
            #endif
            persistent_default_layer_set(1UL<<_DVORAK);
          }
          break;
      return false;
        case LOWER:
          if (record->event.pressed) {
            layer_on(_LOWER);
            #ifdef BACKLIGHT_ENABLE
                breathing_speed_set(2);
                breathing_pulse();
            #endif
            update_tri_layer(_LOWER, _RAISE, _ADJUST);
          } else {
            layer_off(_LOWER);
            update_tri_layer(_LOWER, _RAISE, _ADJUST);
          }
          break;
      return false;
        case RAISE:
          if (record->event.pressed) {
            layer_on(_RAISE);
            #ifdef BACKLIGHT_ENABLE
                breathing_speed_set(2);
                breathing_pulse();
            #endif
            update_tri_layer(_LOWER, _RAISE, _ADJUST);
          } else {
            layer_off(_RAISE);
            update_tri_layer(_LOWER, _RAISE, _ADJUST);
          }
          break;
      return false;
        case BACKLIT:
          if (record->event.pressed) {
            register_code(KC_RSFT);
            #ifdef BACKLIGHT_ENABLE
              backlight_step();
            #endif
          } else {
            unregister_code(KC_RSFT);
          }
        break;
      return false;
        case PLOVER:
          if (record->event.pressed) {
            #ifdef AUDIO_ENABLE
              stop_all_notes();
              PLAY_NOTE_ARRAY(tone_plover, false, 0);
            #endif
            layer_off(_RAISE);
            layer_off(_LOWER);
            layer_off(_ADJUST);
            layer_on(_PLOVER);
            if (!eeconfig_is_enabled()) {
                eeconfig_init();
            }
            keymap_config.raw = eeconfig_read_keymap();
            keymap_config.nkro = 1;
            eeconfig_update_keymap(keymap_config.raw);
          }
        break;
      return false;
        case EXT_PLV:
          if (record->event.pressed) {
            #ifdef AUDIO_ENABLE
              PLAY_NOTE_ARRAY(tone_plover_gb, false, 0);
            #endif
            layer_off(_PLOVER);
          }
        break;
      return false;

    case RGBLED_TOGGLE:
      //led operations
      if (record->event.pressed) {
        rgblight_toggle();
      }
      return false;
      break;
    case RGBLED_INCREASE_HUE:
      if (record->event.pressed) {
        rgblight_increase_hue();
      }
      return false;
      break;
    case RGBLED_DECREASE_HUE:
      if (record->event.pressed) {
        rgblight_decrease_hue();
      }
      return false;
      break;
    case RGBLED_INCREASE_SAT:
      if (record->event.pressed) {
        rgblight_increase_sat();
      }
      return false;
      break;
    case RGBLED_DECREASE_SAT:
      if (record->event.pressed) {
        rgblight_decrease_sat();
      }
      return false;
      break;
    case RGBLED_INCREASE_VAL:
      if (record->event.pressed) {
        rgblight_increase_val();
      }
      return false;
      break;
    case RGBLED_DECREASE_VAL:
      if (record->event.pressed) {
        rgblight_decrease_val();
      }
      return false;
      break;
    case RGBLED_STEP_MODE:
      if (record->event.pressed) {
        rgblight_step();
      }
      return false;
      break;


      }
  return true;
};
Example #29
0
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{
      switch(id) {
        case _QWERTY:
          if (record->event.pressed) {
            #ifdef AUDIO_ENABLE
              PLAY_NOTE_ARRAY(tone_qwerty, false, 0);
            #endif
            persistant_default_layer_set(1UL<<_QWERTY);
          }
          break;
        case _COLEMAK:
          if (record->event.pressed) {
            #ifdef AUDIO_ENABLE
              PLAY_NOTE_ARRAY(tone_colemak, false, 0);
            #endif
            persistant_default_layer_set(1UL<<_COLEMAK);
          }
          break;
        case _DVORAK:
          if (record->event.pressed) {
            #ifdef AUDIO_ENABLE
              PLAY_NOTE_ARRAY(tone_dvorak, false, 0);
            #endif
            persistant_default_layer_set(1UL<<_DVORAK);
          }
          break;
        case _LOWER:
          if (record->event.pressed) {
            layer_on(_LOWER);
            #ifdef BACKLIGHT_ENABLE
                breathing_speed_set(2);
                breathing_pulse();
            #endif
            update_tri_layer(_LOWER, _RAISE, _ADJUST);
          } else {
            layer_off(_LOWER);
            update_tri_layer(_LOWER, _RAISE, _ADJUST);
          }
          break;
        case _RAISE:
          if (record->event.pressed) {
            layer_on(_RAISE);
            #ifdef BACKLIGHT_ENABLE
                breathing_speed_set(2);
                breathing_pulse();
            #endif
            update_tri_layer(_LOWER, _RAISE, _ADJUST);
          } else {
            layer_off(_RAISE);
            update_tri_layer(_LOWER, _RAISE, _ADJUST);
          }
          break;
        case M_BL:
          if (record->event.pressed) {
            register_code(KC_RSFT);
            #ifdef BACKLIGHT_ENABLE
              backlight_step();
            #endif
          } else {
            unregister_code(KC_RSFT);
          }
        break;
        case 12:
          if (record->event.pressed) {
            #ifdef AUDIO_ENABLE
              stop_all_notes();
              PLAY_NOTE_ARRAY(tone_plover, false, 0);
            #endif
            layer_off(_RAISE);
            layer_off(_LOWER);
            layer_off(_ADJUST);
            layer_on(_PLOVER);
            if (!eeconfig_is_enabled()) {
                eeconfig_init();
            }
            keymap_config.raw = eeconfig_read_keymap();
            keymap_config.nkro = 1;
            eeconfig_update_keymap(keymap_config.raw);
          }
        break;
        case 13:
          if (record->event.pressed) {
            #ifdef AUDIO_ENABLE
              PLAY_NOTE_ARRAY(tone_plover_gb, false, 0);
            #endif
            layer_off(_PLOVER);
          }
        break;

      }
    return MACRO_NONE;
};
Example #30
0
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  switch (keycode) {
    case QWERTY:
      if (record->event.pressed) {
        #ifdef AUDIO_ENABLE
          PLAY_NOTE_ARRAY(tone_qwerty, false, 0);
        #endif
        persistant_default_layer_set(1UL<<_QWERTY);
      }
      return false;
      break;
    case COLEMAK:
      if (record->event.pressed) {
        #ifdef AUDIO_ENABLE
          PLAY_NOTE_ARRAY(tone_colemak, false, 0);
        #endif
        persistant_default_layer_set(1UL<<_COLEMAK);
      }
      return false;
      break;
    case DVORAK:
      if (record->event.pressed) {
        #ifdef AUDIO_ENABLE
          PLAY_NOTE_ARRAY(tone_dvorak, false, 0);
        #endif
        persistant_default_layer_set(1UL<<_DVORAK);
      }
      return false;
      break;
    case LOWER:
      if (record->event.pressed) {
        layer_on(_LOWER);
        update_tri_layer(_LOWER, _RAISE, _ADJUST);
      } else {
        layer_off(_LOWER);
        update_tri_layer(_LOWER, _RAISE, _ADJUST);
      }
      return false;
      break;
    case RAISE:
      if (record->event.pressed) {
        layer_on(_RAISE);
        update_tri_layer(_LOWER, _RAISE, _ADJUST);
      } else {
        layer_off(_RAISE);
        update_tri_layer(_LOWER, _RAISE, _ADJUST);
      }
      return false;
      break;
    case BACKLIT:
      if (record->event.pressed) {
        register_code(KC_RSFT);
        #ifdef BACKLIGHT_ENABLE
          backlight_step();
        #endif
      } else {
        unregister_code(KC_RSFT);
      }
      return false;
      break;
    case PLOVER:
      if (record->event.pressed) {
        #ifdef AUDIO_ENABLE
          stop_all_notes();
          PLAY_NOTE_ARRAY(tone_plover, false, 0);
        #endif
        layer_off(_RAISE);
        layer_off(_LOWER);
        layer_off(_ADJUST);
        layer_on(_PLOVER);
        if (!eeconfig_is_enabled()) {
            eeconfig_init();
        }
        keymap_config.raw = eeconfig_read_keymap();
        keymap_config.nkro = 1;
        eeconfig_update_keymap(keymap_config.raw);
      }
      return false;
      break;
    case EXT_PLV:
      if (record->event.pressed) {
        #ifdef AUDIO_ENABLE
          PLAY_NOTE_ARRAY(tone_plover_gb, false, 0);
        #endif
        layer_off(_PLOVER);
      }
      return false;
      break;
  }
  return true;
}