Пример #1
0
void play_cminor_note(int index, int duration)
{
    clock_t start = clock();
    clock_t stop = start + (duration * (CLOCKS_PER_SEC / 1000));
    buzzer_set_freq(cminor_freq[index-1]);
    while (clock() < stop) {}
}
Пример #2
0
void audio_beep_next()
{
    uint16_t tone = pgm_read_word(&audio_beep_tone_ptr[audio_beep_index]);
    audio_beep_duration = pgm_read_word(&audio_beep_length_ptr[audio_beep_index]);
    audio_beep_index++;

    buzzer_set_vol(fc.audio_volume);
    buzzer_set_freq(tone);

    DEBUG("beep next %d %d\n", tone, audio_beep_index);
}
Пример #3
0
void audio_set_tone(uint16_t tone)
{
    if (tone == 0)
    {
        next_tone = 0;

        //buzzer is running continuously turn off sound
        if (!delay_on)
        {
            //disable sound output
            buzzer_set_vol(0);
        }
    }
    else
    {
        if (next_tone != 0)
        {
            float tmp = ((float)tone - next_tone) / AUDIO_LOW_PASS;
            next_tone = next_tone + tmp;
        }
        else
        {
            next_tone = tone;
        }

        //buzzer is running continuously update freq now
        if (delay_on == false)
        {
            buzzer_set_freq(next_tone);
            buzzer_set_vol(fc.audio_volume);
        }

        //fluid update is enabled
        if (fc.audio_fluid && audio_period == PERIOD_SOUND)
            buzzer_set_freq(next_tone);
    }
}
Пример #4
0
void gui_factory_test_init()
{
	DEBUG(" *** Factory test ***\n");
	fc_pause();
	led_notify_disable();

	//We need to test gps and bt module
	if (!bt_ready())
	{
		DEBUG("Force enable BT\n");
		bt_module_init();
	}

	if (!gps_selftest())
	{
		DEBUG("Force enable GPS\n");
		gps_start();
	}

	buzzer_set_vol(0);
	buzzer_set_freq(0);
	f_test_button_test = 0;

	f_test_lcd = FTEST_LCD_MIN_AUTO;

	if (storage_ready())
	{
		FILINFO fno;

		if (f_stat("SET_CONT", &fno) == FR_OK)
		{
			f_test_lcd_cont_max = 110;
			f_test_lcd_cont_min = 70;
			f_test_lcd_cont = 4;

			f_test_lcd = FTEST_LCD_DONE;
		}
	}


	disp.SetFlip(false);
	disp.SetInvert(false);
}
Пример #5
0
void audio_set_delay(uint16_t length, uint16_t pause)
{
    //Continuous sound (sink)
    if (pause == 0 || length == 0)
    {
        next_length = 0;
        next_pause = 0;

    }
    else
        //with pauses (lift)
    {
        //convert from ms and ticks
        next_length = 31 * length;
        next_pause = 31 * pause;

        //if previous sound was continuous (audio_timer is not working)
        if (delay_on == false)
        {
            //restart timer counter
            audio_timer.SetValue(1);

            //set new tone + enable sound
            buzzer_set_freq(next_tone);
            buzzer_set_vol(fc.audio_volume);

            audio_timer.SetTop(next_length);

            //start timer
            audio_timer.Start();

            //set the period state state
            audio_period = PERIOD_SOUND;
        }

        //we have pauses enabled
        delay_on = true;
    }
}
Пример #6
0
void audio_vario_apply()
{
	switch (audio_vario_mode)
	{
		case(VARIO_OFF):
			//start the beeps
			if (audio_vario_length > 0 && audio_vario_pause > 0)
			{
				buzzer_set_vol(config.gui.vario_volume);
				buzzer_set_freq(audio_vario_freq);

				audio_timer.SetValue(0);
				audio_timer.SetTop(audio_vario_length);
				audio_timer.Start();

				audio_vario_mode = VARIO_BEEP;
				break;
			}
			//continous tone
			else
			{
				buzzer_set_vol(config.gui.vario_volume);
				buzzer_set_freq(audio_vario_freq);

				audio_vario_mode = VARIO_CONT;
				break;
			}

		break;

		case(VARIO_BEEP):
			if (audio_vario_length == 0 || audio_vario_pause == 0)
			{
				audio_timer.Stop();
				buzzer_set_vol(config.gui.vario_volume);
				buzzer_set_freq(audio_vario_freq);

				audio_vario_mode = VARIO_CONT;
				break;
			}

			if (config.audio_profile.fluid)
				buzzer_set_freq(audio_vario_freq);
		break;

		case(VARIO_PAUSE):
			if (vario_force_change)
				audio_vario_mode = VARIO_OFF;
		break;

		case(VARIO_CONT):
			if (audio_vario_length > 0 && audio_vario_pause > 0)
			{
				buzzer_set_freq(audio_vario_freq);

				audio_timer.SetValue(0);
				audio_timer.SetTop(audio_vario_length);
				audio_timer.Start();

				audio_vario_mode = VARIO_BEEP;
				break;
			}

			buzzer_set_freq(audio_vario_freq);
		break;
	}
}