Exemplo n.º 1
0
bool D3D11App::initAPI()
{
	DXGI_FORMAT colorFormat = DXGI_FORMAT_R8G8B8A8_UNORM;
	DXGI_FORMAT depthFormat = DXGI_FORMAT_UNKNOWN;
	switch (depthBits)
	{
		case 16:
			depthFormat = DXGI_FORMAT_D16_UNORM;
			break;
		case 24:
			depthFormat = DXGI_FORMAT_D24_UNORM_S8_UINT;
			break;
		case 32:
			depthFormat = DXGI_FORMAT_D32_FLOAT;
			break;
	}

	return initAPI(D3D11, colorFormat, depthFormat, max(antiAliasSamples, 1), 0);
}
Exemplo n.º 2
0
void Init_All(void){

 // SetBusClock_24MHz();
   //initPLL();
  //eOSC_SetBusCLK_2nM(24);
  initPLL();
  initAPI();
  PWMInit();
  ADC_Init();
  select_plan();
//  OutputCompare_Init();
//  PITInit();
 // Init_MMA();
  //SCI0_BR(38400);
  //SCI0_Init(); 
  //SPI_Init();
  //GYRO_Init();  
  DDRT_DDRT2 = 1;
}
Exemplo n.º 3
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    //check whether another MoonPlayer instance is running
#ifdef Q_OS_LINUX
    std::cout << "Checking another instance..." << std::endl;

    QDBusInterface iface("com.moonsoft.MoonPlayer", "/", "local.Playlist");
    if (iface.isValid())
    {
        if (argc == 1)
        {
            qDebug("Another instance is running. Quit.\n");
            return EXIT_FAILURE;
        }
        QString f = QString::fromUtf8(argv[1]);
        if (f.startsWith("http://"))
            iface.call("addUrl", f);
        else if (f.endsWith(".m3u") || f.endsWith("m3u8") || f.endsWith(".xspf")) //playlist
            iface.call("addList", f);
        else
            iface.call("addFileAndPlay", f.section('/', -1), f);
        return EXIT_SUCCESS;
    }
    QDBusConnection conn = QDBusConnection::sessionBus();
    if (!conn.registerService("com.moonsoft.MoonPlayer"))
    {
        qDebug() << conn.lastError().message();
        return EXIT_FAILURE;
    }
#endif

    //init
#ifdef Q_OS_WIN
    Settings::path = QString(argv[0]).section('\\', 0, -2);
#endif
    std::cout << "Initialize settings..." << std::endl;
    Settings::initSettings();

    std::cout << "Initialize API for Python..." << std::endl;
    initAPI();

    //translate moonplayer
    std::cout << "Initialize language support..." << std::endl;
    QTranslator translator;
    QDir path(Settings::path);
    translator.load(path.filePath("moonplayer_" + QLocale::system().name()));
    a.installTranslator(&translator);

    Player w;
    w.show();

    if (argc > 1)
    {
        std::cout << "Loading file..." << std::endl;
        QTextCodec* codec = QTextCodec::codecForLocale();
        QString file = codec->toUnicode(argv[1]);
        if (file.startsWith("http://"))
            w.playlist->addUrl(file);
        else if (file.endsWith(".m3u") || file.endsWith("m3u8") || file.endsWith(".xspf")) //playlist
            w.playlist->addList(file);
        else
            w.playlist->addFileAndPlay(file.section('/', -1), file);
    }
    a.exec();
    Py_Finalize();
    return 0;
}
Exemplo n.º 4
0
void boardInit() {
  SysTick_Config(SystemCoreClock/1000 - 1); 

  /*
    A note about interrupt priorities

    A smaller numeric priority means that the priority is higher, thus
    the most important interrupt has priority 0, the least import 31.

    If an interrupt arrives while servicing an interrupt with a lower
    priority, then the lesser interrupt is interrupted to service the
    high priority one, if the high priority interrupt is of a different
    preemption priority group.

    IOW: an IRQ in PP group 3 will be interrupted if an IRQ arrives with
    PP group 2,1 or 0.

    The sub priority is only used to order the interrupts at the same PE
    level.

    NVIC_SetPriorityGrouping is used here to divide the 32 levels of
    IRQ priorities into 8 preemption groups and 4 sub priorities.
  */
  NVIC_SetPriorityGrouping(4);   
  for (int i=0;i<35;i++) {
    NVIC_SetPriority(i, GROUP_PRIORITY_DEFAULT);    
  }
  NVIC_SetPriority(TIMER2_IRQn, GROUP_PRIORITY_STEPPER);
  NVIC_SetPriority(SysTick_IRQn, GROUP_PRIORITY_1000HZ); 
  NVIC_SetPriority(TIMER3_IRQn, GROUP_PRIORITY_100HZ);
  NVIC_SetPriority(USB_IRQn, GROUP_PRIORITY_USB);
  
  initUARTs();
  initADC();
  initPWM();
  
  // Motor drivers are active low, so let's disable all of them, until the drivers turn them on:
  GPIO_SET(IO_X_ENABLE);
  GPIO_SET(IO_Y_ENABLE);
  GPIO_SET(IO_Z_ENABLE);
  GPIO_SET(IO_A_ENABLE); 
   
  /*
    Set the simple I/O configuration for all the pins we use,    
    this will ensure that all pins have had its function selected
  */
  for (int i=0;i<ALL_PINS_SIZE;i++) {
    configPin(ALL_PINS[i]);
  }

  /*
    Set up timer3 to poke the "slow" 100Hz maintainance routine
   */    

  TIM_TIMERCFG_Type timerCfg;
  timerCfg.PrescaleOption = TIM_PRESCALE_USVAL;
  timerCfg.PrescaleValue  = 1000; // 1 ms interval
  TIM_Init(LPC_TIM3, TIM_TIMER_MODE, &timerCfg);

  TIM_MATCHCFG_Type timerMatch;
  timerMatch.MatchChannel = 0;
  timerMatch.IntOnMatch   = TRUE;
  timerMatch.ResetOnMatch = TRUE;
  timerMatch.StopOnMatch  = FALSE;
  timerMatch.ExtMatchOutputType = TIM_EXTMATCH_NOTHING;
  timerMatch.MatchValue   = 10-1;
  TIM_ConfigMatch(LPC_TIM3,&timerMatch);

  NVIC_EnableIRQ(TIMER3_IRQn);
  TIM_Cmd(LPC_TIM3,ENABLE);
  
  initAPI();
}
bool D3D10App::initAPI(){
	return initAPI(DXGI_FORMAT_R8G8B8A8_UNORM, depthBits > 16? DXGI_FORMAT_D24_UNORM_S8_UINT : DXGI_FORMAT_D16_UNORM, max(antiAliasSamples, 1), 0);
}
Exemplo n.º 6
0
int main(int argc, char *argv[])
{
  int s;
  int b;
  int l;
  int a;

  initAPI();

  socklen_t clisize;
  struct sockaddr_in addr, addr_client;

  PORT=52736;

  done=0;

  printf("&s=%p\n", &s);
  printf("main=%p\n", main);

  printf("sizeof(off_t)=%d\n",sizeof(off_t));
  printf("sizeof(off64_t)=%d\n",sizeof(off64_t));

  printf("CEServer. Waiting for client connection\n");

  //if (broadcast)
  pthread_create(&identifierthread, NULL, IdentifierThread, NULL);

  s=socket(AF_INET, SOCK_STREAM, 0);
  printf("socket=%d\n", s);

  memset(&addr, 0, sizeof(addr));
  addr.sin_family=AF_INET;
  addr.sin_port=htons(PORT);
  addr.sin_addr.s_addr=INADDR_ANY;

  int optval = 1;
  setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof (optval));

  b=bind(s, (struct sockaddr *)&addr, sizeof(addr));
  printf("bind=%d\n", b);

  if (b!=-1)
  {
    l=listen(s, 32);

    printf("listen=%d\n", l);

    clisize=sizeof(addr_client);
    memset(&addr_client, 0, sizeof(addr_client));

    if (argc>2)
    {
      printf("argv[0]=%s\n", argv[0]);
      printf("argv[1]=%s\n", argv[1]);
      if (strcmp(argv[1], "TEST")==0)
      {
        printf("TESTMODE\n");
        pthread_create(&pth, NULL, (void *)CESERVERTEST, argv);
      }
    }

    fflush(stdout);

    while (done==0)
    {
      int b=1;
      a=accept(s, (struct sockaddr *)&addr_client, &clisize);

      printf("accept=%d\n", a);

      fflush(stdout);

      setsockopt(a, IPPROTO_TCP, TCP_NODELAY, &b, sizeof(b));

      if (a != -1)
      {
        pthread_create(&pth, NULL, (void *)newconnection, (void *)(uintptr_t)a);
      }
    }
  }

  printf("Terminate server\n");

  close(s);

  return 0;
}