käänettäessä saan virheen:
Koodi: Valitse kaikki
Failed config
graphical_display_menu: [source <unicode string>:198]
id: my_menu
active: True
ID 'disp' of type tdisplays3::TDisplayS3 doesn't inherit from display::DisplayBuffer. Please double check your ID is pointing to the correct value.
display: disp
font: pieni
items:
- text: Menu Item 1
type: label
- text: Menu Item 2
type: label
mode: rotaryKoodi: Valitse kaikki
image:
- file: "mdi:volume-low"
id: icon_volume_low
resize: 75x75
- file: "mdi:volume-medium"
id: icon_volume_medium
resize: 75x75
- file: "mdi:volume-high"
id: icon_volume_high
resize: 75x75
font:
- file: "gfonts://Roboto"
id: my_font
size: 45
- file: "gfonts://Roboto"
id: roboto
size: 45
- file: "gfonts://Roboto"
id: pieni
size: 20
- file: 'fonts/Google_Sans_Bold.ttf'
id: font1
glyphs:
['&', '@', '!', ',', '.', '?', '"', '%', '(', ')', '+', '-', '_', ':', '°', '0',
'1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E',
'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ' ', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y', 'z','å', 'Ä', 'ä', 'Ö', 'ö', 'Ü', 'ü','ë', '/']
size: 25
graphical_display_menu:
id: my_menu
active: true
display: disp
font: pieni
items:
- type: Label
text: "Menu Item 1"
- type: Label
text: "Menu Item 2"
display:
- platform: tdisplays3
id: disp
update_interval: 1s
rotation: 90
pages:
- id: page1
lambda: |-
it.printf(150, 6, id(pieni), Color(255, 255, 255), "Etusivu");
it.printf(130, 50, id(roboto), Color(255, 0, 255), id(ha_time).now().strftime("%H:%M").c_str());
it.printf(75, 100, id(roboto), Color(255, 0, 255), id(ha_time).now().strftime("%d/%m/%Y").c_str());
- id: page2
lambda: |-
it.printf(150, 6, id(pieni), Color(255, 255, 255), "Spotify");
if (id(spotify).state == "playing") {
String artist = id(spotify_media_artist).state.c_str();
artist = artist.substring(0, 20);
it.printf(20, 30, id(font1), Color(255, 255, 255), artist.c_str());
String title = id(spotify_media_title).state.c_str();
title = title.substring(0, 20);
it.printf(20, 60, id(font1), Color(255, 255, 255), title.c_str());
float media_duration = id(spotify_media_duration).state;
float media_position = id(spotify_media_position).state;
float progress_percentage = (media_position / media_duration) * 100;
it.printf(175, 120, id(font1), Color(255, 255, 255), "%.2f%%", progress_percentage);
} else if (id(spotify).state == "paused") {
it.printf(150, 70, id(pieni), Color(255, 255, 255), "tauvolla");
} else if (id(spotify).state == "idle") {
it.printf(150, 70, id(pieni), Color(255, 255, 255), "sammutettu");
}
int volume_percentage = int(id(spotify_volume).state * 100);
it.printf(75, 120, id(font1), Color(255, 255, 255), "%d%%", volume_percentage);
if (volume_percentage > 70) {
it.image(0, 100, id(icon_volume_high), Color(255, 0, 0));
} else if (volume_percentage > 30) {
it.image(0, 100, id(icon_volume_medium), Color(255, 255, 0));
} else {
it.image(0, 100, id(icon_volume_low), Color(255, 0, 255));
}
- id: page3
lambda: |-
it.image(0, 0, id(icon_volume_low), Color(255, 0, 255));
- id: graph_page
lambda: |-
it.print(0, 0, id(my_font), "My menu is not currently active");
- id: advanced_drawing_mode_page
lambda: |-
const auto display_width = it.get_width();
const auto display_height = it.get_height();
auto half_display_width = (int)(display_width / 2.0f);
// This will render the menu to the right half of the screen leaving the left half for other drawing purposes
// Arguments: it.menu(x, y, menu, width, height);
it.menu(half_display_width, 0, id(my_menu), half_display_width, display_height);