Fully functional lcd!!!

This commit is contained in:
Joseph Bryant 2024-04-21 22:18:49 -04:00
parent a07dcfff94
commit 859b9f7781

50
lcd.c
View File

@ -132,7 +132,7 @@ void setup() {
ISR(PCINT1_vect) {
// Update button state when any pin changes state
for (unsigned char i = 0; i <= 5; i++) {
for (unsigned char i = 4; i <= 5; i++) {
if (PINC & (1 << i)) {
if(buttonState == 0)
buttonState = i;
@ -148,8 +148,8 @@ void displayNotes() {
static int bufferIndex = 0;
lcd_clear();
lcd_gotoxy(1, 1);
lcd_print("Play");
lcd_gotoxy(6, 2);
lcd_print("PLAY");
_delay_ms(1000);
lcd_clear();
_delay_ms(1000);
@ -165,14 +165,14 @@ void displayNotes() {
circularBuffer[16 - 1] = randomValue;
} else {
// Add the new value to the buffer
circularBuffer[bufferIndex++] = randomValue;
circularBuffer[bufferIndex] = randomValue;
bufferIndex++;
}
lcd_clear();
lcd_gotoxy(1, 1);
for (int i = 0; i < bufferIndex; i++) {
char singleChar[2] = {circularBuffer[bufferIndex - i], '\0'};
lcd_gotoxy(16 - i, 1);
for (int i = 0; i <= bufferIndex - 1; i++) {
char singleChar[2] = {circularBuffer[i], '\0'};
lcd_gotoxy(17-bufferIndex+i ,1);
lcd_print(singleChar); // Print the single character
}
@ -188,8 +188,8 @@ void displaySerialData() {
char circularBuffer[16];
static int bufferIndex = 0;
lcd_clear();
lcd_gotoxy(1, 1);
lcd_print("Record");
lcd_gotoxy(3, 2);
lcd_print("RECORD");
_delay_ms(1000);
lcd_clear();
_delay_ms(1000);
@ -205,13 +205,14 @@ void displaySerialData() {
circularBuffer[16 - 1] = randomValue;
} else {
// Add the new value to the buffer
circularBuffer[bufferIndex++] = randomValue;
circularBuffer[bufferIndex] = randomValue;
bufferIndex++;
}
lcd_clear();
lcd_gotoxy(1,1);
for (int i = (bufferIndex > 16) ? bufferIndex - 16 : 0; i < bufferIndex; i++) {
char singleChar[2] = {circularBuffer[i], '\0'};
for (int i = 0; i <= bufferIndex-1; i++) {
char singleChar[2] = {circularBuffer[bufferIndex- 1 - i], '\0'};
lcd_print(singleChar); // Print the single character
}
@ -223,10 +224,8 @@ void displaySerialData() {
//*******************************************************
int main(void) {
lcd_init();
lcd_init();
lcd_hideCursor();
setup();
lcd_clear();
while (1) {
@ -237,22 +236,11 @@ int main(void) {
} else if (buttonState == 4) {
displayNotes();
}
else {
lcd_gotoxy(6,2);
lcd_print("PIANO");
_delay_ms(1000);
}
}
return 0;
/*while (1) {
lcd_clear();
lcd_gotoxy(1, 1);
lcd_print("Note 1:");
lcd_gotoxy(1, 2);
lcd_print("one country");
lcd_showCursor();
_delay_ms(2500);
lcd_clear();
lcd_gotoxy(1, 1);
lcd_print("and mankind its");
lcd_gotoxy(1, 2);
lcd_print("citizens.");
_delay_ms(3500);
}
return 0;*/
}