commit 8cacc107c96a8816c8d15ad491af583ec75825de
parent ab2a90ea5b0b1a44ad7be910650afd9610eff805
Author: Joseph Bryant <jbryant0653@floridapoly.edu>
Date: Mon, 22 Apr 2024 13:43:14 -0400
mdkajflk
Diffstat:
| M | lcd.c | | | 19 | +++++++++++++------ |
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git 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