Skip to content
Permalink
Browse files

Adding display button to P012, fixing P001 inthandler

  • Loading branch information...
enesbcs committed Mar 30, 2019
1 parent 6d8961b commit 0633bea66ba7644781a603311bd2b33d4e066129
Showing with 43 additions and 6 deletions.
  1. +4 −4 _P001_Switch.py
  2. +38 −1 _P012_LCD.py
  3. +1 −1 rpieGlobals.py
@@ -44,7 +44,7 @@ def __init__(self,taskindex): # general init
def __del__(self):
if self.enabled and self.timer100ms==False:
try:
gpios.HWPorts.remove_event_detect(self.taskdevicepin[0])
gpios.HWPorts.remove_event_detect(int(self.taskdevicepin[0]))
except:
pass

@@ -59,7 +59,7 @@ def plugin_init(self,enableplugin=None):
self.set_value(1,gpios.HWPorts.input(int(self.taskdevicepin[0])),True) # Sync plugin value with real pin state
try:
self.__del__()
gpios.HWPorts.add_event_detect(self.taskdevicepin[0],gpios.BOTH,self.p001_handler)
gpios.HWPorts.add_event_detect(int(self.taskdevicepin[0]),gpios.BOTH,self.p001_handler)
self.timer100ms = False
except:
misc.addLog(rpieGlobals.LOG_LEVEL_ERROR,"Event can not be added, register backup timer")
@@ -72,14 +72,14 @@ def plugin_read(self):
self._lastdataservetime = rpieTime.millis()
result = True
return result

def p001_handler(self,channel):
self.timer_ten_per_second()

def timer_ten_per_second(self):
if self.initialized and self.enabled:
val = gpios.HWPorts.input(int(self.taskdevicepin[0]))
print(val,self.uservar[0])
# print(val,self.uservar[0])
if int(val) != int(float(self.uservar[0])):
self.set_value(1,val,True)
self._lastdataservetime = rpieTime.millis()
@@ -47,6 +47,19 @@ def plugin_init(self,enableplugin=None):
self.__del__()
return False
if self.enabled:
if int(self.taskdevicepin[0])>=0:
try:
gpios.HWPorts.remove_event_detect(int(self.taskdevicepin[0]))
except:
pass
try:
gpios.HWPorts.add_event_detect(int(self.taskdevicepin[0]),gpios.BOTH,self.p012_handler)
self.timer100ms = False
except Exception as e:
misc.addLog(rpieGlobals.LOG_LEVEL_ERROR,"Event can not be added, register backup timer "+str(e))
self.timer100ms = True
else:
self.timer100ms = False
i2cport = -1
try:
for i in range(0,2):
@@ -78,6 +91,7 @@ def plugin_init(self,enableplugin=None):
try:
self.device = CharLCD(i2c_expander=str(self.taskdevicepluginconfig[0]), address=int(self.taskdevicepluginconfig[1]), port=i2cport,
cols=self.width, rows=self.height, auto_linebreaks=(str(self.taskdevicepluginconfig[3])=="1"), backlight_enabled=(str(self.taskdevicepluginconfig[4])=="1"))
self.uservar[0] = 1
self.initialized = True
except Exception as e:
misc.addLog(rpieGlobals.LOG_LEVEL_ERROR,"LCD can not be initialized! "+str(e))
@@ -139,7 +153,7 @@ def webform_load(self): # create html page for settings
except:
linestr = ""
webserver.addFormTextBox("Line"+str(l+1),"p012_template"+str(l),linestr,128)

webserver.addFormPinSelect("Display button","taskdevicepin0",self.taskdevicepin[0])
return True

def __del__(self):
@@ -149,6 +163,11 @@ def __del__(self):
self.device._set_backlight_enabled(False)
except:
pass
if self.enabled and self.timer100ms==False and (self.taskdevicepin[0]>-1):
try:
gpios.HWPorts.remove_event_detect(int(self.taskdevicepin[0]))
except:
pass

def plugin_exit(self):
self.__del__()
@@ -179,6 +198,10 @@ def webform_save(self,params): # process settings post reply
self.lines[l]=linestr
except:
self.lines.append(linestr)
try:
self.taskdevicepin[0]=int(webserver.arg("taskdevicepin0",params))
except:
self.taskdevicepin[0]=-1
self.plugin_init()
return True

@@ -274,3 +297,17 @@ def lcdparse(self,ostr):
else:
resstr=str(linestr)
return resstr

def p012_handler(self,channel):
self.timer_ten_per_second()

def timer_ten_per_second(self):
if self.initialized and self.enabled:
val = gpios.HWPorts.input(int(self.taskdevicepin[0]))
if int(val) != int(float(self.uservar[0])):
self.uservar[0] = int(val)
if int(val)==0:
if self.device._get_backlight_enabled():
self.device._set_backlight_enabled(False)
else:
self.device._set_backlight_enabled(True)
@@ -6,7 +6,7 @@
# Copyright (C) 2018-2019 by Alexander Nagy - https://bitekmindenhol.blog.hu/
#
PROGNAME = "RPIEasy"
BUILD = 19088
BUILD = 19089
PROGVER = "0."+str(BUILD/1000)

gpMenu = []

0 comments on commit 0633bea

Please sign in to comment.
You can’t perform that action at this time.