Some basic “automatic” layouting I do:
pages:
- id: page_tcs34725
lambda: |-
it.set_rotation(id(display_rotation));
// CANVAS DIMENSIONS // width: 128 // height: 64
int w = it.get_width();
int h = it.get_height();
int y_plus = round(h / 7);
int padding = round(h / 7);
int x = 0;
int y = y_plus;
int wx = w - 10;
// If rotated, split to 2 rows
if ( id(display_rotation) == DISPLAY_ROTATION_90_DEGREES || id(display_rotation) == DISPLAY_ROTATION_270_DEGREES ) {
y_plus = round(padding * 1.7); // 240/135 display ratio
y = padding;
wx = w/2 - 10;
}
it.printf(x, y, id(normal), id(black), TextAlign::CENTER_LEFT, "Red");
it.printf(wx, y, id(large), id(red), TextAlign::CENTER_RIGHT, "%.2f%", id(tzt_red).state);
y = y + y_plus;
it.printf(x, y, id(normal), id(black), TextAlign::CENTER_LEFT, "Green");
it.printf(wx, y, id(large), id(green), TextAlign::CENTER_RIGHT, "%.2f%", id(tzt_green).state);
y = y + y_plus;
it.printf(x, y, id(normal), id(black), TextAlign::CENTER_LEFT, "Blue");
it.printf(wx, y, id(large), id(blue), TextAlign::CENTER_RIGHT, "%.2f%", id(tzt_blue).state);
y = y + y_plus;
// If rotated, split to 2 rows
if ( id(display_rotation) == DISPLAY_ROTATION_90_DEGREES || id(display_rotation) == DISPLAY_ROTATION_270_DEGREES ) {
y = padding;
x = w/2;
wx = w;
}
it.printf(x, y, id(normal), id(black), TextAlign::CENTER_LEFT, "Clear");
it.printf(wx, y, id(large), id(black), TextAlign::CENTER_RIGHT, "%.2f%", id(tzt_clear).state);
y = y + y_plus;
it.printf(x, y, id(normal), id(white), TextAlign::CENTER_LEFT, "Lx");
it.printf(wx, y, id(large), id(white), TextAlign::CENTER_RIGHT, "%.2flx", id(tzt_illuminance).state);
y = y + y_plus;
it.printf(x, y, id(normal), id(black), TextAlign::CENTER_LEFT, "K.");
it.printf(wx, y, id(large), id(white), TextAlign::CENTER_RIGHT, "%.2f", id(tzt_color_temperature).state);
But all in all it’s not really meant for designing stuff, better using the awful Nextion editor if your display supports it, or LVGL - Espressif (ESP32) — LVGL documentation