Browse Source

Add get_egalax_edid_path

pull/2/head
Ali Hatami Tajik 2 years ago
parent
commit
57b7774ffb
  1. 6
      src/scripts/python/util/common.py
  2. 27
      src/scripts/python/util/egalax.py

6
src/scripts/python/util/common.py

@ -17,10 +17,14 @@ def max_match(a: str, b: str) -> str:
b (str): second string b (str): second string
Returns: Returns:
str: intersection of two strings str: intersection of two strings OR None if one or both strings are
empty or None
""" """
i = 0 i = 0
if not a or not b:
return None
if len(b) < len(a): if len(b) < len(a):
a, b = b, a a, b = b, a

27
src/scripts/python/util/egalax.py

@ -5,6 +5,8 @@ touchpannel's drm output and its overal status.
""" """
from pathlib import Path from pathlib import Path
from x import get_edid_dev_path
from common import max_match
VENDOR_ID = "0EEF" VENDOR_ID = "0EEF"
DEVICE_ID = "C000" DEVICE_ID = "C000"
@ -38,3 +40,28 @@ def is_egalax_connected() -> bool:
""" """
devpath = get_egalax_path() devpath = get_egalax_path()
return bool(devpath) return bool(devpath)
def get_egalax_edid_path() -> Path:
"""return EDID path of touchpannel rdm
This function will find intersection of the edid pathes and eGalax hid
device and if this intersection and returns the maximum match.
Runtime: 160ms on average -> Not efficient
Returns:
Path: edid path of eGalax OR None if not found or device is'nt connected
"""
egalax_dev = get_egalax_path()
if not egalax_dev:
return None
max_dir = "/sys/devices"
max_path = None
for path in get_edid_dev_path():
base_dir = max_match(str(path), str(egalax_dev))
if len(max_dir) < len(base_dir):
max_dir = base_dir
max_path = path
# TODO add sanity check (both edid and VENDOR:DEVICE are in that base)
return max_path

Loading…
Cancel
Save