Skip to content

Commit

Permalink
experimental
Browse files Browse the repository at this point in the history
  • Loading branch information
bwnance committed Oct 11, 2023
1 parent 9da363e commit 10c0176
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 12 deletions.
4 changes: 3 additions & 1 deletion klippy/extras/bed_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,9 @@ def __init__(self, config):

def handle_connect(self):
self.toolhead = self.printer.lookup_object("toolhead")
self.bmc.print_generated_points(logging.info)
self.debug_options = self.printer.lookup_object("debug_options")
if self.debug_options.log_bed_mesh_at_startup:
self.bmc.print_generated_points(logging.info)

def set_mesh(self, mesh):
if mesh is not None and self.fade_end != self.FADE_DISABLE:
Expand Down
14 changes: 14 additions & 0 deletions klippy/extras/debug_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class DebugOptions:
def __init__(self, config):
self.log_statistics = config.getboolean("log_statistics", True)
self.log_config_file_at_startup = config.getboolean(
"log_config_file_at_startup", True
)
self.log_bed_mesh_at_startup = config.getboolean(
"log_bed_mesh_at_startup", True
)
self.log_shutdown_info = config.getboolean("log_shutdown_info", True)


def load_config_prefix(config):
return DebugOptions(config)
4 changes: 2 additions & 2 deletions klippy/extras/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ def get_status(self, eventtime):
class PrinterStats:
def __init__(self, config):
self.printer = config.get_printer()
self.debug_options = self.printer.lookup_object("debug_options")
reactor = self.printer.get_reactor()
self.log_stats = config.getboolean("log_stats", True)
self.stats_timer = reactor.register_timer(self.generate_stats)
self.stats_cb = []
self.printer.register_event_handler("klippy:ready", self.handle_ready)
Expand All @@ -79,7 +79,7 @@ def handle_ready(self):

def generate_stats(self, eventtime):
stats = [cb(eventtime) for cb in self.stats_cb]
if max([s[0] for s in stats]) and self.log_stats:
if max([s[0] for s in stats]) and self.debug_options.log_statistics:
logging.info(
"Stats %.1f: %s", eventtime, " ".join([s[1] for s in stats])
)
Expand Down
6 changes: 5 additions & 1 deletion klippy/klippy.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,11 @@ def load_object(self, config, section, default=configfile.sentinel):
def _read_config(self):
self.objects["configfile"] = pconfig = configfile.PrinterConfig(self)
config = pconfig.read_main_config()
if self.bglogger is not None:
debug_options = self.load_object(config, "debug_options", None)
if (
self.bglogger is not None
and debug_options.log_config_file_at_startup
):
pconfig.log_config(config)
# Create printer components
for m in [pins, mcu]:
Expand Down
19 changes: 11 additions & 8 deletions klippy/mcu.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class error(Exception):
# Command transmit helper classes
######################################################################


# Class to retry sending of a query command until a given response is received
class RetryAsyncCommand:
TIMEOUT_TIME = 5.0
Expand Down Expand Up @@ -744,6 +745,7 @@ class MCU:

def __init__(self, config, clocksync):
self._printer = printer = config.get_printer()
self.debug_options = printer.lookup_object("debug_options")
self._clocksync = clocksync
self._reactor = printer.get_reactor()
self._name = config.get_name()
Expand Down Expand Up @@ -833,14 +835,15 @@ def _handle_shutdown(self, params):
if clock is not None:
self._shutdown_clock = self.clock32_to_clock64(clock)
self._shutdown_msg = msg = params["static_string_id"]
logging.info(
"MCU '%s' %s: %s\n%s\n%s",
self._name,
params["#name"],
self._shutdown_msg,
self._clocksync.dump_debug(),
self._serial.dump_debug(),
)
if self.debug_options.log_shutdown_info:
logging.info(
"MCU '%s' %s: %s\n%s\n%s",
self._name,
params["#name"],
self._shutdown_msg,
self._clocksync.dump_debug(),
self._serial.dump_debug(),
)
prefix = "MCU '%s' shutdown: " % (self._name,)
if params["#name"] == "is_shutdown":
prefix = "Previous MCU '%s' shutdown: " % (self._name,)
Expand Down
2 changes: 2 additions & 0 deletions klippy/toolhead.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# mm/second), _v2 is velocity squared (mm^2/s^2), _t is time (in
# seconds), _r is ratio (scalar between 0.0 and 1.0)


# Class to track each move request
class Move:
def __init__(self, toolhead, start_pos, end_pos, speed):
Expand Down Expand Up @@ -128,6 +129,7 @@ def set_junction(self, start_v2, cruise_v2, end_v2):

LOOKAHEAD_FLUSH_TIME = 0.250


# Class to track a list of pending move requests and to facilitate
# "look-ahead" across moves to reduce acceleration between moves.
class MoveQueue:
Expand Down

0 comments on commit 10c0176

Please sign in to comment.