From 635f9f04f9338b301e60df7efda88da86dbbb347 Mon Sep 17 00:00:00 2001 From: dmone032 Date: Sat, 25 Jul 2020 15:50:20 +0100 Subject: [PATCH 1/2] Added random colours, rainbow and extended rainbow. --- crc.pyc | Bin 3644 -> 3635 bytes packet.pyc | Bin 3137 -> 3110 bytes vestactrl.pyc | Bin 6218 -> 6170 bytes 3 files changed, 0 insertions(+), 0 deletions(-) diff --git a/crc.pyc b/crc.pyc index 5f71d53225f5666832584a03188dd8af1755128c..6dcd88640e1bb7657af4505b155ceb7fb843faa1 100644 GIT binary patch delta 59 wcmdlZvss3N`7$k__Hgd%A@Q5=oFz9FG=ceixWKPcKIfW|V#G8&Pu!*-30Oj=* A+5i9m diff --git a/packet.pyc b/packet.pyc index a5885b4e8ffd9535eb80e465352075ab1292a79b..32f08505bb348eaa1d71f680ee5daa05fc0a3d37 100644 GIT binary patch delta 150 zcmX>ou}p%4`7@ISH$ qr_|<$LX4<3icL-s@$GGrrx?$Z!Ih$g}U Date: Sun, 26 Jul 2020 16:50:07 +0100 Subject: [PATCH 2/2] Remove some delays from random/rainbow scripts. --- test-extended-rainbow.py | 178 +++++++++++++++++++++++++++++++++++++++ test-rainbow.py | 178 +++++++++++++++++++++++++++++++++++++++ test-random-colours.py | 127 ++++++++++++++++++++++++++++ 3 files changed, 483 insertions(+) create mode 100644 test-extended-rainbow.py create mode 100644 test-rainbow.py create mode 100644 test-random-colours.py diff --git a/test-extended-rainbow.py b/test-extended-rainbow.py new file mode 100644 index 0000000..91d7137 --- /dev/null +++ b/test-extended-rainbow.py @@ -0,0 +1,178 @@ +#!/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() + #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, 5), + random.randint(1, 5), + random.randint(1, 5), + random.randint(1, 5), + random.randint(1, 5), + random.randint(1, 5), + random.randint(1, 5), + random.randint(1, 5), + random.randint(1, 5), + random.randint(1, 5), + random.randint(1, 5), + random.randint(1, 5), + random.randint(1, 5), + random.randint(1, 5), + random.randint(1, 5), + random.randint(1, 5), + random.randint(1, 5), + random.randint(1, 5), + random.randint(1, 5), + random.randint(1, 5), + random.randint(1, 5), + random.randint(1, 5)) + 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_check_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) + +#time.sleep(3) + +#print('**********') +#print board_name +#print('**********') +#r = get_board_content() +#data = json.loads(r) +#print('DATA: %s') % data +#ulines = data['message']['lines'] +#print('ulines: %s') % ulines +#lines = [l.encode('ascii', 'ignore') for l in ulines] +lines = ['`3`4`5`6`7`1`2`3`4`5`6`7`1`2`3`4`5`6`7`1`2`3', '`2`3`4`5`6`7`1`2`3`4`5`6`7`1`2`3`4`5`6`7`1`2', '`1`2`3`4`5`6`7`1`2`3`4`5`6`7`1`2`3`4`5`6`7`1', '`7`1`2`3`4`5`6`7`1`2`3`4`5`6`7`1`2`3`4`5`6`7', '`6`7`1`2`3`4`5`6`7`1`2`3`4`5`6`7`1`2`3`4`5`6', '`5`6`7`1`2`3`4`5`6`7`1`2`3`4`5`6`7`1`2`3`4`5'] +test_flag = 0 +print lines +sys.stdout.flush() +row_num = len(lines) +#print('Number of rows: %d') % row_num +#for i in range(6): + #print('%s || %s' %(lines[i], last_lines[i])) +if row_num > 6: + print('* * * * * ') + print('ERROR: Too many rows; cannot send your message to the board. Sorry!') + print('* * * * * ') + +if row_num < 7: + row_len_flag = 0 + for i in range(row_num): + row_string = lines[i] + #print('CURRENT ROW STRING: %s') % row_string + row_len = len(row_string) - row_string.count('`') + #print('CURRENT ROW LENGTH: %s') % row_len + if row_len > 22: + row_len_flag = 1 + print('* * * * * ') + print('ERROR: Too many characters in row %d; cannot send your message to the board. Sorry!') % i + print('* * * * * ') + #setup_digits(lines_b, left_to_right_swap=False, real_hw=real_hw) + if row_len_flag == 0: + print('*** Jolly good! Message format valid. ***') + sys.stdout.flush() + if lines and is_new_content(lines, last_lines): + #if lines != last_lines: + print 'before setup digits' + sys.stdout.flush() + # ANDREA + setup_digits(lines, left_to_right_swap=False, real_hw=real_hw) + print 'after setup digits' + sys.stdout.flush() + last_lines = lines + print 'Waiting for bits to change...' + sys.stdout.flush() + time.sleep(6) + sys.stdout.flush() + #print 'Done. Please click "Next Flap" to continue.' + #raw_input("Press Enter to continue...") diff --git a/test-rainbow.py b/test-rainbow.py new file mode 100644 index 0000000..d55505c --- /dev/null +++ b/test-rainbow.py @@ -0,0 +1,178 @@ +#!/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() + #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, 5), + random.randint(1, 5), + random.randint(1, 5), + random.randint(1, 5), + random.randint(1, 5), + random.randint(1, 5), + random.randint(1, 5), + random.randint(1, 5), + random.randint(1, 5), + random.randint(1, 5), + random.randint(1, 5), + random.randint(1, 5), + random.randint(1, 5), + random.randint(1, 5), + random.randint(1, 5), + random.randint(1, 5), + random.randint(1, 5), + random.randint(1, 5), + random.randint(1, 5), + random.randint(1, 5), + random.randint(1, 5), + random.randint(1, 5)) + 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_check_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) + +#time.sleep(3) + +#print('**********') +#print board_name +#print('**********') +#r = get_board_content() +#data = json.loads(r) +#print('DATA: %s') % data +#ulines = data['message']['lines'] +#print('ulines: %s') % ulines +#lines = [l.encode('ascii', 'ignore') for l in ulines] +lines = ['`0`0`0`0`0`1`2`3`4`5`6`7`0`0`0`0`0`0`0`0`0`0', '`0`0`0`0`0`0`1`2`3`4`5`6`7`0`0`0`0`0`0`0`0`0', '`0`0`0`0`0`0`0`1`2`3`4`5`6`7`0`0`0`0`0`0`0`0', '`0`0`0`0`0`0`0`0`1`2`3`4`5`6`7`0`0`0`0`0`0`0', '`0`0`0`0`0`0`0`0`0`1`2`3`4`5`6`7`0`0`0`0`0`0', '`0`0`0`0`0`0`0`0`0`0`1`2`3`4`5`6`7`0`0`0`0`0'] +test_flag = 0 +print lines +sys.stdout.flush() +row_num = len(lines) +#print('Number of rows: %d') % row_num +#for i in range(6): + #print('%s || %s' %(lines[i], last_lines[i])) +if row_num > 6: + print('* * * * * ') + print('ERROR: Too many rows; cannot send your message to the board. Sorry!') + print('* * * * * ') + +if row_num < 7: + row_len_flag = 0 + for i in range(row_num): + row_string = lines[i] + #print('CURRENT ROW STRING: %s') % row_string + row_len = len(row_string) - row_string.count('`') + #print('CURRENT ROW LENGTH: %s') % row_len + if row_len > 22: + row_len_flag = 1 + print('* * * * * ') + print('ERROR: Too many characters in row %d; cannot send your message to the board. Sorry!') % i + print('* * * * * ') + #setup_digits(lines_b, left_to_right_swap=False, real_hw=real_hw) + if row_len_flag == 0: + print('*** Jolly good! Message format valid. ***') + sys.stdout.flush() + if lines and is_new_content(lines, last_lines): + #if lines != last_lines: + print 'before setup digits' + sys.stdout.flush() + # ANDREA + setup_digits(lines, left_to_right_swap=False, real_hw=real_hw) + print 'after setup digits' + sys.stdout.flush() + last_lines = lines + print 'Waiting for bits to change...' + sys.stdout.flush() + time.sleep(6) + sys.stdout.flush() + #print 'Done. Please click "Next Flap" to continue.' + #raw_input("Press Enter to continue...") diff --git a/test-random-colours.py b/test-random-colours.py new file mode 100644 index 0000000..ea95eea --- /dev/null +++ b/test-random-colours.py @@ -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) +