Exemple #1
0
 def idle_input(self, conn):
     while True:
         GPIO.wait_for_edge(int(self.trigger), GPIO.BOTH)
         conn.send("inputchange:"+str(self.trigger)+":on")
         gui.change_input_state(str(self.trigger), 1, "reg")
         GPIO.wait_for_edge(int(self.trigger), GPIO.BOTH)
         conn.send("inputchange:"+str(self.trigger)+":off")
         gui.change_input_state(self.trigger, 0, "reg")
Exemple #2
0
 def event_disable_on_input(self, conn):
     while True:
         GPIO.wait_for_edge(int(self.trigger), GPIO.RISING)
         conn.send("inputchange:"+self.trigger+":on")
         gui.change_input_state(self.trigger, 1, "reg")
         conn.send("eventchange:"+self.who+":disable")
         gui.change_event_state(self.who, 0)
         GPIO.wait_for_edge(int(self.trigger), GPIO.FALLING)
         conn.send("inputchange:"+self.trigger+":off")
         gui.change_input_state(self.trigger, 0, "reg")
Exemple #3
0
 def refresh_gui_sensors(self):
     gui.console("Started sensor gui refresh process")
     while self.run_sensor_refresh:
         for i in temp_sensors:
             temp = self.get_temperature(sensor_name = i, return_cache = False)
             self.temp[i] = temp
             gui.change_input_state(temp_sensors[i], temp, "temp")
         for i in light_sensors:
             light = self.get_light_level(sensor_name = i)
             gui.change_input_state(light_sensors[i], light, "light")
         time.sleep(5)
Exemple #4
0
 def output_off_on_input(self, conn):
     while True:
         GPIO.wait_for_edge(int(self.trigger), GPIO.RISING)
         conn.send("inputchange:"+self.trigger+":on")
         gui.change_input_state(self.trigger, 1, "reg")
         for i in self.who:
             outputs[i].output(1)
             gui.change_output_state(i, 0)
         GPIO.wait_for_edge(int(self.trigger), GPIO.FALLING)
         conn.send("inputchange:"+self.trigger+":off")
         gui.change_input_state(self.trigger, 0, "reg")
Exemple #5
0
 def output_toggle_on_input(self, conn):
     state = 0
     while True:
         alreadyon = []
         GPIO.wait_for_edge(self.trigger, GPIO.RISING)
         conn.send("inputchange:"+str(self.trigger)+":on")
         gui.change_input_state(self.trigger, 1, "reg")
         for i in self.who:
             outputs[i].output(state)
             gui.change_output_state(i, not state)
             if state == 0:
                 state = 1
             else:
                 state = 0
         GPIO.wait_for_edge(int(self.trigger), GPIO.FALLING)
         gui.change_input_state(self.trigger, 0, "reg")
Exemple #6
0
 def output_toggle_on_input_timeout(self, conn):
     while True:
         alreadyon = []
         GPIO.wait_for_edge(int(self.trigger), GPIO.BOTH)
         conn.send("inputchange:"+str(self.trigger)+":on")
         gui.change_input_state(int(self.trigger), 1, "reg")
         for i in self.who:
             if outputs[i].input() == 0:
                 alreadyon.append(i)
                 gui.console("Pin already on")
             else:
                 outputs[i].output(1)
                 gui.change_output_state(int(i), 1)
                 conn.send("pinchange:"+i+":on")
         targettime = int(time.time()) + int(self.timeout)
         changed = False
         while not targettime == int(time.time()):
             if GPIO.input(int(self.trigger)):
                 if changed:
                     conn.send("inputchange:"+str(self.trigger)+":on")
                     gui.change_input_state(int(self.trigger), 1, "reg")
                     changed = False
                 targettime = int(time.time()) + self.timeout - 3
             else:
                 changed = True
                 conn.send("inputchange:"+str(self.trigger)+":off")
                 gui.change_input_state(int(self.trigger), 0, "reg")
             time.sleep(0.2)
         for i in self.who:
             if not i in alreadyon:
                 outputs[i].output(1)
                 conn.send("pinchange:"+i+":off")
                 gui.change_output_state(int(i), 0)
Exemple #7
0
 def input_idle(self, conn):
     goahead = True
     goahead1 = True
     while True:
         if goahead:
             try:
                 GPIO.wait_for_edge(self.pin, GPIO.RISING)
                 conn.send("inputchange:"+str(self.pin)+":on")
                 gui.change_input_state(self.pin, 1, "reg")
                 goahead1 = True
             except RuntimeError:
                 goahead1 = False
                 time.sleep(0.5)
         if goahead1:
             try:
                 GPIO.wait_for_edge(self.pin, GPIO.FALLING)
                 conn.send("inputchange:"+str(self.pin)+":off")
                 gui.change_input_state(self.pin, 0, "reg")
                 goahead = True
             except RuntimeError:
                 goahead = False
                 time.sleep(0.5)