Exemplo n.º 1
0
int populate(void*nothing)
{	static char    *in,
                       *chan;
	static short m,n;
	in=(char*)nothing;
	qclear(&g_toget);
        qassign(&g_toget,"# of channels",QINT,NULL,0);
        if(!query(in,&g_toget))
                return(FALSE);
	for(n=(int)qnget(g_toget,0);n;n--)
	{	chan=malloc(10);	
		chan[0]='#';
		for(m=1;m<10;m++)	
			chan[m]=rand()%26+'A';
		if(!join(chan))
			return(FALSE);
		getstuff(SAVE);
	}
	return(TRUE);
}
Exemplo n.º 2
0
int chat(void*channel)
{	char	*in=(char*)channel,
		*mes=CHR(SMALL),
		*tosend=CHR(SMALL);
	struct qval*toget=malloc(sizeof(struct qval));
	qassign(&toget,"Channel",QSTR,NULL,0);
	if(!query(in,&toget))
			return(FALSE);
	strcpy(in,(char*)qnget(toget,0));
	message("Entering chat mode, press escape, then enter to exit\n",-1,1,LEVEL);
	while(1)
	{	getstuff(PRINT);	
		if(poll(g_ufds,2,100)&&g_ufds[1].revents==POLLIN)
		{	mes=fgets(mes,SMALL,stdin);
			if(*mes==27)
				return(TRUE);
			sprintf(tosend,"PRIVMSG %s :%s",in,mes);
			ircsend(tosend);
		}
	}
	return(FALSE);
}
Exemplo n.º 3
0
Arquivo: speed.c Projeto: 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;
     		}          
	};
}