2026-04-20 11:48:38 +08:00
|
|
|
|
"""通用 UCD323/UCDController 辅助函数。
|
|
|
|
|
|
|
2026-05-13 17:17:13 +08:00
|
|
|
|
保留为兼容层和薄代理,避免业务模块直接依赖控制器内部实现细节。
|
2026-04-20 11:48:38 +08:00
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_tx_modules(ucd):
|
2026-05-13 17:17:13 +08:00
|
|
|
|
"""根据当前接口返回 (pg, ag) 模块。"""
|
|
|
|
|
|
return ucd.get_tx_modules()
|
2026-04-20 11:48:38 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_current_resolution(ucd, default=(3840, 2160)):
|
|
|
|
|
|
"""从 UCD 当前 timing 获取 (width, height),失败时返回 default。"""
|
2026-05-13 17:17:13 +08:00
|
|
|
|
return ucd.get_current_resolution(default)
|
2026-04-20 11:48:38 +08:00
|
|
|
|
|
|
|
|
|
|
|
2026-05-13 17:17:13 +08:00
|
|
|
|
def send_image_pattern(ucd, image_path):
|
|
|
|
|
|
"""通过 UCDController 发送一张本地图片作为显示 Pattern。"""
|
|
|
|
|
|
if not getattr(ucd, "status", False):
|
|
|
|
|
|
return False
|
2026-04-20 11:48:38 +08:00
|
|
|
|
|
2026-05-13 17:17:13 +08:00
|
|
|
|
send_via_controller = getattr(ucd, "send_image_pattern", None)
|
|
|
|
|
|
if not callable(send_via_controller):
|
|
|
|
|
|
return False
|
|
|
|
|
|
return bool(send_via_controller(image_path))
|
2026-04-20 11:48:38 +08:00
|
|
|
|
|
|
|
|
|
|
|
2026-05-13 17:17:13 +08:00
|
|
|
|
def send_solid_rgb_pattern(ucd, rgb, *, raise_on_error=False):
|
|
|
|
|
|
"""通过 UCDController 当前状态发送一组纯色 RGB Pattern。"""
|
2026-04-20 11:48:38 +08:00
|
|
|
|
if not getattr(ucd, "status", False):
|
2026-05-13 17:17:13 +08:00
|
|
|
|
if raise_on_error:
|
|
|
|
|
|
raise RuntimeError("UCD 未连接,无法发送纯色 Pattern")
|
2026-04-20 11:48:38 +08:00
|
|
|
|
return False
|
|
|
|
|
|
|
2026-05-13 17:17:13 +08:00
|
|
|
|
send_via_controller = getattr(ucd, "send_solid_rgb_pattern", None)
|
|
|
|
|
|
if not callable(send_via_controller):
|
|
|
|
|
|
if raise_on_error:
|
|
|
|
|
|
raise RuntimeError("UCDController 未实现 send_solid_rgb_pattern")
|
2026-04-20 11:48:38 +08:00
|
|
|
|
return False
|
|
|
|
|
|
|
2026-05-13 17:17:13 +08:00
|
|
|
|
ok = bool(send_via_controller(list(rgb)))
|
|
|
|
|
|
if not ok and raise_on_error:
|
|
|
|
|
|
raise RuntimeError(f"发送纯色 Pattern 失败: {rgb}")
|
|
|
|
|
|
return ok
|
2026-04-20 11:48:38 +08:00
|
|
|
|
|
|
|
|
|
|
|