diff --git a/README.md b/README.md index 42baca2ea..29184004e 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,8 @@ Features merged into the master branch: - [homing: sensorless minimum home distance](https://github.com/DangerKlippers/danger-klipper/pull/65) +- [virtual_sdcard: scanning of subdirectories](https://github.com/DangerKlippers/danger-klipper/pull/68) ([klipper#6327](https://github.com/Klipper3d/klipper/pull/6327)) + "Dangerous Klipper for dangerous users" Klipper is a 3d-Printer firmware. It combines the power of a general diff --git a/docs/Config_Reference.md b/docs/Config_Reference.md index 814ca3294..31aa013a3 100644 --- a/docs/Config_Reference.md +++ b/docs/Config_Reference.md @@ -82,14 +82,14 @@ A collection of DangerKlipper-specific system options # if False, will warn but allow klipper to still run error_on_unused_config_options: True -# If statistics should be logged +# If statistics should be logged # (helpful for keeping the log clean during development) -log_statistics: True +log_statistics: True # If the config file should be logged at startup -log_config_file_at_startup: True +log_config_file_at_startup: True -# If the bed mesh should be logged on startup +# If the bed mesh should be logged on startup # (helpful for keeping the log clean during development) log_bed_mesh_at_startup: True @@ -1521,6 +1521,8 @@ path: # be provided. #on_error_gcode: # A list of G-Code commands to execute when an error is reported. +#with_subdirs: False +# Enable scanning of subdirectories for the menu and for the M20 and M23 commands. The default is False. ``` diff --git a/klippy/extras/display/menu.py b/klippy/extras/display/menu.py index 7414fcdf7..da82e5bff 100644 --- a/klippy/extras/display/menu.py +++ b/klippy/extras/display/menu.py @@ -691,7 +691,7 @@ def _populate(self): super(MenuVSDList, self)._populate() sdcard = self.manager.printer.lookup_object("virtual_sdcard", None) if sdcard is not None: - files = sdcard.get_file_list() + files = sdcard.get_file_list(sdcard.with_subdirs) for fname, fsize in files: self.insert_item( self.manager.menuitem_from( diff --git a/klippy/extras/virtual_sdcard.py b/klippy/extras/virtual_sdcard.py index 0f8bc78d0..d61ea3d70 100644 --- a/klippy/extras/virtual_sdcard.py +++ b/klippy/extras/virtual_sdcard.py @@ -16,6 +16,7 @@ def __init__(self, config): ) # sdcard state sd = config.get("path") + self.with_subdirs = config.getboolean("with_subdirs", False) self.sdcard_dirname = os.path.normpath(os.path.expanduser(sd)) self.current_file = None self.file_position = self.file_size = 0 @@ -185,7 +186,7 @@ def cmd_SDCARD_PRINT_FILE(self, gcmd): def cmd_M20(self, gcmd): # List SD card - files = self.get_file_list() + files = self.get_file_list(self.with_subdirs) gcmd.respond_raw("Begin file list") for fname, fsize in files: gcmd.respond_raw("%s %d" % (fname, fsize)) @@ -203,7 +204,7 @@ def cmd_M23(self, gcmd): filename = gcmd.get_raw_command_parameters().strip() if filename.startswith("/"): filename = filename[1:] - self._load_file(gcmd, filename) + self._load_file(gcmd, filename, self.with_subdirs) def _load_file(self, gcmd, filename, check_subdirs=False): files = self.get_file_list(check_subdirs) @@ -221,7 +222,7 @@ def _load_file(self, gcmd, filename, check_subdirs=False): except: logging.exception("virtual_sdcard file open") raise gcmd.error("Unable to open file") - gcmd.respond_raw("File opened:%s Size:%d" % (filename, fsize)) + gcmd.respond_raw("File opened: %s Size: %d" % (filename, fsize)) gcmd.respond_raw("File selected") self.current_file = f self.file_position = 0 diff --git a/test/klippy/virtual_sdcard.cfg b/test/klippy/virtual_sdcard.cfg new file mode 100644 index 000000000..7a839f9c2 --- /dev/null +++ b/test/klippy/virtual_sdcard.cfg @@ -0,0 +1,85 @@ +# Test config for sdcard_loop +[virtual_sdcard] +path: test/klippy/sdcard_loop +with_subdirs: True + +[display_status] + +# Override to support unlimited belt size +# (homing Z simply resets its virtual position to 0.0) +[homing_override] +axes: xyz +set_position_x: 0 +set_position_y: 0 +set_position_z: 0 +gcode: + G92 X0 Y0 Z0 + + +[stepper_x] +step_pin: PF0 +dir_pin: PF1 +enable_pin: !PD7 +microsteps: 16 +rotation_distance: 40 +endstop_pin: ^PE5 +position_endstop: 0 +position_max: 200 +homing_speed: 50 + +[stepper_y] +step_pin: PF6 +dir_pin: !PF7 +enable_pin: !PF2 +microsteps: 16 +rotation_distance: 40 +endstop_pin: ^PJ1 +position_endstop: 0 +position_max: 200 +homing_speed: 50 + +[stepper_z] +step_pin: PL3 +dir_pin: PL1 +enable_pin: !PK0 +microsteps: 16 +rotation_distance: 8 +endstop_pin: ^PD3 +position_endstop: 0.5 +position_max: 200000000 + +[extruder] +step_pin: PA4 +dir_pin: PA6 +enable_pin: !PA2 +microsteps: 16 +rotation_distance: 33.5 +nozzle_diameter: 0.500 +filament_diameter: 3.500 +heater_pin: PB4 +sensor_type: EPCOS 100K B57560G104F +sensor_pin: PK5 +control: pid +pid_Kp: 22.2 +pid_Ki: 1.08 +pid_Kd: 114 +min_temp: 0 +max_temp: 210 + +[heater_bed] +heater_pin: PH5 +sensor_type: EPCOS 100K B57560G104F +sensor_pin: PK6 +control: watermark +min_temp: 0 +max_temp: 110 + +[mcu] +serial: /dev/ttyACM0 + +[printer] +kinematics: cartesian +max_velocity: 300 +max_accel: 3000 +max_z_velocity: 5 +max_z_accel: 100 diff --git a/test/klippy/virtual_sdcard.test b/test/klippy/virtual_sdcard.test new file mode 100644 index 000000000..2dc8bf484 --- /dev/null +++ b/test/klippy/virtual_sdcard.test @@ -0,0 +1,7 @@ +; Virtual SD card unit tests + +DICTIONARY atmega2560.dict +CONFIG virtual_sdcard.cfg + +G28 +M20