percent and point change displayed simultaneously

This commit is contained in:
Neythen 2021-10-28 19:44:44 +01:00
parent f8c5a19c45
commit eb284137a8
14 changed files with 67 additions and 50 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": 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}}}
{"feature": "Stocks", "speed": "medium", "animation": "down", "percent": true, "point": true, "logos": true, "chart": false, "title": true, "symbols": {"NEO,USD": {"current": 41.53, "24hr_change": 3.0530667588098535}, "BTC,USD": {"current": 61214, "24hr_change": 3.5007811771288146}, "ETH,BTC": {"current": 0.0688888, "24hr_change": 4.981732790736668}, "ADA,GBP": {"current": 1.46, "24hr_change": 1.6355039771734323}}}

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": "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}
{"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": "overcast clouds", "temp": 10.43, "min_temp": 10.43, "max_temp": 18.87, "feels_like": 9.33, "humidity": 69, "clouds": 95, "wind_speed": 1.17, "wind_direction": 39, "visibility": 10000, "uv": 0, "rain_chance": 0}, "Tokyo": {"main_weather": "Clouds", "description": "few clouds", "temp": 13.65, "min_temp": 13.65, "max_temp": 19.19, "feels_like": 12.4, "humidity": 51, "clouds": 20, "wind_speed": 2.24, "wind_direction": 15, "visibility": 10000, "uv": 0, "rain_chance": 0}, "London": {"main_weather": "Clouds", "description": "overcast clouds", "temp": 13.16, "min_temp": 12.37, "max_temp": 15.93, "feels_like": 12.72, "humidity": 84, "clouds": 100, "wind_speed": 4.12, "wind_direction": 160, "visibility": 10000, "uv": 0, "rain_chance": 0}, "Moscow": {"main_weather": "Clouds", "description": "overcast clouds", "temp": 7.03, "min_temp": 4.95, "max_temp": 9.93, "feels_like": 4.45, "humidity": 80, "clouds": 100, "wind_speed": 3.81, "wind_direction": 353, "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": -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}
{"feature": "Current Weather", "speed": "medium", "animation": "continuous", "temp": "celsius", "wind_speed": "miles/sec", "colour": "white", "city_colour": "yellow", "title": true, "locations": {"Beijing": [{"main_weather": "Clear", "description": "clear sky", "min_temp": 10.43, "max_temp": 18.87}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 11.79, "max_temp": 20.3}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 11.75, "max_temp": 17.06}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 9.83, "max_temp": 15.21}, {"main_weather": "Clouds", "description": "broken clouds", "min_temp": 10.02, "max_temp": 16.08}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 10.22, "max_temp": 17.99}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 11.18, "max_temp": 19.34}, {"main_weather": "Clouds", "description": "overcast clouds", "min_temp": 12.1, "max_temp": 15.76}], "Tokyo": [{"main_weather": "Clouds", "description": "scattered clouds", "min_temp": 13.65, "max_temp": 19.19}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 13.79, "max_temp": 18.73}, {"main_weather": "Clouds", "description": "overcast clouds", "min_temp": 16.17, "max_temp": 20.03}, {"main_weather": "Rain", "description": "light rain", "min_temp": 16.41, "max_temp": 20.18}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 16.73, "max_temp": 19.89}, {"main_weather": "Rain", "description": "light rain", "min_temp": 15.76, "max_temp": 20.23}, {"main_weather": "Rain", "description": "light rain", "min_temp": 15.45, "max_temp": 17.57}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 14.26, "max_temp": 20.42}], "London": [{"main_weather": "Clouds", "description": "few clouds", "min_temp": 12.37, "max_temp": 15.93}, {"main_weather": "Rain", "description": "light rain", "min_temp": 11.81, "max_temp": 14.55}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 10.27, "max_temp": 13.92}, {"main_weather": "Rain", "description": "moderate rain", "min_temp": 8.95, "max_temp": 13.13}, {"main_weather": "Clouds", "description": "scattered clouds", "min_temp": 7.76, "max_temp": 11.97}, {"main_weather": "Rain", "description": "light rain", "min_temp": 7.48, "max_temp": 11.03}, {"main_weather": "Clouds", "description": "scattered clouds", "min_temp": 5.69, "max_temp": 10.83}, {"main_weather": "Clouds", "description": "scattered clouds", "min_temp": 5.58, "max_temp": 10.35}], "Moscow": [{"main_weather": "Rain", "description": "light rain", "min_temp": 4.95, "max_temp": 9.93}, {"main_weather": "Clouds", "description": "overcast clouds", "min_temp": 5.4, "max_temp": 8.06}, {"main_weather": "Clouds", "description": "scattered clouds", "min_temp": 7.55, "max_temp": 12.8}, {"main_weather": "Clouds", "description": "few clouds", "min_temp": 6.22, "max_temp": 11.06}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 5.43, "max_temp": 10.23}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 4.38, "max_temp": 9.17}, {"main_weather": "Clear", "description": "clear sky", "min_temp": 3.2, "max_temp": 8.07}, {"main_weather": "Rain", "description": "light rain", "min_temp": 6.67, "max_temp": 8.85}]}, "current_weather": true}

View File

@ -1 +1 @@
["Sports (Upcoming Games)"]
["Forex"]

View File

@ -1 +1 @@
{"feature": "Stocks", "speed": "medium", "animation": "down", "percent": false, "point": true, "logos": false, "chart": false, "title": true, "symbols": {"NZD,GBP": {"current": 1.9471, "24hr_change": 0.0029000000000001247}, "CAD,USD": {"current": 1.271, "24hr_change": 0.0033999999999998476}}}
{"feature": "Stocks", "speed": "medium", "animation": "down", "percent": false, "point": true, "logos": false, "chart": false, "title": true, "symbols": {"NZD,GBP": {"current": 1.9136, "24hr_change": -0.0041999999999999815}, "CAD,USD": {"current": 1.2357, "24hr_change": -0.005099999999999882}}}

View File

@ -1 +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"}
{"stocks": "28/10/2021 14:43:29", "crypto": "28/10/2021 14:36:22", "news": "28/10/2021 14:36:24", "weather": "28/10/2021 14:36:22", "forex": "28/10/2021 20:36:26", "sports": "28/10/2021 14:36:24"}

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 +1 @@
{"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}}}
{"feature": "Stocks", "speed": "medium", "animation": "down", "percent": true, "point": true, "logos": false, "chart": false, "title": true, "symbols": {"MSFT": {"current": 323.7, "opening": 324.325}, "GOOG": {"current": 2923.335, "opening": 2947.07}}}

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -805,8 +805,8 @@ class StockTicker():
return width,height
#Draw Ticker, current and change onto one image
def textToImage(self, TICKER, CURRENT, CHANGE, ARROW, font = ImageFont.load("./fonts/10x20.pil")):
def textToImage(self, TICKER, CURRENT, ARROW, percent_change = False, point_change = False, font = ImageFont.load("./fonts/10x20.pil")):
text_width_current, text_height = self.get_text_dimensions(CURRENT, font)
img = Image.new('RGB', (text_width_current +100 , 32))
@ -818,9 +818,18 @@ class StockTicker():
img.paste(ARROW, ((text_width_current + 9),18))
d.text(((text_width_current+29), 16), CHANGE, fill=self.greenORred, font=font)
if point_change:
d.text(((text_width_current+29), 16), point_change, fill=self.greenORred, font=font)
if percent_change:
d.text(((text_width_current+29), 14 - text_height), percent_change, fill=self.greenORred, font=font)
text_width_change, text_height = self.get_text_dimensions(CHANGE, font)
if percent_change:
text_width_change, text_height = self.get_text_dimensions(percent_change, font)
elif point_change:
text_width_change, text_height = self.get_text_dimensions(point_change, font)
else:
text_width_change=0
newWidth = text_width_current + text_width_change +30
@ -887,23 +896,25 @@ class StockTicker():
for i, cb in enumerate(coin_bases):
ticker, base = cb.split(',')
current = coin_info[cb]["current"]
change = coin_info[cb]["24hr_change"]
current = '%.2f' % current
current = float(coin_info[cb]["current"])
change = float(coin_info[cb]["24hr_change"])
percent_change = '%.2f' % abs(change) +'%'
point_change = '%.2f' % abs(change/100 * current)
arrow, change = self.getArrow(change)
if all_crypto_settings["point"]:
# convert percent to points
change = change/100 * current
change = '%.2f' % change
else:
change = '%.2f' % change +'%'
current = '%.2f' % current
if not all_crypto_settings['percent']:
percent_change = False
if not all_crypto_settings['point']:
point_change = False
midFrame = self.textToImage(ticker + '(' + base + ')', current, change, arrow) #IMAGE THE TEXT
midFrame = self.textToImage(ticker + '(' + base + ')', current, arrow, percent_change, point_change) #IMAGE THE TEXT
if all_crypto_settings['logos']:
try:
@ -1013,25 +1024,24 @@ class StockTicker():
for i, sb in enumerate(symbol_bases):
symbol, base = sb.split(',')
current = forex_settings[sb]['current']
change = forex_settings[sb]['24hr_change']
current = float(forex_settings[sb]['current'])
change = float(forex_settings[sb]['24hr_change'])
percent_change = '%.2f' % abs(change) +'%'
point_change = '%.2f' % abs(change/100 * current)
arrow, change = self.getArrow(change)
if all_forex_settings["percent"]:
# convert percent to points
change = change/current * 100
change = '%.2f' % change + '%'
else:
change = '%.6f' % change
current = '%.3f' % current
midFrame = self.textToImage(symbol+ '(' + base + ')', current, change, arrow) #IMAGE THE TEXT
midFrame = self.textToImage(symbol+ '(' + base + ')', current, arrow, percent_change, point_change) #IMAGE THE TEXT
if all_forex_settings['logos']:
@ -1159,20 +1169,26 @@ class StockTicker():
change = float(info['current'])-float(info['opening']) #TEXT
ticker = symbol #TEXT
percent_change = '%.2f' % abs(float(change)/float(info['current'])*100) + '%'
point_change = '%.2f' % abs(change)
arrow, change = self.getArrow(change)
if all_stocks_settings["percent"]:
change = change/float(info['current']) * 100
change = '%.2f' % change + '%'
else:
change = '%.2f' % change
print(percent_change, point_change)
current = '%.2f' % float(info['current']) #TEXT
midFrame = self.textToImage(ticker, current, change, arrow) #IMAGE THE TEXT
if not all_stocks_settings['percent']:
percent_change = False
if not all_stocks_settings['point']:
point_change = False
midFrame = self.textToImage(ticker, current, arrow, percent_change, point_change) #IMAGE THE TEXT
if all_stocks_settings['logos']:
try:
@ -2431,9 +2447,10 @@ if __name__ == '__main__':
stock_ticker.setImage(start_image)
time.sleep(1)
stock_ticker.resetMatrix()
stock_ticker.resetMatrix()
#stock_ticker.getLeagueImage('NHL', 'future')
#stock_ticker.getLeagueImage('NHL', 'future')
stock_ticker.getCryptoImage()
#
#stock_ticker.process_msg('G')