image and gif upload and display working
This commit is contained in:
parent
b511b4f69e
commit
29784eed4f
Binary file not shown.
@ -1,3 +1,3 @@
|
|||||||
name,current,24hr change
|
name,current,24hr change
|
||||||
bitcoin,50378,0.18956930030648758
|
bitcoin,40905,1.9630605505752174
|
||||||
ethereum,4007.97,4.564560454952176
|
ethereum,2756.88,2.711695798229129
|
||||||
|
|
@ -1 +1 @@
|
|||||||
hello world!,255,255,0
|
ARUSHI IS CUTE,0,0,255
|
|
@ -1,2 +1,2 @@
|
|||||||
speed,brightness
|
speed,brightness
|
||||||
s,5
|
m,5
|
|
BIN
display_gif
Normal file
BIN
display_gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 747 B |
BIN
display_image
Normal file
BIN
display_image
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
BIN
final1.ppm
BIN
final1.ppm
Binary file not shown.
BIN
gifs/close.gif
Normal file
BIN
gifs/close.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 821 B |
BIN
gifs/open.gif
Normal file
BIN
gifs/open.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 747 B |
BIN
scroll_text.ppm
BIN
scroll_text.ppm
Binary file not shown.
67
server.py
67
server.py
@ -137,15 +137,58 @@ def Brightness():
|
|||||||
LastCommand = 'Change Brightness'
|
LastCommand = 'Change Brightness'
|
||||||
return hello()
|
return hello()
|
||||||
|
|
||||||
@app.route("/Display_text", methods=['POST'])
|
@app.route("/DisplayText", methods=['POST'])
|
||||||
def Display_text():
|
def DisplayText():
|
||||||
text = request.form['text']
|
text = request.form['text']
|
||||||
f = open('csv/scroll_text.csv', 'w+')
|
f = open('csv/scroll_text.csv', 'w+')
|
||||||
f.write(text)
|
f.write(text)
|
||||||
f.close()
|
f.close()
|
||||||
|
ticker.sendline('K')
|
||||||
ticker.sendline('T')
|
ticker.sendline('T')
|
||||||
return hello()
|
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'])
|
@app.route("/Ticker", methods=['POST'])
|
||||||
def Ticker():
|
def Ticker():
|
||||||
@ -153,13 +196,13 @@ def Ticker():
|
|||||||
if 'file' not in request.files:
|
if 'file' not in request.files:
|
||||||
print('No file attached in request')
|
print('No file attached in request')
|
||||||
return hello()
|
return hello()
|
||||||
file = request.files['file']
|
fle = request.files['file']
|
||||||
if file.filename == '':
|
if fle.filename == '':
|
||||||
print('No file selected')
|
print('No file selected')
|
||||||
return hello()
|
return hello()
|
||||||
if file and allowed_file(file.filename):
|
if fle and allowed_file(fle.filename):
|
||||||
filename = secure_filename(file.filename)
|
filename = secure_filename(fle.filename)
|
||||||
file.save(os.path.join(CSV_FOLDER, filename))
|
fle.save(os.path.join(CSV_FOLDER, filename))
|
||||||
process_file(os.path.join(CSV_FOLDER, filename), filename)
|
process_file(os.path.join(CSV_FOLDER, filename), filename)
|
||||||
global LastCommand
|
global LastCommand
|
||||||
LastCommand = 'Change CSV file'
|
LastCommand = 'Change CSV file'
|
||||||
@ -172,13 +215,13 @@ def AddLogo():
|
|||||||
if 'file' not in request.files:
|
if 'file' not in request.files:
|
||||||
print('No file attached in request')
|
print('No file attached in request')
|
||||||
return hello()
|
return hello()
|
||||||
file = request.files['file']
|
fle = request.files['file']
|
||||||
if file.filename == '':
|
if fle.filename == '':
|
||||||
print('No file selected')
|
print('No file selected')
|
||||||
return hello()
|
return hello()
|
||||||
if file and allowed_file(file.filename):
|
if fle and allowed_file(fle.filename):
|
||||||
filename = secure_filename(file.filename)
|
filename = secure_filename(fle.filename)
|
||||||
file.save(os.path.join(LOGO_FOLDER, filename))
|
fle.save(os.path.join(LOGO_FOLDER, filename))
|
||||||
global LastCommand
|
global LastCommand
|
||||||
LastCommand = 'Add a new logo file'
|
LastCommand = 'Add a new logo file'
|
||||||
return hello()
|
return hello()
|
||||||
|
@ -180,6 +180,37 @@ class StockTicker():
|
|||||||
|
|
||||||
img.save('scroll_text.ppm')
|
img.save('scroll_text.ppm')
|
||||||
self.scrollImageTransition(['scroll_text.ppm', 'scroll_text.ppm'], offset_x = 128, offset_y = 0, stocks = False)
|
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):
|
def process_msg(self, msg):
|
||||||
|
|
||||||
if msg == 'S':
|
if msg == 'S': # stocks
|
||||||
self.getFullStockImage(1)
|
self.getFullStockImage(1)
|
||||||
self.displayStocks()
|
self.displayStocks()
|
||||||
|
|
||||||
|
# speed settings
|
||||||
elif msg == 's':
|
elif msg == 's':
|
||||||
self.delay = 0.03
|
self.delay = 0.03
|
||||||
|
|
||||||
@ -420,16 +451,36 @@ class StockTicker():
|
|||||||
elif msg == 'f':
|
elif msg == 'f':
|
||||||
self.delay = 0.005
|
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)
|
self.brightness = min(1.0, float(msg)/10 + 0.1)
|
||||||
elif msg == 'T':
|
|
||||||
|
|
||||||
|
elif msg == 'T':# text
|
||||||
|
|
||||||
self.displayText()
|
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__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
#print(sys.stdin.readlines())
|
#print(sys.stdin.readlines())
|
||||||
stock_ticker = StockTicker()
|
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(brightness)
|
||||||
#stock_ticker.process_msg(speed)
|
#stock_ticker.process_msg(speed)
|
||||||
|
BIN
stockTicker.pyc
BIN
stockTicker.pyc
Binary file not shown.
@ -30,11 +30,23 @@
|
|||||||
</form>
|
</form>
|
||||||
|
|
||||||
<p>Display scrolling text. Enter the message followed by the rgb values seperated by commas. e.g. hello world!,255,255,0</p>
|
<p>Display scrolling text. Enter the message followed by the rgb values seperated by commas. e.g. hello world!,255,255,0</p>
|
||||||
<form action="/Display_text" method="POST">
|
<form action="/DisplayText" method="POST">
|
||||||
<input name="text" placeholder="hello world!,255,255,0"style="height:24px">
|
<input name="text" placeholder="hello world!,255,255,0"style="height:24px">
|
||||||
<input type="submit" value="Display"style="height:30px">
|
<input type="submit" value="Display"style="height:30px">
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<p>Display an image</p>
|
||||||
|
<form action="/DisplayImage" method="POST" enctype=multipart/form-data>
|
||||||
|
<p><input type=file name=file style="height:30px">
|
||||||
|
<input type=submit value=Upload style="height:30px">
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<p>Display a gif</p>
|
||||||
|
<form action="/DisplayGIF" method="POST" enctype=multipart/form-data>
|
||||||
|
<p><input type=file name=file style="height:30px">
|
||||||
|
<input type=submit value=Upload style="height:30px">
|
||||||
|
</form>
|
||||||
|
|
||||||
<br><br>
|
<br><br>
|
||||||
<h3>Tickers to display</h3>
|
<h3>Tickers to display</h3>
|
||||||
<p>To change the tickers displayed please upload a CSV (comma separated value) file with 11 tickers on each row e.g</p>
|
<p>To change the tickers displayed please upload a CSV (comma separated value) file with 11 tickers on each row e.g</p>
|
||||||
|
Loading…
Reference in New Issue
Block a user