Example #1
0
File: speed.c Project: nesl/natcar
void processcamera()
{  //keypad= getchar1();
 
          


		int ysize=0;
		int y=0;
		int xmean=0;
		int xmin=0;
		int xmax=0;
		int xcnt=0;
		int xconf=0;
		int i = 0;
			
		//Find packet start
		while(getchar1()!=0xFE && i < 25) //Wait for packet start
		{
			//count how many times we loop, time out and reinit if need be
			i++;
		} 
		
  		if(i >= 25)
  		{
  		g_speed = 3;
  		initcamera();
  		return;
  		}
		ysize = getchar1();
		
		//For each line
		for(y=0; y<ysize; y++)
		{
			xmean = getchar1();
			xmin  = getchar1();
			xmax  = getchar1();
			xcnt  = getchar1();
			xconf = getchar1();

			if(xconf > THRESHOLD)
				xmeans[y] = xmean; //change from mean to center if needed
			else
				xmeans[y]=255;     
		     	for(i=0; i<XRES; i++)
			{
				char printchar = ' ';
				if(i>=xmin&&i<=xmax)
					printchar = 'X';
				if(i==xmean)
					printchar = '|';
				if(xconf < THRESHOLD)
					printchar = ' ';
				printf("%c",printchar);
			}
		printf("\r");   
		}
		calcstats(ysize);
}  
Example #2
0
int ca3Dbase::run(int argc, char **argv)
{
	ca3Dglobal::CurrentCA = this;

	initglut(argc, argv);
	initspace(size, wrap);
	initgraphics();
	initcamera();

	glutMainLoop(); //call the main loop
	return 0;
}
Example #3
0
File: speed.c Project: nesl/natcar
void main(void)
{    
        unsigned int UBR = XTAL/(16*BAUD) -1; 
        // USART0 initialization
	UBRR0H=(unsigned char)(UBR >>8);                
	UBRR0L=(unsigned char)(UBR &0xFF); 
    	UCSR0A=0x00;              
	UCSR0B=0xD8;
	UCSR0C=0x06;            // 0000 0110 character size reserved, asynchronous operation
	
	// USART1 initialization
	UBRR1H=(unsigned char)(UBR >>8);                    
  	UBRR1L=(unsigned char)(UBR & 0xFF);             
    	UCSR1A = 0x00;          //normal data rate for asynchronous operation
	UCSR1B=0xD8;            // 1101 1000 enable transmitter, reciever, interupts on transmit and recieve complete
	UCSR1C=0x06;            // 0000 0110 character size reserved, asynchronous operation     

	// SPEED PWM - HBRIDGE CONTROL
	//B 5,6 output compare
	//B 1 SPI clk
	DDRB = 0x60; // 0110 0000
	
	// TIMER INTERRUPT
	//-11- --00
	//outputcompare/timer overflow 
	TIMSK = 0x01; // 0000 0001 
	
	// TIMER 0
	//TCCR
	//interrupt to update pwm
	//---- -xxx
	//0: stopped, 1: no scaling, 2: 8, 3: 32, 4: 64, 5:128, 6: 256, 7: 1024
	//-000 0---
	//no output compare, overflow on max
	TCCR0 = 0x07; // 0000 0111    
	
 	// TIMER 1
	// SPEED PWM - HBRIDGE CONTROL
	//TCCRA: AABB CC--
	//Overflow at top
	//Clear OCR1 on compare match
	
	//TCCRA: ---- --xx TCCRB: ---xx---
	//Fast PWM
	//Top = ICR1
	//Update OCR1 at top

    	//TCCRB: ---- -xxx 
	//0:stopped 1:no prescaling 2: 8 3:64 4:256 5:1024 6,7: external clock
	TCCR1A = 0xF2; // 111100 10
	TCCR1B = 0x19; // 00011 001
	ICR1H = TOP >> 8;
	ICR1L = TOP & 0xFF;
	
    	// TIMER 3
	// ENCODER TICKS COUNTER
	//---- -xxx
	//6: clock on Tn pin rising 7: Clock on Tn pin falling
	TCCR3A = 0x00;
	TCCR3B = 0x07;
    
    //EIMSK = 0b11000000;
    //EICRA = 0b00001000;
    
	//TWI_init(TWI_ADDR);
	initcamera();
	//keypad_init();    
	
	get_calibrated_settings(speed_range, speed_slope, speed_height, speed_max_mem);

	#asm("sei");
	while(1) 
	{
        getstuff();
        getSpeedIndex();
        updatespeed();
        
		if(testvar ==30)
  		{       
  			//printf("\rstate: %d maxspeed: %d ticks: %d topspeed: %d\r", state,maxspeed, ticks, topspeed);    
  			printf("keypad: %d",keypad);
                       	printf("index_in: %d Data_in: %d\r", index_in,Data_in);
                       	testvar =0;
     		}          
	};
}
Example #4
0
File: main.c Project: damora/ivr
//-----------------------------------------------------------------------------------------------------------------------//
// initialization
//-----------------------------------------------------------------------------------------------------------------------//
int init (CMDARGS args, int rank)
{
    int rc=0;
//	int coords[3] = {0, 0, 0};
//	int procdims[3] = {1, 1, 1};

    // initialize view
    angle = args.angle;
    axis[0] = args.axis.x;
    axis[1] = args.axis.y;
    axis[2] = args.axis.z;

    // inititalize window
    viewport.tilewid = args.tilewid;
    viewport.tilehgt = args.tilehgt;
    fprintf(stderr, "rank:%d, viewport.tilewid=%d, viewport.tilehgt=%d\n", rank,viewport.tilewid, viewport.tilehgt);

    viewport.tilex = WINDOWWIDTH/viewport.tilewid;
    viewport.tiley = WINDOWHEIGHT/viewport.tilehgt;
    fprintf(stderr, "rank:%d ,viewport.tilex=%d, viewport.tiley=%d\n", rank,viewport.tilex, viewport.tiley);
    viewport.w = viewport.tilex  * viewport.tilewid;
    viewport.h = viewport.tiley * viewport.tilehgt;
    fprintf(stderr, "rank:%d,  viewport.w=%f, viewport.h=%f\n", rank,viewport.w, viewport.h);

    // init camera
    initcamera();

    // set window, i.e. portion of window we will render to. Need to fix this whole view mapping mess
    setviewport(&viewport, 0, 0, viewport.w, viewport.h);

    //  initialize attributes of volume both global and local
    initvolattrs(args, rank);

    // each rank reads the part of the volume it is responsible for processing
    if ((rc=readvoldata(args.filename)) < 0) {
        fprintf(stderr, "reading volume data input file failed %d\n",rc);
        freeall();
        exit(0);
    };


#ifdef LOCAL
    for (int i=0; i<8; i++) {
        vertices[i][0] *= scalefactor.x;
        vertices[i][1] *= scalefactor.y;
        vertices[i][2] *= scalefactor.z;
    }
#endif

    // initialize colormap function
    initcolormap(args.colormap);

    // initialize volume color tables
    if (args.colormap != -1) initvolluts();

    // init init color buffers
    initcolbufs(rank);

    // initialize xfer function
    inittransferfunc(args.xfer);


    // initialize xfer function // set to LINEAR  or NEAREST, but this should be a client menu option
    initsamplefunc(LINEAR);

    // initialize timers
    RESET_TIME();

    return 0;
}