Skip to content

Commit

Permalink
Try to fix APDS gesture timer
Browse files Browse the repository at this point in the history
  • Loading branch information
enesbcs committed Jan 9, 2019
1 parent 328f398 commit 6e1edd6
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions _P064_APDS9960.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ def plugin_init(self,enableplugin=None):
gpios.HWPorts.add_event_detect(self.taskdevicepin[0],gpios.FALLING,self.p064_handler,200)
self.timer100ms = False
except Exception as e:
self.timer100ms = True
if str(self.taskdevicepluginconfig[0])=="0":
self.timer100ms = True
misc.addLog(rpieGlobals.LOG_LEVEL_ERROR,"Interrupt error "+str(e))
else:
self.timer100ms = True
if str(self.taskdevicepluginconfig[0])=="0":
self.timer100ms = True

try:
i2cok = gpios.HWPorts.i2c_init()
Expand All @@ -85,7 +87,7 @@ def plugin_init(self,enableplugin=None):
if initok:
try:
self.apds.setProximityIntLowThreshold(50)
if self.taskdevicepluginconfig[0]==1:
if str(self.taskdevicepluginconfig[0])=="1":
self.apds.enableProximitySensor()
self.apds.enableLightSensor()
else:
Expand Down Expand Up @@ -121,7 +123,8 @@ def webform_save(self,params): # process settings post reply
self.set_valuenames(self.PLUGIN_VALUENAME1)
self.vtype = rpieGlobals.SENSOR_TYPE_DIMMER
try:
gpios.HWPorts.remove_event_detect(self.taskdevicepin[0])
if self.taskdevicepin[0]>=0:
gpios.HWPorts.remove_event_detect(self.taskdevicepin[0])
except:
pass
self.set_value(1,0,False)
Expand Down Expand Up @@ -162,7 +165,7 @@ def timer_ten_per_second(self): # called 10 times per second (best effort)
if self.initialized and self.enabled:
tvar = self.uservar[0]
self.p064_get_gesture()
if tvar != self.uservar[0]: # publish changes if different gesture received than previous
if int(tvar) != int(self.uservar[0]): # publish changes if different gesture received than previous
self.plugin_senddata()
rpieTime.addsystemtimer(3,self.p064_timercb,[-1]) # reset gesture to None (0) after 3 sec
return True
Expand Down

0 comments on commit 6e1edd6

Please sign in to comment.