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


Python Arduino.readEEPROM方法代码示例

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


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

示例1: Uarm

# 需要导入模块: from pyfirmata import Arduino [as 别名]
# 或者: from pyfirmata.Arduino import readEEPROM [as 别名]

#.........这里部分代码省略.........
	def writeAngleRaw(self,servo_1,servo_2,servo_3,servo_4):
		
		self.servo_base.write(self.angleConstrain(servo_1))
		self.servo_left.write(self.angleConstrain(servo_2))
		self.servo_right.write(self.angleConstrain(servo_3))
		self.servo_end.write(self.angleConstrain(servo_4))
		

	def readAnalog(self,servo_number):
	
		if servo_number == 1:
			for i in range(1,4):
				data = self.uarm.readAnalogPin(2)
			return data
		elif servo_number == 2:
			for i in range(1,4):
				data = self.uarm.readAnalogPin(0)
			return data
		elif servo_number == 3:
			for i in range(1,4):
				data = self.uarm.readAnalogPin(1)
			return data
		elif servo_number == 4:
			for i in range(1,4):
				data = self.uarm.readAnalogPin(3)
			return data
		else:
			return
	

	def readServoOffset(self,servo_number):
		if servo_number ==1 or servo_number ==2 or servo_number ==3:
			addr = self.kAddrOffset + (servo_number - 1)*2
			servo_offset = (self.uarm.readEEPROM(addr+1))/10.00
			if(self.uarm.readEEPROM(addr) == 0):
				servo_offset *= -1
			return servo_offset
		elif servo_number == 4:
			return 0
		else:
			pass
	

	def readToAngle(self,input_analog,servo_number,tirgger):
		addr = self.kAddrAandB + (servo_number-1)*6

		data_a = (self.uarm.readEEPROM(addr+1)+ (self.uarm.readEEPROM(addr+2)*256))/10.0

		if (self.uarm.readEEPROM(addr) == 0):
			data_a = -data_a
		data_b = (self.uarm.readEEPROM(addr+4)+ (self.uarm.readEEPROM(addr+5)*256))/100.0
		
		if (self.uarm.readEEPROM(addr+3) == 0):
			data_b = -data_b
		
		if tirgger == 0 :
			return (data_a + data_b *input_analog) - self.readServoOffset(servo_number)
		elif tirgger == 1:
			return (data_a + data_b *input_analog)
		else:
			pass


	def fwdKine(self,theta_1,theta_2,theta_3):
		g_l3_1 = MATH_L3 * math.cos(theta_2/MATH_TRANS)
		g_l4_1 = MATH_L4 * math.cos(theta_3 / MATH_TRANS);
开发者ID:gx9702,项目名称:UArmForROS,代码行数:70,代码来源:uarm_python.py


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