예제 #1
0
// 接收按键处理
void Process_BetPadKey(unsigned char Id, unsigned char *Data) {
	unsigned short Key = (Data[0]|(Data[1]<<8));
	unsigned short Release;			// 已释放掉的键
	unsigned char BitIdx;
	int Tick;

	Key &= 0x0EFF;
	
	if (!RecvTick[Id]) {
		// 发送ID
		if (Id < COM_PLAYER_COUNT) {
			Send_ID(Id);
		}
		Set_Odds(Id);
		Set_LED(Id);
		Set_Score(Id);
	}
	RecvTick[Id] = GetTick() + 3000;	// 如果1.5秒内没有信息发过来就当掉线
	
	DownKey[Id] = Key & (Key ^ ConstDownKey[Id]);
	
	// 长按开始计数
	Release = DownKey[Id]&(~ConstDownKey[Id]);
	Tick = GetTick();
	while (Release & KeyPressFlag) {
		BitIdx = bsr32(Release);
		Release &= ~(1<<BitIdx);
		KeyCount[Id][BitIdx] = Tick + 200;
	}
	
	Release = (Key ^ DownKey[Id] ^ ConstDownKey[Id]);
	ConstDownKey[Id] = Key & (~Release);
}
예제 #2
0
/*------------------------------------------------------------------------------
   Обработчик прерываний от ADC

 ------------------------------------------------------------------------------*/
void ADC_Isr(void)
{
  Set_LED();
  VAN_adcr = ADC_R;
  VOLTAGE_adcr = ADC_R;
  TEMPER_adcr = ADC_R;
  INTTEMPER_adcr = ADC_R;

  Clear_LED();
}
예제 #3
0
// 切换
void OnSwitch(char Id) {
	char CurrentSwitch = GetCharValue(UD_BETSCORE_SWITCH + Id);
	if (++CurrentSwitch >= 3) {
		CurrentSwitch = 0;
	}
	SetCharValue(UD_BETSCORE_SWITCH + Id, CurrentSwitch);
	
	// 发灯
	Set_LED(Id);
	Set_Sound(Id);
}