コード例 #1
0
 def _init_module(self):
     self._distance = 0
     self._pack = NeuronPackData()
     self._pack.type = NeuronPackData.TYPE_SENSOR
     self._pack.service = 0x63
     self._pack.subservice = 0x3
     self._pack.on_response = self.__on_parse
コード例 #2
0
 def _init_module(self):
     self._pack = NeuronPackData()
     self._pack.type = NeuronPackData.TYPE_SENSOR
     self._pack.service = 0x63
     self._pack.subservice = 0x7
     self._pack.on_response = self.__on_parse
     self._status = {"temp": 0, "hum": 0}
コード例 #3
0
 def calibrate(self):
     pack = NeuronPackData()
     pack.idx = self._pack.idx
     pack.service = self._pack.service
     pack.subservice = self._pack.subservice
     pack.data = [0x10]
     self.call(pack)
コード例 #4
0
 def set_led(self, red, green, blue):
     pack = NeuronPackData()
     pack.idx = self._pack.idx
     pack.service = self._pack.service
     pack.subservice = self._pack.subservice
     pack.data = [0x1]
     pack.data.extend(short2bits(red))
     pack.data.extend(short2bits(green))
     pack.data.extend(short2bits(blue))
     self.call(pack)
コード例 #5
0
 def reset_pressed(self, idx=2):
     if type(idx) == str:
         if idx.lower() == 'a':
             idx = 0
         elif idx.lower() == 'b':
             idx = 1
     pack = NeuronPackData()
     pack.idx = self._pack.idx
     pack.service = self._pack.service
     pack.subservice = self._pack.subservice
     pack.data = [0x11, idx]
     self.call(pack)
コード例 #6
0
 def subscribe_all(self):
     pack = NeuronPackData()
     pack.on_response = self.on_subscribe_response
     pack.idx = self._pack.idx
     pack.service = self._pack.service
     pack.subservice = self._pack.subservice
     pack.data = [0x7f, NeuronPackData.TYPE_CHANGE, 0, 0, 0, 0]
     self.subscribe(pack)
     pack = NeuronPackData()
     pack.on_response = self.on_subscribe_response
     pack.idx = self._pack.idx
     pack.service = self._pack.service
     pack.subservice = self._pack.subservice
     pack.data = [0x7e, NeuronPackData.TYPE_CHANGE, 0, 0, 0, 0]
     self.subscribe(pack)
     pack = NeuronPackData()
     pack.on_response = self.on_subscribe_response
     pack.idx = self._pack.idx
     pack.service = self._pack.service
     pack.subservice = self._pack.subservice
     pack.data = [0x7d, NeuronPackData.TYPE_CHANGE, 0, 0, 0, 0]
     self.subscribe(pack)
     pack = NeuronPackData()
     pack.on_response = self.on_subscribe_response
     pack.idx = self._pack.idx
     pack.service = self._pack.service
     pack.subservice = self._pack.subservice
     pack.data = [0x7c, NeuronPackData.TYPE_PERIOD]
     pack.data.extend(long2bits(200))
     self.subscribe(pack)
     pack = NeuronPackData()
     pack.on_response = self.on_subscribe_response
     pack.idx = self._pack.idx
     pack.service = self._pack.service
     pack.subservice = self._pack.subservice
     pack.data = [0x7b, NeuronPackData.TYPE_CHANGE, 0, 0, 0, 0]
     self.subscribe(pack)
     pack = NeuronPackData()
     pack.on_response = self.on_subscribe_response
     pack.idx = self._pack.idx
     pack.service = self._pack.service
     pack.subservice = self._pack.subservice
     pack.data = [0x7a, NeuronPackData.TYPE_PERIOD]
     pack.data.extend(long2bits(200))
     self.subscribe(pack)
     pack = NeuronPackData()
     pack.on_response = self.on_subscribe_response
     pack.idx = self._pack.idx
     pack.service = self._pack.service
     pack.subservice = self._pack.subservice
     pack.data = [0x78, NeuronPackData.TYPE_PERIOD]
     pack.data.extend(long2bits(200))
     self.subscribe(pack)
コード例 #7
0
 def _init_module(self):
     self._pack = NeuronPackData()
     self._pack.service = 0x62
     self._pack.subservice = 0xa
コード例 #8
0
 def setup(self, board, idx, mode=1, period=0):
     self._board = board
     self._mode = mode
     self._pack = NeuronPackData()
     self._pack.idx = idx
     self._init_module()
コード例 #9
0
 def _init_module(self):
     self._pack = NeuronPackData()
コード例 #10
0
 def broadcast(self):
     self._dev.send(NeuronPackData.broadcast().to_buffer())