Enabled replaying recording with P1.3 button.

This commit is contained in:
Jonathan Chan 2018-03-20 14:39:02 -07:00
parent 8c65cbcb4e
commit f4c44bf892
1 changed files with 11 additions and 9 deletions

View File

@ -30,6 +30,7 @@
#define DELAY 1000 // input sample delay in microseconds #define DELAY 1000 // input sample delay in microseconds
#define MAXNOTES 64 // record at most 64 notes (arbitrary) #define MAXNOTES 64 // record at most 64 notes (arbitrary)
// max length of note is 0xFFFF centiseconds = approx. 10 minutes
unsigned int rec[MAXNOTES]; // notes recorded unsigned int rec[MAXNOTES]; // notes recorded
unsigned int len[MAXNOTES]; // length of each note in centiseconds unsigned int len[MAXNOTES]; // length of each note in centiseconds
@ -48,7 +49,7 @@ unsigned int whole[8] = {
void play(unsigned int note) { void play(unsigned int note) {
CCR0 = note; CCR0 = note;
CCR1 = note == n ? 0 : 100; CCR1 = note == n ? 0 : 250;
} }
void playback() { void playback() {
@ -79,7 +80,6 @@ void record() {
} }
__delay_cycles(DELAY); __delay_cycles(DELAY);
} }
P1OUT &= ~LED1;
} }
void main(void) { void main(void) {
@ -97,7 +97,6 @@ void main(void) {
__enable_interrupt(); __enable_interrupt();
record(); record();
playback();
} }
#if defined(__TI_COMPILER_VERSION__) #if defined(__TI_COMPILER_VERSION__)
@ -124,9 +123,12 @@ __interrupt void port1_isr(void)
void __attribute__ ((interrupt(PORT1_VECTOR))) port1_isr (void) void __attribute__ ((interrupt(PORT1_VECTOR))) port1_isr (void)
#endif #endif
{ {
save_length(notes); // save length of current note if (recording) {
TACCTL0 &= ~CCIE; // disable interrupts for clock save_length(notes);
P1IE &= ~BIT3; // disable interrupts for button recording = false;
P1IFG &= ~BIT3; // set interrupt flag to 0 P1OUT &= ~LED1;
recording = false; // stop recording TACCTL0 &= ~CCIE; // disable interrupts for clock
}
playback();
P1IFG &= ~BUTTON; // set interrupt flag to 0
} }