コード例 #1
0
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)
コード例 #2
0
    for tweet in stream:
        if 'text' in tweet:
            text = tweet['text']
            if type(text) == str:
                if SEARCHTERM in text.lower():
                    display_tweet.append(text)
            if display_tweet:
                item = display_tweet.pop()

                textLCD.setBacklight(True)
                print item
                row1 = item[:20]
                row2 = item[20:40]
                print("Writing to first row....")
                textLCD.setDisplayString(0, row1)
                print("Writing to second row....")
                textLCD.setDisplayString(1, row2)
                sleep(2)

                print("Turn on cursor....")
                textLCD.setCursor(True)
                sleep(2)

                print("Turn on cursor blink....")
                textLCD.setCursor(False)
                textLCD.setCursorBlink(True)
                sleep(2)

            print("No Tweets")
            textLCD.setBacklight(False)
コード例 #3
0
ファイル: thi2textlcd.py プロジェクト: kj1216/thi2textlcd
    else:
        displaylcdinfo()
        dispalyifkinfo()

    print("Setting the data rate for each sensor index to 4ms....")
    for i in range(interfaceKit.getSensorCount()):
        try:
            interfaceKit.setDataRate(i, 4)
        except PhidgetException as e:
            print("Phidget Exception %i: %s" % (e.code, e.details))

    print("Press Enter to quit....")

    sys.stdin.read(1)

    print("Closing...")

    try:
        textLCD.setDisplayString(0, b"")
        textLCD.setDisplayString(1, b"")
        interfaceKit.closePhidget()
        textLCD.closePhidget()

    except PhidgetException as e:
        print("Phidget Exception %i: %s" % (e.code, e.details))
        print("Exiting....")
        exit(1)

    print("Done.")
    exit(0)
コード例 #4
0
    except PhidgetException as e:
        print("Phidget Exception %i: %s" % (e.code, e.details))
        print("Exiting....")
        exit(1)
    print("Exiting....")
    exit(1)
else:
    DisplayDeviceInfo()

try:
    if textLCD.getDeviceID()==PhidgetID.PHIDID_TEXTLCD_ADAPTER:
        textLCD.setScreenIndex(0)
        textLCD.setScreenSize(TextLCD_ScreenSize.PHIDGET_TEXTLCD_SCREEN_2x8)
    
    print("Writing to first row....")
    textLCD.setDisplayString(0, "Row 1")
    sleep(2)
    
    print("Writing to second row....")
    textLCD.setDisplayString(1, "Row 2")
    sleep(2)
    
    print("Adjusting contrast up....")
    textLCD.setContrast(255)
    sleep(2)
    
    print("Adjusting contrast down....")
    textLCD.setContrast(110)
    sleep(2)
    
    print("Turn on cursor....")
except PhidgetException as e:
    print("Phidget Exception %i: %s" % (e.code, e.details))
    try:
        textLCD.closePhidget()
    except PhidgetException as e:
        print("Phidget Exception %i: %s" % (e.code, e.details))
        print("Exiting....")
        exit(1)
    print("Exiting....")
    exit(1)

try:
    textLCD.setScreenIndex(0)

    #print("Writing to first row....")
    textLCD.setDisplayString(0, "Initialising...")
    sleep(2)

    textLCD.setBacklight(True)
    textLCD.setBrightness(128)

    #print("Writing to second row....")
    textLCD.setDisplayString(1, "Complete!")
    sleep(2)

except PhidgetException as e:
    print("Phidget Exception %i: %s" % (e.code, e.details))
    print("Exiting....")
    exit(1)

print("Press Enter to quit....")
コード例 #6
0
    except PhidgetException as e:
        print("Phidget Exception %i: %s" % (e.code, e.details))
        print("Exiting....")
        exit(1)
    print("Exiting....")
    exit(1)
else:
    DisplayDeviceInfo()

try:
    if textLCD.getDeviceID() == PhidgetID.PHIDID_TEXTLCD_ADAPTER:
        textLCD.setScreenIndex(0)
        textLCD.setScreenSize(TextLCD_ScreenSize.PHIDGET_TEXTLCD_SCREEN_2x8)

    print("Writing to first row....")
    textLCD.setDisplayString(0, "Row 1")
    sleep(2)

    print("Writing to second row....")
    textLCD.setDisplayString(1, "Row 2")
    sleep(2)

    print("Adjusting contrast up....")
    textLCD.setContrast(255)
    sleep(2)

    print("Adjusting contrast down....")
    textLCD.setContrast(110)
    sleep(2)

    print("Turn on cursor....")
コード例 #7
0
ファイル: srv_lcd.py プロジェクト: nomad-cam/ass-bot
print("PULL socket complete on ipc://lcd.ipc")
#message = {}

#The MEAT goes here...
#result = lcd_receiver.recv_json()

while True:
    print("going into forever loop mode")
    result = lcd_receiver.recv_json()
    print(result)
    #print result['message'],result['line'],result['delay']


    try:
        #clear the specified line...
        textLCD.setDisplayString(int(result['line']),"")
        #print the required text...
        textLCD.setDisplayString(int(result['line']),str(result['message']))
        
        if 'delay' in result:
            print("Waiting for Delay...")
            sleep(int(result['delay']))


    except PhidgetException as e:
        print("Phidget Exception %i: %s" % (e.code, e.details))
        print("Exiting....")
        exit(1)


#print("Press Enter to quit....")
コード例 #8
0
#        sleep(2)

#         print("Writing to second row....")
#         textLCD.setDisplayString(1, "   IOX Sample App   ")
#        sleep(2)

        headers={'Accept':'application/json'}
        data={'value':sensor_port0}
        r=requests.post("http://10.10.30.235:8080/rumble", data=data, headers=headers, verify=False)

        # if r.status_code == requests.codes.ok:
        #     print "success sending"
        # else:
        #     print "fail sending"

        textLCD.setDisplayString(0, "Quake reading:%6i" % sensor_port0)
        textLCD.setDisplayString(1, "")
#        sleep(2)
        
    except PhidgetException as e:
        print("Phidget Exception %i: %s" % (e.code, e.details))
        print("Exiting....")
        exit(1)


print("Closing...")

textLCD.setDisplayString(0, "")
textLCD.setDisplayString(1, "")

try:
コード例 #9
0
    except PhidgetException as e:
        print("Phidget Exception %i: %s" % (e.code, e.details))
        print("Exiting....")
        exit(1)
    print("Exiting....")
    exit(1)
else:
    DisplayDeviceInfo()

try:
    if textLCD.getDeviceID()==PhidgetID.PHIDID_TEXTLCD_ADAPTER:
        textLCD.setScreenIndex(0)
        textLCD.setScreenSize(TextLCD_ScreenSize.PHIDGET_TEXTLCD_SCREEN_2x8)
    
    print("Writing to first row....")
    textLCD.setDisplayString(0, "benhuah")
    sleep(2)
    
    print("Writing to second row....")
    textLCD.setDisplayString(1, "what")
    
    
    
except PhidgetException as e:
    print("Phidget Exception %i: %s" % (e.code, e.details))
    print("Exiting....")
    exit(1)

try:
    
    sleep(2)
コード例 #10
0
    for tweet in stream:
        if 'text' in tweet:
            text = tweet['text']
            if type(text) == str:
                if SEARCHTERM in text.lower():
                    display_tweet.append(text)
            if display_tweet:
                item = display_tweet.pop()

                textLCD.setBacklight(True)
                print item
                row1 = item[:20]
                row2 = item[20:40]
                print("Writing to first row....")
                textLCD.setDisplayString(0, row1)
                print("Writing to second row....")
                textLCD.setDisplayString(1, row2)
                sleep(2)

                print("Turn on cursor....")
                textLCD.setCursor(True)
                sleep(2)

                print("Turn on cursor blink....")
                textLCD.setCursor(False)
                textLCD.setCursorBlink(True)
                sleep(2)

            print("No Tweets")
            textLCD.setBacklight(False)
コード例 #11
0
while True:

    #first collect shaft movement messages...
    #try:
    #    relayed = relay_receiver.recv_json()
    #    print(result)

    #Then worry about displaying messages on the LCD...
    result = lcd_receiver.recv_json()
    print(result)
    #print result['message'],result['line'],result['delay']

    if 'message' in result:
        try:
            #clear the specified line...
            textLCD.setDisplayString(int(result['line']), "")
            #print the required text...
            textLCD.setDisplayString(int(result['line']),
                                     str(result['message']))

            if 'delay' in result:
                print("Waiting for Delay...")
                sleep(int(result['delay']))

        except PhidgetException as e:
            print("Phidget Exception %i: %s" % (e.code, e.details))
            print("Exiting....")
            exit(1)

#    if 'up' in result:
#        interfaceKitLCD.setOutputState(0,True)
except PhidgetException as e:
    print("Phidget Exception %i: %s" % (e.code, e.details))
    try:
        textLCD.closePhidget()
    except PhidgetException as e:
        print("Phidget Exception %i: %s" % (e.code, e.details))
        print("Exiting....")
        exit(1)
    print("Exiting....")
    exit(1)    

try:
    textLCD.setScreenIndex(0)

    #print("Writing to first row....")
    textLCD.setDisplayString(0, "Initialising...")
    sleep(2)

    textLCD.setBacklight(True)
    textLCD.setBrightness(128)

    #print("Writing to second row....")
    textLCD.setDisplayString(1, "Complete!")
    sleep(2)

except PhidgetException as e:
    print("Phidget Exception %i: %s" % (e.code, e.details))
    print("Exiting....")
    exit(1)