def __init__(self): import I2C #Adjust in order to made address change easier !!! self.i2cConnection = I2C.I2C(0x04) #Check if there is an Arduino if self.i2cConnection.testConnection() is False: print "Something found on I2C, but no Arduino with the good sketch" sys.exit(1)
def __init__(self, pi, bus, device): self.bus = bus self.pi = pi self.h = I2C.I2C(pi, bus, device) self.h.write_byte(self.__PWR_MGMT_1, 0x00) self.h.write_byte(self.__SMPLRT_DIV, 0x07) self.h.write_byte(self.__CONFIG, 0b01000000) self.h.write_byte(self.__GYRO_CONFIG, 0b00000000) # 250dps, self.h.write_byte(self.__ACCEL_CONFIG, 0b00000000) # 2g-scale #self.h.write_byte(self.__ACCEL_CONFIG2, 0b00000000) # low pass self.gyro = Gyro() self.accel = Accel() self.magn = Magn() self.temp = Temp() self.h.write_byte(0x37,0x02) # enable i2c master bypass self.h_magn = I2C.I2C(self.pi, self.bus, self.__MAGN_ADDR)
def __init__(self, accel_address = _ACCEL_ADDRESS, mag_address = _MAG_ADDRESS): self.accel = I2C.I2C(accel_address) self.mag = I2C.I2C(mag_address)
#!/usr/bin/env python3 # -*- coding: utf-8 -*- '''-----------------------------导入模块--------------------------------''' from LKIF_function import * from I2C import * import time from tkinter import * import tkinter.messagebox as messagebox laser=LKIF() i2c=I2C() class La_Mes(object): def __init__(self): self.TVIB=0 self.TVIB_reg=0 self.DIRECT_reg=0x00 self.RING_reg=0x02 self.LSC_reg=0x80 self.SAC2_reg=0x00#需先写Ring self.SAC3_reg=0x40#需先写Ring self.SAC4_reg=0x80#需先写Ring self.SAC5_reg=0xc0#需先写Ring self.i2c_clk=400 self.I2C_Open_Ok=0 def soft_PD(self):
def __init__(self, pi, bus, device): self.h = I2C.I2C(pi, bus, device) self.read_cal_data()
for i2c import I2C bus = I2C() print bus
def __init__(self, gyro_address=_GYRO_ADDRESS): self.gyro = I2C.I2C(gyro_address)