v.0.4.5 rm font_height from utils
This commit is contained in:
@@ -2,5 +2,6 @@ from .font_3x5 import font_3x5
|
||||
from .font_5x7 import font_5x7
|
||||
from .font_8x8 import font_8x8
|
||||
from .font_16x16 import font_16x16
|
||||
from .fonts_utils import *
|
||||
|
||||
__all__ = ['font_3x5', 'font_5x7', 'font_8x8', 'font_16x16']
|
||||
|
||||
@@ -22,21 +22,6 @@ def char_width(char_matrix) -> int:
|
||||
return cw
|
||||
|
||||
|
||||
def font_height(font) -> int:
|
||||
"""Höhe in Pixeln eines Fonts
|
||||
|
||||
Args:
|
||||
font ([int]): der Font für den die Höhe bestimmt wird
|
||||
|
||||
Returns:
|
||||
int: Höhe in Pixeln
|
||||
"""
|
||||
|
||||
# wir nehmen uns ein Zeichen des Fonts
|
||||
# die Anzahl der Werte entspricht der Höhe in Pixeln
|
||||
return len(font['a'])
|
||||
|
||||
|
||||
def shift_letter_right(char, letter, debug=False) -> bool:
|
||||
"""Prüfe ob das Zeichen auch komplett nach rechts gezogen ist
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
from app.display.fonts.fonts_utils import align_font, font_height, char_width, screen_text
|
||||
from app.display.fonts.fonts_utils import align_font, screen_text
|
||||
from app.display.neopixel_64x64 import NeoPixel_64x64
|
||||
import app.utils as utils
|
||||
from app.utils import colors
|
||||
|
||||
|
||||
@@ -13,7 +12,7 @@ def fonts_check(display: NeoPixel_64x64, font, pretty=False) -> None:
|
||||
display.clear()
|
||||
display.set_font(font)
|
||||
|
||||
height = font_height(font)
|
||||
height = display.font_height
|
||||
|
||||
alphanum: str = ''.join(sorted(font.keys()))
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
from app.display.neopixel_64x64 import NeoPixel_64x64
|
||||
from app.web.wlan import Wlan
|
||||
import app.utils.colors as colors
|
||||
from app.display.fonts.font_3x5 import font_3x5
|
||||
from app.display.fonts.font_5x7 import font_5x7
|
||||
import app.display.fonts as fonts
|
||||
|
||||
|
||||
def weather_check(display, test_mode: bool = False):
|
||||
def weather_check(display: NeoPixel_64x64, test_mode: bool = False):
|
||||
wlan = Wlan('WOKWI-Guest', '12345678')
|
||||
|
||||
try:
|
||||
@@ -14,30 +14,34 @@ def weather_check(display, test_mode: bool = False):
|
||||
display.clear_row(0, effect=False)
|
||||
|
||||
display.clear()
|
||||
display.set_font(font_3x5)
|
||||
display.write_text('wlan connected', 0, 0, color=colors.RAINBOW[0])
|
||||
display.write_text('querying', 0, 8, color=colors.RAINBOW[1])
|
||||
display.write_text('weather data', 0, 16, color=colors.RAINBOW[2])
|
||||
display.set_font(fonts.font_3x5)
|
||||
ypos = 0
|
||||
display.write_text('wlan connected', 0, ypos, color=colors.RAINBOW[0])
|
||||
ypos += display.font_height + 1
|
||||
display.write_text('querying', 0, ypos, color=colors.RAINBOW[1])
|
||||
ypos += display.font_height + 1
|
||||
display.write_text('weather data', 0, ypos, color=colors.RAINBOW[2])
|
||||
|
||||
w_resp = wlan.actual_weather(lang='en', test_mode=test_mode)
|
||||
|
||||
display.clear()
|
||||
|
||||
delta = 8
|
||||
ypos = 0
|
||||
display.write_text(f'{str(w_resp.location.name).upper()}', 0, ypos, color=colors.RAINBOW[0])
|
||||
display.set_font(font_5x7)
|
||||
ypos += delta
|
||||
display.write_text(f'{str(w_resp.location.name)}', 0, ypos, color=colors.RAINBOW[0])
|
||||
ypos += display.font_height + 1
|
||||
display.set_font(fonts.font_8x8)
|
||||
display.write_text(f'{str(w_resp.current.temp_c)}°C', 0, ypos, color=colors.RAINBOW[1])
|
||||
ypos += delta
|
||||
display.write_text(f'{str(w_resp.current.condition.text)}°C', 0, ypos, color=colors.RAINBOW[1])
|
||||
ypos += delta
|
||||
display.write_text(f'upd:{str(w_resp.current.last_updated)[-5:]}', 0, ypos, color=colors.RAINBOW[2])
|
||||
ypos += delta
|
||||
display.write_text(f'cur:{str(w_resp.location.localtime)[-5:]}', 0, ypos, color=colors.RAINBOW[3])
|
||||
ypos += display.font_height + 1
|
||||
display.set_font(fonts.font_5x7)
|
||||
display.write_text(f'{str(w_resp.current.condition.text)}°C', 0, ypos, color=colors.RAINBOW[2])
|
||||
ypos += display.font_height + 1
|
||||
display.write_text(f'upd:{str(w_resp.current.last_updated)[-5:]}', 0, ypos, color=colors.RAINBOW[3])
|
||||
ypos += display.font_height + 1
|
||||
display.write_text(f'cur:{str(w_resp.location.localtime)[-5:]}', 0, ypos, color=colors.RAINBOW[4])
|
||||
|
||||
ypos += 3 * delta
|
||||
display.write_text('ready.', 30, ypos, color=colors.WHITE)
|
||||
ypos += 3 * (display.font_height + 1)
|
||||
|
||||
display.write_text('done.', 38, ypos, color=colors.WHITE)
|
||||
|
||||
except OSError as e:
|
||||
print(f'Error: connection closed - {e}')
|
||||
|
||||
4
main.py
4
main.py
@@ -8,6 +8,6 @@ if __name__ == '__main__':
|
||||
display = NeoPixel_64x64()
|
||||
|
||||
# tryout.emojis_check(display)
|
||||
tryout.fonts_check(display, fonts.font_8x8, pretty=False)
|
||||
# tryout.weather_check(display, test_mode=True)
|
||||
# tryout.fonts_check(display, fonts.font_8x8, pretty=False)
|
||||
tryout.weather_check(display, test_mode=False)
|
||||
utils.show_system_load()
|
||||
|
||||
@@ -6,50 +6,50 @@
|
||||
"lat": 53.6667,
|
||||
"lon": 10.2833,
|
||||
"tz_id": "Europe/Berlin",
|
||||
"localtime_epoch": 1761296721,
|
||||
"localtime": "2025-10-24 11:05"
|
||||
"localtime_epoch": 1761383733,
|
||||
"localtime": "2025-10-25 11:15"
|
||||
},
|
||||
"current": {
|
||||
"last_updated_epoch": 1761296400,
|
||||
"last_updated": "2025-10-24 11:00",
|
||||
"temp_c": 11.3,
|
||||
"temp_f": 52.3,
|
||||
"last_updated_epoch": 1761383700,
|
||||
"last_updated": "2025-10-25 11:15",
|
||||
"temp_c": 10.2,
|
||||
"temp_f": 50.4,
|
||||
"is_day": 1,
|
||||
"condition": {
|
||||
"text": "Overcast",
|
||||
"icon": "//cdn.weatherapi.com/weather/64x64/day/122.png",
|
||||
"code": 1009
|
||||
},
|
||||
"wind_mph": 21.3,
|
||||
"wind_kph": 34.2,
|
||||
"wind_degree": 233,
|
||||
"wind_dir": "SW",
|
||||
"pressure_mb": 989.0,
|
||||
"pressure_in": 29.21,
|
||||
"precip_mm": 0.01,
|
||||
"wind_mph": 17.7,
|
||||
"wind_kph": 28.4,
|
||||
"wind_degree": 208,
|
||||
"wind_dir": "SSW",
|
||||
"pressure_mb": 991.0,
|
||||
"pressure_in": 29.26,
|
||||
"precip_mm": 0.03,
|
||||
"precip_in": 0.0,
|
||||
"humidity": 76,
|
||||
"humidity": 82,
|
||||
"cloud": 100,
|
||||
"feelslike_c": 8.0,
|
||||
"feelslike_f": 46.4,
|
||||
"windchill_c": 5.9,
|
||||
"windchill_f": 42.7,
|
||||
"heatindex_c": 9.7,
|
||||
"heatindex_f": 49.5,
|
||||
"dewpoint_c": 5.0,
|
||||
"dewpoint_f": 41.0,
|
||||
"feelslike_c": 6.9,
|
||||
"feelslike_f": 44.5,
|
||||
"windchill_c": 5.4,
|
||||
"windchill_f": 41.8,
|
||||
"heatindex_c": 9.0,
|
||||
"heatindex_f": 48.3,
|
||||
"dewpoint_c": 6.3,
|
||||
"dewpoint_f": 43.4,
|
||||
"vis_km": 10.0,
|
||||
"vis_miles": 6.0,
|
||||
"uv": 0.1,
|
||||
"gust_mph": 30.5,
|
||||
"gust_kph": 49.1,
|
||||
"gust_mph": 25.3,
|
||||
"gust_kph": 40.7,
|
||||
"air_quality": {
|
||||
"co": 152.678,
|
||||
"no2": 13.578,
|
||||
"o3": 40.0,
|
||||
"so2": 2.678,
|
||||
"pm2_5": 6.678,
|
||||
"pm10": 7.078,
|
||||
"co": 155.678,
|
||||
"no2": 9.678,
|
||||
"o3": 45.0,
|
||||
"so2": 2.078,
|
||||
"pm2_5": 4.678,
|
||||
"pm10": 6.178,
|
||||
"us-epa-index": 1,
|
||||
"gb-defra-index": 1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user