commit
132d65637a
1
csv/system_info.json
Normal file
1
csv/system_info.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"update_available": false, "first_boot": true}
|
@ -643,8 +643,6 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
# sports
|
# sports
|
||||||
sports_time = datetime.strptime(last_updates['sports'], "%d/%m/%Y %H:%M:%S")
|
sports_time = datetime.strptime(last_updates['sports'], "%d/%m/%Y %H:%M:%S")
|
||||||
|
|
||||||
|
|
||||||
NY_time = datetime.now(NY_zone).replace(tzinfo=None)
|
NY_time = datetime.now(NY_zone).replace(tzinfo=None)
|
||||||
diff = (NY_time - sports_time).total_seconds()/60 #minutes
|
diff = (NY_time - sports_time).total_seconds()/60 #minutes
|
||||||
if diff >= update_frequencies['sports'] or msg == 'S':
|
if diff >= update_frequencies['sports'] or msg == 'S':
|
||||||
|
14
server.py
14
server.py
@ -46,9 +46,19 @@ CSV_FOLDER = 'csv/new/'
|
|||||||
ALLOWED_EXTENSIONS = {'csv', 'png'}
|
ALLOWED_EXTENSIONS = {'csv', 'png'}
|
||||||
|
|
||||||
ticker = pexpect.spawn("sudo -E python3 stockTicker.py")
|
ticker = pexpect.spawn("sudo -E python3 stockTicker.py")
|
||||||
ticker.sendline('*') # run by default
|
time.sleep(2) # give the ticker time to initialise
|
||||||
|
|
||||||
|
system_info = json.load(open('csv/system_info.json'))
|
||||||
|
|
||||||
|
ticker.sendline('*') # run startup gif by default
|
||||||
time.sleep(8)
|
time.sleep(8)
|
||||||
ticker.sendline('A') # run by default
|
if system_info['first_boot']: # let startup message display
|
||||||
|
|
||||||
|
ticker.sendline('-')
|
||||||
|
system_info['first_boot'] = False
|
||||||
|
json.dump(system_info, open('csv/system_info.json', 'w'))
|
||||||
|
else:
|
||||||
|
ticker.sendline('A') # run by default
|
||||||
|
|
||||||
def allowed_file(filename):
|
def allowed_file(filename):
|
||||||
return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
|
return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
|
||||||
|
@ -57,7 +57,7 @@ class StockTicker():
|
|||||||
options.chain_length = 2
|
options.chain_length = 2
|
||||||
options.parallel = 1
|
options.parallel = 1
|
||||||
options.hardware_mapping = 'adafruit-hat' # If you have an Adafruit HAT: 'adafruit-hat'
|
options.hardware_mapping = 'adafruit-hat' # If you have an Adafruit HAT: 'adafruit-hat'
|
||||||
options.gpio_slowdown = 1
|
options.gpio_slowdown = 4
|
||||||
options.brightness = self.brightness
|
options.brightness = self.brightness
|
||||||
self.matrix = RGBMatrix(options = options)
|
self.matrix = RGBMatrix(options = options)
|
||||||
print(dir(self.matrix))
|
print(dir(self.matrix))
|
||||||
@ -325,7 +325,7 @@ class StockTicker():
|
|||||||
return self.delay
|
return self.delay
|
||||||
|
|
||||||
|
|
||||||
def scrollFunctionsAnimated(self, options, animation = 'down'):
|
def scrollFunctionsAnimated(self, options, animation = 'down', repeat = True):
|
||||||
|
|
||||||
# scrolls trhough all functions with animation. Updates functions and remakes images when each function not being dispplayed
|
# scrolls trhough all functions with animation. Updates functions and remakes images when each function not being dispplayed
|
||||||
|
|
||||||
@ -335,6 +335,7 @@ class StockTicker():
|
|||||||
kill = False
|
kill = False
|
||||||
i = 0 # keep track of which image we are displaying
|
i = 0 # keep track of which image we are displaying
|
||||||
self.double_buffer = self.matrix.CreateFrameCanvas()
|
self.double_buffer = self.matrix.CreateFrameCanvas()
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
|
||||||
update_process = Process(target = self.updateMultiple, args = ([options[(i+1) % len(options)]],))
|
update_process = Process(target = self.updateMultiple, args = ([options[(i+1) % len(options)]],))
|
||||||
@ -423,7 +424,8 @@ class StockTicker():
|
|||||||
|
|
||||||
if kill: break
|
if kill: break
|
||||||
if kill:break
|
if kill:break
|
||||||
|
if not repeat:
|
||||||
|
break
|
||||||
update_process.join()
|
update_process.join()
|
||||||
i+=1
|
i+=1
|
||||||
|
|
||||||
@ -2711,7 +2713,26 @@ class StockTicker():
|
|||||||
|
|
||||||
elif msg == 'K': # kill
|
elif msg == 'K': # kill
|
||||||
self.resetMatrix()
|
self.resetMatrix()
|
||||||
|
|
||||||
|
elif msg =='-':
|
||||||
|
self.run_intro_screen()
|
||||||
|
|
||||||
|
elif msg == '*':
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
self.displayGIF(start_GIF, delay = 0.02, repeat = False)
|
||||||
|
#stock_ticker.setImage(start_image)
|
||||||
|
time.sleep(2)
|
||||||
|
self.resetMatrix()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def run_intro_screen(self):
|
||||||
|
dct = {"feature": "Custom Messages", "speed": "Medium", "animation": "Down", "title": False, "messages": [{"name": "welcome", "text": "Welcome to Fintic!", "text_colour": "White", "size": "Large", "background_colour": "Black"}, {"name": "get_started", "text": "To get started, connect your device to the \"Fintic Hotspot\" and access \"fintic.local:1024\" on your web browser. You can connect your ticker to Wi-Fi there.", "text_colour": "White", "size": "Small", "background_colour": "Black"}]}
|
||||||
|
json.dump(dct, open('csv/message_settings.json', 'w'))
|
||||||
|
self.scrollFunctionsAnimated(['Custom Messages'], repeat = True)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
with open('log.txt', "a") as log:
|
with open('log.txt', "a") as log:
|
||||||
@ -2723,22 +2744,26 @@ if __name__ == '__main__':
|
|||||||
start_GIF = Image.open('./logos/startup_logo1.gif')
|
start_GIF = Image.open('./logos/startup_logo1.gif')
|
||||||
|
|
||||||
msg = getInput()
|
msg = getInput()
|
||||||
if msg =='*':
|
|
||||||
#
|
|
||||||
#
|
|
||||||
|
|
||||||
stock_ticker.displayGIF(start_GIF, delay = 0.02, repeat = False)
|
|
||||||
#stock_ticker.setImage(start_image)
|
|
||||||
time.sleep(2)
|
|
||||||
stock_ticker.resetMatrix()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#stock_ticker.getLeagueImage('NHL', 'future')
|
#stock_ticker.getLeagueImage('NHL', 'future')
|
||||||
#stock_ticker.getCryptoImage()
|
#stock_ticker.getCryptoImage()
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
||||||
#stock_ticker.process_msg('G')
|
#stock_ticker.process_msg('*')
|
||||||
#stock_ticker.process_msg('f')
|
#time.sleep(8)
|
||||||
|
|
||||||
|
#stock_ticker.process_msg('-')
|
||||||
#stock_ticker.process_msg('W')
|
#stock_ticker.process_msg('W')
|
||||||
#stock_ticker.process_msg('A')
|
#stock_ticker.process_msg('A')
|
||||||
|
|
||||||
@ -2748,7 +2773,7 @@ if __name__ == '__main__':
|
|||||||
msg = getInput()
|
msg = getInput()
|
||||||
stock_ticker.process_msg(msg)
|
stock_ticker.process_msg(msg)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
||||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||||
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
||||||
log.write(str(e))
|
log.write(str(e))
|
||||||
@ -2756,6 +2781,6 @@ if __name__ == '__main__':
|
|||||||
log.write('. line: ' + str(exc_tb.tb_lineno))
|
log.write('. line: ' + str(exc_tb.tb_lineno))
|
||||||
log.write('. type: ' + str(exc_type))
|
log.write('. type: ' + str(exc_type))
|
||||||
log.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
log.write('\n ' + "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])))
|
||||||
raise(e)
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user