Beispiel #1
0
__myevic__ void CoilsIClick()
{
	switch ( CurrentMenuItem )
	{
		case 0 : dfRezNI  = 0; dfRezLockedNI  = 0; break;
		case 1 : dfRezTI  = 0; dfRezLockedTI  = 0; break;
		case 2 : dfRezSS  = 0; dfRezLockedSS  = 0; break;
		case 3 : dfRezTCR = 0; dfRezLockedTCR = 0; break;
		case 4 :
			dfRezNI  = 0; dfRezLockedNI  = 0;
			dfRezTI  = 0; dfRezLockedTI  = 0;
			dfRezSS  = 0; dfRezLockedSS  = 0;
			dfRezTCR = 0; dfRezLockedTCR = 0;
			break;
	}
	if (( CurrentMenuItem == dfMode ) || ( CurrentMenuItem == 4 ))
	{
		dfResistance = AtoRez;
	}
	if ( CurrentMenuItem == 5 )
	{
		UpdateDataFlash();
	}
	else
	{
		UpdateDFTimer = 50;
		gFlags.refresh_display = 1;
	}
}
Beispiel #2
0
//----- (00002C00) --------------------------------------------------------
__myevic__ uint32_t hidResetParamCmd( CMD_T *pCmd )
{
	myprintf("Reset param\n");
	ResetDataFlash();
	UpdateDataFlash();
	gFlags.refresh_display = 1;
	pCmd->u8Cmd = HID_CMD_NONE;
	return 0;
}
Beispiel #3
0
__myevic__ void ModesIClick()
{
	if (( CurrentMenuItem < 7 ) && ( CurrentMenuItem != dfMode ))
	{
		dfModesSel ^= ( 1 << CurrentMenuItem );
		if ( dfModesSel == 0x7f ) dfModesSel ^= ( 1 << 4 );
		UpdateDFTimer = 50;
		gFlags.refresh_display = 1;
	}
	else
	{
		UpdateDataFlash();
	}
}
Beispiel #4
0
__myevic__ int EvtFire()
{
	int vret = 0;

	switch ( Screen )
	{
		case 101:
		{
			gFlags.edit_capture_evt ^= 1;
			if ( gFlags.edit_capture_evt )
			{
				gFlags.refresh_display = 1;
				ScreenDuration = 10;
			}
			else
			{
				UpdateDFTimer = 1;
				UpdateDataFlash();
				MainView();
			}
			vret = 1;
		}
		break;
		
		case 102:
		{
			vret = MenuEvent( LastEvent );
		}
		break;

		case 103:
		{
			MainView();
			vret = 1;
		}
		break;

		case 104:
		{
			RTCAdjustClock( 0 );
			MainView();
			vret = 1;
		}
	}

	return vret;
}
Beispiel #5
0
__myevic__ void GameIClick()
{
	UpdateDataFlash();
	if ( dfFBSpeed <= 2 )
	{
		gFlags.playing_fb = 1;
		Screen = 0;
		gFlags.user_idle = 1;
		gFlags.refresh_display = 1;
		BatRefreshTmr = 0;
		SleepTimer = 3000;
		fbInitTimeouts();
		ClearScreenBuffer();
		DisplayRefresh();
		fbBirdAnim( 24 );
		fbCreateTimeout( fbStartScreen + 1 );
	}
}
Beispiel #6
0
//----- (00002788) --------------------------------------------------------
__myevic__ void hidGetOutReport( uint8_t *pu8Buffer, uint32_t u32BufferLen )
{
	uint8_t u8Cmd;
	uint8_t *hidDataPtr;
	uint32_t u32StartAddr;
	uint32_t u32DataSize;
	uint32_t u32ByteCount;
	uint32_t u32Page;

	uint32_t sz;
	uint32_t veo;

	u8Cmd			= hidCmd.u8Cmd;
	u32StartAddr	= hidCmd.u32Arg1;
	u32DataSize		= hidCmd.u32Arg2;
	u32ByteCount	= hidCmd.u32Signature;
	hidDataPtr		= &hidData[hidDataIndex];

	switch ( hidCmd.u8Cmd )
	{
		case HID_CMD_SETPARAMS:
		{
			USBD_MemCopy( hidDataPtr, pu8Buffer, EP3_MAX_PKT_SIZE );
			hidDataIndex += EP3_MAX_PKT_SIZE;

			if ( hidDataIndex >= u32DataSize )
			{
				u8Cmd = HID_CMD_NONE;

				if ( u32StartAddr + u32DataSize > FMC_FLASH_PAGE_SIZE )
				{
					sz = FMC_FLASH_PAGE_SIZE - u32StartAddr;
				}
				else
				{
					sz = u32DataSize;
				}

				MemCpy( (uint8_t*)(&hidDFData) + u32StartAddr, hidData, sz );

				myprintf( "Set Sys Param complete.\n" );

				dfStruct_t * df = (dfStruct_t*)hidDFData;

				if ( Checksum( (uint8_t*)df->params, FMC_FLASH_PAGE_SIZE - 4 ) == df->Checksum )
				{
					myprintf( "\tCompany ID ............................ [0x%08x]\n",
								df->i.fmcCID );
					myprintf( "\tDevice ID ............................. [0x%08x]\n",
								df->i.fmcDID  );
					myprintf( "\tProduct ID ............................ [0x%08x]\n",
								df->i.fmcPID );
					myprintf( "\tu8UpdateAPRom ......................... [0x%08x]\n",
								df->p.BootFlag );

					MemCpy( DataFlash.params, df->params, DATAFLASH_PARAMS_SIZE );

					DFCheckValuesValidity();
					UpdateDataFlash();

					if ( df->i.Year >= 2000 && df->i.Year <= 2099 )
					{
						S_RTC_TIME_DATA_T rtd;
						rtd.u32Year = df->i.Year;
						rtd.u32Month = df->i.Month;
						rtd.u32Day = df->i.Day;
						rtd.u32DayOfWeek = 0;
						rtd.u32Hour = df->i.Hour;
						rtd.u32Minute = df->i.Minute;
						rtd.u32Second = df->i.Second;
						rtd.u32TimeScale = RTC_CLOCK_24;
						SetRTC( &rtd );
					}
					
					gFlags.refresh_display = 1;
				}
				else
				{
					myprintf( "Sys Param Receive fail.\n" );
				}

				hidDataIndex = 0;
			}

			break;
		}

		case HID_CMD_SETLOGO:
		{
			USBD_MemCopy( hidDataPtr, pu8Buffer, EP3_MAX_PKT_SIZE );
			hidDataIndex += EP3_MAX_PKT_SIZE;

			if ( hidDataIndex < FMC_FLASH_PAGE_SIZE && hidDataIndex + u32ByteCount < u32DataSize )
			{
				break;
			}

			u32Page = u32StartAddr + u32ByteCount;

			myprintf( "Writing page %d\n", u32Page );

			SYS_UnlockReg();
			FMC_ENABLE_ISP();
			FMC_ENABLE_AP_UPDATE();

			if ( FMCEraseWritePage( u32Page, (uint32_t*)hidData ) )
			{
				myprintf( "Data Flash Erase error!\n" );
			}

			veo = FMCVerifyPage( u32Page, (uint32_t*)hidData );
			if ( veo )
			{
				myprintf( "Data Flash Verify error! 0x%x\n", 4 * veo - 4 );
			}

			MemClear( hidData, FMC_FLASH_PAGE_SIZE );
			u32ByteCount += hidDataIndex;

			myprintf( "g_u32BytesInPageBuf %d, u32LenCnt 0x%x\n", hidDataIndex, u32ByteCount );

			FMC_DISABLE_AP_UPDATE();
			FMC_DISABLE_ISP();
			SYS_LockReg();

			if ( u32ByteCount < u32DataSize )
			{
				hidDataIndex = 0;
			}
			else
			{
				u8Cmd = HID_CMD_NONE;
				myprintf( "set boot logo command complete.\n" );
			}

			break;
		}

		case HID_CMD_LDUPDATE:
		{
			USBD_MemCopy( hidDataPtr, pu8Buffer, EP3_MAX_PKT_SIZE );
			hidDataIndex += EP3_MAX_PKT_SIZE;

			if ( hidDataIndex < FMC_FLASH_PAGE_SIZE && hidDataIndex + u32ByteCount < u32DataSize )
			{
				break;
			}

			u32Page = u32StartAddr + u32ByteCount;
			myprintf( "Writing page 0x%08X\n", u32Page );

			SYS_UnlockReg();
			FMC_ENABLE_ISP();
			FMC_EnableLDUpdate();

			if ( FMCEraseWritePage( u32Page, (uint32_t*)hidData ) )
			{
				myprintf( "Data Flash Erase error!\n" );
			}

			veo = FMCVerifyPage( u32Page, (uint32_t*)hidData );
			if ( veo )
			{
				myprintf( "Data Flash Verify error! 0x%x\n", 4 * veo - 4 );
			}

			MemClear( hidData, FMC_FLASH_PAGE_SIZE );
			u32ByteCount += hidDataIndex;
			hidDataIndex = 0;

			myprintf( "g_u32BytesInPageBuf %d, u32LenCnt 0x%x\n", hidDataIndex, u32ByteCount );

			FMC_DisableLDUpdate();
			FMC_DISABLE_ISP();
			SYS_LockReg();

			if ( u32ByteCount >= u32DataSize )
			{
				u8Cmd = HID_CMD_NONE;
				myprintf( "Update LDROM command complete.\n" );
			}
			
			break;
		}

		default:
		{
			if ( hidProcessCommand( pu8Buffer, u32BufferLen ) )
			{
				myprintf( "Unknown HID command!\n" );
			}
			return;
		}
	}

	hidCmd.u8Cmd = u8Cmd;
	hidCmd.u32Signature = u32ByteCount;
}
Beispiel #7
0
__myevic__ void DrawScreen()
{
	if ( Screen == 2 && FireDuration && FireDuration != CurrentFD )
	{
		CurrentFD = FireDuration;
		ScreenDuration = 1;
		ShowFDTimer = 0;
		gFlags.refresh_display = 1;
	}

	if ( gFlags.refresh_display )
	{
		gFlags.refresh_display = 0;
		ClearScreenBuffer();

		switch ( Screen )
		{
			case  0: // Black
				break;

			case  1: // Main view
			case  3: // Main view (?)
			case  4: // (unused?)
				ShowMainView();
				break;

			case  2: // Firing
				if ( !dfStealthOn )
				{
					ShowMainView();
				}
				break;

			case  5: // Black w/ Battery
				ShowBatCharging();
				break;

			case 20: // No Atomizer Found
				ShowNoAtoFound();
				break;

			case 21: // Atomizer Short
				ShowAtoShort();
				break;

				case 22: // Atomizer Low
				ShowAtoLow();
				break;

			case 23: // 10s Protection
				Show10sProtec();
				break;

			case 24: // Battery Low
				ShowBatLow();
				break;

			case 25: // Battery Low Lock
				ShowBatLowLock();
				break;

			case 28: // Key Lock
				ShowKeyLock();
				break;

			case 29: // Device too hot
				ShowDevTooHot();
				break;

			case 31: // Key UnLock
				ShowKeyUnLock();
				break;

			case 37: // Board Temp
				ShowBoardTemp();
				break;

			case 40: // Stealth ON/OFF
				ShowStealthMode();
				break;

			case 41: // Ti ON/OFF
				ShowTiOnOff();
				break;

			case 50: // FW Version
				ShowVersion();
				break;

			case 51: // New Coil
				ShowNewCoil();
				break;

			case 54: // Battery Voltage
				ShowBattVolts();
				break;

			case 59: // TCR Set Menu
				ShowTCRSet();
				break;

			case 82: // LOGO Menu
				ShowLOGOMenu();
				break;

			case 83: // Game Menu
				ShowGameMenu();
				break;

			case 100:
				ShowInfos();
				break;

			case 101:
				ShowContrast();
				break;

			case 102:
				ShowMenus();
				break;

			case 103:
				ShowRTCSpeed();
				break;

			case 104:
				ShowRTCAdjust();
				break;

			default:
				break;
		}

		if ( myDbgFlag & 1 )
		{
			int nd = (Screen<100?Screen<10?1:2:3);
			DrawValue( 64-6*nd, 120, Screen, 0, 0x01, nd );
			DrawValue( 0, 120, ScreenDuration, 0, 0x01, 0 );
		}
		
		DisplayRefresh();
	}

	if (( gFlags.firing ) && ISMODETC(dfMode))
	{
		ShowFDTimer += 5;
	}
	else
	{
		ShowFDTimer += 1;
	}

	if ( ShowFDTimer < 10 )
		return;

	ShowFDTimer = 0;

	if ( ScreenDuration && --ScreenDuration )
		return;

	switch ( Screen )
	{
		case   0: // Black
			if ( dfStatus.off )
			{
				SleepTimer = 0;
			}
			break;

		case   2: // Firing
			if ( dfStealthOn )
			{
				gFlags.refresh_display = 1;
				if ( !(gFlags.battery_charging) )
				{
					Screen = 0;
					SleepTimer = 18000;
				}
				else
				{
					Screen = 5;
				}
			}
			else
			{
				MainView();
			}
			break;

		case   5: // Black w/ Battery
			break;

		case  20: // No Atomizer Found
		case  21: // Atomizer Short
			MainView();
			break;

		case  22: // Atomizer Low
		case  23: // 10s Protection
		case  24: // Battery Low
		case  25: // Battery Low Lock
			break;

		case  29: // Device too hot
			MainView();
			break;

		case 101: // Contrast Menu
		case 102: // Menus
		case 103: // RTC Speed
			gFlags.edit_capture_evt = 0;
			// NOBREAK
		case  59: // TCR Set Menu
		case  82: // LOGO Menu
		case  83: // Game Menu
			UpdateDataFlash();
			// NOBREAK
		case   1: // Main view
		case  28: // Key Lock
		case  31: // Key UnLock
		case  37: // Board Temp
		case  40: // Stealth ON/OFF
		case  41: // Ti ON/OFF
		case  54: // Battery Voltage
		case 100: // Ferox's page
		case 104: // Adjust Clock
			if ( !dfScreenSave )
			{
				if ( Screen != 1 )
					MainView();
				break;
			}
			if ( !(gFlags.battery_charging) )
			{
				gFlags.refresh_display = 1;
				Screen = 0;
				SleepTimer = 18000;
			}
			else
			{
				Screen = 5;
			}
			break;

		case  50: // FW Version
			break;

		case  51: // New Coil
			MainView();
			break;

		default:
			break;
	}

	return;
}
Beispiel #8
0
__myevic__ void ScreenSaveMenuOnClick()
{
	dfScreenSave = ScrSaveTimes[CurrentMenuItem];
	UpdateDataFlash();
	MainView();
}
Beispiel #9
0
//=============================================================================
//----- (00004B34) ------------------------------------------------------------
// Called at 100Hz
__myevic__ void GetUserInput()
{
	UserInputs = 14;

	if ( !PE0 && PD2 && PD3 )
	{
		UserInputs = 1;
	}
	else
	{
		if ( gFlags.firing )
		{
			if ( LastInputs == 1 )
				StopFire();
			gFlags.user_idle = 1;
			LastInputs = -1;
			KeyPressTime = 0;
			return;
		}

		if ( !FireClickTimer && FireClicksEvent )
		{
			Event = FireClicksEvent;
			FireClicksEvent = 0;
		}

		if ( !(dfStatus.off) || Screen == 59 )
		{
			if ( !PD2 ) UserInputs = 2;
			if ( !PD3 ) UserInputs = 3;
		}

		if ( !PD2 && !PD3 ) UserInputs = 4;
		if ( !PE0 && !PD2 ) UserInputs = 5;
		if ( !PE0 && !PD3 ) UserInputs = 6;

		if ( USBD_IS_ATTACHED() )
		{
			if ( !(gFlags.usb_attached) )
			{
				UserInputs = 10;
				byte_20000048 = 0;
			}
		}
		else
		{
			if ( gFlags.usb_attached )
			{
				UserInputs = 11;
			}
		}

		if ( gFlags.usb_attached )
		{
			if ( !PD7 && !(gFlags.battery_charging) )
			{
				if ( !byte_20000048 || byte_20000048 >= 50 )
				{
					UserInputs = 12;
					byte_20000048 = 0;
				}
			}
			else if ( PD7 && gFlags.battery_charging )
			{
				UserInputs = 13;
				byte_20000048 = 1;
			}
		}
	}

	if ( UserInputs >= 14 )
	{
		if ( LastInputs == 1 )
			StopFire();
		gFlags.user_idle = 1;
		LastInputs = -1;
		KeyPressTime = 0;
		return;
	}

	if ( UserInputs != LastInputs )
	{
		LastInputs = UserInputs;
		KeyPressTime = 0;
		gFlags.user_idle = 0;
		return;
	}

	++KeyPressTime;

	// A keypress must be stable during at least
	// 60 milliseconds before an event is emitted.

	if ( KeyPressTime == 6 )
	{
		gFlags.user_idle = 0;

		if (   UserInputs == 4
			|| UserInputs == 5
			|| UserInputs == 6
			|| UserInputs == 7
			|| UserInputs == 8
			|| UserInputs == 9
		)
			return;

		Event = UserInputs;

		if ( UserInputs == 1 )
		{
			FireClickTimer = 40;
			++FireClickCount;
			FireClicksEvent = 0;
			Event = 0;

			if ( FireClickCount == 1 )
			{
				FireClicksEvent = 15;	// single click

				if ( !EditModeTimer || EditItemIndex != 4 )
				{
					Event = 1;	// fire
				}
			}
			else if ( FireClickCount == 2 )
			{
				FireClicksEvent = EVENT_DOUBLE_FIRE;	// show date
			}
			else if ( FireClickCount == 3 )
			{
				FireClicksEvent = 16;	// edit mode
			}
			else if ( FireClickCount == 4 )
			{
				FireClicksEvent = EVENT_QUAD_FIRE;	// debug mode
			}
			else if ( FireClickCount == 5 )
			{
				FireClicksEvent = 17;	// Switch On/Off
			}
			else if ( FireClickCount == 10 )
			{
				FireClicksEvent = 31;	// board temp screen
			}
			else if ( FireClickCount == 20 )
			{
				Event = 29;	// firmware version screen
			}
		}
		else if ( UserInputs == 2 )
		{
			if ( dfStatus.keylock && !EditModeTimer
				&& Screen != 51 && Screen != 59 && Screen != 82 && Screen != 83
				&& Screen < 100 )
			{
				Event = 30;	// key lock violation
			}
			else
			{
				Event = 2;	// + button
			}
		}
		else if ( UserInputs == 3 )
		{
			if ( dfStatus.keylock && !EditModeTimer
				&& Screen != 51 && Screen != 59 && Screen != 82 && Screen != 83
				&& Screen < 100 )
			{
				Event = 30;	// key lock violation
			}
			else
			{
				Event = 3;	// - button
			}
		}
	}
	else if ( KeyPressTime == 20 )
	{
		if ( UserInputs == 1 )
		{
			FireClicksEvent = 0;
		}
	}
	else if ( KeyPressTime == 200 )
	{
		if ( UserInputs == 1 )
		{
			if ( Screen == 59 )
			{
				UpdateDataFlash();
				gFlags.refresh_display = 1;
				Screen = 0;
			}
		}
		else if ( UserInputs == 4 )
		{
			if ( !EditModeTimer )
			{
				if ( dfStatus.off )
					Event = 18;	// flip display
				else
					Event = 4;	// key (un)lock
			}
			else
			{
				EditModeTimer = 1000;
				if ( EditItemIndex == 4 )
				{
					if ( dfAPT == 1 )
						Event = 22;	// puff reset
					if ( dfAPT == 2 )
						Event = 23;	// time reset
				}
			}
		}
		else if ( UserInputs == 5 )
		{
			MenuPage = 1;
			if ( !(dfStatus.off) )
			{
				if ( !(gFlags.playing_fb) )
				{
					Event = EVENT_ENTER_MENUS;	// new menus
				//	Event =  40;	// old menus
				}
				else
				{
					gFlags.playing_fb = 0;
					Event = -1;
					fbInitTimeouts();
					MainView();
				}
			}
		}
		else if ( UserInputs == 6 )
		{
			if ( !(dfStatus.off) )
			{
				Event = 6;	// stealth on/off
			}
		}
	}
	else if ( KeyPressTime == 500 )
	{
		if ( UserInputs == 5 )
		{
			if ( dfStatus.off )
			{
				Event = 39;	// tcr set menu
			}
		}
		else if ( UserInputs == 6 )
		{
			if ( dfStatus.off )
			{
				Event = 34;	// battery voltage screen
			}
		}
	}
	else if ( ( KeyPressTime & 0x8000 ) ||  ( KeyPressTime & 0x7fff ) >= 210 )
	{
		if ( UserInputs == 1 )
		{
			if ( KeyPressTime > 1100 )
			{
				KeyPressTime = 1100;
				gFlags.user_idle = 1;
			}
			else if ( FireDuration > 99 )
			{
				Event = 24;	// 10s protection
			}
		}
		else if ( KeyPressTime & 0x8000 )
		{
			KeyPressTime = 6;
		}
	}
}