File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ def __init__(self, pin):
1313
1414 def read (self ):
1515 self .old = self .new
16- self .new = self .adc .read ()/ 4.095
16+ self .new = self .adc .read () / 4.095
1717 return int (self .new )
1818
1919 # result > 0 to state up, < 0 to state down.
@@ -23,7 +23,7 @@ def get_state(self):
2323 return 0 if abs (tmp ) < self .eliminate else tmp
2424
2525 def calibrate (self ):
26- self .eliminate = 2 + self .read () / Intensity .dither
26+ self .eliminate = 2 + self .read () / Intensity .dither
2727
2828
2929class Gesture (object ):
@@ -43,7 +43,9 @@ def get_gesture(self, delay=25):
4343 sleep_ms (delay )
4444 self .get_brightness ()
4545 l_state , r_state = self .l .get_state (), self .r .get_state ()
46+
4647 result = []
48+
4749 if self .l_state == Gesture .idle and r_state > 0 and self .r .new - self .l .new > self .l .eliminate :
4850 self .l_count = 0
4951 self .l_state = Gesture .ing
@@ -77,9 +79,9 @@ def get_gesture(self, delay=25):
7779 result .append ('right' )
7880
7981 if l_state == 0 and r_state == 0 and self .l_state == Gesture .idle and self .r_state == Gesture .idle :
80- self .updata += 1
81- if self .updata > 20 :
82- self .updata = 0
82+ self .updata += 1
83+ if self .updata > 20 :
84+ self .updata = 0
8385 self .l .calibrate ()
8486 self .r .calibrate ()
8587
@@ -103,7 +105,7 @@ def unit_test():
103105 res = g .get_gesture ()
104106 if res != None :
105107 print (res )
106- count = 1 + count
108+ count = 1 + count
107109 print (count )
108110
109111
You can’t perform that action at this time.
0 commit comments