예제 #1
0
파일: main.cpp 프로젝트: teamon/sumocpp
int main() {
  init();
  leds_on();
  
  wait_s(5); // regulaminowy czas

  for(;;){
    if(DEBUG) debug();
        
    if(switch1_pressed()){
      leds_negate();
    }
    
    if(queue.head){
      move = queue.pop(ITIME);
      motor1.set_power(move.m1);
      motor2.set_power(move.m2);
    } else {
      leds_off();
      // szukanie
      motor1.set_power(0);
      motor2.set_power(0);
    }
    wait_ms(ITIME);
  }
}
예제 #2
0
파일: main.c 프로젝트: k-nowicki/NowBoot
//Disks initialization
int StorageInit(void){
	FRESULT res;         	 // FatFs function common result code
	u08 fr_res_buf[50];	 	 //buffer for error text message
	u08* frame = fr_res_buf; //buffer for received frame (same as above)
	u08 logname[30];

	wait_ms(1);
	spiInit();
	wait_s(1);
	//SD initializing
	res = StorageSdInit();
	if(res !=FR_OK){
		debug_msg("Storage: SD Card Error!");
		//here can try again and if three probes fail,
		//then below
		fsDispFRESULT(res, fr_res_buf);
		//while(1) wait_s(120);	//never ending loop
	}else{
		debug_msg("Storage: SD Card Initialized");
	}
}
예제 #3
0
파일: proj2.c 프로젝트: wadimw/sem_15Z
int main()
{
	position ball = {0, 0};
	movement move = {DOWN, RIGHT};
	obstacle block = {0, 0, {	"#####", 
								"#####",
								"#####",
								"#####",
								"#####"}}; 

	obstacle block1 = {0, 0, {	"#####", 
								"#####",
								"#####",
								"#####",
								"#####"}}; 
	int MAXY, MAXX, i;

	initscr();
	noecho();
	start_color();
	curs_set(FALSE);

	init_pair(1, COLOR_BLACK, COLOR_WHITE);
	init_pair(2, COLOR_RED, COLOR_WHITE);
	init_pair(3, COLOR_YELLOW, COLOR_WHITE);

	bkgd(COLOR_PAIR(1));

	getmaxyx(stdscr, MAXY, MAXX);
	//check size
	if(MAXY<=5 || MAXX<=5)
		{
			endwin();
			exit(1);
		};

	//obstacle position
	do
	{
		srand(time(NULL));
		block.x = rand()%(MAXX-5);
		block.y = rand()%(MAXY-5);
	}
	while(block.x==0 && block.y==0);

	//obstacle1 position
	do
	{
		srand(time(NULL)-200);
		block1.x = rand()%(MAXX-5);
		block1.y = rand()%(MAXY-5);
	}
	while(block1.x==0 && block1.y==0);

	while(1)
	{
		clear();
		for(i=0; i<6; i++)
		{
			attron(COLOR_PAIR(3));
			mvprintw(block.y+i, block.x, "%s", block.body[i]);
			mvprintw(block1.y+i, block1.x, "%s", block1.body[i]);
		}
		attron(COLOR_PAIR(2));
		mvprintw(ball.y, ball.x, "o");
		refresh();

		wait_s(0.05);
		
		//move
		ball.x += move.x;
		ball.y += move.y;

		//bounce
		{
			//walls
			if(ball.x>=MAXX-1 || ball.x<=0)
				move.x *= -1;
			if(ball.y>=MAXY-1 || ball.y<=0)
				move.y *= -1;
			//obstacle
			if( ( (ball.x==block.x-1)||(ball.x==block.x+6) ) && ( (ball.y<=block.y+6)&&(ball.y>=block.y-1) ) )
				move.x *= -1;
			if( ( (ball.y==block.y-1)||(ball.y==block.y+6) ) && ( (ball.x<=block.x+6)&&(ball.x>=block.x-1) ) )
				move.y *= -1;
			//obstacle1
			if( ( (ball.x==block1.x-1)||(ball.x==block1.x+6) ) && ( (ball.y<=block1.y+6)&&(ball.y>=block1.y-1) ) )
				move.x *= -1;
			if( ( (ball.y==block1.y-1)||(ball.y==block1.y+6) ) && ( (ball.x<=block1.x+6)&&(ball.x>=block1.x-1) ) )
				move.y *= -1;
		}
		
	}
    
  endwin();
  return 0;
}