コード例 #1
0
 def run(self):
     global interrupt
     previousMessage = None
     travel = None
     while not interrupt:
         currentMessage = None
         logging.debug('interrupt matrix=' + str(interrupt))
         if not self.q.empty():
             previousMessage = self.q.get()
             currentMessage = previousMessage
             if 'travel' in previousMessage:
                 travel = previousMessage['travel']
         if travel is not None and (time(7, 30) <= datetime.now().time() <= time(9, 0)) and (
                 datetime.now().isoweekday() in range(1, 6)):
             text = 'Drive: ' + travel['time']
             logging.debug(text)
             value = travel['seconds']
             if value < 1800:
                 color = 2
             elif 1800 <= value < 2400:
                 color = 3
             else:
                 color = 1
             self.updatestaticmatrix(text, color, 5)
             self.updatestaticmatrix('via', color, 2)
             self.updatescrollmatrix(travel['summary'], color, 0.006, 2)
         if currentMessage is not None and 'now_playing' in previousMessage:
             now_playing = '>Now Playing: ' + previousMessage['now_playing']['title']
             if 'artist' in previousMessage['now_playing']:
                 now_playing += ' >By: ' + previousMessage['now_playing']['artist']
             color = 2
             logging.debug(now_playing)
             self.updatescrollmatrix(now_playing, color, 0.006, 2)
         ldp.clear()
コード例 #2
0
def displayUpdate(upvote):
	colour=1
	num = 0
	while num<3:
		try:
			#show = 0
			textinput = upvote
			textinput+='  ::  '
			if num == 2:
			    textinput = upvote + "                "
			
			# save the ascii values of the input characters into the inputarray 
			# the font module uses the ascii value to index the font array
			inputarray=[]
			for char in textinput:
				inputarray.append(ord(char))

			# dotarray is  8 X n
			# n is determined by the number of characters multiplyed by 8 
			# n will be len(dotarray[0]) after filling dotarray from characters
			# in the inputarray
			#
			dotarray=[[] for i in xrange(8)]
			#
			# fill the dot array with the colour digits
			# this is the dot pattern that we want to show
			#
			for row in range(8):
				for ascii in inputarray:
					# get the width of the character from the first element of the font variable
					width=fontv.array[ascii][0]
					binary='{0:{fill}{align}{width}{base}}'.format(fontv.array[ascii][row+1],base='b',fill='0',align='>',width=width)
					for digit in range(width):
						if binary[digit] == '0':
							dotarray[row].append(0)
						else:
							dotarray[row].append(colour)
			#
			# Continually output to the display until Ctrl-C
			#
			
			
				# loop around each column in the dotarray
				
				
			for col in range(len(dotarray[0])):
				for row in range(8):
					# copy the current dotarray column values to the first column in the matrix
					matrix[row][0]=(dotarray[row][col])
				# now that we have updated the matrix lets show it
				showmatrix()
				# shift the matrix left ready for the next column
				shiftmatrix()
			ldp.displayoff()
			num += 1
		except KeyboardInterrupt:
			ldp.clear()
			print "Finished"
			sys.exit()
コード例 #3
0
                break


def main():
    global interrupt
    fetcherThread = data_fetcher(messageQueue)
    fetcherThread.daemon = True
    fetcherThread.start()
    printerThread = matrixPrinter(messageQueue)
    printerThread.daemon = True
    printerThread.start()
    castThread = cast_fetcher(messageQueue)
    castThread.daemon = True
    castThread.start()
    logging.debug('Threads Started')
    try:
        while True:
            sleep(.1)
    except KeyboardInterrupt:
        logging.info('Shutdown requested... exiting')
        interrupt = True
        fetcherThread.join()
        printerThread.join()


if __name__ == "__main__":
    logging.debug(sys.version)
    main()
    ldp.clear()
    logging.debug('main ended')
コード例 #4
0
ファイル: main.py プロジェクト: cashecollins/firebaseTesting
    #
    check = 0
    while cancel == False:
        try:
            """
            response = fbs.get('/Users', None)
            if len(response) != count:
                count = len(response)
                cancel = True
                print(count)
            """
            if check > 10:
                #fbs.get_async('/Users', None, callback=log_user)
                log_user([1,2,3,4,5])
                check = 0
            # loop around each column in the dotarray
            for col in range(len(dotarray[0])):
                for row in range(8):
                    # copy the current dotarray column values to the first column in the matrix
                    matrix[row][0] = (dotarray[row][col])
                # now that we have updated the matrix lets show it
                showmatrix()
                # shift the matrix left ready for the next column
                shiftmatrix()
            check += 1
        except KeyboardInterrupt:
            ldp.clear()
            print
            print "Finished"

コード例 #5
0
 def clear(self):
     """Zero out hardware buffer so that no LEDs will be on."""
     ldp.clear()
コード例 #6
0
ファイル: sign.py プロジェクト: AnjinMeili/python-ldp8008
 def clear(self):
     """Zero out hardware buffer so that no LEDs will be on."""
     ldp.clear()
コード例 #7
0
def displayUpdateStatic(upvote):
	colour=2
	textinput = upvote
	inputarray=[]
	for char in textinput:
		inputarray.append(ord(char))

	# dotarray is  8 X n
	# n is determined by the number of characters multiplyed by 8 
	# n will be len(dotarray[0]) after filling dotarray from characters
	# in the inputarray
	#
	dotarray=[[] for i in xrange(8)]
	#
	# fill the dot array with the colour digits
	# this is the dot pattern that we want to show
	#
	for row in range(8):
		for ascii in inputarray:
			# get the width of the character from the first element of the font variable
			width=fontv.array[ascii][0]
			binary='{0:{fill}{align}{width}{base}}'.format(fontv.array[ascii][row+1],base='b',fill='0',align='>',width=width)
			for digit in range(width):
				if binary[digit] == '0':
					dotarray[row].append(0)
				else:
					dotarray[row].append(colour)


	totalwidth=len(dotarray[0])
	if totalwidth > displaywidth:
		print 'Message is Larger than the Display'
		sys.exit()

	offset=int((displaywidth - totalwidth) / 2)

	# Fill the matrix initially with offset spaces to centre align the message
	#
	for col in range(offset):
		for row in range(8):
			matrix[row][col]=0
	# now fill the rest of the matrix with the dotarray
	for col in range(totalwidth):
		for row in range(8):
			# copy the current dotarray column values to the first column in the matrix
			matrix[row][offset+col]=(dotarray[row][col])


	#
	# Continually output to the display until Ctrl-C
	#

			# now that we have updated the matrix lets show it
	value = 0
	while value < 500:
		value = value + 1
		try:
			showmatrix2()
			
		except KeyboardInterrupt:
			ldp.clear()
			print "Finished"
			sys.exit()