当前位置: 首页>>代码示例>>Python>>正文


Python Adafruit_I2C.Adafruit_I2C方法代码示例

本文整理汇总了Python中Adafruit_I2C.Adafruit_I2C方法的典型用法代码示例。如果您正苦于以下问题:Python Adafruit_I2C.Adafruit_I2C方法的具体用法?Python Adafruit_I2C.Adafruit_I2C怎么用?Python Adafruit_I2C.Adafruit_I2C使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Adafruit_I2C的用法示例。


在下文中一共展示了Adafruit_I2C.Adafruit_I2C方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import Adafruit_I2C [as 别名]
# 或者: from Adafruit_I2C import Adafruit_I2C [as 别名]
def __init__(self, address=0x48, ic=__IC_ADS1015, debug=False):
    # Depending on if you have an old or a new Raspberry Pi, you
    # may need to change the I2C bus.  Older Pis use SMBus 0,
    # whereas new Pis use SMBus 1.  If you see an error like:
    # 'Error accessing 0x48: Check your I2C address '
    # change the SMBus number in the initializer below!
    self.i2c = Adafruit_I2C(address)
    self.address = address
    self.debug = debug

    # Make sure the IC specified is valid
    if ((ic < self.__IC_ADS1015) | (ic > self.__IC_ADS1115)):
      if (self.debug):
        print "ADS1x15: Invalid IC specfied: %h" % ic
      return -1
    else:
      self.ic = ic
        
    # Set pga value, so that getLastConversionResult() can use it,
    # any function that accepts a pga value must update this.
    self.pga = 6144 
开发者ID:timwaizenegger,项目名称:raspberrypi-examples,代码行数:23,代码来源:Adafruit_ADS1x15.py

示例2: __init__

# 需要导入模块: import Adafruit_I2C [as 别名]
# 或者: from Adafruit_I2C import Adafruit_I2C [as 别名]
def __init__(self, busnum=-1, debug=False, hires=False):

        # Accelerometer and magnetometer are at different I2C
        # addresses, so invoke a separate I2C instance for each
        self.accel = Adafruit_I2C(self.LSM303_ADDRESS_ACCEL, busnum, debug)
        self.mag   = Adafruit_I2C(self.LSM303_ADDRESS_MAG  , busnum, debug)

        # Enable the accelerometer
        self.accel.write8(self.LSM303_REGISTER_ACCEL_CTRL_REG1_A, 0x27)
        # Select hi-res (12-bit) or low-res (10-bit) output mode.
        # Low-res mode uses less power and sustains a higher update rate,
        # output is padded to compatible 12-bit units.
        if hires:
            self.accel.write8(self.LSM303_REGISTER_ACCEL_CTRL_REG4_A,
              0b00001000)
        else:
            self.accel.write8(self.LSM303_REGISTER_ACCEL_CTRL_REG4_A, 0)
  
        # Enable the magnetometer
        self.mag.write8(self.LSM303_REGISTER_MAG_MR_REG_M, 0x00)


    # Interpret signed 12-bit acceleration component from list 
开发者ID:jeonghoonkang,项目名称:BerePi,代码行数:25,代码来源:LSM303.py

示例3: __init__

# 需要导入模块: import Adafruit_I2C [as 别名]
# 或者: from Adafruit_I2C import Adafruit_I2C [as 别名]
def __init__(self, address=0x40, debug=False):
    self.i2c = Adafruit_I2C(address)
    self.i2c.debug = debug
    self.address = address
    self.debug = debug
    if (self.debug):
      print "Reseting PCA9685 MODE1 (without SLEEP) and MODE2"
    self.setAllPWM(0, 0)
    self.i2c.write8(self.__MODE2, self.__OUTDRV)
    self.i2c.write8(self.__MODE1, self.__ALLCALL)
    time.sleep(0.005)                                       # wait for oscillator
    
    mode1 = self.i2c.readU8(self.__MODE1)
    mode1 = mode1 & ~self.__SLEEP                 # wake up (reset sleep)
    self.i2c.write8(self.__MODE1, mode1)
    time.sleep(0.005)                             # wait for oscillator 
开发者ID:robotstreamer,项目名称:robotstreamer,代码行数:18,代码来源:Adafruit_PWM_Servo_Driver.py

示例4: __init__

# 需要导入模块: import Adafruit_I2C [as 别名]
# 或者: from Adafruit_I2C import Adafruit_I2C [as 别名]
def __init__(self, address=0x70, debug=False):
    self.i2c = Adafruit_I2C(address)
    self.address = address
    self.debug = debug

    # Turn the oscillator on
    self.i2c.write8(self.__HT16K33_REGISTER_SYSTEM_SETUP | 0x01, 0x00)

    # Turn blink off
    self.setBlinkRate(self.__HT16K33_BLINKRATE_OFF)

    # Set maximum brightness
    self.setBrightness(15)

    # Clear the screen
    self.clear() 
开发者ID:simonmonk,项目名称:pi_magazine,代码行数:18,代码来源:Adafruit_LEDBackpack.py

示例5: calculateFrequency

# 需要导入模块: import Adafruit_I2C [as 别名]
# 或者: from Adafruit_I2C import Adafruit_I2C [as 别名]
def calculateFrequency():
 """calculate the station frequency based upon the upper and lower bits read from the device"""
#bus = smbus.SMBus (0) # RASP older version (256MB) 
 repeat = 0
 f =0.0
 with i2clib.I2CMaster() as b:
  results = b.transaction(
   reading(add, 5)
  )

 uF = results[0][0]&0x3F
 lF = results[0][1]
 # this is probably not the best way of doing this but I was having issues with the
 #       frequency being off by as much as 1.5 MHz
 current_freq = round((float(round(int(((int(uF)<<8)+int(lF))*cof/4-22500)/100000)/10)-.2)*10)/10
 return current_freq




#import pigpio

#i2c = smbus.SMBus(1) # newer version RASP (512 megabytes) 
#bus = smbus.SMBus (0) # RASP older version (256MB) 

#af = Adafruit_I2C(0x60, 1, True)
#pipi = pigpio.pi() 
开发者ID:LinuxCircle,项目名称:tea5767,代码行数:29,代码来源:radio-smbus-tea5767.py

示例6: __init__

# 需要导入模块: import Adafruit_I2C [as 别名]
# 或者: from Adafruit_I2C import Adafruit_I2C [as 别名]
def __init__(self, address=0x40, debug=False):
    self.i2c = Adafruit_I2C(address)
    self.address = address
    self.debug = debug
    if (self.debug):
      print "Reseting PCA9685"
    self.i2c.write8(self.__MODE1, 0x00) 
开发者ID:RorschachUK,项目名称:meArmPi,代码行数:9,代码来源:Adafruit_PWM_Servo_Driver.py

示例7: begin

# 需要导入模块: import Adafruit_I2C [as 别名]
# 或者: from Adafruit_I2C import Adafruit_I2C [as 别名]
def begin(self, addr = 0x70, bus = -1):
		"""Initialize the Trellis at the provided I2C address and bus number."""
		self._i2c = Adafruit_I2C.Adafruit_I2C(addr, bus)
		self._i2c.writeList(0x21, []) # Turn on the oscillator.
		self.blinkRate(HT16K33_BLINK_OFF)
		self.setBrightness(15) # Max brightness.
		self._i2c.writeList(0xA1, []) # Turn on interrupt, active high. 
开发者ID:tdicola,项目名称:Adafruit_Trellis_Python,代码行数:9,代码来源:Adafruit_Trellis.py

示例8: __init__

# 需要导入模块: import Adafruit_I2C [as 别名]
# 或者: from Adafruit_I2C import Adafruit_I2C [as 别名]
def __init__(self, address=0x39, debug=0, pause=0.8):
        self.i2c = Adafruit_I2C(address)
        self.address = address
        self.pause = pause
        self.debug = debug
        self.gain = 0 # no gain preselected
        self.i2c.write8(0x80, 0x03)     # enable the device 
开发者ID:JeremyMorgan,项目名称:Raspberry_Pi_Weather_Station,代码行数:9,代码来源:luxreader.py


注:本文中的Adafruit_I2C.Adafruit_I2C方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。