mirror of
https://codeberg.org/eel4746_piano/avr_piano.git
synced 2024-11-22 01:00:29 -05:00
bypass _delay_ms and user timer instead for silent note
This commit is contained in:
parent
ece65dcc2a
commit
5f0dbc2e23
14
notes.c
14
notes.c
@ -196,7 +196,19 @@ play_note(unsigned char _note, unsigned short _cycles)
|
|||||||
for (unsigned short i = 0; i < _cycles; i++)
|
for (unsigned short i = 0; i < _cycles; i++)
|
||||||
playtone();
|
playtone();
|
||||||
} else {
|
} else {
|
||||||
_delay_ms(_cycles);
|
// when note is 255, don't play anything for _cycles ms
|
||||||
|
// Prepare Timer/Counter
|
||||||
|
TCNT1 = 1;
|
||||||
|
OCR1A = 16e3 * _cycles / T1_PRESCALAR;
|
||||||
|
TCCR1B |= 1 << CS11;
|
||||||
|
|
||||||
|
// Monitor OutPut Compare Flag
|
||||||
|
while ((TIFR1 & (1 << OCF1A)) == 0);
|
||||||
|
|
||||||
|
// Toggles port For Speaker
|
||||||
|
PORTD ^= 1 << P_SPKR;
|
||||||
|
TIFR1 |= 1 << OCF1A;
|
||||||
|
TCCR1B &= ~(1 << CS11);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user