Example #1
0
//--------------------------------------------------------------
void testApp::update(){
	spriteRenderer->clear();
	spriteRenderer->update(ofGetElapsedTimeMillis());	
	sort( sprites.begin(), sprites.end(), sortVertically );
	
	if(sprites.size()>0){
		for(int i=sprites.size()-1;i>=0;i--){
            sprites[i]->pos.x = 0;
            sprites[i]->pos.y = 0;
//			sprites[i]->pos.y+=sprites[i]->speed;
//            sprites[i]->pos.x+=ofRandom(-2,2);
			if(sprites[i]->pos.y > ofGetHeight()+16){
				delete sprites[i];
				sprites.erase(sprites.begin()+i);
			}
			else
				spriteRenderer->addCenteredTile(&sprites[i]->animation, sprites[i]->pos.x, sprites[i]->pos.y);
		}
	}
	

}
Example #2
0
//--------------------------------------------------------------
void testApp::keyPressed  (int key){
    if (key=='w'||key=='W'||key==OF_KEY_UP) {
        
        shipMoveForward = true;
    }else if(key=='s'||key=='S'||key==OF_KEY_DOWN){
        
        shipMoveBack = true;
    }else if(key=='a'||key=='A'||key==OF_KEY_LEFT){
        
        shipRotateLeft =true;
    }else if(key=='d'||key=='D'||key==OF_KEY_RIGHT){
        
        shipRotateRight = true;
    }else if(key==' '){
    
        if (shield>0) {
            firstTime=ofGetElapsedTimeMillis();
            shield-=1;
        }
    }

}
//--------------------------------------------------------------
void imageLoader::update(){
	//ofBackground(255);


        timeline = ofGetElapsedTimeMillis();
        timeline %= SWITCH_SPEED;
        //cout <<timeline << endl;

        if(timeline < 500){
            goingUp = true;
            reload = true;
            anim = true;
        }

        if (timeline > 1200 && reload == true) {
            if (!path.empty()) {
            loadDir();
            reload = false;
            }
        }

}
//--------------------------------------------------------------
void ofxMSAInteractiveObject::_mouseReleased(ofMouseEventArgs &e) {
	int x = e.x;
	int y = e.y;
	int button = e.button;
	
	if(verbose) printf("ofxMSAInteractiveObject::_mouseReleased(x: %i, y: %i, button: %i)\n", x, y, button);
	if(!enabled) {
        _isMousePressed[button] = false;
        return;
    }
	
	if(hitTest(x, y)) {
		onRelease(x, y, button);
	} else {
		if(isMousePressed(button)) onReleaseOutside(x, y, button);
	}
	_isMousePressed[button] = false;

    _stateChangeTimestampMillis = ofGetElapsedTimeMillis();
    
    mouseReleased(x, y, button);
}
void BlossomParticle::update()
{
    
    long long tm = ofGetElapsedTimeMillis();
    switch(mState){
            case blossomStateGrowing:
                if(tm > mGrowStopTime)
                {
                    mState = blossomStateWaiting;
                }
                break;
            case blossomStateWaiting:
                if(tm > mWaitStopTime)
                {
                    mState = blossomStateFalling;
                }
                break;
//            case blossomStateFalling:
        default:
            break;
    }
}
Example #6
0
 void sinTraj::threadedFunction()
 {
	 while(isRunning()){
		if(checkTime<ofGetElapsedTimef()){
			double secondPos=((ofGetElapsedTimeMillis()-startTime)%1000)/1000.;
			double delay=.001;
			double ti=(ofGetElapsedTimef()-(checkTime-delay));
			checkTime=ofGetElapsedTimef()+delay;
			double yPos=pt.pos/maxAmp*h/2+y+h/2;
			//if(!index){
			pts.push_front(ofPoint(x+w,yPos));
			//}
			while(pts.size()&&pts[pts.size()-1].x<x) pts.pop_back();
			for(unsigned int i=0; i<pts.size(); i++){
				//if(abs(pts[i].y-pts[i+1].y)>7) pts[i].y=(pts[i].y+pts[i+1].y)/2;
				pts[i].x-=ti*(w/seconds);
			}
			tickPos-=ti*(w/seconds);
			if(tickPos<=0) tickPos+=w/numDivs;
		}
	 }
 }
void SomeScene::update() {

    int time_i = ofGetElapsedTimeMillis();

    fbo->begin();

    ofColor c  = ofColor::fromHsb((int)(time_i*0.005)%255, 200, 255);

    ofSetColor(c);
    ofFill();

    ofDrawRectangle(0,0,fbo->getWidth(), fbo->getHeight());

    ofEnableBlendMode(OF_BLENDMODE_ADD);

    ofSetColor(c.getInverted());

    myfont.drawString("OPENFRAMEWORKS", 10, fbo->getHeight()*0.5);

    fbo->end();

}
Example #8
0
void menu::checkCollisiton() {
   // cout << "check \n";
    
    
    _preState = _collistionFlag;
    
    float diffR = _parentR + _myR;
    
    /*
    cout << "diffR:";
    cout << diffR;
    cout << "px,py,mx,my:";
    cout << _parentPoint.x;
    cout << ", ";
    cout << _parentPoint.y;
    cout << ", ";
    cout << _myPoint.x;
    cout << ", ";
    cout << _myPoint.y;
    cout << "\n ";
    */
    
    float diffValue = sqrt(
                           (_parentPoint.x - _myPoint.x)*(_parentPoint.x - _myPoint.x)+
                           (_parentPoint.y - _myPoint.y)*(_parentPoint.y - _myPoint.y));
    if (diffValue < diffR) {
        _collistionFlag = true;
        if (_preState == false) {
            _startTime = ofGetElapsedTimeMillis();
        }
    } else {
        _collistionFlag = false;
        _menuSelected = false;
        _startTime = 0;
        _continueTime = 0;
    }
    
    measureTime();
}
Example #9
0
//--------------------------------------------------------------
void ofApp::draw(){
	
	ofEnableDepthTest();
	// we don't care about alpha blending in this example, and by default alpha blending is on in openFrameworks > 0.8.0
	// so we de-activate it for now.
	ofDisableAlphaBlending();
	
	ofBackgroundGradient(ofColor(18,33,54), ofColor(18,22,28));
	
	ofSetColor(ofColor::white);
	mCamMain.begin();
	
	// bind the shader
	mShdInstanced->begin();
	// give the shader access to our texture
	mShdInstanced->setUniformTexture("tex0", mTexDepth, 0);
	// feed the shader a normalized float value that changes over time, to animate things a little
	mShdInstanced->setUniform1f("timeValue", (ofGetElapsedTimeMillis() % 30000) / 30000.0f);
	// we only want to see triangles facing the camera.
	glEnable(GL_CULL_FACE);
	glCullFace(GL_BACK);

	// let's draw 128 * 128 == 16384 boxes !
	mVboBox.drawInstanced(OF_MESH_FILL, 128*128);

	glDisable(GL_CULL_FACE);
	mShdInstanced->end();
	
	mCamMain.end();

	ofDisableDepthTest();

	ofSetColor(ofColor::white);
	ofDrawBitmapString("Use mouse to move camera.\nPress 'f' to toggle fullscreen;\nSPACEBAR to reload shader.", 10, 20);
	
	ofEnableAlphaBlending();
	
	
}
//-------------------------------------------------------------------------
void pmWarpPiRendererVideoPlayer::updateForScreen()
{
//    ofLog(OF_LOG_NOTICE) << "RendVideoPlayer::update";
    
    /// TWEENZOR
    Tweenzor::update( ofGetElapsedTimeMillis() );
    screenOpacity = screenOpacity; //Why?
    
    
    if(isTesting)
    {
        this->setPlayerVolume(0);
    }
    else
    {
        if(isFading)
            this->setPlayerVolume(screenOpacity * audioVolume);
        else
            this->setPlayerVolume(audioVolume);
    }
    this->updatePlayer();
}
Example #11
0
//--------------------------------------------------------------
void ofxOPC::tryConnecting()
{
    if (!client.isConnected())
    {
        if (connectionAttempts <= 3)
        {
            if(timer >= endTime && !tryReconnecting)
            {
                tryReconnecting = true;
                ofLog(OF_LOG_NOTICE, "Trying to Reconnect: Attempt "+ofToString(connectionAttempts));
                connect();
                startTime = ofGetElapsedTimeMillis();
                connectionAttempts++;
                tryReconnecting = false;
            }
            else
            {
                
            }
        }
    }
}
Example #12
0
//--------------------------------------------------------------
/*public */void ofxSimpleButton::setAsAnimationButton(int time){
    
    ofImage a;
    if(!a.loadImage(b_img_route+"__.png")) return;
    
    a_img_fbo.allocate(a.getWidth(), a.getHeight());
    
    a_img_fbo.begin();
    ofClear(255, 0);
    a_img_fbo.end();
    
    a_img_fbo.begin();
    a.draw(0, 0);
    a_img_fbo.end();
    
    bAnimation = true;
    ofAddListener(ofEvents().update, this, &ofxSimpleButton::update);
    
    aniTime = ofGetElapsedTimeMillis();
    changeTime = time;
    
}
Example #13
0
//--------------------------------------------------------------
void ofxPowerMate::update(ofEventArgs & arg){

    res = hid_read(handle, buf,  sizeof(buf));
   
   
    if(res>0){// && ofGetElapsedTimeMillis() > elapsed+10){
        //hay datos
        
        data.presionado = buf[0];
        data.direccion = buf[1];
        
        if(data.direccion>127)
            data.direccion--;
        
        data.direccion = ((data.direccion + 127) % 255) - 127;

        ofNotifyEvent(tengoInfo, data);
        
        elapsed = ofGetElapsedTimeMillis();
    }

}
void SimpleMission::debugDraw(void){
    int posX = 100;
    int posY = ofGetHeight()-100;
    ofSetColor(255, 255, 255);
    string tmp;
    switch(MissionState){
        case MISSION_IDLE:
            tmp = "MISSION_IDLE";
            break;
        case MISSION_CALIFICATIONS:
            tmp = "MISSION_CALIFICATIONS";
            break;
        case MISSION_STARTED:
            tmp = "MISSION_STARTED";
            break;
        case MISSION_COMPLETED:
            tmp = "MISSION_COMPLETED";
            break;
            
    }

    ofDrawBitmapString(tmp, posX,posY);

    ofDrawBitmapString("Id mission:", posX,posY-20);
	ofDrawBitmapString(ofToString(MissionID, 0), posX + 100,posY-20);
	
    ofDrawBitmapString("Mission Elements:", posX,posY);
	
    ofDrawBitmapString("HIT", posX,posY+40);
    int NoOfElements = MissionElements.size();
    for (int i=0; i < NoOfElements; i++){
        ofDrawBitmapString(ofToString(MissionElements[i].identifier),posX+150+(20*i), posY+20);
        if (true == MissionElements[i].hit){
            ofDrawBitmapString(ofToString(MissionElements[i].identifier),posX+150+(20*i), posY+20);
        }
    }
    if (MISSION_STARTED == MissionState)
        ofDrawBitmapString("Elapsed Milis"+ofToString(ofGetElapsedTimeMillis()-Timer),posX, posY+40);
}
Example #15
0
//--------------------------------------------------------------
void ofApp::draw(){
    ofBackground(0, 0, 0);
    fbo.begin();
    ofClear(0.,0.,0., 0.);
    if(playMode==0){drawWaves();}
    else if (playMode==1){drawBlobs();}
    
    fbo.end();
    fbo.readToPixels(pix);
    pix.getData();
    
    for(int i=0; i<totalSpeakers;i++){
        if(pix.getColor(solenoidArray[i].pos.x, solenoidArray[i].pos.y).r>0 && solenoidArray[i].isActive==false){
            solenoidArray[i].isActive=true;
            solenoidArray[i].timeStamp=ofGetElapsedTimeMillis();
        }
        
        if(solenoidArray[i].isActive != activeSolenoid[i]){
            ofxOscMessage n;
            n.setAddress("/OF");
            n.addFloatArg(i);
            n.addIntArg(playMode); // playMode
            n.addIntArg(solenoidArray[i].isActive); //is active?
            n.addIntArg(nodeID); //index
            sender.sendMessage(n);
            activeSolenoid[i] = solenoidArray[i].isActive;// update our reference node
            cout << "OSC: Noid "<< i << " is " << solenoidArray[i].isActive << " -- nodeID: " << nodeID << endl;
        }
    }
    
    //    fbo.draw(0,0);
    
    //    ofDrawBitmapString(msg, ofGetWidth()/2, ofGetHeight()/2);
    for (int i=0; i<totalSpeakers; i++) {
        drawCircle(i);
    }
    
}
Example #16
0
void ttRope::setup(ofPoint &accFrc,ofPoint &_screenA,ofPoint &_screenB, ofPoint &_CharA, ofPoint &_CharB,ttControl &cont, int num){
    acc = &accFrc;
    screenA = &_screenA;
    screenB = &_screenB;
    charA = &_CharA;
    charB = &_CharB;
    control = &cont;
    ropeNum = num;
    
    
    world.init();
    world.setFPS(60);
    if (ropeNum == 0) {
        world.setGravity(0,9.8);
    }else{
        world.setGravity(0,-9.8);
    }
    
    
    bRopeInUse = false;
    bFall = false;
    bHooked = false;
    bReady = false;
    bInitialize = false;
    bInSky = false;
    bSwing = false;
    counter = 0;
    m_num = 30;
    m_preNum = 30;
    
    startTime = ofGetElapsedTimeMillis();
    duration = 100;
    closetRect = 0;
    
    rectW = 15;
    rectH = 2;
    rectOff = 14;
}
Example #17
0
//--------------------------------------------------------------
void ofApp::update(){
    //sequencer timing
    int millis = ofGetElapsedTimeMillis();
    if(millis - now >= delay){
        //increment sequencer step
        currentSequencerStep = (currentSequencerStep +1 ) % numSequencerSteps;
        
        bool isOn = zoneSequencer.getParamValueBool(sequencerTogglePrefix+ofToString(currentSequencerStep));
        
        if(zoneSequencer.getParamValueBool(playbackParamName))
            zoneSequencer.getParamValueBool(ofxAVUIZone::TOGGLE_PLAY) = isOn;
        
        now = millis;
    }
    //gesture traversal
    gestureTraversal += zoneSequencer.getParamValueFloat(filterSpeedParamName);
    if(gestureTraversal > 1.0) gestureTraversal = 0.0;
    //ofPolyline deals with getting the interpolated position, nice!
    gestureCurrentPoint = gesture.getPointAtPercent(gestureTraversal);
    gestureSize = gesture.size();
    //map to filter
    if(gestureSize > 0){
        ofParameter<float> frequencyParam = zoneSequencer.getParamValueFloat("frequency");
        ofParameter<float> resonanceParam = zoneSequencer.getParamValueFloat("resonance");
        
        float frequency = ofMap(gestureCurrentPoint.x, padBounds.x, padBounds.x+padBounds.width,
                                frequencyParam.getMin(), frequencyParam.getMax());
        float resonance = ofMap(gestureCurrentPoint.y, padBounds.y, padBounds.y+padBounds.height,
                                resonanceParam.getMin(), resonanceParam.getMax());
        cout << "frequency: " << frequency << endl;
        cout << "resonance: " << resonance << endl;
        zoneSequencer.getParamValueFloat("frequency") = frequency;
        zoneSequencer.getParamValueFloat("resonance") = resonance;
    }else{
        //draw circle offscreen
        gestureCurrentPoint.set(-100, -100);
    }
}
Example #18
0
void Level::update(bool _bricks){
    ofBackground(back);
    title_back.update();
    if(title_back.activate == true){
        back = ofColor(ofRandom(255),ofRandom(255),ofRandom(255));
        back.setBrightness(255);
        title_back.reset();
    }
    if(ofGetElapsedTimeMillis()-start<=timelimit){
        if(level_bars.activate == true){
            level_bars.reset();
        }
        copter.update();
        for(int i=0; i<bricks.size(); i++){
            bricks[i].update();
        }
        flocker.applyForces(80, 0.4, 0.75);
        flocker.update();
        level_bars.update();
    } else if(level>0){
        checkWin(_bricks);
    }
    if(level==0){
        title_word1.update();
        if(title_word1.activate == true){
            word1 = ofColor(ofRandom(255),ofRandom(255),ofRandom(255));
            word1.setBrightness(255);
            title_word1.reset();
        }
        title_word2.update();
        if(title_word2.activate == true){
            word2 = ofColor(ofRandom(255),ofRandom(255),ofRandom(255));
            word2.setBrightness(255);
            title_word2.reset();
        }
    }
    copter.bait.update();
}
void ofxSimpleTimer::start( bool _bLoop , bool bForceReset )
{
	//ofLog( OF_LOG_VERBOSE , "ofxSimpleTimer::start() " ) ;

    //We don't want to start the timer if it's already running
    bool bStartTimer = !bIsRunning ;
   	 
    //Unless we specifically want it too
    if ( bForceReset == true )
        bStartTimer = true ;
    
    if ( bStartTimer == true )
    {
	
        bIsRunning = true ;
		bIsPaused = false;
        startTimeMillis = ofGetElapsedTimeMillis() ;
        bLoop = _bLoop ;
        int args = 18 ;
        ofNotifyEvent( TIMER_STARTED , args ) ;
        //ofLog( OF_LOG_VERBOSE , name + " ofxSimpleTimer::start() " ) ;
    }
}
Example #20
0
	// return true if a refresh was done
	bool objectLifeTimeManager::refreshAnimation() {
		if (startTime == 0) {
			start();
			return false;
		}
		float t = ofGetElapsedTimef() - startTime;

		if (t < getWait()) {
			return false;// waiting to start
		}
		//wait = 0; // skip all future usage of wait once we start
				  // check for expired flag 
		if (getObjectLifetime() > 0 && t > getObjectLifetime()) {
			expired = true; // duration of 0 means no expiration
			return false;
		}
		// at this point we can start the time over w/o a wait
		if (t > getRefreshRate()) {
			startTime = ofGetElapsedTimeMillis();
			return true;
		}
		return false;
	}
Example #21
0
void faceDetect::setup(){	
	// setup tracker - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	finder.setup("haarcascade_frontalface_default.xml");
	cam_width = 640; cam_height = 480;
	track_width = 320; track_height = 240;

	vidGrabber.initGrabber(cam_width, cam_height);
	
	vidGrabber.setUseTexture(false);
	camImg.allocate(cam_width, cam_height);
	camImg.setUseTexture(false);
	trackImg.allocate(track_width, track_height);
	trackImg.setUseTexture(false);
	trackImg_gray.allocate(track_width, track_height);
	trackImg_gray.setUseTexture(false);
	finder.findHaarObjects(trackImg_gray);
	tracker_fps = 0;
	framecounter = 0;
	frame_timestamp = ofGetElapsedTimeMillis();
	
	blobsFound = 0;

}
Example #22
0
void Skulls::skullBehaviour()
{
	if (spawntime > 120000)
	{
		GlobalData::enemyType = "skull";
		if (skullPos.x < ofGetWidth()/2 || skullPos.x > ofGetWidth()/2)
			skullPos.x +=1;
		else
		{
			createProjectile();
			if (spawntime >= 155000)
				skullPos.x +=1;
		}

		skull.setPosition(skullPos);
		if (skullPos.x >= ofGetWidth()+500)
			{
				spawnstartTime = ofGetElapsedTimeMillis();
				skullPos.x =-500;
				GlobalData::enemyType = "dragon";
			}
	}
}
//------------------------------------------------------------
ofxParticle::ofxParticle(int width_,int height_, int lifeTime_, int radius_, float fadeOut_){
	setInitialCondition(0,0,0,0);
    
    width = width_;
    height = height_;
    isAlive = true;
    lifeTime = lifeTime_;
    radius = radius_;
    fadeOut = fadeOut_;
    creationTime = ofGetElapsedTimeMillis();
    
	damping	= 0.03f;
	
    seperation.distance		= ofRandom(5,50);
	//seperation.distance		= 35;
	alignment.distance		= 80;
	cohesion.distance		= 90;
	
	seperation.strength		= .03;
    alignment.strength		= .015;
	cohesion.strength		= .015;
	
}
//------------------------------------------------
void SimpleMission::update(void){
    if (MissionState == MISSION_STARTED){
        /* the timer is checked only in the MISSION_STARTED state */
        if ((ofGetElapsedTimeMillis() - Timer) > MissionDuration){     /// TODO SET idcurrentMission to 0 when this finish the timer
            MissionState = MISSION_COMPLETED;
            /* Notify the state change */
            
            eventMission evtMission;
            
			evtMission.pMission = this;//TODO
			evtMission.idCurrentMission = MissionID;
			
            evtMission.eventType = eventMission::MISSION_EVENT_MISSION_COMPLETED;
            ofNotifyEvent(eventMission::onMissionUpdate, evtMission);

            
        }
    }
    if (MissionState == MISSION_COMPLETED){
        resetMission();
    }
    
}
//------------------------------------------------------------------------------
void ofxIpVideoServerRoute::pushFrame(ofPixels& pix) {
    if(pix.isAllocated()) {
        unsigned long long timestamp = ofGetElapsedTimeMillis();
        ofPixels pixels(pix); // copy the pixels
        ofSaveImage(pixels, buffer, OF_IMAGE_FORMAT_JPEG, settings.quality);
        vector<ofxIpVideoServerFrameQueue*>::iterator iter = queues.begin();
        ofxIpVideoServerFrame::Settings settings;
        settings.quality = settings.quality;
        ofxIpVideoServerFramePtr frame = ofxIpVideoServerFramePtr(new ofxIpVideoServerFrame(buffer,
                                                                                            timestamp,
                                                                                            settings));

        while(iter != queues.end()) {
            if((*iter) != NULL && (*iter)->isActive()) {
                (*iter)->push(frame);
            }
            ++iter;
        }
            
    } else {
        ofLogError("ofxIpVideoServerRoute::pushFrame") << "Pushing unallocated pixels.";
    }
}
void TrailParticles::begin()
{
    if(!bEnabled) return;
    data->bUseFrameBuffer = true;

    currentTree = data->currentTree;
    curTime = ofGetElapsedTimeMillis();
    prevTime = curTime;
    bPlayAnim = true;
    ofLogVerbose() << "Trail Particles BEGIN";

    for (int unsigned i=0; i<NUM_BILLBOARDS; i++)
    {
        if(data->direction == 1) {
            billboardVels[i].set(ofRandomf()*5, 0.0, 0);
            billboards.getVertices()[i].set(200, ofRandom(100, 800), 0);
        } else {
            billboardVels[i].set(ofRandomf()*-5, 0.0, 0);
            billboards.getVertices()[i].set(1200-200, ofRandom(100, 800), 0);
        }
        billboards.getColors()[i].set(ofColor::fromHsb(ofRandom(190,255), ofRandom(150,255), 255));
    }
}
void PMDeviceAudioAnalyzer::notifySilence(bool b)
{
    float timeOfSilence = ofGetElapsedTimeMillis() - notSilenceBeginTime;

    bool sendSilenceEvent = ((timeOfSilence > silenceTimeTreshold) && (oldTimeOfSilence <= silenceTimeTreshold));
//    if (sendSilenceEvent)
    {
        silenceParams silenceParams;
        silenceParams.deviceID = deviceID;
        silenceParams.audioInputIndex = audioInputIndex;
        silenceParams.isSilent = b;
        ofNotifyEvent(eventSilenceStateChanged, silenceParams, this);
    }

    oldTimeOfSilence = timeOfSilence;

    bool sendPauseEvent = false;

    if (timeOfSilence > pauseTimeTreshold)
    {
        sendPauseEvent = !isInPause;
        isInPause = true;
    } else
    {
        sendPauseEvent = isInPause;
        isInPause = false;
    }

    if (sendPauseEvent)
    {
        pauseParams pauseParams;
        pauseParams.deviceID = deviceID;
        pauseParams.audioInputIndex = audioInputIndex;
        pauseParams.isPaused = isInPause;
        ofNotifyEvent(eventPauseStateChanged, pauseParams, this);
    }
}
Example #28
0
//--------------------------------------------------------------
void testApp::setup(){

    capW = 240;
    capH = 130;
    	
    vidGrabber.setDeviceID(0);
    vidGrabber.initGrabber(capW, capH);
    capW = vidGrabber.getWidth();
    capH = vidGrabber.getHeight();
    colorImg.allocate(capW,capH);
    grayImage.allocate(capW,capH);
    grayBg.allocate(capW,capH);
    grayDiff.allocate(capW,capH);
    
    threshold = 80;
    
    imageNumber = 0;
    img.clear();
    
    time = ofGetElapsedTimeMillis();
    timeTemp = 0;

    //bLearnBackgroundTime = ofGetElapsedTimeMillis();
    bLearnBackground = true;
    
    slideshow=false;
    slide=0;
    if(wiringPiSetup() == -1){
        printf("Error on wiringPi setup\n");
    }
    pinMode(0, INPUT);
    sensor0= false;
    controlsensor=0;
    
    ofSetVerticalSync(true);
    ofSetFrameRate(20);
}
Example #29
0
void ofxArtnet::threadedFunction(){
    printf("ofxArtnet::threadedFunction\n");
    int maxsd;
    fd_set rset;
    struct timeval tv;
    while(isThreadRunning()) {
        switch (status) {
            case NODES_FINDING:
                while (ofGetElapsedTimeMillis() - find_timeout < _TIMEOUT) {
                    FD_ZERO(&rset);
                    FD_SET(sd, &rset);
                    tv.tv_usec = 0;
                    tv.tv_sec = _TIMEOUT / 1000.f;
                    maxsd = sd;
                    
                    switch (select(maxsd+1, &rset, NULL, NULL, &tv)) {
                        case 0:
                            // timeout
                            break;
                        case -1:
                            printf("select error\n");
                            break;
                        default:
                            artnet_read(node,0);
                            break;
                    }
                }
                if ( nodes_found > 0) status = NODES_FOUND;
                else status = NOT_READY;
                stopThread();
                break;
                
            default:
                break;
        }
    }
}
Example #30
0
//--------------------------------------------------------------
void testApp::recordFrameXML (){
	
	if (leap.isFrameNew()){
		
		// Get the vector of Hands from ofxLeap.
		vector <Hand> hands = leap.getLeapHands();
		
		bRecordingThisFrame = true;
		lastTagNumber = XML.addTag("FRAME");
		if( XML.pushTag("FRAME", lastTagNumber) ){
			
			int frameTime = ofGetElapsedTimeMillis() - recordingStartTimeMillis;
			XML.setValue("COUNT", recordingFrameCount,lastTagNumber);
			XML.setValue("TIME", frameTime, lastTagNumber);
			XML.setValue("NH", (int)hands.size(), lastTagNumber);
			
			// For each hand, get the current hand
			if (hands.size() > 0) {
				for (int h=0; h<hands.size(); h++){
					
					Hand & hand = hands[h];
					recordHandXML (hand, h);
				}
			}
			
			XML.popTag(); // pop FRAME
			bRecordingThisFrame = false;
			recordingFrameCount++;
		}
		
	} else {
		bRecordingThisFrame = false;
	}
	
	
}