@@ -131,3 +131,33 @@ def esp32_create_combined_bin(source, target, env):
131131 if lb .name == "meshtastic-device-ui" :
132132 lb .env .Append (CPPDEFINES = [("APP_VERSION" , verObj ["long" ])])
133133 break
134+
135+ # Get the display resolution from macros
136+ def get_display_resolution (build_flags ):
137+ # Check "DISPLAY_SIZE" to determine the screen resolution
138+ for flag in build_flags :
139+ if isinstance (flag , tuple ) and flag [0 ] == "DISPLAY_SIZE" :
140+ screen_width , screen_height = map (int , flag [1 ].split ("x" ))
141+ return screen_width , screen_height
142+ print ("No screen resolution defined in build_flags. Please define DISPLAY_SIZE." )
143+ exit (1 )
144+
145+ def load_boot_logo (source , target , env ):
146+ build_flags = env .get ("CPPDEFINES" , [])
147+ logo_w , logo_h = get_display_resolution (build_flags )
148+ print (f"TFT build with { logo_w } x{ logo_h } resolution detected" )
149+
150+ # Load the boot logo from `branding/logo_<width>x<height>.png` if it exists
151+ source_path = join (env ["PROJECT_DIR" ], "branding" , f"logo_{ logo_w } x{ logo_h } .png" )
152+ dest_dir = join (env ["PROJECT_DIR" ], "data" , "boot" )
153+ dest_path = join (dest_dir , "logo.png" )
154+ if env .File (source_path ).exists ():
155+ print (f"Loading boot logo from { source_path } " )
156+ # Prepare the destination
157+ env .Execute (f"mkdir -p { dest_dir } && rm -f { dest_path } " )
158+ # Copy the logo to the `data/boot` directory
159+ env .Execute (f"cp { source_path } { dest_path } " )
160+
161+ # Load the boot logo on TFT builds
162+ if ("HAS_TFT" , 1 ) in env .get ("CPPDEFINES" , []):
163+ env .AddPreAction ('$BUILD_DIR/littlefs.bin' , load_boot_logo )
0 commit comments