diff --git a/__pycache__/stockTicker.cpython-37.pyc b/__pycache__/stockTicker.cpython-37.pyc index 82747a2..7f82519 100644 Binary files a/__pycache__/stockTicker.cpython-37.pyc and b/__pycache__/stockTicker.cpython-37.pyc differ diff --git a/csv/crypto.csv b/csv/crypto.csv index 4118e74..d7fad47 100644 --- a/csv/crypto.csv +++ b/csv/crypto.csv @@ -1,3 +1,3 @@ name,current,24hr change -bitcoin,50378,0.18956930030648758 -ethereum,4007.97,4.564560454952176 +bitcoin,40905,1.9630605505752174 +ethereum,2756.88,2.711695798229129 diff --git a/csv/scroll_text.csv b/csv/scroll_text.csv index 300099b..3313a6f 100644 --- a/csv/scroll_text.csv +++ b/csv/scroll_text.csv @@ -1 +1 @@ -hello world!,255,255,0 \ No newline at end of file +ARUSHI IS CUTE,0,0,255 \ No newline at end of file diff --git a/csv/settings.csv b/csv/settings.csv index 3ff8116..bcf18cd 100644 --- a/csv/settings.csv +++ b/csv/settings.csv @@ -1,2 +1,2 @@ speed,brightness -s,5 \ No newline at end of file +m,5 \ No newline at end of file diff --git a/display_gif b/display_gif new file mode 100644 index 0000000..c78d7a0 Binary files /dev/null and b/display_gif differ diff --git a/display_image b/display_image new file mode 100644 index 0000000..1b52aea Binary files /dev/null and b/display_image differ diff --git a/final.ppm b/final.ppm index f4fcab6..72c19b9 100755 Binary files a/final.ppm and b/final.ppm differ diff --git a/final1.ppm b/final1.ppm index a2f9e0f..f4fcab6 100755 Binary files a/final1.ppm and b/final1.ppm differ diff --git a/gifs/close.gif b/gifs/close.gif new file mode 100644 index 0000000..1eadae4 Binary files /dev/null and b/gifs/close.gif differ diff --git a/gifs/open.gif b/gifs/open.gif new file mode 100644 index 0000000..c78d7a0 Binary files /dev/null and b/gifs/open.gif differ diff --git a/scroll_text.ppm b/scroll_text.ppm index cadb84d..9a254cf 100755 Binary files a/scroll_text.ppm and b/scroll_text.ppm differ diff --git a/server.py b/server.py index 46c5dd9..bbb882e 100644 --- a/server.py +++ b/server.py @@ -137,15 +137,58 @@ def Brightness(): LastCommand = 'Change Brightness' return hello() -@app.route("/Display_text", methods=['POST']) -def Display_text(): +@app.route("/DisplayText", methods=['POST']) +def DisplayText(): text = request.form['text'] f = open('csv/scroll_text.csv', 'w+') f.write(text) f.close() + ticker.sendline('K') ticker.sendline('T') return hello() +@app.route("/DisplayImage", methods=['POST']) +def DisplayImage(): + if request.method == 'POST': + if 'file' not in request.files: + print('No file attached in request') + return hello() + fle = request.files['file'] + if fle.filename == '': + print('No file selected') + return hello() + if fle and allowed_file(fle.filename): + filename = 'display_image' + fle.save(os.path.join(os.path.dirname(os.path.abspath(__file__)), filename)) + global LastCommand + LastCommand = 'Add a new logo file' + ticker.sendline('K') + ticker.sendline('I') + return hello() + return hello() + +@app.route("/DisplayGIF", methods=['POST']) +def DisplayGIF(): + + if request.method == 'POST': + if 'file' not in request.files: + print('No file attached in request') + return hello() + fle = request.files['file'] + if fle.filename == '': + print('No file selected') + return hello() + if fle: + print('in') + filename = 'display_gif' + fle.save(os.path.join(os.path.dirname(os.path.abspath(__file__)), filename)) + global LastCommand + LastCommand = 'Add a new logo file' + ticker.sendline('K') + ticker.sendline('G') + return hello() + return hello() + @app.route("/Ticker", methods=['POST']) def Ticker(): @@ -153,13 +196,13 @@ def Ticker(): if 'file' not in request.files: print('No file attached in request') return hello() - file = request.files['file'] - if file.filename == '': + fle = request.files['file'] + if fle.filename == '': print('No file selected') return hello() - if file and allowed_file(file.filename): - filename = secure_filename(file.filename) - file.save(os.path.join(CSV_FOLDER, filename)) + if fle and allowed_file(fle.filename): + filename = secure_filename(fle.filename) + fle.save(os.path.join(CSV_FOLDER, filename)) process_file(os.path.join(CSV_FOLDER, filename), filename) global LastCommand LastCommand = 'Change CSV file' @@ -172,13 +215,13 @@ def AddLogo(): if 'file' not in request.files: print('No file attached in request') return hello() - file = request.files['file'] - if file.filename == '': + fle = request.files['file'] + if fle.filename == '': print('No file selected') return hello() - if file and allowed_file(file.filename): - filename = secure_filename(file.filename) - file.save(os.path.join(LOGO_FOLDER, filename)) + if fle and allowed_file(fle.filename): + filename = secure_filename(fle.filename) + fle.save(os.path.join(LOGO_FOLDER, filename)) global LastCommand LastCommand = 'Add a new logo file' return hello() diff --git a/stockTicker.py b/stockTicker.py index 659eef8..2acd89a 100644 --- a/stockTicker.py +++ b/stockTicker.py @@ -180,6 +180,37 @@ class StockTicker(): img.save('scroll_text.ppm') self.scrollImageTransition(['scroll_text.ppm', 'scroll_text.ppm'], offset_x = 128, offset_y = 0, stocks = False) + + + def displayGIF(self, gif_file): + + im = Image.open(gif_file) + + # To iterate through the entire gif + + i = 0 + while 1: + print(im.tell()) + try: + im.seek(i) + except EOFError: + print('finished') + i = 0 + im.seek(i) + # do something to im + self.setImage(im.convert('RGB')) + time.sleep(0.5) + i += 1 + try: + msg = getInput() + if msg == 'K': + self.resetMatrix() + break + + self.process_msg(msg) + except KeyboardInterrupt: + sys.stdout.flush() + pass @@ -406,11 +437,11 @@ class StockTicker(): def process_msg(self, msg): - if msg == 'S': + if msg == 'S': # stocks self.getFullStockImage(1) self.displayStocks() - + # speed settings elif msg == 's': self.delay = 0.03 @@ -420,16 +451,36 @@ class StockTicker(): elif msg == 'f': self.delay = 0.005 - elif msg in ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']: + + elif msg in ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']: # birghtness ettings self.brightness = min(1.0, float(msg)/10 + 0.1) - elif msg == 'T': + + + elif msg == 'T':# text + self.displayText() + + elif msg == 'I': # image + + image = self.openImage(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'display_image')) + self.setImage( image) + + elif msg == 'G': # gif + + self.displayGIF(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'display_gif')) + + + elif msg == 'K': # kill + self.resetMatrix() if __name__ == '__main__': #print(sys.stdin.readlines()) stock_ticker = StockTicker() + #stock_ticker.displayGIF('/home/pi/Desktop/stock_ticker/gifs/open.gif') + #stock_ticker.displayGIF('/home/pi/Desktop/stock_ticker/gifs/close.gif') + #stock_ticker.process_msg(brightness) #stock_ticker.process_msg(speed) diff --git a/stockTicker.pyc b/stockTicker.pyc index 0801bda..26d88ce 100644 Binary files a/stockTicker.pyc and b/stockTicker.pyc differ diff --git a/templates/index.html b/templates/index.html index 54d4b58..0799a28 100644 --- a/templates/index.html +++ b/templates/index.html @@ -30,11 +30,23 @@

Display scrolling text. Enter the message followed by the rgb values seperated by commas. e.g. hello world!,255,255,0

-
+
+

Display an image

+
+

+ +

+ +

Display a gif

+
+

+ +

+

Tickers to display

To change the tickers displayed please upload a CSV (comma separated value) file with 11 tickers on each row e.g