瀏覽代碼

fix: touchscreen.py if touchscreen is disconnected cpu run 100%...
rescan touchscreen every 1sec

micha 2 年之前
父節點
當前提交
3064c9bd9a
共有 1 個文件被更改,包括 26 次插入8 次删除
  1. 26 8
      input/touchscreen.py

+ 26 - 8
input/touchscreen.py

@@ -575,16 +575,34 @@ def touch_filter(name,lines):
 
 
 
-def main(cmd="",output=""):
+def main(cmd="",output="",name=""):
     a = Action(output)
     line = ""
     #cmd="evtest /dev/input/event5"
     #cmd="evtest /dev/input/event24"
-    r = os.popen(cmd)
-    print(cmd)
     while 1:
-        line = r.readline() 
-        a.action(line)
+        r = os.popen(cmd)
+        print("main cmd: ",cmd)
+        while 1:
+            line = r.readline() 
+            if not line:
+                print("main cmd r.readline return NONE !",int(time.time()))
+                print("losst touchscteen connection",output)
+                print()
+                break
+
+            a.action(line)
+
+        time.sleep(1)
+
+        # rescan touch input's 
+        touch_list =  get_touch_list()
+        x= touch_filter(name,touch_list)
+        print(x)
+        if len(x):   
+            disable_xinput_touch(name)
+            #cmd="evtest /dev/input/event5"
+            cmd="evtest {}".format(x[1])
     
 if __name__ == "__main__":
     
@@ -602,7 +620,7 @@ if __name__ == "__main__":
         #cmd="evtest /dev/input/event24"
         cmd="evtest {}".format(x[1])
         #start_new_thread(main,(cmd,"DP-2"))
-        start_new_thread(main,(cmd,"HDMI-1"))
+        start_new_thread(main,(cmd,"HDMI-1",name))#),name)
         touchscreen_count +=1
 
     #TOUCH 1
@@ -614,7 +632,7 @@ if __name__ == "__main__":
         disable_xinput_touch(name)
         #cmd="evtest /dev/input/event24"
         cmd="evtest {}".format(x[1])
-        start_new_thread(main,(cmd,"DP-2"))
+        start_new_thread(main,(cmd,"DP-2",name))#),name)
         #start_new_thread(main,(cmd,"HDMI-1"))
         touchscreen_count +=1
 
@@ -628,7 +646,7 @@ if __name__ == "__main__":
         disable_xinput_touch(name)
         #cmd="evtest /dev/input/event5"
         cmd="evtest {}".format(x[1])
-        start_new_thread(main,(cmd,"eDP-1"))
+        start_new_thread(main,(cmd,"eDP-1",name))#),name)
         #start_new_thread(main,(cmd,"HDMI-1"))
         touchscreen_count +=1