From fc2273a85b64d7cdfd86911335dc74f7250ab1a8 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 14 Feb 2022 18:48:27 +0000 Subject: [PATCH 1/4] added first boot screeen --- csv/system_info.json | 1 + database_caller.py | 2 -- server.py | 11 +++++++++++ stockTicker.py | 28 ++++++++++++++++++++++++---- 4 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 csv/system_info.json diff --git a/csv/system_info.json b/csv/system_info.json new file mode 100644 index 0000000..c82636f --- /dev/null +++ b/csv/system_info.json @@ -0,0 +1 @@ +{"update_available": false, "first_boot": false} \ No newline at end of file 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..2eb1299 100755 --- a/server.py +++ b/server.py @@ -48,6 +48,17 @@ ALLOWED_EXTENSIONS = {'csv', 'png'} ticker = pexpect.spawn("sudo -E python3 stockTicker.py") ticker.sendline('*') # run by default time.sleep(8) + +system_info = json.load(open('csv/system_info.json')) + + +if system_info['first_boot']: # let startup message display + + time.sleep(10) + system_info['first_boot'] = False + json.dump(system_info, open('csv/system_info.json', 'w')) + + ticker.sendline('A') # run by default def allowed_file(filename): diff --git a/stockTicker.py b/stockTicker.py index a104cd3..1c5a953 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,13 @@ class StockTicker(): elif msg == 'K': # kill self.resetMatrix() - + + + def run_intro_screen(self): + dct = {"feature": "Custom Messages", "speed": "Slow", "animation": "Down", "title": False, "messages": [{"name": "welcome", "text": "Welcome to Fintic", "text_colour": "White", "size": "Large", "background_colour": "Black"}]} + json.dump(dct, open('csv/message_settings.json', 'w')) + self.scrollFunctionsAnimated(['Custom Messages'], repeat = False) + if __name__ == '__main__': with open('log.txt', "a") as log: @@ -2731,6 +2739,18 @@ if __name__ == '__main__': #stock_ticker.setImage(start_image) time.sleep(2) stock_ticker.resetMatrix() + + system_info = json.load(open('csv/system_info.json')) + + + if system_info['first_boot']: + stock_ticker.run_intro_screen() + stock_ticker.resetMatrix() + + + + + #stock_ticker.getLeagueImage('NHL', 'future') #stock_ticker.getCryptoImage() From 4d83c5fbd21bef9e922fe8d842f0885d64a2b25e Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 14 Feb 2022 18:49:06 +0000 Subject: [PATCH 2/4] added first boot screeen --- version.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 version.txt diff --git a/version.txt b/version.txt new file mode 100644 index 0000000..9f8e9b6 --- /dev/null +++ b/version.txt @@ -0,0 +1 @@ +1.0 \ No newline at end of file From 4ad87bdfed70f6250641da71fa4ed8313a265cc4 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 15 Feb 2022 18:33:32 +0000 Subject: [PATCH 3/4] first boot message improvements --- server.py | 13 ++++++------- stockTicker.py | 43 ++++++++++++++++++++++++------------------- 2 files changed, 30 insertions(+), 26 deletions(-) diff --git a/server.py b/server.py index 2eb1299..ca9185b 100755 --- a/server.py +++ b/server.py @@ -46,20 +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(8) +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) if system_info['first_boot']: # let startup message display - time.sleep(10) + ticker.sendline('-') system_info['first_boot'] = False json.dump(system_info, open('csv/system_info.json', 'w')) - - -ticker.sendline('A') # run by default +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 1c5a953..38ad336 100755 --- a/stockTicker.py +++ b/stockTicker.py @@ -2713,12 +2713,25 @@ 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": "Slow", "animation": "Down", "title": False, "messages": [{"name": "welcome", "text": "Welcome to Fintic", "text_colour": "White", "size": "Large", "background_colour": "Black"}]} + 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 = False) + self.scrollFunctionsAnimated(['Custom Messages'], repeat = True) if __name__ == '__main__': @@ -2731,21 +2744,11 @@ 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() - - system_info = json.load(open('csv/system_info.json')) + - if system_info['first_boot']: - stock_ticker.run_intro_screen() - stock_ticker.resetMatrix() + + @@ -2757,8 +2760,10 @@ if __name__ == '__main__': # - #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') @@ -2768,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)) @@ -2776,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) + From c7f3e80dd6d265e5b61861144558d9528f0cb78e Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 15 Feb 2022 18:34:23 +0000 Subject: [PATCH 4/4] first boot message improvements --- csv/system_info.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/csv/system_info.json b/csv/system_info.json index c82636f..02cf3e9 100644 --- a/csv/system_info.json +++ b/csv/system_info.json @@ -1 +1 @@ -{"update_available": false, "first_boot": false} \ No newline at end of file +{"update_available": false, "first_boot": true}