Beispiel #1
0
/**
  * @brief  MSC application Init.
  * @param  None
  * @retval None
  */
static void MSC_InitApplication(void)
{
  /* Configure Key Button */
  BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_GPIO);                
  
  /* Configure Joystick in EXTI mode */
  BSP_JOY_Init(JOY_MODE_EXTI);
    
  /* Initialize the LCD */
  BSP_LCD_Init();
  
  /* Initialize the LCD Log module */
  LCD_LOG_Init();
  
#ifdef USE_USB_HS 
  LCD_LOG_SetHeader((uint8_t *)" USB OTG HS MSC Host");
#else
  LCD_LOG_SetHeader((uint8_t *)" USB OTG FS MSC Host");
#endif
  
  LCD_UsrLog("USB Host library started.\n"); 
  
  /* Initialize menu and MSC process */
  USBH_UsrLog("Starting MSC Demo");
  Menu_Init();
}
Beispiel #2
0
/**
  * @brief  MSC application Init.
  * @param  None
  * @retval None
  */
static void MSC_InitApplication(void)
{
  /* Configure Key Button */
  BSP_PB_Init(BUTTON_WAKEUP, BUTTON_MODE_EXTI);
      
  /* Configure LED1 */
  BSP_LED_Init(LED1);
  
  /* Initialize the LCD */
  BSP_LCD_Init();
  
  /* LCD Layer Initialization */
  BSP_LCD_LayerDefaultInit(1, LCD_FB_START_ADDRESS); 
  
  /* Select the LCD Layer */
  BSP_LCD_SelectLayer(1);
  
  /* Enable the display */
  BSP_LCD_DisplayOn();
  
  /* Initialize the LCD Log module */
  LCD_LOG_Init();
  
  LCD_LOG_SetHeader((uint8_t *)" USB OTG FS MSC Host");
  LCD_UsrLog("USB Host library started.\n"); 
  
  /* Initialize menu and MSC process */
  Menu_Init();
}
Beispiel #3
0
// *************************** Capture image dimensions out of BMP**********
int main(void){
  TExaS_Init(SSI0_Real_Nokia5110_Scope);  // set system clock to 80 MHz
  Output_Init();
	ADC0_Init();
	DAC_Init();
	SysTick_Init();
	Menu_Init();
	Sound_Init();
	UART1_Init();
	
	Button0_Init();
	Timer0_Init(Play, 80000000/11025);	// 11.025 kHz 80000000/11025
	Timer1_Init(Master_Funk,  80000000/60);
	//Timer2_Init(SomeUART function, high speed); //for UART

 /* ST7735_FillScreen(0x0000);            // set screen to black
  ST7735_SetCursor(1, 1);
  ST7735_OutString("GAME OVER");
  ST7735_SetCursor(1, 2);
  ST7735_OutString("Nice try,");
  ST7735_SetCursor(1, 3);
  ST7735_OutString("Earthling!");
  ST7735_SetCursor(2, 4);
  LCD_OutDec(1234);	 */
  while(1){							
  } 
}
Beispiel #4
0
static void M_Menu_Login_Init( void )
{
	menucommon_t *menuitem;
	int yoffset = 0;

	menuitem = UI_InitMenuItem( "m_login_title_1", "WARSOW LOGIN", 0, yoffset, MTYPE_SEPARATOR, ALIGN_CENTER_TOP, uis.fontSystemBig, NULL );
	Menu_AddItem( &s_login_menu, menuitem );
	yoffset += trap_SCR_strHeight( menuitem->font );
	yoffset += trap_SCR_strHeight( menuitem->font );

	menuitem = UI_InitMenuItem( "m_login_email", "email", 0, yoffset, MTYPE_FIELD, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
	UI_SetupField( menuitem, "", MAX_EMAIL_LENGTH, 200 );
	Menu_AddItem( &s_login_menu, menuitem );
	yoffset += trap_SCR_strHeight( menuitem->font );

	menuitem = UI_InitMenuItem( "m_login_pass", "password", 0, yoffset, MTYPE_FIELD, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
	UI_SetupField( menuitem, "", MAX_PASS_LENGTH, 150 );
	UI_SetupFlags( menuitem, F_PASSWORD );
	Menu_AddItem( &s_login_menu, menuitem );
	yoffset += trap_SCR_strHeight( menuitem->font );

	yoffset += trap_SCR_strHeight( menuitem->font );

	menuitem = UI_InitMenuItem( "m_login_back", "back", -70, yoffset, MTYPE_ACTION, ALIGN_RIGHT_TOP, uis.fontSystemBig, M_genericBackFunc );
	Menu_AddItem( &s_login_menu, menuitem );

	menuitem = UI_InitMenuItem( "m_login_submit", "login", -25, yoffset, MTYPE_ACTION, ALIGN_CENTER_TOP, uis.fontSystemBig, M_Login_Login );
	Menu_AddItem( &s_login_menu, menuitem );

	menuitem = UI_InitMenuItem( "m_login_register", "register", 20, yoffset, MTYPE_ACTION, ALIGN_LEFT_TOP, uis.fontSystemBig, M_Login_Register );
	Menu_AddItem( &s_login_menu, menuitem );

	Menu_Center( &s_login_menu );
	Menu_Init( &s_login_menu, qfalse );
}
Beispiel #5
0
static void M_Custom_Init( void )
{
	menucommon_t *menuitem = NULL;
	int yoffset = 40;
	int i, count;

	s_custom_menu.nitems = 0;

	// parse the command line to create the buttons

	if( trap_Cmd_Argc() < 1 )
		return;

	// first one is always the tittle

	menuitem = UI_InitMenuItem( "m_custom_title1", trap_Cmd_Argv( 1 ), 0, yoffset, MTYPE_SEPARATOR, ALIGN_CENTER_TOP, uis.fontSystemBig, NULL );
	Menu_AddItem( &s_custom_menu, menuitem );
	yoffset += trap_SCR_strHeight( menuitem->font );

	yoffset += trap_SCR_strHeight( menuitem->font );

	// from now on each 2 new arguments define a new button
	for( i = 2, count = 0; i < trap_Cmd_Argc(); i += 2, count++ )
	{
		menuitem = UI_InitMenuItem( va( "m_custom_button%i", count ), trap_Cmd_Argv( i ), 0, yoffset, MTYPE_ACTION, ALIGN_CENTER_TOP, uis.fontSystemBig, M_Custom_ExecuteButton );
		menuitem->itemlocal = UI_CopyString( trap_Cmd_Argv( i + 1 ) );
		Menu_AddItem( &s_custom_menu, menuitem );
		yoffset += UI_SetupButton( menuitem, qtrue ) + UI_BUTTONBOX_VERTICAL_SPACE;
	}

	Menu_Center( &s_custom_menu );
	Menu_Init( &s_custom_menu, qtrue );
	Menu_SetStatusBar( &s_custom_menu, NULL );
}
void Paint(u32 X,u32 Y)
{
   extern u8 Page;
   if(Y<30)
   {
      if((X<50)&&(painted)){painted=0;Paint_Init();}
      else if(X<100)PenColor=1;
      else if(X<150)PenColor=2;
      else if(X<200)PenColor=3;
      else if(X<250)PenColor=4;
      else if(X<300)PenColor=5;
      else PenColor=6;
   }
   else if(X<50)
   {
      if(Y<100){shape=0;}
      else if(Y<150){shape=4;}
      else if(Y<200){shape=1;}
      else{shape=2;}
   }
   else if((X>60)&&(Y>55)&&(X<290)&&(Y<195))
   {  painted++;
      if(shape==0){TFT_Set_Pen(colors[PenColor],10);TFT_Circle(X,Y,1);}
      else if(shape==1){TFT_Set_Pen(colors[PenColor],3);TFT_Circle(X,Y,20);}
      else if(shape==2){TFT_Set_Pen(colors[PenColor],3); TFT_Rectangle(X,Y,X+20,Y+20);}
      else  {TFT_Set_Pen(colors[PenColor],20);TFT_Circle(X,Y,1);}
   }
   else if(Y>210 && X>270)
       {
          Page=0;
          Menu_Init();
       }
}
Beispiel #7
0
/**
  * @brief  Manages DS Menu Process.
  * @param  None
  * @retval None
  */
void DS_MenuProcess(void)
{       
  switch(Appli_state)
  {
  case APPLICATION_IDLE:
    break;
    
  case APPLICATION_MSC:
    MSC_MenuProcess();
    break;
    
  case APPLICATION_AUDIO:
    AUDIO_MenuProcess();
    break;
    
  case APPLICATION_HID:
    HID_MenuProcess();
    break;

  default:
	break;
  }
  if(Appli_state == APPLICATION_DISCONNECT)
  {
    Appli_state = APPLICATION_IDLE; 
    Menu_Init();
    /* Unlink the micro SD disk I/O driver */
    FATFS_UnLinkDriver(SD_Path);
    /* Unlink the USB disk I/O driver */
    FATFS_UnLinkDriver(USBDISKPath);
  }
} 
Beispiel #8
0
/**
  * @brief  MSC application Init.
  * @param  None
  * @retval None
  */
static void MSC_InitApplication(void)
{
  /* Configure KEY Button */
  BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_GPIO);                
  
  /* Configure Joystick in EXTI mode */
  BSP_JOY_Init(JOY_MODE_EXTI);
  
  /* Configure the LEDs */
  BSP_LED_Init(LED1);
  BSP_LED_Init(LED2);
  BSP_LED_Init(LED3);
  BSP_LED_Init(LED4);
  
  /* Initialize the LCD */
  BSP_LCD_Init();
  
  /* Initialize the LCD Log module */
  LCD_LOG_Init();
  
  LCD_LOG_SetHeader((uint8_t *)" USB OTG FS MSC Host");
  
  LCD_UsrLog("USB Host library started.\n"); 
  
  /* Start MSC Interface */
  USBH_UsrLog("Starting MSC Demo");
  
  Menu_Init();
}
Beispiel #9
0
/**
  * @brief  CDC application Init
  * @param  None
  * @retval None
  */
static void CDC_InitApplication(void)
{
  /* Configure LED1, LED2, LED3 and LED4 */
  BSP_LED_Init(LED1);
  BSP_LED_Init(LED2);
  BSP_LED_Init(LED3);
  BSP_LED_Init(LED4);
  
  /* Configure KEY Button */
  BSP_PB_Init(BUTTON_WAKEUP, BUTTON_MODE_GPIO);
  
  /* Initialize the LCD */
  BSP_LCD_Init();
  BSP_LCD_LayerDefaultInit(0, LCD_FB_START_ADDRESS);
  BSP_LCD_SelectLayer(0);
  
  /* Init the LCD Log module */
  LCD_LOG_Init();
  
  LCD_LOG_SetHeader((uint8_t *)" USB OTG FS CDC Host");
  LCD_UsrLog("USB Host library started.\n"); 
    
  /* Start CDC Interface */
  USBH_UsrLog("Starting CDC Demo");
  
  Menu_Init();
}
/**
  * @brief  MSC application Init.
  * @param  None
  * @retval None
  */
static void MSC_InitApplication(void)
{
  /* Configure Key Button */
  BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_GPIO);

  /* Configure Joystick in EXTI mode */
  BSP_JOY_Init(JOY_MODE_EXTI);

  /* Configure LED1, LED2, LED3 and LED4 */
  BSP_LED_Init(LED1);
  BSP_LED_Init(LED2);
  BSP_LED_Init(LED3);
  BSP_LED_Init(LED4);

  /* Initialize the LCD */
  BSP_LCD_Init();
  BSP_LCD_LayerDefaultInit(0, LCD_FB_START_ADDRESS);
  BSP_LCD_SelectLayer(0);

  /* Init the LCD Log module */
  LCD_LOG_Init();

#ifdef USE_USB_HS
  LCD_LOG_SetHeader((uint8_t *)" USB OTG HS MSC Host");
#else
  LCD_LOG_SetHeader((uint8_t *)" USB OTG FS MSC Host");
#endif

  LCD_UsrLog("USB Host library started.\n");

  /* Initialize menu and MSC process */
  USBH_UsrLog("Starting MSC Demo");
  Menu_Init();
}
Beispiel #11
0
int main(void)
{
  SystemInit();						// initialize MCU clocks and registers
  TM_DELAY_Init();					// initialize Delay library
  TM_DELAY_SetTime(0);				// Reset couter for systime
  Laser_GPIO_Conf();				// configure GPIO for laser control (to be able to enable/disable lasers via software
  TM_BKPSRAM_Init();				// initialize BKP RAM access library
  Laser_Update();			// load laser statuses saved in BKP RAM
  TM_USART_Init(OUTPUT_USART, OUTPUT_USART_PINS, OUTPUT_USART_SPEED);		// initialize UART used for collected Data output
  TM_USART_Init(MENU_USART, MENU_USART_PINS, MENU_USART_SPEED);				// initialize UART used for configuration
  TM_RTC_Init(TM_RTC_ClockSource_External);									// initialize RTC library
  TM_GPIO_Init(GPIOD, GPIO_Pin_8, TM_GPIO_Mode_OUT, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_Low); // configure GPIO for GSM status indication (RED LED)
  TM_GPIO_Init(GPIOD, GPIO_Pin_9, TM_GPIO_Mode_OUT, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_Low); // configure GPIO for GSM status indication (GREEN LED)
  Laser_ADC_Init();					// initialize ADC peripherals
  Menu_Init();						// initialize CLI library
  sfpInit();						// configure GPIO for SFP modules
  gsm_Init();						// initialize GSM module


  /* configure and initialize Ethernet hardware and LwIP stack */

  ETH_BSP_Config();					// configure ETH GPIOs
  printf("Ethernet MAC and PHY configured successfully!\n");
  LwIP_Init();						// start LwIP stack
  printf("LwIP stack initialized successfully!\n");
  UDP_Server_Init();				// start UDP Server
  printf("UDP Server initialized successfully!\n");

  //start periodic tasks

  /* GSM Status update "task" */
  GSM_Status_Update_Timer = TM_DELAY_TimerCreate(GSM_CHECK_INTERVAL, 1, 1, GSM_Status_Update_Timer_Task, NULL);
  printf("GSM status check task created!\n");
  /* Print results from remote devices "task" */
  Print_Results_Timer = TM_DELAY_TimerCreate(DATA_OUT_INTERVAL, 1, 1, Print_Results_Timer_Task, NULL);
  printf("Print collected data task created!\n");
  /* LaserLock status update "task" */
  LaserLock_Timer = TM_DELAY_TimerCreate(1000, 1, 1, LaserLock_Timer_Task, NULL);
  printf("Laser lock check task created!\n");

  while (1) {
	  /* CLI menu update */
	  Menu_Update();
      /* check if any packet received */
	  if (ETH_CheckFrameReceived())
	  {
		  /* process received ethernet packet */
		  LwIP_Pkt_Handle();
	  }
    /* handle periodic timers for LwIP */
    LwIP_Periodic_Handle(LocalTime);
    /* update laser statuses */
    Laser_Update();
    /* remove SMS messages which were read by system */
    delete_read_gsm_messages();
  }
} 
Beispiel #12
0
static void M_MainInit( void )
{
	int yoffset = 0;
	menucommon_t *menuitem;

	s_main_menu.nitems = 0;

	menuitem = UI_InitMenuItem( "m_main_title1", "MAIN MENU", 0, yoffset, MTYPE_SEPARATOR, ALIGN_CENTER_TOP, uis.fontSystemBig, NULL );
	Menu_AddItem( &s_main_menu, menuitem );
	yoffset += trap_SCR_strHeight( menuitem->font );

	yoffset += trap_SCR_strHeight( menuitem->font );

	menuitem = UI_InitMenuItem( "m_main_join_game", "find a game", 0, yoffset, MTYPE_ACTION, ALIGN_CENTER_TOP, uis.fontSystemBig, JoinNetworkServerFunc );
	Menu_AddItem( &s_main_menu, menuitem );
	yoffset += UI_SetupButton( menuitem, qtrue ) + UI_BUTTONBOX_VERTICAL_SPACE;

#ifdef MATCHMAKER_SUPPORT
	menuitem = UI_InitMenuItem( "m_main_matchmaker", "match maker", 0, yoffset, MTYPE_ACTION, ALIGN_CENTER_TOP, uis.fontSystemBig, MatchMakerFunc );
	Menu_AddItem( &s_main_menu, menuitem );
	yoffset += trap_SCR_strHeight( menuitem->font );
#endif

	menuitem = UI_InitMenuItem( "m_main_tutorials", "tutorials", 0, yoffset, MTYPE_ACTION, ALIGN_CENTER_TOP, uis.fontSystemBig, TutorialsFunc );
	Menu_AddItem( &s_main_menu, menuitem );
	yoffset += UI_SetupButton( menuitem, qtrue ) + UI_BUTTONBOX_VERTICAL_SPACE;

	menuitem = UI_InitMenuItem( "m_main_setup", "setup", 0, yoffset, MTYPE_ACTION, ALIGN_CENTER_TOP, uis.fontSystemBig, SetUpMenuFunc );
	Menu_AddItem( &s_main_menu, menuitem );
	yoffset += UI_SetupButton( menuitem, qtrue ) + UI_BUTTONBOX_VERTICAL_SPACE;

	menuitem = UI_InitMenuItem( "m_main_start_server", "start local game", 0, yoffset, MTYPE_ACTION, ALIGN_CENTER_TOP, uis.fontSystemBig, StartNetworkServerFunc );
	Menu_AddItem( &s_main_menu, menuitem );
	yoffset += UI_SetupButton( menuitem, qtrue ) + UI_BUTTONBOX_VERTICAL_SPACE;

	menuitem = UI_InitMenuItem( "m_main_demos", "demos", 0, yoffset, MTYPE_ACTION, ALIGN_CENTER_TOP, uis.fontSystemBig, DemosMenuFunc );
	Menu_AddItem( &s_main_menu, menuitem );
	yoffset += UI_SetupButton( menuitem, qtrue ) + UI_BUTTONBOX_VERTICAL_SPACE;

	menuitem = UI_InitMenuItem( "m_main_mods", "mods", 0, yoffset, MTYPE_ACTION, ALIGN_CENTER_TOP, uis.fontSystemBig, ModsMenuFunc );
	Menu_AddItem( &s_main_menu, menuitem );
	yoffset += UI_SetupButton( menuitem, qtrue ) + UI_BUTTONBOX_VERTICAL_SPACE;

	menuitem = UI_InitMenuItem( "m_main_console", "console", 0, yoffset, MTYPE_ACTION, ALIGN_CENTER_TOP, uis.fontSystemBig, ConsoleFunc );
	Menu_AddItem( &s_main_menu, menuitem );
	yoffset += UI_SetupButton( menuitem, qtrue ) + UI_BUTTONBOX_VERTICAL_SPACE;

	menuitem = UI_InitMenuItem( "m_main_quit", "quit", 0, yoffset, MTYPE_ACTION, ALIGN_CENTER_TOP, uis.fontSystemBig, QuitMenuFunc );
	Menu_AddItem( &s_main_menu, menuitem );
	yoffset += UI_SetupButton( menuitem, qtrue ) + UI_BUTTONBOX_VERTICAL_SPACE;

	Menu_Center( &s_main_menu );
	Menu_Init( &s_main_menu, qtrue );

	Menu_SetStatusBar( &s_main_menu, main_menu_statusbar[0] ? main_menu_statusbar : NULL );
}
/**
  * @brief  Returns from Send Menu 
  * @param  None
  * @retval None
  */
static void ReturnFromSendMenu(void)
{
  CdcDemo.state = CDC_DEMO_IDLE;
  CdcDemo.select = 0; 
  
  /* Restore main menu */
  LCD_ClearTextZone();
  LCD_LOG_UpdateDisplay();
  Menu_Init();  
}
Beispiel #14
0
/*
===============
Menu_New
===============
*/
void Menu_New(int handle)
{
	menuDef_t *menu = &Menus[menuCount];

	if (menuCount < MAX_MENUS)
	{
		Menu_Init(menu);
		if (Menu_Parse(handle, menu))
		{
			Menu_PostParse(menu);
			menuCount++;
		}
	}
}
/**
  * @brief  CDC application Init.
  * @param  None
  * @retval None
  */
static void CDC_InitApplication(void)
{
  /* Configure Key Button */
  BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_EXTI); 
  
  /* Configure Joystick in EXTI mode */
  BSP_JOY_Init(JOY_MODE_EXTI);
  
  /* Configure LED1, LED2, LED3 and LED4 */
  BSP_LED_Init(LED1);
  BSP_LED_Init(LED2);
  BSP_LED_Init(LED3);
  BSP_LED_Init(LED4);
  
  /* Initialize the LCD */
  BSP_LCD_Init();
  
  /* LCD Layer Initialization */
  BSP_LCD_LayerDefaultInit(1, LCD_FB_START_ADDRESS); 
  
  /* Selects the LCD Layer */
  BSP_LCD_SelectLayer(1);
  
  /* Enables the display */
  BSP_LCD_DisplayOn();
  
  /* Initialize the LCD Log module */
  LCD_LOG_Init();
  
#ifdef USE_USB_HS 
  LCD_LOG_SetHeader((uint8_t *)" USB OTG HS CDC Host");
#else
  LCD_LOG_SetHeader((uint8_t *)" USB OTG FS CDC Host");
#endif
  
  LCD_UsrLog("USB Host library started.\n"); 
  
  /* Start CDC Interface */
  USBH_UsrLog("Starting CDC Demo");
  
  Menu_Init();
  /* Initialize microSD */
  if (SD_StorageInit() == 0)
  {
    SD_StorageParse();
  }
}
Beispiel #16
0
int exec_cfg_command(const char *argument)
{
    const struct cfgmenu *p_menu, *p_item;
    const void *v;

    // is it a plugin related command?
    if (0 == memicmp(argument, "plugin.", 7)) {
        if (0 == PluginManager_handleBroam(argument+7))
            return 0;
        Menu_Update(MENU_UPD_CONFIG);
        return 1;
    }

    // search the item in above structures
    v = exec_internal_broam(argument, cfg_main, &p_menu, &p_item);
    if (NULL == p_item)
        return 0;

    // now take care for some item-specific refreshes
    if (v == &Settings_toolbar.enabled) {
        if (Settings_toolbar.enabled)
            beginToolbar(hMainInstance);
        else
            endToolbar(hMainInstance);
        Menu_Update(MENU_UPD_CONFIG);
    } else if (v == &Settings_menu.sortByExtension
            || v == &Settings_menu.showHiddenFiles) {
        PostMessage(BBhwnd, BB_REDRAWGUI, BBRG_MENU|BBRG_FOLDER, 0);
    } else if (v == &Settings_smartWallpaper) {
        Desk_Reset(true);
    } else if (v == &Settings_menu.dropShadows) {
        Menu_Exit(), Menu_Init();
    } else if (v == &Settings_UTF8Encoding) {
        Workspaces_GetCaptions();
        Tray_SetEncoding();
        PostMessage(BBhwnd, BB_REDRAWGUI, BBRG_MENU|BBRG_FOLDER, 0);
    }

    if (p_menu == cfg_sub_graphics || v == &Settings_UTF8Encoding)
        PostMessage(BBhwnd, BB_RECONFIGURE, 0, 0); // full reconfigure
    else
        PostMessage(BBhwnd, BB_RECONFIGURE, 1, 0); // bypass plugins

    return 1;
}
Beispiel #17
0
	menuDef_t *Interface_CreateMenu(float x, float y, float w, float h, const char *name){
		menuDef_t *menu = &Menus[menuCount];

		if ( menuCount < MAX_MENUS ) {
			Menu_Init( menu );
			menu->window.rect.x = x;
			menu->window.rect.y = y;
			menu->window.rect.w = w;
			menu->window.rect.h = h;
			//Menu_PostParse( menu );
			menu->id = menuCount++;
			menu->uselua = qfalse;
			menu->itemCount = 0;
			menu->window.name = BG_StringAlloc( name );
			return menu;
		}
		return NULL;
	}
Beispiel #18
0
void Menu()
{
	if(!menuHasInit)
	{
		Menu_Init(); // One-time initialization of menu state.
		menuHasInit = true;
	}
	
	Menu_Input();
	Menu_Update();
	Menu_Draw();
	
	menuframeCounter++; // Update frame counter for this state, resetting whenever it hits 32.
	if(menuframeCounter > 32)
	{
		menuframeCounter = 0;
	}
}
Beispiel #19
0
/**
  * @brief  MSC application Init.
  * @param  None
  * @retval None
  */
static void MSC_InitApplication(void)
{
  /* Configure KEY Button */
  BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_GPIO);                
  
  /* Configure Joystick in EXTI mode */
  BSP_JOY_Init(JOY_MODE_EXTI);
  
  /* Configure the LEDs */
  BSP_LED_Init(LED1);
  BSP_LED_Init(LED2);
  BSP_LED_Init(LED3);
  BSP_LED_Init(LED4);
  
  /* Initialize the LCD */
  BSP_LCD_Init();
  
  /* LCD Layer Initialisation */
  BSP_LCD_LayerDefaultInit(1, LCD_FB_START_ADDRESS); 
  
  /*Selects the LCD Layer*/
  BSP_LCD_SelectLayer(1);
  
  /*Enables the display*/
  BSP_LCD_DisplayOn();
  
  /*Init the LCD Log module*/
  LCD_LOG_Init();
  
#ifdef USE_USB_HS 
  LCD_LOG_SetHeader((uint8_t *)" USB OTG HS MSC Host");
#else
  LCD_LOG_SetHeader((uint8_t *)" USB OTG FS MSC Host");
#endif
  
  LCD_UsrLog("USB Host library started.\n"); 
  
  /* Start MSC Interface */
  USBH_UsrLog("Starting MSC Demo");
  
  Menu_Init();
}
Beispiel #20
0
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
 int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       file (startup_stm32f4xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f4xx.c file
     */  
  /* Setup STM32 system (clock, PLL and Flash configuration) */
  SystemInit();
  
  /* GLCD init */
  GLCD_PowerUpInit((pInt8U)IAR_Logo.pPicStream);
  GLCD_Backlight(BACKLIGHT_ON);
  DelayResolution100us(5000);

  GLCD_PowerUpInit((pInt8U)STM32_Logo.pPicStream);
  GLCD_SetFont(&Terminal_9_12_6,0x000F00,0x00FF0);
  GLCD_TextSetPos(4,6);
  GLCD_print("STM32F407ZG-SK");
  GLCD_Backlight(BACKLIGHT_ON);
  
  NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
    
  /* Menu init */
  Menu_Init();
 
  Joystick_Init();
 
   
  DisplayMenu();
  
   
  /* Infinite loop */
  while (1)
  {
  }	
}
Beispiel #21
0
void TaskFor_SetWork(void *Tags)
{
	uint16 i;
	BOOL WorkTrue=False;
	Tos_ArrayMessage Msg[2];
  MGUI_KeyMsg *KeyMsg,KeyMsgBuf[2];	
	POWER_EN;//OLED电源
	LAMP9_ON;//料罐通电                                                                                                        ;
	LAMP10_ON;//阀门开到位
	LAMP11_ON;//阀门关到位
	LAMP12_ON;//密封到位
	LAMP13_ON;//通信
	LAMP14_OFF;//电源
	LAMP2_ON;//启动
	LAMP3_ON;//强制启动
	Load_Configs();
	Menu_Init(&MenuHome[0]);
	KeyBoard_Configuration();
	Tos_TaskGetHandKey();
	SetKey_WorkMode(KWM_Null);
  Set_Brightness();
  for(i=0;i<2;i++)Msg[i].Qmsg_Addr=&KeyMsgBuf[i];
	Tos_TaskCreateQmsg(&Msg[0],2);
	Run_Value.Status="";
	while(1)
	{
re:		 if(KeyMsg->KeyValue==Key_4)GoTo_Stop();
	 if(WorkTrue==True){Draw_Work();}
		 if(WorkTrue==False){Draw_Home();}
		 SSD1325_OutBuffer();
		 Tos_TaskDelay(1);
      KeyMsg=MUI_GetKey(0);
		 if(KeyMsg)
		 {
			if(KeyMsg->KeyType==KeyBoard_Null)goto re;
			if(WorkTrue==True)
			 {
					if(KeyMsg->KeyType==KeyBoard_Hand)
				{
				Beep_WithKey();
					Run_Value.HeartBeat=0;
					if(KeyMsg->KeyValue==Key_A){Run_Value.Status="开阀";Send_ButtonCommand(OC_UpDoorOpen);}
					if(KeyMsg->KeyValue==Key_B){Run_Value.Status="关阀";Send_ButtonCommand(OC_UpDoorClose);}
					if(KeyMsg->KeyValue==Key_1){Run_Value.Status="开阀";Send_ButtonCommand(OC_DownDoorOpen);}
					if(KeyMsg->KeyValue==Key_3){Run_Value.Status="关阀";Send_ButtonCommand(OC_DownDoorClose);}
					if(KeyMsg->KeyValue==Key_5)TankRelieveClick();
					if(KeyMsg->KeyValue==Key_C)TankPowerClick();
					if(KeyMsg->KeyValue==Key_D){Run_Value.Status="启动";Send_ButtonCommand(OC_Start);Printf_Waiting(String_Wating,10);}//启动
					if(KeyMsg->KeyValue==Key_E){Run_Value.Status="停止";Send_ButtonCommand(OC_Stop);WorkTrue=False;Menu_Init(&MenuHome[0]);Printf_Waiting(String_Wating,10);}//停车
				}
				if(KeyMsg->KeyType==KeyBoard_RockerBar)
				{
					Beep_WithKey();
					Run_Value.HeartBeat=0;
					if(KeyMsg->KeyValue==Key_X)if((KeyMsg->KeyTime<0)&(KeyMsg->KeyTime>-3)){Run_Value.Status="前进";Send_ButtonCommand(OC_TankForward1);}
					if(KeyMsg->KeyValue==Key_X)if((KeyMsg->KeyTime<-2)&(KeyMsg->KeyTime>-5)){Run_Value.Status="前进";Send_ButtonCommand(OC_TankForward2);}
					if(KeyMsg->KeyValue==Key_X)if((KeyMsg->KeyTime>0)&(KeyMsg->KeyTime<3)){Run_Value.Status="后退";Send_ButtonCommand(OC_TankBack1);}
					if(KeyMsg->KeyValue==Key_X)if((KeyMsg->KeyTime>2)&(KeyMsg->KeyTime<5)){Run_Value.Status="后退";Send_ButtonCommand(OC_TankBack2);}
					if(KeyMsg->KeyValue==Key_Y)if((KeyMsg->KeyTime<0)){Run_Value.Status="点动";Send_ButtonCommand(OC_TankBackDot);}
				if(KeyMsg->KeyValue==Key_Y)if((KeyMsg->KeyTime>0)){Run_Value.Status="点动";Send_ButtonCommand(OC_TankForwardDot);}
				}
				if(KeyMsg->KeyType==KeyBoard_Null)
				{

				}
			 }
			 if(WorkTrue==False)
			 {
				 if(KeyMsg->KeyType==KeyBoard_Hand)
				{
					Beep_WithKey();
					if(KeyMsg->KeyValue==Key_1){if(PageMenu.DeepRecord[PageMenu.Index])PageMenu.DeepRecord[PageMenu.Index]--;}
					if(KeyMsg->KeyValue==Key_3){if(PageMenu.OptionLength>PageMenu.DeepRecord[PageMenu.Index])PageMenu.DeepRecord[PageMenu.Index]++;}
					if(KeyMsg->KeyValue==Key_A)PageMenu.DeepRecord[PageMenu.Index]=0;
					if(KeyMsg->KeyValue==Key_B)Enter_Menu();
					if(KeyMsg->KeyValue==Key_D){Run_Value.Status="启动";WorkTrue=True;Menu_Init(&MenuWork[0]);Send_ButtonCommand(OC_Start);StartCheck();}//启动
					if(KeyMsg->KeyValue==Key_E){Send_ButtonCommand(OC_Stop);}//停车
				}
				if(KeyMsg->KeyType==KeyBoard_RockerBar)
				{
					Beep_WithKey();
					if(KeyMsg->KeyValue==Key_X)Run_Value.HandSpeedX=KeyMsg->KeyTime;
					if(KeyMsg->KeyValue==Key_Y)Run_Value.HandSpeedY=KeyMsg->KeyTime;
					if(KeyMsg->KeyValue==Key_X)if(KeyMsg->KeyTime<0){if(PageMenu.DeepRecord[PageMenu.Index])PageMenu.DeepRecord[PageMenu.Index]--;}
					if(KeyMsg->KeyValue==Key_X)if(KeyMsg->KeyTime>0){if(PageMenu.OptionLength>PageMenu.DeepRecord[PageMenu.Index])PageMenu.DeepRecord[PageMenu.Index]++;}
					if(KeyMsg->KeyValue==Key_Y)if(KeyMsg->KeyTime<0)PageMenu.DeepRecord[PageMenu.Index]=0;
					if(KeyMsg->KeyValue==Key_Y)if(KeyMsg->KeyTime>0)Enter_Menu();
					
				 }
			 }
		}
		
	}
}
Beispiel #22
0
static qboolean StartServer_MenuInit( void )
{
    menucommon_t *menuitem_settings_background;
    menucommon_t *menuitem, *col_title;
    static char *skill_names[] = { "easy", "normal", "hard", 0 };
    static char *sortmethod_names[] = { "file name", "title", 0 };
    cvar_t *cvar_lastmap;
    int maxclients;
    int scrollwindow_width, xoffset, yoffset = 0; //leave some room for preview pic

    trap_Cvar_Get( "ui_maplist_sortmethod", "1", CVAR_ARCHIVE );

    // create a list with the installed gametype names
    ui_gametype_names = trap_Cvar_Get( "ui_gametype_names", ";", CVAR_NOSET );
    if( !UI_CreateFileNamesListCvar( ui_gametype_names, "progs/gametypes", ".gt", ';' ) )
        trap_Cvar_ForceSet( "ui_gametype_names", "dm;" );

    if( uis.vidWidth < 800 )
        scrollwindow_width = uis.vidWidth * 0.85;
    else if( uis.vidWidth < 1024 )
        scrollwindow_width = uis.vidWidth * 0.75;
    else
        scrollwindow_width = uis.vidWidth * 0.45;
    xoffset = scrollwindow_width / 2;

    // convert to item names format
    M_StartServer_MakeGametypesNames( ui_gametype_names->string );

    s_startserver_menu.nitems = 0;

    menuitem = UI_InitMenuItem( "m_startserver_title1", "SERVER SETUP", 0, yoffset, MTYPE_SEPARATOR, ALIGN_CENTER_TOP, uis.fontSystemBig, NULL );
    Menu_AddItem( &s_startserver_menu, menuitem );
    yoffset += trap_SCR_strHeight( menuitem->font );

    // separator
    yoffset += trap_SCR_strHeight( menuitem->font );

    menuitem = UI_InitMenuItem( "m_startserver_map", "initial map", 0, yoffset, MTYPE_SEPARATOR, ALIGN_CENTER_TOP, uis.fontSystemMedium, NULL );
    Menu_AddItem( &s_startserver_menu, menuitem );
    yoffset += trap_SCR_strHeight( menuitem->font );

    yoffset += trap_SCR_strHeight( menuitem->font ) * 0.5;

    // order type
    menuitem = col_title = UI_InitMenuItem( "m_startserver_order_title", "order by: ", -xoffset - LCOLUMN_OFFSET / 2, yoffset, MTYPE_SEPARATOR, ALIGN_LEFT_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_startserver_menu, menuitem );

    menuitem = UI_InitMenuItem( "m_startserver_order", NULL, col_title->x + trap_SCR_strWidth( col_title->title, uis.fontSystemSmall, 0 ),
                                yoffset, MTYPE_SPINCONTROL, ALIGN_LEFT_TOP, uis.fontSystemSmall, StartServer_UpdateOrderMethod );
    UI_SetupSpinControl( menuitem, sortmethod_names, trap_Cvar_Value( "ui_maplist_sortmethod" ) );
    Menu_AddItem( &s_startserver_menu, menuitem );

    menuitem = UI_InitMenuItem( "m_startserver_mappic", NULL, xoffset - MAPPIC_WIDTH - 8, yoffset, MTYPE_SEPARATOR, ALIGN_CENTER_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_startserver_menu, menuitem );

    cvar_lastmap = trap_Cvar_Get( "ui_startserver_lastselectedmap", "", CVAR_NOSET );
    MapsList_CreateItems( cvar_lastmap->string );
    MapsList_ChooseMap( NULL );

    yoffset += trap_SCR_strHeight( menuitem->font );
    yoffset = MapsList_CreateScrollbox( scrollwindow_width, yoffset );

    yoffset += trap_SCR_strHeight( menuitem->font ) * 0.5;

    menuitem_settings_background = UI_InitMenuItem( "m_startserver_settings_back", "", -xoffset, yoffset, MTYPE_SEPARATOR, ALIGN_LEFT_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_startserver_menu, menuitem_settings_background );
    // create an associated picture to the items to act as window background
    menuitem = menuitem_settings_background;
    menuitem->ownerdraw = M_StartServer_DrawSettingsBox;
    menuitem->pict.shader = uis.whiteShader;
    menuitem->pict.shaderHigh = NULL;
    Vector4Copy( colorMdGrey, menuitem->pict.color );
    menuitem->pict.color[3] = 0;
    menuitem->pict.yoffset = 0;
    menuitem->pict.xoffset = 0;
    menuitem->pict.width = scrollwindow_width;
    menuitem->pict.height = yoffset + menuitem->pict.yoffset; // will be set later

    yoffset += trap_SCR_strHeight( menuitem->font );

    // g_gametype
    m_gametype = mapList_suggested_gametype ? mapList_suggested_gametype : SuggestGameType( NULL );
    menuitem = m_gametypes_item = UI_InitMenuItem( "m_startserver_gametype", "gametype", -130, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, M_GametypeFunc );
    menuitem->statusbar = "select the server gametype";
    UI_SetupSpinControl( menuitem, startserver_gametype_names, m_gametype );
    Menu_AddItem( &s_startserver_menu, menuitem );
    //yoffset += trap_SCR_strHeight( menuitem->font );

    // g_timelimit
    menuitem = UI_InitMenuItem( "m_startserver_timelimit", "time limit", 100, yoffset, MTYPE_FIELD, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    menuitem->statusbar = "0 = no limit";
    UI_SetupField( menuitem, trap_Cvar_String( "g_timelimit" ), 6, -1 );
    UI_SetupFlags( menuitem, F_NUMBERSONLY );
    Menu_AddItem( &s_startserver_menu, menuitem );
    yoffset += trap_SCR_strHeight( menuitem->font );

    // sv_skilllevel
    menuitem = UI_InitMenuItem( "m_startserver_skill", "skill level", -130, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, M_SkillLevelFunc );
    m_skill = trap_Cvar_Value( "sv_skilllevel" );
    menuitem->statusbar = "select server skill level";
    UI_SetupSpinControl( menuitem, skill_names, m_skill );
    Menu_AddItem( &s_startserver_menu, menuitem );
    //yoffset += trap_SCR_strHeight( menuitem->font );

    // g_scorelimit
    menuitem = UI_InitMenuItem( "m_startserver_scorelimit", "score limit", 100, yoffset, MTYPE_FIELD, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    menuitem->statusbar = "0 = no limit";
    UI_SetupField( menuitem, trap_Cvar_String( "g_scorelimit" ), 6, -1 );
    UI_SetupFlags( menuitem, F_NUMBERSONLY );
    Menu_AddItem( &s_startserver_menu, menuitem );
    yoffset += trap_SCR_strHeight( menuitem->font );

    // sv_cheats
    menuitem = UI_InitMenuItem( "m_startserver_cheats", "cheats", -130, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, M_CheatsFunc );
    m_cheats = trap_Cvar_Value( "sv_cheats" );
    menuitem->statusbar = "enable cheats on the server";
    UI_SetupSpinControl( menuitem, offon_names, m_cheats );
    Menu_AddItem( &s_startserver_menu, menuitem );
    //yoffset += trap_SCR_strHeight( menuitem->font );

    // g_numbots
    menuitem = UI_InitMenuItem( "m_startserver_numbots", "number of bots", 100, yoffset, MTYPE_FIELD, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    menuitem->statusbar = "Can't be more than maxclients";
    UI_SetupField( menuitem, trap_Cvar_String( "g_numbots" ), 6, -1 );
    UI_SetupFlags( menuitem, F_NUMBERSONLY );
    Menu_AddItem( &s_startserver_menu, menuitem );
    yoffset += trap_SCR_strHeight( menuitem->font );

    // g_instagib
    menuitem = UI_InitMenuItem( "m_startserver_instagib", "instagib", -130, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, M_InstagibFunc );
    m_instagib = trap_Cvar_Value( "g_instagib" );
    menuitem->statusbar = "enable instagib mode";
    UI_SetupSpinControl( menuitem, offon_names, m_instagib );
    Menu_AddItem( &s_startserver_menu, menuitem );
    //yoffset += trap_SCR_strHeight( menuitem->font );

    // sv_maxclients
    /*
    ** maxclients determines the maximum number of players that can join
    ** the game.  If maxclients is only "1" then we should default the menu
    ** option to 8 players, otherwise use whatever its current value is.
    */
    maxclients = trap_Cvar_Value( "sv_maxclients" ) <= 1 ? 8 : trap_Cvar_Value( "sv_maxclients" );
    menuitem = UI_InitMenuItem( "m_startserver_maxplayers", "max players", 100, yoffset, MTYPE_FIELD, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    UI_SetupField( menuitem, va( "%i", maxclients ), 6, -1 );
    UI_SetupFlags( menuitem, F_NUMBERSONLY );
    Menu_AddItem( &s_startserver_menu, menuitem );
    yoffset += trap_SCR_strHeight( menuitem->font );

    // sv_public
    menuitem = UI_InitMenuItem( "m_startserver_public", "public", -130, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, M_PublicFunc );
    m_public = trap_Cvar_Value( "sv_public" );
    menuitem->statusbar = "announce this server to metaservers";
    UI_SetupSpinControl( menuitem, offon_names, m_public );
    Menu_AddItem( &s_startserver_menu, menuitem );
    //yoffset += trap_SCR_strHeight( menuitem->font );

    // sv_hostname
    menuitem = UI_InitMenuItem( "m_startserver_hostname", "server name", 100, yoffset, MTYPE_FIELD, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    UI_SetupField( menuitem, trap_Cvar_String( "sv_hostname" ), 14, -1 );
    Menu_AddItem( &s_startserver_menu, menuitem );
    yoffset += trap_SCR_strHeight( menuitem->font );

    yoffset += trap_SCR_strHeight( menuitem->font ) * 0.5;

    // here ends the settings background, set it's image height now
    menuitem_settings_background->pict.height = yoffset - menuitem_settings_background->pict.height + ( 0.5 * trap_SCR_strHeight( menuitem->font ) );

    yoffset += trap_SCR_strHeight( menuitem->font );

    // begin button
    menuitem = UI_InitMenuItem( "m_startserver_begin", "begin", 16, yoffset, MTYPE_ACTION, ALIGN_LEFT_TOP, uis.fontSystemBig, StartServerActionFunc );
    Menu_AddItem( &s_startserver_menu, menuitem );
    UI_SetupButton( menuitem, qtrue );

    menuitem = UI_InitMenuItem( "m_startserver_back", "back", -16, yoffset, MTYPE_ACTION, ALIGN_RIGHT_TOP, uis.fontSystemBig, M_genericBackFunc );
    Menu_AddItem( &s_startserver_menu, menuitem );
    yoffset += UI_SetupButton( menuitem, qtrue ) + UI_BUTTONBOX_VERTICAL_SPACE;

    Menu_Center( &s_startserver_menu );
    s_startserver_menu.x = ( uis.vidWidth / 2 );
    Menu_Init( &s_startserver_menu, qfalse );
    return qtrue;
}
Beispiel #23
0
/*******************************************************************************
* Function Name  : Demo_Init
* Description    : Initializes the demonstration application.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void Demo_Init(void)
{
  /* RCC system reset(for debug purpose) */
  RCC_DeInit();

  /* Enable HSE */
  RCC_HSEConfig(RCC_HSE_ON);

  /* Wait till HSE is ready */
  HSEStartUpStatus = RCC_WaitForHSEStartUp();

  if(HSEStartUpStatus == SUCCESS)
  {
    /* Enable Prefetch Buffer */
    FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);

    /* Flash 2 wait state */
    FLASH_SetLatency(FLASH_Latency_2);
 	
    /* HCLK = SYSCLK */
    RCC_HCLKConfig(RCC_SYSCLK_Div1); 
  
    /* PCLK2 = HCLK */
    RCC_PCLK2Config(RCC_HCLK_Div1); 

    /* PCLK1 = HCLK/2 */
    RCC_PCLK1Config(RCC_HCLK_Div2);

    /* PLLCLK = 8MHz * 9 = 72 MHz */
    RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);

    /* Enable PLL */ 
    RCC_PLLCmd(ENABLE);

    /* Wait till PLL is ready */
    while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
    {
    }

    /* Select PLL as system clock source */
    RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);

    /* Wait till PLL is used as system clock source */
    while(RCC_GetSYSCLKSource() != 0x08)
    {
    }
  }

  /* Enable GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG and AFIO clocks */
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |RCC_APB2Periph_GPIOC 
         | RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE | RCC_APB2Periph_GPIOF | RCC_APB2Periph_GPIOG 
         | RCC_APB2Periph_AFIO, ENABLE);
  
  /* TIM1 Periph clock enable */
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1, ENABLE);
 
/*------------------- Resources Initialization -----------------------------*/
  /* GPIO Configuration */
  GPIO_Config();

  /* Interrupt Configuration */
  InterruptConfig();

  /* Configure the systick */    
  SysTick_Configuration();

/*------------------- Drivers Initialization -------------------------------*/
  /* Initialize the LEDs toogling */
  LedShow_Init();

  /* Initialize the Low Power application */
  LowPower_Init();

  /* Initialize the LCD */
  STM3210E_LCD_Init();

  /* Clear the LCD */ 
  LCD_Clear(White);
  
  /* If HSE is not detected at program startup */
  if(HSEStartUpStatus == ERROR)
  {
    /* Generate NMI exception */
    SCB->ICSR |= SCB_ICSR_NMIPENDSET;
  }  
   
  /* Checks the availability of the bitmap files */
  CheckBitmapFilesStatus();
  
  /* Display the STM32 introduction */
  STM32Intro();

  /* Clear the LCD */ 
  LCD_Clear(White);

  /* Initialize the Calendar */
  Calendar_Init();

  /* Enable Leds toggling */
  LedShow(ENABLE);
  
  /* Initialize the Low Power application*/ 
  LowPower_Init();

  /* Set the LCD Back Color */
  LCD_SetBackColor(Blue);

  /* Set the LCD Text Color */
  LCD_SetTextColor(White);
  
  /* Initialize the Menu */
  Menu_Init();

  /* Display the main menu icons */
  ShowMenuIcons();
}
Beispiel #24
0
int main(void)
{

	SystemClockSetup(ClockSource_EX50M,CoreClock_100M);
	DelayInit();
	OLED_Init();
	Sd_Init();
	chuinit_Init();
	DataInit();
	Data_Uart_Init();
	
	while(1)
	{
		Menu_Init();
		//ccd
		while(Flag == 1)
		{
			if(TIME1flag_20ms == 1)
			{
				TIME1flag_20ms = 0;
				ImageCapture(Pixel);
//				Sd_X();
//				Sd_D();
//				UART_Send_Con();
				erzhi();
				LB();
				oled_collect();
				oled_show();
			}
			CCD_HeiXian();
			OLED_ZhongXian();
			OLED_Write_Num3(4,0,Center);
			OLED_Write_Num3(0,0,Left);
			OLED_Write_Num3(9,0,Right);
			if(Key_1 == 0) //??
			{
				DelayMs(100);
				if(Key_1 == 0)
				{
					OLED_Clear();
					Flag = 2;
					SD_X = 0;
					PIT_Start(PIT1);
				}
			}
			if(Key_down == 0) //发车
			{
				DelayMs(100);
				if(Key_down == 0)
				{
					OLED_Clear();
					Flag = 0;
					PIT_Stop(PIT1);
					FTM_PWM_ChangeDuty(FTM1_CH0_PB0,0);
				}
			}
			if(Key_right == 0) //上位机
			{
				DelayMs(100);
				if(Key_right == 0)
				{
					while(1)
					{
						OLED_Clear();
						Sd_D();
						UART_Send_Con();
						FTM_PWM_ChangeDuty(FTM1_CH0_PB0,0);
					}
				}
			}
		}
		
	//发车
		while(Flag == 2)
		{
			if(TIME1flag_20ms==1)
			{
				TIME1flag_20ms=0;
				ImageCapture(Pixel);
				erzhi();
				LB();
				Sd_X();
			}
			CCD_HeiXian();
			if(leixin == 0) 
			{
				if(jiasuflag <= a4) FTM_PWM_ChangeDuty(FTM1_CH0_PB0,5000);
				if(jiasuflag >  a4) FTM_PWM_ChangeDuty(FTM1_CH0_PB0,FTMDuty_1);
			}
			if(leixin == 1) 
			{
				if(jiansuflag <= a3) FTM_PWM_ChangeDuty(FTM1_CH0_PB0,0);
				if(jiansuflag >  a3) FTM_PWM_ChangeDuty(FTM1_CH0_PB0,FTMDuty_2);
			}
			if(Key_down == 0)//菜单
			{
				DelayMs(100);
				if(Key_down == 0)
				{
					OLED_Clear();
					Flag = 0;
					PIT_Stop(PIT1);
					FTM_PWM_ChangeDuty(FTM1_CH0_PB0,0);
				}
			}
		}
	}
}
Beispiel #25
0
//=================
//TeamConfig_MenuInit
//=================
static qboolean TeamConfig_MenuInit( void )
{
	menucommon_t *menuitem;
	m_listitem_t *item;
	playermodelinfo_s *playermodel;
	int yoffset = 0;

	static char *team_names[] =
	{
		"PLAYERS",
		"ALPHA",
		"BETA",
		0
	};

	if( playermodelsItemsList.numItems == 0 )
		return qfalse;

	s_team_config_menu.nitems = 0;

	currentTEAM = TEAM_ALPHA;
	UpdateTeamCvars();

	// title
	menuitem = UI_InitMenuItem( "m_TeamConfig_title1", "TEAM ASPECT SETUP", 0, yoffset, MTYPE_SEPARATOR, ALIGN_CENTER_TOP, uis.fontSystemBig, NULL );
	Menu_AddItem( &s_team_config_menu, menuitem );
	yoffset += trap_SCR_strHeight( menuitem->font );

	yoffset += trap_SCR_strHeight( menuitem->font );

	// team
	menuitem = UI_InitMenuItem( "m_TeamConfig_team", "team", 0, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, ChangeTeamCallback );
	UI_SetupSpinControl( menuitem, team_names, TEAM_ALPHA - TEAM_PLAYERS );
	Menu_AddItem( &s_team_config_menu, menuitem );

	yoffset += trap_SCR_strHeight( menuitem->font );

	// padding
	yoffset += trap_SCR_strHeight( menuitem->font );

	// model
	menuitem = UI_InitMenuItem( "m_TeamConfig_forcemodel", "force a team model", 0, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, M_TeamConfig_ApplyChanges );
	UI_SetupSpinControl( menuitem, noyes_names, ( model->string[0] != 0 ) );
	Menu_AddItem( &s_team_config_menu, menuitem );
	hasForcedModelMenuItem = menuitem;

	yoffset += trap_SCR_strHeight( menuitem->font );

	menuitem = UI_InitMenuItem( "m_TeamConfig_model", "model", 0, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, TeamModelCallback );
	UI_SetupSpinControl( menuitem, playermodelsItemsList.item_names, 0 );
	Menu_AddItem( &s_team_config_menu, menuitem );

	yoffset += trap_SCR_strHeight( menuitem->font );

	item = UI_FindItemInScrollListWithId( &playermodelsItemsList, 0 );
	playermodel = (playermodelinfo_s *)item->data;
	menuitem = UI_InitMenuItem( "m_TeamConfig_skin", "skin", 0, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, M_TeamConfig_ApplyChanges );
	UI_SetupSpinControl( menuitem, playermodel->skinnames, 0 );
	Menu_AddItem( &s_team_config_menu, menuitem );

	yoffset += trap_SCR_strHeight( menuitem->font );

	M_GetTeamModel();

	// padding
	yoffset += trap_SCR_strHeight( menuitem->font );

	// color
	menuitem = UI_InitMenuItem( "m_TeamConfig_forcecolor", "force a team color", 0, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, ForceAColorCallback );
	UI_SetupSpinControl( menuitem, noyes_names, ( color->string[0] != 0 ) );
	Menu_AddItem( &s_team_config_menu, menuitem );
	hasForcedColorMenuItem = menuitem;

	yoffset += trap_SCR_strHeight( menuitem->font );

	menuitem = UI_InitMenuItem( "m_TeamConfig_colorred", "red", 0, yoffset, MTYPE_SLIDER, ALIGN_RIGHT_TOP, uis.fontSystemSmall, M_TeamConfig_ColorRedCallback );
	Menu_AddItem( &s_team_config_menu, menuitem );
	UI_SetupSlider( menuitem, 12, playerColor[0], 0, 255 );

	yoffset += trap_SCR_strHeight( menuitem->font );

	menuitem = UI_InitMenuItem( "m_TeamConfig_colorgreen", "green", 0, yoffset, MTYPE_SLIDER, ALIGN_RIGHT_TOP, uis.fontSystemSmall, M_TeamConfig_ColorGreenCallback );
	Menu_AddItem( &s_team_config_menu, menuitem );
	UI_SetupSlider( menuitem, 12, playerColor[1], 0, 255 );

	yoffset += trap_SCR_strHeight( menuitem->font );

	menuitem = UI_InitMenuItem( "m_TeamConfig_colorblue", "blue", 0, yoffset, MTYPE_SLIDER, ALIGN_RIGHT_TOP, uis.fontSystemSmall, M_TeamConfig_ColorBlueCallback );
	Menu_AddItem( &s_team_config_menu, menuitem );
	UI_SetupSlider( menuitem, 12, playerColor[2], 0, 255 );

	M_GetTeamColor();

	yoffset += trap_SCR_strHeight( menuitem->font );

	// padding
	yoffset += trap_SCR_strHeight( menuitem->font );

	menuitem = UI_InitMenuItem( "m_TeamConfig_MyTeamAlpha", "switch my team to show as team ALPHA", 60, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, M_TeamConfig_MyTeamAlpha );
	UI_SetupSpinControl( menuitem, noyes_names, ( trap_Cvar_Value( "cg_forceMyTeamAlpha" ) ) );
	Menu_AddItem( &s_team_config_menu, menuitem );

	yoffset += trap_SCR_strHeight( menuitem->font );

	menuitem = UI_InitMenuItem( "m_TeamConfig_TeamPlayersTeamBeta", "show teamless players as team BETA players", 60, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, M_TeamConfig_TeamPlayersTeamBeta );
	UI_SetupSpinControl( menuitem, noyes_names, ( trap_Cvar_Value( "cg_forceTeamPlayersTeamBeta" ) ) );
	Menu_AddItem( &s_team_config_menu, menuitem );

	yoffset += trap_SCR_strHeight( menuitem->font );

	// padding
	yoffset += trap_SCR_strHeight( menuitem->font );

	// help
	menuitem = UI_InitMenuItem( "m_TeamConfig_HelpText", "If you want to always force your teammates and your enemies to a specific look,", 10, yoffset, MTYPE_SEPARATOR, ALIGN_CENTER_TOP, uis.fontSystemSmall, NULL );
	Menu_AddItem( &s_team_config_menu, menuitem );
	yoffset += trap_SCR_strHeight( menuitem->font );

	menuitem = UI_InitMenuItem( "m_TeamConfig_HelpText2", "set both of the above options and configure ALPHA and BETA teams", 10, yoffset, MTYPE_SEPARATOR, ALIGN_CENTER_TOP, uis.fontSystemSmall, NULL );
	Menu_AddItem( &s_team_config_menu, menuitem );
	yoffset += trap_SCR_strHeight( menuitem->font );

	// padding
	yoffset += trap_SCR_strHeight( menuitem->font );

	// back
	menuitem = UI_InitMenuItem( "m_TeamConfig_back", "back", 0, yoffset, MTYPE_ACTION, ALIGN_CENTER_TOP, uis.fontSystemBig, M_TeamConfig_SaveAndClose );
	Menu_AddItem( &s_team_config_menu, menuitem );
	UI_SetupButton( menuitem, qtrue );

	Menu_Center( &s_team_config_menu );
	Menu_Init( &s_team_config_menu, qfalse );

	return qtrue;
}
Beispiel #26
0
int main(void)
{

	SystemClockSetup(ClockSource_EX50M,CoreClock_100M);
	DelayInit();
	OLED_Init();
	Sd_Init();
	chuinit_Init();
	DataInit();
	Data_Uart_Init();
	
	while(1)
	{
		Menu_Init();
		//ccd测试
		while(Flag == 1)
		{
			if(TIME1flag_20ms == 1)
			{
				TIME1flag_20ms = 0;
				ImageCapture(P1);
//				Sd_X();
//				Sd_D();
//				UART_Send_Con();
				oled_collect();
				oled_show();
			}
			CCD_HeiXian();
			OLED_ZhongXian();
			OLED_Write_Num3(4,0,Center);
			OLED_Write_Num3(0,0,Left);
			OLED_Write_Num3(9,0,Right);
			OLED_Write_Num3(0,2,AverageValue);

			if(Key_1 == 0) //发车
			{
				DelayMs(100);
				if(Key_1 == 0)
				{
					OLED_Clear();
					Flag = 2;
					SD_X = 0;
					PIT_Start(PIT1);
				}
			}
			if(Key_down == 0) //菜单
			{
				DelayMs(100);
				if(Key_down == 0)
				{
					OLED_Clear();
					Flag = 0;
					PIT_Stop(PIT1);
					FTM_PWM_ChangeDuty(FTM1_CH0_PB0,0);
					FTM_PWM_ChangeDuty(FTM1_CH1_PB1,0);
				}
			}
			if(Key_up == 0) //SD 发车
			{
				DelayMs(100);
				if(Key_up == 0)
				{
					SD_Flag = !SD_Flag;
					if(SD_Flag) OLED_Write_String(2,2,"SD running");
					else 				OLED_Write_String(2,2,"SD stopping");
				}
			}
			if(Key_right == 0) //上位机
			{
				DelayMs(100);
				if(Key_right == 0)
				{
					while(1)
					{
						OLED_Clear();
						Sd_D();
						UART_Send_Con();
					}
				}
			}
		}
		
	//发车
		while(Flag == 2)
		{
			if(TIME1flag_20ms == 1)
			{
				TIME1flag_20ms = 0;
				ImageCapture(P1);
				Sd_X();
			}
			CCD_HeiXian();
			if(leixin == 0)
			{
				if (jiasuflag <= jiasu_Num) FTM_PWM_ChangeDuty(FTM1_CH0_PB0,5000);
				else 								 				FTM_PWM_ChangeDuty(FTM1_CH0_PB0,FTMDuty_1);
			}
			if(leixin == 1) 
			{
				if (jiansuflag <= jiansu_Num)
				{
					FTM_PWM_ChangeDuty(FTM1_CH0_PB0,0);
					FTM_PWM_ChangeDuty(FTM1_CH1_PB1,100);
				}
//				else if(zhidaoflag_save < 200 && jiansuflag <= a6)
//				{
//					FTM_PWM_ChangeDuty(FTM1_CH0_PB0,0);
//				}
				else FTM_PWM_ChangeDuty(FTM1_CH0_PB0,FTMDuty_2);
			}
			if(Key_down == 0) //菜单
			{
				DelayMs(100);
				if(Key_down == 0)
				{
					OLED_Clear();
					Flag = 0;
					PIT_Stop(PIT1);
					FTM_PWM_ChangeDuty(FTM1_CH0_PB0,0);
					FTM_PWM_ChangeDuty(FTM1_CH1_PB1,0);
				}
			}
		}
	}
}
Beispiel #27
0
static void Performance_Init( void )
{
    menucommon_t *menuitem;
    int yoffset = 0;

    char custom_resolution[64];
    static char **resolutions;

    static char *colordepth_names[] = { "desktop", "16 bits", "32 bits", 0 };

    static char *plighting_names[] = { "vertex (fast)", "lightmaps (normal)", "per pixel (quality)", "per pixel (no specular)", 0 };

    static char **texfilter_names;
    int anisotropic, spinindex;

#ifndef PREDEFINES_PROFILES
    if( !gfx_profiles )
    {
        int i = 0, num, total, len;
        char *current, buffer[1024];
        total = trap_FS_GetFileList( "profiles", ".cfg", NULL, 0, 0, 0 );

        if( total )
            gfx_profiles = UI_Malloc( sizeof( char * ) * ( total + 1 ) );

        while( i < total )
        {
            if( ( num = trap_FS_GetFileList( "profiles", ".cfg", buffer, sizeof( buffer ), i, total ) ) == 0 )
            {
                i++; // can happen if the filename is too long to fit into the buffer or we're done
                continue;
            }

            // add profiles to profiles list
            for( current = buffer ; num ; i++, num--, current += len )
            {
                len = strlen( current ) + 1;
                if( strncmp( current, "gfx_", 4 ) )
                    continue;

                COM_StripExtension( current );

                gfx_profiles[i] = UI_Malloc( strlen( current + 4 ) + 1 );
                strcpy( gfx_profiles[i], current + 4 );
            }
        }
    }
#endif

    if( !resolutions )
    {   // count video modes
        int i, width, height;
        qboolean wideScreen;

        for( i = 0; trap_VID_GetModeInfo( &width, &height, &wideScreen, i - 1 ); i++ ) ;

        resolutions = (char **)UI_Malloc( sizeof( char * ) * ( i + 1 ) );

        for( i = 0; trap_VID_GetModeInfo( &width, &height, &wideScreen, i - 1 ); i++ )
        {
            Q_snprintfz( custom_resolution, sizeof( custom_resolution ), "%s%s%i x %i", i ? "" : "custom: ", ( wideScreen ? "W " : "" ), width, height );
            resolutions[i] = UI_CopyString( custom_resolution );
        }
        resolutions[i] = NULL;
    }

    if( !texfilter_names )
    {
        int i, count;

        for( count = 0; ; count++ )
        {
            if( trap_Cvar_Value( "gl_ext_texture_filter_anisotropic_max" ) <= (1<<count) )
                break;
        }

        texfilter_names = (char **)UI_Malloc( sizeof( char * ) * ( count + 1 + 1 ) );

        texfilter_names[0] = UI_CopyString( "bilinear" );
        for( i = 0; i < count; i++ )
            texfilter_names[i+1] = UI_CopyString( va( "trilinear %ixAF", (1<<i) ) );
        texfilter_names[i+1] = NULL;
    }

    menuitem = UI_InitMenuItem( "m_performance_title1", "GRAPHICS OPTIONS", 0, yoffset, MTYPE_SEPARATOR, ALIGN_CENTER_TOP, uis.fontSystemBig, NULL );
    Menu_AddItem( &s_performance_menu, menuitem );
    yoffset += trap_SCR_strHeight( menuitem->font );
    yoffset += trap_SCR_strHeight( menuitem->font );

    menuitem = UI_InitMenuItem( "m_performance_profile", "profile", 0, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_performance_menu, menuitem );
    UI_SetupSpinControl( menuitem, gfx_profiles, trap_Cvar_Value( "ui_gfxprofile" ) );
    yoffset += trap_SCR_strHeight( menuitem->font );
    yoffset += trap_SCR_strHeight( menuitem->font );

    menuitem = UI_InitMenuItem( "m_performance_applyprofile", "apply profile", 0, yoffset, MTYPE_ACTION, ALIGN_CENTER_TOP, uis.fontSystemBig, ApplyProfileButton );
    Menu_AddItem( &s_performance_menu, menuitem );
    yoffset += 1.5 * UI_SetupButton( menuitem, qtrue );

    menuitem = UI_InitMenuItem( "m_performance_resolution", "resolution", 0, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_performance_menu, menuitem );
    UI_SetupSpinControl( menuitem, resolutions, max( trap_Cvar_Value( "r_mode" ), -1 ) + 1 );
    yoffset += trap_SCR_strHeight( menuitem->font );

    menuitem = UI_InitMenuItem( "m_performance_fullscreen", "fullscreen", 0, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_performance_menu, menuitem );
    UI_SetupSpinControl( menuitem, noyes_names, trap_Cvar_Value( "vid_fullscreen" ) != 0 );
    yoffset += trap_SCR_strHeight( menuitem->font );

    menuitem = UI_InitMenuItem( "m_performance_swapinterval", "vertical sync", 0, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_performance_menu, menuitem );
    UI_SetupSpinControl( menuitem, noyes_names, trap_Cvar_Value( "r_swapinterval" ) );
    yoffset += trap_SCR_strHeight( menuitem->font );

    menuitem = UI_InitMenuItem( "m_performance_gamma", "brightness", 0, yoffset, MTYPE_SLIDER, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_performance_menu, menuitem );
    UI_SetupSlider( menuitem, 12, bound( (int)( trap_Cvar_Value( "r_gamma" ) * 10.0f ), 5, 13 ), 5, 13 );
    yoffset += trap_SCR_strHeight( menuitem->font );

    menuitem = UI_InitMenuItem( "m_performance_colorbits", "color quality", 0, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_performance_menu, menuitem );
    if( !Q_stricmp( trap_Cvar_String( "r_colorbits" ), "16" ) )
        UI_SetupSpinControl( menuitem, colordepth_names, 1 );
    else if( !Q_stricmp( trap_Cvar_String( "r_colorbits" ), "32" ) )
        UI_SetupSpinControl( menuitem, colordepth_names, 2 );
    else
        UI_SetupSpinControl( menuitem, colordepth_names, 0 );
    yoffset += trap_SCR_strHeight( menuitem->font );

    menuitem = UI_InitMenuItem( "m_performance_picmip", "texture quality", 0, yoffset, MTYPE_SLIDER, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_performance_menu, menuitem );
    UI_SetupSlider( menuitem, 12, 6-trap_Cvar_Value( "r_picmip" ), 0, 6 );
    yoffset += trap_SCR_strHeight( menuitem->font );

    menuitem = UI_InitMenuItem( "m_performance_filter", "texture filter", 0, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_performance_menu, menuitem );
    anisotropic = trap_Cvar_Value( "r_texturefilter" );
    if( anisotropic >= 2 )
        spinindex = NEARESTEXPOF2( anisotropic ) + 1;
    else if( !Q_stricmp( trap_Cvar_String( "r_texturemode" ), "GL_LINEAR_MIPMAP_NEAREST" ) )
        spinindex = 0;
    else
        spinindex = 1;
    UI_SetupSpinControl( menuitem, texfilter_names, spinindex );
    yoffset += trap_SCR_strHeight( menuitem->font );

    menuitem = UI_InitMenuItem( "m_performance_skymip", "sky quality", 0, yoffset, MTYPE_SLIDER, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_performance_menu, menuitem );
    UI_SetupSlider( menuitem, 12, (trap_Cvar_Value( "r_fastsky" ) ? 0 : 4-trap_Cvar_Value( "r_skymip" )), 0, 4 );
    yoffset += trap_SCR_strHeight( menuitem->font );

    menuitem = UI_InitMenuItem( "m_performance_LOD_slider", "geometry level of detail", 0, yoffset, MTYPE_SLIDER, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_performance_menu, menuitem );
    UI_SetupSlider( menuitem, 12, 4-max( trap_Cvar_Value( "r_lodbias" ), NEARESTEXPOF2( trap_Cvar_Value( "r_subdivisions" ) ) ), 0, 4 );
    yoffset += trap_SCR_strHeight( menuitem->font );

#if 0
    menuitem = UI_InitMenuItem( "m_performance_glsl", "opengl shaders", 0, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_performance_menu, menuitem );
    UI_SetupSpinControl( menuitem, offon_names, trap_Cvar_Value( "gl_ext_GLSL" ) );
    yoffset += trap_SCR_strHeight( menuitem->font );
#endif

    if( trap_Cvar_Value( "r_lighting_vertexlight" ) )
        spinindex = 0;
    else if( !trap_Cvar_Value( "r_lighting_deluxemapping" ) )
        spinindex = 1;
    else if( trap_Cvar_Value( "r_lighting_specular" ) )
        spinindex = 2;
    else
        spinindex = 3;

    menuitem = UI_InitMenuItem( "m_performance_pplighting", "lighting", 0, yoffset, MTYPE_SPINCONTROL, ALIGN_RIGHT_TOP, uis.fontSystemSmall, NULL );
    Menu_AddItem( &s_performance_menu, menuitem );
    UI_SetupSpinControl( menuitem, plighting_names, spinindex );
    yoffset += trap_SCR_strHeight( menuitem->font );

    yoffset += trap_SCR_strHeight( menuitem->font );

    menuitem = UI_InitMenuItem( "m_performance_back", "back", -16, yoffset, MTYPE_ACTION, ALIGN_RIGHT_TOP, uis.fontSystemBig, M_genericBackFunc );
    Menu_AddItem( &s_performance_menu, menuitem );
    UI_SetupButton( menuitem, qtrue );
    menuitem = UI_InitMenuItem( "m_performance_apply", "apply", 16, yoffset, MTYPE_ACTION, ALIGN_LEFT_TOP, uis.fontSystemBig, ApplyButton );
    Menu_AddItem( &s_performance_menu, menuitem );
    yoffset += UI_SetupButton( menuitem, qtrue ) + UI_BUTTONBOX_VERTICAL_SPACE;;

    yoffset += trap_SCR_strHeight( uis.fontSystemSmall );

    menuitem = UI_InitMenuItem( "m_performance_advanced", "advanced options", 0, yoffset, MTYPE_ACTION, ALIGN_CENTER_TOP, uis.fontSystemBig, AdvancedButton );
    Menu_AddItem( &s_performance_menu, menuitem );
    UI_SetupButton( menuitem, qtrue );

    Menu_Center( &s_performance_menu );
    Menu_Init( &s_performance_menu, qfalse );
}
Beispiel #28
0
static void M_TV_Init( void )
{
	int i, yoffset, xoffset, vspacing;
	static char titlename[64];
	menucommon_t *menuitem;
	int scrollwindow_height, scrollwindow_width, scrollbar_id;

	yoffset = 0;
	xoffset = 0;

	s_tv_menu.nitems = 0;

	Q_snprintfz( titlename, sizeof( titlename ), "%s TV", trap_Cvar_String( "gamename" ) );

	menuitem = UI_InitMenuItem( "m_tv_title1", titlename, 0, yoffset, MTYPE_SEPARATOR, ALIGN_CENTER_TOP, uis.fontSystemBig, NULL );
	Menu_AddItem( &s_tv_menu, menuitem );
	yoffset += 2 *trap_SCR_strHeight( menuitem->font );

	// scrollbar
	if( uis.vidWidth < 800 )
		scrollwindow_width = uis.vidWidth * 0.85;
	else
		scrollwindow_width = uis.vidWidth * 0.75;

	xoffset = scrollwindow_width / 2;

	vspacing = trap_SCR_strHeight( uis.fontSystemSmall ) + 4;
	scrollwindow_height = uis.vidHeight - ( yoffset + ( 16 * trap_SCR_strHeight( uis.fontSystemBig ) ) );
	max_menu_channels = scrollwindow_height / vspacing;
	if( max_menu_channels < 5 )
		max_menu_channels = 5;

	menuitem = UI_InitMenuItem( "m_tv_titlerow", NULL, -xoffset, yoffset, MTYPE_SEPARATOR, ALIGN_LEFT_TOP, uis.fontSystemSmall, NULL );
	Q_snprintfz( menuitem->title, MAX_STRING_CHARS, 
			ROW_PATTERN,
			COLUMN_WIDTH_NO, "No", 
			COLUMN_WIDTH_NAME, "", "Server",
			COLUMN_WIDTH_PLAYERS, "", " Pl/Sp",
			COLUMN_WIDTH_GAMETYPE, "", "Gametype",
			COLUMN_WIDTH_MAPNAME, "", "Map",
			COLUMN_WIDTH_MATCHNAME, "", "Match"
	);
	Menu_AddItem( &s_tv_menu, menuitem );
	yoffset += trap_SCR_strHeight( menuitem->font );

	menuitem = UI_InitMenuItem( "m_tv_scrollbar", NULL, xoffset, yoffset, MTYPE_SCROLLBAR, ALIGN_LEFT_TOP, uis.fontSystemSmall, M_TV_UpdateScrollbar );
	menuitem->vspacing = vspacing;
	menuitem->scrollbar_id = scrollbar_id = s_tv_menu.nitems; //give the scrollbar an id to pass onto its list
	Q_strncpyz( menuitem->title, va( "ui_tv_scrollbar%i_curvalue", scrollbar_id ), sizeof( menuitem->title ) );
	if( !trap_Cvar_Value( menuitem->title ) )
		trap_Cvar_SetValue( menuitem->title, 0 );
	UI_SetupScrollbar( menuitem, max_menu_channels, trap_Cvar_Value( menuitem->title ), 0, 0 );
	Menu_AddItem( &s_tv_menu, menuitem );

	for( i = 0; i < max_menu_channels; i++ )
	{
		menuitem = UI_InitMenuItem( va( "m_tv_button_%i", i ), NO_CHANNEL_STRING, -xoffset, yoffset, MTYPE_ACTION,
		                            ALIGN_LEFT_TOP, uis.fontSystemSmall, NULL );
		menuitem->callback_doubleclick = M_TV_JoinChannel;
		menuitem->scrollbar_id = scrollbar_id; //id of the scrollbar so that mwheelup/down can scroll from the list
		menuitem->height = vspacing;
		menuitem->statusbar = "press ENTER to watch";
		menuitem->ownerdraw = M_UpdateChannelButton;
		menuitem->localdata[0] = i; // line in the window
		menuitem->localdata[1] = i; // line in list
		menuitem->width = scrollwindow_width; // adjust strings to this width
		Menu_AddItem( &s_tv_menu, menuitem );

		// create an associated picture to the items to act as window background
		menuitem->pict.shader = uis.whiteShader;
		menuitem->pict.shaderHigh = uis.whiteShader;
		Vector4Copy( colorWhite, menuitem->pict.colorHigh );
		Vector4Copy( ( i & 1 ) ? colorDkGrey : colorMdGrey, menuitem->pict.color );
		menuitem->pict.color[3] = menuitem->pict.colorHigh[3] = 0.65f;
		menuitem->pict.yoffset = 0;
		menuitem->pict.xoffset = 0;
		menuitem->pict.width = scrollwindow_width;
		menuitem->pict.height = vspacing;

		yoffset += vspacing;
	}

	yoffset += 1.5 * trap_SCR_strHeight( menuitem->font );

	menuitem = UI_InitMenuItem( "m_tv_refresh", "refresh", -xoffset, yoffset, MTYPE_ACTION, ALIGN_LEFT_TOP, uis.fontSystemBig, M_TV_RefreshFunc );
	Menu_AddItem( &s_tv_menu, menuitem );
	UI_SetupButton( menuitem, qtrue );

	menuitem = UI_InitMenuItem( "m_tv_disconnect", "watch", xoffset, yoffset, MTYPE_ACTION, ALIGN_RIGHT_TOP, uis.fontSystemBig, M_TV_JoinChannel );
	Menu_AddItem( &s_tv_menu, menuitem );
	UI_SetupButton( menuitem, qtrue );
	xoffset -= ( menuitem->width + 16 );

	menuitem = UI_InitMenuItem( "m_tv_setup", "main menu", xoffset, yoffset, MTYPE_ACTION, ALIGN_RIGHT_TOP, uis.fontSystemBig, M_TV_MenuMainFunc );
	Menu_AddItem( &s_tv_menu, menuitem );
	UI_SetupButton( menuitem, qtrue );
	xoffset -= ( menuitem->width + 16 );

	if( uis.clientState >= CA_ACTIVE )
	{
		menuitem = UI_InitMenuItem( "m_tv_chasecam", "chasecam", xoffset, yoffset, MTYPE_ACTION, ALIGN_RIGHT_TOP, uis.fontSystemBig, M_TV_SpecModeMenuFunc );
		Menu_AddItem( &s_tv_menu, menuitem );
		UI_SetupButton( menuitem, qtrue );
		xoffset -= ( menuitem->width + 16 );
	}

	Menu_Center( &s_tv_menu );
	Menu_Init( &s_tv_menu, qfalse );

	Menu_SetStatusBar( &s_tv_menu, NULL );
}
Beispiel #29
0
static void M_Msgbox_Init( void )
{
	int i, j, s;
	int lineend, len;
	int n = 0;
	const char *p;
	menucommon_t *menuitem = NULL;
	char menuitem_name[40];
	char scnd_btn_name[120] = { '\0' }, scnd_btn_action[120] = { '\0' };
	int width = 0, yoffset = 40;

	s_msgbox_menu.nitems = 0;

	mbtext[0] = 0;

	for( i = 1; i < trap_Cmd_Argc(); i++ )
	{
		Q_strncpyz( mbtext, trap_Cmd_Argv(i), sizeof( mbtext ) );
		len = strlen( mbtext );

		// a secret second button
		if( !strncmp( mbtext, "\\btn\\", 5 ) )
		{
			p = strstr( mbtext + 6, "\\" );
			if( p ) {
				mbtext[p - mbtext] = '\0';

				Q_strncpyz( scnd_btn_name, mbtext + 5, sizeof( scnd_btn_name ) );
				Q_strncpyz( scnd_btn_action, p + 1, sizeof( scnd_btn_action ) );
			}

			continue;
		}

		// split the text into lines
		for( s = 0; s <= len; s += j + 1 )
		{
			lineend = min( len - s, M_MSGBOX_LINELEN );

			for( j = lineend; j && mbtext[s+j] && mbtext[s+j] != ' '; j-- );
			if( !j ) j = lineend;

			mbtext[s+j] = '\0';

			Q_snprintfz( menuitem_name, sizeof( menuitem_name ), "m_msgbox_textline_%i", n );
			menuitem = UI_InitMenuItem( menuitem_name, mbtext + s, 0, yoffset, MTYPE_SEPARATOR, ALIGN_CENTER_TOP, uis.fontSystemSmall, NULL );
			Menu_AddItem( &s_msgbox_menu, menuitem );
			yoffset += trap_SCR_strHeight( menuitem->font );

			n++;
		}
	}

	//if we printed something, add one line separation
	if( menuitem )
		yoffset += trap_SCR_strHeight( menuitem->font );

	if( scnd_btn_name[0] && scnd_btn_action[0] )
		width = UI_StringWidth( "close", uis.fontSystemBig );
	else
		width = 0;

	menuitem = UI_InitMenuItem( "m_msgbox_close", "close", -width, yoffset, MTYPE_ACTION, ALIGN_CENTER_TOP, uis.fontSystemBig, M_genericBackFunc );
	Menu_AddItem( &s_msgbox_menu, menuitem );

	if( scnd_btn_name[0] && scnd_btn_action[0] )
	{
		UI_SetupButton( menuitem, qtrue );

		menuitem = UI_InitMenuItem( "m_msgbox_connect", scnd_btn_name, width, yoffset, MTYPE_ACTION, ALIGN_CENTER_TOP, uis.fontSystemBig, M_Msgbox_SecondButton );
		menuitem->itemlocal = UI_CopyString( scnd_btn_action );
		Menu_AddItem( &s_msgbox_menu, menuitem );
	}

	yoffset += UI_SetupButton( menuitem, qtrue ) + UI_BUTTONBOX_VERTICAL_SPACE;

	Menu_Center( &s_msgbox_menu );
	Menu_Init( &s_msgbox_menu, qfalse );
	Menu_SetStatusBar( &s_msgbox_menu, NULL );
}
/*
===========
ClientConnect

Called when a player begins connecting to the server.
The game can refuse entrance to a client by returning false.
If the client is allowed, the connection process will continue
and eventually get to ClientBegin()
Changing levels will NOT cause this to be called again, but
loadgames will.
============
*/
qboolean ClientConnect (edict_t *ent, char *userinfo)
{
	char	*value;

	// check to see if they are on the banned IP list
	value = Info_ValueForKey (userinfo, "ip");
	if (SV_FilterPacket(value)) {
		Info_SetValueForKey(userinfo, "rejmsg", "Banned.");
		return false;
	}

	// check for a spectator
	value = Info_ValueForKey (userinfo, "spectator");
	if (deathmatch->value && *value && strcmp(value, "0")) {
		int i, numspec;

		if (*spectator_password->string && 
			strcmp(spectator_password->string, "none") && 
			strcmp(spectator_password->string, value)) {
			Info_SetValueForKey(userinfo, "rejmsg", "Spectator password required or incorrect.");
			return false;
		}

		// count spectators
		for (i = numspec = 0; i < maxclients->value; i++)
			if (g_edicts[i+1].inuse && g_edicts[i+1].client->pers.spectator)
				numspec++;

		if (numspec >= maxspectators->value) {
			Info_SetValueForKey(userinfo, "rejmsg", "Server spectator limit is full.");
			return false;
		}
	} else {
		// check for a password
		value = Info_ValueForKey (userinfo, "password");
		if (*password->string && strcmp(password->string, "none") && 
			strcmp(password->string, value)) {
			Info_SetValueForKey(userinfo, "rejmsg", "Password required or incorrect.");
			return false;
		}
	}


	// they can connect
	ent->client = game.clients + (ent - g_edicts - 1);

	// if there is already a body waiting for us (a loadgame), just
	// take it, otherwise spawn one from scratch
	if (ent->inuse == false)
	{
		// clear the respawning variables
		InitClientResp (ent->client);
		if (!game.autosaved || !ent->client->pers.weapon)
			InitClientPersistant (ent->client);
	}

	ClientUserinfoChanged (ent, userinfo);

	if (game.maxclients > 1)
		gi.dprintf ("%s connected\n", ent->client->pers.netname);

	ent->svflags = 0; // make sure we start with known default
	ent->client->pers.connected = true;
// debut mod : qmenu
	Menu_Init (ent);
	return true;
// fin mod : qmenu
}