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


Python i2c.writing_bytes函数代码示例

本文整理汇总了Python中quick2wire.i2c.writing_bytes函数的典型用法代码示例。如果您正苦于以下问题:Python writing_bytes函数的具体用法?Python writing_bytes怎么用?Python writing_bytes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: getFullLuminosity

    def getFullLuminosity(self):
        self.enable()
        self.wait()
        
        with i2c.I2CMaster(self.i2cbus) as bus:    
            read_results = bus.transaction(
                i2c.writing_bytes(address, self.COMMAND_BIT | self.WORD_BIT | self.REGISTER_CHAN1_LOW ),
                i2c.reading(address, 2),
                i2c.writing_bytes(address, self.COMMAND_BIT | self.WORD_BIT | self.REGISTER_CHAN0_LOW ),
                i2c.reading(address, 2)        
            )
       
        self.disable()  

        full = read_results[0][1]
#        print("---- full: %#08x" % full)
        full = full << 8
        full += read_results[0][0]
#        print("---- full: %#08x" % full)
        full = full << 8    
        full += read_results[1][1]
#        print("---- full: %#08x" % full)
        full = full << 8
        full += read_results[1][0]
#        print("---- full: %#08x" % full)

        return full
开发者ID:cznewt,项目名称:TSL2561,代码行数:27,代码来源:TSL2561.py

示例2: initSensor

 def initSensor(self):
     """ initalizes the first channel if the MAX1164 device in single
     endded mode with vdd as ref
     """
     with i2c.I2CMaster(1) as bus:
         bus.transaction(i2c.writing_bytes(self.address, 0x8a ))
         bus.transaction(i2c.writing_bytes(self.address, 0x01 ))    
开发者ID:Roboteurs,项目名称:slushengine,代码行数:7,代码来源:Temprature.py

示例3: getDate

	def getDate():
		# get date and return value
		
		#get day
		day, day2 = bus.transaction(
			i2c.writing_bytes(rtc_address1, 0x05),
			i2c.reading(rtc_address1,2))[0]
		timeday1 = ((day >> 4) & 0x03)
		timeday2 = (day & 0x0F)
		
		#get month
		month, month2 = bus.transaction(
			i2c.writing_bytes(rtc_address1, 0x07),
			i2c.reading(rtc_address1,2))[0]
		timemonth1 = ((month >> 4) & 0x01)
		timemonth2 = (month & 0x0F)
		
		#get year
		year, year2 = bus.transaction(
			i2c.writing_bytes(rtc_address1, 0x08),
			i2c.reading(rtc_address1,2))[0]
		timeyear1 = ((year >> 4))
		timeyear2 = (year & 0x0F)

		return str(timeday1) + str(timeday2) + "/" + str(timemonth1) + str(timemonth2) + "/" + str(timeyear1) + str(timeyear2)
开发者ID:abelectronicsuk,项目名称:AlarmPi,代码行数:25,代码来源:wakeup.py

示例4: readAlarmTime

	def readAlarmTime(month, year):

		#---------
		# minute
		#--------
		minute, minute2 = bus.transaction(      i2c.writing_bytes(rtc_address1, 0x09),
							i2c.reading(rtc_address1,2))[0]

		timeminute1 = ((minute >> 4) & 0x07)
		timeminute2 = (minute & 0x0F)

		#------
		# hour
		#------
		hour, hour2 = bus.transaction(	i2c.writing_bytes(rtc_address1, 0x0A),
						i2c.reading(rtc_address1,2))[0]

		timehour1 = ((hour >> 4) & 0x03)
		timehour2 = (hour & 0x0F)

		#------
		# Day
		#-----
		day, day2 = bus.transaction(	i2c.writing_bytes(rtc_address1, 0x0B),
						i2c.reading(rtc_address1,2))[0]

		timeday1 = ((day >> 4) & 0x05)
		timeday2 = (day & 0x0F)

		alminute        = int(str(timeminute1)+str(timeminute2))
		alhour          = int(str(timehour1)+str(timehour2))
		alday           = int(str(timeday1)+str(timeday2))
		weekday,dayname = weekDay(year,month,alday)

		return alminute, alhour, alday, weekday, dayname
开发者ID:argn,项目名称:AlarmPi,代码行数:35,代码来源:setalarm.py

示例5: set_IO_DIR

def set_IO_DIR(port_expand_addr, port, value):
	with q2w_i2c.I2CMaster() as bus:
		if port == 'A':			
			bus.transaction(
			q2w_i2c.writing_bytes(port_expand_addr, IODIRA, value))
		elif port == 'B':
			bus.transaction(
			q2w_i2c.writing_bytes(port_expand_addr, IODIRB, value))
开发者ID:TwitALU,项目名称:Twitalu,代码行数:8,代码来源:twitalu_I2C.py

示例6: write_data

def write_data(port_expand_addr, port, value):
	with q2w_i2c.I2CMaster() as bus:
		if port == 'A':			
			bus.transaction(
			q2w_i2c.writing_bytes(port_expand_addr, GPIOA, value))
		elif port == 'B':
			bus.transaction(
			q2w_i2c.writing_bytes(port_expand_addr, GPIOB, value))
开发者ID:TwitALU,项目名称:Twitalu,代码行数:8,代码来源:twitalu_I2C.py

示例7: readSensor

	def readSensor() :

		bus.transaction(i2c.writing_bytes(ADDR, 0x22, 0x20))
		time.sleep(0.05)
		readout = bus.transaction(i2c.writing_bytes(ADDR, 0xE0, 0x00), i2c.reading(ADDR, 6))
		time.sleep(1.0)

		return readout
开发者ID:rainerraul,项目名称:pi-weather,代码行数:8,代码来源:sht31.py

示例8: set_IO_PULL_UP

def set_IO_PULL_UP(port_expand_addr, port, value):
	with q2w_i2c.I2CMaster() as bus:
		if port == 'A':			
			bus.transaction(
			q2w_i2c.writing_bytes(port_expand_addr, GPPUA, value))
		elif port == 'B':
			bus.transaction(
			q2w_i2c.writing_bytes(port_expand_addr, GPPUB, value))
开发者ID:TwitALU,项目名称:Twitalu,代码行数:8,代码来源:twitalu_I2C.py

示例9: read_data

def read_data(port_expand_addr, port):
	with q2w_i2c.I2CMaster() as bus:
		if port == 'A':
			return bus.transaction(
			q2w_i2c.writing_bytes(port_expand_addr, GPIOA),
			q2w_i2c.reading(port_expand_addr, 1))[0][0]
		elif port == 'B':
			return bus.transaction(
			q2w_i2c.writing_bytes(port_expand_addr, GPIOB),
			q2w_i2c.reading(port_expand_addr, 1))[0][0]
开发者ID:TwitALU,项目名称:Twitalu,代码行数:10,代码来源:twitalu_I2C.py

示例10: write_cgchar

 def write_cgchar(self, pos, data):
     cgaddr = pos & 0x07
     cgaddr = (cgaddr << 3) | 0x40
     time.sleep(0.1)
     self.bus.transaction(i2c.writing_bytes(self.address, 0x00, 0x38)) # Function Set, 8bit, 2lines, NoDoubleHeight, InstructionTable=0
     time.sleep(0.1)
     self.bus.transaction(i2c.writing_bytes(self.address, 0x00, cgaddr)) # select CGRAM address
     time.sleep(0.1)
     for datum in data:
         self.bus.transaction(i2c.writing_bytes(self.address, 0x40, datum)) # Write data, byte by byte (normally 8)
     self.bus.transaction(i2c.writing_bytes(self.address, 0x00, 0x80)) # return to DDRAM
开发者ID:mtedaldi,项目名称:PyFanControl,代码行数:11,代码来源:i2c_display.py

示例11: write

 def write(self, register, value):
   log.debug("Writing to address {0:#4X} register 0x{1:#4X} value {2:#10b}".format(self.ADDRESS, register, value))
   if self.TOGGLE_MODE:
     a = value & 0b11111111
     b = (value >> 8) & 0b11111111
     BUS.transaction(
       i2c.writing_bytes(self.ADDRESS, register, a, b),
     )
   else:
     BUS.transaction(
       i2c.writing_bytes(self.ADDRESS, register ,value),
     )
开发者ID:computerlyrik,项目名称:MCP23017-RPi-python,代码行数:12,代码来源:MCP23017.py

示例12: bank_mode

 def bank_mode(self, bank):
   self.BANK = bank
   log.info("Bank set to {0:d}".format(bank))
   #EVERYTHING else goes to zero - some magic to write bit on both settings
   if self.BANK == 1: #assume has been bank=0 before
     BUS.transaction( 
       i2c.writing_bytes(self.ADDRESS,0x15, IOCON['BANK']),
       i2c.writing_bytes(self.ADDRESS,0x0A, IOCON['BANK']))
   elif self.BANK == 0:
     BUS.transaction( 
       i2c.writing_bytes(self.ADDRESS,0x15, 0 ),
       i2c.writing_bytes(self.ADDRESS,0x0A, 0 ))
开发者ID:computerlyrik,项目名称:MCP23017-RPi-python,代码行数:12,代码来源:MCP23017.py

示例13: resetAlarm

	def resetAlarm():

		#-----------------------
		# Clear status register
		#-----------------------
		bus.transaction(i2c.writing_bytes(rtc_address1, 0x01, 0x00))

		#-----------------------
		# Clear alarm registers
		#-----------------------
		bus.transaction(i2c.writing_bytes(rtc_address1, 0x09, 0x00))
		bus.transaction(i2c.writing_bytes(rtc_address1, 0x0A, 0x00))
		bus.transaction(i2c.writing_bytes(rtc_address1, 0x0B, 0x00))
		bus.transaction(i2c.writing_bytes(rtc_address1, 0x0C, 0x00))
开发者ID:argn,项目名称:AlarmPi,代码行数:14,代码来源:setalarm.py

示例14: __readADC

 def __readADC(self):
     command = 0x00
     #Read D1
     self.bus.transaction(i2c.writing_bytes(self.address, 0x48))
     time.sleep(0.01)
     values = self.bus.transaction(i2c.writing_bytes(self.address, command), i2c.reading(self.address, 3))
     self.D[1] = (values[0][0] << 16) | (values[0][1] << 8) | (values[0][2])
     self.logger.debug("CMD(" + "{0:#04x}".format(command) + ") -> D1 = " + str(self.D[1])) 
     # Read D2
     self.bus.transaction(i2c.writing_bytes(self.address, 0x58))
     time.sleep(0.01)
     values = self.bus.transaction(i2c.writing_bytes(self.address, command), i2c.reading(self.address, 3))
     self.D[2] = (values[0][0] << 16) | (values[0][1] << 8) | (values[0][2])
     self.logger.debug("CMD(" + "{0:#04x}".format(command) + ") -> D2 = " + str(self.D[2])) 
开发者ID:mrmarkgray,项目名称:haldane,代码行数:14,代码来源:sensor.py

示例15: getadcreading

	def getadcreading(address, channel, gain, res):
		channel = channel - 1
		adcConfig = MCP342X_START | MCP342X_CHANNEL_1 | MCP342X_CONTINUOUS
		adcConfig |= channel << 5 | res << 2 | gain
		#print("adcConfig")
		#print(adcConfig)
		
		varDivisior = 1 << (gain + 2*res)
		
		bus.transaction(i2c.writing_bytes(address, adcConfig))
		
		
		time.sleep(0.05)
		if (res ==3):
			h, m, l ,s = bus.transaction(i2c.reading(address,4))[0]
			time.sleep(0.05)
			h, m, l, s  = bus.transaction(i2c.reading(address,4))[0]
		

			t = ((h & 0b00000001) << 16) | (m << 8) | l
		else:
			h, m, l = bus.transaction(i2c.reading(address,3))[0]
			time.sleep(0.05)
			h, m, l  = bus.transaction(i2c.reading(address,3))[0]
			t = (h << 8) | m	
		if (h > 128):
			t = ~(0x020000 - t)

		# remove / 1000 to return value in milivolts
		return ((t/varDivisior) * 2.4705882) / 1000
开发者ID:sonite,项目名称:abelectronics,代码行数:30,代码来源:adcpiv2.py


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