示例#1
0
int16_t main(void)
{
	initRobotBase();
	powerON(); 
	setLEDs(0b111111); 
	mSleep(1000); 
	setLEDs(0b000000);
	mSleep(500);
	uint8_t runningLight = 1;
	for (uint8_t i = 0; i < 6; i++){
		for (uint8_t j = 0; j< 3;j++)
			destination[j] = destinationarray[i][j];
		//mainloopOpen();
		mainloopClosed();
		fancyled(&runningLight);
		/*for (uint8_t j = 0; j< 3;j++)
			source[j] = destination[j];*/
		mSleep(2000);
		
	}
	task_RP6System();
	while(true)
	{
		fancyled(&runningLight);
		if (motioncomplete == 0)
			moveAtSpeed(0,0);
		mSleep(200);
		task_RP6System();
	}
	return 0; 
}
示例#2
0
int main(void) {
    
    initRobotBase();

    setLEDs(0b111111);
    mSleep(1500);
    setLEDs(0b000000);

    // Set Bumpers state changed event handler:
    BUMPERS_setStateChangedHandler(bumpersStateChanged);

    powerON(); // Turn Encoders, Motor Current Sensors 
    // ATTENTION: Automatic Motor control will not work without this!

    /* RP6 SAGAN GENERATED COMMANDS START */
    
    /*{SAGAN1_COMMANDS_HERE}*/
    
    /* RP6 SAGAN GENERATED COMMANDS STOP */

    stop();
    moveAtSpeed(0, 0);
    BUMPERS_setStateChangedHandler(BUMPERS_stateChanged_empty);
    setLEDs(0b000000);

    while (true) {
        statusLEDs.LED2 = !statusLEDs.LED2; // Toggle LED bit in LED shadow register... 
        statusLEDs.LED5 = !statusLEDs.LED5;
        updateStatusLEDs();
        mSleep(500);
        task_RP6System();
    }
    return 0;
}
示例#3
0
int main(void)
{
	initRP6M256(); 
	initLCD(); 
			   
	writeString_P_WIFI("\n\nRP6 CONTROL M256 I2C Master Example Program!\n"); 

	// IMPORTANT:
	I2CTWI_initMaster(100); // Initialize the TWI Module for Master operation
							// with 100kHz SCL Frequency
							
	// Register the event handlers:
	I2CTWI_setTransmissionErrorHandler(I2C_transmissionError);

	setLEDs(0b1111); // Turn all LEDs on!

	showScreenLCD("################", "################");
	mSleep(500);
	showScreenLCD("I2C-Master", "Example Program 1");
	mSleep(1000);
	// ---------------------------------------
	setLEDs(0b0000); // All LEDs off!
	
	uint8_t counter = 1;
	
	
	// The command and register used here - in the next example we define them all. 
	#define CMD_SET_ACS_POWER	9 
	#define ACS_PWR_MED  2
	
	// Set ACS to medium power (you can see the ACS value changes in the raw registers):
	I2CTWI_transmit3Bytes(I2C_RP6_BASE_ADR, 0, CMD_SET_ACS_POWER, ACS_PWR_MED);


	while(true) 
	{
		// Increment a counter and send value to LEDs of the
		// Slave Controller:
		setLEDs(0b0001);
		showScreenLCD("INCREMENT", "COUNTER");
		setCursorPosLCD(1, 11);
		writeIntegerLengthLCD(counter, DEC, 3);
		I2CTWI_transmit3Bytes(I2C_RP6_BASE_ADR, 0, 3, counter);

		counter++;
	
		// Read and display ALL registers of the slave controller:
		setLEDs(0b0010);

		readAllRegisters();
	
		// Read the light sensors:
		setLEDs(0b0100); 
		readLightSensors();
		
		mSleep(250);
	}
	return 0;
}
示例#4
0
文件: ir.c 项目: kokx/fhict-proftaak4
// functions
void ir_sendBaseStation(void)
{
    if(lees<schrijf){
        I2CTWI_transmitByte(I2C_RP6_BASE_ADR, 27); 

        transmit_buffer[0]= SPI_EEPROM_readByte(lees);
        transmit_buffer[1]= SPI_EEPROM_readByte(lees+1);
        transmit_buffer[2]= SPI_EEPROM_readByte(lees+2);
        transmit_buffer[3]= SPI_EEPROM_readByte(lees+3);
        mSleep(10);

        I2CTWI_transmit2Bytes(I2C_RP6_BASE_ADR, 1, 9);
        I2CTWI_transmit2Bytes(I2C_RP6_BASE_ADR, 2, transmit_buffer[0]);
        I2CTWI_transmit2Bytes(I2C_RP6_BASE_ADR, 0, 10);
        mSleep(2000);
        I2CTWI_transmit2Bytes(I2C_RP6_BASE_ADR, 2, transmit_buffer[1]);
        I2CTWI_transmit2Bytes(I2C_RP6_BASE_ADR, 0, 10);
        mSleep(2000);
        I2CTWI_transmit2Bytes(I2C_RP6_BASE_ADR, 2, transmit_buffer[2]);
        I2CTWI_transmit2Bytes(I2C_RP6_BASE_ADR, 0, 10);
        mSleep(2000);
        I2CTWI_transmit2Bytes(I2C_RP6_BASE_ADR, 2, transmit_buffer[3]);
        I2CTWI_transmit2Bytes(I2C_RP6_BASE_ADR, 0, 10);
        mSleep(2000);

        lees = (lees + 8);

    }else if(lees == schrijf){
        I2CTWI_transmitByte(I2C_RP6_BASE_ADR, 27); 

        transmit_buffer[0]= SPI_EEPROM_readByte(lees);
        transmit_buffer[1]= SPI_EEPROM_readByte(lees+1);
        transmit_buffer[2]= SPI_EEPROM_readByte(lees+2);
        transmit_buffer[3]= SPI_EEPROM_readByte(lees+3);
        mSleep(10);

        I2CTWI_transmit2Bytes(I2C_RP6_BASE_ADR, 1, 9);
        I2CTWI_transmit2Bytes(I2C_RP6_BASE_ADR, 2, transmit_buffer[0]);
        I2CTWI_transmit2Bytes(I2C_RP6_BASE_ADR, 0, 10);
        mSleep(2000);
        I2CTWI_transmit2Bytes(I2C_RP6_BASE_ADR, 2, transmit_buffer[1]);
        I2CTWI_transmit2Bytes(I2C_RP6_BASE_ADR, 0, 10);
        mSleep(2000);
        I2CTWI_transmit2Bytes(I2C_RP6_BASE_ADR, 2, transmit_buffer[2]);
        I2CTWI_transmit2Bytes(I2C_RP6_BASE_ADR, 0, 10);
        mSleep(2000);
        I2CTWI_transmit2Bytes(I2C_RP6_BASE_ADR, 2, transmit_buffer[3]);
        I2CTWI_transmit2Bytes(I2C_RP6_BASE_ADR, 0, 10);
        mSleep(2000);
        I2CTWI_transmit2Bytes(I2C_RP6_BASE_ADR, 2, 50);
        I2CTWI_transmit2Bytes(I2C_RP6_BASE_ADR, 0, 10);

        lees = (lees + 8);
    }
}
示例#5
0
int main(void)
{
	initRP6M256();  
	initLCD();
    
	writeString_P_WIFI("\n\nRP6 CONTROL M32 I2C Master Example Program!\n"); 
    writeString_P_WIFI("\nMoving...\n"); 

	// ---------------------------------------
	WDT_setRequestHandler(watchDogRequest); 
	
	// ---------------------------------------
	// Init TWI Interface:
	I2CTWI_initMaster(100);  
	I2CTWI_setRequestedDataReadyHandler(I2C_requestedDataReady);
	I2CTWI_setTransmissionErrorHandler(I2C_transmissionError);


	setLEDs(0b1111);

	showScreenLCD("################", "################");
	mSleep(1000);
	showScreenLCD("I2C-Master", "Movement...");
	mSleep(1000);
	setLEDs(0b0000);
	
	// ---------------------------------------
	I2CTWI_transmit3Bytes(I2C_RP6_BASE_ADR, 0, CMD_SET_ACS_POWER, ACS_PWR_MED);
	I2CTWI_transmit3Bytes(I2C_RP6_BASE_ADR, 0, CMD_SET_WDT, true);
	I2CTWI_transmit3Bytes(I2C_RP6_BASE_ADR, 0, CMD_SET_WDT_RQ, true);

	while(true) 
	{ 
		setLEDs(0b1001); 
		showScreenLCD("MOVE", "FWD");
		writeString_P_WIFI("\nMoving Forwards...\n"); 
		move(70, FWD, DIST_MM(300), BLOCKING);
		setLEDs(0b1000); 
		showScreenLCD("ROTATE", "LEFT");
		writeString_P_WIFI("\nRotating Left...\n"); 
		rotate(60, LEFT, 180, BLOCKING);
		setLEDs(0b1001); 
		showScreenLCD("MOVE", "FWD");
		writeString_P_WIFI("\nMoving Forwards...\n"); 
		move(70, FWD, DIST_MM(300), BLOCKING);
		setLEDs(0b0001); 
		showScreenLCD("ROTATE", "RIGHT");
		writeString_P_WIFI("\nRotating Right...\n"); 
		rotate(60, RIGHT, 180, BLOCKING);
	}
	return 0;
}
int main(void)
{
	initRobotBase();

	setLEDs(0b111111);
	mSleep(500);
	setLEDs(0b000000);

	writeString_P("\nJust a simple counter program\n\n");
	
	uint16_t counter = 0;

	while(true)
	{
		timer = 0; 
		if(counter < 100) 
		{
			writeString_P("Counter: ");
			writeInteger(counter, BIN);
			writeString_P("(BIN) | ");
			writeInteger(counter, OCT);
			writeString_P("(OCT) | ");
			writeInteger(counter, DEC);
			writeString_P("(DEC) | ");
			writeInteger(counter, HEX);
			writeString_P("(HEX) ");
		}
		else
		{
			writeString_P("Counter L: ");
			writeIntegerLength(counter, BIN, 16);  
			writeString_P("(BIN) | ");
			writeIntegerLength(counter, OCT, 6);
			writeString_P("(OCT) | ");
			writeIntegerLength(counter, DEC, 6);
			writeString_P("(DEC) | ");
			writeIntegerLength(counter, HEX, 4);
			writeString_P("(HEX) ");
		}
		
		writeChar(' ');
		writeInteger(timer,DEC); 
		writeString(" *100us");
		writeChar('\n');
		
		counter++;  
		mSleep(100);
	}
	return 0;
}
示例#7
0
void testLPABallon( void )
{
	initLCD(); 		 // Initialize the LC-Display (LCD)
	showScreenLCD("################", "################");
	mSleep(500);
	showScreenLCD("Tst LPA BallonLIB", "versie 29jun15");
	mSleep(500);
	// ---------------------------------------
	setLEDs(0b0000); // All LEDs off!

	// This text is fixed on the LCD. Only the
	// key and ADC values are changed later on!
	showScreenLCD("hoogte: ", "VS:       BS:");
	while(true) 
	{
      // read some simulations parameter values and display them on teh LCD
      showSimParams();
      // Check if a key is pressed:
      uint8_t key = getPressedKeyNumber(); 
      // This function returns a 0 if no key is pressed and the key number from 1 to 5 otherwise.
      if(key) // If a key is pressed... (key != 0)
      {
         // ... and depending on which key was pressed, we 
         // call some library functions related to the burner and the valve.

         switch(key)
         {
            case 1: 
               Balloon_set_burner(ON);
               break;
            case 2:
               Balloon_set_burner(OFF);
               break;
            case 3: 
               Balloon_set_valve(OPEN);
               break;
            case 4: 
               Balloon_set_valve(CLOSED);
               break;
            case 5: 
               break;
         }
         // ... wait until the key is released again...
         while(getPressedKeyNumber())
         {
            showSimParams(); // use busy waiting for polling keys
         }
      }
	}
}
示例#8
0
void mainloopOpen()
{	
	motioncomplete=1;
	while(motioncomplete == 1) {	
		double delta_x=0.0, delta_y=0.0,pho=0.0;
		//Odometry();	   //should comment for open loop controller
		delta_x = destination[0] - source[0];
		delta_y = destination[1] - source[1];
		pho = sqrt(pow(delta_x,2)+pow(delta_y,2));
		double alpha = atan2(delta_y,delta_x);
		
	
		if (abs(alpha*100) > 0){
			alpha = (alpha*180)/M_PI; 
			//alpha = (alpha < 0 ? -(alpha +180):alpha);
		
		}
		/*writeIntegerLength((int16_t)delta_y, DEC,16);
		writeString("\n");
		writeIntegerLength((int16_t)delta_x, DEC,16);
		writeString("\n");
		writeIntegerLength((int16_t)alpha, DEC,16);
		writeString("\n");*/
		task_RP6System();
		/*REPLACE THIS CONTROLLER*/
		OpenLoopController((int16_t)alpha,pho,0); 
		//SiegwartController(alpha,pho,0); 
		task_RP6System();
		//motioncomplete=0;  //debug ... do not forget to remove :-)
		mSleep(200);
	}                 
	
	

}
示例#9
0
void mainloopClosed()
{
	motioncomplete = 1;
	while(motioncomplete == 1){
	
		double delta_x=0.0, delta_y=0.0,pho=0.0;
		Odometry();
		delta_x = destination[0] - source[0];
		delta_y = destination[1] - source[1];
		pho = sqrt(pow(delta_x,2)+pow(delta_y,2));
		double alpha = atan2(delta_y,delta_x);
		/*if (abs(alpha*100) > 0){
			alpha = (alpha*180)/M_PI; 
			
		}*/
		task_RP6System();
		SiegwartController(alpha,pho,0);
		task_RP6System(); 
		task_motionControl();
		mSleep(200);
		

	
	}


}
示例#10
0
int main()
{
	HGPSOEMGR hGPSoEMgr = INVALID_HGPSOEMGR_VALUE;
	double utc = 0;
	double latitude = 0;
	double longitude = 0;
	int i = 0;

	INIT_DEBUG;

	InitGPSoEMgr(&hGPSoEMgr, (char*)SZDEV, 100, DATA_POLLING_MODE_GPSOE, THREAD_PRIORITY_NORMAL, TRUE);

	for (i = 0; i < 1000; i++)
	{
		if (GetDataGPSoEMgr(hGPSoEMgr, &utc, &latitude, &longitude) == EXIT_SUCCESS)
		{
			printf("UTC : %f, Latitude : %f, Longitude : %f\n", utc, latitude, longitude);
		}
		mSleep(200);
	}
	
	ReleaseGPSoEMgr(&hGPSoEMgr);

	printf("Press ENTER to continue . . .");(void)getchar();

	return EXIT_SUCCESS;
}
示例#11
0
文件: main.c 项目: b3nzchr3ur/rp6
int main(void)
{
	initRobotBase(); // Always call this first! 
	                  // The Processor will not work correctly otherwise.
					 
	// Write a text message to the UART:
	writeString_P("\nCounting and Receiving\n");
	
	// Define a counting variable:
	uint16_t counter = 0;
	
	// clear the UART buffer once at the start of the program
	clearReceptionBuffer();
	
	while(true)
	{
		// example of sending some data over UART
		counter++;    
		SendDataOverUART(counter);

		//example of receiving some data over UART
		ShowDataReceivedOverUART();
		
		mSleep(100); // delay 100ms = 0.1s
	}
	return 0;
}
示例#12
0
int main(void)
{

	int i = 0;
	int timer;
	
	//Init Robotarm 
	initRobotBase();
	//Init Display
	vInitDisplay();
	
	//Set Robotarm powerLED on green
	PowerLEDorange();
	
	while(1){
		
		//Write value 'i' to display
		ucShowPositiveDecimalValueInDisplay(i);
		
		//Wait 10 times 10 ms = 1 sec
		for(timer=0; timer<10; timer++){
			mSleep(100);
		}
		
		//increment value 'i' with 1
		i++;
	
	}
	
	
}
示例#13
0
int main(void)
{
	initRobotBase(); 	// Always call this first! The Processor will not work
						// correctly otherwise.		 
	mSleep(1000);        // delay 1s

	speed = 0; //Speed for servo from '0'(fast) - '10'(slow)

	writeString_P("\n Key Board Control \n\n");

	Start_position(); //Use this function to set the servomotor in the centre. 
					  //This function must be called before using Power_Servos();
	
	Power_Servos();  //Use this function to power the servo motors on
					 //When you want to power off the servos, you need to call function Power_Off_Servos();
	
	
	// ---------------------------------------
	// Main loop:
	while(true)
	{
		
		Event(scan_keyboard());
		
	// End of main loop!
	// ---------------------------------------
	}
	return 0;
}
DWORD WINAPI ConnectThrProc(LPVOID lpParam)	{
#else
void* ConnectThrProc(void* lpParam)	{
#endif

	int EndThread = 0;
	CLITCP* pCLITCP = (CLITCP*)lpParam;
	int connected = 0;

	do
	{
		memcpy_ts(&connected, &pCLITCP->connected, sizeof(int), &pCLITCP->CSconnected); // Thread-safe copy
		if (connected != 1)	{ // The client is not connected to the server, trying to connect or reconnect
			StopTCP(&pCLITCP->ConnectSocket, &pCLITCP->addrinf);
			if (
				(InitTCP(&pCLITCP->ConnectSocket, pCLITCP->address, pCLITCP->port, &pCLITCP->addrinf) == EXIT_SUCCESS)&&
//				(SetSockOptTCP(pCLITCP->ConnectSocket, 1, 10000) == EXIT_SUCCESS)&& // Setting timeouts on the client socket
				(ConnectTCP(&pCLITCP->ConnectSocket, &pCLITCP->addrinf) == EXIT_SUCCESS)//&&
//				(SetSockOptTCP(pCLITCP->ConnectSocket, 1, 10000) == EXIT_SUCCESS) // Setting timeouts on the client socket
				)	{
					fprintf(stdout, "Connection successful\n");
					connected = 1;
					memcpy_ts(&pCLITCP->connected, &connected, sizeof(int), &pCLITCP->CSconnected); // Thread-safe copy
			}
			else fprintf(stdout, "Unable to connect\n");
		}
		mSleep(1000);
		memcpy_ts(&EndThread, &pCLITCP->EndThread, sizeof(int), &pCLITCP->CSEndThread); // Thread-safe copy
	} while(!EndThread);

	return 0; 
} 
示例#15
0
文件: ir.c 项目: kokx/fhict-proftaak4
void ir_sendSituation(direction dir, uint8_t x, uint8_t y)
{
    // hal_hasWallLeft() hal_hasWallRight() hal_hasWallFront()
    receive_buffer[0] = x;
    receive_buffer[1] = y+16;

    // direction
    if (dir == NORTH){
        receive_buffer[2] = 32;
    } else if (dir == EAST) {
        receive_buffer[2] = 33;
    } else if (dir == SOUTH) {
        receive_buffer[2] = 34;
    } else if (dir == WEST) {
        receive_buffer[2] = 35;
    }

    // pro-tip: het maakt geen zak uit hoe veel lijnen een programma is

    // wall
    receive_buffer[3] = 40 + (hal_hasWallLeft() << 2) + (hal_hasWallFront() << 1) + hal_hasWallRight();
#if 0
    L F R
        0 0 0   0
        0 0 1   1
        0 1 0   2
        0 1 1   3
        1 0 0   4
        1 0 1   5
        1 1 0   6
        1 1 1   7
#endif

    SPI_EEPROM_writeByte(schrijf,receive_buffer[0]);
    mSleep(10);
    SPI_EEPROM_writeByte(schrijf+1,receive_buffer[1]);
    mSleep(10);
    SPI_EEPROM_writeByte(schrijf+2,receive_buffer[2]);
    mSleep(10);
    SPI_EEPROM_writeByte(schrijf+3,receive_buffer[3]);
    mSleep(10);
    schrijf = (schrijf + 8);
}
示例#16
0
void Leds_Beeper (void)

{

	changeBeepsound(150);
	setBeepsound();
	PowerLEDred();	
	mSleep(500); 
	
	changeBeepsound(200);
	PowerLEDgreen();	
	mSleep(500); 
	
	changeBeepsound(255);
	PowerLEDorange();
	mSleep(500); 
	
	PowerLEDoff();
	clearBeepsound();
}
示例#17
0
/**
 * Here we react on any obstacle that we may hit. 
 * If any of the bumpers detects an obstacle, we stop the motors and start
 * LED blink.
 */
void bumpersStateChanged(void) {
    
    if (bumper_left || bumper_right) {
        
        stop();
        moveAtSpeed(0, 0); // stop moving!
        
        setLEDs(0b111111);
        updateStatusLEDs();
        mSleep(500);
        
        while (true) {
            statusLEDs.LED2 = !statusLEDs.LED2; // Toggle LED bit in LED shadow register... 
            statusLEDs.LED5 = !statusLEDs.LED5;
            updateStatusLEDs();
            mSleep(500);
            task_RP6System();
        }
    }
}
示例#18
0
void outputTextStuff(void)
{
uint8_t x,y;
	for(x = 0; x < 53; x++)
	{
		writeStringLength("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",10,x);
		writeChar(' ');
		for(y = 0; y < x; y++)
			writeChar('#');
		mSleep(200); 
		writeChar('\n');
	}
}
示例#19
0
/*
 * Initialize the pathfinder
 */
void pathfinder_init(uint8_t x, uint8_t y, direction currentDirection)
{
    lastDirection = currentDirection;

    clearLCD();

    setCursorPosLCD(0, 2);
    writeIntegerLCD(x, DEC);
    setCursorPosLCD(0, 5);
    writeIntegerLCD(y, DEC);

    mSleep(5000);

    // initialize root node
    root = malloc(sizeof(root));

    root->count = nodeCount;
    root->x = x;
    root->y = y;

    root->north = NULL;
    root->west  = NULL;
    root->south = NULL;
    root->east  = NULL;

    // make the current node the root node
    current = root;

    // also, initialize the empty node
    empty = malloc(sizeof(empty));

    empty->count = 255;
    empty->x = 255;
    empty->y = 255;

    empty->north = NULL;
    empty->west  = NULL;
    empty->south = NULL;
    empty->east  = NULL;

    // initialize the current node
    if (!hal_hasWallLeft()) {
        current->west = empty;
    }
    if (!hal_hasWallFront()) {
        current->north = empty;
    }
    if (!hal_hasWallRight()) {
        current->east = empty;
    }
}
示例#20
0
byte Message_Receive(void)
{
	if (getBufferLength() < MS_DataBegin)
	{
		return 0;
	}

	if (readChar() != MS_CharA)
	{
		return 0;
	}

	if (readChar() != MS_CharB)
	{
		return 0;
	}

	Message_BeginWrite();

	VarAction = readChar();
	VarDataLength = readChar();

	if (VarDataLength > MS_MaxDataLen)
	{
		VarDataLength = MS_MaxDataLen;
	}

	VarCorrChk = readChar();

	if (getBufferLength() < VarDataLength)
	{
		//sleep 25 ms (well or less..)
		//delay(25);
		mSleep(25);
		if (getBufferLength() < VarDataLength)
		{
			VarIsCorrupt = true;
			return MS_DataBegin;//discart message because we are not receiving anything further
		}
	}

	for (int i = 0; i < VarDataLength; ++i)
	{
		VarBuffer[MS_DataBegin + i] = readChar();
	}

	CurrCorrChk = CalculateCorruptionCheck();
	VarIsCorrupt = VarCorrChk != CurrCorrChk;
	return MS_DataBegin + VarDataLength;
}
示例#21
0
int main(void)
{
	initRP6M256(); 
	initLCD();

	// ---------------------------------------
	WDT_setRequestHandler(watchDogRequest); 

	// ---------------------------------------
	I2CTWI_initMaster(100);  
	I2CTWI_setRequestedDataReadyHandler(I2C_requestedDataReady);
	I2CTWI_setTransmissionErrorHandler(I2C_transmissionError);


	setLEDs(0b1111);
	mSleep(1000);
	setLEDs(0b0000);
	
	// ---------------------------------------
	// Setup ACS power:
	I2CTWI_transmit3Bytes(I2C_RP6_BASE_ADR, 0, CMD_SET_ACS_POWER, ACS_PWR_OFF);
	// Enable Watchdog for Interrupt requests:
	I2CTWI_transmit3Bytes(I2C_RP6_BASE_ADR, 0, CMD_SET_WDT, true);
	// Enable timed watchdog requests:
	I2CTWI_transmit3Bytes(I2C_RP6_BASE_ADR, 0, CMD_SET_WDT_RQ, true);

	startStopwatch1();
	startStopwatch2();
	startStopwatch3();
	
	while(true) 
	{ 
		/*
		mSleep(600);
		warnForObs();
		mSleep(600);
		task_checkINT();
		mSleep(600);
		light_detection();
		mSleep(600);
	    task_I2CTWI();
		mSleep(600);*/
		writeIntegerLength_WIFI(adcBat,DEC,4);
		behaviourController();
	}
	return 0;
}
示例#22
0
int main(void)
{
	initRobotBase(); 
	setLEDs(0b111111);
	mSleep(2500);
	setLEDs(0b100100); 

	BUMPERS_setStateChangedHandler(bumpersStateChanged);
	
	powerON(); 
	
	while(true) 
	{		
		behaviourController();
		task_RP6System();
	}
	return 0;
}
示例#23
0
bool DkUtils::exists(const QFileInfo& file, int waitMs) {

	QFuture<bool> future = QtConcurrent::run(&DkUtils::checkFile, file);

	for (int idx = 0; idx < waitMs; idx++) {
		if (future.isFinished())
			break;

		//qDebug() << "you are trying the new exists method... - you are modern!";

		mSleep(1);
	}

	//future.cancel();

	// assume file is not existing if it took longer than waitMs
	return (future.isFinished()) ? future : false;
}
int BlsChildChannel::init()
{
    // wait for master process running.
    mSleep(3);

    int ret = E_SUCCESS;

    m_socket = new MTcpSocket(this);
    if ((ret = m_socket->initSocket()) != E_SUCCESS) {
        return ret;
    }

    if ((ret = m_socket->connectToHost("127.0.0.1", 1940)) != E_SUCCESS) {
        return ret;
    }
    log_trace("connected to master success.");

    return MThread::start();
}
示例#25
0
文件: Trash.cpp 项目: mildrock/Media
/***********************************************************************************************************************
Function:  TrashProc
Description:   
Called By:    
Input:          
Output:          
Return:       
Others:        
************************************************************************************************************************/
tProcType_t CTrash::TrashProc(tProcPara_t Param)
{
	while (m_bInit) {
		while(m_ObjQ.empty()) { mSleep(3*1000); }
		for (list<CTrash*>::iterator it = m_ObjQ.begin(); it != m_ObjQ.end(); ) {
			if ((*it)->m_aLive == false && (*it)->m_NotALiveCnt++ > 10 ) {
				if((*it)->m_bDeletEd == true)
				{
					delete (*it); 
					(*it) = NULL;
				}
				it = m_ObjQ.erase(it);
			} else {
				++it; 
			}
		}
		sleep(3);
	}

	return MW_SUCC;
}
示例#26
0
bool CRTSPStream::SendH264File(const char *pFileName)
{
	if(pFileName == NULL)
	{
		return false;
	}
	FILE *fp = fopen(pFileName, "rb");  
	if(!fp)  
	{  
		printf("[RTSPStream] error:open file %s failed!",pFileName);
	}  
	fseek(fp, 0, SEEK_SET);

	unsigned char *buffer  = new unsigned char[FILEBUFSIZE];
	int pos = 0;
	while(1)
	{
		int readlen = fread(buffer+pos, FILEBUFSIZE-pos,1, fp);
	printf("readlen = %d\n", readlen);
		if(readlen<=0)
		{
			break;
		}

		readlen+=pos;

		int writelen = SendH264Data(buffer,readlen);
		if(writelen<=0)
		{
			break;
		}
		memcpy(buffer,buffer+writelen,readlen-writelen);
		pos = readlen-writelen;
	sleep(1);	
		mSleep(25);
	}
	fclose(fp);
	delete[] buffer;
	return true;
}
示例#27
0
void loop(void)
{
	static uint8_t ledstate = 1;
	uint16_t tmp = getMicrophonePeak();
	
	clearLCD();
	writeIntegerLengthLCD(tmp, DEC, 4);
	writeCharLCD(':');
	writeIntegerLengthLCD((uint16_t)ledstate, DEC, 4);
	
	if (tmp > 512)
	{
		ledstate <<= 1;
		if (ledstate == 16)
		{
			ledstate = 1;
		}
	}

	setLEDs(ledstate);
	mSleep(100);
}
DWORD WINAPI ConnectThrProc(LPVOID lpParam)	{
#else
void* ConnectThrProc(void* lpParam)	{
#endif

	int EndThread = 0;
	CLITCP* pCLITCP = (CLITCP*)lpParam;
	int connected = 0;


	do
	{
		// Checks whether the client is currently connected or not
		memcpy_ts(&connected, &pCLITCP->connected, sizeof(int), &pCLITCP->CSconnected); // Thread-safe copy
		if (connected != 1)	{ // The client is not connected to the server, trying to connect or reconnect
			ShutdownTCP(&pCLITCP->ConnectSocket, SD_BOTH);
			DestroySocketTCP(&pCLITCP->ConnectSocket, &pCLITCP->addrinf);
			if (
				(CreateSocketTCP(&pCLITCP->ConnectSocket, pCLITCP->address, pCLITCP->port, &pCLITCP->addrinf) == EXIT_SUCCESS)&&
				(SetSockOptTCP(pCLITCP->ConnectSocket, 1, 10000) == EXIT_SUCCESS)&& // Setting timeouts on the client socket
				(ConnectTCP(pCLITCP->ConnectSocket, &pCLITCP->addrinf) == EXIT_SUCCESS)
				)	
			{
					connected = 1;
					memcpy_ts(&pCLITCP->connected, &connected, sizeof(int), &pCLITCP->CSconnected); // Thread-safe copy
					fprintf(stdout, "Connection successful\n");
			}
			else	{
				fprintf(stdout, "Unable to connect\n");
			}
		}
		mSleep(1000);
		memcpy_ts(&EndThread, &pCLITCP->EndThread, sizeof(int), &pCLITCP->CSEndThread); // Thread-safe copy
	} while(!EndThread);

	return 0; 
} 
示例#29
0
文件: otg.cpp 项目: ropo/otg
int main(int argc, char* argv[])
{
	init_genrand(getMS());
	COUTHANDLE hOUT = ConsoleInit();
	g.pTaskMan = new TaskMan();
	g.keys = 0;

	g.pTaskMan->AddTask( new taskStage() );

	ConsoleClear(hOUT);
	unsigned int dwNextTime = 0;
	while( (g.keys & KEY_ESCAPE) == false ) {
		g.onUpdate();

		unsigned int dwTime;
		while( (dwTime=getMS()) < dwNextTime )
			mSleep(1);
		dwNextTime = dwTime + 16;
		g.pTaskMan->onUpdate(hOUT);
	}
	delete g.pTaskMan;

	return 0;
}
示例#30
0
void signal(void) {
    
    int c;
    for (c = 0; c < 3; c++) {
        setLEDs(0b100000);
        mSleep(200);
        setLEDs(0b010000);
        mSleep(200);
        setLEDs(0b001000);
        mSleep(200);
        setLEDs(0b000100);
        mSleep(200);
        setLEDs(0b000010);
        mSleep(200);
        setLEDs(0b000001);
        mSleep(200);
    }
    
    setLEDs(0b000000);
}