Exemple #1
0
ScrobblerAdapter::ScrobblerAdapter( QObject *parent, const QString &clientId )
    : QObject( parent ),
      m_scrobbler( new lastfm::Audioscrobbler( clientId ) ),
      m_clientId( clientId ),
      m_lastSaved( 0 )
{
    DEBUG_BLOCK

    resetVariables();

    //HACK work around a bug in liblastfm---it doesn't create its config dir, so when it
    // tries to write the track cache, it fails silently. until we have a fixed version, do this
    // path finding code taken from liblastfm/src/misc.cpp
    QString lpath = QDir::home().filePath( ".local/share/Last.fm" );
    QDir ldir = QDir( lpath );
    if( !ldir.exists() )
    {
        ldir.mkpath( lpath );
    }
    
    connect( The::mainWindow(), SIGNAL( loveTrack( Meta::TrackPtr) ), SLOT( loveTrack( Meta::TrackPtr ) ) );
    connect( The::mainWindow(), SIGNAL( banTrack() ), SLOT( banTrack() ) );

    EngineController *engine = The::engineController();

    connect( engine, SIGNAL( stopped( qint64, qint64 ) ),
             this, SLOT( stopped( qint64, qint64 ) ) );
    connect( engine, SIGNAL( trackPositionChanged( qint64, bool ) ),
             this, SLOT( trackPositionChanged( qint64, bool ) ) );
    //Use trackChanged instead of trackPlaying to prevent reset of current track after Unpausing.
    connect( engine, SIGNAL( trackChanged( Meta::TrackPtr ) ),
             this, SLOT( trackPlaying( Meta::TrackPtr ) ) );
    connect( engine, SIGNAL( trackMetadataChanged( Meta::TrackPtr ) ),
             this, SLOT( trackMetadataChanged( Meta::TrackPtr ) ) );
}
Exemple #2
0
void Slic::generateSpx(Mat & frame)
{
	resetVariables();
	Mat frameLab;
	cvtColor(frame, frameLab, CV_BGR2Lab);
	frameLab.convertTo(frameLab, CV_32FC3);
	//initializa clusters
	int diamSpx_d2 = m_diamSpx / 2;
	for (int y = diamSpx_d2 - 1; y < m_height; y += m_diamSpx)
	{
		//Vec3f* frameLab_r = frameLab.ptr<Vec3f>(y);
		for (int x = diamSpx_d2 - 1; x < m_width; x += m_diamSpx)
		{
			center c;
			c.xy = Point(x, y);
			Vec3f cLab;
			moveToLowGrad(c.xy, cLab, frameLab);
			c.Lab[0] = cLab[0];
			c.Lab[1] = cLab[1];
			c.Lab[2] = cLab[2];

			m_allCenters.push_back(c);
		}
	}
	m_nSpx = (int)m_allCenters.size(); //real number of spx

	// iterate
	for (int it = 0; it < m_nIteration; it++)
	{
		findCenters(frameLab);
		updateCenters(frameLab);
	}
	//enforceConnectivity();
}
P_Crop::P_Crop( IWindow *dlg ) :

   ISetCanvas( P_CROP, dlg, dlg, IRectangle(),
     (ISetCanvas::classDefaultStyle    |
      ISetCanvas::decksByGroup         |
      ISetCanvas::packEven)            &
     ~ISetCanvas::packTight            ),

   enableCBx( P_CROP_ENABLE_CBX, this, this, IRectangle(),
      ICheckBox::classDefaultStyle     |
      IControl::group                  |
      IControl::tabStop                )
{
   // initialize variables
   resetVariables();

   // force a groupbox around the canvas
   setText( "Crop" ).disableGroup();

   // set the enable/disable checkbox
   enableCBx.setText( "enable" );

   // setup handlers
   ISelectHandler::  handleEventsFor( &enableCBx );
   ICommandHandler:: handleEventsFor( this );
   IMenuHandler::    handleEventsFor( this );
   IMenuHandler::    handleEventsFor( &enableCBx );

   return;
}
Exemple #4
0
PDCreceive::PDCreceive(long product) {
    pinMode(RECEIVEPIN, INPUT);
    //  irrecv.enableIRIn();              // Start the IR receiver
    
    my_id = product;
    resetVariables();
    
}
Exemple #5
0
void AvalancheEngine::initVariables() {
	for (int i = 0; i < 31; i++) {
		_also[i][0] = nullptr;
		_also[i][1] = nullptr;
	}

	memset(_fxPal, 0, 16 * 16 * 3);

	for (int i = 0; i < 15; i++) {
		_peds[i]._direction = kDirNone;
		_peds[i]._x = 0;
		_peds[i]._y = 0;
		_magics[i]._operation = kMagicNothing;
		_magics[i]._data = 0;
	}

	for (int i = 0; i < 7; i++) {
		_portals[i]._operation = kMagicNothing;
		_portals[i]._data = 0;
	}

	for (int i = 0; i < 30; i++) {
		_fields[i]._x1 = 0;
		_fields[i]._y1 = 0;
		_fields[i]._x2 = 0;
		_fields[i]._y2 = 0;
	}

	_fieldNum = 0;
	_cp = 0;
	_ledStatus = 177;
	_alive = false;
	_subjectNum = 0;
	_him = kPeoplePardon;
	_her = kPeoplePardon;
	_it = Parser::kPardon;
	_roomCycles = 0;
	_doingSpriteRun = false;
	_isLoaded = false;
	_soundFx = true;
	_holdTheDawn = false;

	_lineNum = 0;
	for (int i = 0; i < 50; i++)
		_lines[i]._color = kColorWhite;
	_dropsOk = false;
	_cheat = false;
	_letMeOut = false;
	_thinks = 2;
	_thinkThing = true;
	_animationsEnabled = true;
	_currentMouse = 177;
	_holdLeftMouse = false;

	resetVariables();
}
void SwingState::onExit(Scene & scene)
{
	stateManager_->MovementState().setDirection(xDirection_);
	stateManager_->MovementState().setSpeed(xSpeed_);
	stateManager_->MovementState().setAngle(angle_);
	stateManager_->MovementState().setRadius(radius_);
	stateManager_->MovementState().setKeyDirection(false);
	if (angleRange_ <= 0)
	{
		stateManager_->MovementState().setAngle(RESTING_ANGLE);
	}
	resetVariables();
}
void TSelectionClass::MakeSelection(UInt_t nEvents)
{if(nEvents==0)
	this->nEvents=eventReader->GetEntries();
else if(nEvents>eventReader->GetEntries()){
	cerr<<"nEvents is bigger than entries in eventReader tree: \""<<eventReader->getTree()->GetName()<<"\""<<endl;
}
else
	this->nEvents=nEvents;

if(verbosity)cout<<"Make Selection"<<endl;
if(verbosity)cout<<"goToSelectionTreeDir"<<endl;
settings->goToSelectionTreeDir();
histSaver->SetNumberOfEvents(this->nEvents);
createdTree=createSelectionTree(nEvents);
if(!createdTree) return;
this->setBranchAdressess();
createFiducialCut();
hFiducialCutSilicon->Reset();
hFiducialCutSiliconDiamondHit->Reset();
hFiducialCutSiliconOneAndOnlyOneDiamondHit->Reset();
hAnalysisFraction->Reset();
hSelectedEvents->Reset();
nUseForAlignment=0;
nUseForAnalysis=0;
nUseForSiliconAlignment=0;
nValidButMoreThanOneDiaCluster=0;
nValidSiliconNoDiamondHit=0;
nNoValidSiliconTrack=0;
nValidSiliconTrack=0;
nValidSiliconAndDiamondCluster=0;
nValidDiamondTrack=0;
nSiliconTrackNotFiducialCut=0;
nToBigDiamondCluster=0;
cout<<"start selection in  "<<nEvents<<" Events."<<endl;
if(settings->getTrainingMethod()==TSettings::enumFraction)
	cout<<"Use Fraction Training, with  fraction: "<<settings->getAlignment_training_track_fraction()*100.<<"%"<<endl;
else
	cout<<"Use the first "<<settings->getAlignmentTrainingTrackNumber()<<" Events for Alignment!"<<endl;
for(nEvent=0;nEvent<nEvents;nEvent++){
	TRawEventSaver::showStatusBar(nEvent,nEvents,100,verbosity>=20);
	eventReader->LoadEvent(nEvent);
	if(verbosity>10)cout<<"Loaded Event "<<nEvent<<flush;
	resetVariables();
	if(verbosity>10)cout<<"."<<flush;
	setVariables();
	if(verbosity>10)cout<<"."<<flush;
	selectionTree->Fill();
	if(verbosity>10)cout<<"DONE"<<endl;
}
createCutFlowDiagramm();
}
Exemple #8
0
void myGauge2::paintEvent(QPaintEvent *)
{
    QPainter painter(this);
    painter.setRenderHints(QPainter::Antialiasing|QPainter::TextAntialiasing);
    resetVariables(&painter);
    drawOuterCircle(&painter);
    drawInnerCircle(&painter);
    drawColorPie(&painter);
    drawCoverCircle(&painter);
    drawMark(&painter);
    drawIndicator(&painter);
    drawCoverBall(&painter);
    drawTextRect(&painter);
    painter.end();
}
//Begins Text Input
void getText(char *buffer)
{
	int FINISHED = 0;
	clearScreen();
	setupInterrupts();
	initializeSprites();
	drawKeyboard();
	playBG = TRUE;	
	while(!FINISHED)
	{
		if(playBG && !BGplaying)
        {
            // play the bg music
            DMA[2].cnt |= DMA_ON;
            REG_TM1CNT |= TM_ON;
            startBG = vblankcount;
            BGplaying = TRUE;
            DMA[2].src = flute;
        }
		checkMovement();
		//Check Input and End Function if finished
		if(!endInput)
		{
			checkSelection(buffer);
			copyShadow();
			waitForVblank();
			moveSpriteToMem();
		}
		else
		{
			DMA[2].cnt &= ~DMA_ON;
            REG_TM1CNT &= ~TM_ON;
			playBG = FALSE;
			waitForVblank();
			FINISHED = 1;
			resetVariables();
			endInput = 0;
			resetCursor();
		}
		
	}
	clearScreen();
}
void TSelectionClass::createFiducialCut(){

//	std::vector<std::pair<Float_t,Float_t> > xInt,yInt;
//	xInt.push_back( make_pair(settings->getSi_avg_fidcut_xlow(),settings->getSi_avg_fidcut_xhigh()));
//	yInt.push_back( make_pair(settings->getSi_avg_fidcut_ylow(),settings->getSi_avg_fidcut_yhigh()));
//	fiducialCuts = new TFidCutRegions(xInt,yInt,1);
	fiducialCuts = settings->getSelectionFidCuts();
	cout<<"Create AutoFidCut with "<<endl;
	fiducialCuts->Print(1);
	UInt_t nEvents = settings->getAutoFidCutEvents();
	if(nEvents>eventReader->GetEntries())nEvents=eventReader->GetEntries();
	cout<<" "<<nEvents<<endl;
	for(nEvent=0;nEvent<nEvents;nEvent++){
		TRawEventSaver::showStatusBar(nEvent,nEvents,100,verbosity>=20);
		eventReader->LoadEvent(nEvent);
		if(verbosity>10)cout<<"Loaded Event "<<nEvent<<flush;
		resetVariables();
		if(verbosity>10)cout<<"."<<flush;
		setVariables();
	}
	//  findFiducialCut(hFiducialCutSiliconDiamondHit);

	if(settings->getUseAutoFidCut()==true){
		delete fiducialCuts;
		fiducialCuts = new TFidCutRegions(hFiducialCutSiliconDiamondHit,settings->getNDiamonds(),settings->getAutoFidCutPercentage());
		fiducialCuts->setRunDescription(settings->getRunDescription());
	}
	else{
		fiducialCuts->setHistogramm(hFiducialCutSiliconDiamondHit);
	}
	histSaver->SaveCanvas(fiducialCuts->getFiducialCutCanvas(TPlaneProperties::X_COR));
	histSaver->SaveCanvas(fiducialCuts->getFiducialCutCanvas(TPlaneProperties::Y_COR));
	TCanvas *c1 = fiducialCuts->getFiducialCutCanvas(TPlaneProperties::XY_COR);
	c1->SetTitle(Form("Fiducial Cut of Run %i with \"%s\"",settings->getRunNumber(),settings->getRunDescription().c_str()));
	c1->SetName("cFidCutCanvasXY");
	histSaver->SaveCanvas(c1);
	if(verbosity)
		fiducialCuts->Print(1);
	if (verbosity>3&&verbosity%2==1){
		cout<<"Press a key and enter to continue..."<<flush;
		char t;
		cin >>t;
	}
Exemple #11
0
void MainWindow::on_enterButton_clicked()
{
    input2 = inputString.toDouble();
    if(function == "add"){
        answer = input1 + input2;
    }else if(function == "subtract"){
        answer = input1 - input2;
    }else if(function == "multiply"){
        answer = input1 * input2;
    }else if(function == "divide"){
        answer = input1 / input2;
    }

    inputString = QString::number(answer);
    ui->numberView->display(inputString);
    resetVariables();


}
Exemple #12
0
void myGauge1::paintEvent(QPaintEvent *)
{
    QPainter painter;
    painter.begin(this);
    painter.setRenderHints(QPainter::Antialiasing|QPainter::TextAntialiasing);

    resetVariables(&painter);
    drawOuterCircle(&painter);
    drawInnerCircle(&painter);
    drawColorPies(&painter);
    drawGraph(&painter);
    drawCoverLines(&painter);
    drawCoverCircle(&painter);
    drawMarkAndText(&painter);

    drawTextRect(&painter);

    painter.end();
}
void CDebugDrawer::removeFramebuffers()
{
	CTextureResource::bind(0, 0, GL_TEXTURE_2D);

	if(m_fboId != 0)
	{
		glDeleteFramebuffers(1, &m_fboId);
	}

	if(m_fboPickId != 0)
	{
		glDeleteTextures(1, &m_fboPickId);
	}

	if(m_fboDepthId != 0)
	{
		glDeleteTextures(1, &m_fboDepthId);
	}

	resetVariables();
}
Exemple #14
0
Common::Error MortevielleEngine::run() {
	// Initialize the game
	Common::ErrorCode err = initialize();
	if (err != Common::kNoError)
		return err;

	// Check for a savegame
	int loadSlot = 0;
	if (ConfMan.hasKey("save_slot")) {
		int gameToLoad = ConfMan.getInt("save_slot");
		if ((gameToLoad >= 1) && (gameToLoad <= 999))
			loadSlot = gameToLoad;
	}

	if (loadSlot == 0)
		// Show the game introduction
		showIntroduction();
	else {
		_caff = 51;
		_text->taffich();
	}

	// Either load the initial game state savegame, or the specified savegame number
	adzon();
	resetVariables();
	if (loadSlot != 0)
		_savegameManager->loadSavegame(generateSaveFilename(loadSlot));

	// Run the main game loop
	mainGame();

	// Cleanup (allocated in initialize())
	_screenSurface->free();
	free(_soundManager->_cfiphBuffer);
	free(_cfiecBuffer);

	return Common::kNoError;
}
Exemple #15
0
// ----- initialisation des registres specifiques au QEI -----
void QEIInit()
{
	resetVariables();
	
	LATCbits.LATC3 = 0;  //desactivation des pattes
	LATCbits.LATC4 = 0;
	LATBbits.LATB5 = 0;
	LATBbits.LATB6 = 0;

	TRISCbits.TRISC3 = 1; //configuration en tant qu'inputs
	TRISCbits.TRISC4 = 1;
	TRISBbits.TRISB5 = 1;
	TRISBbits.TRISB6 = 1;
	
	//reconfiguration des pattes RP19/20 (moteur gauche) et RP5/6 (moteur droit) en mode QEI
	RPINR14bits.QEA1R = 19; //phases A et B moteur gauche
	RPINR14bits.QEB1R = 20;
	RPINR16bits.QEA2R = 5;  //phases A et B moteur droit
	RPINR16bits.QEB2R = 6;	
	
	QEI1CON = 0x0000; //reset "propre" du registre
	QEI2CON = 0x0000;

	QEI1CONbits.QEIM = 0b111; //configuration en mode x4 (POSxCNT reset si = MAXxCNT)
	QEI2CONbits.QEIM = 0b111;
	
	QEI1CONbits.SWPAB = 1;
	
	MAX1CNT = 360-1;     //valeur maximale du compteur de position --> 360 pins par tour en x4
	MAX2CNT = 360-1;
	POS1CNT = 0;         //valeur initiale du compteur de position
	POS2CNT = 0;
	
	IEC3bits.QEI1IE = 1; //on active l'interruption
	IEC4bits.QEI2IE = 1;
	IFS3bits.QEI1IF = 0; //on reset le flag d'interruption
	IFS4bits.QEI2IF = 0;
}
void P_Crop::deleteExtraControls()
{
   // delete all of the unused controls
   IMenuHandler::stopHandlingEventsFor( xStartTxt );
   IMenuHandler::stopHandlingEventsFor( yStartTxt );
   IMenuHandler::stopHandlingEventsFor( xEndTxt   );
   IMenuHandler::stopHandlingEventsFor( yEndTxt   );
   IFocusHandler::stopHandlingEventsFor( xStartSB  );
   IFocusHandler::stopHandlingEventsFor( yStartSB  );
   IFocusHandler::stopHandlingEventsFor( xEndSB    );
   IFocusHandler::stopHandlingEventsFor( yEndSB    );
   delete( xStartTxt );
   delete( yStartTxt );
   delete( xStartSB  );
   delete( yStartSB  );
   delete( xEndTxt   );
   delete( yEndTxt   );
   delete( xEndSB    );
   delete( yEndSB    );
   resetVariables();

   return;
}
Exemple #17
0
//print the array when the end of transmission code is received
void PDCreceive::printTransmission() {
  
   Serial.println("print transmission called");
   Serial.print("index = "); Serial.println(h_index);
//   delay(10);
  
  for (int i=0; i<h_index; i++) {
    Keyboard.print(transmissionArray[0][i]);
//    delay(10);
    Keyboard.print(",");
//    delay(10);
    Keyboard.print(transmissionArray[1][i]);
//    delay(10);
    if (i == h_index-1) {
      Keyboard.print(":");
//      delay(10);
    } else {
      Keyboard.print(";");
//      delay(10);
    }
  }
  resetVariables();
}
Exemple #18
0
void HangState::onExit(Scene& scene)
{
	resetVariables();
}
int main(int argc, char **argv)
{
    daemonize();
    storepid();//Lagra pid nummer för att kunna stänga med stop-skript
    srand(time(NULL));

    gameOver = true;

    ghostHitCount = 0;

    r3p1v.x = 180;
    r3p1v.y = 97;
    r3p1v.w = 16;
    r3p1v.h = 50;

    r3p1h.x = 440;
    r3p1h.y = 97;
    r3p1h.w = 16;
    r3p1h.h = 50;

    r2p0v.x = 0;
    r2p0v.y = 195;
    r2p0v.w = 16;
    r2p0v.h = 50;

    r2p0h.x = 270;
    r2p0h.y = 195;
    r2p0h.w = 16;
    r2p0h.h = 50;

    r2p1v.x = 370;
    r2p1v.y = 195;
    r2p1v.w = 16;
    r2p1v.h = 50;

    r2p1h.x = 622;
    r2p1h.y = 195;
    r2p1h.w = 16;
    r2p1h.h = 50;

    r1p1v.x = 190;
    r1p1v.y = 297;
    r1p1v.w = 16;
    r1p1v.h = 50;

    r1p1h.x = 450;
    r1p1h.y = 297;
    r1p1h.w = 16;
    r1p1h.h = 50;

    r0p0v.x = 0;
    r0p0v.y = 415;
    r0p0v.w = 16;
    r0p0v.h = 50;

    r0p0h.x = 622;
    r0p0h.y = 415;
    r0p0h.w = 16;
    r0p0h.h = 50;

    ghostRect1.x = 300;
    ghostRect1.y = 97;
    ghostRect1.w = 50;
    ghostRect1.h = 50;

    ghostRect2.x = 50;
    ghostRect2.y = 195;
    ghostRect2.w = 50;
    ghostRect2.h = 50;

    ghostRect3.x = 500;
    ghostRect3.y = 195;
    ghostRect3.w = 50;
    ghostRect3.h = 50;

    ghostRect4.x = 300;
    ghostRect4.y = 297;
    ghostRect4.w = 50;
    ghostRect4.h = 50;

    ghostRect5.x = 400;
    ghostRect5.y = 415;
    ghostRect5.w = 50;
    ghostRect5.h = 50;

	IPaddress ip, *remoteIP;
	int quit, quit2;
	char buffer[512];
	bool clientInitiated;

	firstPosition = false;

	SDL_Thread *client1, *client2, *enemy1, *enemy2, *enemy3, *enemy4, *enemy5;

    positionSetMutex = SDL_CreateMutex();
    ghostHitMutex = SDL_CreateMutex();
    if(!positionSetMutex)
    {
        return 0;
    }
    if(!ghostHitMutex)
    {
        return 0;
    }
	initFunctions(&ip, &sd); //Initiera TCP för SDL

    enemy1 = SDL_CreateThread(nextMove, "ghost1", &ghostRect1);
    enemy2 = SDL_CreateThread(nextMove, "ghost1", &ghostRect2);
    enemy3 = SDL_CreateThread(nextMove, "ghost1", &ghostRect3);
    enemy4 = SDL_CreateThread(nextMove, "ghost1", &ghostRect4);
    enemy5 = SDL_CreateThread(nextMove, "ghost1", &ghostRect5);

    while(true)
    {
        if(gameOver == true)
        {
                waitForClients(&sd); // Väntar på 2 st klienter ska koppla upp sig
                resetVariables();
                gameOver = false;
                client1Position = 0;
                client1 = SDL_CreateThread(startClient, "Client1", (void *)NULL);
                client2 = SDL_CreateThread(startClient, "Client2", (void *)NULL);
                SDL_DetachThread(client1); // Förhindrar att tråden tar upp minne efter att den stänger ner
                SDL_DetachThread(client2);

        }

        SDL_Delay(1000);
    }

	SDLNet_TCP_Close(sd);
	SDLNet_Quit();

	return EXIT_SUCCESS;
}
Exemple #20
0
// Asservissement en vitesse des moteurs pour qu'il atteignent leur propre consigne
void asservirMoteurs(void){
	pos0 = position_m3; //pas inversé
	pos1 = pos1 + QEIVelocityGet(QEI1_BASE)*QEIDirectionGet(QEI1_BASE); //pas inversé
	pos2 = position_m2;//pas inversé
	pos3 =  pos3 - QEIVelocityGet(QEI0_BASE)*QEIDirectionGet(QEI0_BASE); //inversé
	
	ajustementVitesse();
	
	//Motor 0
	measured_speed0 =  (pos0 - previous_pos0)/dt;
	if(measured_speed0 < 0){
		measured_speed0 = -measured_speed0;
	}
	previous_pos0 = pos0;
	if(consigne0 > 3200){
		output0 = PIDHandler0(&consigne0, &measured_speed0, &I0, &previous_error0, dt);
	}
	else{
		output0 = SlowPIDHandler0(&consigne0, &measured_speed0, &I0, &previous_error0, dt);
	}
	//Motor 1
	measured_speed1 = QEIVelocityGet(QEI1_BASE)/dt;//(pos1 - previous_pos1)*10;
	if(measured_speed1 < 0){
		measured_speed1 = -measured_speed1;
	}
	previous_pos1 = pos1;
	if(consigne1 > 3200){
		output1 = PIDHandler1(&consigne1, &measured_speed1, &I1, &previous_error1, dt);
	}
	else{
		output1 = SlowPIDHandler1(&consigne1, &measured_speed1, &I1, &previous_error1, dt);
	}
	//Motor 2
	measured_speed2 = (pos2 - previous_pos2)/dt;
	if(measured_speed2 < 0){
		measured_speed2 = -measured_speed2;
	}
	previous_pos2 = pos2;
	if(consigne2 > 3200){
		output2 = PIDHandler2(&consigne2, &measured_speed2, &I2, &previous_error2, dt);
	}
	else{
		output2 = SlowPIDHandler2(&consigne2, &measured_speed2, &I2, &previous_error2, dt);
	}
	//Motor 3
	measured_speed3 = QEIVelocityGet(QEI0_BASE)/dt;//(pos3 - previous_pos3)*10;
	if(measured_speed3 < 0){
		measured_speed3 = -measured_speed3;
	}
	previous_pos3 = pos3;
	if(consigne3 > 3200){
		output3 = PIDHandler3(&consigne3, &measured_speed3, &I3, &previous_error3, dt);
	}
	else{
		output3 = SlowPIDHandler3(&consigne3, &measured_speed3, &I3, &previous_error3, dt);
	}
	
	/*output0 = output0_old +(dt/Tf0)*(output0-output0_old);
	output1 = output1_old +(dt/Tf1)*(output1-output1_old);
	output2 = output2_old +(dt/Tf2)*(output2-output2_old);
	output3 = output3_old +(dt/Tf3)*(output3-output3_old);
	output0_old = output0;
	output1_old = output1;
	output2_old = output2;
	output3_old = output3;*/
	
	//output0_table[index%10] = output0;
	//output1_table[index%10] = output1;
	//output2_table[index%10] = output2;
	//output3_table[index%10] = output3;

	
	//Traduction 6400e de tour fraction appliqué au pulse width
	float fraction0;
	float fraction1;
	float fraction2;
	float fraction3;
	//Une équation linéaire est utilisée x*0.5/7700 = % du duty cycle
	fraction0 = ((output0*0.5)/7700);
	if(fraction0 > 0.99){
		fraction0 = 0.99;
	}
	else if(fraction0 < 0){
		fraction0 = 0;
	}
	fraction1 = ((output1*0.5)/7700);
	if(fraction1 > 0.99){
		fraction1 = 0.99;
	}else if(fraction1 < 0){
		fraction1 = 0;
	}
	fraction2 = ((output2*0.5)/7700);
	if(fraction2 > 0.99){
		fraction2 = 0.99;
	}else if(fraction2 < 0){
		fraction2 = 0;
	}
	fraction3 = ((output3*0.5)/7700);
	if(fraction3 > 0.99){
		fraction3 = 0.99;
	}else if(fraction3 < 0){
		fraction3 = 0;
	}
	PWMPulseWidthSet(PWM_BASE, PWM_OUT_0, (periodPWM*fraction0));
	PWMPulseWidthSet(PWM_BASE, PWM_OUT_1, (periodPWM*fraction1));
	PWMPulseWidthSet(PWM_BASE, PWM_OUT_2, (periodPWM*fraction2));
	PWMPulseWidthSet(PWM_BASE, PWM_OUT_3, (periodPWM*fraction3));
	
	pos0_table[index%300]=GPIOPinRead(GPIO_PORTD_BASE, GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7);
	pos1_table[index%300]=GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_4 | GPIO_PIN_5);
	pos2_table[index%300]=pos2;
	pos3_table[index%300]=pos3;
	speed0_table[index%300]=measured_speed0;
	speed1_table[index%300]=measured_speed1;
	speed2_table[index%300]=measured_speed2;
	speed3_table[index%300]=measured_speed3;
	output0_table[index%300]=output0;
	output1_table[index%300]=output1;
	output2_table[index%300]=output2;
	output3_table[index%300]=output3;
	fraction0_table[index%300]=fraction0;
	fraction1_table[index%300]=fraction1;
	fraction2_table[index%300]=fraction2;
	fraction3_table[index%300]=fraction3;
	
	//Si le robot est immobile
	if(a_atteint_consigne && measured_speed0==0 && measured_speed1==0 && measured_speed2==0 && measured_speed3==0){
		resetVariables();
		resetQEIs();
		ROM_PWMPulseWidthSet(PWM_BASE, PWM_OUT_0, 0);//periodPWM / 4);
		ROM_PWMPulseWidthSet(PWM_BASE, PWM_OUT_1, 0);
		ROM_PWMPulseWidthSet(PWM_BASE, PWM_OUT_2, 0);
		ROM_PWMPulseWidthSet(PWM_BASE, PWM_OUT_3, 0);
		est_en_mouvement = false;
	}
	else{
		est_en_mouvement = true;
	}
}
Exemple #21
0
Sequence::Sequence(AvalancheEngine *vm) {
	_vm = vm;

	resetVariables();
}
Exemple #22
0
PDCreceive::PDCreceive() {
    pinMode(RECEIVEPIN, INPUT);
    //  irrecv.enableIRIn();              // Start the IR receiver
    
    resetVariables();
}
Exemple #23
0
Nim::Nim(AvalancheEngine *vm) {
	_vm = vm;

	resetVariables();
}
Exemple #24
0
void MainWindow::on_clearAllButton_clicked()
{
    resetVariables();
    ui->numberView->display("0");
}