How to draw entire screen/page from local C++ file

Hey all,

I would like to clean up my yaml file with a screen with multiple pages. Is is possible to put the lambda lines in a C++ file. Include it and than just run lambda: screen_01(); from the main yaml files?

Like main.yaml:

  includes:
    - screens/screen_01.h
display:
  - platform: it8951e
    ...
    pages:
      - id: page1
        lambda: screen_01();
void screen_01( ){
  it.print(0, 10, id(my_font), "Hello world");
}

I mean, I know this code does not run. But what would I need to get the lambda scope into my custom external function? All it. display functionality and all sensors and stuff.

Hmm yes, I would not recommend this approach. To transfer EVERYTHING you need from the global scope to the included functions. You would need to have everything put in parameters… Hell no, I’m going to stick to playing syntax error battleship in the lambda part.