Skip to content

Commit

Permalink
additonal LED range checks, fixed but for new 'home on startup' feature
Browse files Browse the repository at this point in the history
  • Loading branch information
moggieuk committed Dec 10, 2024
1 parent 312e0a4 commit d06b59d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion extras/mmu/mmu.py
Original file line number Diff line number Diff line change
Expand Up @@ -1224,7 +1224,7 @@ def cmd_MMU_BOOTUP(self, gcmd):
if self.startup_reset_ttg_map:
self._reset_ttg_map()

if self.startup_home_if_unloaded and self.check_if_not_calibrated(self.CALIBRATED_SELECTOR) and self.filament_pos == self.FILAMENT_POS_UNLOADED:
if self.startup_home_if_unloaded and not self.check_if_not_calibrated(self.CALIBRATED_SELECTOR) and self.filament_pos == self.FILAMENT_POS_UNLOADED:
self.home(0)

if self.log_startup_status:
Expand Down
7 changes: 6 additions & 1 deletion extras/mmu_leds.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ def __init__(self, config):
logging.warning("MMU: Happy Hare LED support cannot be loaded. Led strip '%s' not defined" % led_strip)
else:
try:
_ = config.get_printer().load_object(config, led_strip.replace(':', ' '))
l = config.get_printer().load_object(config, led_strip.replace(':', ' '))
led_count = l.led_helper.led_count
MmuLeds.led_strip = led_strip
except Exception as e:
raise config.error("Unable to load LED strip '%s': %s" % (led_strip, str(e)))
Expand All @@ -45,11 +46,15 @@ def __init__(self, config):
MmuLeds.chains[segment] = None
if segment == 'status':
sidx = config.getint("%s_index" % segment, None)
if sidx and not (1 <= sidx <= led_count):
raise config.error("Status LED must be between 1 and %s" % led_count)
MmuLeds.chains[segment] = [sidx] if sidx else None
else:
led_range = config.get("%s_range" % segment, None)
if led_range:
first, last = map(int, led_range.split('-'))
if not (1 <= first <= led_count and 1 <= last <= led_count):
raise config.error("Range of '%s' LEDS must be between 1 and %s" % (segment, led_count))
if abs(first - last) + 1 != MmuLeds.num_gates:
raise config.error("Range of '%s' LEDS doesn't match num_gates (%s)" % (segment, MmuLeds.num_gates))
MmuLeds.chains[segment] = list(range(first, last + 1) if first <= last else range(first, last - 1, -1))
Expand Down

0 comments on commit d06b59d

Please sign in to comment.