From 8cacc107c96a8816c8d15ad491af583ec75825de Mon Sep 17 00:00:00 2001 From: Joseph Bryant Date: Mon, 22 Apr 2024 13:43:14 -0400 Subject: [PATCH] mdkajflk --- lcd.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/lcd.c b/lcd.c index 54225c2..0c1dbcc 100644 --- a/lcd.c +++ b/lcd.c @@ -23,6 +23,8 @@ char notesBuffer[NOTES_BUFFER_SIZE]; int serialIndex = 0; int notesIndex = 0; volatile int buttonState = 0; // Holds the state of all buttons +unsigned char songBuffer[1024]; +int count = 0; void usart_init(void) @@ -167,17 +169,18 @@ ISR(PCINT1_vect) { void displayNotes() { char circularBuffer[16]; static int bufferIndex = 0; - + lcd_clear(); lcd_gotoxy(6, 2); lcd_print("PLAYING"); _delay_ms(1000); lcd_clear(); _delay_ms(1000); - while (buttonState == 4) { - char randomValue = getNote(); + for(int k = 0; k < count) { + unsigned char randomValue = songBuffer[k]; if (bufferIndex == 16) { + // Remove the first value and shift other values down for (int i = 0; i < 16 - 1; i++) { circularBuffer[i] = circularBuffer[i + 1]; @@ -199,8 +202,9 @@ void displayNotes() { lcd_print("PLAYING"); } - //_delay_ms(1000); + _delay_ms(500); } + buttonState = 0; bufferIndex = 0; lcd_clear(); } @@ -216,7 +220,10 @@ void displaySerialData() { lcd_clear(); _delay_ms(1000); while (buttonState == 5) { - char randomValue = getNote(); + unsigned char randomValue = getNote(); + count = 0; + songBuffer[count] = randomValue; + count++; if (bufferIndex == 16) { // Remove the first value and shift other values down @@ -257,7 +264,7 @@ void displayPiano() { lcd_clear(); _delay_ms(1000); while (buttonState == 0) { - char randomValue = getNote(); + unsigned char randomValue = getNote(); if (bufferIndex == 16) { // Remove the first value and shift other values down