mirror of
https://codeberg.org/eel4746_piano/avr_piano.git
synced 2024-11-22 01:00:29 -05:00
don't read record mode from uart
This commit is contained in:
parent
5f0dbc2e23
commit
a07dcfff94
77
notes.c
77
notes.c
@ -237,11 +237,11 @@ main(void)
|
|||||||
unsigned short cycles = 0;
|
unsigned short cycles = 0;
|
||||||
unsigned char tmp = 0;
|
unsigned char tmp = 0;
|
||||||
for (unsigned char n = 0;; n = (n + 1) % 2) {
|
for (unsigned char n = 0;; n = (n + 1) % 2) {
|
||||||
if (UCSR0A & (1 << RXC0)) {
|
if (PINC & _BV(5))
|
||||||
mode = UDR0;
|
mode = '2';
|
||||||
PORTD &= ~(1 << P_SPKR);
|
else
|
||||||
usart_send(mode);
|
mode = '0';
|
||||||
}
|
|
||||||
// check if any buttons are pressed, otherwise don't play a note
|
// check if any buttons are pressed, otherwise don't play a note
|
||||||
if (mode == '0' && ((PINB & PCMSK0) | (PINC & PCMSK1) | (PIND & PCMSK2)) == 0) {
|
if (mode == '0' && ((PINB & PCMSK0) | (PINC & PCMSK1) | (PIND & PCMSK2)) == 0) {
|
||||||
// if a button was released, then send note and cycles played
|
// if a button was released, then send note and cycles played
|
||||||
@ -261,23 +261,6 @@ main(void)
|
|||||||
playtone();
|
playtone();
|
||||||
|
|
||||||
cycles = (cycles + 1) % 0xffff;
|
cycles = (cycles + 1) % 0xffff;
|
||||||
} else if (mode == '1') {
|
|
||||||
note = usart_read();
|
|
||||||
if (note >= 'Z') note -= '0';
|
|
||||||
tmp = usart_read();
|
|
||||||
cycles = tmp << 8;
|
|
||||||
tmp = usart_read();
|
|
||||||
cycles |= tmp;
|
|
||||||
tmp = usart_read();
|
|
||||||
|
|
||||||
// reset to default mode when an invalid note is read
|
|
||||||
if (tmp != 'z' || note >= '|') {
|
|
||||||
mode = '0';
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (unsigned short i = 0; i < cycles; i++)
|
|
||||||
playtone();
|
|
||||||
} else if (mode == '2') {
|
} else if (mode == '2') {
|
||||||
play_note(MARIO + 0, 131 * 0.3);
|
play_note(MARIO + 0, 131 * 0.3);
|
||||||
play_note(MARIO + 1, 262 * 0.3);
|
play_note(MARIO + 1, 262 * 0.3);
|
||||||
@ -285,14 +268,14 @@ main(void)
|
|||||||
play_note(MARIO + 3, 220 * 0.3);
|
play_note(MARIO + 3, 220 * 0.3);
|
||||||
play_note(MARIO + 4, 117 * 0.3);
|
play_note(MARIO + 4, 117 * 0.3);
|
||||||
play_note(MARIO + 5, 233 * 0.3);
|
play_note(MARIO + 5, 233 * 0.3);
|
||||||
play_note(255, 1800);
|
_delay_ms(1800);
|
||||||
play_note(MARIO + 0, 131 * 0.3);
|
play_note(MARIO + 0, 131 * 0.3);
|
||||||
play_note(MARIO + 1, 262 * 0.3);
|
play_note(MARIO + 1, 262 * 0.3);
|
||||||
play_note(MARIO + 2, 110 * 0.3);
|
play_note(MARIO + 2, 110 * 0.3);
|
||||||
play_note(MARIO + 3, 220 * 0.3);
|
play_note(MARIO + 3, 220 * 0.3);
|
||||||
play_note(MARIO + 4, 117 * 0.3);
|
play_note(MARIO + 4, 117 * 0.3);
|
||||||
play_note(MARIO + 5, 233 * 0.3);
|
play_note(MARIO + 5, 233 * 0.3);
|
||||||
play_note(255, 1800);
|
_delay_ms(1800);
|
||||||
|
|
||||||
play_note(MARIO + 6, 87 * 0.3);
|
play_note(MARIO + 6, 87 * 0.3);
|
||||||
play_note(MARIO + 7, 175 * 0.3);
|
play_note(MARIO + 7, 175 * 0.3);
|
||||||
@ -300,59 +283,57 @@ main(void)
|
|||||||
play_note(MARIO + 9, 147 * 0.3);
|
play_note(MARIO + 9, 147 * 0.3);
|
||||||
play_note(MARIO + 10, 78 * 0.3);
|
play_note(MARIO + 10, 78 * 0.3);
|
||||||
play_note(MARIO + 11, 156 * 0.3);
|
play_note(MARIO + 11, 156 * 0.3);
|
||||||
play_note(255, 1800);
|
_delay_ms(1800);
|
||||||
play_note(MARIO + 6, 87 * 0.3);
|
play_note(MARIO + 6, 87 * 0.3);
|
||||||
play_note(MARIO + 7, 175 * 0.3);
|
play_note(MARIO + 7, 175 * 0.3);
|
||||||
play_note(MARIO + 8, 73 * 0.3);
|
play_note(MARIO + 8, 73 * 0.3);
|
||||||
play_note(MARIO + 9, 147 * 0.3);
|
play_note(MARIO + 9, 147 * 0.3);
|
||||||
play_note(MARIO + 10, 78 * 0.3);
|
play_note(MARIO + 10, 78 * 0.3);
|
||||||
play_note(MARIO + 11, 156 * 0.3);
|
play_note(MARIO + 11, 156 * 0.3);
|
||||||
play_note(255, 1800);
|
_delay_ms(1800);
|
||||||
|
|
||||||
play_note(MARIO + 12, 156 * 0.3);
|
play_note(MARIO + 12, 156 * 0.3);
|
||||||
play_note(255, 25);
|
_delay_ms(25);
|
||||||
play_note(MARIO + 13, 147 * 0.3);
|
play_note(MARIO + 13, 147 * 0.3);
|
||||||
play_note(255, 25);
|
_delay_ms(25);
|
||||||
play_note(MARIO + 14, 139 * 0.3);
|
play_note(MARIO + 14, 139 * 0.3);
|
||||||
play_note(255, 25);
|
_delay_ms(25);
|
||||||
play_note(MARIO + 15, 131 * 0.6);
|
play_note(MARIO + 15, 131 * 0.6);
|
||||||
play_note(255, 25);
|
_delay_ms(25);
|
||||||
play_note(MARIO + 16, 156 * 0.3);
|
play_note(MARIO + 16, 156 * 0.3);
|
||||||
play_note(255, 25);
|
_delay_ms(25);
|
||||||
play_note(MARIO + 17, 147 * 0.6);
|
play_note(MARIO + 17, 147 * 0.6);
|
||||||
play_note(255, 25);
|
_delay_ms(25);
|
||||||
play_note(MARIO + 18, 104 * 0.6);
|
play_note(MARIO + 18, 104 * 0.6);
|
||||||
play_note(255, 25);
|
_delay_ms(25);
|
||||||
play_note(MARIO + 19, 98 * 0.6);
|
play_note(MARIO + 19, 98 * 0.6);
|
||||||
play_note(255, 25);
|
_delay_ms(25);
|
||||||
play_note(MARIO + 20, 139 * 0.6);
|
play_note(MARIO + 20, 139 * 0.6);
|
||||||
|
|
||||||
play_note(MARIO + 21, 156 * 0.3);
|
play_note(MARIO + 21, 156 * 0.3);
|
||||||
play_note(255, 25);
|
_delay_ms(25);
|
||||||
play_note(MARIO + 22, 185 * 0.3);
|
play_note(MARIO + 22, 185 * 0.3);
|
||||||
play_note(255, 25);
|
_delay_ms(25);
|
||||||
play_note(MARIO + 23, 175 * 0.3);
|
play_note(MARIO + 23, 175 * 0.3);
|
||||||
play_note(255, 25);
|
_delay_ms(25);
|
||||||
play_note(MARIO + 24, 165 * 0.3);
|
play_note(MARIO + 24, 165 * 0.3);
|
||||||
play_note(255, 25);
|
_delay_ms(25);
|
||||||
play_note(MARIO + 25, 233 * 0.3);
|
play_note(MARIO + 25, 233 * 0.3);
|
||||||
play_note(255, 25);
|
_delay_ms(25);
|
||||||
play_note(MARIO + 26, 220 * 0.3);
|
play_note(MARIO + 26, 220 * 0.3);
|
||||||
play_note(255, 25);
|
_delay_ms(25);
|
||||||
play_note(MARIO + 27, 208 * 0.6);
|
play_note(MARIO + 27, 208 * 0.6);
|
||||||
play_note(255, 25);
|
_delay_ms(25);
|
||||||
play_note(MARIO + 28, 156 * 0.6);
|
play_note(MARIO + 28, 156 * 0.6);
|
||||||
play_note(255, 25);
|
_delay_ms(25);
|
||||||
play_note(MARIO + 29, 123 * 0.6);
|
play_note(MARIO + 29, 123 * 0.6);
|
||||||
play_note(255, 25);
|
_delay_ms(25);
|
||||||
play_note(MARIO + 30, 123 * 0.6);
|
play_note(MARIO + 30, 123 * 0.6);
|
||||||
play_note(255, 25);
|
_delay_ms(25);
|
||||||
play_note(MARIO + 31, 110 * 0.6);
|
play_note(MARIO + 31, 110 * 0.6);
|
||||||
play_note(255, 25);
|
_delay_ms(25);
|
||||||
play_note(MARIO + 32, 104 * 0.6);
|
play_note(MARIO + 32, 104 * 0.6);
|
||||||
play_note(255, 25);
|
_delay_ms(25);
|
||||||
|
|
||||||
play_note(255, 3600);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user