MCPcopy Create free account
hub / github.com/TactilityProject/Tactility / write_lvgl_variables

Function write_lvgl_variables

device.py:223–314  ·  view source on GitHub ↗
(output_file, device_properties: ConfigParser)

Source from the content-addressed store, hash-verified

221 output_file.write("CONFIG_TT_LVGL_SHARED_ICON_SIZE=12\n")
222
223def write_lvgl_variables(output_file, device_properties: ConfigParser):
224 output_file.write("# LVGL\n")
225 if not has_group(device_properties, "lvgl") or not has_group(device_properties, "display"):
226 write_lvgl_variable_placeholders(output_file)
227 return
228 # LVGL DPI overrides the real DPI settings
229 dpi_text = get_property_or_none(device_properties, "lvgl", "dpi")
230 if dpi_text is None:
231 dpi_text = get_property_or_exit(device_properties, "display", "dpi")
232 dpi = safe_int(dpi_text, f"DPI must be an integer, but was: '{dpi_text}'")
233 output_file.write(f"CONFIG_LV_DPI_DEF={dpi}\n")
234 color_depth = get_property_or_exit(device_properties, "lvgl", "colorDepth")
235 output_file.write(f"CONFIG_LV_COLOR_DEPTH={color_depth}\n")
236 output_file.write(f"CONFIG_LV_COLOR_DEPTH_{color_depth}=y\n")
237 output_file.write("CONFIG_LV_DISP_DEF_REFR_PERIOD=10\n")
238 theme = get_property_or_default(device_properties, "lvgl", "theme", "DefaultDark")
239 if theme == "DefaultDark":
240 output_file.write("CONFIG_LV_THEME_DEFAULT_DARK=y\n")
241 elif theme == "DefaultLight":
242 output_file.write("CONFIG_LV_THEME_DEFAULT_LIGHT=y\n")
243 elif theme == "Mono":
244 output_file.write("CONFIG_LV_USE_THEME_MONO=y\n")
245 else:
246 exit_with_error(f"Unknown theme: {theme}")
247 font_height_text = get_property_or_default(device_properties, "lvgl", "fontSize", "14")
248 font_height = safe_int(font_height_text, f"Font height must be an integer, but was: '{font_height_text}'")
249 if font_height <= 12:
250 output_file.write("CONFIG_LV_FONT_MONTSERRAT_8=y\n")
251 output_file.write("CONFIG_LV_FONT_MONTSERRAT_12=y\n")
252 output_file.write("CONFIG_LV_FONT_MONTSERRAT_16=y\n")
253 output_file.write("CONFIG_LV_FONT_DEFAULT_MONTSERRAT_12=y\n")
254 output_file.write("CONFIG_TT_LVGL_FONT_SIZE_SMALL=8\n")
255 output_file.write("CONFIG_TT_LVGL_FONT_SIZE_DEFAULT=12\n")
256 output_file.write("CONFIG_TT_LVGL_FONT_SIZE_LARGE=16\n")
257 output_file.write("CONFIG_TT_LVGL_STATUSBAR_ICON_SIZE=12\n")
258 output_file.write("CONFIG_TT_LVGL_LAUNCHER_ICON_SIZE=30\n")
259 output_file.write("CONFIG_TT_LVGL_SHARED_ICON_SIZE=12\n")
260 elif font_height <= 14:
261 output_file.write("CONFIG_LV_FONT_MONTSERRAT_10=y\n")
262 output_file.write("CONFIG_LV_FONT_MONTSERRAT_14=y\n")
263 output_file.write("CONFIG_LV_FONT_MONTSERRAT_18=y\n")
264 output_file.write("CONFIG_LV_FONT_DEFAULT_MONTSERRAT_14=y\n")
265 output_file.write("CONFIG_TT_LVGL_FONT_SIZE_SMALL=10\n")
266 output_file.write("CONFIG_TT_LVGL_FONT_SIZE_DEFAULT=14\n")
267 output_file.write("CONFIG_TT_LVGL_FONT_SIZE_LARGE=18\n")
268 output_file.write("CONFIG_TT_LVGL_STATUSBAR_ICON_SIZE=16\n")
269 output_file.write("CONFIG_TT_LVGL_LAUNCHER_ICON_SIZE=36\n")
270 output_file.write("CONFIG_TT_LVGL_SHARED_ICON_SIZE=16\n")
271 elif font_height <= 16:
272 output_file.write("CONFIG_LV_FONT_MONTSERRAT_12=y\n")
273 output_file.write("CONFIG_LV_FONT_MONTSERRAT_16=y\n")
274 output_file.write("CONFIG_LV_FONT_MONTSERRAT_22=y\n")
275 output_file.write("CONFIG_LV_FONT_DEFAULT_MONTSERRAT_16=y\n")
276 output_file.write("CONFIG_TT_LVGL_FONT_SIZE_SMALL=12\n")
277 output_file.write("CONFIG_TT_LVGL_FONT_SIZE_DEFAULT=16\n")
278 output_file.write("CONFIG_TT_LVGL_FONT_SIZE_LARGE=22\n")
279 output_file.write("CONFIG_TT_LVGL_STATUSBAR_ICON_SIZE=16\n")
280 output_file.write("CONFIG_TT_LVGL_LAUNCHER_ICON_SIZE=42\n")

Callers 1

write_propertiesFunction · 0.85

Calls 8

has_groupFunction · 0.85
safe_intFunction · 0.85
get_property_or_defaultFunction · 0.85
get_property_or_noneFunction · 0.70
get_property_or_exitFunction · 0.70
exit_with_errorFunction · 0.70
writeMethod · 0.45

Tested by

no test coverage detected