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
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}
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)
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)
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)
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)
def _init_module(self): self._pack = NeuronPackData() self._pack.service = 0x62 self._pack.subservice = 0xa
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()
def _init_module(self): self._pack = NeuronPackData()
def broadcast(self): self._dev.send(NeuronPackData.broadcast().to_buffer())