def do(self, action):
     print self._blinking_loop
     if self._blinking_loop is not None:
         try:
             self._blinking_loop.stop()
         except:
             pass
     if action is not None:
         for k, v in action.iteritems():
             if k == 'state':
                 grovepi.digitalWrite(self._pin, v)
             elif k == 'blink':
                 self._blinking_period = float(v)
                 self._blinking_loop = task.LoopingCall(self._blink)
                 self._blinking_loop.start(self._blinking_period)
     print 'action done'
コード例 #2
0
 def _read(self):
     data = {}
     sensor_value = grovepi.analogRead(self._pin)
     data['gas_measurement'] = sensor_value
     gas_density = float(sensor_value) / 1024.0
     data['gas_density'] = gas_density
     return data
コード例 #3
0
 def _read(self):
     data = {}
     sensor_value = grovepi.analogRead(self._pin)
     amplitude = float(sensor_value) / 1024.0 * _vcc / 800.0 * 2000000.0
     effective = amplitude_current / 1.414
     data['measurement'] = sensor_value
     data['amplitude'] = amplitude
     data['effective'] = effective
     return data
コード例 #4
0
 def _read(self):
     data = {}
     data['distance'] = grovepi.ultrasonicRead(self._pin)
     presence = data.get('distance') < 50
     if presence == True:
         data['presence'] = 1
     else:
         data['presence'] = 0
     return data
コード例 #5
0
 def _read(self):
     data = {}
     data['vibrating'] = grovepi.analogRead(self._pin)
     return data
コード例 #6
0
 def _read(self):
     data = {}
     data['moisture'] = grovepi.analogRead(self._pin)
     return data
コード例 #7
0
 def _read(self):
     data = {}
     sensor_value = grovepi.analogRead(self._pin)
     data['light'] = sensor_value
     return data
コード例 #8
0
 def _read(self):
     data = {}
     sensor_value = grovepi.analogRead(self._pin)
     data['potentiometer'] = sensor_value
     return data
コード例 #9
0
 def _init_sensor(self):
     try:
         grovepi.pinMode(self._pin, "INPUT")
     except:
         pass
コード例 #10
0
 def do(self, action):
     if action is not None:
         for k, v in action.iteritems():
             if k == 'level':
                 grovepi.ledBar_setLevel(self._pin, v)
コード例 #11
0
 def _init_actuator(self):
     grovepi.ledBar_init(self._pin, 0)
     sleep(0.5)
     grovepi.ledBar_setLevel(self._pin, 5)
コード例 #12
0
 def do(self, action):
     if action is not None:
         for k, v in action.iteritems():
             if k == 'state':
                 grovepi.digitalWrite(self._pin, v)
コード例 #13
0
 def _init_actuator(self):
     grovepi.pinMode(self._pin, 'OUTPUT')
コード例 #14
0
 def _blink(self):
     grovepi.digitalWrite(self._pin, self._led_status)
     if self._led_status == 0:
         self._led_status = 1
     else:
         self._led_status = 0
コード例 #15
0
 def _read(self):
     data = {}
     data['motion'] = grovepi.digitalRead(self._pin)
     return data
コード例 #16
0
 def _read(self):
     data = {}
     data['flame'] = grovepi.digitalRead(self._pin)
     return data
コード例 #17
0
 def _read(self):
     data = {}
     sensor_value = grovepi.analogRead(self._pin)
     data['sound_measurement'] = sensor_value
     return data
コード例 #18
0
 def _read(self):
     data = {}
     [temp, humidity] = grovepi.dht(self._pin, 1)
     data['temperature'] = temp
     data['humidity'] = humidity
     return data
コード例 #19
0
 def _init_actuator(self):
     grovepi.pinMode(self._pin, 'OUTPUT')
     self._blinking_loop = task.LoopingCall(self._blink)
     self._blinking_loop.start(0.5)