v.0.2.0 font_5x7_optimized
This commit is contained in:
66
main.py
66
main.py
@@ -1,7 +1,9 @@
|
||||
# from machine import Pin, ADC # type: ignore
|
||||
from app.display.fonts.font_5x7_opt import font_5x7
|
||||
from app.display.neopixel_64x64 import NeoPixel_64x64
|
||||
from app.utils.colors import GREEN, ORANGE, RAINBOW, RED, YELLOW, GOLD
|
||||
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
|
||||
|
||||
from app.web.wlan import Wlan
|
||||
|
||||
@@ -9,13 +11,11 @@ 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
|
||||
# time.sleep(0.1) # Wait for USB to become ready
|
||||
|
||||
print('Hello, Pi Pico!')
|
||||
display = NeoPixel_64x64()
|
||||
|
||||
|
||||
def emoji_test():
|
||||
display = NeoPixel_64x64()
|
||||
display.clear()
|
||||
# display.set_font(font_8x8)
|
||||
# display.show_hello()
|
||||
@@ -64,22 +64,64 @@ def weather_check():
|
||||
|
||||
display.clear()
|
||||
|
||||
display.draw_text(f'{str(w_resp.location.name)}', 0, 0, color=RAINBOW[0])
|
||||
display.draw_text(f'{str(w_resp.current.temp_c)}°C', 0, 8, color=RAINBOW[1])
|
||||
display.draw_text(f'upd: {str(w_resp.current.last_updated)[-5:]}', 0, 16, color=RAINBOW[2])
|
||||
display.draw_text(f'cur: {str(w_resp.location.localtime)[-5:]}', 0, 24, color=RAINBOW[3])
|
||||
# display.draw_text(f'{str(w_resp.location.name)}', 0, 0, color=RAINBOW[0])
|
||||
# display.draw_text(f'{str(w_resp.current.temp_c)}°C', 0, 8, color=RAINBOW[1])
|
||||
# display.draw_text(f'upd: {str(w_resp.current.last_updated)[-5:]}', 0, 16, color=RAINBOW[2])
|
||||
# display.draw_text(f'cur: {str(w_resp.location.localtime)[-5:]}', 0, 24, color=RAINBOW[3])
|
||||
# display.write()
|
||||
|
||||
display.write()
|
||||
display.write_text(f'{str(w_resp.location.name)}', 0, 0, color=RAINBOW[0])
|
||||
display.write_text(f'{str(w_resp.current.temp_c)}°C', 0, 1, color=RAINBOW[1])
|
||||
display.write_text(f'upd: {str(w_resp.current.last_updated)[-5:]}', 0, 2, color=RAINBOW[2])
|
||||
display.write_text(f'cur: {str(w_resp.location.localtime)[-5:]}', 0, 3, color=RAINBOW[3])
|
||||
|
||||
# display.clear_row(2)
|
||||
display.write_text('ready', 5, 7, color=WHITE)
|
||||
|
||||
print(w_resp)
|
||||
except OSError as e:
|
||||
print(f'Error: connection closed - {e}')
|
||||
finally:
|
||||
print('finally done.')
|
||||
|
||||
|
||||
def font_5x7_test() -> None:
|
||||
alphabet: str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||
char_line_1 = alphabet[:11]
|
||||
char_line_2 = alphabet[11:22]
|
||||
char_line_3 = alphabet[21:]
|
||||
num_line = '0123456789'
|
||||
|
||||
display.write_text(num_line, 0, 0)
|
||||
display.write_text(char_line_1.lower(), 0, 1, YELLOW)
|
||||
display.write_text(char_line_2.lower(), 0, 2, YELLOW)
|
||||
display.write_text(char_line_3.lower(), 0, 3, YELLOW)
|
||||
display.write_text(' !?.,:;\'"-_+=*/\\()', 0, 4, ORANGE)
|
||||
|
||||
|
||||
def bit_arrays():
|
||||
# def number_to_bitarray_msb(number):
|
||||
# """Convert 8-bit number to bit array (MSB first)"""
|
||||
# return [(number >> i) & 1 for i in range(7, -1, -1)]
|
||||
|
||||
# c = 'A'
|
||||
# print(c)
|
||||
# [print(utils.number_to_bitarray_msb(num)) for num in font_5x7[c]]
|
||||
char_row = '¶•'
|
||||
[display.write_text(c, 0, idx, YELLOW) for idx, c in enumerate(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__':
|
||||
# emoji_test()
|
||||
weather_check()
|
||||
# weather_check()
|
||||
# font_5x7_test()
|
||||
bit_arrays()
|
||||
|
||||
Reference in New Issue
Block a user