From 1fc421335655fc22367b6cc78f339bd1bba0e7e9 Mon Sep 17 00:00:00 2001 From: Jakub Bialoskorski Date: Sat, 3 Aug 2019 17:16:00 +0200 Subject: [PATCH 01/19] initial commit --- stock.py | 27 +++++++++++++++++++++++++ stock_and_time.py | 50 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 stock.py create mode 100644 stock_and_time.py diff --git a/stock.py b/stock.py new file mode 100644 index 0000000..1617baa --- /dev/null +++ b/stock.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python +import ZeroSeg.led as led +import time +from datetime import datetime +import requests +import alpha_vantage +import json +import urllib + +device = led.sevensegment(cascaded=2) +device.clear() + +def stock(): + API_URL = "https://www.alphavantage.co/query" + symbols = ['ZEN'] + for symbol in symbols: + data = { "function": "GLOBAL_QUOTE", + "symbol": symbol, + "datatype": "json", + "apikey": "YOUR_API_KEY_HERE" } + response = requests.get(API_URL, data) + data = response.json() + output = data["Global Quote"]["05. price"] + output_filtered = output[:4] + device.write_text(1, "ZEN "+ output_filtered) + +stock() diff --git a/stock_and_time.py b/stock_and_time.py new file mode 100644 index 0000000..3284457 --- /dev/null +++ b/stock_and_time.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python +import ZeroSeg.led as led +import time +from datetime import datetime +import requests +import alpha_vantage +import json +import urllib + +def clock(device, deviceId, seconds): + + for _ in xrange(seconds): + now = datetime.now() + hour = now.hour + minute = now.minute + second = now.second + dot = second % 2 == 0 # calculate blinking dot + # Set hours + device.letter(deviceId, 7, int(hour / 10)) # Tens + device.letter(deviceId, 6, hour % 10) # Ones + device.letter(deviceId, 5, "-") + # Set minutes + device.letter(deviceId, 4, int(minute / 10)) # Tens + device.letter(deviceId, 3, minute % 10, dot) # Ones + time.sleep(1) + +def stock(): + API_URL = "https://www.alphavantage.co/query" + symbols = ['ZEN'] + for symbol in symbols: + data = { "function": "GLOBAL_QUOTE", + "symbol": symbol, + "datatype": "json", + "apikey": "YOUR_API_KEY_HERE" } + response = requests.get(API_URL, data) + data = response.json() + output = data["Global Quote"]["05. price"] + output_filtered = output[:2] + device.write_text(1, " ZEN " + output_filtered) + +device = led.sevensegment(cascaded=2) +device.clear() + +while True: + stock() + time.sleep(10) + device.clear() + clock(device, 1, seconds=10) + time.sleep(10) + device.clear() From 08c04a1bc08e2c1646d32cdf5e89a6653095129e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Bia=C5=82osk=C3=B3rski?= Date: Sat, 3 Aug 2019 18:40:11 +0200 Subject: [PATCH 02/19] added IDEA to ignored --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 1ce8652..b14d54c 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,6 @@ nosetests.xml .project .pydevproject .ropeproject + +# IDE +.idea \ No newline at end of file From 8e6846fd1801b1b375cb625b5becddd0587e0ed1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Bia=C5=82osk=C3=B3rski?= Date: Sat, 3 Aug 2019 18:49:48 +0200 Subject: [PATCH 03/19] added brightness button steering --- stock.py | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/stock.py b/stock.py index 1617baa..3bf685d 100644 --- a/stock.py +++ b/stock.py @@ -6,10 +6,23 @@ import alpha_vantage import json import urllib +import RPi.GPIO as GPIO +# setup buttons +button1 = 17 +button2 = 26 +GPIO.setmode(GPIO.BCM) # Use BCM GPIO numbers +GPIO.setup(button1, GPIO.IN) +GPIO.setup(button2, GPIO.IN) + +# cleanup before run device = led.sevensegment(cascaded=2) device.clear() +# set brightness to minimal +level = 1 + +# check Zendesk stock price def stock(): API_URL = "https://www.alphavantage.co/query" symbols = ['ZEN'] @@ -23,5 +36,25 @@ def stock(): output = data["Global Quote"]["05. price"] output_filtered = output[:4] device.write_text(1, "ZEN "+ output_filtered) + time.sleep(300) + +while True: + device.brightness(level) + if not GPIO.input(button1): + if level == 1: + print "MIN" + time.sleep(0.5) + if level >= 2: + level = level -1 + print "-1 ", level + time.sleep(0.5) -stock() + elif not GPIO.input(button2): + if level == 15: + print "MAX" + time.sleep(0.5) + if level <= 14: + level = level +1 + print "+1 ", level + time.sleep(0.5) + stock() \ No newline at end of file From 36f5deff29b9c432c6261b4448bbbd1cb3573af4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Bia=C5=82osk=C3=B3rski?= Date: Sat, 3 Aug 2019 18:53:18 +0200 Subject: [PATCH 04/19] removed sleep for stock checking --- stock.py | 1 - 1 file changed, 1 deletion(-) diff --git a/stock.py b/stock.py index 3bf685d..0a25f2b 100644 --- a/stock.py +++ b/stock.py @@ -36,7 +36,6 @@ def stock(): output = data["Global Quote"]["05. price"] output_filtered = output[:4] device.write_text(1, "ZEN "+ output_filtered) - time.sleep(300) while True: device.brightness(level) From 25f3cd80a2aacb09cb7cf30b90f9c03201b6ab99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Bia=C5=82osk=C3=B3rski?= Date: Sat, 3 Aug 2019 18:56:20 +0200 Subject: [PATCH 05/19] removed button functionality for brightness --- stock.py | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/stock.py b/stock.py index 0a25f2b..e98f497 100644 --- a/stock.py +++ b/stock.py @@ -21,6 +21,7 @@ # set brightness to minimal level = 1 +device.brightness(3) # check Zendesk stock price def stock(): @@ -37,23 +38,4 @@ def stock(): output_filtered = output[:4] device.write_text(1, "ZEN "+ output_filtered) -while True: - device.brightness(level) - if not GPIO.input(button1): - if level == 1: - print "MIN" - time.sleep(0.5) - if level >= 2: - level = level -1 - print "-1 ", level - time.sleep(0.5) - - elif not GPIO.input(button2): - if level == 15: - print "MAX" - time.sleep(0.5) - if level <= 14: - level = level +1 - print "+1 ", level - time.sleep(0.5) - stock() \ No newline at end of file +stock() \ No newline at end of file From 7afb1ccf678f2e8ae6249b8de843e0434caceeb1 Mon Sep 17 00:00:00 2001 From: Jakub Bialoskorski Date: Sat, 3 Aug 2019 19:55:49 +0200 Subject: [PATCH 06/19] fix hardcoded brightness --- stock.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stock.py b/stock.py index e98f497..be2645b 100644 --- a/stock.py +++ b/stock.py @@ -21,7 +21,7 @@ # set brightness to minimal level = 1 -device.brightness(3) +device.brightness(level) # check Zendesk stock price def stock(): @@ -38,4 +38,4 @@ def stock(): output_filtered = output[:4] device.write_text(1, "ZEN "+ output_filtered) -stock() \ No newline at end of file +stock() From 66b8fb2861f28379daf3b6ff407b768705543d9a Mon Sep 17 00:00:00 2001 From: Jakub Bialoskorski Date: Sun, 4 Aug 2019 13:45:46 +0200 Subject: [PATCH 07/19] added more digits to stock and removed ticker --- stock.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stock.py b/stock.py index be2645b..86716c8 100644 --- a/stock.py +++ b/stock.py @@ -31,11 +31,11 @@ def stock(): data = { "function": "GLOBAL_QUOTE", "symbol": symbol, "datatype": "json", - "apikey": "YOUR_API_KEY_HERE" } + "apikey": "YOUR_API_KEY" } response = requests.get(API_URL, data) data = response.json() output = data["Global Quote"]["05. price"] - output_filtered = output[:4] - device.write_text(1, "ZEN "+ output_filtered) + output_filtered = output[:6] + device.write_text(1, "-" + output_filtered + "-") stock() From 85a25b7518793dc4d0a62a343ef7a4209ffd07a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Bia=C5=82osk=C3=B3rski?= Date: Tue, 6 Aug 2019 12:54:39 +0200 Subject: [PATCH 08/19] adjust display for six digits --- stock.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stock.py b/stock.py index 86716c8..7ba2316 100644 --- a/stock.py +++ b/stock.py @@ -36,6 +36,6 @@ def stock(): data = response.json() output = data["Global Quote"]["05. price"] output_filtered = output[:6] - device.write_text(1, "-" + output_filtered + "-") + device.write_text(1, " " + output_filtered) stock() From bbbb42e8f9cbdb6bb06b93ebcf76a22e933f7a2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Bia=C5=82osk=C3=B3rski?= Date: Tue, 6 Aug 2019 16:30:15 +0200 Subject: [PATCH 09/19] remove unused module and buttons functionality --- stock.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/stock.py b/stock.py index 7ba2316..85f3fc5 100644 --- a/stock.py +++ b/stock.py @@ -6,14 +6,6 @@ import alpha_vantage import json import urllib -import RPi.GPIO as GPIO - -# setup buttons -button1 = 17 -button2 = 26 -GPIO.setmode(GPIO.BCM) # Use BCM GPIO numbers -GPIO.setup(button1, GPIO.IN) -GPIO.setup(button2, GPIO.IN) # cleanup before run device = led.sevensegment(cascaded=2) From 083efe8596afbafaac7a1dc021f26925eb0623bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Bia=C5=82osk=C3=B3rski?= Date: Tue, 6 Aug 2019 16:35:26 +0200 Subject: [PATCH 10/19] remove unused script --- stock_and_time.py | 50 ----------------------------------------------- 1 file changed, 50 deletions(-) delete mode 100644 stock_and_time.py diff --git a/stock_and_time.py b/stock_and_time.py deleted file mode 100644 index 3284457..0000000 --- a/stock_and_time.py +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env python -import ZeroSeg.led as led -import time -from datetime import datetime -import requests -import alpha_vantage -import json -import urllib - -def clock(device, deviceId, seconds): - - for _ in xrange(seconds): - now = datetime.now() - hour = now.hour - minute = now.minute - second = now.second - dot = second % 2 == 0 # calculate blinking dot - # Set hours - device.letter(deviceId, 7, int(hour / 10)) # Tens - device.letter(deviceId, 6, hour % 10) # Ones - device.letter(deviceId, 5, "-") - # Set minutes - device.letter(deviceId, 4, int(minute / 10)) # Tens - device.letter(deviceId, 3, minute % 10, dot) # Ones - time.sleep(1) - -def stock(): - API_URL = "https://www.alphavantage.co/query" - symbols = ['ZEN'] - for symbol in symbols: - data = { "function": "GLOBAL_QUOTE", - "symbol": symbol, - "datatype": "json", - "apikey": "YOUR_API_KEY_HERE" } - response = requests.get(API_URL, data) - data = response.json() - output = data["Global Quote"]["05. price"] - output_filtered = output[:2] - device.write_text(1, " ZEN " + output_filtered) - -device = led.sevensegment(cascaded=2) -device.clear() - -while True: - stock() - time.sleep(10) - device.clear() - clock(device, 1, seconds=10) - time.sleep(10) - device.clear() From 3931838a0f11e2c26153d6f07f3cc2dbaf778115 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Bia=C5=82osk=C3=B3rski?= Date: Tue, 6 Aug 2019 16:36:32 +0200 Subject: [PATCH 11/19] cleanup imports --- stock.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/stock.py b/stock.py index 85f3fc5..77d2786 100644 --- a/stock.py +++ b/stock.py @@ -1,11 +1,8 @@ #!/usr/bin/env python + +import time, requests, alpha_vantage, json, urllib import ZeroSeg.led as led -import time from datetime import datetime -import requests -import alpha_vantage -import json -import urllib # cleanup before run device = led.sevensegment(cascaded=2) From f8c6471e9781d4fbdd99a94d8c41935b0fc34da6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Bia=C5=82osk=C3=B3rski?= Date: Tue, 6 Aug 2019 16:37:52 +0200 Subject: [PATCH 12/19] initial commit --- requirements.txt | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..acd5374 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +requests +alpha_vantage \ No newline at end of file From ac4e4b9154102e4ec2b53a5a9a70267971ca51fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Bia=C5=82osk=C3=B3rski?= Date: Tue, 6 Aug 2019 16:45:00 +0200 Subject: [PATCH 13/19] add stock counter to calculate total richness --- stock.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/stock.py b/stock.py index 77d2786..3ef8b42 100644 --- a/stock.py +++ b/stock.py @@ -24,7 +24,16 @@ def stock(): response = requests.get(API_URL, data) data = response.json() output = data["Global Quote"]["05. price"] - output_filtered = output[:6] + output_filtered = output[:4] device.write_text(1, " " + output_filtered) -stock() +def how_rich_am_i(output_filtered): + number_of_stocks_total = XXX # change XXX to your total number of owned stocks + richness = number_of_stocks_total * output_filtered + device.write_text(1, richness) + +while True: + stock() + time.sleep(10) + how_rich_am_i() + time.sleep(10) \ No newline at end of file From 1d724999d1ed2f28e205664bfd8c7b73ea0878a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Bia=C5=82osk=C3=B3rski?= Date: Tue, 6 Aug 2019 16:49:06 +0200 Subject: [PATCH 14/19] increase number of digits for output --- stock.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stock.py b/stock.py index 3ef8b42..4c7dc8d 100644 --- a/stock.py +++ b/stock.py @@ -24,7 +24,7 @@ def stock(): response = requests.get(API_URL, data) data = response.json() output = data["Global Quote"]["05. price"] - output_filtered = output[:4] + output_filtered = output[:5] device.write_text(1, " " + output_filtered) def how_rich_am_i(output_filtered): From a47a11e138052a7347a0a4e4cb1d0f2a9d28edd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Bia=C5=82osk=C3=B3rski?= Date: Tue, 6 Aug 2019 16:57:53 +0200 Subject: [PATCH 15/19] resign from richness tracking --- stock.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/stock.py b/stock.py index 4c7dc8d..d13ef48 100644 --- a/stock.py +++ b/stock.py @@ -24,16 +24,7 @@ def stock(): response = requests.get(API_URL, data) data = response.json() output = data["Global Quote"]["05. price"] - output_filtered = output[:5] + output_filtered = output[:6] device.write_text(1, " " + output_filtered) -def how_rich_am_i(output_filtered): - number_of_stocks_total = XXX # change XXX to your total number of owned stocks - richness = number_of_stocks_total * output_filtered - device.write_text(1, richness) - -while True: - stock() - time.sleep(10) - how_rich_am_i() - time.sleep(10) \ No newline at end of file +stock() \ No newline at end of file From 212140d6904a6aa4941f46c6e5631557bb21f4b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Bia=C5=82osk=C3=B3rski?= Date: Sat, 10 Aug 2019 10:18:18 +0200 Subject: [PATCH 16/19] initial commit --- how_rich.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 how_rich.py diff --git a/how_rich.py b/how_rich.py new file mode 100644 index 0000000..8c7858c --- /dev/null +++ b/how_rich.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python + +import time, requests, alpha_vantage, json, urllib +import ZeroSeg.led as led +from datetime import datetime + +# cleanup before run +device = led.sevensegment(cascaded=2) +device.clear() + +# set brightness to minimal +level = 1 +device.brightness(level) + +# check Zendesk stock price +def stock(): + API_URL = "https://www.alphavantage.co/query" + symbols = ['ZEN'] + for symbol in symbols: + data = { "function": "GLOBAL_QUOTE", + "symbol": symbol, + "datatype": "json", + "apikey": "YOUR_API_KEY" } + response = requests.get(API_URL, data) + data = response.json() + output = data["Global Quote"]["05. price"] + output_filtered = float(output) + how_rich = output_filtered * NUMBER_OF_STOCKS_HERE + device.write_text(1, " " + how_rich) + +stock() \ No newline at end of file From 55258726d68d22413bfe9c6a374ac887773123c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Bia=C5=82osk=C3=B3rski?= Date: Sat, 10 Aug 2019 21:02:16 +0200 Subject: [PATCH 17/19] fix float to str conversion --- how_rich.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/how_rich.py b/how_rich.py index 8c7858c..092e676 100644 --- a/how_rich.py +++ b/how_rich.py @@ -24,8 +24,7 @@ def stock(): response = requests.get(API_URL, data) data = response.json() output = data["Global Quote"]["05. price"] - output_filtered = float(output) - how_rich = output_filtered * NUMBER_OF_STOCKS_HERE - device.write_text(1, " " + how_rich) + how_rich = float(output) * NUMBER_OF_STOCKS_HERE + device.write_text(1, str(how_rich)) stock() \ No newline at end of file From a2cdc77c0eb642fabead15421f3f4b76233aee11 Mon Sep 17 00:00:00 2001 From: Szymon Czajka Date: Sun, 11 Aug 2019 14:39:36 +0200 Subject: [PATCH 18/19] Add a new file - info.txt --- info.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 info.txt diff --git a/info.txt b/info.txt new file mode 100644 index 0000000..6b6278b --- /dev/null +++ b/info.txt @@ -0,0 +1 @@ +Try to create a new branch From 77be4207b60ad54fadfb560f90251a44cae38ed0 Mon Sep 17 00:00:00 2001 From: Szymon Czajka Date: Sun, 11 Aug 2019 14:57:10 +0200 Subject: [PATCH 19/19] Edit info.txt --- info.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/info.txt b/info.txt index 6b6278b..68eb475 100644 --- a/info.txt +++ b/info.txt @@ -1 +1 @@ -Try to create a new branch +Try to create a new branch again