// Analog to Digital Conversion

static u8 	ADC_flag=0;							// Gia poio port egine to teleytaio conversion
static u8	temp_u8=0;

static u8	tzampa=0;
// acc+-2g front
static u8   ADC0_low=80;
static u8   ADC0_high=80;
static u8   ADC1_low=80;
static u8   ADC1_high=80;
static u8   ADC2_low=80;
static u8   ADC2_high=80;
static u8   ADC3_low=80;
static u8   ADC3_high=80;
static u8   ADC4_low=80;
static u8   ADC4_high=80;
static u8   ADC5_low=80;
static u8   ADC5_high=80;


/*
void adc_routine(void){
	switch (ADC_flag){
		case 0:
				ADC_flag=1;
				if((TX_read<2)||(TX_read>3)){//if(TX_read!=7){
					
					ADC0_low=ADCL;
					ADC0_high=ADCH;
					if((ADC0_high==0)&&(ADC0_low==0)){
						ADC0_high='?';
						ADC0_low='0';
					}
						
				}
				else{
					temp_u8=ADCL;
					temp_u8=ADCH;
				}
				ADMUX&=ADC1_and;						// Sample ADC1
				ADMUX|=ADC1_or;			
			break;		
		case 1:			
				ADC_flag=2;
				if((TX_read<4)||(TX_read>5)){
					ADC1_low=ADCL;
					ADC1_high=ADCH;
					if((ADC1_high==0)&&(ADC1_low==0)){
						ADC1_high='?';
						ADC1_low='1';
					}
				}
				else{
					temp_u8=ADCL;
					temp_u8=ADCH;
				}
				ADMUX&=ADC2_and;
				ADMUX|=ADC2_or;							// Sample ADC2
			break;
		case 2:
				ADC_flag=3;								// Sample next ADC port
				if((TX_read<6)||(TX_read>7)){
					ADC2_low=ADCL;
					ADC2_high=ADCH;
					if((ADC2_high==0)&&(ADC2_low==0)){
						ADC2_high='?';
						ADC2_low='2';
					}
				}
				else{
					temp_u8=ADCL;
					temp_u8=ADCH;
				}
				ADMUX&=ADC3_and;
				ADMUX|=ADC3_or;							// Sample ADC3
			break;
		case 3:
				ADC_flag=4;								// Sample next ADC port
				if((TX_read<8)||(TX_read>9)){//if(TX_read!=13){
					ADC3_low=ADCL;
					ADC3_high=ADCH;
					if((ADC3_high==0)&&(ADC3_low==0)){
						ADC3_high='?';
						ADC3_low='3';
					}
				}
				else{
					temp_u8=ADCL;
					temp_u8=ADCH;
				}
				ADMUX&=ADC4_and;
				ADMUX|=ADC4_or;							// Sample ADC4
				
			break;
		case 4:		
				ADC_flag=5;
				if((TX_read<10)||(TX_read>11)){//if(TX_read!=19){
					ADC4_low=ADCL;
					ADC4_high=ADCH;
					if((ADC4_high==0)&&(ADC4_low==0)){
						ADC4_high='?';
						ADC4_low='4';
					}
				}
				else{
					temp_u8=ADCL;
					temp_u8=ADCH;
				}
				ADMUX&=ADC5_and;
				ADMUX|=ADC5_or;							// Sample ADC5
				break;
		case 5:		
				ADC_flag=0;								
				if((TX_read<12)||(TX_read>13)){					
					ADC5_low=ADCL;
					ADC5_high=ADCH;
					if((ADC5_high==0)&&(ADC5_low==0)){
						ADC5_high='?';
						ADC5_low='0';
					}

				}
				else{

					temp_u8=ADCL;
					temp_u8=ADCH;
				}
				ADMUX&=ADC0_and;
				ADMUX|=ADC0_or;							// Sample ADC0
				break;

		default:
			ADC_flag=0;
			
			ADMUX&=ADC0_and;
			ADMUX|=ADC0_or;
			break; 
	}
	ADCSRA|=(1<<ADSC);							// Start New Conversion
}
*/



















/*
// servos
static	int	servo_clock;					// Me prescaler 0, exoume overflow ka8e 16us(mesw flag), opote 20ms/16us=1250 kyklous
static 	u8	servo_0=94;						//  Exw kentro me 1.5ms, opote 1.5ms/16us=94 palmous
static 	u8	servo_1=94;
static 	u8	servo_2=94;
static 	u8	servo_3=94;
static 	u8	servo_4=94;
static 	u8	servo_5=94;
static 	u8	servo_6=94;
static 	u8	servo_7=94;
#define	servo_center 94
*/

