Added flap test script that takes flap as argument, removing the need for 64 different scripts.

This commit is contained in:
dmone032
2020-10-30 12:22:56 -04:00
parent 700a112852
commit 4e07b8d175

71
test-flap-all.py Normal file
View File

@@ -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.")