Esempio n. 1
0
void audio_on() {
	audio_off();	//Turn off to make sure we do a proper reset
	delay(1000000);

	i2s_init(SPARROW_I2S);
	write_pin(AUDIO_POWER_EN_PIN, true);
	delay(1000000);		//TLV320AIC3100 spec: Reset low for at least 10ns
	write_pin(AUDIO_NRESET, true);
	delay(1000000);		//TLV320AIC3100 spec: 1ms min after reset
}
Esempio n. 2
0
void fc_landing()
{
	gui_dialog_set_P(PSTR("Landing"), PSTR(""), GUI_STYLE_STATS, fc_landing_cb);
	fc_landing_old_gui_task = gui_task;
	gui_switch_task(GUI_DIALOG);

	fc.flight_state = FLIGHT_LAND;

	fc.flight_timer = task_get_ms_tick() - fc.flight_timer;

	audio_off();

	logger_stop();
}
Esempio n. 3
0
void audio_beep_loop()
{
    DEBUG("beep loop %d %d\n", audio_beep_duration, audio_beep_index);
    if (audio_beep_duration > AUDIO_STEP_MS)
    {
        audio_beep_duration -= AUDIO_STEP_MS;
    }
    else
    {
        if (audio_beep_index == audio_beep_len)
        {
            audio_beep = false;
            audio_off();
        }
        else
            audio_beep_next();
    }
};
Esempio n. 4
0
void audio_vario_step(float vario)
{
	if (config.gui.vario_mute || config.gui.silent & (1 << active_page))
	{
		audio_off();
		return;
	}

	//climb is float in m/s
	int16_t ivario = vario * 100;

	vario_force_change = (abs(ivario - vario_ivario_old) >= 10) ? true: false;
	vario_ivario_old = ivario;

	//buzzer
	if (config.vario.weak_lift_enabled)
	{
		int16_t buzz_thold = config.audio_profile.lift - config.vario.weak_lift;

		if (ivario >= buzz_thold && ivario < config.audio_profile.lift && ivario > config.audio_profile.sink)
		{
			int16_t freq;

			//addition to base weak lift freq (can be negative)
			int16_t beep_freq = get_near(config.audio_profile.lift / 100.0, config.audio_profile.freq);
			beep_freq -= config.audio_profile.weak_lift_freq;

			freq = config.audio_profile.weak_lift_freq + ((int32_t)beep_freq * (int32_t)(ivario - buzz_thold)) / (int32_t)config.vario.weak_lift;

			if (audio_vario_freq != 0)
				audio_vario_freq += ((float)freq - audio_vario_freq) / AUDIO_LOW_PASS;
			else
				audio_vario_freq = freq;

			audio_vario_length = 0;
			audio_vario_pause = 0;
			audio_vario_apply();

			return;
		}
	}

	if ((ivario >= config.audio_profile.lift || ivario <= config.audio_profile.sink) && (config.gui.vario_volume > 0))
	{
		//get frequency from the table
		uint16_t freq = get_near(vario, config.audio_profile.freq);
		if (audio_vario_freq != 0)
			audio_vario_freq += ((float)freq - audio_vario_freq) / AUDIO_LOW_PASS;
		else
			audio_vario_freq = freq;

		//convert ms to timer ticks
		audio_vario_length = get_near(vario, config.audio_profile.length) * 31;
		audio_vario_pause = get_near(vario, config.audio_profile.pause) * 31;

		//update audio with new settings
		audio_vario_apply();

		return;
	}

	//no threshold was exceeded -> silent
	audio_off();
}
Esempio n. 5
0
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{

    // MACRODOWN only works in this function
    switch(id)
    {

        case MACRO_QWERTY:
            if (record->event.pressed)
            {
                persistant_default_layer_set(1UL<<LAYER_QWERTY);
				#ifdef AUDIO_ENABLE
                	PLAY_NOTE_ARRAY(tone_qwerty, false, STACCATO);
				#endif /* AUDIO_ENABLE */
            }
            break;

        case MACRO_COLEMAK:
            if (record->event.pressed)
            {
                persistant_default_layer_set(1UL<<LAYER_COLEMAK);
				#ifdef AUDIO_ENABLE
                	PLAY_NOTE_ARRAY(tone_colemak, false, STACCATO);
				#endif /* AUDIO_ENABLE */
            }
            break;

        case MACRO_DVORAK:
            if (record->event.pressed)
            {
                persistant_default_layer_set(1UL<<LAYER_DVORAK);
				#ifdef AUDIO_ENABLE
    	            PLAY_NOTE_ARRAY(tone_dvorak, false, STACCATO);
				#endif /* AUDIO_ENABLE */
            }
            break;

        case MACRO_LOWER:
            if (record->event.pressed)
            {
                layer_on(LAYER_LOWER);
                update_tri_layer(LAYER_LOWER, LAYER_RAISE, LAYER_ADJUST);
            }
            else
            {
                layer_off(LAYER_LOWER);
                update_tri_layer(LAYER_LOWER, LAYER_RAISE, LAYER_ADJUST);
            }
            break;

        case MACRO_RAISE:
            if (record->event.pressed)
            {
                layer_on(LAYER_RAISE);
                update_tri_layer(LAYER_LOWER, LAYER_RAISE, LAYER_ADJUST);
            }
            else
            {
                layer_off(LAYER_RAISE);
                update_tri_layer(LAYER_LOWER, LAYER_RAISE, LAYER_ADJUST);
            }
            break;

        case MACRO_FUNCTION:
            if (record->event.pressed)
            {
                layer_on(LAYER_FUNCTION);
            }
            else
            {
                layer_off(LAYER_FUNCTION);
            }
            break;

#ifdef MOUSEKEY_ENABLE

        case MACRO_MOUSE:
            if (record->event.pressed)
            {
                layer_invert(LAYER_MOUSE);
            }
            break;

#endif /* MOUSEKEY_ENABLE */

#ifdef AUDIO_ENABLE

        case MACRO_TIMBRE_1:
            if (record->event.pressed) set_timbre(TIMBRE_12);
            break;

        case MACRO_TIMBRE_2:
            if (record->event.pressed) set_timbre(TIMBRE_25);
            break;

        case MACRO_TIMBRE_3:
            if (record->event.pressed) set_timbre(TIMBRE_50);
            break;

        case MACRO_TIMBRE_4:
            if (record->event.pressed) set_timbre(TIMBRE_75);
            break;

        case MACRO_TEMPO_U:
            if (record->event.pressed) increase_tempo(10);
            break;

        case MACRO_TEMPO_D:
            if (record->event.pressed) decrease_tempo(10);
            break;

        case MACRO_TONE_DEFAULT:
            if (record->event.pressed)
            {
                set_timbre(TIMBRE_DEFAULT);
                set_tempo(TEMPO_DEFAULT);
            }
            break;

        case MACRO_AUDIO_OFF:
            if (record->event.pressed)
            {
                #ifdef AUDIO_ENABLE
                    audio_off();
                #endif
            }
            break;

        case MACRO_AUDIO_ON:
            if (record->event.pressed)
            {
                #ifdef AUDIO_ENABLE
                    audio_on();
                PLAY_NOTE_ARRAY(tone_audio_on, false, STACCATO);
                #endif
            }
            break;

        case MACRO_MUSIC_ON:
            if (record->event.pressed)
            {
                #ifdef AUDIO_ENABLE
                    PLAY_NOTE_ARRAY(tone_music_on, false, STACCATO);
                    layer_on(LAYER_MUSIC);
                #endif
            }
            break;

        case MACRO_MUSIC_OFF:
            if (record->event.pressed)
            {
                #ifdef AUDIO_ENABLE
                    layer_off(LAYER_MUSIC);
                    stop_all_notes();
                #endif
            }
            break;

        case MACRO_INC_VOICE:
            if (record->event.pressed)
            {
                #ifdef AUDIO_ENABLE
                    voice_iterate();
                    PLAY_NOTE_ARRAY(music_scale, false, STACCATO);
                #endif
            }
            break;

        case MACRO_DEC_VOICE:
            if (record->event.pressed)
            {
                #ifdef AUDIO_ENABLE
                    voice_deiterate();
                    PLAY_NOTE_ARRAY(music_scale, false, STACCATO);
                #endif
            }
            break;

#endif /* AUDIO_ENABLE */

        default:
            break;

    }
    return MACRO_NONE;
};
Esempio n. 6
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);
          }
        case _NUMPAD:
          if (record->event.pressed) {
            #ifdef AUDIO_ENABLE
              PLAY_NOTE_ARRAY(tone_dvorak, false, 0);
            #endif
            persistant_default_layer_set(1UL<<_NUMPAD);
          }
          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);
          }
          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);
          }
          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 6:
          if (record->event.pressed) {
            #ifdef AUDIO_ENABLE
              audio_off();
            #endif
          }
        break;
        case 7:
          if (record->event.pressed) {
            #ifdef AUDIO_ENABLE
              audio_on();
              PLAY_NOTE_ARRAY(tone_startup, false, 0);
            #endif
          }
        break;
        case 8:
          if (record->event.pressed) {
            #ifdef AUDIO_ENABLE
              layer_off(_MUSIC);
              stop_all_notes();
            #endif
          }
        break;
        case 9:
          if (record->event.pressed) {
            #ifdef AUDIO_ENABLE
              PLAY_NOTE_ARRAY(music_scale, false, 0);
              layer_on(_MUSIC);
            #endif
          }
        break;
        case 10:
          if (record->event.pressed) {
            #ifdef AUDIO_ENABLE
              voice_iterate();
              PLAY_NOTE_ARRAY(music_scale, false, 0);
            #endif
          }
        break;
        case 11:
          if (record->event.pressed) {
            #ifdef AUDIO_ENABLE
              voice_deiterate();
              PLAY_NOTE_ARRAY(music_scale, false, 0);
            #endif
          }
        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_off(_MUSIC);
            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;
};