Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pOmelchenko - virtual_sdcard: add support subdirectories in menu and M'commands #68

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions docs/Config_Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.

```

Expand Down
2 changes: 1 addition & 1 deletion klippy/extras/display/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
7 changes: 4 additions & 3 deletions klippy/extras/virtual_sdcard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand All @@ -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)
Expand All @@ -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
Expand Down
85 changes: 85 additions & 0 deletions test/klippy/virtual_sdcard.cfg
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions test/klippy/virtual_sdcard.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
; Virtual SD card unit tests

DICTIONARY atmega2560.dict
CONFIG virtual_sdcard.cfg

G28
M20