Untitled

 avatar
unknown
plain_text
a year ago
2.3 kB
6
Indexable
int main(void) {

    // ... (Ustawienia rejestrów kierunku i inicjalizacja wyświetlacza LCD - bez zmian)

    // Zdefiniowanie kolejnych symboli
    unsigned char symbol2[8] = {
        0b01110,
        0b10001,
        0b11111,
        0b10101,
        0b10001,
        0b11111,
        0b10001,
        0b01110
    };
    unsigned char symbol3[8] = {
        0b11000,
        0b11100,
        0b01100,
        0b00110,
        0b01100,
        0b11100,
        0b11000
    };
    unsigned char symbol4[8] = {
        0b00110,
        0b01010,
        0b01110,
        0b11110,
        0b01110,
        0b01010,
        0b00110
    };
    unsigned char symbol5[8] = {
        0b10001,
        0b01001,
        0b10101,
        0b11111,
        0b10101,
        0b01001,
        0b10001
    };

    // Zapisanie symboli do pamięci CGRAM
    LCD_saveCustChar(2, symbol2);
    LCD_saveCustChar(3, symbol3);
    LCD_saveCustChar(4, symbol4);
    LCD_saveCustChar(5, symbol5);

    char text[] = "Jak [2][2] to [3][3] jest [4][4] byc [5][5] skryba [2][3][4][5]?"; // Tekst do wyświetlania
    int textLength = sizeof(text) - 1; // Długość tekstu (bez znaku null)
    int position = 0; // Pozycja wyświetlania tekstu

    while (1) {
        // Wyczyszczenie ekranu
        LCD_sendCommand(LCD_CLEAR);

        // Wyświetlanie pierwszej linii tekstu
        LCD_setCursor(1, 0);
        for (int i = position; i < position + 16; i++) {
            if (text[i] == '[') {
                LCD_sendData(i + 2 - position); // Wyświetlanie symbolu z pamięci CGRAM
                i += 2;
            } else {
                LCD_sendData(text[i]);
            }
        }

        // Wyświetlanie drugiej linii tekstu
        LCD_setCursor(2, 0);
        for (int i = position + 16; i < textLength; i++) {
            if (text[i] == '[') {
                LCD_sendData(i + 2 - position - 16); // Wyświetlanie symbolu z pamięci CGRAM
                i += 2;
            } else {
                LCD_sendData(text[i]);
            }
        }

        // Przesunięcie pozycji wyświetlania
        position++;
        if (position + 16 > textLength) {
            position = 0;
        }

        __delay_ms(500); // Opóźnienie
    }

    return 0;
}

Editor is loading...
Leave a Comment