Skip to content

Commit

Permalink
1.15.0 update
Browse files Browse the repository at this point in the history
  • Loading branch information
s-victor committed Jul 11, 2024
1 parent 2ac6057 commit 7d618eb
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
4 changes: 2 additions & 2 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
WIP
2.15.0 (2024-07-11)
-----------------------------
* General
- Added new weather icon set in "images" folder.
- Added new weather icon set (by S.Victor) in "images" folder.

* Fuel Calculator
- Add Battery charge drain & regen (%) per lap to history log.
Expand Down
2 changes: 1 addition & 1 deletion tinypedal/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from PySide2.QtCore import qVersion


VERSION = "2.14.1"
VERSION = "2.15.0"
APP_NAME = "TinyPedal"
PLATFORM = platform.system()
APP_ICON = "images/icon.png"
Expand Down
6 changes: 4 additions & 2 deletions tinypedal/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@
MAX_MINUTES = 9999
MIN_TEMPERATURE = -273
DEFAULT = [(MAX_MINUTES, -1, MIN_TEMPERATURE, -1)]
WEATHER_NODES = ("START", "NODE_25", "NODE_50", "NODE_75", "FINISH")


def forecast_rf2(data: dict) -> list[tuple]:
"""Get value from weather forecast dictionary, output 5 api data + 5 padding data"""
weather_nodes = ("START", "NODE_25", "NODE_50", "NODE_75", "FINISH")
try:
output = [
(round(index * 0.2, 1), # 0 - fraction start time
data[weather]["WNV_SKY"]["currentValue"], # 1 - sky type index
round(data[weather]["WNV_TEMPERATURE"]["currentValue"]), # 2 - temperature
round(data[weather]["WNV_RAIN_CHANCE"]["currentValue"]), # 3 - rain chance
) for index, weather in enumerate(weather_nodes)]
) for index, weather in enumerate(WEATHER_NODES)]
output.extend(DEFAULT * 5)
except (KeyError, TypeError):
output = DEFAULT * 10
Expand Down Expand Up @@ -65,6 +65,8 @@ def sky_type_correction(sky_type, raininess):
10 Overcast & Storm
"""
if raininess <= 0:
if sky_type > 4:
return 4
return sky_type
if 0 < raininess <= 10:
return 5
Expand Down
19 changes: 13 additions & 6 deletions tinypedal/widget/weather_forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,14 @@ def __init__(self, config):
text_def = "n/a"
bar_padx = round(self.wcfg["font_size"] * self.wcfg["bar_padding"]) * 2
bar_gap = self.wcfg["bar_gap"]
bar_width = font_m.width * 4 + bar_padx
self.icon_size = int(max(self.wcfg["icon_size"], 16) * 0.5) * 2
bar_width = max(font_m.width * 4 + bar_padx, self.icon_size)

# Base style
self.setStyleSheet(
f"font-family: {self.wcfg['font_name']};"
f"font-size: {self.wcfg['font_size']}px;"
f"font-weight: {self.wcfg['font_weight']};"
f"min-width: {bar_width}px;"
)

# Create layout
Expand Down Expand Up @@ -84,6 +83,7 @@ def __init__(self, config):
bar_style_time = (
f"color: {self.wcfg['font_color_estimated_time']};"
f"background: {self.wcfg['bkg_color_estimated_time']};"
f"min-width: {bar_width}px;"
)
self.bar_time_0 = QLabel("now")
self.bar_time_0.setAlignment(Qt.AlignCenter)
Expand Down Expand Up @@ -115,6 +115,7 @@ def __init__(self, config):
bar_style_temp = (
f"color: {self.wcfg['font_color_ambient_temperature']};"
f"background: {self.wcfg['bkg_color_ambient_temperature']};"
f"min-width: {bar_width}px;"
)
self.bar_temp_0 = QLabel(text_def)
self.bar_temp_0.setAlignment(Qt.AlignCenter)
Expand Down Expand Up @@ -143,8 +144,11 @@ def __init__(self, config):

# Rain chance
if self.wcfg["show_rain_chance_bar"]:
bar_style_rain = f"background: {self.wcfg['rain_chance_bar_bkg_color']};"
self.bar_rain_width = max(bar_width, self.icon_size)
bar_style_rain = (
f"background: {self.wcfg['rain_chance_bar_bkg_color']};"
f"min-width: {bar_width}px;"
)
self.bar_rain_width = bar_width
self.bar_rain_height = max(self.wcfg["rain_chance_bar_height"], 1)
self.pixmap_rainchance = QPixmap(self.bar_rain_width, self.bar_rain_height)

Expand Down Expand Up @@ -174,7 +178,10 @@ def __init__(self, config):
layout_4.addWidget(self.bar_rain_4, 3, 0)

# Forecast icon
bar_style_icon = f"background: {self.wcfg['bkg_color']};"
bar_style_icon = (
f"background: {self.wcfg['bkg_color']};"
f"min-width: {bar_width}px;"
)
self.bar_icon_0 = QLabel()
self.bar_icon_0.setAlignment(Qt.AlignCenter)
self.bar_icon_0.setStyleSheet(bar_style_icon)
Expand Down Expand Up @@ -295,7 +302,7 @@ def update_weather_forecast_restapi(self):
def update_estimated_time(self, curr, last, index):
"""Estimated time"""
if curr != last:
if curr >= wthr.MAX_MINUTES:
if curr >= wthr.MAX_MINUTES or curr < 0:
time_text = "n/a"
elif curr >= 60:
time_text = f"{curr / 60:.1f}h"
Expand Down

0 comments on commit 7d618eb

Please sign in to comment.