Код: Выделить всё
struct menus {
char line0[21] = {"This is a menu 12351"};
char line1[21] = {"This is a menu 12352"};
char line2[21] = {"This is a menu 12353"};
char line3[21] = {"This is a menu 12354"};
char line4[21] = {"This is a menu 12355"};
char line5[21] = {"This is a menu 12356"};
char line6[21] = {"This is a menu 12357"};
char line7[21] = {"This is a menu 12358"};
u_int8_t top_line = 0; // place holder for which line is at the top of the display
} menu;
// Function to update the display sendString([text to display],[column],[row])
void updateDisplay() {
LCD.sendString(menu.line0, 0, 0);
LCD.sendString(menu.line1, 0, 1);
LCD.sendString(menu.line2, 0, 2);
LCD.sendString(menu.line3, 0, 3);
}
< /code>
Есть ли способ сделать что -то вроде: lcd.sendstring (меню. (Линия+переменная), 0,0) ?? < /p>
Тест, который я попробовал < /p>
// Function to scroll the display
void scrollDisplay()
{
menu.top_line++;
if (menu.top_line > 7)
{
menu.top_line = 0;
}
// Calculate the indices of the lines to display
int line0_index = menu.top_line % 8;
int line1_index = (menu.top_line + 1) % 8;
int line2_index = (menu.top_line + 2) % 8;
int line3_index = (menu.top_line + 3) % 8;
// Update the display with the new lines
LCD.sendString(menu.line0 + line0_index, 0, 0);
LCD.sendString(menu.line1 + line1_index, 0, 1);
LCD.sendString(menu.line2 + line2_index, 0, 2);
LCD.sendString(menu.line3 + line3_index, 0, 3);
}
Подробнее здесь: https://stackoverflow.com/questions/794 ... cd-display