diff --git a/csv/system_info.json b/csv/system_info.json new file mode 100644 index 0000000..02cf3e9 --- /dev/null +++ b/csv/system_info.json @@ -0,0 +1 @@ +{"update_available": false, "first_boot": true} diff --git a/database_caller.py b/database_caller.py index 9f94e52..3dd3022 100755 --- a/database_caller.py +++ b/database_caller.py @@ -643,8 +643,6 @@ if __name__ == '__main__': # sports sports_time = datetime.strptime(last_updates['sports'], "%d/%m/%Y %H:%M:%S") - - NY_time = datetime.now(NY_zone).replace(tzinfo=None) diff = (NY_time - sports_time).total_seconds()/60 #minutes if diff >= update_frequencies['sports'] or msg == 'S': diff --git a/server.py b/server.py index 43c63e0..ca9185b 100755 --- a/server.py +++ b/server.py @@ -46,9 +46,19 @@ CSV_FOLDER = 'csv/new/' ALLOWED_EXTENSIONS = {'csv', 'png'} 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) -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): return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS diff --git a/stockTicker.py b/stockTicker.py index a104cd3..38ad336 100755 --- a/stockTicker.py +++ b/stockTicker.py @@ -57,7 +57,7 @@ class StockTicker(): options.chain_length = 2 options.parallel = 1 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 self.matrix = RGBMatrix(options = options) print(dir(self.matrix)) @@ -325,7 +325,7 @@ class StockTicker(): 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 @@ -335,6 +335,7 @@ class StockTicker(): kill = False i = 0 # keep track of which image we are displaying self.double_buffer = self.matrix.CreateFrameCanvas() + while True: 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 not repeat: + break update_process.join() i+=1 @@ -2711,7 +2713,26 @@ class StockTicker(): elif msg == 'K': # kill 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__': with open('log.txt', "a") as log: @@ -2723,22 +2744,26 @@ if __name__ == '__main__': start_GIF = Image.open('./logos/startup_logo1.gif') 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.getCryptoImage() # - #stock_ticker.process_msg('G') - #stock_ticker.process_msg('f') + #stock_ticker.process_msg('*') + #time.sleep(8) + + #stock_ticker.process_msg('-') #stock_ticker.process_msg('W') #stock_ticker.process_msg('A') @@ -2748,7 +2773,7 @@ if __name__ == '__main__': msg = getInput() stock_ticker.process_msg(msg) except Exception as e: - + exc_type, exc_obj, exc_tb = sys.exc_info() fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] log.write(str(e)) @@ -2756,6 +2781,6 @@ if __name__ == '__main__': log.write('. line: ' + str(exc_tb.tb_lineno)) 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]))) - raise(e) +