void Program::startProgram() { time = 0; // Comms *c = new Comms(); // c->openSerial(); // Load config c.loadConfig(); // Start oven controller oven = new OvenController(); connect(oven, SIGNAL(updateTemp(float)), this, SLOT(updatePID(float))); oven->setConfig(&c); oven->openSerial(); // Create PID controller pid = PID(&c); pid.initialise(); // Create & connect timer timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(updateTick())); timer->start((1 / c.getSampleRate()) * 1000); }
void bHandler(void* args) { // Get the gpio handle from the args mraa::Gpio *encB = (mraa::Gpio*)args; int a = aState; int b = bState; int newB = encB->read(); bState = newB; int prevPhase = getPhase(a, b); int curPhase = getPhase(a, newB); updateTick(prevPhase, curPhase); }
void aHandler(void* args) { // Get the gpio handle from the args mraa::Gpio *encA = (mraa::Gpio*)args; int a = aState; int b = bState; int newA = encA->read(); aState = newA; int prevPhase = getPhase(a, b); int curPhase = getPhase(newA, b); updateTick(prevPhase, curPhase); }
void SharedFoldersWidget::setClient(BtsClient *newclient) { if(client) { api->disconnect(this); api->deleteLater(); api = nullptr; } client = newclient; api = new BtsApi(client, this); connect(api, SIGNAL(error(QString)), this, SIGNAL(error(QString))); connect(api, SIGNAL(getFoldersResult(QVector<BtsGetFoldersResult>,QString)), this, SLOT(updateFolders(QVector<BtsGetFoldersResult>))); connect(client, SIGNAL(clientStarted()), this, SLOT(updateTick())); connect(api, SIGNAL(addFolderResult()), this, SLOT(updateTick())); connect(api, SIGNAL(removeFolderResult(QString)), this, SLOT(updateTick())); }
SharedFoldersWidget::SharedFoldersWidget(QWidget *parent) :QWidget(parent) ,client(nullptr) ,api(nullptr) { setupUi(this); foldersTable->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); QTimer *updateTimer = new QTimer(this); updateTimer->setInterval(2000); updateTimer->start(); connect(updateTimer, SIGNAL(timeout()), this, SLOT(updateTick())); connect(addButton, SIGNAL(clicked()), this, SLOT(addFolder())); connect(removeButton, SIGNAL(clicked()), this, SLOT(removeFolder())); connect(infoButton, SIGNAL(clicked()), this, SLOT(folderInfo())); connect(foldersTable, SIGNAL(itemDoubleClicked(QTableWidgetItem*)), this, SLOT(itemDoubleClicked(QTableWidgetItem*))); }
void SplashState::run() { lairAssert(_initialized); log().log("Starting splash state..."); _running = true; _loop.start(); _fpsTime = sys()->getTimeNs(); _fpsCount = 0; do { switch(_loop.nextEvent()) { case InterpLoop::Tick: updateTick(); break; case InterpLoop::Frame: updateFrame(); break; } } while (_running); _loop.stop(); }
void MainState::run() { lairAssert(_initialized); log().log("Starting main state..."); _running = true; _loop.start(); _fpsTime = _game->sys()->getTimeNs(); _fpsCount = 0; unsigned lvl = 0; do { log().log("Our heroes strike",(lvl?".":" again !")); lvl += 20; _player.strat[rand()%NB_STRATS] = true; _player.strat[rand()%NB_STRATS] = true; _player.strat[rand()%NB_STRATS] = true; initFight(lvl); _state = PLAYING; do { switch(_loop.nextEvent()) { case InterpLoop::Tick: updateTick(); break; case InterpLoop::Frame: updateFrame(); break; } } while (_state != GAME_OVER && _running); } while (_fight->boss.hp && _running); log().log("The mighty has fallen..."); log().log("Stopping main state..."); _loop.stop(); }
bool perfMonitor::update(float &fFPS) { struct timeval Time; gettimeofday( &Time, NULL ); double time = Time.tv_sec + Time.tv_usec * 1.0/1000000.0; double dTick = time - _dLastTick; double d = updateTick( dTick ); _dLastTick = time; if( Time.tv_sec - _tvLastSec >= 1 ) { double time = Time.tv_sec + Time.tv_usec * 1.0/1000000.0; _fCurrentFPS = 1.f / d; _tvLastSec = Time.tv_sec; fFPS = _fCurrentFPS; return true; } else { fFPS = _fCurrentFPS; return false; } }
//----------------------------------------------------------------------------- // per frame simulation update void PhysicsVehicle::update( const float currentTime, const float elapsedTime ) { // prevent any updates with zero or negative delta time // prevent any updates where the elapsed time is > 5 sec // this might be a result of debugging // or is plainly very very bad if( ( elapsedTime <= 0.0f ) || ( elapsedTime > 5.0f ) ) { return; } bool ticked(false); // just update the tick structure _physicsUpdateTick.setAnimationInterval(getPhysicsUpdateFrameTime()); SLSize ticks(_physicsUpdateTick.update(elapsedTime, ticked)); if(ticked == false) { // just do nothing // a feature is missing here ... // state interpolation return; } // now read the internal motion state in case needed if(_dirtyLocalSpaceData) { _internalMotionState.readLocalSpaceData(*this); _dirtyLocalSpaceData = false; } // set the updateTick counter to the right value // this is a very interesting value for networking // assuming the physics frame rate does not change _updateTicks = ticks; // following code should be stable enough to change the physics frame rate during runtime const float deltaTime(static_cast<float>(_physicsUpdateTick.getAnimationInterval())); SLSize deltaTicks(ticks - _physicsUpdateTick.getLastAnimationTick()); float tickDeltaTime(static_cast<float>(deltaTicks) * deltaTime); float accumTime(static_cast<float>(_physicsUpdateTick.getTickedAccumTime())); accumTime -= tickDeltaTime; for(SLSize i(0); i < deltaTicks; ++i) { updateTick(accumTime, deltaTime); accumTime += deltaTime; } // pass over the internal 'fixed frame time' motion state to the 'render state' _motionState = _internalMotionState; SLTimeInterval missedDeltaTime(_physicsUpdateTick.getAccumTime() - _physicsUpdateTick.getTickedAccumTime()); if(missedDeltaTime != 0.0) { #if 0 printf("Missed dt(%f)\n", missedDeltaTime); #endif // integrate with given linear and angular velocity _motionState.integrateMotionState(static_cast<float>(missedDeltaTime)); } // and finally write the motion state back to the local space _motionState.writeLocalSpaceData(*this); if( _proximityToken != NULL ) { // notify proximity database that our position has changed _proximityToken->updateForNewPosition( position() ); } // annotation annotationVelocityAcceleration (5, 0); recordTrailVertex(static_cast<float>(_physicsUpdateTick.getAccumTime()), position()); }
void CrowdToolState::handleUpdate(const float dt) { if (m_run) updateTick(dt); }
bool Creature1Sp::update(const Constants::float_type dt) { updateTick(dt); return false; }