Closed halfmanbear closed 6 months ago
noticed the code is present for some feedback after action in show_shutdown_screens
although this doesn't appear to work for me
putting self.display.show_shutdown_screens()
within a self._loop.create_task
allows it to run (probably because it's a async method?).
elif action == "shutdown_host":
logger.info("Shutting down Host")
self._loop.create_task(self.display.show_shutdown_screens())
self._loop.create_task(self._send_moonraker_request("machine.shutdown"))
It also appears using delay confuses the Nextion connector. It assumes the connection is lost as the display is storing and delaying the remaining serial instructions for 10s without responding.
async def show_shutdown_screens(self):
await self.write("cls 44637")
await self.write("xstr 8,220,256,20,1,54151,44637,1,1,1,\"Please wait while your printer\"")
await self.write("xstr 24,240,224,20,1,54151,44637,1,1,1,\"shuts down.\"")
await self.write("delay=10000")
await self.write("cls BLACK")
await self.write("xstr 24,220,224,20,1,54150,0,1,1,1,\"It's now safe to turn off\"")
await self.write("xstr 24,240,224,20,1,54150,0,1,1,1,\"your printer.\"")
It might be required to change bkcmd=3
to bkcmd=0
to allow for the lack of response or find a way of preventing it trying reconnect?
2024-03-31 11:42:05,936 - DEBUG - Navigating to shutdown_dialog
138 133
(24, 104, 248, 154)
2024-03-31 11:42:06,735 - INFO - Shutting down Host
Command "delay=10000" timeout.
Connection lost
Command "bkcmd=3" timeout.
Command "get sleep" timeout.
Connection lost
Command "bkcmd=3" timeout.
Command "get sleep" timeout.
Connection lost
2024-03-31 11:42:16,797 - INFO - Reconnected to Display
Task exception was never retrieved
future: <Task finished name='Task-226' coro=<DisplayController.display_event_handler() done, defined at /home/mks/display_connector/display.py:732> exception=AttributeError("'DisplayController' object has no attribute 'initialize_display'")>
Traceback (most recent call last):
File "/home/mks/display_connector/display.py", line 745, in display_event_handler
self.initialize_display()
^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'DisplayController' object has no attribute 'initialize_display'
The idea for this code was the following:
So the delay is there to communicate to the user that the host system should now be shut down and it's safe to cut power. The connector shouldn't attempt to reconnect because right after sending the commands it should be killed by the host shutting down. At least that is the idea :D I will take a look into why that is not correctly working.
The Elegoo loading spiral page after initiating host shutdown/reboot would be nice, just so the user is aware they have pressed it.