cockroach: Remove code for second led

This commit is contained in:
Thammi 2012-10-12 01:22:37 +02:00
parent 8ca3783741
commit 9ac3083a8b

View File

@ -13,7 +13,6 @@ static void led_sound(void)
static bool discharge; static bool discharge;
static timer_t mytimer; static timer_t mytimer;
uint16_t led1; uint16_t led1;
uint16_t led2;
if (mode_uninitialized) { if (mode_uninitialized) {
mode_uninitialized = false; mode_uninitialized = false;
@ -21,25 +20,19 @@ static void led_sound(void)
ADMUX = (1 << REFS0); // use VCC reference ADMUX = (1 << REFS0); // use VCC reference
ADCSRA = (1 << ADPS1) | (1 << ADPS0); // prescaler F_CPU/8 ADCSRA = (1 << ADPS1) | (1 << ADPS0); // prescaler F_CPU/8
ADCSRA |= (1 << ADEN); // ADC enable - turn it on ADCSRA |= (1 << ADEN); // ADC enable - turn it on
/*do one conversion*/
ADCSRA |= (1 << ADSC);
while (ADCSRA & (1 << ADSC)) {
/*wait for conversion to end */
}
uint16_t __attribute__ ((unused)) dummy = ADCW; //read once
timer_set(&mytimer, 10); timer_set(&mytimer, 10);
discharge = true; discharge = true;
} }
if (timer_expired(&mytimer)) { if (timer_expired(&mytimer)) {
if (discharge) { if (discharge) {
DDRC |= (1 << PORTC0) | (1 << PORTC1) | //set LED Ports to output: DDRC |= (1 << PORTC0) | (1 << PORTC1); //set LED Ports to output:
(1 << PORTC2) | (1 << PORTC3);
/*discharge*/ /*discharge*/
PORTC = (PORTC & 0b11110000); PORTC = (PORTC & 0b11110000);
/*set C0 and C2 to input (disable pullups)*/ /*set C0 and C2 to input (disable pullups)*/
DDRC &= ~((1 << PORTC0) | (1 << PORTC2)); //set Led Ports to input DDRC &= ~(1 << PORTC0); //set Led Ports to input
/*pull ups off*/ /*pull ups off*/
PORTC &= ~((1 << PORTC0) | (1 << PORTC2)); PORTC &= ~(1 << PORTC0);
discharge = false; discharge = false;
} else { } else {
/*single measurement*/ /*single measurement*/
@ -48,16 +41,11 @@ static void led_sound(void)
while (ADCSRA & (1 << ADSC)) ; // wait for conversion to end while (ADCSRA & (1 << ADSC)) ; // wait for conversion to end
led1 = ADCW; // read result led1 = ADCW; // read result
ADMUX = (ADMUX & ~(0x1F)) | 2; // select channel 2
ADCSRA |= (1 << ADSC); // start single conversion
while (ADCSRA & (1 << ADSC)) ; // wait for conversion to end
led2 = ADCW; // read result
set_motor(led1 > 0x50 ? MOTOR_ON : MOTOR_OFF); set_motor(led1 > 0x50 ? MOTOR_ON : MOTOR_OFF);
discharge = true; discharge = true;
} }
timer_set(&mytimer, 2); //relaunch timer timer_set(&mytimer, 10); //relaunch timer
} //end if timer_expired } //end if timer_expired
} //end mode5 } //end mode5