Example #1
0
int main(void)
{   
    initializeHardware();
    initializeVariables();
    
    uint8 ledTiming = 0;
    
    for (;;) 
    {
            
        mainTask();
        buttonTask();
        
        if (ledTiming == 200)   // led have to be changed only every 1000ms
        {
            ledTask();
            ledTiming = 0;
        }
        ledTiming++;
        
        Timer_delayMs(5);
     }

    return 0 ;
}
Example #2
0
GLSprite::GLSprite(GLTexture* texture, Rectangle textureRectangle)
{
    initializeVariables();
    _texture          = texture;
    _textureRectangle = textureRectangle;
    generateVertices();
    generateTextureCoordinates();
}
Example #3
0
void cStream::runBenchmarkTuned()
{
  initializeVariables();
  runChecks();
  runTunedTests();
  checkSTREAMresults();
  calculateBandwidthResults();
  outputSummary();
}; // void cStream::runBenchmarkTuned()
DynamicDiscretization::DynamicDiscretization( UserInteraction* _userInteraction )
                      :AlgorithmicBase( _userInteraction ){

    // setup options and loggings for stand-alone instances
    if ( _userInteraction == 0 ){

         setupOptions( );
         setupLogging( );
    }
    initializeVariables();
}
void WMLSelectElement::selectInitialOptions()
{
    // Spec: Step 1 - the default option index is determined using iname and ivalue
    calculateDefaultOptionIndices();

    if (m_defaultOptionIndices.isEmpty())
        return;

    // Spec: Step 2 – initialise variables
    initializeVariables();

    // Spec: Step 3 – pre-select option(s) specified by the default option index 
    selectDefaultOptions();
}
/**
 * Initializes the structure; returns false if failure during initialization
 *
 */
uint8_t Configuration::initialize()
{
	uint8_t flag = false;

	EEPROM.begin(FLASH_SIZE);

	Serial.print(F("Reading client configuration...."));
	flag = read();
	if( flag)
	{
		Serial.print(F("checking version..."));
		if( getVersion() == DEFAULT_VERSION )
		{
			Serial.print(F("version matches: "));
			flag = true;
		}
		else
		{
			Serial.print(F("version mismatch: "));
			flag = false;
		}
		Serial.println( getVersion(), HEX );
	}
	else
	{
		Serial.println(F("**ERROR - unable to read configuration."));
	}

	if( !flag )
	{
		Serial.print(F("Initializing configuration..."));
		initializeVariables();
		Serial.print(F("writing..."));
		flag = write();
		if( flag )
		{
			Serial.println(F("SUCCESS!"));
		}
		else
		{
			Serial.println(F("**FAILURE!"));
		}
	}

	dump();

	return flag;

}
JabberFileTransfer::JabberFileTransfer ( JabberAccount *account, XMPP::FileTransfer *incomingTransfer )
{
	kDebug(JABBER_DEBUG_GLOBAL) << "New incoming transfer from " << incomingTransfer->peer().full () << ", filename " << incomingTransfer->fileName () << ", size " << QString::number ( incomingTransfer->fileSize () );

	mAccount = account;
	mXMPPTransfer = incomingTransfer;

	// try to locate an exact match in our pool first
	mContact = mAccount->contactPool()->findExactMatch ( mXMPPTransfer->peer () );

	if ( !mContact )
	{
		// we have no exact match, try a broader search
		mContact = mAccount->contactPool()->findRelevantRecipient ( mXMPPTransfer->peer () );
	}

	if ( !mContact )
	{
		kDebug(JABBER_DEBUG_GLOBAL) << "No matching local contact found, creating a new one.";

		Kopete::MetaContact *metaContact = new Kopete::MetaContact ();

		metaContact->setTemporary (true);

		mContact = mAccount->contactPool()->addContact ( mXMPPTransfer->peer (), metaContact, false );

		Kopete::ContactList::self ()->addMetaContact ( metaContact );
	}

	connect ( Kopete::TransferManager::transferManager (), SIGNAL (accepted(Kopete::Transfer*,QString)),
			  this, SLOT (slotIncomingTransferAccepted(Kopete::Transfer*,QString)) );
	connect ( Kopete::TransferManager::transferManager (), SIGNAL (refused(Kopete::FileTransferInfo)),
			  this, SLOT (slotTransferRefused(Kopete::FileTransferInfo)) );

	initializeVariables ();

	if (!mXMPPTransfer->thumbnail().isNull()) {
		JT_BitsOfBinary *task = new JT_BitsOfBinary ( mAccount->client()->rootTask() );
		connect ( task, SIGNAL(finished()), this, SLOT(slotThumbnailReceived()) );
		task->get ( mXMPPTransfer->peer(), QString(mXMPPTransfer->thumbnail().data) );
		task->go ( true );
		QTimer::singleShot ( 5000, this, SLOT(askIncomingTransfer()) ); // Wait for thumbnail max 5s
	} else {
		askIncomingTransfer ();
	}
}
JabberFileTransfer::JabberFileTransfer ( JabberAccount *account, JabberBaseContact *contact, const QString &file )
{
	kDebug(JABBER_DEBUG_GLOBAL) << "New outgoing transfer for " << contact->contactId() << ": " << file;

	mAccount = account;
	mContact = contact;
	mLocalFile.setFileName ( file );
	bool canOpen=mLocalFile.open ( QIODevice::ReadOnly );
	
	mKopeteTransfer = Kopete::TransferManager::transferManager()->addTransfer ( contact,
																			  mLocalFile.fileName (),
																			  mLocalFile.size (),
																			  contact->contactId (),
																			  Kopete::FileTransferInfo::Outgoing );


	connect ( mKopeteTransfer, SIGNAL (result(KJob*)), this, SLOT (slotTransferResult()) );

	mXMPPTransfer = mAccount->client()->fileTransferManager()->createTransfer ();

	initializeVariables ();

	connect ( mXMPPTransfer, SIGNAL (connected()), this, SLOT (slotOutgoingConnected()) );
	connect ( mXMPPTransfer, SIGNAL (bytesWritten(qint64)), this, SLOT (slotOutgoingBytesWritten(qint64)) );
	connect ( mXMPPTransfer, SIGNAL (error(int)), this, SLOT (slotTransferError(int)) );
	
	FTThumbnail preview;
	QImage img=QImage(mLocalFile.fileName());
	if(!img.isNull())
	{
		img=img.scaled(64,64,Qt::KeepAspectRatio);
		QByteArray ba;
		QBuffer buffer(&ba);
		buffer.open(QIODevice::WriteOnly);
		img.save(&buffer, "PNG"); // writes image into ba in PNG format
		preview= FTThumbnail(ba,QString("image/png"),img.width(),img.height());
	}

	  
	if(canOpen) {
		mXMPPTransfer->sendFile ( XMPP::Jid ( contact->fullAddress () ), KUrl(file).fileName (), mLocalFile.size (), "", preview);
	} else {
		mKopeteTransfer->slotError ( KIO::ERR_CANNOT_OPEN_FOR_READING, file );
	}

}
BEGIN_NAMESPACE_ACADO




//
// PUBLIC MEMBER FUNCTIONS:
//

DynamicDiscretization::DynamicDiscretization()
                      :AlgorithmicBase( ){

    setupOptions( );
    setupLogging( );

    initializeVariables();
}
bool CovariantMovementPrimitive::initialize(const int num_time_steps,
                                            const int num_dimensions,
                                            const double movement_duration,
                                            const std::vector<Eigen::MatrixXd>& derivative_costs,
                                            const std::vector<Eigen::VectorXd>& initial_trajectory)
{
  num_time_steps_ = num_time_steps;
  num_dimensions_ = num_dimensions;
  movement_duration_ = movement_duration;
  derivative_costs_ = derivative_costs;
  parameters_all_ = initial_trajectory;

  ROS_VERIFY(initializeVariables());
  ROS_VERIFY(initializeCosts());
  ROS_VERIFY(initializeBasisFunctions());

  return true;
}
int main(void)
{
    setupHardware();
    printf("\r\n++++++++++++++++++++++\r\n");
    printf("Megalan Controller 2.3\r\n");
    printf("++++++++++++++++++++++\r\n");
    initializeVariables();
    //wait pir to stabilize
    delayMs(1000);
    

    while (1)
    {
        printf("\r\nAwake\r\n");

        if (processIRCommand)
        {
            handleIR();
        }

        if (checkPIR() && !pirActive)
        {
            handleMovement();
        }
        else if (!checkPIR() && pirActive)
        {
            handleMovementMissing();
        }

        if (rtcAlarm)
        {
            handleRTC();
        }

        gotoSLEEP();
        //wait a bit
        //otherwise we may put the device
        //to sleep while it is receiving commands!
        delayMs(500);
    }
}
Example #12
0
void cStream::runBenchmarkTunedNoOutput()
{
  initializeVariables();
  runTests();
  calculateBandwidthResults();
}; // void cStream::runBenchmarkTunedNoOutput()
//----------------------------------------------------------------------------------------------
void arduinoThread::setup(){
    // do not change this sequence
    initializeVariables();
    initializeArduino();
}
Example #14
0
	//function which centrally controls the execution of game
	void gameHandler(){
		settextstyle(0,0,6);
		outtextxy(180,200,"DX-Ball");
		getch();
		clearviewport();
		brickLen=25,brickBred=15;
		for(int i=0;i<20;i++)
			for(int j=0;j<8;j++)
				isBrick[i][j]=1;
		drawBricks();
		b.cx=20;
		b.cy=240;
		b.xIncre=1;
		b.yIncre=1;
		b.radius=5;
		br.size=80;
		br.movement=10;
		score=0;
		livesRemain[0]=' ';
		livesRemain[1]=' ';
		strcat(livesRemain,"live(s) remaining.");
		b.lives=3;
		line(500,0,500,480);
		settextstyle(0,0,2);
		outtextxy(535,200,"Score:");
		settextstyle(0,0,2);
		setScoreString();
		outtextxy(535,230,scoreString);
		outtextxy(535,320,"Lives:");
		setLivesString();
		outtextxy(565,350,livesString);
		b.ulimit=0;
		b.llimit=0;
		b.rlimit=500;
		br.llimit=0;
		br.rlimit=500;
		br.rePositionBar(0);
		br.drawBar();
		int ch='a';
		while(1){
			while(!kbhit()){
			delay(4);
			b.removePreviousBall();
			changeScore();
			initializeVariables();
			whetherBallTouchesBrick();
			b.drawBall();
			br.removePreviousBar();
			br.drawBar();
			line(500,0,500,480);
			}
			ch=getch();
			if(ch=='a'){
				br.removePreviousBar();
				br.rePositionBar('a');
				br.drawBar();
			}
			if(ch=='s'){
				br.removePreviousBar();
				br.rePositionBar('s');
				br.drawBar();
			}
			if(ch=='p')
				ch=getch();
			if(ch=='q'){
				displayAbout();
				getch();
				exit(0);
			}
		}
	}
/**
 * Constructor
 *
 */
Configuration::Configuration()
{
	initializeVariables();
}