Я имею 4-й линии на 20 символов OLED (NHD0420CW-AB3) и структуру в C ++, которая содержит 8 различных линий для отображения. Каждый раз, когда нажата кнопка, я бы хотел, чтобы дисплей переместил каждую позицию вверх 1 линейку 1 и следующий массив в структуре, добавленной в нижнюю линию. После того, как последняя строка в структуре помещена в нижнюю часть дисплея, нажатие кнопки «Следующая кнопка» помещает первый массив внизу, как круглый буфер. Я был бы признателен за любой вклад в отношении того, как я должен индексировать эти строки. < /P>
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);
}
Я имею 4-й линии на 20 символов OLED (NHD0420CW-AB3) и структуру в C ++, которая содержит 8 различных линий для отображения. Каждый раз, когда нажата кнопка, я бы хотел, чтобы дисплей переместил каждую позицию вверх 1 линейку 1 и следующий массив в структуре, добавленной в нижнюю линию. После того, как последняя строка в структуре помещена в нижнюю часть дисплея, нажатие кнопки «Следующая кнопка» помещает первый массив внизу, как круглый буфер. Я был бы признателен за любой вклад в отношении того, как я должен индексировать эти строки. < /P> [code]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); } [/code] Но строка только прокручивается вправо.>