本文整理汇总了Python中Phidgets.Devices.InterfaceKit.getSerialNum方法的典型用法代码示例。如果您正苦于以下问题:Python InterfaceKit.getSerialNum方法的具体用法?Python InterfaceKit.getSerialNum怎么用?Python InterfaceKit.getSerialNum使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phidgets.Devices.InterfaceKit
的用法示例。
在下文中一共展示了InterfaceKit.getSerialNum方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PhidgetTextLCD
# 需要导入模块: from Phidgets.Devices import InterfaceKit [as 别名]
# 或者: from Phidgets.Devices.InterfaceKit import getSerialNum [as 别名]
class PhidgetTextLCD(object):
"""
A class modelled after a Phidget InterfaceKit with an integrated LCD.
It contains a list of objects, which are subclasses of Sensor object.
Attributes:
analog_sensors: a list containing objects of one of subclasses of Sensor
data_dir: a string of directory path to save sensor reading data in
"""
def __init__(self, analog_sensors, data_dir):
"""Initializes the members."""
self.__interfaceKit = InterfaceKit()
self.__textLCD = TextLCD()
self.__data_dir = data_dir
# instantiate classes according to actual sensor port configuration
self.sensors = []
for sensor in analog_sensors:
a_sensor = self.__Factory(sensor)
self.sensors.append(a_sensor)
try:
# Interface Kit
self.__interfaceKit.openPhidget()
self.__interfaceKit.waitForAttach(10000)
print "%s (serial: %d) attached!" % (
self.__interfaceKit.getDeviceName(), self.__interfaceKit.getSerialNum())
# get initial value from each sensor
i = 0
for sensor in self.sensors:
#print sensor.product_name
#print sensor.value
sensor.value = self.__interfaceKit.getSensorValue(i)
i += 1
self.__interfaceKit.setOnSensorChangeHandler(self.__SensorChanged)
# Text LCD
self.__textLCD.openPhidget()
self.__textLCD.waitForAttach(10000)
print "%s attached!" % (self.__textLCD.getDeviceName())
self.__textLCD.setCursorBlink(False)
except PhidgetException, e:
print "Phidget Exception %i: %s" % (e.code, e.message)
sys.exit(1)
示例2: encoderPositionChangeHandler
# 需要导入模块: from Phidgets.Devices import InterfaceKit [as 别名]
# 或者: from Phidgets.Devices.InterfaceKit import getSerialNum [as 别名]
def encoderPositionChangeHandler(e):
global velocity
DEAD_ZONE = 1.0
factor = 0.5
velocity = factor*e.positionChange/e.time
print "velocity", velocity
if velocity < DEAD_ZONE:
velocity = 0
return 0
try:
interfaceKit.openPhidget()
interfaceKit.waitForAttach(10000)
print ("interfaceKit %d attached!" % (interfaceKit.getSerialNum()))
encoder.openPhidget()
encoder.waitForAttach(10000)
print ("encoder %d attached!" % (encoder.getSerialNum()))
interfaceKit.setOnSensorChangeHandler(interfaceKitSensorChanged)
interfaceKit.setOnInputChangeHandler(interfaceKitInputChanged)
encoder.setOnPositionChangeHandler(encoderPositionChangeHandler)
while True:
time.sleep(0.05)
liblo.send(target, "/steer", steer)
liblo.send(target, "/velocity", float(velocity))
示例3: message
# 需要导入模块: from Phidgets.Devices import InterfaceKit [as 别名]
# 或者: from Phidgets.Devices.InterfaceKit import getSerialNum [as 别名]
try:
try:
message( "Opening IR Device 121774")
ir.openPhidget(121774)
message( "Waiting for attachment...")
ir.waitForAttach(10000)
message("Device ready.")
ir.setOnAttachHandler(irAttached)
ir.setOnDetachHandler(irDetached)
ir.setOnErrorhandler(irError)
ir.setOnIRCodeHandler(irCodeRecv)
ir.setOnIRLearnHandler(irLearnRecv)
ir.setOnIRRawDataHandler(irRawDataRecv)
try:
message("Device ready and waiting...")
while True:
pass
except KeyboardInterrupt as e:
message("Exiting")
except PhidgetException as e:
message("Phidget Exception %i: %s" % (e.code, e.details))
message("Exiting....")
finally:
if ir:
message ("Closing %d" % (interfaceKit.getSerialNum()))
interfaceKit.closePhidget()