示例#1
0
void CWinsys::Init () {
	Uint32 sdl_flags = SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE | SDL_INIT_TIMER;
	if (SDL_Init (sdl_flags) < 0) Message ("Could not initialize SDL");

	SDL_GL_SetAttribute(SDL_GL_CONTEXT_EGL, 1);
	SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1); 
	SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); 

	SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1);
#if defined (USE_STENCIL_BUFFER)
	SDL_GL_SetAttribute (SDL_GL_STENCIL_SIZE, 8);
#endif
#ifdef USE_GLES
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
	glHint(GL_LINE_SMOOTH_HINT, GL_FASTEST);
#endif

	SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);

	SetupVideoMode (GetResolution (param.res_type));
	context = SDL_GL_CreateContext(window);
	SetOrient(param.orient >= 0 ? param.orient : resolution.width < resolution.height);
	Reshape (resolution.width, resolution.height);

	//SDL_WM_SetCaption (WINDOW_TITLE, WINDOW_TITLE);
	KeyRepeat (false);
	if (USE_JOYSTICK) InitJoystick ();
//	SDL_EnableUNICODE (1);
}
示例#2
0
文件: main.c 项目: ClockSelect/myevic
//=========================================================================
//----- (00000148) --------------------------------------------------------
__myevic__ void Main()
{
	InitDevices();

	InitVariables();

	// Enable chip temp sensor sampling by ADC
	if ( ISRX300 )
	{
		SYS->IVSCTL |= SYS_IVSCTL_VTEMPEN_Msk;
	}

	InitHardware();

	myprintf( "\n\nJoyetech APROM\n" );
	myprintf( "CPU @ %dHz(PLL@ %dHz)\n", SystemCoreClock, PllClock );

	SetBatteryModel();

	gFlags.sample_vbat = 1;
	ReadBatteryVoltage();

	gFlags.sample_btemp = 1;
	ReadBoardTemp();

	InitDisplay();
	MainView();
	SplashTimer = 3;

	CustomStartup();

	if ( !PD3 )
	{
		DrawScreen();
		while ( !PD3 )
			;
	}

	while ( 1 )
	{
		while ( gFlags.playing_fb )
		{
			// Flappy Bird game loop
			fbCallTimeouts();
			if ( gFlags.tick_100hz )
			{
				// 100Hz
				gFlags.tick_100hz = 0;
				ResetWatchDog();
				TimedItems();
				SleepIfIdle();
				GetUserInput();
				if ( !PE0 )
					SleepTimer = 3000;
			}
			if ( gFlags.tick_10hz )
			{
				// 10Hz
				gFlags.tick_10hz = 0;
				DataFlashUpdateTick();
			}
		}

		if ( gFlags.firing )
		{
			ReadAtoCurrent();
		}

		if ( gFlags.tick_5khz )
		{
			// 5000Hz
			gFlags.tick_5khz = 0;

			if ( gFlags.firing )
			{
				RegulateBuckBoost();
			}
		}

		if ( gFlags.tick_1khz )
		{
			// 1000Hz
			gFlags.tick_1khz = 0;

			if ( gFlags.firing )
			{
				ReadAtomizer();

				if ( ISMODETC(dfMode) )
				{
					if ( gFlags.check_mode )
					{
						CheckMode();
					}
					TweakTargetVoltsTC();
				}
				else if ( ISMODEVW(dfMode) )
				{
					TweakTargetVoltsVW();
				}
			}

			if ( dfStatus.vcom )
			{
				VCOM_Poll();
			}
		}

		if ( gFlags.tick_100hz )
		{
			// 100Hz
			gFlags.tick_100hz = 0;

			ResetWatchDog();

			if ( gFlags.read_battery )
			{
				gFlags.read_battery = 0;
			}

			TimedItems();
			SleepIfIdle();
			ReadBatteryVoltage();
			ReadBoardTemp();

			if ( gFlags.firing && BoardTemp >= 70 )
			{
				Overtemp();
			}

			if ( ISVTCDUAL )
			{
				BatteryChargeDual();
			}
			else if ( ISCUBOID || ISCUBO200 || ISRX200S || ISRX23 || ISRX300 )
			{
				BatteryCharge();
			}

			if (( gFlags.anim3d ) && ( Screen == 1 ) && ( !EditModeTimer ))
			{
				anim3d( 0 );
			}

			if ( Screen == 60 )
			{
				AnimateScreenSaver();
			}

			if ( gFlags.firing )
			{
				if ( gFlags.read_bir && ( FireDuration > 10 ) )
				{
					ReadInternalResistance();
				}

				if ( PreheatTimer && !--PreheatTimer )
				{
					uint16_t pwr;

					if ( dfMode == 6 )
					{
						pwr = dfSavedCfgPwr[ConfigIndex];
					}
					else
					{
						pwr = dfPower;
					}

					if ( pwr > BatteryMaxPwr )
					{
						gFlags.limit_power = 1;
						PowerScale = 100 * BatteryMaxPwr / pwr;
					}
					else
					{
						gFlags.limit_power = 0;
						PowerScale = 100;
					}
				}
			}

			if ( KeyTicks >= 5 )
			{
				KeyRepeat();
			}

			GetUserInput();
		}

		if ( gFlags.tick_10hz )
		{
			// 10Hz
			gFlags.tick_10hz = 0;

			DataFlashUpdateTick();
			LEDTimerTick();

			if ( gFlags.firing )
			{
				++FireDuration;

				if ( gFlags.monitoring )
				{
					Monitor();
				}
			}

			if ( ShowWeakBatFlag )
				--ShowWeakBatFlag;

			if ( ShowProfNum )
				--ShowProfNum;

			if ( !( gFlags.firing && ISMODETC(dfMode) ) )
			{
				DrawScreen();
			}

			if ( KeyTicks < 5 )
			{
				KeyRepeat();
			}
		}

		if ( gFlags.tick_5hz )
		{
			// 5Hz
			gFlags.tick_5hz = 0;

			if ( !gFlags.rtcinit && NumBatteries )
			{
				InitRTC();
			}

			if ( gFlags.firing )
			{
				if ( TargetVolts == 0 )
				{
					ProbeAtomizer();
				}
			}
			else
			{
				if
				(	!dfStatus.off
					&& Event == 0
					&& ( AtoProbeCount < 12 )
					&& ( Screen == 0 || Screen == 1 || Screen == 5 ) )
				{
					ProbeAtomizer();
				}
			}

			if ( IsClockOnScreen() )
			{
				static uint8_t u8Seconds = 61;
				S_RTC_TIME_DATA_T rtd;

				GetRTC( &rtd );

				if ( (uint8_t)rtd.u32Second != u8Seconds )
				{
					u8Seconds = (uint8_t)rtd.u32Second;
					gFlags.refresh_display = 1;
				}
			}
		}

		if ( gFlags.tick_2hz )
		{
			// 2Hz
			gFlags.tick_2hz = 0;

			gFlags.osc_1hz ^= 1;

			if ( gFlags.firing )
			{
				if ( ISMODETC(dfMode) )
				{
					DrawScreen();
				}
			}
			else
			{
				if
				(	!dfStatus.off
					&& Event == 0
					&& ( AtoProbeCount >= 12 )
					&& ( Screen == 0 || Screen == 1 || Screen == 5 ) )
				{
					ProbeAtomizer();
				}

				if ( gFlags.monitoring )
				{
					Monitor();
				}
			}
		}

		if ( gFlags.tick_1hz )
		{
			// 1Hz
			gFlags.tick_1hz = 0;

			if ( SplashTimer )
			{
				--SplashTimer;
				
				if ( !SplashTimer )
				{
					MainView();
				}
			}

			if ( !gFlags.firing && !dfStatus.off && !EditModeTimer )
			{
				if ( HideLogo )
				{
					if ( Screen == 1 )
					{
						--HideLogo;

						if ( !HideLogo )
						{
							gFlags.refresh_display = 1;
						}
					}
				}
			}
		}

		EventHandler();

	}
}