summaryrefslogtreecommitdiff
path: root/lcd.c
diff options
context:
space:
mode:
authorJoseph Bryant <jbryant0653@floridapoly.edu>2024-04-22 13:43:14 -0400
committerJoseph Bryant <jbryant0653@floridapoly.edu>2024-04-22 13:43:14 -0400
commit8cacc107c96a8816c8d15ad491af583ec75825de (patch)
treec6c7b34d3efd37320337d012299a5c02370da5c6 /lcd.c
parentab2a90ea5b0b1a44ad7be910650afd9610eff805 (diff)
mdkajflk
Diffstat (limited to 'lcd.c')
-rw-r--r--lcd.c19
1 files 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];
23int serialIndex = 0; 23int serialIndex = 0;
24int notesIndex = 0; 24int notesIndex = 0;
25volatile int buttonState = 0; // Holds the state of all buttons 25volatile int buttonState = 0; // Holds the state of all buttons
26unsigned char songBuffer[1024];
27int count = 0;
26 28
27void 29void
28usart_init(void) 30usart_init(void)
@@ -167,17 +169,18 @@ ISR(PCINT1_vect) {
167void displayNotes() { 169void displayNotes() {
168 char circularBuffer[16]; 170 char circularBuffer[16];
169 static int bufferIndex = 0; 171 static int bufferIndex = 0;
170 172
171 lcd_clear(); 173 lcd_clear();
172 lcd_gotoxy(6, 2); 174 lcd_gotoxy(6, 2);
173 lcd_print("PLAYING"); 175 lcd_print("PLAYING");
174 _delay_ms(1000); 176 _delay_ms(1000);
175 lcd_clear(); 177 lcd_clear();
176 _delay_ms(1000); 178 _delay_ms(1000);
177 while (buttonState == 4) { 179 for(int k = 0; k < count) {
178 char randomValue = getNote(); 180 unsigned char randomValue = songBuffer[k];
179 181
180 if (bufferIndex == 16) { 182 if (bufferIndex == 16) {
183
181 // Remove the first value and shift other values down 184 // Remove the first value and shift other values down
182 for (int i = 0; i < 16 - 1; i++) { 185 for (int i = 0; i < 16 - 1; i++) {
183 circularBuffer[i] = circularBuffer[i + 1]; 186 circularBuffer[i] = circularBuffer[i + 1];
@@ -199,8 +202,9 @@ void displayNotes() {
199 lcd_print("PLAYING"); 202 lcd_print("PLAYING");
200 } 203 }
201 204
202 //_delay_ms(1000); 205 _delay_ms(500);
203 } 206 }
207 buttonState = 0;
204 bufferIndex = 0; 208 bufferIndex = 0;
205 lcd_clear(); 209 lcd_clear();
206} 210}
@@ -216,7 +220,10 @@ void displaySerialData() {
216 lcd_clear(); 220 lcd_clear();
217 _delay_ms(1000); 221 _delay_ms(1000);
218 while (buttonState == 5) { 222 while (buttonState == 5) {
219 char randomValue = getNote(); 223 unsigned char randomValue = getNote();
224 count = 0;
225 songBuffer[count] = randomValue;
226 count++;
220 227
221 if (bufferIndex == 16) { 228 if (bufferIndex == 16) {
222 // Remove the first value and shift other values down 229 // Remove the first value and shift other values down
@@ -257,7 +264,7 @@ void displayPiano() {
257 lcd_clear(); 264 lcd_clear();
258 _delay_ms(1000); 265 _delay_ms(1000);
259 while (buttonState == 0) { 266 while (buttonState == 0) {
260 char randomValue = getNote(); 267 unsigned char randomValue = getNote();
261 268
262 if (bufferIndex == 16) { 269 if (bufferIndex == 16) {
263 // Remove the first value and shift other values down 270 // Remove the first value and shift other values down