v.0.4.1 tryout.fonts weather
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import app.utils.colors as colors
|
||||
import app.display.fonts.fonts_utils as fonts_utils
|
||||
|
||||
from app.display.emoji.emoji_8x8 import emoji_8x8
|
||||
from app.display.emoji.emoji_16x16 import emoji_16x16
|
||||
|
||||
38
app/tryout/fonts.py
Normal file
38
app/tryout/fonts.py
Normal file
@@ -0,0 +1,38 @@
|
||||
from app.display.fonts.fonts_utils import align_font, font_height
|
||||
import app.utils.colors as colors
|
||||
|
||||
|
||||
def font_pretty(font):
|
||||
pretty_font = align_font(font)
|
||||
print(pretty_font)
|
||||
|
||||
|
||||
def fonts_check(display, font) -> None:
|
||||
display.clear()
|
||||
display.set_font(font)
|
||||
|
||||
height = font_height(font)
|
||||
|
||||
alphabet: str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||
char_line_1 = alphabet[:11]
|
||||
char_line_2 = alphabet[11:22]
|
||||
char_line_3 = alphabet[21:]
|
||||
num_line = '0123456789'
|
||||
|
||||
row = 0
|
||||
incr = height
|
||||
display.write_text(num_line, 0, row)
|
||||
row += incr
|
||||
display.write_text(char_line_1.upper(), 0, row, colors.YELLOW)
|
||||
# row += incr
|
||||
# display.write_text(char_line_2.upper(), 0, row, colors.YELLOW)
|
||||
# row += incr
|
||||
# display.write_text(char_line_3.upper(), 0, row, colors.YELLOW)
|
||||
row += incr
|
||||
display.write_text(char_line_1.lower(), 0, row, colors.YELLOW)
|
||||
# row += incr
|
||||
# display.write_text(char_line_2.lower(), 0, row, colors.YELLOW)
|
||||
# row += incr
|
||||
# display.write_text(char_line_3.lower(), 0, row, colors.YELLOW)
|
||||
row += incr
|
||||
display.write_text('!.,:;\'"-_+=*/\\()~°•', 0, row, colors.ORANGE)
|
||||
45
app/tryout/weather.py
Normal file
45
app/tryout/weather.py
Normal file
@@ -0,0 +1,45 @@
|
||||
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
|
||||
|
||||
|
||||
def weather_check(display, test_mode: bool = False):
|
||||
wlan = Wlan('WOKWI-Guest', '12345678')
|
||||
|
||||
try:
|
||||
display.clear()
|
||||
display.write_text('search wlan', 0, 0, color=colors.WHITE)
|
||||
|
||||
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])
|
||||
|
||||
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.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 += 3 * delta
|
||||
display.write_text('ready.', 30, ypos, color=colors.WHITE)
|
||||
|
||||
except OSError as e:
|
||||
print(f'Error: connection closed - {e}')
|
||||
finally:
|
||||
print('finally done.')
|
||||
Reference in New Issue
Block a user