Beispiel #1
0
int keyCheck(int longCheck) {
	// get key press or use macro
	extern int GetCurKey();
	int i, keystroke;
	unsigned int curkey;
	static int keydown = 0;

	if(keydown) {	// we are waiting for key up or long timer to expire
		
		curkey = GetCurKey();
		if(curkey != keydown) {		// the key is up - return it
			*P_TimeBaseB_Ctrl = 0;    // stop timer
//			logKeystroke(keydown | 0x8000);
			curkey = keydown;
			keydown = 0;
			return curkey;
		} else if (keydown_counter > KEY_LONG_DOWN_THRESH) {
			*P_TimeBaseB_Ctrl = 0;    // stop timer
			curkey = keydown | LONG_KEY_STROKE;
			keydown = 0;
//			logKeystroke(curkey | 0xc000);
			logKeystroke(curkey);
			return (curkey);  // return long key stroke
		}
	}
	// loop allows time for service loop to stabilize on keys
	// based on C_DebounceCnt = 8 in IOKeyScan.asm (i < 12 was too short)	
	KeyScan_ServiceLoop();
	if (longCheck) {
		for (i = 0; i < 15; i++) {
			KeyScan_ServiceLoop();
		}
	}
		
	keystroke = (int)SP_GetCh();
	// BUG: Combo keys are not working. Not sure why yet.
//	if (keystroke == ADMIN_COMBO_KEYS)
//		adminOptions();  //might also want to move this to control tracks
	if (MACRO_FILE) {
		keystroke = nextMacroKey(keystroke);
		logKeystroke(keystroke);
		return(keystroke);
	}
	
// we have debounced key down, start timer and wait for key up or long key press time to expire
	if (keystroke) {
		
		__asm__("irq off");
		__asm__("fiq off");

		*P_TimeBaseB_Ctrl = TIMEBASE_B_16HZ;  // enable int & divide second into 16 chunks (could be 8,16,32,64)
		keydown_counter = 0;
		
		__asm__("irq on");
		__asm__("fiq on");
		
		keydown = keystroke;
	}
	if(longCheck && keydown) {
		while(((curkey = GetCurKey()) == keydown) && (keydown_counter <= KEY_LONG_DOWN_THRESH)) 
			;
		curkey = keydown;
		if (keydown_counter > KEY_LONG_DOWN_THRESH)
			curkey |= LONG_KEY_STROKE;
		keydown = 0;
		logKeystroke(curkey);
		return(curkey);
	}
	return (0);
//	return keystroke;
}
Beispiel #2
0
void demo(void *pvParameters)
{
	unsigned Key = 0;
	unsigned SpeechIndex = 0;
	unsigned VolumeIndex = 9;
	unsigned DAC_FIR_Type = C_DAC_FIR_Type2;
	unsigned PlayCon = 0;

	SACM_A1600_Initial();		// A1600 initial
	
	while(1)
	{
		Key = SP_GetCh();
		switch(Key)
		{	
			case 0x0000:
				break;

			case 0x0001:	// IOA0 + Vcc
				PlayCon = 0;
				SACM_A1600_Play(SpeechIndex, DAC1 + DAC2, Ramp_Up + Ramp_Dn);		// play speech
				break;

			case 0x0002:	// IOA1 + Vcc
				PlayCon = 0;
				SACM_A1600_Stop();						// stop
				break;

			case 0x0004:	// IOA2 + Vcc
				SACM_A1600_Pause();						// playback pause
				break;

			case 0x0008:	// IOA3 + Vcc
				SACM_A1600_Resume();					// playback resuem
				break;
			
			case 0x0010:	// IOA4 + Vcc
				if(++SpeechIndex >= MaxSpeechNum)		// next speech
					SpeechIndex = 0;
				PlayCon = 0;
				SACM_A1600_Play(SpeechIndex, DAC1 + DAC2, Ramp_Up + Ramp_Dn);		// play next speech
				break;

			case 0x0020:	// IOA5 + Vcc
				if(++VolumeIndex >= MaxVolumeNum)
					VolumeIndex = 0;
				USER_A1600_Volume(VolumeIndex);			// volume up
				break;

			case 0x0040:	// IOA6 + Vcc
				if(++DAC_FIR_Type > C_DAC_FIR_Type3)
					DAC_FIR_Type = C_DAC_FIR_Type0;
				SACM_A1600_DA_FIRType(DAC_FIR_Type);	// change DAC filter type
				break;

			case 0x0080:	// IOA7 + Vcc
				PlayCon = 1;
				SpeechIndex = 0;
				USER_A1600_SetStartAddr(SpeechIndex);
				SACM_A1600_Play(Manual_Mode_Index, DAC1 + DAC2, Ramp_Up);
				break;

			default:
				break;
		} // end of switch
		
		if(PlayCon)
		{
			if(SACM_A1600_Check_Con() == -1)
			{
				if(++SpeechIndex >= MaxSpeechNum)		// next speech
					SpeechIndex = 0;
				USER_A1600_SetStartAddr_Con(SpeechIndex);
				SACM_A1600_Play_Con(Manual_Mode_Index, DAC1 + DAC2, Ramp_Dn);
			}
		}
		
		if(ServiceType == Foreground)
			SACM_A1600_ServiceLoop();
		
		System_ServiceLoop();
	} // end of while
}