From 4e07b8d1750ce0dd0421f57b809575dc33bb63e0 Mon Sep 17 00:00:00 2001 From: dmone032 Date: Fri, 30 Oct 2020 12:22:56 -0400 Subject: [PATCH] Added flap test script that takes flap as argument, removing the need for 64 different scripts. --- test-flap-all.py | 71 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 test-flap-all.py diff --git a/test-flap-all.py b/test-flap-all.py new file mode 100644 index 0000000..3d96b6e --- /dev/null +++ b/test-flap-all.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import json +from vestactrl import * +import random +import sys + +real_hw = True + +def is_new_content(new, old): + retval = False + for v in zip(new,old): + if v[0] != v[1]: + retval = True + break + return retval + +timeouts = 15 +if real_hw: + print('before init_uart') + sys.stdout.flush() + board_init_uart() + print('after init_uart') + sys.stdout.flush() + +last_lines = ['', '', '', '', '', ''] + +char_list = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '!', '@', '#', '$', '&', ';', '(', ')', '-', '+', '=', ':', '\'', '\"', '%', ',', '.', '?', '`8', '/', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '`0', '`1', '`2', '`3', '`4', '`5', '`6', '`7'] + +data = None +if((len(sys.argv)) > 1): + c = sys.argv[1] + if c in char_list: + lines = [22*c, 22*c, 22*c, 22*c, 22*c, 22*c] + print(lines) + test_flag = 0 + print lines + sys.stdout.flush() + row_num = len(lines) + + if row_num > 6: + print('* * * * *\nERROR: Too many rows; cannot send your message to the board. Sorry!\n* * * * *') + + if row_num < 7: + row_len_flag = 0 + for i in range(row_num): + row_string = lines[i] + row_len = len(row_string) - row_string.count('`') + if row_len > 22: + row_len_flag = 1 + print('* * * * *\nERROR: Too many characters in row %d; cannot send your message to the board. Sorry!\n* * * * *') % i + if row_len_flag == 0: + print('*** Jolly good! Message format valid. ***') + sys.stdout.flush() + if lines and is_new_content(lines, last_lines): + print 'before setup digits' + sys.stdout.flush() + 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) + print 'Click \"Next Flap\" to continue.' + sys.stdout.flush() + else: + print("Invalid character selection... try again.") +else: + print("No argument fed to script... try again.") \ No newline at end of file