sports feature improvements and real time brightness control

This commit is contained in:
Neythen 2021-10-25 19:42:00 +01:00
parent a1c9c3ba8f
commit e0c8cf8c1e
19 changed files with 75 additions and 35 deletions

View File

@ -1 +1 @@
{"feature": "Stocks", "speed": "medium", "animation": "down", "percent": false, "point": true, "logos": true, "chart": false, "title": true, "symbols": {"NEO,USD": {"current": 43.42, "24hr_change": -3.963839231643678}, "BTC,USD": {"current": 49343, "24hr_change": 0.902025932223419}, "ETH,BTC": {"current": 0.06930671, "24hr_change": -1.7367682270496585}, "ADA,GBP": {"current": 1.62, "24hr_change": -3.549646457710461}}}
{"feature": "Stocks", "speed": "medium", "animation": "down", "percent": false, "point": true, "logos": true, "chart": false, "title": true, "symbols": {"NEO,USD": {"current": 44.52, "24hr_change": 3.358636475756234}, "BTC,USD": {"current": 63102, "24hr_change": 5.213527329930638}, "ETH,BTC": {"current": 0.06669059, "24hr_change": 5.704625383993851}, "ADA,GBP": {"current": 1.57, "24hr_change": 3.0217237241282655}}}

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": "few clouds", "temp": 4.6, "min_temp": 4.6, "max_temp": 11.07, "feels_like": 2.79, "humidity": 73, "clouds": 16, "wind_speed": 2.11, "wind_direction": 120, "visibility": 10000, "uv": 0, "rain_chance": 0}, "Beijing": {"main_weather": "Clouds", "description": "overcast clouds", "temp": 11.63, "min_temp": 11.63, "max_temp": 14.76, "feels_like": 11.28, "humidity": 93, "clouds": 100, "wind_speed": 1.1, "wind_direction": 9, "visibility": 10000, "uv": 0, "rain_chance": 0.84}, "Tokyo": {"main_weather": "Clouds", "description": "few clouds", "temp": 21.42, "min_temp": 21.42, "max_temp": 27.62, "feels_like": 21.73, "humidity": 81, "clouds": 20, "wind_speed": 0.45, "wind_direction": 291, "visibility": 10000, "uv": 0, "rain_chance": 0}, "London": {"main_weather": "Clouds", "description": "overcast clouds", "temp": 12.23, "min_temp": 11.77, "max_temp": 16.42, "feels_like": 11.91, "humidity": 92, "clouds": 91, "wind_speed": 4.01, "wind_direction": 181, "visibility": 10000, "uv": 0, "rain_chance": 0}}, "current_weather": true}
{"feature": "Current Weather", "speed": "medium", "animation": "continuous", "temp": "celsius", "wind_speed": "miles/sec", "colour": "white", "city_colour": "yellow", "title": true, "locations": {"Moscow": {"main_weather": "Clear", "description": "clear sky", "temp": 0.33, "min_temp": -0.89, "max_temp": 3.23, "feels_like": -4.45, "humidity": 76, "clouds": 10, "wind_speed": 4.9, "wind_direction": 236, "visibility": 10000, "uv": 0, "rain_chance": 0}, "Tokyo": {"main_weather": "Mist", "description": "mist", "temp": 12.31, "min_temp": 12.31, "max_temp": 21.05, "feels_like": 12.02, "humidity": 93, "clouds": 75, "wind_speed": 0.89, "wind_direction": 301, "visibility": 4500, "uv": 0, "rain_chance": 1}, "Beijing": {"main_weather": "Clouds", "description": "overcast clouds", "temp": 10.98, "min_temp": 10.98, "max_temp": 20.74, "feels_like": 10.38, "humidity": 86, "clouds": 100, "wind_speed": 1.48, "wind_direction": 23, "visibility": 10000, "uv": 0, "rain_chance": 0}, "London": {"main_weather": "Clouds", "description": "few clouds", "temp": 11.3, "min_temp": 10.99, "max_temp": 16.36, "feels_like": 10.73, "humidity": 86, "clouds": 16, "wind_speed": 2.95, "wind_direction": 245, "visibility": 10000, "uv": 0, "rain_chance": 0.36}}, "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": "broken clouds", "min_temp": 4.6, "max_temp": 11.07}, {"main_weather": "Clouds", "description": "overcast clouds", "min_temp": 4.88, "max_temp": 11.53}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 4.11, "max_temp": 11.44}, {"main_weather": "Clouds", "description": "scattered clouds", "min_temp": 3.34, "max_temp": 10.75}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 3.99, "max_temp": 11.32}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 4.57, "max_temp": 11.12}, {"main_weather": "Clouds", "description": "broken clouds", "min_temp": 3.94, "max_temp": 9.68}, {"main_weather": "Clouds", "description": "broken clouds", "min_temp": 5.99, "max_temp": 10.77}], "Beijing": [{"main_weather": "Rain", "description": "light rain", "min_temp": 11.63, "max_temp": 14.76}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 10.22, "max_temp": 12.33}, {"main_weather": "Clouds", "description": "overcast clouds", "min_temp": 10.29, "max_temp": 17.61}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 11.53, "max_temp": 19.55}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 13.15, "max_temp": 19.6}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 14.29, "max_temp": 19.8}, {"main_weather": "Clouds", "description": "overcast clouds", "min_temp": 13.08, "max_temp": 18.87}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 11.42, "max_temp": 19.6}], "Tokyo": [{"main_weather": "Clear", "description": "clear sky", "min_temp": 21.42, "max_temp": 27.62}, {"main_weather": "Clouds", "description": "few clouds", "min_temp": 21.12, "max_temp": 26.36}, {"main_weather": "Clouds", "description": "overcast clouds", "min_temp": 20.3, "max_temp": 22.81}, {"main_weather": "Rain", "description": "light rain", "min_temp": 21.31, "max_temp": 26.99}, {"main_weather": "Rain", "description": "light rain", "min_temp": 20.53, "max_temp": 23.98}, {"main_weather": "Rain", "description": "light rain", "min_temp": 19.15, "max_temp": 24.43}, {"main_weather": "Clouds", "description": "few clouds", "min_temp": 21.26, "max_temp": 26.41}, {"main_weather": "Rain", "description": "light rain", "min_temp": 22.4, "max_temp": 26.43}], "London": [{"main_weather": "Rain", "description": "light rain", "min_temp": 11.77, "max_temp": 16.42}, {"main_weather": "Rain", "description": "heavy intensity rain", "min_temp": 10.89, "max_temp": 13.15}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 9.54, "max_temp": 15.37}, {"main_weather": "Clouds", "description": "overcast clouds", "min_temp": 10.64, "max_temp": 17.51}, {"main_weather": "Clouds", "description": "overcast clouds", "min_temp": 13.65, "max_temp": 17.56}, {"main_weather": "Clouds", "description": "broken clouds", "min_temp": 14.4, "max_temp": 18.88}, {"main_weather": "Clouds", "description": "scattered clouds", "min_temp": 12.83, "max_temp": 18.66}, {"main_weather": "Clouds", "description": "broken clouds", "min_temp": 12.03, "max_temp": 19.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": {"Moscow": [{"main_weather": "Clouds", "description": "overcast clouds", "min_temp": -0.89, "max_temp": 3.23}, {"main_weather": "Clouds", "description": "overcast clouds", "min_temp": 0.73, "max_temp": 6.01}, {"main_weather": "Rain", "description": "light rain", "min_temp": 3.15, "max_temp": 6.05}, {"main_weather": "Rain", "description": "light rain", "min_temp": 4.26, "max_temp": 8.05}, {"main_weather": "Rain", "description": "light rain", "min_temp": 4.88, "max_temp": 7.46}, {"main_weather": "Clouds", "description": "scattered clouds", "min_temp": 5.89, "max_temp": 11.6}, {"main_weather": "Clouds", "description": "broken clouds", "min_temp": 6.19, "max_temp": 10.56}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 5.15, "max_temp": 9.73}], "Tokyo": [{"main_weather": "Rain", "description": "heavy intensity rain", "min_temp": 12.31, "max_temp": 21.05}, {"main_weather": "Rain", "description": "light rain", "min_temp": 15.31, "max_temp": 16.7}, {"main_weather": "Rain", "description": "light rain", "min_temp": 14.72, "max_temp": 21.8}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 14.58, "max_temp": 19.65}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 13.65, "max_temp": 19.04}, {"main_weather": "Rain", "description": "light rain", "min_temp": 16.29, "max_temp": 18.42}, {"main_weather": "Rain", "description": "light rain", "min_temp": 17.11, "max_temp": 20.85}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 14.56, "max_temp": 17.01}], "Beijing": [{"main_weather": "Clear", "description": "clear sky", "min_temp": 10.98, "max_temp": 20.74}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 11.29, "max_temp": 19.34}, {"main_weather": "Clouds", "description": "overcast clouds", "min_temp": 11.78, "max_temp": 17.42}, {"main_weather": "Clouds", "description": "scattered clouds", "min_temp": 12.14, "max_temp": 18.5}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 12.12, "max_temp": 19.71}, {"main_weather": "Rain", "description": "light rain", "min_temp": 10.77, "max_temp": 14.76}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 9.36, "max_temp": 14.99}, {"main_weather": "Clouds", "description": "overcast clouds", "min_temp": 11.72, "max_temp": 12.52}], "London": [{"main_weather": "Rain", "description": "light rain", "min_temp": 10.99, "max_temp": 16.36}, {"main_weather": "Clouds", "description": "overcast clouds", "min_temp": 9.86, "max_temp": 16.98}, {"main_weather": "Clouds", "description": "overcast clouds", "min_temp": 14.64, "max_temp": 17.65}, {"main_weather": "Clouds", "description": "few clouds", "min_temp": 12.86, "max_temp": 16.89}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 11.27, "max_temp": 14.85}, {"main_weather": "Rain", "description": "light rain", "min_temp": 9.47, "max_temp": 13.41}, {"main_weather": "Rain", "description": "light rain", "min_temp": 11.02, "max_temp": 14.31}, {"main_weather": "Rain", "description": "light rain", "min_temp": 7.06, "max_temp": 10.92}]}, "current_weather": true}

View File

@ -1 +1 @@
["Forex Prof", "Stocks Prof", "Crypto Prof"]
["Sports (Upcoming Games)"]

View File

@ -0,0 +1 @@
{"stocks": "25/10/2021 14:39:52", "crypto": "25/10/2021 14:31:38", "news": "25/10/2021 14:31:41", "weather": "25/10/2021 14:31:39", "forex": "25/10/2021 20:31:45", "sports": "25/10/2021 14:31:42"}

View File

@ -1 +1 @@
{"feature": "Sports (Team Stats)", "speed": "medium", "animation": "continuous", "title": true, "leagues": {"Premier League": [{"name": "Man City", "wins": "27", "loss": "6", "draw": "5", "played": "38", "standing": "1", "points": "86"}, {"name": "Man United", "wins": "21", "loss": "6", "draw": "11", "played": "38", "standing": "2", "points": "74"}, {"name": "Liverpool", "wins": "20", "loss": "9", "draw": "9", "played": "38", "standing": "3", "points": "69"}, {"name": "Chelsea", "wins": "19", "loss": "9", "draw": "10", "played": "38", "standing": "4", "points": "67"}, {"name": "Leicester", "wins": "20", "loss": "12", "draw": "6", "played": "38", "standing": "5", "points": "66"}, {"name": "West Ham", "wins": "19", "loss": "11", "draw": "8", "played": "38", "standing": "6", "points": "65"}, {"name": "Tottenham", "wins": "18", "loss": "12", "draw": "8", "played": "38", "standing": "7", "points": "62"}, {"name": "Arsenal", "wins": "18", "loss": "13", "draw": "7", "played": "38", "standing": "8", "points": "61"}, {"name": "Leeds", "wins": "18", "loss": "15", "draw": "5", "played": "38", "standing": "9", "points": "59"}, {"name": "Everton", "wins": "17", "loss": "13", "draw": "8", "played": "38", "standing": "10", "points": "59"}, {"name": "Aston Villa", "wins": "16", "loss": "15", "draw": "7", "played": "38", "standing": "11", "points": "55"}, {"name": "Newcastle", "wins": "12", "loss": "17", "draw": "9", "played": "38", "standing": "12", "points": "45"}, {"name": "Wolves", "wins": "12", "loss": "17", "draw": "9", "played": "38", "standing": "13", "points": "45"}, {"name": "Crystal Palace", "wins": "12", "loss": "18", "draw": "8", "played": "38", "standing": "14", "points": "44"}, {"name": "Southampton", "wins": "12", "loss": "19", "draw": "7", "played": "38", "standing": "15", "points": "43"}, {"name": "Brighton", "wins": "9", "loss": "15", "draw": "14", "played": "38", "standing": "16", "points": "41"}, {"name": "Burnley", "wins": "10", "loss": "19", "draw": "9", "played": "38", "standing": "17", "points": "39"}, {"name": "Fulham", "wins": "5", "loss": "20", "draw": "13", "played": "38", "standing": "18", "points": "28"}, {"name": "West Brom", "wins": "5", "loss": "22", "draw": "11", "played": "38", "standing": "19", "points": "26"}, {"name": "Sheffield United", "wins": "7", "loss": "29", "draw": "2", "played": "38", "standing": "20", "points": "23"}]}}
{"feature": "Sports (Team Stats)", "speed": "medium", "animation": "down", "title": true, "leagues": {"Premier League": [{"name": "Man City", "wins": "27", "loss": "6", "draw": "5", "played": "38", "standing": "1", "points": "86"}, {"name": "Man United", "wins": "21", "loss": "6", "draw": "11", "played": "38", "standing": "2", "points": "74"}, {"name": "Liverpool", "wins": "20", "loss": "9", "draw": "9", "played": "38", "standing": "3", "points": "69"}, {"name": "Chelsea", "wins": "19", "loss": "9", "draw": "10", "played": "38", "standing": "4", "points": "67"}, {"name": "Leicester", "wins": "20", "loss": "12", "draw": "6", "played": "38", "standing": "5", "points": "66"}, {"name": "West Ham", "wins": "19", "loss": "11", "draw": "8", "played": "38", "standing": "6", "points": "65"}, {"name": "Tottenham", "wins": "18", "loss": "12", "draw": "8", "played": "38", "standing": "7", "points": "62"}, {"name": "Arsenal", "wins": "18", "loss": "13", "draw": "7", "played": "38", "standing": "8", "points": "61"}, {"name": "Leeds", "wins": "18", "loss": "15", "draw": "5", "played": "38", "standing": "9", "points": "59"}, {"name": "Everton", "wins": "17", "loss": "13", "draw": "8", "played": "38", "standing": "10", "points": "59"}, {"name": "Aston Villa", "wins": "16", "loss": "15", "draw": "7", "played": "38", "standing": "11", "points": "55"}, {"name": "Newcastle", "wins": "12", "loss": "17", "draw": "9", "played": "38", "standing": "12", "points": "45"}, {"name": "Wolves", "wins": "12", "loss": "17", "draw": "9", "played": "38", "standing": "13", "points": "45"}, {"name": "Crystal Palace", "wins": "12", "loss": "18", "draw": "8", "played": "38", "standing": "14", "points": "44"}, {"name": "Southampton", "wins": "12", "loss": "19", "draw": "7", "played": "38", "standing": "15", "points": "43"}, {"name": "Brighton", "wins": "9", "loss": "15", "draw": "14", "played": "38", "standing": "16", "points": "41"}, {"name": "Burnley", "wins": "10", "loss": "19", "draw": "9", "played": "38", "standing": "17", "points": "39"}, {"name": "Fulham", "wins": "5", "loss": "20", "draw": "13", "played": "38", "standing": "18", "points": "28"}, {"name": "West Brom", "wins": "5", "loss": "22", "draw": "11", "played": "38", "standing": "19", "points": "26"}, {"name": "Sheffield United", "wins": "7", "loss": "29", "draw": "2", "played": "38", "standing": "20", "points": "23"}]}}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,2 +1,2 @@
speed,brightness
f,0
f,7
1 speed brightness
2 f 0 7

View File

@ -1 +1 @@
{"feature": "Stocks", "speed": "medium", "animation": "down", "percent": false, "point": true, "logos": false, "chart": false, "title": true, "symbols": {"MSFT": {"current": 282.63, "opening": 287.28}, "GOOG": {"current": 2665.2, "opening": 2713.99}}}
{"feature": "Stocks", "speed": "medium", "animation": "down", "percent": false, "point": true, "logos": false, "chart": false, "title": true, "symbols": {"MSFT": {"current": 308.65, "opening": 309.22}, "GOOG": {"current": 2771, "opening": 2776}}}

File diff suppressed because one or more lines are too long

View File

@ -19,8 +19,8 @@ from multiprocessing import Process
from subprocess import Popen, PIPE
import numpy as np
#stock_ticker = StockTicker()
print('API CALLER NOT STARTED')
#api_caller = pexpect.spawn("sudo -E python3 api_caller.py")
#print('API CALLER NOT STARTED')
api_caller = pexpect.spawn("sudo -E python3 api_caller.py")
command = 300
@ -139,12 +139,16 @@ def Speed():
LastCommand = 'Change Speed'
return index()
@app.route("/Brightness", methods=['POST'])
def Brightness():
@app.route("/brightness", methods=['PUT','POST'])
def brightness():
global brightness
brightness = int(request.form['text'])-1
ticker.sendline(str(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)

View File

@ -559,18 +559,27 @@ var startButton = document.getElementById("start-btn");
// start the display
startButton.addEventListener("click", () => {
var HTML = document.getElementById('display-format').innerHTML;
console.log('pressed');
console.log(HTML);
fetch("/start", {
method:"PUT",
body:JSON.stringify(HTML)
});
});
var brightnessButton = document.getElementById("brightness-btn");
// start the display
brightnessButton.addEventListener("click", () => {
let brightness = document.querySelectorAll(".brightness-text")[0].value;
console.log(brightness);
fetch("/brightness", {
method:"PUT",
body:JSON.stringify({'brightness':brightness})
});
});
var shutdownButton = document.getElementById("shutdown-btn");
shutdownButton.addEventListener("click", () => {

View File

@ -55,7 +55,10 @@ class StockTicker():
options.parallel = 1
options.hardware_mapping = 'adafruit-hat' # If you have an Adafruit HAT: 'adafruit-hat'
options.gpio_slowdown = 4
options.brightness = 100
self.matrix = RGBMatrix(options = options)
print(dir(self.matrix))
#sys.exit()
self.points = True # display crypto change in points or percent
self.functions = {'Stocks': self.getStockImage, 'Crypto': self.getCryptoImage, 'Forex': self.getForexImage,
@ -1438,11 +1441,21 @@ class StockTicker():
for league in leagues:
x_offset = 0
img = Image.new('RGB', (10000, 32))
league_info = json.load(open('csv/sports/{}/{}_games.json'.format(league, time), 'r'))
try:
league_logo = Image.open('logos/sports/league_logos/{}.png'.format(league)).convert('RGB')
img.paste(league_logo, (x_offset,0))
x_offset += league_logo.size[0] +self.blank.size[0]
except:
pass
small_font = ImageFont.load("./fonts/5x7.pil")
med_font = ImageFont.load("./fonts/7x14B.pil")
@ -1455,7 +1468,7 @@ class StockTicker():
buff_size = 25
x_offset = 0
for match in league_info[-15:]:
@ -1552,11 +1565,12 @@ class StockTicker():
x_offset += away_logo.size[0]
x_offset += buff_size
img = img.crop((0,0,x_offset ,32))
imgs.append(img)
return self.stitchImage([title_img, img])
return self.stitchImage(imgs)
def getLeagueTableImage(self, league = False):
@ -1575,9 +1589,17 @@ class StockTicker():
for league in leagues:
x_offset = 0
img = Image.new('RGB', (10000, 32))
league_logo = Image.open('logos/sports/league_logos/{}.png'.format(league)).convert('RGB')
img.paste(league_logo, (x_offset,0))
x_offset += league_logo.size[0] +self.blank.size[0]
team_info = leagues_info[league]
small_font = ImageFont.load("./fonts/5x7.pil")
@ -1589,7 +1611,7 @@ class StockTicker():
sports_info = self.readSportsCSV(league) # gets colour and symbol info etc from csv
buff_size = 20
x_offset = 0
for team in team_info:
try:
@ -1625,8 +1647,9 @@ class StockTicker():
img = img.crop((0,0,x_offset ,32))
imgs.append(img)
return self.stitchImage([title_img, img])
return self.stitchImage(imgs)
def getTodayWeatherImage(self):
all_settings = json.load(open('csv/current_weather.json', 'r'))
@ -2337,7 +2360,9 @@ class StockTicker():
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 = float(msg)*10
self.matrix.brightness = self.brightness
elif msg == 'T':# text
@ -2406,7 +2431,8 @@ if __name__ == '__main__':
stock_ticker.setImage(start_image)
time.sleep(1)
stock_ticker.resetMatrix()
stock_ticker.resetMatrix()
#stock_ticker.getLeagueImage('NHL', 'future')
#

View File

@ -73,13 +73,13 @@
<input
type="text"
id="inputText"
class="form-control"
class="form-control brightness-text"
aria-describedby="TextHelpInline"
/>
</div>
<div class="col-auto">
<a href="#" class="btn set-btn">Set</a>
<a href="#" class="btn set-btn" id="brightness-btn">Set</a>
</div>
</div>