Not going too well… Thought it would be straight-forward. But no!
This is the head of my yaml file:
esphome:
name: esp32s2-msp2807
friendly_name: "ESP32 S2 msp2807"
includes:
- esp32s2-msp2807.h
esp32:
board: lolin_s2_mini
framework:
type: arduino
If I miss-spell the includes: filename, the editor complains. So I guess that that bits right?
And this is esp32s2-msp2807.h (absolute path: /config/esphome/esp32s2-msp2807.h):
globals:
- id: line1x
type: int
initial_value: '0'
- id: line1y
type: int
initial_value: '0'
- id: line2x
type: int
initial_value: '0'
- id: line2y
type: int
initial_value: '50'
… and lastly, this is the section in the project file that references the globals: held in the header file:
display:
- platform: ili9xxx
#
# truncated for brevity....
#
lambda: |-
it.printf(id(line1x), id(line1y), id(my_font), TextAlign::TOP_LEFT, "Temperature");
it.printf(it.get_width(), id(line1y), id(my_font), TextAlign::TOP_RIGHT, " %.1f°C", id(outside_temp).state);
it.printf(id(line2x), id(line2y), id(my_font), "Veh.Volts");
it.printf(it.get_width(), id(line2y), id(my_font), TextAlign::TOP_RIGHT, " %.1fV", id(veh_volts).state);
it.printf(id(line3x), id(line3y), id(my_font), "Veh.Amps");
it.printf(it.get_width(), id(line3y), id(my_font), TextAlign::TOP_RIGHT, " %.1fA", id(veh_amps).state);
#
#et cetera....
As is, the HA editor reports that “line1x”, “line2x” can not be found?