bool PBase::init() { if ( !WJLayer::init() ) { return false; } #if (COCOS2D_DEBUG) CCLOG("Init Scene: %s...", getGameName().c_str()); #endif m_winSize = Director::getInstance()->getWinSize(); m_visibleSize = Director::getInstance()->getVisibleSize(); m_origin = Director::getInstance()->getVisibleOrigin(); m_visibleRect = Rect(m_origin.x, m_origin.y, m_visibleSize.width, m_visibleSize.height); // top layer m_topLayer = WJLayer::create(); m_topLayer->saveCurrentPosition(); this->addChild(m_topLayer, ZORDER_TOP_LAYER); // p001 welcome if (getGameNumber() == GameNumber::P000 || getGameNumber() == GameNumber::P010) { // android back key this->addChild(LBToolbar::createBackKey([&]() { // quit app WJUtils::callaction_void(ACTION_VOID_CONFIRM_QUIT); })); } else { initPopupMenu(); initSnapshot(); initAdsBanner(); } return true; }
void startHwPump() { // DEBUG // // WARN("pump disabled"); // printf("*** Hw pump disabled ***\n"); // return; // init phi snapshot initSnapshot(); // init the event gate that synchronizes writing out to the motors (init to CLOSED) eventGate_init(&egMotorWrite, FALSE); // spawn threads to pump each interface // // Note: threads are started detached and we don't keep track // of the pthread_t, threads are "fire and forget" int iface; for (iface = 0 ; iface < 3 ; iface++) { pthread_t thread; pthread_attr_t threadAttr; // init default attrs PHI_ZERO(threadAttr); pthread_attr_init(&threadAttr); // request detached thread pthread_attr_setdetachstate(&threadAttr, PTHREAD_CREATE_DETACHED); /* NO ARGUMENTS // alloc args PHILINK_ARGS* pArgs = PHI_ALLOC(....); pArgs -> a = a; pArgs -> b = b; */ // create interface thread switch(iface) { case 0: pthread_create(&thread, &threadAttr, &hwPump_UART_thread, NULL); break; case 1: pthread_create(&thread, &threadAttr, &hwPump_SPI_thread, NULL); break; case 2: pthread_create(&thread, &threadAttr, &hwPump_I2C_thread, NULL); break; } // release thread attr because we don't use it pthread_attr_destroy(&threadAttr); // increase priority to make pumps more even // Note: not sure if this is a good idea // // if (setRealtimePrio(thread) == FALSE) { // // not fatal // LOG_ERR("pump set_realtime_priority() failed!"); // } } // for }