Lifetime
This commit is contained in:
4
lifetime
Executable file
4
lifetime
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
sudo python /home/pi/vestaboard-client-new/lifetime-testing.py
|
||||
|
135
lifetime-testing.py
Executable file
135
lifetime-testing.py
Executable file
@@ -0,0 +1,135 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import httplib
|
||||
import json
|
||||
from vbctrl import *
|
||||
import random
|
||||
import errno
|
||||
import os
|
||||
import signal
|
||||
import time
|
||||
|
||||
real_hw = True
|
||||
|
||||
def adjust_blanks(s):
|
||||
blank = '░'
|
||||
return s.replace('░',' ')
|
||||
|
||||
def get_board_content():
|
||||
conn = httplib.HTTPSConnection('app.vestaboard.com')
|
||||
conn.request('GET', '/api/v1/board/%s/describe' % board_id)
|
||||
response = conn.getresponse()
|
||||
print response.status, response.reason
|
||||
retval = adjust_blanks(response.read())
|
||||
conn.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`%d`%d`%d`%d`%d`%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),
|
||||
random.randint(1, 5))
|
||||
lines.append(s)
|
||||
setup_digits(lines, left_to_right_swap=False)
|
||||
|
||||
|
||||
board_id = '700df57c-8b0a-4166-8758-b9de6e900cb8'
|
||||
|
||||
# ANDREA
|
||||
timeouts = 10
|
||||
if real_hw:
|
||||
print 'before pause'
|
||||
time.sleep(5)
|
||||
print 'after pause'
|
||||
print 'before init_uart'
|
||||
board_init_uart()
|
||||
print 'after init_uart'
|
||||
print 'before blanks'
|
||||
# ANDREA
|
||||
emc_blanks()
|
||||
print 'after blanks'
|
||||
print 'before 2nd pause'
|
||||
time.sleep(timeouts)
|
||||
print 'after 2nd pause'
|
||||
|
||||
last_lines = ['', '', '', '', '', '']
|
||||
displayChar = ['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']
|
||||
displayLines = ['','','','','','']
|
||||
data = None
|
||||
|
||||
class TimeoutError(Exception):
|
||||
pass
|
||||
|
||||
class timeout:
|
||||
def __init__(self, seconds=1, error_message='Timeout'):
|
||||
self.seconds = seconds
|
||||
self.error_message = error_message
|
||||
def handle_timeout(self, signum, frame):
|
||||
raise TimeoutError(self.error_message)
|
||||
def __enter__(self):
|
||||
signal.signal(signal.SIGALRM, self.handle_timeout)
|
||||
signal.alarm(self.seconds)
|
||||
def __exit__(self, type, value, traceback):
|
||||
signal.alarm(0)
|
||||
|
||||
while True:
|
||||
for pos in range(64):
|
||||
for j in range(6):
|
||||
displayLines[j] = 22*displayChar[pos]
|
||||
lines = displayLines
|
||||
print 'LINES: '
|
||||
print lines
|
||||
|
||||
print 'before setup digits'
|
||||
# ANDREA
|
||||
with timeout(seconds=2):
|
||||
try:
|
||||
setup_digits(lines, left_to_right_swap=False, real_hw=real_hw)
|
||||
print 'after setup digits'
|
||||
last_lines = lines
|
||||
except:
|
||||
continue
|
||||
print 'Waiting for bits to change...'
|
||||
if pos == 63:
|
||||
time.sleep(2)
|
||||
else:
|
||||
time.sleep(4.5)
|
||||
print 'Fetching message...'
|
Reference in New Issue
Block a user