diff options
| -rw-r--r-- | lcd.c | 56 |
1 files changed, 22 insertions, 34 deletions
| @@ -132,7 +132,7 @@ void setup() { | |||
| 132 | 132 | ||
| 133 | ISR(PCINT1_vect) { | 133 | ISR(PCINT1_vect) { |
| 134 | // Update button state when any pin changes state | 134 | // Update button state when any pin changes state |
| 135 | for (unsigned char i = 0; i <= 5; i++) { | 135 | for (unsigned char i = 4; i <= 5; i++) { |
| 136 | if (PINC & (1 << i)) { | 136 | if (PINC & (1 << i)) { |
| 137 | if(buttonState == 0) | 137 | if(buttonState == 0) |
| 138 | buttonState = i; | 138 | buttonState = i; |
| @@ -148,8 +148,8 @@ void displayNotes() { | |||
| 148 | static int bufferIndex = 0; | 148 | static int bufferIndex = 0; |
| 149 | 149 | ||
| 150 | lcd_clear(); | 150 | lcd_clear(); |
| 151 | lcd_gotoxy(1, 1); | 151 | lcd_gotoxy(6, 2); |
| 152 | lcd_print("Play"); | 152 | lcd_print("PLAY"); |
| 153 | _delay_ms(1000); | 153 | _delay_ms(1000); |
| 154 | lcd_clear(); | 154 | lcd_clear(); |
| 155 | _delay_ms(1000); | 155 | _delay_ms(1000); |
| @@ -165,14 +165,14 @@ void displayNotes() { | |||
| 165 | circularBuffer[16 - 1] = randomValue; | 165 | circularBuffer[16 - 1] = randomValue; |
| 166 | } else { | 166 | } else { |
| 167 | // Add the new value to the buffer | 167 | // Add the new value to the buffer |
| 168 | circularBuffer[bufferIndex++] = randomValue; | 168 | circularBuffer[bufferIndex] = randomValue; |
| 169 | bufferIndex++; | ||
| 169 | } | 170 | } |
| 170 | 171 | ||
| 171 | lcd_clear(); | 172 | lcd_clear(); |
| 172 | lcd_gotoxy(1, 1); | 173 | for (int i = 0; i <= bufferIndex - 1; i++) { |
| 173 | for (int i = 0; i < bufferIndex; i++) { | 174 | char singleChar[2] = {circularBuffer[i], '\0'}; |
| 174 | char singleChar[2] = {circularBuffer[bufferIndex - i], '\0'}; | 175 | lcd_gotoxy(17-bufferIndex+i ,1); |
| 175 | lcd_gotoxy(16 - i, 1); | ||
| 176 | lcd_print(singleChar); // Print the single character | 176 | lcd_print(singleChar); // Print the single character |
| 177 | } | 177 | } |
| 178 | 178 | ||
| @@ -188,8 +188,8 @@ void displaySerialData() { | |||
| 188 | char circularBuffer[16]; | 188 | char circularBuffer[16]; |
| 189 | static int bufferIndex = 0; | 189 | static int bufferIndex = 0; |
| 190 | lcd_clear(); | 190 | lcd_clear(); |
| 191 | lcd_gotoxy(1, 1); | 191 | lcd_gotoxy(3, 2); |
| 192 | lcd_print("Record"); | 192 | lcd_print("RECORD"); |
| 193 | _delay_ms(1000); | 193 | _delay_ms(1000); |
| 194 | lcd_clear(); | 194 | lcd_clear(); |
| 195 | _delay_ms(1000); | 195 | _delay_ms(1000); |
| @@ -205,16 +205,17 @@ void displaySerialData() { | |||
| 205 | circularBuffer[16 - 1] = randomValue; | 205 | circularBuffer[16 - 1] = randomValue; |
| 206 | } else { | 206 | } else { |
| 207 | // Add the new value to the buffer | 207 | // Add the new value to the buffer |
| 208 | circularBuffer[bufferIndex++] = randomValue; | 208 | circularBuffer[bufferIndex] = randomValue; |
| 209 | bufferIndex++; | ||
| 209 | } | 210 | } |
| 210 | 211 | ||
| 211 | lcd_clear(); | 212 | lcd_clear(); |
| 212 | lcd_gotoxy(1,1); | 213 | lcd_gotoxy(1,1); |
| 213 | for (int i = (bufferIndex > 16) ? bufferIndex - 16 : 0; i < bufferIndex; i++) { | 214 | for (int i = 0; i <= bufferIndex-1; i++) { |
| 214 | char singleChar[2] = {circularBuffer[i], '\0'}; | 215 | char singleChar[2] = {circularBuffer[bufferIndex- 1 - i], '\0'}; |
| 215 | lcd_print(singleChar); // Print the single character | 216 | lcd_print(singleChar); // Print the single character |
| 216 | } | 217 | } |
| 217 | 218 | ||
| 218 | _delay_ms(1000); | 219 | _delay_ms(1000); |
| 219 | } | 220 | } |
| 220 | bufferIndex = 0; | 221 | bufferIndex = 0; |
| @@ -224,9 +225,7 @@ void displaySerialData() { | |||
| 224 | //******************************************************* | 225 | //******************************************************* |
| 225 | int main(void) { | 226 | int main(void) { |
| 226 | lcd_init(); | 227 | lcd_init(); |
| 227 | lcd_init(); | ||
| 228 | lcd_hideCursor(); | 228 | lcd_hideCursor(); |
| 229 | |||
| 230 | setup(); | 229 | setup(); |
| 231 | lcd_clear(); | 230 | lcd_clear(); |
| 232 | while (1) { | 231 | while (1) { |
| @@ -236,23 +235,12 @@ int main(void) { | |||
| 236 | 235 | ||
| 237 | } else if (buttonState == 4) { | 236 | } else if (buttonState == 4) { |
| 238 | displayNotes(); | 237 | displayNotes(); |
| 239 | } | 238 | } |
| 239 | else { | ||
| 240 | lcd_gotoxy(6,2); | ||
| 241 | lcd_print("PIANO"); | ||
| 242 | _delay_ms(1000); | ||
| 243 | } | ||
| 240 | } | 244 | } |
| 241 | return 0; | 245 | return 0; |
| 242 | /*while (1) { | ||
| 243 | lcd_clear(); | ||
| 244 | lcd_gotoxy(1, 1); | ||
| 245 | lcd_print("Note 1:"); | ||
| 246 | lcd_gotoxy(1, 2); | ||
| 247 | lcd_print("one country"); | ||
| 248 | lcd_showCursor(); | ||
| 249 | _delay_ms(2500); | ||
| 250 | lcd_clear(); | ||
| 251 | lcd_gotoxy(1, 1); | ||
| 252 | lcd_print("and mankind its"); | ||
| 253 | lcd_gotoxy(1, 2); | ||
| 254 | lcd_print("citizens."); | ||
| 255 | _delay_ms(3500); | ||
| 256 | } | ||
| 257 | return 0;*/ | ||
| 258 | } | 246 | } |
