def sendLine(line,speed=0.25,hold=0): buffer = " " * 18 line = unicodedata.normalize('NFKD',unicode(line)).encode('ascii','ignore') if len(line) <= len(buffer): buffer=string.center(line,len(buffer)) ledboard.drawstring(buffer,font()) else: buffer=line[:len(buffer)] ledboard.drawstring(buffer,font()) time.sleep(speed) for x in line[len(buffer):]: buffer = buffer[1:]+x ledboard.drawstring(buffer,font()) time.sleep(speed) time.sleep(hold)
def thrd(): global _buffer global ts global scroll global wdth f = font() while True: try: if scroll: ledboard.drawstring(_buffer[0:wdth], f) _buffer = _buffer[1:] + _buffer[0] time.sleep(0.1) if ts and time.time() - ts >= 60: print('end') _buffer = ' ' * wdth ts = None scroll = False except Exception as e: break print('text thread end')
def sendLine(line, speed=0.25, hold=0): buffer = " " * 18 line = unicodedata.normalize('NFKD', unicode(line)).encode('ascii', 'ignore') if len(line) <= len(buffer): buffer = string.center(line, len(buffer)) ledboard.drawstring(buffer, font()) else: buffer = line[:len(buffer)] ledboard.drawstring(buffer, font()) time.sleep(speed) for x in line[len(buffer):]: buffer = buffer[1:] + x ledboard.drawstring(buffer, font()) time.sleep(speed) time.sleep(hold)
last_b_usd = 0 last_l_usd = 0 while 1: #Koers _b_usd = urllib2.urlopen('https://btc-e.com/api/2/btc_usd/ticker') _l_usd = urllib2.urlopen('https://btc-e.com/api/2/ltc_usd/ticker') b_usd = json.load(_b_usd) l_usd = json.load(_l_usd) if last_b_usd < b_usd['ticker']['last']: updwn_b_usd = chr(0x80) else: updwn_b_usd = chr(0x81) if last_l_usd < l_usd['ticker']['last']: updwn_l_usd = chr(0x80) else: updwn_l_usd = chr(0x81) last_b_usd = b_usd['ticker']['last'] last_l_usd = l_usd['ticker']['last'] _buffer="B/U %s %s | L/U %s %s" % (b_usd['ticker']['last'],updwn_b_usd ,l_usd['ticker']['last'],updwn_l_usd) my_long_string = (" " * 18) + _buffer for i in range (0, len(my_long_string)): _buffer = my_long_string[i:(i+18)] ledboard.drawstring(_buffer,font())