mirror of
https://codeberg.org/eel4746_piano/avr_piano.git
synced 2024-11-22 01:00:29 -05:00
mdkajflk
This commit is contained in:
parent
ab2a90ea5b
commit
8cacc107c9
17
lcd.c
17
lcd.c
@ -23,6 +23,8 @@ char notesBuffer[NOTES_BUFFER_SIZE];
|
|||||||
int serialIndex = 0;
|
int serialIndex = 0;
|
||||||
int notesIndex = 0;
|
int notesIndex = 0;
|
||||||
volatile int buttonState = 0; // Holds the state of all buttons
|
volatile int buttonState = 0; // Holds the state of all buttons
|
||||||
|
unsigned char songBuffer[1024];
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
void
|
void
|
||||||
usart_init(void)
|
usart_init(void)
|
||||||
@ -174,10 +176,11 @@ void displayNotes() {
|
|||||||
_delay_ms(1000);
|
_delay_ms(1000);
|
||||||
lcd_clear();
|
lcd_clear();
|
||||||
_delay_ms(1000);
|
_delay_ms(1000);
|
||||||
while (buttonState == 4) {
|
for(int k = 0; k < count) {
|
||||||
char randomValue = getNote();
|
unsigned char randomValue = songBuffer[k];
|
||||||
|
|
||||||
if (bufferIndex == 16) {
|
if (bufferIndex == 16) {
|
||||||
|
|
||||||
// Remove the first value and shift other values down
|
// Remove the first value and shift other values down
|
||||||
for (int i = 0; i < 16 - 1; i++) {
|
for (int i = 0; i < 16 - 1; i++) {
|
||||||
circularBuffer[i] = circularBuffer[i + 1];
|
circularBuffer[i] = circularBuffer[i + 1];
|
||||||
@ -199,8 +202,9 @@ void displayNotes() {
|
|||||||
lcd_print("PLAYING");
|
lcd_print("PLAYING");
|
||||||
}
|
}
|
||||||
|
|
||||||
//_delay_ms(1000);
|
_delay_ms(500);
|
||||||
}
|
}
|
||||||
|
buttonState = 0;
|
||||||
bufferIndex = 0;
|
bufferIndex = 0;
|
||||||
lcd_clear();
|
lcd_clear();
|
||||||
}
|
}
|
||||||
@ -216,7 +220,10 @@ void displaySerialData() {
|
|||||||
lcd_clear();
|
lcd_clear();
|
||||||
_delay_ms(1000);
|
_delay_ms(1000);
|
||||||
while (buttonState == 5) {
|
while (buttonState == 5) {
|
||||||
char randomValue = getNote();
|
unsigned char randomValue = getNote();
|
||||||
|
count = 0;
|
||||||
|
songBuffer[count] = randomValue;
|
||||||
|
count++;
|
||||||
|
|
||||||
if (bufferIndex == 16) {
|
if (bufferIndex == 16) {
|
||||||
// Remove the first value and shift other values down
|
// Remove the first value and shift other values down
|
||||||
@ -257,7 +264,7 @@ void displayPiano() {
|
|||||||
lcd_clear();
|
lcd_clear();
|
||||||
_delay_ms(1000);
|
_delay_ms(1000);
|
||||||
while (buttonState == 0) {
|
while (buttonState == 0) {
|
||||||
char randomValue = getNote();
|
unsigned char randomValue = getNote();
|
||||||
|
|
||||||
if (bufferIndex == 16) {
|
if (bufferIndex == 16) {
|
||||||
// Remove the first value and shift other values down
|
// Remove the first value and shift other values down
|
||||||
|
Loading…
Reference in New Issue
Block a user