コード例 #1
0
ファイル: ADS1015.py プロジェクト: shermanlam/RaspberryPiROS
def activate_ready():
	"""
	swaps the high and low threshold registers so that the conversion
	ready pin will be activated on the ADC
	"""
	high = I2C.reverseByteOrder(0x8000)
	low = I2C.reverseByteOrder(0x7fff)
	D.dut.write16(D.highThreshReg, high)
	D.dut.write16(D.lowThreshReg,low)
コード例 #2
0
 def _load_calibration(self):
     #load calibration
     self._device.write16(
         TMP007_CONFIG,
         I2C.reverseByteOrder(TMP007_CFG_MODEON | TMP007_CFG_ALERTEN
                              | TMP007_CFG_TRANSC | self._mode))
     #set alert status
     self._device.write16(
         TMP007_STATMASK,
         I2C.reverseByteOrder(TMP007_STAT_ALERTEN | TMP007_STAT_CRTEN))
コード例 #3
0
ファイル: HDC100x.py プロジェクト: scanner/HDC100X_Python
    def dry_sensor(self):
        """
        Cribbed from the Adafruit Arduino code. Guess it makes sure the
        sensor is ready for reading after normalizing in a room.
        """
        orig_config = self._device.readU16BE(HDC1000_CONFIG)

        # reset, heat up, and select 14 bit temp & humidity
        #
        new_config = I2C.reverseByteOrder(HDC1000_CONFIG_RST |
                                          HDC1000_CONFIG_HEAT |
                                          HDC1000_CONFIG_MODE |
                                          HDC1000_CONFIG_TRES_14 |
                                          HDC1000_CONFIG_HRES_14)
        self._device.write16(HDC1000_CONFIG, new_config)

        time.sleep(0.015)

        # Take 1000 readings and toss the results.
        #
        for i in range(1000):
            self._read32(HDC1000_TEMP)
            time.sleep(0.001)

        # Write our original config back out to the device.
        #
        self._device.write16(HDC1000_CONFIG, orig_config)
        time.sleep(0.015)
コード例 #4
0
ファイル: ADS1015.py プロジェクト: shermanlam/RaspberryPiROS
def write_config():
	"""
	Write the desired options to the ADC configuration register.
	Get data from global options
	"""
	global D
	
	# bit shift everything into its right place in the message. Check datasheet.
	# Some options were not broken out for changing. The "magic bits" are 
	# those options. Combine all the options through bit-wise OR
	newConfig = (	1 << 15		|	# OS - trigger conversion
			D.mux << 12	|	# MUX
			D.pga << 9	|	# PGA
			1 << 8		|	# MODE - singal shot
			D.dr << 5	|	# DR
			0 << 4		|	# COMP_MODE
			0 << 3 		|	# COMP_POL
			0 << 2		|	# COMP_LAT
			0 << 1 	)		# COMP_QUE
	
	# print "mux: ", bin(D.mux)
	# print "pga: ", bin(D.pga)
	# print "dr: ", bin(D.dr)

	# due to something with byte-writing order, we need to flip
	# the bytes before writing. I don't know the full details
	# print "config: %s"%bin(newConfig)
	# print "length: %d"%len(bin(newConfig))
	rev = I2C.reverseByteOrder(newConfig)
	# print "Reversed byte order: ", bin(rev)

	# write it!
	D.dut.write16(D.configReg,rev)	
コード例 #5
0
ファイル: ina219.py プロジェクト: crdietrich/pyINA219
    def set_config(self):
        """Set the 16 bit Big Endian INA219 configuration register (0x00)
        """

        reg_00 = self.reg_00
        if self.host_endian_is_little:
            reg_00 = I2C.reverseByteOrder(reg_00)
        self.device.write16(0x00, reg_00)
コード例 #6
0
ファイル: HDC100x.py プロジェクト: scanner/HDC100X_Python
 def reset(self):
     """
     reset, and select 14 bit temp & humidity
     """
     self._device.write16(HDC1000_CONFIG,
                          I2C.reverseByteOrder(HDC1000_CONFIG_RST |
                                               HDC1000_CONFIG_MODE |
                                               HDC1000_CONFIG_TRES_14 |
                                               HDC1000_CONFIG_HRES_14))
     time.sleep(0.015)
コード例 #7
0
ファイル: TMP007.py プロジェクト: THP-JOE/Python_TMP007
 def _load_calibration(self):
         #load calibration               
         self._device.write16(TMP007_CONFIG, I2C.reverseByteOrder(TMP007_CFG_MODEON | TMP007_CFG_ALERTEN | TMP007_CFG_TRANSC | self._mode))
         #set alert status
         self._device.write16(TMP007_STATMASK, I2C.reverseByteOrder(TMP007_STAT_ALERTEN |TMP007_STAT_CRTEN))
コード例 #8
0
ファイル: testImport.py プロジェクト: alberthli/ahrs
import Adafruit_GPIO.I2C as i2c

x = i2c.reverseByteOrder(1)
print(i2c.reverseByteOrder)
print(x)