當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。