def close(self): if self.active: self.active = False ret = sys_bhi160.disable_sensor(self.sensor_id) if ret < 0: raise ValueError("Disable sensor returned %i", ret) interrupt.disable_callback(self.interrupt_id) interrupt.set_callback(self.interrupt_id, None)
def _alarm_handler(self): interrupt.disable_callback(interrupt.RTC_ALARM) vibra.set(True) while True: pressed = buttons.read(buttons.BOTTOM_LEFT | buttons.BOTTOM_RIGHT | \ buttons.TOP_RIGHT | buttons.TOP_LEFT) if pressed != 0: break vibra.set(False) self._done = True
def close(self): """ Close the currently open connection to the sensor. """ if self.active: self.active = False ret = sys_max30001.disable_sensor() if ret < 0: raise ValueError("Disable sensor returned %i", ret) interrupt.disable_callback(self.interrupt_id) interrupt.set_callback(self.interrupt_id, None)
def enable_sensor(self): interrupt.disable_callback(self.interrupt_id) interrupt.set_callback(self.interrupt_id, self._interrupt) self.stream_id = sys_bhi160.enable_sensor(self.sensor_id, self.sample_buffer_len, self.sample_rate, self.dynamic_range) if self.stream_id < 0: raise ValueError("Enable sensor returned %i", self.stream_id) self.active = True if self._callback: interrupt.enable_callback(self.interrupt_id)
def enable_sensor(self): """ Enables the sensor. Automatically called by __init__. """ interrupt.disable_callback(self.interrupt_id) interrupt.set_callback(self.interrupt_id, self._interrupt) self.stream_id = sys_max30001.enable_sensor( self.usb, self.bias, self.sample_rate, self.sample_buffer_len ) if self.stream_id < 0: raise ValueError("Enable sensor returned %i", self.stream_id) self.active = True if self._callback: interrupt.enable_callback(self.interrupt_id)