mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-24 00:03:42 +05:00
feat: implement get-id feature
Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
|
|
||||||
import textwrap
|
import textwrap
|
||||||
|
import time
|
||||||
|
|
||||||
from components.klipper_firmware.flash_options import (
|
from components.klipper_firmware.flash_options import (
|
||||||
FlashOptions,
|
FlashOptions,
|
||||||
@@ -131,9 +132,10 @@ class KlipperFlashCommandMenu(BaseMenu):
|
|||||||
# noinspection PyUnusedLocal
|
# noinspection PyUnusedLocal
|
||||||
# noinspection PyMethodMayBeStatic
|
# noinspection PyMethodMayBeStatic
|
||||||
class KlipperSelectMcuConnectionMenu(BaseMenu):
|
class KlipperSelectMcuConnectionMenu(BaseMenu):
|
||||||
def __init__(self, previous_menu: BaseMenu):
|
def __init__(self, previous_menu: BaseMenu, standalone: bool = False):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
|
self.__standalone = standalone
|
||||||
self.previous_menu: BaseMenu = previous_menu
|
self.previous_menu: BaseMenu = previous_menu
|
||||||
self.options = {
|
self.options = {
|
||||||
"1": self.select_usb,
|
"1": self.select_usb,
|
||||||
@@ -193,8 +195,16 @@ class KlipperSelectMcuConnectionMenu(BaseMenu):
|
|||||||
if len(self.flash_options.mcu_list) < 1:
|
if len(self.flash_options.mcu_list) < 1:
|
||||||
Logger.print_warn("No MCUs found!")
|
Logger.print_warn("No MCUs found!")
|
||||||
Logger.print_warn("Make sure they are connected and repeat this step.")
|
Logger.print_warn("Make sure they are connected and repeat this step.")
|
||||||
else:
|
|
||||||
self.goto_next_menu()
|
# if standalone is True, we only display the MCUs to the user and return
|
||||||
|
if self.__standalone and len(self.flash_options.mcu_list) > 0:
|
||||||
|
Logger.print_ok("The following MCUs were found:", prefix=False)
|
||||||
|
for i, mcu in enumerate(self.flash_options.mcu_list):
|
||||||
|
print(f" ● MCU #{i}: {COLOR_CYAN}{mcu}{RESET_FORMAT}")
|
||||||
|
time.sleep(3)
|
||||||
|
return
|
||||||
|
|
||||||
|
self.goto_next_menu()
|
||||||
|
|
||||||
def goto_next_menu(self, **kwargs):
|
def goto_next_menu(self, **kwargs):
|
||||||
KlipperSelectMcuIdMenu(previous_menu=self).run()
|
KlipperSelectMcuIdMenu(previous_menu=self).run()
|
||||||
|
|||||||
@@ -58,4 +58,4 @@ class AdvancedMenu(BaseMenu):
|
|||||||
KlipperFlashMethodMenu(previous_menu=self).run()
|
KlipperFlashMethodMenu(previous_menu=self).run()
|
||||||
|
|
||||||
def get_id(self, **kwargs):
|
def get_id(self, **kwargs):
|
||||||
KlipperSelectMcuConnectionMenu(previous_menu=self).run()
|
KlipperSelectMcuConnectionMenu(previous_menu=self, standalone=True).run()
|
||||||
|
|||||||
Reference in New Issue
Block a user