127 lines
3.6 KiB
Python
127 lines
3.6 KiB
Python
# from machine import Pin, ADC # type: ignore
|
|
from app.display.fonts.font_3x5 import font_3x5
|
|
from app.display.fonts.font_5x7 import font_5x7
|
|
from app.display.fonts.fonts_utils import align_font, font_height
|
|
from app.display.neopixel_64x64 import NeoPixel_64x64
|
|
from app.utils.colors import BLUE, GREEN, ORANGE, RAINBOW, RED, WHITE, YELLOW, GOLD
|
|
from app.utils.system_load import show_system_load
|
|
import app.utils.utils as utils
|
|
import app.display.fonts.fonts_utils as fonts_utils
|
|
from app.tryout.emojis import emojis_check
|
|
|
|
from app.web.wlan import Wlan
|
|
|
|
from app.display.emoji.emoji_8x8 import emoji_8x8
|
|
from app.display.emoji.emoji_16x16 import emoji_16x16
|
|
from app.display.fonts.font_8x8 import font_8x8
|
|
from app.display.fonts.font_16x16 import font_16x16
|
|
|
|
display = NeoPixel_64x64()
|
|
|
|
|
|
def weather_check(test_mode: bool = False):
|
|
wlan = Wlan('WOKWI-Guest', '12345678')
|
|
|
|
try:
|
|
display.clear()
|
|
display.write_text('search wlan', 0, 0, color=WHITE)
|
|
|
|
display.clear_row(0, effect=False)
|
|
|
|
display.clear()
|
|
display.set_font(font_3x5)
|
|
display.write_text('wlan connected', 0, 0, color=RAINBOW[0])
|
|
display.write_text('querying', 0, 8, color=RAINBOW[1])
|
|
display.write_text('weather data', 0, 16, color=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=RAINBOW[0])
|
|
display.set_font(font_5x7)
|
|
ypos += delta
|
|
display.write_text(f'{str(w_resp.current.temp_c)}°C', 0, ypos, color=RAINBOW[1])
|
|
ypos += delta
|
|
display.write_text(f'{str(w_resp.current.condition.text)}°C', 0, ypos, color=RAINBOW[1])
|
|
ypos += delta
|
|
display.write_text(f'upd:{str(w_resp.current.last_updated)[-5:]}', 0, ypos, color=RAINBOW[2])
|
|
ypos += delta
|
|
display.write_text(f'cur:{str(w_resp.location.localtime)[-5:]}', 0, ypos, color=RAINBOW[3])
|
|
|
|
ypos += 3 * delta
|
|
display.write_text('ready.', 30, ypos, color=WHITE)
|
|
|
|
except OSError as e:
|
|
print(f'Error: connection closed - {e}')
|
|
finally:
|
|
print('finally done.')
|
|
|
|
|
|
def font_test(font) -> None:
|
|
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, YELLOW)
|
|
# row += incr
|
|
# display.write_text(char_line_2.upper(), 0, row, YELLOW)
|
|
# row += incr
|
|
# display.write_text(char_line_3.upper(), 0, row, YELLOW)
|
|
row += incr
|
|
display.write_text(char_line_1.lower(), 0, row, YELLOW)
|
|
# row += incr
|
|
# display.write_text(char_line_2.lower(), 0, row, YELLOW)
|
|
# row += incr
|
|
# display.write_text(char_line_3.lower(), 0, row, YELLOW)
|
|
row += incr
|
|
display.write_text('!.,:;\'"-_+=*/\\()~°•', 0, row, ORANGE)
|
|
|
|
|
|
def font_pretty(font):
|
|
pretty_font = align_font(font)
|
|
print(pretty_font)
|
|
|
|
|
|
def bit_arrays():
|
|
display.set_font(font_3x5)
|
|
# c = 'A'
|
|
# print(c)
|
|
# [print(utils.number_to_bitarray_msb(num)) for num in font_5x7[c]]
|
|
char_row = '1'
|
|
[display.write_text(c, 0, idx, YELLOW) for idx, c in enumerate(char_row)]
|
|
|
|
fonts_utils.shift_letter_right(char_row, font_5x7[char_row])
|
|
|
|
# display.write_text(char_row, 0, len(char_row), ORANGE)
|
|
# display.write_text('Kiel', 0, 7, BLUE)
|
|
|
|
|
|
# c = 'I'
|
|
# print(c)
|
|
# [print(number_to_bitarray_msb(num)) for num in font_5x7[c]]
|
|
# c = 'J'
|
|
# print(c)
|
|
# [print(number_to_bitarray_msb(num)) for num in font_5x7[c]]
|
|
|
|
|
|
if __name__ == '__main__':
|
|
emojis_check(display)
|
|
# font_test(font_16x16)
|
|
# bit_arrays()
|
|
# show_system_load()
|
|
font_pretty(emoji_16x16)
|
|
# weather_check(test_mode=True)
|