Remove some delays from random/rainbow scripts.
This commit is contained in:
127
test-random-colours.py
Normal file
127
test-random-colours.py
Normal file
@@ -0,0 +1,127 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import httplib
|
||||
import urllib
|
||||
import json
|
||||
from vestactrl import *
|
||||
import random
|
||||
import sys
|
||||
|
||||
real_hw = True
|
||||
|
||||
def adjust_blanks(s):
|
||||
blank = '░'
|
||||
return s.replace('░','`0')
|
||||
|
||||
def adjust_empty_spaces(s):
|
||||
empty_space = ' '
|
||||
return s.replace(' ', '`0')
|
||||
|
||||
def get_board_content():
|
||||
url1 = 'https://app.vestaboard.com/api/v1/board/'
|
||||
url2 = '/describe'
|
||||
full_url = url1 + board_id + url2
|
||||
page = urllib.urlopen(full_url)
|
||||
#conn = httplib.HTTPSConnection('app.vestaboard.com')
|
||||
#conn.request('GET', '/api/v1/board/%s/describe' % board_id)
|
||||
#response = conn.getresponse()
|
||||
contents = page.read()
|
||||
#print response.status, response.reason
|
||||
print page.getcode()
|
||||
sys.stdout.flush()
|
||||
#retval = adjust_blanks(response.read())
|
||||
contents2 = adjust_blanks(contents)
|
||||
retval = adjust_empty_spaces(contents2)
|
||||
#conn.close()
|
||||
page.close()
|
||||
return retval
|
||||
|
||||
def is_new_content(new, old):
|
||||
retval = False
|
||||
for v in zip(new,old):
|
||||
if v[0] != v[1]:
|
||||
retval = True
|
||||
break
|
||||
return retval
|
||||
|
||||
def random_colors():
|
||||
proto = [
|
||||
'`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d',
|
||||
'`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d',
|
||||
'`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d',
|
||||
'`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d',
|
||||
'`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d',
|
||||
'`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d`%d']
|
||||
lines = []
|
||||
for p in proto:
|
||||
s = p % (random.randint(1, 6),
|
||||
random.randint(1, 6),
|
||||
random.randint(1, 6),
|
||||
random.randint(1, 6),
|
||||
random.randint(1, 6),
|
||||
random.randint(1, 6),
|
||||
random.randint(1, 6),
|
||||
random.randint(1, 6),
|
||||
random.randint(1, 6),
|
||||
random.randint(1, 6),
|
||||
random.randint(1, 6),
|
||||
random.randint(1, 6),
|
||||
random.randint(1, 6),
|
||||
random.randint(1, 6),
|
||||
random.randint(1, 6),
|
||||
random.randint(1, 6),
|
||||
random.randint(1, 6),
|
||||
random.randint(1, 6),
|
||||
random.randint(1, 6),
|
||||
random.randint(1, 6),
|
||||
random.randint(1, 6),
|
||||
random.randint(1, 6))
|
||||
lines.append(s)
|
||||
setup_digits(lines, left_to_right_swap=False)
|
||||
|
||||
# VBR (23x7)
|
||||
#board_id = '700df57c-8b0a-4166-8758-b9de6e900cb8'
|
||||
# VB (22x6)
|
||||
#board_id = 'demo-a3c6ed9d-0499-4368-a3e9-b132cfc94305'
|
||||
# Testaboard
|
||||
board_id = 'demo-6a439bfd-fe37-4d82-af76-9cbf4fbd6367'
|
||||
#board_id = ' '
|
||||
board_name = 'Testaboard'
|
||||
|
||||
# ANDREA
|
||||
timeouts = 15
|
||||
if real_hw:
|
||||
#print 'before pause'
|
||||
#sys.stdout.flush()
|
||||
#time.sleep(timeouts)
|
||||
#print 'after pause'
|
||||
sys.stdout.flush()
|
||||
print 'before init_uart'
|
||||
sys.stdout.flush()
|
||||
board_init_uart()
|
||||
print 'after init_uart'
|
||||
sys.stdout.flush()
|
||||
print 'before blanks'
|
||||
sys.stdout.flush()
|
||||
# ANDREA
|
||||
#test_long_blanks()
|
||||
print 'after blanks'
|
||||
sys.stdout.flush()
|
||||
print 'before 2nd pause'
|
||||
sys.stdout.flush()
|
||||
#time.sleep(10)
|
||||
print 'after 2nd pause'
|
||||
sys.stdout.flush()
|
||||
|
||||
last_lines = ['', '', '', '', '', '']
|
||||
|
||||
data = None
|
||||
#while True:
|
||||
|
||||
#while board_id == ' ':
|
||||
#time.sleep(5)
|
||||
|
||||
random_colors()
|
||||
time.sleep(5)
|
||||
|
Reference in New Issue
Block a user