コード例 #1
0
 def __init__(self, tid, name, pin):
     Sensor.__init__(self, tid, name, pin, "angle")
     self.add_property(
         Property(name="angle",
                  type=PropertyType.INT,
                  value=0,
                  unit="°",
                  range=[0, 100]))
コード例 #2
0
 def __init__(self, tid, name, pin):
     Sensor.__init__(self, tid, name, pin, "temperature")
     self.add_property(
         Property(name="temperature",
                  type=PropertyType.INT,
                  value=0,
                  unit="°C",
                  range=[0, 100]))
     self.add_property(
         Property(name="humidity",
                  type=PropertyType.INT,
                  value=0,
                  unit="%",
                  range=[0, 100]))
コード例 #3
0
 def __init__(self, tid, name, pin):
     Sensor.__init__(self, tid, name, pin)
     self.add_action(Action("turn_on"))
     self.add_action(Action("turn_off"))
     self.add_action(
         Action("flash").add_parameter(
             Property(name="duration",
                      type=PropertyType.INT,
                      value=10,
                      range=[10, 100])).add_parameter(
                          Property(name="interval",
                                   type=PropertyType.INT,
                                   value=1,
                                   range=[1, 10])))
     self.working_thread = None
コード例 #4
0
 def __init__(self, tid, name, pin):
     Sensor.__init__(self, tid, name, pin, "sound")
     self.add_property(
         Property(name="volume", type=PropertyType.INT, value=0, unit="dB"))
コード例 #5
0
 def turn_off(self):
     Sensor.digital_write(self, Relay.OFF)
コード例 #6
0
 def turn_on(self):
     Sensor.digital_write(self, Relay.ON)
コード例 #7
0
 def update_state(self):
     data = Sensor.analog_read(self, "dht")
     if data is not None:
         self.update_property(temperature=data[0], humidity=data[1])
コード例 #8
0
 def turn_on(self):
     Sensor.digital_write(self, Led.ON)
コード例 #9
0
 def turn_off(self):
     Sensor.digital_write(self, Buzzer.OFF)
コード例 #10
0
 def turn_on(self):
     Sensor.digital_write(self, Buzzer.ON)
コード例 #11
0
 def update_state(self):
     data = Sensor.analog_read(self, "ultrasonic")
     if data is not None:
         self.update_property(distance=data)
コード例 #12
0
 def __init__(self, tid, name, pin):
     Sensor.__init__(self, tid, name, pin, "distance")
     self.add_property(
         Property(name="distance", type=PropertyType.INT, unit="cm"))
コード例 #13
0
 def update_state(self):
     data = Sensor.digital_read(self)
     if data is not None:
         self.update_property(pressed=(data > 0))
コード例 #14
0
 def __init__(self, tid, name, pin):
     Sensor.__init__(self, tid, name, pin, "button")
     self.add_property(Property("pressed", PropertyType.BOOL))
コード例 #15
0
 def turn_off(self):
     Sensor.digital_write(self, Led.OFF)
コード例 #16
0
 def update_state(self):
     data = Sensor.analog_read(self)
     if data is not None and data is not 0:
         resistance = (1023 - data) * 10000.0 / data
         value = 1 / (math.log(resistance / 10000) / 4250 + 1 / 298.15) - 273.15 + 100
         self.update_property(temperature=value)
コード例 #17
0
 def update_state(self):
     data = Sensor.analog_read(self)
     if data is not None:
         self.update_property(angle=data)
コード例 #18
0
 def __init__(self, tid, name, pin):
     Sensor.__init__(self, tid, name, pin, "lcd")
     self.add_action(Action("display", message=PropertyType.STRING))