Exemplo n.º 1
0
void KeyCheck(void){

	if	(
		BitIsSet(PrevKey, KEY_STEP_FLAG)					//Нужно повторное считывание порта STEP
		&&
		BitIsClear(KEY_PORTIN_STEP, KEY_STEP_PORT)
		)
		SetBit(Key, KEY_STEP_FLAG);
	if	(
		BitIsSet(PrevKey, KEY_OK_FLAG)						//Нужно повторное считывание порта OK
		&&
		BitIsClear(KEY_PORTIN_OK, KEY_OK_PORT)
		)
		SetBit(Key, KEY_OK_FLAG);
	PrevKey = 0;
	if (Key){												//Да, есть нажатие какой-то клавиши
		if (AlarmBeepIsSound()){							//Если сигнал будильника включен то выключить его
			SoundOff();
			SetClockStatus(csClock, csNone);				//Вернутся в нормальный режим
			Key = 0;
			BeginScakKeyRepeat();
			return;											//и выйти т.к. это нажатие выключения будильника
		}
	TimeoutReturnToClock(TIMEOUT_RET_CLOCK_MODE_MIN);		//Установить интервал таймаута для возврата в основной режим 
	SoundOn(SND_KEY_BEEP);									//Пискнуть кнопкой
	}
	if BitIsSet(Key, KEY_STEP_FLAG){						//Шаг
		MenuStep();
	}
	else if BitIsSet(Key, KEY_OK_FLAG){						//ОК
		MenuOK();
	}
	Key = 0;												//Все клавиши отработаны
	BeginScakKeyRepeat();
}
Exemplo n.º 2
0
static void Toggle (void)
{
	sound_on^=1;
	if (sound_on)
		SoundOn ();
	else
		SoundOff ();
}
Exemplo n.º 3
0
void SoundManager::play(int i)
{
    //If there is no music playing
    switch (i)
    {
    case GUN_PICKUP:
        Mix_PlayChannel(GUN_PICKUP, gunPickup, 0);
        break;
    case SCORE_PICKUP:
        Mix_PlayChannel(SCORE_PICKUP, scorePickup, 0);
        break;
    case GUNSHOT:
        Mix_PlayChannel(GUNSHOT, gunshot, 0);
        break;
    case HEALTH:
        Mix_PlayChannel(HEALTH, health, 0);
        break;
    case MINE:
        Mix_PlayChannel(MINE, mine, 0);
        break;
    case ELECTROCUTED:
        Mix_PlayChannel(ELECTROCUTED, electrocuted, 0);
        break;
    case SWITCH:
        Mix_PlayChannel(SWITCH, switchSound, 0);
        break;
    case MENU_MUSIC:
        // If there is no music playing
        if (Mix_PlayingMusic() == 0)
        {
            //Play the music
            Mix_PlayMusic(menuMusic, -1);// -1 means we want it to loop until it is stopped

        }
        // If the music is being played
        else
        {
            //If the music is paused
            if (Mix_PausedMusic() == 1 && SoundOn())
            {
                //Resume the music
                Mix_ResumeMusic();
            }
            //If the music is playing
            else
            {
                if (!SoundOn())
                {
                    //Pause the music
                    Mix_PauseMusic();
                }
            }
        }
        break;
    case LEVEL_ONE_MUSIC:
        if (Mix_PlayingMusic() == 0)
        {
            //Play the music
            Mix_PlayMusic(levelOneMusic, -1);

        }

        else
        {
            //If the music is paused
            if (Mix_PausedMusic() == 1 && SoundOn())
            {
                //Resume the music
                Mix_ResumeMusic();
            }
            //If the music is playing
            else
            {
                if (!SoundOn())
                {
                    //Pause the music
                    Mix_PauseMusic();
                }
            }
        }
        break;

    case LEVEL_TWO_MUSIC:
        if (Mix_PlayingMusic() == 0)
        {
            //Play the music
            Mix_PlayMusic(levelTwoMusic, -1);

        }

        else
        {
            //If the music is paused
            if (Mix_PausedMusic() == 1 && SoundOn())
            {
                //Resume the music
                Mix_ResumeMusic();
            }
            //If the music is playing
            else
            {
                if (!SoundOn())
                {
                    //Pause the music
                    Mix_PauseMusic();
                }
            }
        }
        break;

    case LEVEL_THREE_MUSIC:
        if (Mix_PlayingMusic() == 0)
        {
            //Play the music
            Mix_PlayMusic(levelThreeMusic, -1);

        }

        else
        {
            //If the music is paused
            if (Mix_PausedMusic() == 1 && SoundOn())
            {
                //Resume the music
                Mix_ResumeMusic();
            }
            //If the music is playing
            else
            {
                if (!SoundOn())
                {
                    //Pause the music
                    Mix_PauseMusic();
                }
            }
        }
        break;

    case LEVEL_FOUR_MUSIC:
        if (Mix_PlayingMusic() == 0)
        {
            //Play the music
            Mix_PlayMusic(levelFourMusic, -1);

        }

        else
        {
            //If the music is paused
            if (Mix_PausedMusic() == 1 && SoundOn())
            {
                //Resume the music
                Mix_ResumeMusic();
            }
            //If the music is playing
            else
            {
                if (!SoundOn())
                {
                    //Pause the music
                    Mix_PauseMusic();
                }
            }
        }
        break;

    case VICTORY:
        if (Mix_PlayingMusic() == 0)
        {
            //Play the music
            Mix_PlayMusic(victory, -1);

        }

        else
        {
            //If the music is paused
            if (Mix_PausedMusic() == 1 && SoundOn())
            {
                //Resume the music
                Mix_ResumeMusic();
            }
            //If the music is playing
            else
            {
                if (!SoundOn())
                {
                    //Pause the music
                    Mix_PauseMusic();
                }
            }
        }
        break;
    }
}
Exemplo n.º 4
0
void CALLBACK SPUstartChannels2(unsigned short channels)
{
 SoundOn(16,24,channels);
}
Exemplo n.º 5
0
void CALLBACK SPUstartChannels1(unsigned short channels)
{
 SoundOn(0,16,channels);
}
void LongPulseLaserWork_Process(uint16_t pic_id)
{
	bool update = false;
	uint16_t new_pic_id = pic_id;
	static int timeout_cnt = 0;
	
	DGUS_SOLIDSTATELASER* value;
	ReadVariable(FRAMEDATA_SOLIDSTATELASER_BASE, (void**)&value, sizeof(frameData_SolidStateLaser));
	if ((osSignalWait(DGUS_EVENT_SEND_COMPLETED, g_wDGUSTimeout).status != osEventTimeout) && (osSignalWait(DGUS_EVENT_RECEIVE_COMPLETED, g_wDGUSTimeout).status != osEventTimeout))
	{
		convert_laserdata_ss(&frameData_SolidStateLaser, value);
		timeout_cnt = 0;
	}
	else 
	{
		timeout_cnt++;
		if (timeout_cnt > 2)
		{
			timeout_cnt = 0;
			
			// Solid State Laser Off
			footswitch_en = false;
			SolidStateLaser_en = false;
			LampControlPulseStop();
			osDelay(100);
			__SOLIDSTATELASER_SIMMEROFF();
			osDelay(100);
			__SOLIDSTATELASER_HVOFF();
			osDelay(100);
			__SOLIDSTATELASER_DISCHARGEON();
			
			new_pic_id = FRAME_PICID_LONGPULSE_INPUT;
			
			SoundOn();
			__HAL_TIM_SET_AUTORELOAD(&hTIM11, 42000);
			HAL_TIM_Base_Start_IT(&hTIM11);
			
			update = true;
		}
		return;
	}
	
	uint16_t state = frameData_SolidStateLaser.state;
	
	osDelay(50);
	
	__SOLIDSTATELASER_DISCHARGEOFF();
	
	if (pic_id >= 51 && pic_id <= 62 && pic_id != 55 && pic_id != 53)
		__SOLIDSTATELASER_HVON();
	else
		__SOLIDSTATELASER_HVOFF();
	
	if (pic_id >= 51 && pic_id <= 62 && pic_id != 53)
		__SOLIDSTATELASER_SIMMERON();
	else
		__SOLIDSTATELASER_SIMMEROFF();
	
	if (pic_id == FRAME_PICID_LONGPULSE_WORK)
		SolidStateLaser_en = true;
	else
		SolidStateLaser_en = false;
	
	//frameData_SolidStateLaser.state = 0;
	
	// Input pressed
	if (frameData_SolidStateLaser.buttons.onSimmerBtn != 0)
	{		
		new_pic_id = FRAME_PICID_LONGPULSE_SIMMER;
		
		frameData_SolidStateLaser.state = 2;
		
		// On Input Pressed
		frameData_SolidStateLaser.buttons.onSimmerBtn = 0;
		update = true;
	}
	
#ifdef DEBUG_SOLID_STATE_LASER
	static int16_t simmer_off_cnt = 0;
	if (!(__MISC_GETSIMMERSENSOR()))
	{
		simmer_off_cnt++;
		if (simmer_off_cnt > 10) simmer_off_cnt = 10;
	}
	else
	{
		simmer_off_cnt--;
		if (simmer_off_cnt < 0) simmer_off_cnt = 0;
	}
	if ((simmer_off_cnt > 5) && pic_id != 55 && pic_id != 53) 
	{
		new_pic_id = FRAME_PICID_LONGPULSE_SIMMERSTART;
		
		// Solid State Laser Off
		footswitch_en = false;
		SolidStateLaser_en = false;
		LampControlPulseStop();
		osDelay(1000);
		__SOLIDSTATELASER_HVOFF();
		osDelay(1000);
		__SOLIDSTATELASER_SIMMEROFF();
		osDelay(1000);
		__SOLIDSTATELASER_DISCHARGEON();
		
		update = true;
	}
#endif
	
	// Simmer wait
	if (pic_id == FRAME_PICID_LONGPULSE_SIMMER)
	{
		frameData_SolidStateLaser.state = 2;
		
#ifdef DEBUG_SOLID_STATE_LASER
		if (__MISC_GETSIMMERSENSOR()) 
#endif
		{
			frameData_SolidStateLaser.state = 3;
			new_pic_id = FRAME_PICID_LONGPULSE_INPUT;
			update = true;
		}
	}
	
	// Start pressed
	if (frameData_SolidStateLaser.buttons.onStartBtn != 0)
	{
		// On Start Pressed
		frameData_SolidStateLaser.buttons.onStartBtn = 0;
		
		//LampControlPulseStart();
		__MISC_LASERLED_ON();
		
		new_pic_id = FRAME_PICID_LONGPULSE_WORK;
		
		update = true;
	}
	
	if (frameData_SolidStateLaser.buttons.onStopBtn != 0)
	{
		// On Input Pressed
		frameData_SolidStateLaser.buttons.onStopBtn = 0;
		
		__MISC_LASERLED_OFF();
		
		SolidStateLaser_en = false;
		LampControlPulseStop();
		__SOLIDSTATELASER_HVOFF();
		//__SOLIDSTATELASER_SIMMEROFF();
		SetDACValue(0.0f);
		frameData_SolidStateLaser.state = 0;
		new_pic_id = FRAME_PICID_LONGPULSE_INPUT;
		update = true;
		StoreGlobalVariables();
	}
	
	if (frameData_SolidStateLaser.buttons.onCancelBtn != 0)
	{
		// On Input Pressed
		frameData_SolidStateLaser.buttons.onCancelBtn = 0;
		
		SolidStateLaser_en = false;
		LampControlPulseStop();
		__SOLIDSTATELASER_HVOFF();
		//__SOLIDSTATELASER_SIMMEROFF();
		SetDACValue(0.0f);
		frameData_SolidStateLaser.state = 0;
		new_pic_id = FRAME_PICID_LONGPULSE_INPUT;
		update = true;
		StoreGlobalVariables();
	}
	
	if (state != frameData_SolidStateLaser.state)
		update = true;
	
	if (frameData_SolidStateLaser.PulseCounter != GetSolidStateGlobalPulse(LaserID))
	{
		frameData_SolidStateLaser.PulseCounter = GetSolidStateGlobalPulse(LaserID);
		frameData_SolidStateLaser.SessionPulseCounter = GetSolidStateSessionPulse(LaserID);
		update = true;
	}
	
	if (update)
	{
		WriteSolidStateLaserDataConvert16(FRAMEDATA_SOLIDSTATELASER_BASE, &frameData_SolidStateLaser);
		osSignalWait(DGUS_EVENT_SEND_COMPLETED, g_wDGUSTimeout);
	}
	
	if (pic_id != new_pic_id && update)
		SetPicId(new_pic_id, g_wDGUSTimeout);
}