def __init__(self): print("INIT: LCD") try: self.textLCD = TextLCD() except RuntimeError as e: print("RuntimeExceotion: %s" % e.details) print("Exiting....") exit(1) try: self.textLCD.setOnAttachHandler(TextLCDAttached) self.textLCD.setOnDetachHandler(TextLCDDetached) self.textLCD.setOnErrorhandler(TextLCDError) except PhidgetException as e: print("Phidget Exception %i: %s" % (e.code, e.details)) print("Exiting....") exit(1) try: self.textLCD.openPhidget() except PhidgetException as e: print("Phidget Exception %i: %s" % (e.code, e.details)) print("Exiting....") exit(1) sleep(2) return
def __init__(self, serialNumber=None, waitForAttach=1000, **kargs): self.textLCD = TextLCD() if 'remoteHost' in kargs: self.textLCD.openRemote(kargs['remoteHost'], serialNumber) else: self.textLCD.openPhidget(serialNumber) h = [ 'onAttachHandler', 'onDetachHandler', 'onErrorhandler' ] for event in h: self.__dict__[event] = None if event in kargs: self.__dict__[event] = kargs[event] self.textLCD.setOnAttachHandler(self.attached) self.textLCD.setOnDetachHandler(self.detached) if waitForAttach > 0: try: self.textLCD.waitForAttach(waitForAttach) except PhidgetException as e: #print("Phidget Exception %i: %s" % (e.code, e.details)) try: self.textLCD.closePhidget() except PhidgetException as e2: pass raise e
__date__ = '10 August 2013' from ctypes import * import sys from time import sleep import zmq #Phidget specific imports from Phidgets.Phidget import PhidgetID from Phidgets.PhidgetException import PhidgetErrorCodes, PhidgetException from Phidgets.Events.Events import AttachEventArgs, DetachEventArgs, ErrorEventArgs from Phidgets.Devices.TextLCD import TextLCD, TextLCD_ScreenSize #Create an TextLCD object try: textLCD = TextLCD() except RuntimeError as e: print("Runtime Exception: %s" % e.details) print("Exiting....") exit(1) def TextLCDError(e): try: source = e.device print("TextLCD %i: Phidget Error %i: %s" % (source.getSerialNum(), e.eCode, e.description)) except PhidgetException as e: print("Phidget Exception %i: %s" % (e.code, e.details)) #Connect the event handlers try:
__author__ = 'Adam Stelmack' __version__ = '2.1.4' __date__ = 'May 02 2008' #Basic imports from ctypes import * import sys from time import sleep #Phidget specific imports from Phidgets.PhidgetException import * from Phidgets.Events.Events import * from Phidgets.Devices.TextLCD import TextLCD #Create an TextLCD object textLCD = TextLCD() #Information Display Function def DisplayDeviceInfo(): try: isAttached = textLCD.isAttached() type = textLCD.getDeviceType() serialNo = textLCD.getSerialNum() version = textLCD.getDeviceVersion() rowCount = textLCD.getRowCount() columnCount = textLCD.getColumnCount() except PhidgetException, e: print "Phidget Exception %i: %s" % (e.code, e.message) return 1 print "|------------|----------------------------------|--------------|------------|" print "|- Attached -|- Type -|- Serial No. -|- Version -|"
def AttachTextLCD(databasepath, serialNumber): def onAttachHandler(event): logString = "TextLCD Attached " + str(event.device.getSerialNum()) #print(logString) DisplayAttachedDeviceInfo(event.device) def onDetachHandler(event): logString = "TextLCD Detached " + str(event.device.getSerialNum()) #print(logString) DisplayDetachedDeviceInfo(event.device) event.device.closePhidget() def onErrorHandler(event): logString = "TextLCD Error " + str( event.device.getSerialNum()) + ", Error: " + event.description print(logString) DisplayErrorDeviceInfo(event) def onServerConnectHandler(event): logString = "TextLCD Server Connect " + str( event.device.getSerialNum()) #print(logString) def onServerDisconnectHandler(event): logString = "TextLCD Server Disconnect " + str( event.device.getSerialNum()) #print(logString) try: p = TextLCD() p.setOnAttachHandler(onAttachHandler) p.setOnDetachHandler(onDetachHandler) p.setOnErrorhandler(onErrorHandler) p.setOnServerConnectHandler(onServerConnectHandler) p.setOnServerDisconnectHandler(onServerDisconnectHandler) p.openPhidget(serialNumber) except PhidgetException as e: print("Phidget Exception %i: %s" % (e.code, e.details)) print("Exiting...") exit(1)
__date__ = 'May 17 2010' #Basic imports from ctypes import * import sys from time import sleep #Phidget specific imports from Phidgets.Phidget import PhidgetID from Phidgets.PhidgetException import PhidgetErrorCodes, PhidgetException from Phidgets.Events.Events import AttachEventArgs, DetachEventArgs, ErrorEventArgs from Phidgets.Devices.TextLCD import TextLCD, TextLCD_ScreenSize from Phidgets.Phidget import PhidgetLogLevel #Create an TextLCD object try: textLCD = TextLCD() except RuntimeError as e: print("Runtime Exception: %s" % e.details) print("Exiting....") exit(1) #Information Display Function def DisplayDeviceInfo(): try: isAttached = textLCD.isAttached() name = textLCD.getDeviceName() serialNo = textLCD.getSerialNum() version = textLCD.getDeviceVersion() rowCount = textLCD.getRowCount() columnCount = textLCD.getColumnCount()
class csss_lcd: str_top = "" str_bottom = "" top_len = 0 bot_len = 0 textLCD = None def __init__(self): print("INIT: LCD") try: self.textLCD = TextLCD() except RuntimeError as e: print("RuntimeExceotion: %s" % e.details) print("Exiting....") exit(1) try: self.textLCD.setOnAttachHandler(TextLCDAttached) self.textLCD.setOnDetachHandler(TextLCDDetached) self.textLCD.setOnErrorhandler(TextLCDError) except PhidgetException as e: print("Phidget Exception %i: %s" % (e.code, e.details)) print("Exiting....") exit(1) try: self.textLCD.openPhidget() except PhidgetException as e: print("Phidget Exception %i: %s" % (e.code, e.details)) print("Exiting....") exit(1) sleep(2) return #Information Display Function def display(self, row, str): print("Displaying %s" % str) if len(str) > 20: self.scroll(row, str) try: if self.textLCD.getDeviceID()==PhidgetID.PHIDID_TEXTLCD_ADAPTER: self.textLCD.setScreenIndex(0) self.textLCD.setScreenSize(TextLCD_ScreenSize.PHIDGET_TEXTLCD_SCREEN_2x8) self.textLCD.setDisplayString(row, str)#bytes(str, 'utf-8')) except PhidgetException as e: print("Phidget Exception %i: %s" % (e.code, e.details)) def displaySlow(self, row,str): self.display(row, str) sleep(0.75) def scroll(self, row, str): length = len(str) currIndex = 0 endIndex = 20 self.displaySlow(row, str[currIndex:endIndex]) for currIndex in range (1,length): self.display(row,str[currIndex:endIndex]) if endIndex < length: endIndex += 1 sleep(0.22) self.clearRow(row) def clearRow(self, row): print("Clearing TextLCD") self.display(row, " ") def clearAll(self): self.clearRow(0) self.clearRow(1) def close(self): try: print("Closing TextLCD") self.textLCD.closePhidget() except PhidgetException as e: print("Phidget Exception &i: %s" % (e.code, e.details)) print("Exiting....") exit(1)
# for twitter import tweetstream import json import urllib2 import re USER= "******" PASSWORD = "******" SEARCHTERM = "royalwedding" stream = tweetstream.TweetStream(USER, PASSWORD) #Create an TextLCD object try: textLCD = TextLCD() except RuntimeError as e: print("Runtime Exception: %s" % e.details) print("Exiting....") exit(1) #Information Display Function def DisplayDeviceInfo(): try: isAttached = textLCD.isAttached() name = textLCD.getDeviceName() serialNo = textLCD.getSerialNum() version = textLCD.getDeviceVersion() rowCount = textLCD.getRowCount() columnCount = textLCD.getColumnCount() except PhidgetException as e:
__author__ = 'Adam Stelmack' __version__ = '2.1.4' __date__ = 'May 02 2008' #Basic imports from ctypes import * import sys from time import sleep #Phidget specific imports from Phidgets.PhidgetException import * from Phidgets.Events.Events import * from Phidgets.Devices.TextLCD import TextLCD #Create an TextLCD object textLCD = TextLCD() #Information Display Function def DisplayDeviceInfo(): try: isAttached = textLCD.isAttached() type = textLCD.getDeviceType() serialNo = textLCD.getSerialNum() version = textLCD.getDeviceVersion() rowCount = textLCD.getRowCount() columnCount = textLCD.getColumnCount() except PhidgetException, e: print "Phidget Exception %i: %s" % (e.code, e.message) return 1 print "|------------|----------------------------------|--------------|------------|"
def AttachTextLCD(databasepath, serialNumber): def onAttachHandler(event): logString = "TextLCD Attached " + str(event.device.getSerialNum()) #print(logString) DisplayAttachedDeviceInfo(event.device) def onDetachHandler(event): logString = "TextLCD Detached " + str(event.device.getSerialNum()) #print(logString) DisplayDetachedDeviceInfo(event.device) event.device.closePhidget() def onErrorHandler(event): logString = "TextLCD Error " + str(event.device.getSerialNum()) + ", Error: " + event.description print(logString) DisplayErrorDeviceInfo(event) def onServerConnectHandler(event): logString = "TextLCD Server Connect " + str(event.device.getSerialNum()) #print(logString) def onServerDisconnectHandler(event): logString = "TextLCD Server Disconnect " + str(event.device.getSerialNum()) #print(logString) try: p = TextLCD() p.setOnAttachHandler(onAttachHandler) p.setOnDetachHandler(onDetachHandler) p.setOnErrorhandler(onErrorHandler) p.setOnServerConnectHandler(onServerConnectHandler) p.setOnServerDisconnectHandler(onServerDisconnectHandler) p.openPhidget(serialNumber) except PhidgetException as e: print("Phidget Exception %i: %s" % (e.code, e.details)) print("Exiting...") exit(1)
from ctypes import * import sys from time import sleep import zmq #Phidget specific imports from Phidgets.Phidget import PhidgetID from Phidgets.PhidgetException import PhidgetErrorCodes, PhidgetException from Phidgets.Events.Events import AttachEventArgs, DetachEventArgs, ErrorEventArgs from Phidgets.Devices.TextLCD import TextLCD, TextLCD_ScreenSize #from Phidgets.Devices.InterfaceKit import InterfaceKit #Create an TextLCD object try: textLCD = TextLCD() except RuntimeError as e: print("Runtime Exception: %s" % e.details) print("Exiting....") exit(1) #try: # interfaceKitLCD = InterfaceKit() #except RuntimeError as e: # print("Runtime Exception: %s" % e.details) # print("Exiting....") # exit(1) def TextLCDError(e): try: source = e.device
from ctypes import * import sys from time import sleep import zmq #Phidget specific imports from Phidgets.Phidget import PhidgetID from Phidgets.PhidgetException import PhidgetErrorCodes, PhidgetException from Phidgets.Events.Events import AttachEventArgs, DetachEventArgs, ErrorEventArgs from Phidgets.Devices.TextLCD import TextLCD, TextLCD_ScreenSize #from Phidgets.Devices.InterfaceKit import InterfaceKit #Create an TextLCD object try: textLCD = TextLCD() except RuntimeError as e: print("Runtime Exception: %s" % e.details) print("Exiting....") exit(1) #try: # interfaceKitLCD = InterfaceKit() #except RuntimeError as e: # print("Runtime Exception: %s" % e.details) # print("Exiting....") # exit(1) def TextLCDError(e): try:
from Phidgets.Devices.AdvancedServo import AdvancedServo from Phidgets.Devices.Servo import ServoTypes from Phidgets.PhidgetException import PhidgetException from Phidgets.Devices.GPS import GPS #Create an interfacekit object try: interfaceKit = InterfaceKit() except RuntimeError as e: print("Runtime Exception: %s" % e.details) print("Exiting....") exit(1) #Create an TextLCD object try: textLCD = TextLCD() except RuntimeError as e: print("Runtime Exception: %s" % e.details) print("Exiting....") exit(1) #Information Display Function #IFkit8/8/8 def displayDeviceInfo(): print( "|------------|----------------------------------|--------------|------------|" ) print( "|- Attached -|- Type -|- Serial No. -|- Version -|" ) print(
__author__ = 'Cameron Rodda' __version__ = '0.0.1' __date__ = '30 July 2013' from ctypes import * import sys from time import sleep #Phidget specific imports from Phidgets.Phidget import PhidgetID from Phidgets.PhidgetException import PhidgetErrorCodes, PhidgetException from Phidgets.Events.Events import AttachEventArgs, DetachEventArgs, ErrorEventArgs from Phidgets.Devices.TextLCD import TextLCD, TextLCD_ScreenSize #Create an TextLCD object try: textLCD = TextLCD() except RuntimeError as e: print("Runtime Exception: %s" % e.details) print("Exiting....") exit(1) def TextLCDError(e): try: source = e.device print("TextLCD %i: Phidget Error %i: %s" % (source.getSerialNum(), e.eCode, e.description)) except PhidgetException as e: print("Phidget Exception %i: %s" % (e.code, e.details)) #Connect the event handlers try:
__version__ = '2.1.8' __date__ = 'May 17 2010' #Basic imports from ctypes import * import sys from time import sleep #Phidget specific imports from Phidgets.Phidget import PhidgetID from Phidgets.PhidgetException import PhidgetErrorCodes, PhidgetException from Phidgets.Events.Events import AttachEventArgs, DetachEventArgs, ErrorEventArgs from Phidgets.Devices.TextLCD import TextLCD, TextLCD_ScreenSize #Create an TextLCD object try: textLCD = TextLCD() except RuntimeError as e: print("Runtime Exception: %s" % e.details) print("Exiting....") exit(1) #Information Display Function def DisplayDeviceInfo(): try: isAttached = textLCD.isAttached() name = textLCD.getDeviceName() serialNo = textLCD.getSerialNum() version = textLCD.getDeviceVersion() rowCount = textLCD.getRowCount() columnCount = textLCD.getColumnCount() except PhidgetException as e:
__author__ = 'Cameron Rodda' __version__ = '0.0.1' __date__ = '30 July 2013' from ctypes import * import sys from time import sleep #Phidget specific imports from Phidgets.Phidget import PhidgetID from Phidgets.PhidgetException import PhidgetErrorCodes, PhidgetException from Phidgets.Events.Events import AttachEventArgs, DetachEventArgs, ErrorEventArgs from Phidgets.Devices.TextLCD import TextLCD, TextLCD_ScreenSize #Create an TextLCD object try: textLCD = TextLCD() except RuntimeError as e: print("Runtime Exception: %s" % e.details) print("Exiting....") exit(1) def TextLCDError(e): try: source = e.device print("TextLCD %i: Phidget Error %i: %s" % (source.getSerialNum(), e.eCode, e.description)) except PhidgetException as e: print("Phidget Exception %i: %s" % (e.code, e.details))
# for twitter import tweetstream import json import urllib2 import re USER = "******" PASSWORD = "******" SEARCHTERM = "royalwedding" stream = tweetstream.TweetStream(USER, PASSWORD) #Create an TextLCD object try: textLCD = TextLCD() except RuntimeError as e: print("Runtime Exception: %s" % e.details) print("Exiting....") exit(1) #Information Display Function def DisplayDeviceInfo(): try: isAttached = textLCD.isAttached() name = textLCD.getDeviceName() serialNo = textLCD.getSerialNum() version = textLCD.getDeviceVersion() rowCount = textLCD.getRowCount() columnCount = textLCD.getColumnCount()
# Basic imports from ctypes import * import sys import random from time import sleep # Phidget specific imports from Phidgets.Phidget import PhidgetID from Phidgets.PhidgetException import PhidgetErrorCodes, PhidgetException from Phidgets.Events.Events import AttachEventArgs, DetachEventArgs, ErrorEventArgs, InputChangeEventArgs, OutputChangeEventArgs, SensorChangeEventArgs from Phidgets.Devices.InterfaceKit import InterfaceKit from Phidgets.Devices.TextLCD import TextLCD, TextLCD_ScreenSize # Create an interfacekit object try: interfaceKit = InterfaceKit() textLCD = TextLCD() except RuntimeError as e: print("Runtime Exception: %s" % e.details) print("Exiting....") exit(1) # Information Display Function def dispalyifkinfo(): print("|------------|----------------------------------|--------------|------------|") print("|- Attached -|- Type -|- Serial No. -|- Version -|") print("|------------|----------------------------------|--------------|------------|") print("|- %8s -|- %30s -|- %10d -|- %8d -|" % (interfaceKit.isAttached(), interfaceKit.getDeviceName(), interfaceKit.getSerialNum(), interfaceKit.getDeviceVersion())) print("|------------|----------------------------------|--------------|------------|")
except RuntimeError as e: print("Runtime Exception: %s" % e.details) print("Exiting....") exit(1) #Create an interfacekit object try: interfaceKit = InterfaceKit() except RuntimeError as e: print("Runtime Exception: %s" % e.details) print("Exiting....") exit(1) #Create an TextLCD object try: textLCD = TextLCD() except RuntimeError as e: print("Runtime Exception: %s" % e.details) print("Exiting....") exit(1) #Information Display Function def DisplayDeviceInfo(): print("|------------|----------------------------------|--------------|------------|") print("|- Attached -|- Type -|- Serial No. -|- Version -|") print("|------------|----------------------------------|--------------|------------|") print("|- %8s -|- %30s -|- %10d -|- %8d -|" % (stepper.isAttached(), stepper.getDeviceName(), stepper.getSerialNum(), stepper.getDeviceVersion())) print("|------------|----------------------------------|--------------|------------|") print("Number of Motors: %i" % (stepper.getMotorCount())) #Information Display Function
from Phidgets.Phidget import PhidgetID from Phidgets.Devices.TextLCD import TextLCD, TextLCD_ScreenSize import requests #Create an interfacekit object try: interfaceKit = InterfaceKit() except RuntimeError as e: print("InterfaceKit: Runtime Exception: %s" % e.details) print("Exiting....") exit(1) #Create an TextLCD object try: textLCD = TextLCD() except RuntimeError as e: print("LCD: Runtime Exception: %s" % e.details) try: interfaceKit.closePhidget() except PhidgetException as e: print("InterfaceKit Close: Phidget Exception %i: %s" % (e.code, e.details)) print("Exiting....") exit(1) print 'Setting sensors to 0' sensor_port0 = 0 sensor_port1 = 0 #Information Display Function def DisplayInterfaceKitDeviceInfo():
class PHIDGET_TEXTLCD(object): """ Phidget TextLCD with integrated InterfaceKit """ def __init__(self, serialNumber=None, waitForAttach=1000, **kargs): self.textLCD = TextLCD() if 'remoteHost' in kargs: self.textLCD.openRemote(kargs['remoteHost'], serialNumber) else: self.textLCD.openPhidget(serialNumber) h = [ 'onAttachHandler', 'onDetachHandler', 'onErrorhandler' ] for event in h: self.__dict__[event] = None if event in kargs: self.__dict__[event] = kargs[event] self.textLCD.setOnAttachHandler(self.attached) self.textLCD.setOnDetachHandler(self.detached) if waitForAttach > 0: try: self.textLCD.waitForAttach(waitForAttach) except PhidgetException as e: #print("Phidget Exception %i: %s" % (e.code, e.details)) try: self.textLCD.closePhidget() except PhidgetException as e2: pass raise e def attached(self, e): from Phidgets.Phidget import PhidgetID if e.device.getDeviceID()==PhidgetID.PHIDID_TEXTLCD_ADAPTER: e.device.setScreenIndex(0) e.device.setScreenSize(TextLCD.TextLCD_ScreenSize.PHIDGET_TEXTLCD_SCREEN_2x20) if self.onAttachHandler: self.onAttachHandler(e) def detached(self, e): if self.onDetachHandler: self.onDetachHandler(e) def error(self, e): error = {'code': e.eCode, 'description': e.description} if self.onErrorhandler: self.onErrorhandler(error, e)