More Screen updates, icon and screens correction
This commit is contained in:
@@ -5,7 +5,7 @@ import framebuf
|
|||||||
|
|
||||||
# Icon and bitmaps
|
# Icon and bitmaps
|
||||||
image_weather_frost_bits = bytearray(b'\x01\x00\x13\x901\x18s\x9c\x09 \x05@S\x94\xfe\xfeS\x94\x05@\x09 s\x9c1\x18\x13\x90\x01\x00\x00\x00')
|
image_weather_frost_bits = bytearray(b'\x01\x00\x13\x901\x18s\x9c\x09 \x05@S\x94\xfe\xfeS\x94\x05@\x09 s\x9c1\x18\x13\x90\x01\x00\x00\x00')
|
||||||
image_Alert_bits = bytearray(b'\x08\x00\x1c\x00\x14\x006\x006\x00\x7f\x00w\x00\xff\x80')
|
image_Alert_bits = bytearray(b'\xf7\x80\xe3\x80\xeb\x80\xc9\x80\xc9\x80\x80\x80\x88\x80\x00\x00')
|
||||||
image_CoolHiSmall_bits = bytearray(b'\x1f\xff\xc0?\xff\xe0\x7f\xff\xf0\xff\xdf\xf8\xffW\xf8\xfd\x8d\xf8\xf9\xdc\xf8\xfe\xdb\xf8\xf7Wx\xfb\x8e\xf8\xe0\x008\xfb\x8e\xf8\xf7Wx\xfe\xdb\xf8\xf9\xdc\xf8\xfd\x8d\xf8\xffW\xf8\xff\xdf\xf8\x7f\xff\xf0?\xff\xe0\x1f\xff\xc0')
|
image_CoolHiSmall_bits = bytearray(b'\x1f\xff\xc0?\xff\xe0\x7f\xff\xf0\xff\xdf\xf8\xffW\xf8\xfd\x8d\xf8\xf9\xdc\xf8\xfe\xdb\xf8\xf7Wx\xfb\x8e\xf8\xe0\x008\xfb\x8e\xf8\xf7Wx\xfe\xdb\xf8\xf9\xdc\xf8\xfd\x8d\xf8\xffW\xf8\xff\xdf\xf8\x7f\xff\xf0?\xff\xe0\x1f\xff\xc0')
|
||||||
image_CoolLoSmall_bits = bytearray(b'\x1f\xff\xc0 \x00 @\x00\x10\x80 \x08\x80\xa8\x08\x82r\x08\x86#\x08\x81$\x08\x88\xa8\x88\x84q\x08\x9f\xff\xc8\x84q\x08\x88\xa8\x88\x81$\x08\x86#\x08\x82r\x08\x80\xa8\x08\x80 \x08@\x00\x10 \x00 \x1f\xff\xc0')
|
image_CoolLoSmall_bits = bytearray(b'\x1f\xff\xc0 \x00 @\x00\x10\x80 \x08\x80\xa8\x08\x82r\x08\x86#\x08\x81$\x08\x88\xa8\x88\x84q\x08\x9f\xff\xc8\x84q\x08\x88\xa8\x88\x81$\x08\x86#\x08\x82r\x08\x80\xa8\x08\x80 \x08@\x00\x10 \x00 \x1f\xff\xc0')
|
||||||
image_music_sound_wave_bits = bytearray(b'\x00\x00\x00\x02\x00\x00\x02 \x00\x02 \x00\x02 \x00\x0a(\x00\x0a\xa8\x00*\xa8\x00\xaa\xaa\x80\x0a\xaa\x00\x0a\xa8\x00\x0a \x00\x02 \x00\x02 \x00\x02\x00\x00\x00\x00\x00')
|
image_music_sound_wave_bits = bytearray(b'\x00\x00\x00\x02\x00\x00\x02 \x00\x02 \x00\x02 \x00\x0a(\x00\x0a\xa8\x00*\xa8\x00\xaa\xaa\x80\x0a\xaa\x00\x0a\xa8\x00\x0a \x00\x02 \x00\x02 \x00\x02\x00\x00\x00\x00\x00')
|
||||||
@@ -26,7 +26,7 @@ CHARACTER_HEIGHT = 7
|
|||||||
|
|
||||||
class MicrowaveScreen:
|
class MicrowaveScreen:
|
||||||
# Used for animation
|
# Used for animation
|
||||||
lastUpdateTime = 0
|
# lastUpdateTime = 0 # Not used right now
|
||||||
|
|
||||||
def __init__(self, display):
|
def __init__(self, display):
|
||||||
self.display = display
|
self.display = display
|
||||||
@@ -73,11 +73,11 @@ class MicrowaveScreen:
|
|||||||
def update(self, cooking_state: CookingState | None, defrost_mode: bool = False):
|
def update(self, cooking_state: CookingState | None, defrost_mode: bool = False):
|
||||||
self.flick()
|
self.flick()
|
||||||
|
|
||||||
self.lastUpdateTime = time.time()
|
# self.lastUpdateTime = time.time() # Not Used right now
|
||||||
|
|
||||||
if cooking_state: # Is currently cooking
|
|
||||||
# self.h_centered_text(cooking_state.state, 28, 1)
|
|
||||||
|
|
||||||
|
if not cooking_state or cooking_state.state == CookingStates.IDLE: # Is not currently cooking
|
||||||
|
self.h_centered_text("Ready !", 28, 1)
|
||||||
|
else:
|
||||||
# Screen center
|
# Screen center
|
||||||
if cooking_state.state == CookingStates.STIRRING_REQUIRED:
|
if cooking_state.state == CookingStates.STIRRING_REQUIRED:
|
||||||
self._message("Pls Stir", True)
|
self._message("Pls Stir", True)
|
||||||
@@ -85,8 +85,7 @@ class MicrowaveScreen:
|
|||||||
self._message("Alert !", True)
|
self._message("Alert !", True)
|
||||||
elif cooking_state.state == CookingStates.DONE:
|
elif cooking_state.state == CookingStates.DONE:
|
||||||
self._message("Done !", False)
|
self._message("Done !", False)
|
||||||
else:
|
else: # Progress bar
|
||||||
# Progress bar
|
|
||||||
elapsed_time = cooking_state.get_elapsed_time()
|
elapsed_time = cooking_state.get_elapsed_time()
|
||||||
estimated_progress = elapsed_time / (elapsed_time + cooking_state.estimated_remaining_time)
|
estimated_progress = elapsed_time / (elapsed_time + cooking_state.estimated_remaining_time)
|
||||||
self._progressBar(estimated_progress, 21, 25)
|
self._progressBar(estimated_progress, 21, 25)
|
||||||
@@ -94,7 +93,7 @@ class MicrowaveScreen:
|
|||||||
# Estimated remaining time
|
# Estimated remaining time
|
||||||
if cooking_state.paused:
|
if cooking_state.paused:
|
||||||
self.h_centered_text("Paused", 40, 1)
|
self.h_centered_text("Paused", 40, 1)
|
||||||
else:
|
elif cooking_state.state != CookingStates.DONE:
|
||||||
remaining_time = cooking_state.estimated_remaining_time
|
remaining_time = cooking_state.estimated_remaining_time
|
||||||
minutes = remaining_time // 60
|
minutes = remaining_time // 60
|
||||||
seconds = remaining_time % 60
|
seconds = remaining_time % 60
|
||||||
@@ -111,9 +110,6 @@ class MicrowaveScreen:
|
|||||||
if cooking_state.power_level is not None:
|
if cooking_state.power_level is not None:
|
||||||
self.display.blit(fb_image_music_sound_wave_bits, 74, 2)
|
self.display.blit(fb_image_music_sound_wave_bits, 74, 2)
|
||||||
self.display.text(f"{cooking_state.power_level}W", 92, 6, 1)
|
self.display.text(f"{cooking_state.power_level}W", 92, 6, 1)
|
||||||
else:
|
|
||||||
self.h_centered_text("Ready !", 28, 1)
|
|
||||||
|
|
||||||
if defrost_mode:
|
if defrost_mode:
|
||||||
self.display.blit(fb_image_CoolHiSmall_bits, 2, 2)
|
self.display.blit(fb_image_CoolHiSmall_bits, 2, 2)
|
||||||
else:
|
else:
|
||||||
@@ -124,9 +120,10 @@ class MicrowaveScreen:
|
|||||||
|
|
||||||
def _message(self, text, alert):
|
def _message(self, text, alert):
|
||||||
self.display.fill_rect(0, 27, self.width, CHARACTER_HEIGHT + 4, 1)
|
self.display.fill_rect(0, 27, self.width, CHARACTER_HEIGHT + 4, 1)
|
||||||
if alert and self.lastUpdateTime % 2000 < 1000:
|
if alert:
|
||||||
self.display.blit(fb_image_Alert_bits, 10, 27)
|
self.display.blit(fb_image_Alert_bits, 10, 29)
|
||||||
self.h_centered_text(text, 28, 0)
|
self.display.blit(fb_image_Alert_bits, self.width - 10, 29)
|
||||||
|
self.h_centered_text(text, 29, 0)
|
||||||
|
|
||||||
def message(self, text, alert):
|
def message(self, text, alert):
|
||||||
self.flick()
|
self.flick()
|
||||||
|
|||||||
@@ -116,6 +116,8 @@ def cooking_state_on_state_change(state):
|
|||||||
if lora:
|
if lora:
|
||||||
lora.send_reliable({"id": DEVICE_ID, "new_cooking_state": state.state})
|
lora.send_reliable({"id": DEVICE_ID, "new_cooking_state": state.state})
|
||||||
|
|
||||||
|
microwave_screen.update(cooking_state, defrost_mode)
|
||||||
|
|
||||||
def cooking_state_on_refresh(state):
|
def cooking_state_on_refresh(state):
|
||||||
# Update OLED display
|
# Update OLED display
|
||||||
if microwave_screen:
|
if microwave_screen:
|
||||||
|
|||||||
Reference in New Issue
Block a user