示例#1
0
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
    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
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
    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
 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
 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
import Adafruit_GPIO.I2C as i2c

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