I have added a ILI9341 TFT display to one of my ESPHome devices.
It works fine when setting x/y positioning, fonts, colors etc. directly in the lambda printf line.
Now I would like to get the printf parameters from HA to control :
x & y position
font
font size
font color
text string
I am using the HA input_text helper, and that works fine for getting the text_string (input_text.displaytext)
but I don’t know how to get the others ;
x_pos
y_pos
font name
font size
and font color.
Googling & trying to find a solution in HA Community didn’t help…
Regarding fonts/font sizes, & colors, its ok if the input_text content just “points” to my predefined fonts/font sizes & colors in the ESPHome file
Is there an easy way to do this ??
The first line in my lambda code works fine , but I would like the second lambda line to execute by getting all parameters from the input_text values…
> Blockquote
text_sensor:
- platform: homeassistant
name: displayxpos
entity_id: input_text.displayxpos
id: displayxpos
- platform: homeassistant
name: displayypos
entity_id: input_text.displayypos
id: displayypos
- platform: homeassistant
name: displaytext
entity_id: input_text.displaytext
id: displaytext
- platform: homeassistant
name: displayfont
entity_id: input_text.displayfont
id: displayfont
- platform: homeassistant
name: displayfontcolor
entity_id: input_text.displayfontcolor
id: displayfontcolor
color:
- id: yellow
red: 100%
green: 100%
blue: 0%
- id: red
red: 100%
green: 0%
blue: 0%
- id: navy
red: 0%
green: 0%
blue: 50%
- id: black
red: 0%
green: 0%
blue: 0%
- id: white
red: 100%
green: 100%
blue: 100%
- id: blue
blue: 100%
- id: green
green: 100%
font:
- file: fonts/Teko-SemiBold.ttf
id: text_44
size: 44
- file: fonts/Teko-SemiBold.ttf
id: text_96
size: 96
spi:
clk_pin: GPIO7
mosi_pin: GPIO11
miso_pin: GPIO9
display:
- platform: ili9xxx
model: TFT 2.4
cs_pin: 5
dc_pin: 12
reset_pin: 33 ### Not used ###
lambda: |-
it.printf(120, 20, id(text_44), id(white), TextAlign::TOP_CENTER, "%s", to_string( id(displaytext).state).c_str());
it.printf(id(displayxpos), id(displayypos), id(displayfont) id(displaycolor),TextAlign::TOP_CENTER, "%s", (id(displaytext).state.c_str());