v.0.2.2 NeoPixel_64x64.write_text wieder Pixel weise

This commit is contained in:
tiijay
2025-10-22 19:31:09 +02:00
parent b588339fb4
commit 2eea871408
3 changed files with 23 additions and 17 deletions

View File

@@ -136,7 +136,6 @@ class NeoPixel_64x64(NeoPixel):
char_data = self.selected_font[letter] char_data = self.selected_font[letter]
char_width = get_char_width(letter) char_width = get_char_width(letter)
print(letter)
for row in range(self.font_height): for row in range(self.font_height):
row_data = char_data[row] row_data = char_data[row]
@@ -351,11 +350,8 @@ class NeoPixel_64x64(NeoPixel):
err += dx err += dx
y1 += sy y1 += sy
def write_text(self, text: str, xpos: int, line_no: int, color=WHITE) -> None: def write_text(self, text: str, xpos: int, ypos: int, color=WHITE) -> None:
"""Textausgabe in Zeile line_no""" self.draw_text(text, xpos, ypos, color) # Pixel setzen
self.draw_text(
text, xpos * (self.font_width + 1), line_no * (self.font_height + 1), color
) # Pixel setzen
self.write() # und anzeigen self.write() # und anzeigen

View File

@@ -103,11 +103,11 @@ class Wlan:
weather_url = ( weather_url = (
f'https://api.weatherapi.com/v1/current.json?key={API_KEY}&q={city}&aqi=yes&lang={lang}' f'https://api.weatherapi.com/v1/current.json?key={API_KEY}&q={city}&aqi=yes&lang={lang}'
) )
print(f'query: {weather_url}')
if not test_mode: if not test_mode:
self.connect() self.connect()
print(f'query: {weather_url}')
r = urequests.get(weather_url) r = urequests.get(weather_url)
print('Status-Code:', r.status_code) print('Status-Code:', r.status_code)

30
main.py
View File

@@ -41,7 +41,7 @@ def emoji_test():
display.write() display.write()
def weather_check(): def weather_check(test_mode: bool = False):
wlan = Wlan('WOKWI-Guest', '12345678') wlan = Wlan('WOKWI-Guest', '12345678')
try: try:
@@ -58,7 +58,7 @@ def weather_check():
display.draw_text('weather data', 0, 16, color=RAINBOW[1]) display.draw_text('weather data', 0, 16, color=RAINBOW[1])
display.write() display.write()
w_resp = wlan.actual_weather(test_mode=True) w_resp = wlan.actual_weather(test_mode=test_mode)
display.clear() display.clear()
@@ -68,12 +68,22 @@ def weather_check():
# display.draw_text(f'cur: {str(w_resp.location.localtime)[-5:]}', 0, 24, color=RAINBOW[3]) # 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]) delta = 8
display.write_text(f'{str(w_resp.current.temp_c)}°C', 0, 1, color=RAINBOW[1]) ypos = 0
display.write_text(f'upd: {str(w_resp.current.last_updated)[-5:]}', 0, 2, color=RAINBOW[2]) display.write_text(f'{str(w_resp.location.name)}', 0, ypos, color=RAINBOW[0])
display.write_text(f'cur: {str(w_resp.location.localtime)[-5:]}', 0, 3, color=RAINBOW[3]) 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])
display.write_text('ready', 5, 7, color=WHITE) ypos += 3 * delta
display.write_text('ready.', 30, ypos, color=WHITE)
except OSError as e: except OSError as e:
print(f'Error: connection closed - {e}') print(f'Error: connection closed - {e}')
@@ -122,7 +132,7 @@ def bit_arrays():
if __name__ == '__main__': if __name__ == '__main__':
# emoji_test() # emoji_test()
# weather_check() weather_check(test_mode=False)
# font_5x7_test() # font_5x7_test()
bit_arrays() # bit_arrays()
show_system_load() # show_system_load()