two screensavers added

This commit is contained in:
Neythen 2021-11-17 19:34:13 +00:00
parent 999dc32d92
commit 2cc6afc5cf
13 changed files with 76 additions and 227 deletions

View File

@ -658,6 +658,7 @@ if __name__ == '__main__':
if checkStocks(stock_time, stock_frequency) or msg == 's': if checkStocks(stock_time, stock_frequency) or msg == 's':
stock_time = NY_time.strftime("%d/%m/%Y %H:%M:%S") stock_time = NY_time.strftime("%d/%m/%Y %H:%M:%S")
last_updates['stocks'] = stock_time last_updates['stocks'] = stock_time
updateStocks()
# crypto # crypto
crypto_time = datetime.strptime(last_updates['crypto'], "%d/%m/%Y %H:%M:%S") crypto_time = datetime.strptime(last_updates['crypto'], "%d/%m/%Y %H:%M:%S")

View File

@ -1 +1 @@
{"feature": "Stocks", "speed": "medium", "animation": "down", "percent": false, "point": false, "logos": true, "chart": false, "title": true, "symbols": {"NEO,USD": {"current": 43.14, "24hr_change": -1.4320514042952985}, "BTC,USD": {"current": 60800, "24hr_change": 0.27878029217327127}, "ETH,BTC": {"current": 0.07025085, "24hr_change": -1.2732675844426864}, "ADA,GBP": {"current": 1.4, "24hr_change": -1.9972252884320558}}} {"feature": "Stocks", "speed": "medium", "animation": "down", "percent": false, "point": false, "logos": true, "chart": false, "title": true, "symbols": {"NEO,USD": {"current": 42.95, "24hr_change": -2.0434968411618937}, "BTC,USD": {"current": 60594, "24hr_change": -0.03867146261533629}, "ETH,BTC": {"current": 0.07020828, "24hr_change": -0.632522958888375}, "ADA,GBP": {"current": 1.39, "24hr_change": -2.1188381102215366}}}

View File

@ -1 +1 @@
{"feature": "Current Weather", "speed": "medium", "animation": "down", "temp": "celsius", "wind_speed": "miles/sec", "colour": "white", "city_colour": "yellow", "title": true, "locations": {"Moscow": {"main_weather": "Clouds", "description": "overcast clouds", "temp": 0.41, "min_temp": -2.12, "max_temp": 0.41, "feels_like": -2.18, "humidity": 83, "clouds": 100, "wind_speed": 2.17, "wind_direction": 224, "visibility": 10000, "uv": 0, "rain_chance": 0}, "Beijing": {"main_weather": "Clear", "description": "clear sky", "temp": -0.06, "min_temp": -0.06, "max_temp": 12.94, "feels_like": -0.06, "humidity": 49, "clouds": 0, "wind_speed": 0.71, "wind_direction": 25, "visibility": 10000, "uv": 0, "rain_chance": 0}, "London": {"main_weather": "Clouds", "description": "overcast clouds", "temp": 7.29, "min_temp": 7.29, "max_temp": 11.19, "feels_like": 5.54, "humidity": 85, "clouds": 100, "wind_speed": 2.59, "wind_direction": 270, "visibility": 10000, "uv": 0, "rain_chance": 0}, "Tokyo": {"main_weather": "Clouds", "description": "broken clouds", "temp": 10.85, "min_temp": 10.85, "max_temp": 17.07, "feels_like": 9.87, "humidity": 72, "clouds": 75, "wind_speed": 0.89, "wind_direction": 57, "visibility": 10000, "uv": 0, "rain_chance": 0.04}}, "current_weather": true} {"feature": "Current Weather", "speed": "medium", "animation": "down", "temp": "celsius", "wind_speed": "miles/sec", "colour": "white", "city_colour": "yellow", "title": true, "locations": {"Beijing": {"main_weather": "Clear", "description": "clear sky", "temp": -1.06, "min_temp": -1.06, "max_temp": 12.94, "feels_like": -1.06, "humidity": 49, "clouds": 0, "wind_speed": 0.71, "wind_direction": 25, "visibility": 10000, "uv": 0, "rain_chance": 0}, "London": {"main_weather": "Clouds", "description": "overcast clouds", "temp": 6.83, "min_temp": 6.83, "max_temp": 11.37, "feels_like": 4.93, "humidity": 88, "clouds": 100, "wind_speed": 2.68, "wind_direction": 268, "visibility": 10000, "uv": 0, "rain_chance": 0}, "Moscow": {"main_weather": "Clouds", "description": "overcast clouds", "temp": 0.41, "min_temp": -2.12, "max_temp": 0.41, "feels_like": -2.18, "humidity": 84, "clouds": 100, "wind_speed": 2.17, "wind_direction": 224, "visibility": 10000, "uv": 0, "rain_chance": 0}, "Tokyo": {"main_weather": "Clouds", "description": "broken clouds", "temp": 11.46, "min_temp": 11.46, "max_temp": 17.07, "feels_like": 10.52, "humidity": 71, "clouds": 75, "wind_speed": 0.89, "wind_direction": 346, "visibility": 10000, "uv": 0, "rain_chance": 0}}, "current_weather": true}

View File

@ -1 +1 @@
{"feature": "Current Weather", "speed": "medium", "animation": "continuous", "temp": "celsius", "wind_speed": "miles/sec", "colour": "white", "city_colour": "yellow", "title": true, "locations": {"Moscow": [{"main_weather": "Clouds", "description": "overcast clouds", "min_temp": -2.12, "max_temp": 0.41}, {"main_weather": "Snow", "description": "light snow", "min_temp": -1.63, "max_temp": 0.24}, {"main_weather": "Clouds", "description": "overcast clouds", "min_temp": -0.6, "max_temp": 1.53}, {"main_weather": "Snow", "description": "rain and snow", "min_temp": 0.88, "max_temp": 5.22}, {"main_weather": "Snow", "description": "light snow", "min_temp": 0.72, "max_temp": 2.13}, {"main_weather": "Snow", "description": "light snow", "min_temp": -3.96, "max_temp": 0.25}, {"main_weather": "Snow", "description": "light snow", "min_temp": -4.37, "max_temp": -1.28}, {"main_weather": "Snow", "description": "snow", "min_temp": -0.46, "max_temp": 1.39}], "Beijing": [{"main_weather": "Clouds", "description": "few clouds", "min_temp": -0.06, "max_temp": 12.94}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 5.15, "max_temp": 9.77}, {"main_weather": "Clouds", "description": "overcast clouds", "min_temp": 6.02, "max_temp": 9.97}, {"main_weather": "Clouds", "description": "overcast clouds", "min_temp": 2.73, "max_temp": 8.78}, {"main_weather": "Clear", "description": "clear sky", "min_temp": -0.16, "max_temp": 3.35}, {"main_weather": "Clear", "description": "clear sky", "min_temp": -1.02, "max_temp": 3.5}, {"main_weather": "Clear", "description": "clear sky", "min_temp": -1.05, "max_temp": 4.64}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 0.23, "max_temp": 7.72}], "London": [{"main_weather": "Clouds", "description": "overcast clouds", "min_temp": 7.29, "max_temp": 11.19}, {"main_weather": "Clouds", "description": "broken clouds", "min_temp": 6.86, "max_temp": 12.12}, {"main_weather": "Clouds", "description": "overcast clouds", "min_temp": 8.91, "max_temp": 13.56}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 8.83, "max_temp": 12.04}, {"main_weather": "Clouds", "description": "scattered clouds", "min_temp": 4.98, "max_temp": 10}, {"main_weather": "Rain", "description": "light rain", "min_temp": 5.58, "max_temp": 8.88}, {"main_weather": "Rain", "description": "light rain", "min_temp": 5.59, "max_temp": 8.54}, {"main_weather": "Clouds", "description": "broken clouds", "min_temp": 4.17, "max_temp": 7.12}], "Tokyo": [{"main_weather": "Rain", "description": "light rain", "min_temp": 10.85, "max_temp": 17.07}, {"main_weather": "Clouds", "description": "broken clouds", "min_temp": 13.12, "max_temp": 17.24}, {"main_weather": "Clouds", "description": "broken clouds", "min_temp": 13.09, "max_temp": 16.3}, {"main_weather": "Rain", "description": "light rain", "min_temp": 13.04, "max_temp": 14.23}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 12.46, "max_temp": 16.24}, {"main_weather": "Rain", "description": "light rain", "min_temp": 13.46, "max_temp": 15.28}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 10.71, "max_temp": 14.18}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 9.46, "max_temp": 14.24}]}, "current_weather": true} {"feature": "Current Weather", "speed": "medium", "animation": "continuous", "temp": "celsius", "wind_speed": "miles/sec", "colour": "white", "city_colour": "yellow", "title": true, "locations": {"Beijing": [{"main_weather": "Clouds", "description": "few clouds", "min_temp": -1.06, "max_temp": 12.94}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 5.15, "max_temp": 9.77}, {"main_weather": "Clouds", "description": "overcast clouds", "min_temp": 6.02, "max_temp": 9.97}, {"main_weather": "Clouds", "description": "overcast clouds", "min_temp": 2.73, "max_temp": 8.78}, {"main_weather": "Clear", "description": "clear sky", "min_temp": -0.16, "max_temp": 3.35}, {"main_weather": "Clear", "description": "clear sky", "min_temp": -1.02, "max_temp": 3.5}, {"main_weather": "Clear", "description": "clear sky", "min_temp": -1.05, "max_temp": 4.64}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 0.23, "max_temp": 7.72}], "London": [{"main_weather": "Clouds", "description": "overcast clouds", "min_temp": 6.83, "max_temp": 11.37}, {"main_weather": "Clouds", "description": "broken clouds", "min_temp": 6.99, "max_temp": 13.15}, {"main_weather": "Clouds", "description": "broken clouds", "min_temp": 9.22, "max_temp": 13.85}, {"main_weather": "Clouds", "description": "few clouds", "min_temp": 8.67, "max_temp": 12.75}, {"main_weather": "Rain", "description": "light rain", "min_temp": 6.23, "max_temp": 9.51}, {"main_weather": "Clouds", "description": "few clouds", "min_temp": 5.99, "max_temp": 8.96}, {"main_weather": "Clouds", "description": "broken clouds", "min_temp": 5.47, "max_temp": 8.48}, {"main_weather": "Rain", "description": "light rain", "min_temp": 4.07, "max_temp": 7.85}], "Moscow": [{"main_weather": "Clouds", "description": "overcast clouds", "min_temp": -2.12, "max_temp": 0.41}, {"main_weather": "Snow", "description": "light snow", "min_temp": -1.63, "max_temp": 0.24}, {"main_weather": "Clouds", "description": "overcast clouds", "min_temp": -0.6, "max_temp": 1.53}, {"main_weather": "Snow", "description": "rain and snow", "min_temp": 0.88, "max_temp": 5.22}, {"main_weather": "Snow", "description": "light snow", "min_temp": 0.72, "max_temp": 2.13}, {"main_weather": "Snow", "description": "light snow", "min_temp": -3.96, "max_temp": 0.25}, {"main_weather": "Snow", "description": "light snow", "min_temp": -4.37, "max_temp": -1.28}, {"main_weather": "Snow", "description": "snow", "min_temp": -0.46, "max_temp": 1.39}], "Tokyo": [{"main_weather": "Rain", "description": "light rain", "min_temp": 11.46, "max_temp": 17.07}, {"main_weather": "Clouds", "description": "broken clouds", "min_temp": 13.12, "max_temp": 17.24}, {"main_weather": "Clouds", "description": "broken clouds", "min_temp": 13.09, "max_temp": 16.3}, {"main_weather": "Rain", "description": "light rain", "min_temp": 13.04, "max_temp": 14.23}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 12.46, "max_temp": 16.24}, {"main_weather": "Rain", "description": "light rain", "min_temp": 13.46, "max_temp": 15.28}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 10.71, "max_temp": 14.18}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 9.46, "max_temp": 14.24}]}, "current_weather": true}

View File

@ -1 +1 @@
["Current Weather"] ["Stocks"]

View File

@ -1 +1 @@
{"stocks": "17/11/2021 13:38:11", "crypto": "17/11/2021 13:32:17", "news": "17/11/2021 13:32:19", "weather": "17/11/2021 13:32:17", "forex": "17/11/2021 19:32:24", "sports": "17/11/2021 13:32:20"} {"stocks": "17/11/2021 14:30:18", "crypto": "17/11/2021 14:28:16", "news": "17/11/2021 14:28:19", "weather": "17/11/2021 14:28:17", "forex": "17/11/2021 20:28:22", "sports": "17/11/2021 14:28:19"}

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
{"feature": "Stocks", "speed": "medium", "animation": "down", "percent": true, "point": true, "logos": false, "chart": false, "title": true, "symbols": {"MSFT": {"current": 340.12, "opening": 339.29}, "GOOG": {"current": 2980.07, "opening": 2984.38}}} {"feature": "Stocks", "speed": "medium", "animation": "down", "percent": true, "point": true, "logos": false, "chart": false, "title": true, "symbols": {"MSFT": {"current": 339.89, "opening": 339.29}, "GOOG": {"current": 2990.345, "opening": 2984.38}}}

Binary file not shown.

252
server.py
View File

@ -21,7 +21,9 @@ import numpy as np
#stock_ticker = StockTicker() #stock_ticker = StockTicker()
#print('API CALLER NOT STARTED') #print('API CALLER NOT STARTED')
api_caller = pexpect.spawn("sudo -E python3 api_caller.py") api_caller = pexpect.spawn("sudo -E python3 api_caller.py")
displaying_screensaver = False
screensaver_p = None
professional = False
command = 300 command = 300
tickerList = 0 tickerList = 0
@ -99,212 +101,21 @@ def index():
} }
return render_template('index.html', **templateData) return render_template('index.html', **templateData)
@app.route("/Runtime", methods=['POST'])
def Runtime():
command = request.form['text']
LastCommand = 'Change runtime'
return index()
@app.route("/Delay", methods=['POST'])
def Delay():
global DelayTime
DelayTime = request.form['text']
global LastCommand
LastCommand = 'Change Delay'
return index()
@app.route("/Speed", methods=['POST'])
def Speed():
global speed
speed = request.form['text']
ticker.sendline(speed)
f = open('csv/settings.csv', 'r')
CSV = csv.reader(f)
next(CSV)
for line in CSV:
_, brightness = line
f.close()
f = open('csv/settings.csv', 'w+')
f.write('speed,brightness\n')
f.write(str(speed) + ',' + brightness)
f.close()
global LastCommand
LastCommand = 'Change Speed'
return index()
@app.route("/brightness", methods=['PUT','POST'])
def brightness():
global brightness
data= request.data.decode('utf-8')
settings = json.loads(data)
print(settings)
brightness =settings['brightness']
print(str(int(brightness) - 1))
ticker.sendline(str(int(brightness) - 1))
f = open('csv/settings.csv', 'r')
CSV = csv.reader(f)
next(CSV)
for line in CSV:
speed, _ = line
f.close()
f = open('csv/settings.csv', 'w+')
f.write('speed,brightness\n')
f.write(str(speed) + ',' + str(brightness))
f.close()
global LastCommand
LastCommand = 'Change Brightness'
return index()
@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 index()
@app.route("/SetNews", methods=['POST'])
def SetNews():
text = request.form['text']
#args = ['q', 'sources', 'category', 'country']
args = ['q', 'category', 'country']
arg_dict = {}
lst = text.split(',')
try:
for i, arg in enumerate(args):
if len(lst[i])>0:
arg_dict[arg] = lst[i]
json.dump( arg_dict, open( "csv/news_settings.json", 'w+' ))
except Exception as e:
#reset settings
f = open( "csv/news_settings.json", 'w+' )
f.close()
api_caller.sendline('R')
return index()
@app.route("/SetWeather", methods=['POST'])
def SetWeather():
text = request.form['text']
#args = ['q', 'sources', 'category', 'country']
f = open( "csv/weather_location.txt", 'w+' )
f.write(text)
f.close()
api_caller.sendline('R')
return index()
@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:
filename = 'user_gif.gif'
fle.save(os.path.join(os.path.dirname(os.path.abspath(__file__)),os.path.join('display_images', filename)))
global LastCommand
LastCommand = 'Add a new logo file'
ticker.sendline('K')
ticker.sendline('G')
return hello()
return index()
@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:
filename = 'user_image.ppm'
fle.save(os.path.join(os.path.dirname(os.path.abspath(__file__)),os.path.join('display_images', filename)))
global LastCommand
LastCommand = 'Add a new logo file'
ticker.sendline('K')
ticker.sendline('I')
return hello()
return index()
@app.route("/Ticker", methods=['POST'])
def Ticker():
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 = 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'
return hello()
return index()
@app.route("/AddLogo", methods=['POST'])
def AddLogo():
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 = secure_filename(fle.filename)
fle.save(os.path.join(LOGO_FOLDER, filename))
global LastCommand
LastCommand = 'Add a new logo file'
return hello()
return index()
professional = False
@app.route("/start", methods = ['PUT', 'POST']) @app.route("/start", methods = ['PUT', 'POST'])
def start(): def start():
global displaying_screensaver
global ticker
global api_caller
if displaying_screensaver:
screensaver_p.close()
api_caller = pexpect.spawn("sudo -E python3 api_caller.py")
ticker = pexpect.spawn("sudo -E taskset -c 3 python3 stockTicker.py")
displaying_screensaver = False
print(professional) print(professional)
data = str(request.data) data = str(request.data)
@ -396,8 +207,37 @@ def upload():
return index() return index()
@app.route("/screensaver", methods = ['PUT', 'POST'])
def screensaver():
global displaying_screensaver
global ticker
global api_caller
global screensaver_p
api_caller.close()
ticker.close()
data = str(request.data)
if "Pulsating Colors" in data:
screensaver_p = pexpect.spawn("sudo -E python3 ./rpi-rgb-led-matrix/bindings/python/samples/pulsing-colors.py")
elif "Rotating Square" in data:
screensaver_p = pexpect.spawn("sudo -E python3 ./rpi-rgb-led-matrix/bindings/python/samples/rotating-block-generator.py")
elif "Pulsating brightness" in data:
screensaver_p = pexpect.spawn("sudo -E python3 ./rpi-rgb-led-matrix/bindings/python/samples/pulsing-brightness.py")
elif "Game of Life" in data:
screensaver_p = pexpect.spawn("sudo -E python3 game_of_life.py")
displaying_screensaver = True
return index()
def combine_dict(current_settings, input_symbols, current_key): def combine_dict(current_settings, input_symbols, current_key):
# removes keys not in input from current_settings[current_key] and adds keys not in current from input # removes keys not in input from current_settings[current_key] and adds keys not in current from input
@ -532,6 +372,12 @@ def save_message_settings(input_settings):
def stop(): def stop():
print('stop') print('stop')
ticker.sendline('K') ticker.sendline('K')
global displaying_screensaver
if displaying_screensaver:
screensaver.close()
api_caller = pexpect.spawn("sudo -E python3 api_caller.py")
ticker = pexpect.spawn("sudo -E taskset -c 3 python3 stockTicker.py")
displaying_screensaver = False
return index() return index()
@app.route("/shutdown") @app.route("/shutdown")

View File

@ -1269,6 +1269,12 @@ let inputAnimationBtn = document.getElementById("input-animation-btn");
inputAnimationBtn.addEventListener("click", () => { inputAnimationBtn.addEventListener("click", () => {
localStorage.setItem("inputAnimation", inputAnimation.value); localStorage.setItem("inputAnimation", inputAnimation.value);
fetch("/screensaver", {
method: "POST",
body: inputAnimation.value,
});
}); });
// scroll speed row two // scroll speed row two

View File

@ -2431,9 +2431,9 @@ class StockTicker():
#userSettings = ['crypto', 'stocks'] # these wil be read from csv, just for demo #userSettings = ['crypto', 'stocks'] # these wil be read from csv, just for demo
#userSettings = [ 'display_image', 'news'] # these wil be read from csv, just for demo #userSettings = [ 'display_image', 'news'] # these wil be read from csv, just for demo
userSettings = json.load(open('csv/display_settings.json')) userSettings = json.load(open('csv/display_settings.json'))
if 'Prof' in userSettings[0]: #if professional display if len(userSettings)>0 and 'Prof' in userSettings[0] : #if professional display
self.scrollProfessionalAnimated(userSettings) self.scrollProfessionalAnimated(userSettings)
else: elif len(userSettings)>0:
self.scrollFunctionsAnimated(userSettings, animation = 'down') self.scrollFunctionsAnimated(userSettings, animation = 'down')
elif msg == 'b': elif msg == 'b':

View File

@ -102,8 +102,10 @@
<div class="col-auto"> <div class="col-auto">
<select id="inputAnimation" class="form-select"> <select id="inputAnimation" class="form-select">
<option>Pulsating Colors</option> <option>Pulsating Colors</option>
<option>Random</option> <option>Rotating Square</option>
<option>Pulsating brightness</option> <option>Pulsating brightness</option>
<option>Game of Life</option>
<option>Sleep</option>
</select> </select>
</div> </div>
<div class="col-auto" id="input-animation-btn"> <div class="col-auto" id="input-animation-btn">
@ -241,19 +243,9 @@
id="available-features" id="available-features"
class="display-features-list text-dark" class="display-features-list text-dark"
> >
<li>Stocks</li> {% for f in not_displaying %}
<li>Crypto</li> <li>{{f}}</li>
<li>Forex</li> {% endfor%}
<li>Current Weather</li>
<li>Daily Forecast</li>
<li>News</li>
<li>Custom Images</li>
<li>Custom Messages</li>
<li>Cstom Gifs</li>
<li>Sports (Upcoming Games)</li>
<li>Sports (Live Games)</li>
<li>Sports (Past Games)</li>
<li>Sports (Team Stats)</li>
</ul> </ul>
</div> </div>
</div> </div>
@ -279,7 +271,11 @@
<ul <ul
id="display-format" id="display-format"
class="display-features-list text-dark" class="display-features-list text-dark"
></ul> >
{% for f in currently_displaying %}
<li>{{f}}</li>
{% endfor%}
</ul>
</div> </div>
</div> </div>
<div class="col-lg-2 col-md-2 col-sm-12"> <div class="col-lg-2 col-md-2 col-sm-12">