not working yet

This commit is contained in:
bigalex 2012-09-25 20:19:14 +02:00
parent c1c545428b
commit 61c84c52aa
2 changed files with 27 additions and 15 deletions

View File

@ -78,7 +78,6 @@ void init_motor(void)
void set_motor(int val){ void set_motor(int val){
PORTB = ~(val); PORTB = ~(val);
PORTB = PORTB;
return; return;
}; };

View File

@ -136,6 +136,20 @@ static void mode_beeptest(void)
return; return;
} }
static void flashleds(int leds)
{
led_off(LED_L|LED_R);
for (int i=0; i<10; i++){
led_on(leds);
_delay_ms(10);
led_off(LED_L|LED_R);
_delay_ms(90);
};
return;
}
int main(void) int main(void)
{ {
@ -149,7 +163,7 @@ int main(void)
for(;;) /* ever */ { for(;;) /* ever */ {
//do something //do something
//TODO: check switches and change mode
switch(mode){ switch(mode){
case 1: case 1:
@ -161,24 +175,23 @@ int main(void)
case 3: case 3:
mode_beeptest(); mode_beeptest();
break; break;
case 4: case 4: break;
default: default: //mode=0;
mode=0;
case 0:
blinkrattlebeep(); blinkrattlebeep();
} }
//check switches and change mode
switch( PIND & 3){ switch( PIND & 0b00000011){
case 1: case 2: //left switch pressed
mode++; mode = (mode+1) % 4;
flashleds(LED_L);
break; break;
case 2: case 1: //right switch pressed
mode --; mode = (mode-1) % 4;
flashleds(LED_R);
break; break;
case 3:
default:
;
} }
} }