Add A Footer to TFT Display

An IlI9488 TFT Display has been configured on an ESP32-S3. The display has been configured with three pages. Each page displays a footer that is exactly the same for each of the three pages. Rather than include the same code at the end of each page section, I want to find a way to write that section of code once then somehow “publish it”. I tried setting up a script however I couldn’t overcome the reported errors. I think the errors were due to the script being called within the lambda: function of the display code.

I’m looking for an idea that allows me to code the “footer” once then somehow call that section of code into display code an display it at the bottom of each page. The footer code I want to include on each page is;

// ------------------------------------------------------------------------------------- LINE
it.filled_rectangle(9, 292, 460, 2, black);

// ----------------------------------------------------------------------------------- Print Current Time
if(id(ds1307_time).is_failed() == false){
// Refresh Timestamp
// Code by EnsconcE from https://community.home-assistant.io/t/esphome-show-time/348903
char str[40];
time_t currTime = id(ds1307_time).now().timestamp;
strftime(str, sizeof(str), "%I:%M%p %a %b %Oe, %Y", localtime(&currTime));
it.printf(239, 313, id(Regular_16pt), black, TextAlign::BASELINE_CENTER, "%s", str);
} else {
it.print(239, 313, id(Regular_16pt), red, TextAlign::BASELINE_CENTER, "Date And Time Unknown!");
}

// ----------------------------------------------------------------------------------- Print WiFi Strength
// Icon to be printed is generated via include file named wifi_icon.h
it.printf(430, 315, id(font_mdi_small), black, TextAlign::BASELINE_CENTER, wifi_icon(id(wifi_signal_pct).state));

Any insight you can offer would be greatly appreciated.

I was searching for exact the same. Ended up doing it without “pages”.
Used partial update, virtual switch, and “if state” in display lambda

You can find my code in my own replay on my post.
Inkplate 6, ESPHom - echo

substitutions:
  friendly_name: Inkplate Hallway
  devicename: inkplate_hallway

globals:
  - id: winter_bool
    type: bool
    restore_value: true
    initial_value: 'true'

switch:
# Virtual switch based on a global variable.
  - platform: template
    name: "Winter Mode"
    icon: mdi:snowflake
    id: winter_mode
    restore_mode: RESTORE_DEFAULT_ON
    turn_on_action:
      - globals.set:
          id: winter_bool
          value: 'true'
      - component.update: ${devicename}_display
    turn_off_action:
      - globals.set:
          id: winter_bool
          value: 'false'
      - component.update: ${devicename}_display
    lambda: |-
      return id(winter_bool);

display:
- platform: inkplate6
  id: ${devicename}_display

lambda: |-
  lambda: |-
      // -- Header --\\

	// do things you want in footer

     // -- Header end --\\
      // -- Footer --\\

	// do things you want in footer

    // -- Footer end --\\

    if (id(winter_mode).state) {

      // -- Winter -- \\

	// do things you want in "page1"

      // -- Winter end -- \\
    } else {
      // -- Summer -- \\

	// do things you want in "page2"

      // -- Summer end -- \\
      }

https://community.home-assistant.io/t/inkplate-6-esphome/295389?u=echo

Thank you. I’ve set that project aside for the winter but will have a look at your code as I’ll be getting back to the project in March.