Exemplo n.º 1
0
class Pi_hat_adc():
    def __init__(self, bus_num=1, addr=ADC_DEFAULT_IIC_ADDR):
        self.bus = Bus(bus_num)
        self.addr = addr

    # get all raw adc data,THe max value is 4095,cause it is 12 Bit ADC
    def get_all_adc_raw_data(self):
        array = []
        for i in range(ADC_CHAN_NUM):
            data = self.bus.read_i2c_block_data(self.addr, REG_RAW_DATA_START + i, 2)
            val = data[1] << 8 | data[0]
            array.append(val)
        return array

    def get_nchan_adc_raw_data(self, n):
        data = self.bus.read_i2c_block_data(self.addr, REG_RAW_DATA_START + n, 2)
        val = data[1] << 8 | data[0]
        return val

    # get all data with unit mv.
    def get_all_vol_milli_data(self):
        array = [0 for _ in range(ADC_CHAN_NUM)]
        for i in range(ADC_CHAN_NUM):
            data = self.bus.read_i2c_block_data(self.addr, REG_VOL_START + i, 2)
            val = data[1] << 8 | data[0]
            array[i] = val
        return array

    def get_nchan_vol_milli_data(self, n):
        data = self.bus.read_i2c_block_data(self.addr, REG_VOL_START + n, 2)
        val = data[1] << 8 | data[0]
        return val
Exemplo n.º 2
0
    def init(self, busno, caseflag):

        self.busnum = busno

        self.bus = Bus(busno)
        self.case = caseflag
        time.sleep(.001)
        self.paj7620SelectBank(self.BANK0)
        self.paj7620SelectBank(self.BANK0)

        data0 = self.paj7620ReadReg(0, 1)[0]
        data1 = self.paj7620ReadReg(1, 1)[0]

        if self.debug:
            print("data0:", data0, "data1:", data1)
        if data0 != 0x20:  #or data1 <> 0x76:
            if self.debug:
                print("Error with sensor")
            #return 0xff
        if data0 == 0x20:
            if self.debug:
                print("wake-up finish.")

        for i in range(len(self.initRegisterArray)):
            self.paj7620WriteReg(self.initRegisterArray[i][0],
                                 self.initRegisterArray[i][1])
        self.paj7620SelectBank(self.BANK0)
        self.active = 1
        print("Paj7620 initialize register finished.")
Exemplo n.º 3
0
    def __init__(self, address=0x03, evt_en=True):
        super(ButtonTypedI2c, self).__init__(0)

        self.bus = Bus()
        self._addr = address

        # Initialise the I2C button device
        self.dev_id = 0
        self._probe_uid()
        self._version = 0
        self.version()
        self._size = self.size()

        self._set_mode(True)

        self.__last_evt = None
        self.__last_evt = self.read()

        self.key_names = _grove_5way_tactile_keys
        if self._size == 6:
            self.key_names = _grove_6pos_dip_switch_keys

        self.__thrd_exit = False
        self.__thrd = None
        if not evt_en:
            return

        if self.__thrd is None or not self.__thrd.is_alive():
            self.__thrd = threading.Thread( \
                    target = ButtonTypedI2c.__thrd_chk_evt, \
                    args = (self,))
            self.__thrd.setDaemon(True)
            self.__thrd.start()
class GroveTemperatureHumidityAHT20(object):
    def __init__(self, address=0x38, bus=None):
        self.address = address

        # I2C bus
        self.bus = Bus(bus)

    def read(self):
        self.bus.write_i2c_block_data(self.address, 0x00, [0xac, 0x33, 0x00])

        # measurement duration < 16 ms
        time.sleep(0.016)

        data = self.bus.read_i2c_block_data(self.address, 0x00, 6)

        humidity = data[1]
        humidity <<= 8
        humidity += data[2]
        humidity <<= 4
        humidity += (data[3] >> 4)
        humidity /= 1048576.0
        humidity *= 100

        temperature = data[3] & 0x0f
        temperature <<= 8
        temperature += data[4]
        temperature <<= 8
        temperature += data[5]
        temperature = temperature / 1048576.0 * 200.0 - 50.0  # Convert to Celsius

        return temperature, humidity
 def __init__(self, address=0x33):
     self.bus = Bus()
     self.addr = address
     self.refresh_rate = RefreshRate.REFRESH_0_5_HZ
     self._I2CReadWords(0x2400, eeData)
     # print(eeData)
     self._ExtractParameters()
class MLX9064X_I2C_Driver:
    def __init__(self, address):
        self.bus = Bus()
        self.addr = address

    def I2CWriteWord(self, writeAddress, data):
        write = self.bus.msg.write(
            self.addr,
            [writeAddress >> 8, writeAddress & 0xFF, data >> 8, data & 0xFF])
        try:
            self.bus.i2c_rdwr(write)
        except OSError:
            print(
                "Error:Please check if the I2C device insert in I2C of Base Hat"
            )
            exit(1)

    def I2CReadWords(self, addr, buffer, *, end=None):
        if end is None:
            remainingWords = len(buffer)
        else:
            remainingWords = end
        write = self.bus.msg.write(self.addr, [addr >> 8, addr & 0xFF])
        read = self.bus.msg.read(self.addr, 2 * remainingWords)
        try:
            self.bus.i2c_rdwr(write, read)
        except OSError:
            print(
                "Error:Please check if the I2C device insert in I2C of Base Hat"
            )
            exit(1)
        result = list(read)
        for i in range(remainingWords * 2):
            if i % 2 != 0:
                buffer[(i - 1) // 2] = (result[i - 1] << 8) | result[i] & 0xff
Exemplo n.º 7
0
        def init(self, busno=1, caseflag=1):
                self.busnum = busno
                print("set busnum to "+str(self.busnum))
                sys.stderr.write("init"+str(busno))
                self.bus = Bus(busno)
                self.case = caseflag
                self.paj7620SelectBank(self.BANK0)
                self.paj7620SelectBank(self.BANK0)
                
                data0 = self.paj7620ReadReg(0, 1)[0]
                data1 = self.paj7620ReadReg(1, 1)[0]

                if self.debug:
                        print("data0:",data0,"data1:",data1)
                if data0 != 0x20  :#or data1 <> 0x76:
                        if self.debug:
                                sys.stderr.write("Error with sensor")
                        #return 0xff
                if data0 == 0x20:
                        if self.debug:
                                sys.stderr.write("wake-up finish.")
                        
                for i in range(len(self.initRegisterArray)):
                        self.paj7620WriteReg(self.initRegisterArray[i][0],self.initRegisterArray[i][1])
                self.paj7620SelectBank(self.BANK0)
                self.active=1
                sys.stderr.write("Paj7620 initialize register finished.")
Exemplo n.º 8
0
class GroveTemperatureHumiditySensorSHT3x(object):
    def __init__(self, address=0x45, bus=None):
        self.address = address

        # I2C bus
        self.bus = Bus(bus)

    def read(self):
        # high repeatability, clock stretching disabled
        self.bus.write_i2c_block_data(self.address, 0x24, [0x00])

        # measurement duration < 16 ms
        time.sleep(0.016)

        # read 6 bytes back
        # Temp MSB, Temp LSB, Temp CRC, Humididty MSB, Humidity LSB, Humidity CRC
        data = self.bus.read_i2c_block_data(0x45, 0x00, 6)
        temperature = data[0] * 256 + data[1]
        celsius = -45 + (175 * temperature / 65535.0)
        humidity = 100 * (data[3] * 256 + data[4]) / 65535.0
        if data[2] != CRC(data[:2]):
            raise RuntimeError("temperature CRC mismatch")
        if data[5] != CRC(data[3:5]):
            raise RuntimeError("humidity CRC mismatch")
        return celsius, humidity
Exemplo n.º 9
0
    def __init__(self,
                 weather_sensor_address=Config.I2C_WEATHER_SENSOR_ADDRESS,
                 bus=None):
        self.weather_sensor_address = weather_sensor_address
        self.bus = Bus(bus)

        if Config.ENABLE_POWERGAUGE:
            self.powergauge_module = LC709203F(
                board.I2C(), address=Config.I2C_POWERGAUGE_ADDRESS)
    def __init__(self, bus_num=1, addr=ADC_DEFAULT_IIC_ADDR):
        '''
        Init iic.

        Args: 
            bus_num(int): the bus number;
            addr(int): iic address;
        '''
        self.bus = Bus(bus_num)
        self.addr = addr
Exemplo n.º 11
0
    def __init__(self, bus=None, address=0x3C):
        self.bus = Bus(bus)
        self.address = address

        self.off()
        self.inverse = False
        self.mode = self.HORIZONTAL

        self.clear()
        self.on()
class Motor(object):
    __MotorSpeedSet = 0x82
    __PWMFrequenceSet = 0x84
    __DirectionSet = 0xaa
    __MotorSetA = 0xa1
    __MotorSetB = 0xa5
    __Nothing = 0x01
    __EnableStepper = 0x1a
    __UnenableStepper = 0x1b
    __Stepernu = 0x1c
    I2CAddr = 0x0f  #Set the address of the I2CMotorDriver
    SPEED_MAX = 100

    def __init__(self, address=0x0f):
        #I2C Port - Grove - I2C Motor Driver V1.3
        self.I2CAddr = address
        self.bus = Bus()
        self.motor = [null, DCMotor(), DCMotor]

    def __del__(self):
        self.set_speed(0, 0)

    #Maps speed from 0-100 to 0-255
    def _map_vals(self, value, leftMin, leftMax, rightMin, rightMax):
        #http://stackoverflow.com/questions/1969240/mapping-a-range-of-values-to-another
        # Figure out how 'wide' each range is
        leftSpan = leftMax - leftMin
        rightSpan = rightMax - rightMin

        # Convert the left range into a 0-1 range (float)
        valueScaled = float(value - leftMin) / float(leftSpan)

        # Convert the 0-1 range into a value in the right range.
        return int(rightMin + (valueScaled * rightSpan))

    def update(self):
        self.set_dir(self.motor[1].clockwise, self.motor[2].clockwise)
        self.set_speed(self.motor[1].speed, self.motor[2].speed)

    #Set motor speed
    def set_speed(self, speed1=0, speed2=0):
        s1 = self._map_vals(speed1, 0, 100, 0, 255)
        s2 = self._map_vals(speed2, 0, 100, 0, 255)
        self.bus.write_i2c_block_data(self.I2CAddr, self.__MotorSpeedSet,
                                      [s1, s2])
        time.sleep(.02)

    #Set motor direction
    def set_dir(self, clock_wise1=True, clock_wise2=True):
        dir1 = 0b10 if clock_wise1 else 0b01
        dir2 = 0b10 if clock_wise2 else 0b01
        dir = (dir2 << 2) | dir1
        self.bus.write_i2c_block_data(self.I2CAddr, self.__DirectionSet,
                                      [dir, 0])
        time.sleep(.02)
Exemplo n.º 13
0
    def __init__(self, bus=None, address=0x29):
        self.address = address
        self.bus = Bus(bus)

        self.awake = False

        if self.id not in (0x44, 0x4D):
            raise ValueError('Not find a Grove I2C Color Sensor V2')

        self.set_integration_time(24)
        self.set_gain(4)
Exemplo n.º 14
0
class TouchSlider():

    left_button_press_flag = UNPRESSED
    right_button_press_flag = UNPRESSED

    def __init__(self, bus_num=1, addr=TOUCH_SENSOR_CY8C_DEFAULT_IIC_ADDR):
        self.bus = Bus(bus_num)
        self.addr = addr

    def read_sensor_button_value(self):
        button_value = self.bus.read_byte_data(self.addr, BUTTON_REG_ADDR)
        return button_value

    def read_sensor_slider_value(self):
        slider_value = self.bus.read_byte_data(self.addr,
                                               TOUCH_SLIDER_REG_ADDR)
        return slider_value

    def parse_and_print_result(self, button_value, slider_value):
        '''
        if(0 == button_value):
            if(PRESSED == self.left_button_press_flag):
                print("Left button is released")
                self.left_button_press_flag = UNPRESSED
            if(PRESSED == self.right_button_press_flag):
                print("Right button is released")
                self.right_button_press_flag = UNPRESSED
        '''
        if (0x01 == button_value & 0x1):
            if (UNPRESSED == self.left_button_press_flag):
                print("Left button is pressed")
                self.left_button_press_flag = PRESSED
        elif (0 == button_value & 0x1):
            if (PRESSED == self.left_button_press_flag):
                print("Left button is released")
                self.left_button_press_flag = UNPRESSED
        if (0x02 == button_value & 0x2):
            if (UNPRESSED == self.right_button_press_flag):
                print("Right button is pressed")
                self.right_button_press_flag = PRESSED
        elif (0 == button_value & 0x2):
            if (PRESSED == self.right_button_press_flag):
                print("Right button is released")
                self.right_button_press_flag = UNPRESSED
        if (0 != slider_value):
            print("Slider is pressed,value is %s" % (slider_value))

    def listen_sensor_status(self):
        while True:
            button_value = self.read_sensor_button_value()
            slider_value = self.read_sensor_slider_value()
            self.parse_and_print_result(button_value, slider_value)
            time.sleep(.05)
Exemplo n.º 15
0
    def __init__(self):
        self.bus = Bus()

        # SGB30 i2c default address is 0x58
        self.address = 0x58
        self.crc_status = [0, 0]
        self.CO2eq = 0
        self.TVOC = 0
        self.CO2eq_raw = 0
        self.TVOC_raw = 0
        self.CO2eq_baseline = 0
        self.TVOC_baseline = 0
Exemplo n.º 16
0
 def __init__(self, address=0x03):
     self.bus = Bus()
     self.addr = address
     self.dev_id = 0
     self.val = 0
     self.probeDevID()
     self.get_val()
     self.send_Byte(0x02)
     app1 = self.status_read()
     while 1:
         self.status_read()
         time.sleep(1.0)
         continue
    def __init__(self, address=0x53, i2c=None):
        self.address = address
        self.bus = Bus(i2c)

        print('ID: {}'.format(self.id))
        self.reset()

        self._timing_control = 0
        self._power_control = 0
        self._measurement_control = 0
        self._sample_rate = 400
        self._bandwidth = 200
        self._mode = STANDBY_MODE
Exemplo n.º 18
0
 def __init__(self, dht_type, pin=12, bus_num=1):
     if dht_type != self.DHT_TYPE['DHT11'] and dht_type != self.DHT_TYPE[
             'DHT22'] and dht_type != self.DHT_TYPE['DHT10']:
         print('ERROR: Please use 11|22|10 as dht type.')
         exit(1)
     self.dht_type = dht_type
     if dht_type == self.DHT_TYPE['DHT10']:
         self.bus = Bus(bus_num)
         self.addr = self.DEFAULT_ADDR
         self._dht10_init()
     else:
         self.pin = GPIO(pin, GPIO.OUT)
         self._last_temp = 0.0
         self._last_humi = 0.0
Exemplo n.º 19
0
    def __init__(self, bus=None, address=0x3C):
        self.bus = Bus(bus)
        self.address = address

        self.off()
        self.inverse = False
        self.mode = self.HORIZONTAL

        self.width = 128 # test
        self.height = 64 # test
        self._pages = self.height//8 # test
        self._buffer = [0]*(self.width*self._pages) # test

        self.clear()
        self.on()
Exemplo n.º 20
0
def get_data():
    i2c_port_number = get_i2c_port_number()
    sgp30 = seeed_sgp30.grove_sgp30(Bus(i2c_port_number))

    co2_eq_ppm = 400
    tvoc_ppb = 0

    sample_number = 0
    sample_array = numpy.zeros((10, 2))

    for lp in range(40):
        data = sgp30.read_measurements()
        co2_eq_ppm, tvoc_ppb = data.data
        # print("\r {}: tVOC = {} ppb CO2eq = {}  ".format(lp, tvoc_ppb, co2_eq_ppm))

        if co2_eq_ppm > 400 or tvoc_ppb > 0:
            sample_array[sample_number] = (tvoc_ppb, co2_eq_ppm)
            sample_number += 1
            # print(sample_array)

        if sample_number == 10:
            # print(sample_array)
            result = numpy.mean(sample_array, axis=0)
            # print(result)
            return result[0], result[1]  # VOC, CO2
            # break

        time.sleep(1)

    return get_data()
Exemplo n.º 21
0
class I2C_Station:
    def __init__(self,
                 weather_sensor_address=Config.I2C_WEATHER_SENSOR_ADDRESS,
                 bus=None):
        self.weather_sensor_address = weather_sensor_address
        self.bus = Bus(bus)

        if Config.ENABLE_POWERGAUGE:
            self.powergauge_module = LC709203F(
                board.I2C(), address=Config.I2C_POWERGAUGE_ADDRESS)

    def CRC(self, data):
        crc = 0xff
        for s in data:
            crc ^= s
            for _ in range(8):
                if crc & 0x80:
                    crc <<= 1
                    crc ^= 0x131
                else:
                    crc <<= 1
        return crc

    def read_weather_data(self):
        self.bus.write_i2c_block_data(self.weather_sensor_address, 0x24,
                                      [0x00])

        time.sleep(0.016)

        data = self.bus.read_i2c_block_data(self.weather_sensor_address, 0x00,
                                            6)

        temperature = data[0] * 256 + data[1]
        celsius = -45 + (175 * temperature / 65535.0)
        humidity = 100 * (data[3] * 256 + data[4]) / 65535.0

        return celsius, humidity

    def get_power_stats(self):
        try:
            voltage = self.powergauge_module.cell_voltage
            power = self.powergauge_module.cell_percent
        except Exception as e:
            voltage = None
            power = None

        return power, voltage
Exemplo n.º 22
0
    class Pi_hat_adc():
        def __init__(self,bus_num=1,addr=ADC_DEFAULT_IIC_ADDR):
            self.bus=Bus(bus_num)
            self.addr=addr

        def get_all_vol_milli_data(self):
            array = []
            for i in range(ADC_CHAN_NUM):
                data=self.bus.read_i2c_block_data(self.addr,REG_VOL_START+i,2)
                val=data[1]<<8|data[0]
                array.append(val)
            return array

        def get_nchan_vol_milli_data(self,n):
            data=self.bus.read_i2c_block_data(self.addr,REG_VOL_START+n,2)
            val =data[1]<<8|data[0]
            return val
Exemplo n.º 23
0
class Pi_hat_adc():
    def __init__(self,bus_num=1,addr=0X04):
        self.bus=Bus(bus_num)
        self.addr=addr
 
    #get all raw adc data,THe max value is 4095,cause it is 12 Bit ADC
    def get_all_adc_raw_data(self):
        array = []
        for i in range(8):  
            data=self.bus.read_i2c_block_data(self.addr,0X10+i,2)
            val=data[1]<<8|data[0]
            array.append(val)
        return array
 
    def get_nchan_adc_raw_data(self,n):
        data=self.bus.read_i2c_block_data(self.addr,0X10+n,2)
        val =data[1]<<8|data[0]
        return val
    def __init__(self, bus=I2C_SMBUS, address=I2C_ADDRESS, debug=1, pause=0.8):
            # assert(bus is not None)
            # assert(address > 0b000111 and address < 0b1111000)
            self.address = address
            self.bus = Bus(bus)
            self.pause = pause
            self.debug = debug
            self.gain  = 0
            self._bus  = bus
            self._addr = address

            ambient       = None
            IR            = None
            self._ambient = 0
            self._IR      = 0
            self._LUX     = None
            self._control(_POWER_UP)
            self._partno_revision()
    def __init__(self, addr=ICM20600_I2C_ADDR1):
        self._dev = _akicm.rpi_icm20600_alloc()
        dev_path = "/dev/i2c-{}".format(Bus().bus)
        icm20600_cfg = ICM20600Cfg(ICM20600_RANGE_2K_DPS,
                                   ICM20600_GYRO_RATE_1K_BW_176,
                                   ICM20600_GYRO_AVERAGE_1, ICM20600_RANGE_16G,
                                   ICM20600_ACC_RATE_1K_BW_420,
                                   ICM20600_ACC_AVERAGE_4,
                                   ICM20600_ICM_6AXIS_LOW_POWER, 0)

        _akicm.rpi_icm20600_init(self._dev, dev_path, addr,
                                 byref(icm20600_cfg))
class GroveTemperatureHumiditySensorSHT3x(object):
    def __init__(self, address=0x45, bus=None):
        self.address = address

        # I2C bus
        self.bus = Bus(bus)

    def CRC(self, data):
        crc = 0xff
        for s in data:
            crc ^= s
            for i in range(8):
                if crc & 0x80:
                    crc <<= 1
                    crc ^= 0x131
                else:
                    crc <<= 1
        return crc

    def read(self):
        # High repeatability, clock stretching disabled
        self.bus.write_i2c_block_data(self.address, 0x24, [0x00])

        # Measurement duration < 16 ms
        time.sleep(0.016)

        # Read 6 bytes back:
        # Temp MSB, Temp LSB, Temp CRC,
        # Humididty MSB, Humidity LSB, Humidity CRC
        data = self.bus.read_i2c_block_data(0x45, 0x00, 6)
        temperature = data[0] * 256 + data[1]
        celsius = -45 + (175 * temperature / 65535.0)
        humidity = 100 * (data[3] * 256 + data[4]) / 65535.0
        if data[2] != self.CRC(data[:2]):
            raise RuntimeError("Temperature CRC mismatch")
        if data[5] != self.CRC(data[3:5]):
            raise RuntimeError("Humidity CRC mismatch")
        return celsius, humidity
Exemplo n.º 27
0
    def __init__(self,
                 address=0x71,
                 brightness=BRIGHT_DEFAULT,
                 display_type=FOUR_TUBES):
        """
        Constructor

        Args:
            address: I2C address, default is 0x71
            brightness: Startup brightness, value between 0 and 15
            display_type: Display type, can be one of 0: FOUR_TUBES and 1: TWO_TUBES
        """
        self.address = address
        self.display_type = display_type
        self.font = display_font4 if display_type == FOUR_TUBES else display_font2
        self.first_dot = False
        self.second_dot = False

        self.bus = Bus()
        self.data = [0] * 4 if self.display_type == FOUR_TUBES else 2

        self.bus.write_i2c_block_data(self.address, REG_INIT, [])
        self.bus.write_i2c_block_data(self.address, DISP_ON, [])
        self.set_brightness(brightness)
def main():
    print(\
""" Make sure Grove-VOC-eCO2-Gas-Sensor(SGP30)
   inserted in one I2C slot of Grove-Base-Hat

Baseline operations reference:
   http://wiki.seeedstudio.com/Grove-VOC_and_eCO2_Gas_Sensor-SGP30/
""")

    # configuration
    baseline_conf = "/tmp/SGP30_baseline"
    # Baseline file used to store baseline compensation parameters.
    sgp = GroveVOC_eCO2GasSgp30(Bus(), baseline_filename=baseline_conf)

    sgp.i2c_geral_call()
    sgp.read_features()
    serial = sgp.read_serial()
    print("SGP30 SERIAL: {}".format(serial.raw))

    # sgp initialize
    sgp.init_sgp()

    # Load baseline if applicable
    t = file_get_modify_time(baseline_conf)
    if not t is None and time.time() - t < 7.0 * 24 * 3600:
        print("Try to set baseline: {}".format(sgp.try_set_baseline()))
    else:
        print("*** Baseline unexist or expired")

    print("First reading: ")
    print("  DATA = {}".format(sgp.read_measurements().data))
    print("SGP30 need at least 15 seconds to warm up")
    for i in range(20):
        time.sleep(1)
        print(".", end="", file=sys.stderr)
    print()

    print("Has to run for 12 hours to get really stable data/baseline")
    start = time.time()
    while time.time() - start <= 12.0 * 3600:
        reading = sgp.read_measurements()
        sgp30_data_display(reading, time.time() - start)
        time.sleep(0.5)

    print("\nBaseline stored")
    sgp.store_baseline()
Exemplo n.º 29
0
    def __init__(self, acc_addr = BMI088_ACCEL_I2C_ADDR, gyro_addr = BMI088_GYRO_I2C_ADDR):
        self._dev = _bmi.rpi_bmi088_alloc()
        dev_path = "/dev/i2c-{}".format(Bus().bus)
        accel_cfg = BMI08xCfg(BMI08X_ACCEL_PM_ACTIVE,
                              BMI088_ACCEL_RANGE_6G,
                              BMI08X_ACCEL_BW_NORMAL,
                              BMI08X_ACCEL_ODR_100_HZ)
        gyro_cfg = BMI08xCfg(BMI08X_GYRO_PM_NORMAL,
                              BMI08X_GYRO_RANGE_1000_DPS,
                              BMI08X_GYRO_BW_23_ODR_200_HZ,
                              BMI08X_GYRO_BW_23_ODR_200_HZ)

        _bmi.rpi_bmi088_init(self._dev,
                             dev_path,
                             acc_addr,
                             gyro_addr,
                             byref(accel_cfg),
                             byref(gyro_cfg))
Exemplo n.º 30
0
    def __init__(self, acc_addr = BMI088_ACCEL_I2C_ADDR, gyro_addr = BMI088_GYRO_I2C_ADDR):
        _bmi.rpi_bmi088_alloc.restype = c_char_p
        self._dev = _bmi.rpi_bmi088_alloc()
        dev_path = b"/dev/i2c-%d" %(Bus().bus)
        

        accel_cfg = BMI08xCfg(BMI08X_ACCEL_PM_ACTIVE,
                              BMI088_ACCEL_RANGE_6G,
                              BMI08X_ACCEL_BW_NORMAL,
                              BMI08X_ACCEL_ODR_100_HZ)
        gyro_cfg = BMI08xCfg(BMI08X_GYRO_PM_NORMAL,
                              BMI08X_GYRO_RANGE_1000_DPS,
                              BMI08X_GYRO_BW_23_ODR_200_HZ,
                              BMI08X_GYRO_BW_23_ODR_200_HZ)
        _bmi.rpi_bmi088_init.argtypes = [c_char_p,c_char_p,c_int,c_int,POINTER(BMI08xCfg),POINTER(BMI08xCfg)]
        _bmi.rpi_bmi088_init(self._dev,
                             dev_path,
                             acc_addr,
                             gyro_addr,
                             byref(accel_cfg),
                             byref(gyro_cfg))