diff --git a/files/buzzer-support/buzzer-support.cfg b/files/buzzer-support/buzzer-support.cfg index 5ea0be4..ed61746 100644 --- a/files/buzzer-support/buzzer-support.cfg +++ b/files/buzzer-support/buzzer-support.cfg @@ -8,7 +8,6 @@ timeout: 2 verbose: False [gcode_macro BEEP] - gcode: - RUN_SHELL_COMMAND CMD=beep - RUN_SHELL_COMMAND CMD=beep +description: Play a sound +gcode: RUN_SHELL_COMMAND CMD=beep diff --git a/files/camera-settings/camera-settings-nebula.cfg b/files/camera-settings/camera-settings-nebula.cfg new file mode 100644 index 0000000..354f6d3 --- /dev/null +++ b/files/camera-settings/camera-settings-nebula.cfg @@ -0,0 +1,43 @@ +######################################## +# Camera Settings Control +######################################## + +[gcode_shell_command v4l2-ctl] +command: v4l2-ctl +timeout: 5.0 +verbose: True + +[gcode_macro CAM_SETTINGS] +description: Show current camera settings +gcode: + RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="-d /dev/video4 -l" + +[gcode_macro CAM_BRIGHTNESS] +description: min=50 / max=160 +gcode: + {% set brightness = params.BRIGHTNESS|default(100) %} + RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="-d /dev/video4 --set-ctrl brightness="{brightness} + +[gcode_macro CAM_CONTRAST] +description: min=50 / max=160 +gcode: + {% set contrast = params.CONTRAST|default(50) %} + RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="-d /dev/video4 --set-ctrl contrast="{contrast} + +[gcode_macro CAM_SATURATION] +description: min=50 / max=160 +gcode: + {% set saturation = params.SATURATION|default(56) %} + RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="-d /dev/video4 --set-ctrl saturation="{saturation} + +[gcode_macro CAM_HUE] +description: min=50 / max=160 +gcode: + {% set hue = params.HUE|default(50) %} + RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="-d /dev/video4 --set-ctrl hue="{hue} + +[gcode_macro CAM_WHITE_BALANCE_TEMPERATURE_AUTO] +description: disable=0 / enable=1 +gcode: + {% set white_balance_temperature_auto = params.WHITE_BALANCE_TEMPERATURE_AUTO|default(1) %} + RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="-d /dev/video4 --set-ctrl white_balance_temperature_auto="{white_balance_temperature_auto} diff --git a/files/camera-settings/camera-settings.cfg b/files/camera-settings/camera-settings.cfg index 9efbb08..2c05662 100644 --- a/files/camera-settings/camera-settings.cfg +++ b/files/camera-settings/camera-settings.cfg @@ -25,6 +25,7 @@ timeout: 5.0 verbose: True [gcode_macro CAM_SETTINGS] +description: Show current camera settings gcode: RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="-d /dev/video4 -l" diff --git a/files/fixes/gcode_3v3.py b/files/fixes/gcode_3v3.py new file mode 100644 index 0000000..2ce612a --- /dev/null +++ b/files/fixes/gcode_3v3.py @@ -0,0 +1,553 @@ +# Parse gcode commands +# +# Copyright (C) 2016-2021 Kevin O'Connor +# +# This file may be distributed under the terms of the GNU GPLv3 license. +import os, re, logging, collections, shlex +from extras.tool import reportInformation + +class CommandError(Exception): + pass + +Coord = collections.namedtuple('Coord', ('x', 'y', 'z', 'e')) + +class GCodeCommand: + error = CommandError + def __init__(self, gcode, command, commandline, params, need_ack): + self._command = command + self._commandline = commandline + self._params = params + self._need_ack = need_ack + # Method wrappers + self.respond_info = gcode.respond_info + self.respond_raw = gcode.respond_raw + def get_command(self): + return self._command + def get_commandline(self): + return self._commandline + def get_command_parameters(self): + return self._params + def get_raw_command_parameters(self): + command = self._command + if command.startswith("M117 ") or command.startswith("M118 "): + command = command[:4] + rawparams = self._commandline + urawparams = rawparams.upper() + if not urawparams.startswith(command): + rawparams = rawparams[urawparams.find(command):] + end = rawparams.rfind('*') + if end >= 0: + rawparams = rawparams[:end] + rawparams = rawparams[len(command):] + if rawparams.startswith(' '): + rawparams = rawparams[1:] + return rawparams + def ack(self, msg=None): + if not self._need_ack: + return False + ok_msg = "ok" + if msg: + ok_msg = "ok %s" % (msg,) + self.respond_raw(ok_msg) + self._need_ack = False + return True + # Parameter parsing helpers + class sentinel: pass + def get(self, name, default=sentinel, parser=str, minval=None, maxval=None, + above=None, below=None): + value = self._params.get(name) + if value is None: + if default is self.sentinel: + raise self.error("""{"code":"key251", "msg":"Error on '%s': missing %s", "values":["%s",%s"]}""" + % (self._commandline, name, self._commandline, name)) + return default + try: + value = parser(value) + except: + raise self.error( + """{"code":"key171", "msg": "Unable to parse '%s' as a %s", "values": ["%s", "%s"]}""" % (self._commandline, value, + self._commandline, value) + ) + if minval is not None and value < minval: + raise self.error("""{"code":"key252","msg":"Error on '%s': %s must have minimum of %s","values":["%s","%s","%s"]}""" + % (self._commandline, name, minval, self._commandline, name, minval)) + if maxval is not None and value > maxval: + raise self.error("""{"code":"key253", "msg":"Error on '%s': %s must have maximumof %s", "values":["%s","%s","%s"]}""" + % (self._commandline, name, maxval, self._commandline, name, maxval)) + if above is not None and value <= above: + raise self.error("""{"code":"key254", "msg":"Error on '%s': %s must be above %s", "values":["%s","%s","%s"]}""" + % (self._commandline, name, above, self._commandline, name, above)) + if below is not None and value >= below: + raise self.error("""{"code":"key255", "msg":"Error on '%s': %s must be below %s", "values":["%s","%s","%s"]}""" + % (self._commandline, name, below, self._commandline, name, below)) + return value + def get_int(self, name, default=sentinel, minval=None, maxval=None): + return self.get(name, default, parser=int, minval=minval, maxval=maxval) + def get_float(self, name, default=sentinel, minval=None, maxval=None, + above=None, below=None): + return self.get(name, default, parser=float, minval=minval, + maxval=maxval, above=above, below=below) + +# Parse and dispatch G-Code commands +class GCodeDispatch: + error = CommandError + Coord = Coord + def __init__(self, printer): + self.printer = printer + self.is_fileinput = not not printer.get_start_args().get("debuginput") + printer.register_event_handler("klippy:ready", self._handle_ready) + printer.register_event_handler("klippy:shutdown", self._handle_shutdown) + printer.register_event_handler("klippy:disconnect", + self._handle_disconnect) + # Command handling + self.is_printer_ready = False + self.mutex = printer.get_reactor().mutex() + self.output_callbacks = [] + self.base_gcode_handlers = self.gcode_handlers = {} + self.ready_gcode_handlers = {} + self.mux_commands = {} + self.gcode_help = {} + # Register commands needed before config file is loaded + handlers = ['M110', 'M112', 'M115', + 'RESTART', 'FIRMWARE_RESTART', 'ECHO', 'STATUS', 'HELP'] + for cmd in handlers: + func = getattr(self, 'cmd_' + cmd) + desc = getattr(self, 'cmd_' + cmd + '_help', None) + self.register_command(cmd, func, True, desc) + self.last_temperature_info = "/usr/data/creality/userdata/config/temperature_info.json" + self.exclude_object_info = "/usr/data/creality/userdata/config/exclude_object_info.json" + def is_traditional_gcode(self, cmd): + # A "traditional" g-code command is a letter and followed by a number + try: + cmd = cmd.upper().split()[0] + val = float(cmd[1:]) + return cmd[0].isupper() and cmd[1].isdigit() + except: + return False + def register_command(self, cmd, func, when_not_ready=False, desc=None): + if func is None: + old_cmd = self.ready_gcode_handlers.get(cmd) + if cmd in self.ready_gcode_handlers: + del self.ready_gcode_handlers[cmd] + if cmd in self.base_gcode_handlers: + del self.base_gcode_handlers[cmd] + return old_cmd + if cmd in self.ready_gcode_handlers: + raise self.printer.config_error( + """{"code":"key57", "msg":"gcode command %s already registered", "values": ["%s"]}""" % (cmd, cmd)) + if not self.is_traditional_gcode(cmd): + origfunc = func + func = lambda params: origfunc(self._get_extended_params(params)) + self.ready_gcode_handlers[cmd] = func + if when_not_ready: + self.base_gcode_handlers[cmd] = func + if desc is not None: + self.gcode_help[cmd] = desc + def register_mux_command(self, cmd, key, value, func, desc=None): + prev = self.mux_commands.get(cmd) + if prev is None: + handler = lambda gcmd: self._cmd_mux(cmd, gcmd) + self.register_command(cmd, handler, desc=desc) + self.mux_commands[cmd] = prev = (key, {}) + prev_key, prev_values = prev + if prev_key != key: + raise self.printer.config_error( + """{"code":"key58", "msg":"mux command %s %s %s may have only one key (%s)", "values": ["%s", "%s", "%s", "%s"]}""" % ( + cmd, key, value, prev_key, cmd, key, value, prev_key)) + if value in prev_values: + raise self.printer.config_error( + """{"code":"key59", "msg":"mux command %s %s %s already registered (%s)", "values": ["%s", "%s", "%s", "%s"]}""" % ( + cmd, key, value, prev_values, cmd, key, value, prev_values)) + prev_values[value] = func + def get_command_help(self): + return dict(self.gcode_help) + def register_output_handler(self, cb): + self.output_callbacks.append(cb) + def _handle_shutdown(self): + if not self.is_printer_ready: + return + self.is_printer_ready = False + self.gcode_handlers = self.base_gcode_handlers + self._respond_state("Shutdown") + def _handle_disconnect(self): + self._respond_state("Disconnect") + def _handle_ready(self): + self.is_printer_ready = True + self.gcode_handlers = self.ready_gcode_handlers + self._respond_state("Ready") + # Parse input into commands + args_r = re.compile('([A-Z_]+|[A-Z*/])') + def _process_commands(self, commands, need_ack=True): + for line in commands: + # Ignore comments and leading/trailing spaces + line = origline = line.strip() + cpos = line.find(';') + if cpos >= 0: + line = line[:cpos] + # Break line into parts and determine command + parts = self.args_r.split(line.upper()) + numparts = len(parts) + cmd = "" + if numparts >= 3 and parts[1] != 'N': + cmd = parts[1] + parts[2].strip() + elif numparts >= 5 and parts[1] == 'N': + # Skip line number at start of command + cmd = parts[3] + parts[4].strip() + # Build gcode "params" dictionary + params = { parts[i]: parts[i+1].strip() + for i in range(1, numparts, 2) } + gcmd = GCodeCommand(self, cmd, origline, params, need_ack) + # Invoke handler for command + handler = self.gcode_handlers.get(cmd, self.cmd_default) + try: + handler(gcmd) + except self.error as e: + self._respond_error(str(e)) + self.printer.send_event("gcode:command_error") + if not need_ack: + raise + except: + msg = """{"code":"key60", "msg":"Internal error on command:%s", "values": ["%s"]}""" % (cmd, cmd) + logging.exception(msg) + self.printer.invoke_shutdown(msg) + self._respond_error(msg) + if not need_ack: + raise + gcmd.ack() + if line.startswith("G1") or line.startswith("G0"): + pass + elif line.startswith("M104"): + self.set_temperature("extruder", line) + elif line.startswith("M140"): + self.set_temperature("bed", line) + elif line.startswith("M109"): + self.set_temperature("extruder", line) + elif line.startswith("M190"): + self.set_temperature("bed", line) + elif line.startswith("EXCLUDE_OBJECT_DEFINE") or line.startswith("EXCLUDE_OBJECT NAME"): + self.record_exclude_object_info(line) + def set_temperature(self, key, value): + import json + try: + # configfile = self.printer.lookup_object('configfile') + # print_stats = self.printer.load_object(configfile, 'print_stats') + temp_value = float(value.strip("\n").split("S")[-1]) + # if key == "extruder" and print_stats and print_stats.state == "printing": + # if temp_value >= 240: + # self.run_script_from_command("M107 P1") + # logging.info("Fan Off SET M107 P1") + # elif temp_value >= 170: + # self.run_script_from_command("M106 P1 S255") + # logging.info("Fan On SET M106 P1 S255") + if key == "extruder" and temp_value < 170: + return + if not os.path.exists(self.last_temperature_info): + from subprocess import call + call("touch %s" % self.last_temperature_info, shell=True) + with open(self.last_temperature_info, "r") as f: + ret = f.read() + if len(ret) > 0: + ret = json.loads(ret) + else: + ret = {} + ret[key] = temp_value + with open(self.last_temperature_info, "w") as f: + f.write(json.dumps(ret)) + f.flush() + except Exception as err: + logging.error("set_temperature error: %s" % err) + def record_exclude_object_info(self, line): + import json + try: + if not os.path.exists(self.exclude_object_info): + with open(self.exclude_object_info, "w") as f: + data = {} + data["EXCLUDE_OBJECT_DEFINE"] = [] + data["EXCLUDE_OBJECT"] = [] + f.write(json.dumps(data)) + f.flush() + with open(self.exclude_object_info, "r") as f: + ret = f.read() + if len(ret) > 0: + ret = eval(ret) + else: + ret = {} + if line.startswith("EXCLUDE_OBJECT_DEFINE"): + if line not in ret["EXCLUDE_OBJECT_DEFINE"]: + ret["EXCLUDE_OBJECT_DEFINE"].append(line) + elif line.startswith("EXCLUDE_OBJECT NAME"): + if line not in ret["EXCLUDE_OBJECT"]: + ret["EXCLUDE_OBJECT"].append(line) + with open(self.exclude_object_info, "w") as f: + f.write(json.dumps(ret)) + f.flush() + except Exception as err: + logging.error("record_exclude_object_info error: %s" % err) + def run_script_from_command(self, script): + self._process_commands(script.split('\n'), need_ack=False) + def run_script(self, script): + with self.mutex: + self._process_commands(script.split('\n'), need_ack=False) + def get_mutex(self): + return self.mutex + def create_gcode_command(self, command, commandline, params): + return GCodeCommand(self, command, commandline, params, False) + # Response handling + def respond_raw(self, msg): + for cb in self.output_callbacks: + cb(msg) + def respond_info(self, msg, log=True): + if log: + logging.info(msg) + lines = [l.strip() for l in msg.strip().split('\n')] + self.respond_raw("// " + "\n// ".join(lines)) + def _respond_error(self, msg): + import time + from extras.tool import reportInformation + try: + v_sd = self.printer.lookup_object('virtual_sdcard') + if v_sd.print_id and "key" in msg and re.findall('key(\d+)', msg) and v_sd.cur_print_data: + v_sd.update_print_history_info(only_update_status=True, state="error", error_msg=eval(msg)) + if os.path.exists("/tmp/camera_main"): + reportInformation("key608", data={"print_id": v_sd.print_id}) + time.sleep(0.2) + v_sd.print_id = "" + reportInformation("key701", data=v_sd.cur_print_data) + v_sd.cur_print_data = {} + except Exception as err: + logging.error(err) + try: + if "key" in msg and re.findall('key(\d+)', msg): + reportInformation(msg) + except Exception as err: + logging.error(err) + logging.warning(msg) + lines = msg.strip().split('\n') + if len(lines) > 1: + self.respond_info("\n".join(lines), log=False) + self.respond_raw('!! %s' % (lines[0].strip(),)) + if self.is_fileinput: + self.printer.request_exit('error_exit') + def _respond_state(self, state): + self.respond_info("Klipper state: %s" % (state,), log=False) + # Parameter parsing helpers + extended_r = re.compile( + r'^\s*(?:N[0-9]+\s*)?' + r'(?P[a-zA-Z_][a-zA-Z0-9_]+)(?:\s+|$)' + r'(?P[^#*;]*?)' + r'\s*(?:[#*;].*)?$') + def _get_extended_params(self, gcmd): + m = self.extended_r.match(gcmd.get_commandline()) + if m is None: + raise self.error("""{"code":"key513", "msg": "Malformed command '%s'", "values": ["%s"]}""" % (gcmd.get_commandline(), gcmd.get_commandline())) + eargs = m.group('args') + try: + eparams = [earg.split('=', 1) for earg in shlex.split(eargs)] + eparams = { k.upper(): v for k, v in eparams } + gcmd._params.clear() + gcmd._params.update(eparams) + return gcmd + except ValueError as e: + raise self.error("""{"code":"key514", "msg": "Malformed command args '%s'", "values": ["%s"]}""" % (gcmd.get_commandline(), str(e))) + # G-Code special command handlers + def cmd_default(self, gcmd): + cmd = gcmd.get_command() + if cmd == 'M105': + # Don't warn about temperature requests when not ready + gcmd.ack("T:0") + return + if cmd == 'M21': + # Don't warn about sd card init when not ready + return + if not self.is_printer_ready: + raise gcmd.error(self.printer.get_state_message()[0]) + return + if not cmd: + cmdline = gcmd.get_commandline() + if cmdline: + logging.debug(cmdline) + return + if cmd.startswith("M117 ") or cmd.startswith("M118 "): + # Handle M117/M118 gcode with numeric and special characters + handler = self.gcode_handlers.get(cmd[:4], None) + if handler is not None: + handler(gcmd) + return + elif cmd in ['M140', 'M104'] and not gcmd.get_float('S', 0.): + # Don't warn about requests to turn off heaters when not present + return + elif cmd == 'M107' or (cmd == 'M106' and ( + not gcmd.get_float('S', 1.) or self.is_fileinput)): + # Don't warn about requests to turn off fan when fan not present + return + gcmd.respond_info("""{"code":"key61, "msg":"Unknown command:%s", "values": ["%s"]}""" % (cmd, cmd)) + def get_muxcmd(self, cmdkey): + if cmdkey in self.mux_commands: + key, values = self.mux_commands[cmdkey] + return values + return None + def _cmd_mux(self, command, gcmd): + key, values = self.mux_commands[command] + if None in values: + key_param = gcmd.get(key, None) + else: + key_param = gcmd.get(key) + if key_param not in values: + raise gcmd.error("""{"code":"key69", "msg": "The value '%s' is not valid for %s", "values": ["%s", "%s"]}""" + % (key_param, key, key_param, key)) + values[key_param](gcmd) + # Low-level G-Code commands that are needed before the config file is loaded + def cmd_M110(self, gcmd): + # Set Current Line Number + pass + def cmd_M112(self, gcmd): + # Emergency Stop + self.printer.invoke_shutdown("""{"code":"key70", "msg": "Shutdown due to M112 command", "values": []}""") + def cmd_M115(self, gcmd): + # Get Firmware Version and Capabilities + software_version = self.printer.get_start_args().get('software_version') + kw = {"FIRMWARE_NAME": "Klipper", "FIRMWARE_VERSION": software_version} + msg = " ".join(["%s:%s" % (k, v) for k, v in kw.items()]) + did_ack = gcmd.ack(msg) + if not did_ack: + gcmd.respond_info(msg) + def request_restart(self, result): + if self.is_printer_ready: + toolhead = self.printer.lookup_object('toolhead') + print_time = toolhead.get_last_move_time() + if result == 'exit': + logging.info("Exiting (print time %.3fs)" % (print_time,)) + self.printer.send_event("gcode:request_restart", print_time) + toolhead.dwell(0.500) + toolhead.wait_moves() + self.printer.request_exit(result) + cmd_RESTART_help = "Reload config file and restart host software" + def cmd_RESTART(self, gcmd): + self.request_restart('restart') + cmd_FIRMWARE_RESTART_help = "Restart firmware, host, and reload config" + def cmd_FIRMWARE_RESTART(self, gcmd): + self.request_restart('firmware_restart') + def cmd_ECHO(self, gcmd): + gcmd.respond_info(gcmd.get_commandline(), log=False) + cmd_STATUS_help = "Report the printer status" + def cmd_STATUS(self, gcmd): + if self.is_printer_ready: + self._respond_state("Ready") + return + msg = self.printer.get_state_message()[0] + msg = msg.rstrip() + "\nKlipper state: Not ready" + raise gcmd.error(msg) + cmd_HELP_help = "Report the list of available extended G-Code commands" + def cmd_HELP(self, gcmd): + cmdhelp = [] + if not self.is_printer_ready: + cmdhelp.append("""{"code":"key72", "msg": "Printer is not ready - not all commands available.\n""") + cmdhelp.append("Available extended commands:") + for cmd in sorted(self.gcode_handlers): + if cmd in self.gcode_help: + cmdhelp.append("%-10s: %s" % (cmd, self.gcode_help[cmd])) + gcmd.respond_info("\n".join(cmdhelp), log=False) + +# Support reading gcode from a pseudo-tty interface +class GCodeIO: + def __init__(self, printer): + self.printer = printer + printer.register_event_handler("klippy:ready", self._handle_ready) + printer.register_event_handler("klippy:shutdown", self._handle_shutdown) + self.gcode = printer.lookup_object('gcode') + self.gcode_mutex = self.gcode.get_mutex() + self.fd = printer.get_start_args().get("gcode_fd") + self.reactor = printer.get_reactor() + self.is_printer_ready = False + self.is_processing_data = False + self.is_fileinput = not not printer.get_start_args().get("debuginput") + self.pipe_is_active = True + self.fd_handle = None + if not self.is_fileinput: + self.gcode.register_output_handler(self._respond_raw) + self.fd_handle = self.reactor.register_fd(self.fd, + self._process_data) + self.partial_input = "" + self.pending_commands = [] + self.bytes_read = 0 + self.input_log = collections.deque([], 50) + def _handle_ready(self): + self.is_printer_ready = True + if self.is_fileinput and self.fd_handle is None: + self.fd_handle = self.reactor.register_fd(self.fd, + self._process_data) + def _dump_debug(self): + out = [] + out.append("Dumping gcode input %d blocks" % (len(self.input_log),)) + for eventtime, data in self.input_log: + out.append("Read %f: %s" % (eventtime, repr(data))) + logging.info("\n".join(out)) + def _handle_shutdown(self): + if not self.is_printer_ready: + return + self.is_printer_ready = False + self._dump_debug() + if self.is_fileinput: + self.printer.request_exit('error_exit') + m112_r = re.compile('^(?:[nN][0-9]+)?\s*[mM]112(?:\s|$)') + def _process_data(self, eventtime): + # Read input, separate by newline, and add to pending_commands + try: + data = str(os.read(self.fd, 4096).decode()) + except (os.error, UnicodeDecodeError): + logging.exception("Read g-code") + return + self.input_log.append((eventtime, data)) + self.bytes_read += len(data) + lines = data.split('\n') + lines[0] = self.partial_input + lines[0] + self.partial_input = lines.pop() + pending_commands = self.pending_commands + pending_commands.extend(lines) + self.pipe_is_active = True + # Special handling for debug file input EOF + if not data and self.is_fileinput: + if not self.is_processing_data: + self.reactor.unregister_fd(self.fd_handle) + self.fd_handle = None + self.gcode.request_restart('exit') + pending_commands.append("") + # Handle case where multiple commands pending + if self.is_processing_data or len(pending_commands) > 1: + if len(pending_commands) < 20: + # Check for M112 out-of-order + for line in lines: + if self.m112_r.match(line) is not None: + self.gcode.cmd_M112(None) + if self.is_processing_data: + if len(pending_commands) >= 20: + # Stop reading input + self.reactor.unregister_fd(self.fd_handle) + self.fd_handle = None + return + # Process commands + self.is_processing_data = True + while pending_commands: + self.pending_commands = [] + with self.gcode_mutex: + self.gcode._process_commands(pending_commands) + pending_commands = self.pending_commands + self.is_processing_data = False + if self.fd_handle is None: + self.fd_handle = self.reactor.register_fd(self.fd, + self._process_data) + def _respond_raw(self, msg): + if self.pipe_is_active: + try: + os.write(self.fd, (msg+"\n").encode()) + # if 'key506' not in msg and 'key507' not in msg and 'key3"' not in msg and "key" in msg: + # reportInformation(msg) + except os.error: + logging.exception("Write g-code response") + self.pipe_is_active = False + def stats(self, eventtime): + return False, "gcodein=%d" % (self.bytes_read,) + +def add_early_printer_objects(printer): + printer.add_object('gcode', GCodeDispatch(printer)) + printer.add_object('gcode_io', GCodeIO(printer)) diff --git a/files/git-backup/S52Git-Backup b/files/git-backup/S52Git-Backup index 05d0dc2..ad7f953 100755 --- a/files/git-backup/S52Git-Backup +++ b/files/git-backup/S52Git-Backup @@ -1,26 +1,29 @@ #!/bin/sh +start_git_backup() { + echo "Info: Starting Git Backup..." + /usr/data/helper-script/files/git-backup/git-backup.sh -b "$BRANCH" -t "$IFS" -g origin > /dev/null 2>&1 & +} + case "$1" in start) - echo "Starting Git Backup..." - /usr/data/helper-script/files/git-backup/git-backup.sh -b "$BRANCH" -t "$IFS" -g origin & > /dev/null + start_git_backup ;; stop) - echo "Stopping Git Backup..." - pkill Git-Backup - pkill inotifywait - pkill git-backup.sh + echo "Info: Stopping Git Backup..." + killall -q git-backup.sh + killall -q inotifywait ;; restart) - echo "Restarting Git Backup..." - pkill Git-Backup - pkill inotifywait + echo "Info: Restarting Git Backup..." + $0 stop sleep 1 - /usr/data/helper-script/files/git-backup/git-backup.sh -b "$BRANCH" -t "$IFS" -g origin & > /dev/null + start_git_backup ;; *) echo "Usage: $0 {start|stop|restart}" exit 1 ;; esac -exit 0 + +exit 0 \ No newline at end of file diff --git a/files/git-backup/git-backup.cfg b/files/git-backup/git-backup.cfg index 9fcc513..248da57 100644 --- a/files/git-backup/git-backup.cfg +++ b/files/git-backup/git-backup.cfg @@ -20,16 +20,52 @@ timeout: 600.0 verbose: true -[gcode_macro GIT_BACKUP_STOP] +[gcode_macro _GIT_STOP] +description: Stop pushing to GitHub until manually resumed gcode: RUN_SHELL_COMMAND CMD=Backup_Stop + RESPOND TYPE=command MSG="action:prompt_end" + + +[gcode_macro _GIT_PAUSE] +description: Stop pushing to GitHub until next reboot or until manually resumed +gcode: + RUN_SHELL_COMMAND CMD=Backup_Pause + RESPOND TYPE=command MSG="action:prompt_end" + + +[gcode_macro _GIT_RESUME] +description: Resume pushing to GitHub +gcode: + RUN_SHELL_COMMAND CMD=Backup_Resume + RESPOND TYPE=command MSG="action:prompt_end" + + +[gcode_macro GIT_BACKUP_STOP] +description: Stop pushing to GitHub until manually resumed +gcode: + RESPOND TYPE=command MSG="action:prompt_begin Git Backup" + RESPOND TYPE=command MSG="action:prompt_text Do you want to stop pushing to GitHub until manually resumed?" + RESPOND TYPE=command MSG="action:prompt_footer_button NO|RESPOND TYPE=command MSG="action:prompt_end"|error" + RESPOND TYPE=command MSG="action:prompt_footer_button YES|_GIT_STOP|primary" + RESPOND TYPE=command MSG="action:prompt_show" [gcode_macro GIT_BACKUP_PAUSE] +description: Stop pushing to GitHub until next reboot or until manually resumed gcode: - RUN_SHELL_COMMAND CMD=Backup_Pause + RESPOND TYPE=command MSG="action:prompt_begin Git Backup" + RESPOND TYPE=command MSG="action:prompt_text Do you want to stop pushing to GitHub until next reboot or until manually resumed?" + RESPOND TYPE=command MSG="action:prompt_footer_button NO|RESPOND TYPE=command MSG="action:prompt_end"|error" + RESPOND TYPE=command MSG="action:prompt_footer_button YES|_GIT_PAUSE|primary" + RESPOND TYPE=command MSG="action:prompt_show" [gcode_macro GIT_BACKUP_RESUME] +description: Resume pushing to GitHub gcode: - RUN_SHELL_COMMAND CMD=Backup_Resume + RESPOND TYPE=command MSG="action:prompt_begin Git Backup" + RESPOND TYPE=command MSG="action:prompt_text Do you want to resume pushing to GitHub?" + RESPOND TYPE=command MSG="action:prompt_footer_button NO|RESPOND TYPE=command MSG="action:prompt_end"|error" + RESPOND TYPE=command MSG="action:prompt_footer_button YES|_GIT_RESUME|primary" + RESPOND TYPE=command MSG="action:prompt_show" diff --git a/files/git-backup/git-backup.sh b/files/git-backup/git-backup.sh index 95a850b..a17d5c8 100755 --- a/files/git-backup/git-backup.sh +++ b/files/git-backup/git-backup.sh @@ -7,37 +7,12 @@ # - Dominik D. Geyer # - Phil Thompson # - Dave Musicant -# -# Edited to work on busybox ash shell, specifically the Creality K1 & K1Max -############################################################################# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -############################################################################# -# -# Idea and original code taken from http://stackoverflow.com/a/965274 -# original work by Lester Buck -# (but heavily modified by now) -# -# Requires the command 'inotifywait' to be available, which is part of -# the inotify-tools (See https://github.com/rvoicilas/inotify-tools ), -# and (obviously) git. -# Will check the availability of both commands using the `which` command -# and will abort if either command (or `which`) is not found. -# +# - Guislain Cyril white=`echo -en "\033[m"` yellow=`echo -en "\033[1;33m"` green=`echo -en "\033[01;32m"` +darkred=`echo -en "\033[31m"` INSTALL=0 PAUSE=0 @@ -49,7 +24,7 @@ TARGET="" EVENTS="${EVENTS:-close_write,move,move_self,delete,create,modify}" SLEEP_TIME=5 DATE_FMT="+%d-%m-%Y (%H:%M:%S)" -COMMITMSG="Auto-commit on %d by Git Backup" +COMMITMSG="Auto-commit by Git Backup" SKIP_IF_MERGING=0 # Function to print script help @@ -110,61 +85,161 @@ if [ "$PAUSE" = 1 ]; then exit 0 elif [ "$STOP" = 1 ]; then echo "Info: Stopping automatic backups until manually restarted..." - mv /etc/init.d/S52Git-Backup /etc/init.d/disabled.S52Git-Backup + if [ -f mv /etc/init.d/S52Git-Backup ];then + mv /etc/init.d/S52Git-Backup /etc/init.d/disabled.S52Git-Backup + fi + /etc/init.d/S52Git-Backup stop exit 0 elif [ "$RESUME" = 1 ]; then echo "Info: Resuming automatic backups..." - mv /etc/init.d/disabled.S52Git-Backup /etc/init.d/S52Git-Backup + if [ -f /etc/init.d/disabled.S52Git-Backup ];then + mv /etc/init.d/disabled.S52Git-Backup /etc/init.d/S52Git-Backup + fi + /etc/init.d/S52Git-Backup start exit 0 elif [ "$INSTALL" = 1 ]; then # Install required packages using opkg if [ -f /opt/bin/opkg ]; then /opt/bin/opkg update - /opt/bin/opkg install inotifywait procps-ng-pkill + /opt/bin/opkg install inotifywait else - echo "Error: opkg package manager not found. Please install Entware." + echo + echo "${white}${darkred} ✗ opkg package manager not found. Please install Entware.${white}" + echo exit 1 fi # Prompt user for configuration echo "${white}" read -p " Please enter your ${green}GitHub username${white} and press Enter: ${yellow}" USER_NAME + while [ -z "$USER_NAME" ]; do + echo "${white}" + echo "${darkred} ✗ Invalid GitHub username!${white}" + echo + read -p " Please enter your ${green}GitHub username${white} and press Enter: ${yellow}" USER_NAME + done + valid_email=false + while [ "$valid_email" != true ]; do + echo "${white}" + read -p " Please enter your ${green}GitHub email address${white} and press Enter: ${yellow}" USER_MAIL + echo "$USER_MAIL" | grep -E -q "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$" + if [ $? -ne 0 ]; then + echo "${white}" + echo "${darkred} ✗ Invalid email address!${white}" + else + valid_email=true + fi + done echo "${white}" read -p " Please enter your ${green}GitHub repository name${white} and press Enter: ${yellow}" REPO_NAME + while [ -z "$REPO_NAME" ]; do + echo "${white}" + echo "${darkred} ✗ Invalid GitHub repository name!${white}" + echo + read -p " Please enter your ${green}GitHub repository name${white} and press Enter: ${yellow}" REPO_NAME + done echo "${white}" read -p " Please enter your ${green}GitHub branch name${white} and press Enter: ${yellow}" REPO_BRANCH + while [ -z "$REPO_BRANCH" ]; do + echo "${white}" + echo "${darkred} ✗ Invalid GitHub branch name!${white}" + echo + read -p " Please enter your ${green}GitHub branch name${white} and press Enter: ${yellow}" REPO_BRANCH + done echo "${white}" read -p " Please enter your ${green}GitHub personal access token${white} and press Enter: ${yellow}" GITHUB_TOKEN + while [ -z "$GITHUB_TOKEN" ]; do + echo "${white}" + echo "${darkred} ✗ Invalid GitHub personal access token!${white}" + echo + read -p " Please enter your ${green}GitHub personal access token${white} and press Enter: ${yellow}" GITHUB_TOKEN + done echo "${white}" - # Prompt user to select folders to be watched + # Folder to be watched IFS=/usr/data/printer_data/config # Connect config directory to github cd "$IFS" || exit + git config --global user.name "$USER_NAME" + git config --global user.email "$USER_MAIL" git init git remote add origin "https://$USER_NAME:$GITHUB_TOKEN@github.com/$USER_NAME/$REPO_NAME.git" git checkout -b "$REPO_BRANCH" git add . git commit -m "Initial Backup" - git push -u origin "$REPO_BRANCH" + push_repo=$(git push -u origin "$REPO_BRANCH" 2>&1) + if echo "$push_repo" | grep -q "fatal: remote origin already exists"; then + echo + rm -rf /usr/data/printer_data/config/.git + killall -q inotifywait >/dev/null 2>&1 + /opt/bin/opkg --autoremove remove inotifywait >/dev/null 2>&1 + echo "${white}${darkred} ✗ A branch named $REPO_BRANCH already exists!" + echo " Use another branch name or clean your repo and restart Git Backup installation.${white}" + echo + exit 0 + elif echo "$push_repo" | grep -q "error: failed to push some refs to"; then + echo + rm -rf /usr/data/printer_data/config/.git + killall -q inotifywait >/dev/null 2>&1 + /opt/bin/opkg --autoremove remove inotifywait >/dev/null 2>&1 + echo "${white}${darkred} ✗ Your repository already contains commits and files cannot be merged!" + echo " Please clean your repo and restart Git Backup installation.${white}" + echo + exit 0 + elif echo "$push_repo" | grep -q "remote: Repository not found"; then + echo + rm -rf /usr/data/printer_data/config/.git + killall -q inotifywait >/dev/null 2>&1 + /opt/bin/opkg --autoremove remove inotifywait >/dev/null 2>&1 + echo "${white}${darkred} ✗ Your repository was not found!" + echo " Check your provided information and restart Git Backup installation.${white}" + echo + exit 0 + elif echo "$push_repo" | grep -q "fatal: Authentication failed"; then + echo + rm -rf /usr/data/printer_data/config/.git + killall -q inotifywait >/dev/null 2>&1 + /opt/bin/opkg --autoremove remove inotifywait >/dev/null 2>&1 + echo "${white}${darkred} ✗ Authentication failed!" + echo " Check your GitHub personal access token and restart Git Backup installation.${white}" + echo + exit 0 + else + git push -u origin "$REPO_BRANCH" + fi # Write configuration to .env file - echo "IFS=$IFS" > "$IFS/.env" - echo "GITHUB_TOKEN=$GITHUB_TOKEN" >> "$IFS/.env" - echo "REMOTE=$REPO_NAME" >> "$IFS/.env" - echo "BRANCH=$REPO_BRANCH" >> "$IFS/.env" - echo "USER=$USER_NAME" >> "$IFS/.env" - - # Create .gitignore file to protect .env variables - echo ".env" > "$IFS/.gitignore" + if [ ! -d /usr/data/helper-script-backup/git-backup ]; then + mkdir -p /usr/data/helper-script-backup/git-backup + fi + ENV=/usr/data/helper-script-backup/git-backup/.env + echo "IFS=$IFS" > "$ENV" + echo "GITHUB_TOKEN=$GITHUB_TOKEN" >> "$ENV" + echo "REMOTE=$REPO_NAME" >> "$ENV" + echo "BRANCH=$REPO_BRANCH" >> "$ENV" + echo "USER=$USER_NAME" >> "$ENV" - # Insert .env to S52gitwatch.sh and move to init.d + # Insert .env to init.d + echo "Info: Copying file..." cp -f /usr/data/helper-script/files/git-backup/S52Git-Backup /etc/init.d/S52Git-Backup - sed -i "2i source $IFS/.env" /etc/init.d/S52Git-Backup + sed -i "2i source $ENV" /etc/init.d/S52Git-Backup + echo "Info: Linking file..." + ln -sf /usr/data/helper-script/files/git-backup/git-backup.cfg /usr/data/printer_data/config/Helper-Script/git-backup.cfg + if grep -q "include Helper-Script/git-backup" /usr/data/printer_data/config/printer.cfg ; then + echo "Info: Git Backup configurations are already enabled in printer.cfg file..." + else + echo "Info: Adding Git Backup configurations in printer.cfg file..." + sed -i '/\[include printer_params\.cfg\]/a \[include Helper-Script/git-backup\.cfg\]' /usr/data/printer_data/config/printer.cfg + fi + echo "Info: Starting Git Backup service..." chmod +x /etc/init.d/S52Git-Backup - /etc/init.d/S52Git-Backup start - + /etc/init.d/S52Git-Backup start >/dev/null 2>&1 + echo "Info: Restarting Klipper service..." + /etc/init.d/S55klipper_service start + echo + echo "${white}${green} ✓ Git Backup has been installed and configured successfully!${white}" + echo exit 0 fi @@ -225,16 +300,13 @@ else fi if [ -d "$TARGET" ]; then # if the target is a directory - TARGETDIR=$(echo "$IN" | sed -e "s/\/*$//") # dir to CD into before using git commands: trim trailing slash, if any - # construct inotifywait-commandline if [ "$(uname)" != "Darwin" ]; then INW_ARGS="-qmr -e $EVENTS $TARGETDIR" fi GIT_ADD="git add -A ." # add "." (CWD) recursively to index GIT_COMMIT_ARGS="-a" # add -a switch to "commit" call just to be sure - else stderr "Error: The target is neither a regular file nor a directory." exit 3 @@ -283,7 +355,7 @@ while true; do if [ -n "$line" ]; then # Process changes if [ -n "$DATE_FMT" ]; then - COMMITMSG=$(echo "$COMMITMSG" | awk -v date="$(date "$DATE_FMT")" '{gsub(/%d/, date)}1') # splice the formatted date-time into the commit message + COMMITMSG=$(echo "$COMMITMSG") # splice the formatted date-time into the commit message fi cd "$TARGETDIR" || { @@ -299,11 +371,10 @@ while true; do $GIT_ADD # add file(s) to index $GIT commit $GIT_COMMIT_ARGS -m "$COMMITMSG" # construct commit message and commit - if [ -n "$PUSH_CMD" ]; then echo "Push command is $PUSH_CMD" eval "$PUSH_CMD" - pkill 'inotifywait' + killall -q inotifywait timeout fi fi diff --git a/files/guppy-screen/guppy_update-3v3.cfg b/files/guppy-screen/guppy_update-3v3.cfg new file mode 100644 index 0000000..e6eb0ec --- /dev/null +++ b/files/guppy-screen/guppy_update-3v3.cfg @@ -0,0 +1,33 @@ +######################################## +# Guppy Screen Update +######################################## + +[gcode_shell_command guppy_update] +command: sh /usr/data/helper-script/files/guppy-screen/guppy-update.sh +timeout: 600.0 +verbose: True + + +[gcode_macro GUPPY_UPDATE] +description: Check for Guppy Screen Updates +gcode: + {% if printer.idle_timeout.state == "Printing" %} + RESPOND TYPE=error MSG="It's not possible to update Guppy Screen while printing!" + {% else %} + RUN_SHELL_COMMAND CMD=guppy_update + {% endif %} + + +[gcode_macro INPUT_SHAPER_CALIBRATION] +description: Measure X and Y Axis Resonances and Save values +gcode: + SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=soc_fan TARGET=30 + {% if printer.toolhead.homed_axes != "xyz" %} + RESPOND TYPE=command MSG="Homing..." + G28 + {% endif %} + RESPOND TYPE=command MSG="Measuring X and Y Resonances..." + SHAPER_CALIBRATE + M400 + SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=soc_fan TARGET=45 + CXSAVE_CONFIG \ No newline at end of file diff --git a/files/guppy-screen/guppy_update.cfg b/files/guppy-screen/guppy_update.cfg index 45a4d99..a82f4ed 100644 --- a/files/guppy-screen/guppy_update.cfg +++ b/files/guppy-screen/guppy_update.cfg @@ -21,8 +21,8 @@ gcode: [gcode_macro INPUT_SHAPER_CALIBRATION] description: Measure X and Y Axis Resonances and Save values gcode: - {% if printer["configfile"].config["temperature_fan mcu_fan"] %} - SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=mcu_fan TARGET=30 + {% if printer["configfile"].config["temperature_fan soc_fan"] %} + SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=soc_fan TARGET=30 {% endif %} {% if printer.toolhead.homed_axes != "xyz" %} RESPOND TYPE=command MSG="Homing..." @@ -31,7 +31,7 @@ gcode: RESPOND TYPE=command MSG="Measuring X and Y Resonances..." SHAPER_CALIBRATE M400 - {% if printer["configfile"].config["temperature_fan mcu_fan"] %} - SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=mcu_fan TARGET=50 + {% if printer["configfile"].config["temperature_fan soc_fan"] %} + SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=soc_fan TARGET=50 {% endif %} CXSAVE_CONFIG \ No newline at end of file diff --git a/files/guppy-screen/guppyconfig-3v3.json b/files/guppy-screen/guppyconfig-3v3.json new file mode 100644 index 0000000..3710a2e --- /dev/null +++ b/files/guppy-screen/guppyconfig-3v3.json @@ -0,0 +1,51 @@ +{ + "config_path": "/usr/data/guppyscreen/guppyconfig.json", + "default_printer": "Ender-3 V3", + "display_rotate": 3, + "display_sleep_sec": -1, + "guppy_init_script": "/etc/init.d/S99guppyscreen", + "invert_z_icon": true, + "log_path": "/usr/data/printer_data/logs/guppyscreen.log", + "printers": { + "Ender-3 V3": { + "default_macros": { + "cooldown": "SET_HEATER_TEMPERATURE HEATER=extruder TARGET=0\nSET_HEATER_TEMPERATURE HEATER=heater_bed TARGET=0", + "load_filament": "LOAD_MATERIAL", + "unload_filament": "QUIT_MATERIAL" + }, + "fans": [ + { + "display_name": "Model Cooling", + "id": "output_pin fan0" + }, + { + "display_name": "Auxiliary Cooling", + "id": "output_pin fan2" + } + ], + "leds": null, + "log_level": "debug", + "monitored_sensors": [ + { + "color": "red", + "controllable": true, + "display_name": "Extruder", + "id": "extruder" + }, + { + "color": "purple", + "controllable": true, + "display_name": "Bed", + "id": "heater_bed" + } + ], + "moonraker_api_key": false, + "moonraker_host": "127.0.0.1", + "moonraker_port": 7125 + } + }, + "prompt_emergency_stop": true, + "thumbnail_path": "/usr/data/printer_data/thumbnails", + "touch_calibrated": false, + "wpa_supplicant": "/var/run/wpa_supplicant" +} diff --git a/files/improved-shapers/improved-shapers-3v3.cfg b/files/improved-shapers/improved-shapers-3v3.cfg new file mode 100644 index 0000000..af0db16 --- /dev/null +++ b/files/improved-shapers/improved-shapers-3v3.cfg @@ -0,0 +1,125 @@ +######################################## +# Improved Shapers Configurations +######################################## + +[respond] + +[calibrate_shaper_config] + + +[gcode_shell_command resonance_graph] +command: /usr/data/printer_data/config/Helper-Script/improved-shapers/scripts/calibrate_shaper.py +timeout: 600.0 +verbose: False + + +[gcode_shell_command belts_graph] +command: /usr/data/printer_data/config/Helper-Script/improved-shapers/scripts/graph_belts.py +timeout: 600.0 +verbose: False + + +[gcode_shell_command delete_graph] +command: sh /usr/data/helper-script/files/improved-shapers/delete_graph.sh +timeout: 600.0 +verbose: False + + +[gcode_shell_command delete_csv] +command: sh /usr/data/helper-script/files/improved-shapers/delete_csv.sh +timeout: 600.0 +verbose: False + + +[gcode_macro INPUT_SHAPER_CALIBRATION] +description: Measure X and Y Axis Resonances and Save values +gcode: + SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=soc_fan TARGET=30 + {% if printer.toolhead.homed_axes != "xyz" %} + RESPOND TYPE=command MSG="Homing..." + G28 + {% endif %} + RESPOND TYPE=command MSG="Measuring X and Y Resonances..." + SHAPER_CALIBRATE + M400 + SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=soc_fan TARGET=45 + RUN_SHELL_COMMAND CMD=delete_csv + RESPOND TYPE=command MSG="Input Shaper Calibration complete!" + SAVE_CONFIG + + +[gcode_macro TEST_RESONANCES_GRAPHS] +description: Test X and Y Axis Resonances and Generate Graphs +gcode: + RUN_SHELL_COMMAND CMD=delete_graph + {% set x_png = params.X_PNG|default("/usr/data/printer_data/config/Helper-Script/improved-shapers/resonances_x.png") %} + {% set y_png = params.Y_PNG|default("/usr/data/printer_data/config/Helper-Script/improved-shapers/resonances_y.png") %} + SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=soc_fan TARGET=30 + {% if printer.toolhead.homed_axes != "xyz" %} + RESPOND TYPE=command MSG="Homing..." + G28 + {% endif %} + RESPOND TYPE=command MSG="Testing X Resonances..." + TEST_RESONANCES AXIS=X NAME=x + M400 + RESPOND TYPE=command MSG="Generating X Graph... This may take some time." + RUN_SHELL_COMMAND CMD=resonance_graph PARAMS="/tmp/resonances_x_x.csv -o {x_png}" + RESPOND TYPE=command MSG="X Graph (resonances_x.png) is now available in /Helper-Script/improved-shapers folder." + RESPOND TYPE=command MSG="Testing Y Resonances..." + TEST_RESONANCES AXIS=Y NAME=y + M400 + RESPOND TYPE=command MSG="Generating Y Graph... This may take some time." + RUN_SHELL_COMMAND CMD=resonance_graph PARAMS="/tmp/resonances_y_y.csv -o {y_png}" + RESPOND TYPE=command MSG="Y Graph (resonances_y.png) is now available in /Helper-Script/improved-shapers folder." + SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=soc_fan TARGET=45 + RUN_SHELL_COMMAND CMD=delete_csv + RESPOND TYPE=command MSG="Resonances Test complete!" + + +[gcode_macro BELTS_SHAPER_CALIBRATION] +description: Perform a custom half-axis test to analyze and compare the frequency profiles of individual belts on CoreXY printers +gcode: + RUN_SHELL_COMMAND CMD=delete_graph + {% set min_freq = params.FREQ_START|default(5)|float %} + {% set max_freq = params.FREQ_END|default(133.33)|float %} + {% set hz_per_sec = params.HZ_PER_SEC|default(1)|float %} + {% set png_width = params.PNG_WIDTH|default(8)|float %} + {% set png_height = params.PNG_HEIGHT|default(4.8)|float %} + {% set png_out_path = params.PNG_OUT_PATH|default("/usr/data/printer_data/config/Helper-Script/improved-shapers/belts_calibration.png") %} + SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=soc_fan TARGET=30 + {% if printer.toolhead.homed_axes != "xyz" %} + RESPOND TYPE=command MSG="Homing..." + G28 + {% endif %} + TEST_RESONANCES AXIS=1,1 OUTPUT=raw_data NAME=b FREQ_START={min_freq} FREQ_END={max_freq} HZ_PER_SEC={hz_per_sec} + M400 + TEST_RESONANCES AXIS=1,-1 OUTPUT=raw_data NAME=a FREQ_START={min_freq} FREQ_END={max_freq} HZ_PER_SEC={hz_per_sec} + M400 + RESPOND TYPE=command MSG="Generating Belts Frequency Profiles Graph... This may take some time." + RUN_SHELL_COMMAND CMD=belts_graph PARAMS="-w {png_width} -l {png_height} -n -o {png_out_path} -k /usr/share/klipper /tmp/raw_data_axis=1.000,-1.000_a.csv /tmp/raw_data_axis=1.000,1.000_b.csv" + RESPOND TYPE=command MSG="Graph (belts_calibration.png) is now available in /Helper-Script/improved-shapers folder." + SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=soc_fan TARGET=45 + RUN_SHELL_COMMAND CMD=delete_csv + RESPOND TYPE=command MSG="Belts Shaper Calibration complete!" + + +[gcode_macro EXCITATE_AXIS_AT_FREQ] +description: Maintain a specified excitation frequency for a period of time to diagnose and locate a vibration source +gcode: + {% set frequency = params.FREQUENCY|default(25)|int %} + {% set time = params.TIME|default(10)|int %} + {% set axis = params.AXIS|default("x")|string|lower %} + {% if axis not in ["x", "y", "a", "b"] %} + { action_raise_error("AXIS selection is invalid. Should be either x, y, a or b!") } + {% endif %} + {% if axis == "a" %} + {% set axis = "1,-1" %} + {% elif axis == "b" %} + {% set axis = "1,1" %} + {% endif %} + {% if printer.toolhead.homed_axes != "xyz" %} + RESPOND TYPE=command MSG="Homing..." + G28 + {% endif %} + TEST_RESONANCES OUTPUT=raw_data AXIS={axis} FREQ_START={frequency-1} FREQ_END={frequency+1} HZ_PER_SEC={1/(time/3)} + M400 diff --git a/files/improved-shapers/improved-shapers.cfg b/files/improved-shapers/improved-shapers.cfg index 5d6cb63..3da812a 100644 --- a/files/improved-shapers/improved-shapers.cfg +++ b/files/improved-shapers/improved-shapers.cfg @@ -34,8 +34,8 @@ verbose: False [gcode_macro INPUT_SHAPER_CALIBRATION] description: Measure X and Y Axis Resonances and Save values gcode: - {% if printer["configfile"].config["temperature_fan mcu_fan"] %} - SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=mcu_fan TARGET=30 + {% if printer["configfile"].config["temperature_fan soc_fan"] %} + SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=soc_fan TARGET=30 {% endif %} {% if printer.toolhead.homed_axes != "xyz" %} RESPOND TYPE=command MSG="Homing..." @@ -44,8 +44,8 @@ gcode: RESPOND TYPE=command MSG="Measuring X and Y Resonances..." SHAPER_CALIBRATE M400 - {% if printer["configfile"].config["temperature_fan mcu_fan"] %} - SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=mcu_fan TARGET=50 + {% if printer["configfile"].config["temperature_fan soc_fan"] %} + SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=soc_fan TARGET=50 {% endif %} RUN_SHELL_COMMAND CMD=delete_csv RESPOND TYPE=command MSG="Input Shaper Calibration complete!" @@ -58,8 +58,8 @@ gcode: RUN_SHELL_COMMAND CMD=delete_graph {% set x_png = params.X_PNG|default("/usr/data/printer_data/config/Helper-Script/improved-shapers/resonances_x.png") %} {% set y_png = params.Y_PNG|default("/usr/data/printer_data/config/Helper-Script/improved-shapers/resonances_y.png") %} - {% if printer["configfile"].config["temperature_fan mcu_fan"] %} - SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=mcu_fan TARGET=30 + {% if printer["configfile"].config["temperature_fan soc_fan"] %} + SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=soc_fan TARGET=30 {% endif %} {% if printer.toolhead.homed_axes != "xyz" %} RESPOND TYPE=command MSG="Homing..." @@ -77,8 +77,8 @@ gcode: RESPOND TYPE=command MSG="Generating Y Graph... This may take some time." RUN_SHELL_COMMAND CMD=resonance_graph PARAMS="/tmp/resonances_y_y.csv -o {y_png}" RESPOND TYPE=command MSG="Y Graph (resonances_y.png) is now available in /Helper-Script/improved-shapers folder." - {% if printer["configfile"].config["temperature_fan mcu_fan"] %} - SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=mcu_fan TARGET=50 + {% if printer["configfile"].config["temperature_fan soc_fan"] %} + SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=soc_fan TARGET=50 {% endif %} RUN_SHELL_COMMAND CMD=delete_csv RESPOND TYPE=command MSG="Resonances Test complete!" @@ -94,8 +94,8 @@ gcode: {% set png_width = params.PNG_WIDTH|default(8)|float %} {% set png_height = params.PNG_HEIGHT|default(4.8)|float %} {% set png_out_path = params.PNG_OUT_PATH|default("/usr/data/printer_data/config/Helper-Script/improved-shapers/belts_calibration.png") %} - {% if printer["configfile"].config["temperature_fan mcu_fan"] %} - SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=mcu_fan TARGET=30 + {% if printer["configfile"].config["temperature_fan soc_fan"] %} + SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=soc_fan TARGET=30 {% endif %} {% if printer.toolhead.homed_axes != "xyz" %} RESPOND TYPE=command MSG="Homing..." @@ -108,8 +108,8 @@ gcode: RESPOND TYPE=command MSG="Generating Belts Frequency Profiles Graph... This may take some time." RUN_SHELL_COMMAND CMD=belts_graph PARAMS="-w {png_width} -l {png_height} -n -o {png_out_path} -k /usr/share/klipper /tmp/raw_data_axis=1.000,-1.000_a.csv /tmp/raw_data_axis=1.000,1.000_b.csv" RESPOND TYPE=command MSG="Graph (belts_calibration.png) is now available in /Helper-Script/improved-shapers folder." - {% if printer["configfile"].config["temperature_fan mcu_fan"] %} - SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=mcu_fan TARGET=50 + {% if printer["configfile"].config["temperature_fan soc_fan"] %} + SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=soc_fan TARGET=50 {% endif %} RUN_SHELL_COMMAND CMD=delete_csv RESPOND TYPE=command MSG="Belts Shaper Calibration complete!" diff --git a/files/kamp/Adaptive_Meshing.cfg b/files/kamp/Adaptive_Meshing.cfg index 0b599ae..40aab8b 100644 --- a/files/kamp/Adaptive_Meshing.cfg +++ b/files/kamp/Adaptive_Meshing.cfg @@ -1,5 +1,5 @@ ########################################### -# Adaptive Meshing for Creality K1 Series +# Adaptive Bed Meshing Macros ########################################### [gcode_macro BED_MESH_CALIBRATE] @@ -50,44 +50,26 @@ gcode: {% set points_y = [points_y , probe_count[1]]|min %} {% if verbose_enable == True %} - {% if printer.exclude_object.objects != [] %} - RESPOND TYPE=command MSG="Algorithm: {algorithm}" RESPOND TYPE=command MSG="Default probe count: {probe_count[0]},{probe_count[1]}" RESPOND TYPE=command MSG="Adapted probe count: {points_x},{points_y}" RESPOND TYPE=command MSG="Default mesh bounds: {bed_mesh_min[0]},{bed_mesh_min[1]}, {bed_mesh_max[0]},{bed_mesh_max[1]}" - {% if mesh_margin > 0 %} - RESPOND TYPE=command MSG="Mesh margin is {mesh_margin}, mesh bounds extended by {mesh_margin}mm." - {% else %} - RESPOND TYPE=command MSG="Mesh margin is 0, margin not increased." - {% endif %} - {% if fuzz_amount > 0 %} - RESPOND TYPE=command MSG="Mesh point fuzzing enabled, points fuzzed up to {fuzz_amount}mm" - {% else %} - RESPOND TYPE=command MSG="Fuzz amount is 0, mesh points not fuzzed." - {% endif %} - RESPOND TYPE=command MSG="Adapted mesh bounds: {adapted_x_min},{adapted_y_min}, {adapted_x_max},{adapted_y_max}" RESPOND TYPE=command MSG="KAMP adjustments successful. Happy KAMPing!" - {% else %} - RESPOND TYPE=command MSG="No object detected! Make sure you have enabled Exclude Objets setting in your slicer. Using Full Bed Mesh." G4 P5000 - {% endif %} - {% endif %} - _BED_MESH_CALIBRATE mesh_min={adapted_x_min},{adapted_y_min} mesh_max={adapted_x_max},{adapted_y_max} ALGORITHM={algorithm} PROBE_COUNT={points_x},{points_y} diff --git a/files/kamp/KAMP_Settings.cfg b/files/kamp/KAMP_Settings.cfg index 62fe6cd..d2ac515 100644 --- a/files/kamp/KAMP_Settings.cfg +++ b/files/kamp/KAMP_Settings.cfg @@ -1,5 +1,5 @@ ########################################### -# KAMP Settings for Creality K1 Series +# KAMP Settings ########################################### # Below you can enable or disable specific configuration files depending on what you want KAMP to do: @@ -37,4 +37,4 @@ variable_flow_rate: 12 # Flow rate of purge in mm3/s. Defau variable_smart_park_height: 10 # Z position for Smart Park. Default is 10. gcode: - RESPOND TYPE=command MSG="Running the KAMP_Settings macro does nothing, it's only used for storing KAMP settings." + RESPOND TYPE=command MSG="Running the _KAMP_Settings macro does nothing, it's only used for storing KAMP settings." diff --git a/files/kamp/Line_Purge.cfg b/files/kamp/Line_Purge.cfg index c998fb3..dfea53b 100644 --- a/files/kamp/Line_Purge.cfg +++ b/files/kamp/Line_Purge.cfg @@ -1,5 +1,5 @@ ########################################### -# Line Purge for Creality K1 Series +# Purge Line Macros ########################################### [gcode_macro _LINE_PURGE] @@ -44,70 +44,28 @@ gcode: {% set purge_move_speed = (flow_rate / 5.0) * 60 | float %} {% if cross_section < 5 %} - RESPOND TYPE=command MSG="[Extruder] max_extrude_cross_section is insufficient for line purge, please set it to 5 or greater. Purge skipped." - {% else %} - {% if verbose_enable == True %} - RESPOND TYPE=command MSG="Moving filament tip {tip_distance}mm" - {% endif %} - {% if detect_object == 0 %} - RESPOND TYPE=command MSG="No object detected! Using classic purge line." - {% elif purge_y_origin_low > 0 %} - RESPOND TYPE=command MSG="KAMP line purge starting at {purge_x_center}, {purge_y_origin_low} and purging {purge_amount}mm of filament, requested flow rate is {flow_rate}mm3/s." - {% elif purge_x_origin_low > 0 %} - RESPOND TYPE=command MSG="KAMP line purge starting at {purge_x_origin_low}, {purge_y_center} and purging {purge_amount}mm of filament, requested flow rate is {flow_rate}mm3/s." - {% elif purge_y_origin_high < bed_y_max %} - RESPOND TYPE=command MSG="KAMP line purge starting at {purge_x_center}, {purge_y_origin_high} and purging {purge_amount}mm of filament, requested flow rate is {flow_rate}mm3/s." - {% elif purge_x_origin_high < bed_x_max %} - RESPOND TYPE=command MSG="KAMP line purge starting at {purge_x_origin_high}, {purge_y_center} and purging {purge_amount}mm of filament, requested flow rate is {flow_rate}mm3/s." - {% else %} - RESPOND TYPE=command MSG="No space for purge line! Using classic purge line." - {% endif %} - SAVE_GCODE_STATE NAME=Prepurge_State - {% if detect_object == 0 %} - - G92 E0 - G1 Z0.1 F600 - M83 - {RETRACT} - SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY=5 - M204 S12000 - SET_VELOCITY_LIMIT ACCEL_TO_DECEL=6000 - M220 S100 - M221 S100 - G1 Z2.0 F1200 - G1 X0.1 Y20 Z0.3 F6000.0 - G1 X0.1 Y180.0 Z0.3 F3000.0 E10.0 - G1 X0.4 Y180.0 Z0.3 F3000.0 - G1 X0.4 Y20.0 Z0.3 F3000.0 E10.0 - G1 Y10.0 F3000.0 - G1 Z2.0 F3000.0 - G92 E0 - M82 - G1 F12000 - G21 - + CX_PRINT_DRAW_ONE_LINE {% elif purge_y_origin_low > 0 %} - G92 E0 G0 F{travel_speed} G90 @@ -121,9 +79,7 @@ gcode: G92 E0 M82 G0 Z{purge_height * 2} F{travel_speed} - {% elif purge_x_origin_low > 0 %} - G92 E0 G0 F{travel_speed} G90 @@ -137,9 +93,7 @@ gcode: G92 E0 M82 G0 Z{purge_height * 2} F{travel_speed} - {% elif purge_y_origin_high < bed_y_max %} - G92 E0 G0 F{travel_speed} G90 @@ -153,9 +107,7 @@ gcode: G92 E0 M82 G0 Z{purge_height * 2} F{travel_speed} - {% elif purge_x_origin_high < bed_x_max %} - G92 E0 G0 F{travel_speed} G90 @@ -169,32 +121,8 @@ gcode: G92 E0 M82 G0 Z{purge_height * 2} F{travel_speed} - {% else %} - - G92 E0 - G1 Z0.1 F600 - M83 - {RETRACT} - SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY=5 - M204 S12000 - SET_VELOCITY_LIMIT ACCEL_TO_DECEL=6000 - M220 S100 - M221 S100 - G1 Z2.0 F1200 - G1 X0.1 Y20 Z0.3 F6000.0 - G1 X0.1 Y180.0 Z0.3 F3000.0 E10.0 - G1 X0.4 Y180.0 Z0.3 F3000.0 - G1 X0.4 Y20.0 Z0.3 F3000.0 E10.0 - G1 Y10.0 F3000.0 - G1 Z2.0 F3000.0 - G92 E0 - M82 - G1 F12000 - G21 - + CX_PRINT_DRAW_ONE_LINE {% endif %} - RESTORE_GCODE_STATE NAME=Prepurge_State - {% endif %} diff --git a/files/kamp/Prusa_Slicer.cfg b/files/kamp/Prusa_Slicer.cfg index 6ed8dc4..0a313d1 100644 --- a/files/kamp/Prusa_Slicer.cfg +++ b/files/kamp/Prusa_Slicer.cfg @@ -1,32 +1,38 @@ ########################################### -# PrusaSlicer Macros for Creality K1 Series +# PrusaSlicer Macros ########################################### [gcode_macro DEFINE_OBJECT] +description: Needed macro for Exclude Objects gcode: EXCLUDE_OBJECT_DEFINE {rawparams} [gcode_macro START_CURRENT_OBJECT] +description: Needed macro for Exclude Objects gcode: EXCLUDE_OBJECT_START NAME={params.NAME} [gcode_macro END_CURRENT_OBJECT] +description: Needed macro for Exclude Objects gcode: EXCLUDE_OBJECT_END {% if params.NAME %}NAME={params.NAME}{% endif %} [gcode_macro LIST_OBJECTS] +description: Needed macro for Exclude Objects gcode: EXCLUDE_OBJECT_DEFINE [gcode_macro LIST_EXCLUDED_OBJECTS] +description: Needed macro for Exclude Objects gcode: EXCLUDE_OBJECT [gcode_macro REMOVE_ALL_EXCLUDED] +description: Needed macro for Exclude Objects gcode: EXCLUDE_OBJECT RESET=1 diff --git a/files/kamp/Smart_Park.cfg b/files/kamp/Smart_Park.cfg index bf08741..7a6a269 100644 --- a/files/kamp/Smart_Park.cfg +++ b/files/kamp/Smart_Park.cfg @@ -1,5 +1,5 @@ ########################################### -# Smart Park for Creality K1 Series +# Smart Park Macros ########################################### [gcode_macro _SMART_PARK] @@ -59,21 +59,13 @@ gcode: {% endif %} {% if verbose_enable == True %} - RESPOND TYPE=command MSG="Smart Park location: {x_min},{y_min}" - {% endif %} - SAVE_GCODE_STATE NAME=Presmartpark_State - G90 {% if printer.toolhead.position.z < z_height %} - G0 Z{z_height} - {% endif %} - G0 X{x_min} Y{y_min} F{travel_speed} G0 Z{z_height} - RESTORE_GCODE_STATE NAME=Presmartpark_State diff --git a/files/kamp/Start_Print-3v3.cfg b/files/kamp/Start_Print-3v3.cfg new file mode 100644 index 0000000..d49d9f0 --- /dev/null +++ b/files/kamp/Start_Print-3v3.cfg @@ -0,0 +1,131 @@ +########################################### +# Additional Macros for Creality Ender-3 V3 +########################################### + +[respond] + +[virtual_pins] + +[output_pin ADAPTIVE_BED_MESH] +pin: virtual_pin:ADAPTIVE_BED_MESH_pin +value: 1 + +[output_pin FULL_BED_MESH] +pin: virtual_pin:FULL_BED_MESH_pin +value: 0 + +[output_pin ADAPTIVE_PURGE_LINE] +pin: virtual_pin:ADAPTIVE_PURGE_LINE_pin +value: 1 + + +[gcode_macro _ADAPTIVE_BED_MESH_ON] +description: Enable Adaptive Bed Mesh and Disable Full Bed Mesh +gcode: + SET_PIN PIN=ADAPTIVE_BED_MESH VALUE=1 + SET_PIN PIN=FULL_BED_MESH VALUE=0 + RESPOND TYPE=command MSG="action:prompt_end" + + +[gcode_macro _FULL_BED_MESH_ON] +description: Disable Adaptive Bed Mesh and Enable Full Bed Mesh +gcode: + SET_PIN PIN=ADAPTIVE_BED_MESH VALUE=0 + SET_PIN PIN=FULL_BED_MESH VALUE=1 + RESPOND TYPE=command MSG="action:prompt_end" + + +[gcode_macro _BED_MESH_OFF] +description: Disable Adaptive Bed Mesh and Enable Full Bed Mesh +gcode: + SET_PIN PIN=ADAPTIVE_BED_MESH VALUE=0 + SET_PIN PIN=FULL_BED_MESH VALUE=0 + RESPOND TYPE=command MSG="action:prompt_end" + + +[gcode_macro _ADAPTIVE_PURGE_LINE_ON] +description: Enable Adaptive Purge Line +gcode: + SET_PIN PIN=ADAPTIVE_PURGE_LINE VALUE=1 + RESPOND TYPE=command MSG="action:prompt_end" + + +[gcode_macro _ADAPTIVE_PURGE_LINE_OFF] +description: Disable Adaptive Purge Line +gcode: + SET_PIN PIN=ADAPTIVE_PURGE_LINE VALUE=0 + RESPOND TYPE=command MSG="action:prompt_end" + + +[gcode_macro KAMP_BED_MESH_SETTINGS] +description: Configure Bed Mesh type +gcode: + RESPOND TYPE=command MSG="action:prompt_begin Bed Mesh Settings" + RESPOND TYPE=command MSG="action:prompt_text What type of bed mesh do you want to use when you start printing?" + RESPOND TYPE=command MSG="action:prompt_button ADAPTIVE BED MESH|_ADAPTIVE_BED_MESH_ON|primary" + RESPOND TYPE=command MSG="action:prompt_button FULL BED MESH|_FULL_BED_MESH_ON|primary" + RESPOND TYPE=command MSG="action:prompt_button NONE|_BED_MESH_OFF|primary" + RESPOND TYPE=command MSG="action:prompt_show" + + +[gcode_macro KAMP_PURGE_LINE_SETTINGS] +description: Configure Purge Line type +gcode: + RESPOND TYPE=command MSG="action:prompt_begin Purge Line Settings" + RESPOND TYPE=command MSG="action:prompt_text What type of purge line do you want to use when you start printing?" + RESPOND TYPE=command MSG="action:prompt_button ADAPTIVE PURGE LINE|_ADAPTIVE_PURGE_LINE_ON|primary" + RESPOND TYPE=command MSG="action:prompt_button CLASSIC PURGE LINE|_ADAPTIVE_PURGE_LINE_OFF|primary" + RESPOND TYPE=command MSG="action:prompt_show" + + +[gcode_macro START_PRINT] +variable_prepare: 0 +variable_z_sensorless: 0 +gcode: + SET_GCODE_VARIABLE MACRO=M106 VARIABLE=user_flag VALUE=0 + WAIT_TEMP_END + CLEAR_PAUSE + SET_TEMPERATURE_FAN_TARGET temperature_fan=soc_fan target=5 + {% set g28_extruder_temp = printer.custom_macro.g28_ext_temp %} + {% set bed_temp = printer.custom_macro.default_bed_temp %} + {% set extruder_temp = printer.custom_macro.default_extruder_temp %} + {% if 'BED_TEMP' in params|upper and (params.BED_TEMP|float) %} + {% set bed_temp = params.BED_TEMP %} + {% endif %} + {% if 'EXTRUDER_TEMP' in params|upper and (params.EXTRUDER_TEMP|float) %} + {% set extruder_temp = params.EXTRUDER_TEMP %} + {% endif %} + {% if printer['gcode_macro START_PRINT'].prepare|int == 0 %} + {action_respond_info("not prepare.\n")} + PRINT_PREPARE_CLEAR + CX_ROUGH_G28 EXTRUDER_TEMP={extruder_temp} BED_TEMP={bed_temp} + CX_NOZZLE_CLEAR + Z_SENSORLESS_SET + ACCURATE_G28 + {% if printer['output_pin ADAPTIVE_BED_MESH'].value == 1 %} + RESPOND TYPE=command MSG="Starting Adaptative Bed Mesh..." + BED_MESH_CLEAR + BED_MESH_CALIBRATE + BED_MESH_PROFILE SAVE=adaptive + BED_MESH_PROFILE LOAD=adaptive + {% else %} + {% if printer['output_pin FULL_BED_MESH'].value == 1 %} + RESPOND TYPE=command MSG="Starting Full Bed Mesh..." + CX_PRINT_LEVELING_CALIBRATION + {% endif %} + BED_MESH_PROFILE LOAD=default + {% endif %} + {% else %} + PRINT_PREPARE_CLEAR + {% endif %} + {% if printer['output_pin ADAPTIVE_PURGE_LINE'].value == 1 %} + _SMART_PARK + M109 S{extruder_temp} + M190 S{bed_temp} + RESPOND TYPE=command MSG="Starting Adaptive Purge Line..." + _LINE_PURGE + {% else %} + RESPOND TYPE=command MSG="Starting Classic Purge Line..." + CX_PRINT_DRAW_ONE_LINE + {% endif %} + SET_VELOCITY_LIMIT ACCEL={printer.configfile.settings.printer.max_accel} diff --git a/files/kamp/Start_Print.cfg b/files/kamp/Start_Print.cfg index ec353bd..569e91d 100644 --- a/files/kamp/Start_Print.cfg +++ b/files/kamp/Start_Print.cfg @@ -1,20 +1,83 @@ ########################################### -# Start Print Macro for Creality K1 Series +# Additional Macros for Creality K1 Series ########################################### [respond] [virtual_pins] -[output_pin KAMP] -pin: virtual_pin:KAMP_pin +[output_pin ADAPTIVE_BED_MESH] +pin: virtual_pin:ADAPTIVE_BED_MESH_pin value: 1 -[output_pin BED_LEVELING] -pin: virtual_pin:BED_LEVELING_pin +[output_pin FULL_BED_MESH] +pin: virtual_pin:FULL_BED_MESH_pin +value: 0 + +[output_pin ADAPTIVE_PURGE_LINE] +pin: virtual_pin:ADAPTIVE_PURGE_LINE_pin value: 1 +[gcode_macro _ADAPTIVE_BED_MESH_ON] +description: Enable Adaptive Bed Mesh and Disable Full Bed Mesh +gcode: + SET_PIN PIN=ADAPTIVE_BED_MESH VALUE=1 + SET_PIN PIN=FULL_BED_MESH VALUE=0 + RESPOND TYPE=command MSG="action:prompt_end" + + +[gcode_macro _FULL_BED_MESH_ON] +description: Disable Adaptive Bed Mesh and Enable Full Bed Mesh +gcode: + SET_PIN PIN=ADAPTIVE_BED_MESH VALUE=0 + SET_PIN PIN=FULL_BED_MESH VALUE=1 + RESPOND TYPE=command MSG="action:prompt_end" + + +[gcode_macro _BED_MESH_OFF] +description: Disable Adaptive Bed Mesh and Enable Full Bed Mesh +gcode: + SET_PIN PIN=ADAPTIVE_BED_MESH VALUE=0 + SET_PIN PIN=FULL_BED_MESH VALUE=0 + RESPOND TYPE=command MSG="action:prompt_end" + + +[gcode_macro _ADAPTIVE_PURGE_LINE_ON] +description: Enable Adaptive Purge Line +gcode: + SET_PIN PIN=ADAPTIVE_PURGE_LINE VALUE=1 + RESPOND TYPE=command MSG="action:prompt_end" + + +[gcode_macro _ADAPTIVE_PURGE_LINE_OFF] +description: Disable Adaptive Purge Line +gcode: + SET_PIN PIN=ADAPTIVE_PURGE_LINE VALUE=0 + RESPOND TYPE=command MSG="action:prompt_end" + + +[gcode_macro KAMP_BED_MESH_SETTINGS] +description: Configure Bed Mesh type +gcode: + RESPOND TYPE=command MSG="action:prompt_begin Bed Mesh Settings" + RESPOND TYPE=command MSG="action:prompt_text What type of bed mesh do you want to use when you start printing?" + RESPOND TYPE=command MSG="action:prompt_button ADAPTIVE BED MESH|_ADAPTIVE_BED_MESH_ON|primary" + RESPOND TYPE=command MSG="action:prompt_button FULL BED MESH|_FULL_BED_MESH_ON|primary" + RESPOND TYPE=command MSG="action:prompt_button NONE|_BED_MESH_OFF|primary" + RESPOND TYPE=command MSG="action:prompt_show" + + +[gcode_macro KAMP_PURGE_LINE_SETTINGS] +description: Configure Purge Line type +gcode: + RESPOND TYPE=command MSG="action:prompt_begin Purge Line Settings" + RESPOND TYPE=command MSG="action:prompt_text What type of purge line do you want to use when you start printing?" + RESPOND TYPE=command MSG="action:prompt_button ADAPTIVE PURGE LINE|_ADAPTIVE_PURGE_LINE_ON|primary" + RESPOND TYPE=command MSG="action:prompt_button CLASSIC PURGE LINE|_ADAPTIVE_PURGE_LINE_OFF|primary" + RESPOND TYPE=command MSG="action:prompt_show" + + [gcode_macro START_PRINT] variable_prepare: 0 gcode: @@ -34,14 +97,14 @@ gcode: CX_ROUGH_G28 EXTRUDER_TEMP={extruder_temp} BED_TEMP={bed_temp} CX_NOZZLE_CLEAR ACCURATE_G28 - {% if printer['output_pin KAMP'].value == 1 %} - RESPOND TYPE=command MSG="Starting KAMP Bed Mesh..." + {% if printer['output_pin ADAPTIVE_BED_MESH'].value == 1 %} + RESPOND TYPE=command MSG="Starting Adaptive Bed Mesh..." BED_MESH_CLEAR BED_MESH_CALIBRATE - BED_MESH_PROFILE SAVE=kamp - BED_MESH_PROFILE LOAD=kamp + BED_MESH_PROFILE SAVE=adaptive + BED_MESH_PROFILE LOAD=adaptive {% else %} - {% if printer['output_pin BED_LEVELING'].value == 1 %} + {% if printer['output_pin FULL_BED_MESH'].value == 1 %} RESPOND TYPE=command MSG="Starting Full Bed Mesh..." CX_PRINT_LEVELING_CALIBRATION {% endif %} @@ -50,14 +113,14 @@ gcode: {% else %} PRINT_PREPARE_CLEAR {% endif %} - {% if printer['output_pin KAMP'].value == 1 %} + {% if printer['output_pin ADAPTIVE_PURGE_LINE'].value == 1 %} _SMART_PARK M109 S{extruder_temp} M190 S{bed_temp} - RESPOND TYPE=command MSG="Starting KAMP line purge..." + RESPOND TYPE=command MSG="Starting Adaptive Purge Line..." _LINE_PURGE {% else %} - RESPOND TYPE=command MSG="Starting classic line purge..." + RESPOND TYPE=command MSG="Starting Classic Purge Line..." CX_PRINT_DRAW_ONE_LINE {% endif %} SET_VELOCITY_LIMIT ACCEL={printer.configfile.settings.printer.max_accel} diff --git a/files/macros/M600-support-3v3.cfg b/files/macros/M600-support-3v3.cfg new file mode 100644 index 0000000..3f42a2a --- /dev/null +++ b/files/macros/M600-support-3v3.cfg @@ -0,0 +1,176 @@ +######################################## +# M600 Support +######################################## + +[respond] + +[idle_timeout] +gcode: + RESPOND TYPE=command MSG="Stopping hotend heating..." + M104 S0 +timeout: 99999999 + + +[filament_switch_sensor filament_sensor] +pause_on_runout: false +switch_pin: !PC15 +runout_gcode: + M600 + + +[gcode_macro _UNLOAD_FILAMENT] +gcode: + RESTORE_E_CURRENT + M109 S{printer['gcode_macro PRINTER_PARAM'].hotend_temp|int} + RESPOND TYPE=command MSG="Unloading filament..." + M83 + G1 E10 F300 + G1 E-15 F3000 + G1 E-22.4700 F2400 + G1 E-6.4200 F1200 + G1 E-3.2100 F720 + G1 E5.0000 F356 + G1 E-5.0000 F384 + G1 E5.0000 F412 + G1 E-5.0000 F440 + G1 E5.0000 F467 + G1 E-5.0000 F495 + G1 E5.0000 F523 + G1 E-5.0000 F3000 + G1 E-15 F3000 + SET_E_MIN_CURRENT + + +[gcode_macro _LOAD_FILAMENT] +gcode: + RESTORE_E_CURRENT + M109 S{printer['gcode_macro PRINTER_PARAM'].hotend_temp|int} + RESPOND TYPE=command MSG="Loading filament..." + G91 + G1 E100 F180 + G90 + M400 + SET_E_MIN_CURRENT + + +[gcode_macro _PURGE_MORE] +gcode: + RESTORE_E_CURRENT + M109 S{printer['gcode_macro PRINTER_PARAM'].hotend_temp|int} + RESPOND TYPE=command MSG="Purging filament..." + G91 + G1 E10 F180 + G90 + M400 + SET_E_MIN_CURRENT + + +[gcode_macro M600] +description: Filament Change +variable_m600_state: 0 +variable_fan0_speed: 0 +gcode: + {% set E = printer["gcode_macro PAUSE"].extrude|float %} + {% set y_park = printer.toolhead.axis_minimum.y|float + 5.0 %} + {% set x_park = printer.toolhead.axis_maximum.x|float - 10.0 %} + {% set max_z = printer["gcode_macro PRINTER_PARAM"].max_z_position|float %} + {% set act_z = printer.toolhead.position.z|float %} + {% set z_safe = 0.0 %} + {% if act_z < 48.0 %} + {% set z_safe = 50.0 - act_z %} + {% elif act_z < (max_z - 2.0) %} + {% set z_safe = 2.0 %} + {% elif act_z < max_z %} + {% set z_safe = max_z - act_z %} + {% endif %} + {action_respond_info("z_safe = %s"% (z_safe))} + SET_GCODE_VARIABLE MACRO=M600 VARIABLE=m600_state VALUE=1 + SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=hotend_temp VALUE={printer.extruder.target} + SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=z_safe_pause VALUE={z_safe|float} + RESPOND TYPE=command MSG="Print paused for filament change!" + PAUSE_BASE + G91 + {% if "xyz" in printer.toolhead.homed_axes %} + {% if printer.extruder.can_extrude|lower == 'true' %} + G1 E-1.0 F180 + G1 E-{E} F4000 + {% else %} + RESPOND TYPE=command MSG="Extruder not hot enough!" + {% endif %} + G1 Z{z_safe} F600 + M400 + G90 + G1 X{x_park} Y{y_park} F12000 + {% endif %} + _UNLOAD_FILAMENT + SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=fan2_speed VALUE={printer['output_pin fan2'].value} + SET_GCODE_VARIABLE MACRO=M600 VARIABLE=fan0_speed VALUE={printer['output_pin fan0'].value} + M106 P0 S0 + M106 P2 S0 + SET_IDLE_TIMEOUT TIMEOUT=900 + SET_E_MIN_CURRENT + RESPOND TYPE=command MSG="action:prompt_begin Filament change detected!" + RESPOND TYPE=command MSG="action:prompt_text A necessary filament change has been detected. Please replace filament, LOAD it and click RESUME button." + RESPOND TYPE=command MSG="action:prompt_button UNLOAD FILAMENT|_UNLOAD_FILAMENT|secondary" + RESPOND TYPE=command MSG="action:prompt_button LOAD FILAMENT|_LOAD_FILAMENT|secondary" + RESPOND TYPE=command MSG="action:prompt_button PURGE MORE FILAMENT|_PURGE_MORE|secondary" + RESPOND TYPE=command MSG="action:prompt_footer_button CANCEL PRINT|CANCEL_PRINT|error" + RESPOND TYPE=command MSG="action:prompt_footer_button IGNORE|RESPOND TYPE=command MSG=action:prompt_end|warning" + RESPOND TYPE=command MSG="action:prompt_footer_button RESUME|RESUME|primary" + RESPOND TYPE=command MSG="action:prompt_show" + + +[gcode_macro RESUME] +description: Resume the current print +rename_existing: RESUME_BASE +gcode: + RESTORE_E_CURRENT + {% if printer['gcode_macro PRINTER_PARAM'].hotend_temp|int != 0 %} + {% if printer['gcode_macro PRINTER_PARAM'].hotend_temp|int > printer.extruder.temperature %} + RESPOND TYPE=command MSG="Starting hotend heating..." + M109 S{printer['gcode_macro PRINTER_PARAM'].hotend_temp|int} + {% else %} + RESPOND TYPE=command MSG="Starting hotend heating..." + M104 S{printer['gcode_macro PRINTER_PARAM'].hotend_temp|int} + {% endif %} + SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=hotend_temp VALUE=0 + {% endif %} + {% if printer['gcode_macro PRINTER_PARAM'].fan2_speed > 0 %} + {% set s_value = (printer['gcode_macro PRINTER_PARAM'].fan2_speed * 255 - printer['gcode_macro PRINTER_PARAM'].fan2_min) * 255 / (255 - printer['gcode_macro PRINTER_PARAM'].fan2_min)|float %} + M106 P2 S{s_value} G1 + {% endif %} + {% if printer['gcode_macro M600'].m600_state != 1 %} + {% set z_resume_move = printer['gcode_macro PRINTER_PARAM'].z_safe_pause|int %} + {% if z_resume_move > 2 %} + {% set z_resume_move = z_resume_move - 2 %} + G91 + G1 Z-{z_resume_move} F600 + M400 + {% endif %} + {% endif %} + {% set E = printer["gcode_macro PAUSE"].extrude|float + 1.0 %} + {% if 'VELOCITY' in params|upper %} + {% set get_params = ('VELOCITY=' + params.VELOCITY) %} + {%else %} + {% set get_params = "" %} + {% endif %} + {% if printer["gcode_macro M600"].m600_state == 1 %} + {% if printer['gcode_macro M600'].fan0_speed > 0 %} + {% set s_value = (printer['gcode_macro M600'].fan0_speed * 255 - printer['gcode_macro PRINTER_PARAM'].fan0_min) * 255 / (255 - printer['gcode_macro PRINTER_PARAM'].fan0_min)|float %} + M106 P0 S{s_value} G1 + {% endif %} + SET_GCODE_VARIABLE MACRO=M600 VARIABLE=m600_state VALUE=0 + SET_IDLE_TIMEOUT TIMEOUT=99999999 + {% else %} + {% if printer.extruder.can_extrude|lower == 'true' %} + G91 + G1 E{E} F2100 + G90 + M400 + {% else %} + RESPOND TYPE=command MSG="Extruder not hot enough!" + {% endif %} + {% endif %} + RESPOND TYPE=command MSG="action:prompt_end" + RESPOND TYPE=command MSG="Restarting print..." + RESUME_BASE {get_params} diff --git a/files/macros/M600-support.cfg b/files/macros/M600-support.cfg index 8d974bf..9d125fc 100644 --- a/files/macros/M600-support.cfg +++ b/files/macros/M600-support.cfg @@ -18,6 +18,53 @@ runout_gcode: M600 +[gcode_macro _UNLOAD_FILAMENT] +gcode: + RESTORE_E_CURRENT + M109 S{printer['gcode_macro PRINTER_PARAM'].hotend_temp|int} + RESPOND TYPE=command MSG="Unloading filament..." + M83 + G1 E10 F300 + G1 E-15 F3000 + G1 E-22.4700 F2400 + G1 E-6.4200 F1200 + G1 E-3.2100 F720 + G1 E5.0000 F356 + G1 E-5.0000 F384 + G1 E5.0000 F412 + G1 E-5.0000 F440 + G1 E5.0000 F467 + G1 E-5.0000 F495 + G1 E5.0000 F523 + G1 E-5.0000 F3000 + G1 E-15 F3000 + SET_E_MIN_CURRENT + + +[gcode_macro _LOAD_FILAMENT] +gcode: + RESTORE_E_CURRENT + M109 S{printer['gcode_macro PRINTER_PARAM'].hotend_temp|int} + RESPOND TYPE=command MSG="Loading filament..." + G91 + G1 E100 F180 + G90 + M400 + SET_E_MIN_CURRENT + + +[gcode_macro _PURGE_MORE] +gcode: + RESTORE_E_CURRENT + M109 S{printer['gcode_macro PRINTER_PARAM'].hotend_temp|int} + RESPOND TYPE=command MSG="Purging filament..." + G91 + G1 E10 F180 + G90 + M400 + SET_E_MIN_CURRENT + + [gcode_macro M600] description: Filament Change variable_m600_state: 0 @@ -55,22 +102,22 @@ gcode: G90 G1 X{x_park} Y{y_park} F30000 {% endif %} - G91 - {% if printer.extruder.can_extrude|lower == 'true' %} - RESPOND TYPE=command MSG="Extracting filament..." - G1 E20 F180 - G1 E-30 F180 - G1 E-50 F2000 - {% else %} - RESPOND TYPE=command MSG="Extruder not hot enough!" - {% endif %} + _UNLOAD_FILAMENT SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=fan2_speed VALUE={printer['output_pin fan2'].value} SET_GCODE_VARIABLE MACRO=M600 VARIABLE=fan0_speed VALUE={printer['output_pin fan0'].value} M106 P0 S0 M106 P2 S0 SET_IDLE_TIMEOUT TIMEOUT=900 SET_E_MIN_CURRENT - RESPOND TYPE=command MSG="Replace filament at the extruder inlet and click on Resume button!" + RESPOND TYPE=command MSG="action:prompt_begin Filament change detected!" + RESPOND TYPE=command MSG="action:prompt_text A necessary filament change has been detected. Please replace filament, LOAD it and click RESUME button." + RESPOND TYPE=command MSG="action:prompt_button UNLOAD FILAMENT|_UNLOAD_FILAMENT|secondary" + RESPOND TYPE=command MSG="action:prompt_button LOAD FILAMENT|_LOAD_FILAMENT|secondary" + RESPOND TYPE=command MSG="action:prompt_button PURGE MORE FILAMENT|_PURGE_MORE|secondary" + RESPOND TYPE=command MSG="action:prompt_footer_button CANCEL PRINT|CANCEL_PRINT|error" + RESPOND TYPE=command MSG="action:prompt_footer_button IGNORE|RESPOND TYPE=command MSG=action:prompt_end|warning" + RESPOND TYPE=command MSG="action:prompt_footer_button RESUME|RESUME|primary" + RESPOND TYPE=command MSG="action:prompt_show" [gcode_macro RESUME] @@ -108,15 +155,6 @@ gcode: {% set get_params = "" %} {% endif %} {% if printer["gcode_macro M600"].m600_state == 1 %} - {% if printer.extruder.can_extrude|lower == 'true' %} - RESPOND TYPE=command MSG="Loading and purging filament..." - G91 - G1 E100 F180 - G90 - M400 - {% else %} - RESPOND TYPE=command MSG="Extruder not hot enough!" - {% endif %} {% if printer['gcode_macro M600'].fan0_speed > 0 %} {% set s_value = (printer['gcode_macro M600'].fan0_speed * 255 - printer['gcode_macro PRINTER_PARAM'].fan0_min) * 255 / (255 - printer['gcode_macro PRINTER_PARAM'].fan0_min)|float %} M106 P0 S{s_value} @@ -133,5 +171,6 @@ gcode: RESPOND TYPE=command MSG="Extruder not hot enough!" {% endif %} {% endif %} + RESPOND TYPE=command MSG="action:prompt_end" RESPOND TYPE=command MSG="Restarting print..." RESUME_BASE {get_params} diff --git a/files/macros/fans-control.cfg b/files/macros/fans-control.cfg index 65c1c25..554f44a 100644 --- a/files/macros/fans-control.cfg +++ b/files/macros/fans-control.cfg @@ -5,7 +5,7 @@ [respond] [duplicate_pin_override] -pins: PC0, PC5, PB2, ADC_TEMPERATURE +pins: PC0, PC5, PB2, PC6, ADC_TEMPERATURE [temperature_fan chamber_fan] @@ -25,7 +25,7 @@ max_speed: 1.0 min_speed: 0.0 -[temperature_fan mcu_fan] +[temperature_fan soc_fan] pin: PB2 cycle_time: 0.0100 hardware_pwm: false @@ -39,9 +39,10 @@ max_delta: 2 target_temp: 50.0 max_speed: 1.0 min_speed: 0.0 +tachometer_pin:PC6 -[output_pin mcu_fan] +[output_pin soc_fan] pin: PB2 pwm: True cycle_time: 0.0100 diff --git a/files/macros/useful-macros-3v3.cfg b/files/macros/useful-macros-3v3.cfg new file mode 100644 index 0000000..3cda86a --- /dev/null +++ b/files/macros/useful-macros-3v3.cfg @@ -0,0 +1,232 @@ +######################################## +# Useful Macros +######################################## + +[gcode_shell_command Klipper_Backup] +command: sh /usr/data/helper-script/files/scripts/useful_macros.sh -backup_klipper +timeout: 600.0 +verbose: true + +[gcode_shell_command Klipper_Restore] +command: sh /usr/data/helper-script/files/scripts/useful_macros.sh -restore_klipper +timeout: 600.0 +verbose: true + +[gcode_shell_command Moonraker_Backup] +command: sh /usr/data/helper-script/files/scripts/useful_macros.sh -backup_moonraker +timeout: 600.0 +verbose: true + +[gcode_shell_command Moonraker_Restore] +command: sh /usr/data/helper-script/files/scripts/useful_macros.sh -restore_moonraker +timeout: 600.0 +verbose: true + +[gcode_shell_command Reload_Camera] +command: sh /usr/data/helper-script/files/scripts/useful_macros.sh -reload_camera +timeout: 600.0 +verbose: true + + +[gcode_macro _KLIPPER_BACKUP] +gcode: + RUN_SHELL_COMMAND CMD=Klipper_Backup + RESPOND TYPE=command MSG="action:prompt_end" + + +[gcode_macro _KLIPPER_RESTORE] +gcode: + RUN_SHELL_COMMAND CMD=Klipper_Restore + RESPOND TYPE=command MSG="action:prompt_end" + + +[gcode_macro _MOONRAKER_BACKUP] +gcode: + RUN_SHELL_COMMAND CMD=Moonraker_Backup + RESPOND TYPE=command MSG="action:prompt_end" + + +[gcode_macro _MOONRAKER_RESTORE] +gcode: + RUN_SHELL_COMMAND CMD=Moonraker_Restore + RESPOND TYPE=command MSG="action:prompt_end" + + +[gcode_macro KLIPPER_BACKUP_CONFIG] +description: Backup Klipper configuration files +gcode: + RESPOND TYPE=command MSG="action:prompt_begin Backup Klipper configuration files" + RESPOND TYPE=command MSG="action:prompt_text Do you want to backup Klipper configuration files?" + RESPOND TYPE=command MSG="action:prompt_footer_button CANCEL|RESPOND TYPE=command MSG="action:prompt_end"|error" + RESPOND TYPE=command MSG="action:prompt_footer_button BACKUP|_KLIPPER_BACKUP|primary" + RESPOND TYPE=command MSG="action:prompt_show" + + +[gcode_macro KLIPPER_RESTORE_CONFIG] +description: Restore Klipper configuration files +gcode: + RESPOND TYPE=command MSG="action:prompt_begin Restore Klipper configuration files" + RESPOND TYPE=command MSG="action:prompt_text Do you want to restore Klipper configuration files?" + RESPOND TYPE=command MSG="action:prompt_footer_button CANCEL|RESPOND TYPE=command MSG="action:prompt_end"|error" + RESPOND TYPE=command MSG="action:prompt_footer_button RESTORE|_KLIPPER_RESTORE|primary" + RESPOND TYPE=command MSG="action:prompt_show" + + +[gcode_macro MOONRAKER_BACKUP_DATABASE] +description: Backup Moonraker database +gcode: + RESPOND TYPE=command MSG="action:prompt_begin Backup Moonraker database" + RESPOND TYPE=command MSG="action:prompt_text Do you want to backup Moonraker database?" + RESPOND TYPE=command MSG="action:prompt_footer_button CANCEL|RESPOND TYPE=command MSG="action:prompt_end"|error" + RESPOND TYPE=command MSG="action:prompt_footer_button BACKUP|_MOONRAKER_BACKUP|primary" + RESPOND TYPE=command MSG="action:prompt_show" + + +[gcode_macro MOONRAKER_RESTORE_DATABASE] +description: Restore Moonraker database +gcode: + RESPOND TYPE=command MSG="action:prompt_begin Restore Moonraker database" + RESPOND TYPE=command MSG="action:prompt_text Do you want to restore Moonraker database?" + RESPOND TYPE=command MSG="action:prompt_footer_button CANCEL|RESPOND TYPE=command MSG="action:prompt_end"|error" + RESPOND TYPE=command MSG="action:prompt_footer_button RESTORE|_MOONRAKER_RESTORE|primary" + RESPOND TYPE=command MSG="action:prompt_show" + + +[gcode_macro RELOAD_CAMERA] +description: Reload camera service +gcode: + RUN_SHELL_COMMAND CMD=Reload_Camera + + +[gcode_macro BED_LEVELING] +description: Start Bed Leveling +gcode: + {% if 'PROBE_COUNT' in params|upper %} + {% set get_count = ('PROBE_COUNT=' + params.PROBE_COUNT) %} + {%else %} + {% set get_count = "" %} + {% endif %} + {% set bed_temp = printer.custom_macro.default_bed_temp %} + {% set extruder_temp = printer.custom_macro.g28_ext_temp %} + {% set nozzle_clear_temp = printer.custom_macro.default_extruder_temp %} + {% if 'BED_TEMP' in params|upper %} + {% set bed_temp = params.BED_TEMP %} + {% endif %} + {% if 'EXTRUDER_TEMP' in params|upper %} + {% set nozzle_clear_temp = params.EXTRUDER_TEMP %} + {% endif %} + SET_FILAMENT_SENSOR SENSOR=filament_sensor ENABLE=0 + SET_TEMPERATURE_FAN_TARGET temperature_fan=soc_fan target=5 + M109 S140 + {% if printer.toolhead.homed_axes != "xyz" %} + G28 + {% endif %} + BED_MESH_CLEAR + NOZZLE_CLEAR HOT_MIN_TEMP={hotend_temp} HOT_MAX_TEMP={nozzle_clear_temp} BED_MAX_TEMP={bed_temp} + M204 S5000 + SET_VELOCITY_LIMIT ACCEL_TO_DECEL=5000 + BED_MESH_CALIBRATE {get_count} + BED_MESH_OUTPUT + {% set y_park = printer.toolhead.axis_maximum.y/2 %} + {% set x_park = printer.toolhead.axis_maximum.x|float - 10.0 %} + G1 X{x_park} Y{y_park} F3600 + TURN_OFF_HEATERS + SET_TEMPERATURE_FAN_TARGET temperature_fan=soc_fan target=45 + SET_FILAMENT_SENSOR SENSOR=filament_sensor ENABLE=1 + + +[gcode_macro PID_BED] +description: Start Bed PID +gcode: + G90 + {% if printer.toolhead.homed_axes != "xyz" %} + G28 + {% endif %} + G1 Z10 F600 + M106 + PID_CALIBRATE HEATER=heater_bed TARGET={params.BED_TEMP|default(70)} + M107 + {% set y_park = printer.toolhead.axis_maximum.y/2 %} + {% set x_park = printer.toolhead.axis_maximum.x|float - 10.0 %} + G1 X{x_park} Y{y_park} F6000 + + +[gcode_macro PID_HOTEND] +description: Start Hotend PID +gcode: + G90 + {% if printer.toolhead.homed_axes != "xyz" %} + G28 + {% endif %} + G1 Z10 F600 + M106 + PID_CALIBRATE HEATER=extruder TARGET={params.HOTEND_TEMP|default(250)} + M107 + {% set y_park = printer.toolhead.axis_maximum.y/2 %} + {% set x_park = printer.toolhead.axis_maximum.x|float - 10.0 %} + G1 X{x_park} Y{y_park} F6000 + WAIT_TEMP_START + + +[gcode_macro WARMUP] +description: Stress Test +variable_maxd: 14142.14 ; = SQRT(2*maxy) +gcode: + {% set min_loops = 2 %} + {% set max_loops = params.LOOPS|default(3)|int %} + {% if 'LOOPS' in params|upper %} + {% if max_loops < min_loops %} + {% set max_loops = min_loops %} + {% endif %} + {% endif %} + {% set loop_cnt = max_loops %} + {% set maxx = params.X_ACCEL_MAX|default(10000)|int %} + {% set maxy = params.Y_ACCEL_MAX|default(10000)|int %} + {% set max_x = (printer.toolhead.axis_maximum.x|int-5) %} + {% set max_y = (printer.toolhead.axis_maximum.y|int-5) %} + {% set loop_step_y = max_y//(loop_cnt-1) %} + {% set loop_step_x = max_x//(loop_cnt-1) %} + {% set y_park = printer.toolhead.axis_maximum.y/2 %} + {% set x_park = printer.toolhead.axis_maximum.x|float - 10.0 %} + {% if printer.toolhead.homed_axes != "xyz" %} + G28 + {% endif %} + SET_VELOCITY_LIMIT ACCEL={maxx} ACCEL_TO_DECEL={maxx/2} + {% for number in range(10,max_y+11,loop_step_y) %} + {% if number >= max_y %} + {% set number = max_y %} + {% endif %} + G1 F{maxy} X10 Y{number} + G1 F{maxx} X{max_x} Y{number} + {% endfor %} + SET_VELOCITY_LIMIT ACCEL={maxy} ACCEL_TO_DECEL={maxy/2} + {% for number in range(10,max_x+11,loop_step_y) %} + {% if number >= max_x %} + {% set number = max_x %} + {% endif %} + G1 F{maxy} X{number} Y{max_y} + G1 F{maxy} X{number} Y10 + {% endfor %} + SET_VELOCITY_LIMIT ACCEL={maxd} ACCEL_TO_DECEL={maxd/2} + {% for times in range(loop_cnt) %} + G1 F{maxx} X10 Y10 + G1 F{maxd} X{max_x} Y{max_y} + G1 F{maxx} X10 Y{max_y} + G1 F{maxd} X{max_x} Y10 + G1 F{maxy} X{max_x} Y{max_y} + G1 F{maxd} X10 Y10 + G1 F{maxy} X10 Y{max_y} + G1 F{maxd} X{max_x} Y10 + {% endfor %} + SET_VELOCITY_LIMIT ACCEL={maxx} ACCEL_TO_DECEL={maxx/2} + {% for times in range(loop_cnt) %} + G1 F{maxy} X10 Y10 + G1 F{maxy} X10 Y{max_y} + G1 F{maxx} X{max_x} Y{max_y} + G1 F{maxy} X{max_x} Y10 + G1 F{maxx} X10 Y10 + G1 F{maxx} X{max_x} Y10 + G1 F{maxy} X{max_x} Y{max_y} + G1 F{maxx} X10 Y{max_y} + {% endfor %} + G1 X{x_park} Y{y_park} F15000 diff --git a/files/macros/useful-macros.cfg b/files/macros/useful-macros.cfg index b32dde9..807ab77 100644 --- a/files/macros/useful-macros.cfg +++ b/files/macros/useful-macros.cfg @@ -28,26 +28,72 @@ timeout: 600.0 verbose: true -[gcode_macro KLIPPER_BACKUP_CONFIG] +[gcode_macro _KLIPPER_BACKUP] gcode: RUN_SHELL_COMMAND CMD=Klipper_Backup + RESPOND TYPE=command MSG="action:prompt_end" + + +[gcode_macro _KLIPPER_RESTORE] +gcode: + RUN_SHELL_COMMAND CMD=Klipper_Restore + RESPOND TYPE=command MSG="action:prompt_end" + + +[gcode_macro _MOONRAKER_BACKUP] +gcode: + RUN_SHELL_COMMAND CMD=Moonraker_Backup + RESPOND TYPE=command MSG="action:prompt_end" + + +[gcode_macro _MOONRAKER_RESTORE] +gcode: + RUN_SHELL_COMMAND CMD=Moonraker_Restore + RESPOND TYPE=command MSG="action:prompt_end" + + +[gcode_macro KLIPPER_BACKUP_CONFIG] +description: Backup Klipper configuration files +gcode: + RESPOND TYPE=command MSG="action:prompt_begin Backup Klipper configuration files" + RESPOND TYPE=command MSG="action:prompt_text Do you want to backup Klipper configuration files?" + RESPOND TYPE=command MSG="action:prompt_footer_button CANCEL|RESPOND TYPE=command MSG="action:prompt_end"|error" + RESPOND TYPE=command MSG="action:prompt_footer_button BACKUP|_KLIPPER_BACKUP|primary" + RESPOND TYPE=command MSG="action:prompt_show" [gcode_macro KLIPPER_RESTORE_CONFIG] +description: Restore Klipper configuration files gcode: - RUN_SHELL_COMMAND CMD=Klipper_Restore + RESPOND TYPE=command MSG="action:prompt_begin Restore Klipper configuration files" + RESPOND TYPE=command MSG="action:prompt_text Do you want to restore Klipper configuration files?" + RESPOND TYPE=command MSG="action:prompt_footer_button CANCEL|RESPOND TYPE=command MSG="action:prompt_end"|error" + RESPOND TYPE=command MSG="action:prompt_footer_button RESTORE|_KLIPPER_RESTORE|primary" + RESPOND TYPE=command MSG="action:prompt_show" [gcode_macro MOONRAKER_BACKUP_DATABASE] +description: Backup Moonraker database gcode: - RUN_SHELL_COMMAND CMD=Moonraker_Backup + RESPOND TYPE=command MSG="action:prompt_begin Backup Moonraker database" + RESPOND TYPE=command MSG="action:prompt_text Do you want to backup Moonraker database?" + RESPOND TYPE=command MSG="action:prompt_footer_button CANCEL|RESPOND TYPE=command MSG="action:prompt_end"|error" + RESPOND TYPE=command MSG="action:prompt_footer_button BACKUP|_MOONRAKER_BACKUP|primary" + RESPOND TYPE=command MSG="action:prompt_show" [gcode_macro MOONRAKER_RESTORE_DATABASE] +description: Restore Moonraker database gcode: - RUN_SHELL_COMMAND CMD=Moonraker_Restore + RESPOND TYPE=command MSG="action:prompt_begin Restore Moonraker database" + RESPOND TYPE=command MSG="action:prompt_text Do you want to restore Moonraker database?" + RESPOND TYPE=command MSG="action:prompt_footer_button CANCEL|RESPOND TYPE=command MSG="action:prompt_end"|error" + RESPOND TYPE=command MSG="action:prompt_footer_button RESTORE|_MOONRAKER_RESTORE|primary" + RESPOND TYPE=command MSG="action:prompt_show" + [gcode_macro RELOAD_CAMERA] +description: Reload camera service gcode: RUN_SHELL_COMMAND CMD=Reload_Camera @@ -56,9 +102,9 @@ gcode: description: Start Bed Leveling gcode: {% if 'PROBE_COUNT' in params|upper %} - {% set get_count = ('PROBE_COUNT=' + params.PROBE_COUNT) %} + {% set get_count = ('PROBE_COUNT=' + params.PROBE_COUNT) %} {%else %} - {% set get_count = "" %} + {% set get_count = "" %} {% endif %} {% set bed_temp = params.BED_TEMP|default(50)|float %} {% set hotend_temp = params.HOTEND_TEMP|default(140)|float %} @@ -114,38 +160,6 @@ gcode: WAIT_TEMP_START -[gcode_macro LUBRICATE_RODS] -description: Distribute lubricant on Rods -gcode: - {% set min_speed = 3000 %} # Minimum speed in mm/min - {% set max_speed = 18000 %} # Maximum speed in mm/min - {% if printer.toolhead.homed_axes != "xyz" %} - G28 - {% endif %} - G1 Z50 F300 - {% set x_max = printer.toolhead.axis_maximum.x|int %} - {% set y_max = printer.toolhead.axis_maximum.y|int %} - {% set edge_offset_x = x_max * 0.05 %} - {% set edge_offset_y = y_max * 0.05 %} - {% set x_range = x_max - edge_offset_x %} - {% set y_range = y_max - edge_offset_y %} - {% set num_steps_x = (x_range / 10)|int %} - {% set num_steps_y = (y_range / 10)|int %} - {% set speed_increment_x = (max_speed - min_speed) / num_steps_x %} - {% set speed_increment_y = (max_speed - min_speed) / num_steps_y %} - {% set current_speed_x = min_speed %} - {% set current_speed_y = min_speed %} - {% for i in range(num_steps_x) %} - G1 X{edge_offset_x + i * 10} Y{edge_offset_y} F{current_speed_x} - G1 X{edge_offset_x + i * 10} Y{y_range} F{current_speed_x} - {% set current_speed_x = current_speed_x + speed_increment_x %} - {% endfor %} - {% for j in range(num_steps_y) %} - G1 Y{edge_offset_y + j * 10} X{edge_offset_x} F{current_speed_y} - G1 Y{edge_offset_y + j * 10} X{x_range} F{current_speed_y} - {% set current_speed_y = current_speed_y + speed_increment_y %} - {% endfor %} - [gcode_macro WARMUP] description: Stress Test variable_maxd: 14142.14 ; = SQRT(2*maxy) @@ -158,12 +172,8 @@ gcode: {% endif %} {% endif %} {% set loop_cnt = max_loops %} - {% if 'X_ACCEL_MAX' in params|upper %} - {% set maxx = params.X_ACCEL_MAX|default(10000)|int %} - {% endif %} - {% if 'Y_ACCEL_MAX' in params|upper %} - {% set maxy = params.Y_ACCEL_MAX|default(10000)|int %} - {% endif %} + {% set maxx = params.X_ACCEL_MAX|default(10000)|int %} + {% set maxy = params.Y_ACCEL_MAX|default(10000)|int %} {% set max_x = (printer.toolhead.axis_maximum.x|int-5) %} {% set max_y = (printer.toolhead.axis_maximum.y|int-5) %} {% set loop_step_y = max_y//(loop_cnt-1) %} diff --git a/files/moonraker/moonraker.tar.gz b/files/moonraker/moonraker.tar.gz index 3fbe80b..9b3417d 100644 Binary files a/files/moonraker/moonraker.tar.gz and b/files/moonraker/moonraker.tar.gz differ diff --git a/files/moonraker/nginx.conf b/files/moonraker/nginx.conf new file mode 100644 index 0000000..c7262d1 --- /dev/null +++ b/files/moonraker/nginx.conf @@ -0,0 +1,201 @@ +worker_processes 1; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + + sendfile on; + keepalive_timeout 65; + proxy_connect_timeout 1600; + proxy_send_timeout 1600; + proxy_read_timeout 1600; + send_timeout 1600; + + server { + listen 4408 default_server; + + access_log off; + error_log off; + gzip on; + gzip_vary on; + gzip_proxied any; + gzip_proxied expired no-cache no-store private auth; + gzip_comp_level 4; + gzip_buffers 16 8k; + gzip_http_version 1.1; + gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/json application/xml; + + root /usr/share/fluidd; + + index index.html; + server_name _; + + client_max_body_size 0; + proxy_request_buffering off; + + location / { + try_files $uri $uri/ /index.html; + } + + location = /index.html { + add_header Cache-Control "no-store, no-cache, must-revalidate"; + } + + location /websocket { + proxy_pass http://apiserver/websocket; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_read_timeout 86400; + } + + location ~ ^/(printer|api|access|machine|server)/ { + proxy_pass http://apiserver$request_uri; + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Scheme $scheme; + } + + location /webcam/ { + proxy_pass http://mjpgstreamer1/; + } + + location /webcam2/ { + proxy_pass http://mjpgstreamer2/; + } + + location /webcam3/ { + proxy_pass http://mjpgstreamer3/; + } + + location /webcam4/ { + proxy_pass http://mjpgstreamer4/; + } + } + + server { + listen 4409 default_server; + + access_log off; + error_log off; + gzip on; + gzip_vary on; + gzip_proxied any; + gzip_proxied expired no-cache no-store private auth; + gzip_comp_level 4; + gzip_buffers 16 8k; + gzip_http_version 1.1; + gzip_types text/plain text/css text/xml text/javascript application/javascript application/x-javascript application/json application/xml; + + root /usr/data/mainsail; + + index index.html; + server_name _; + + client_max_body_size 0; + proxy_request_buffering off; + + location / { + try_files $uri $uri/ /index.html; + } + + location = /index.html { + add_header Cache-Control "no-store, no-cache, must-revalidate"; + } + + location /websocket { + proxy_pass http://apiserver/websocket; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_read_timeout 86400; + } + + location ~ ^/(printer|api|access|machine|server)/ { + proxy_pass http://apiserver$request_uri; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Scheme $scheme; + } + + location /webcam/ { + postpone_output 0; + proxy_buffering off; + proxy_ignore_headers X-Accel-Buffering; + access_log off; + error_log off; + proxy_pass http://mjpgstreamer1/; + } + + location /webcam2/ { + postpone_output 0; + proxy_buffering off; + proxy_ignore_headers X-Accel-Buffering; + access_log off; + error_log off; + proxy_pass http://mjpgstreamer2/; + } + + location /webcam3/ { + postpone_output 0; + proxy_buffering off; + proxy_ignore_headers X-Accel-Buffering; + access_log off; + error_log off; + proxy_pass http://mjpgstreamer3/; + } + + location /webcam4/ { + postpone_output 0; + proxy_buffering off; + proxy_ignore_headers X-Accel-Buffering; + access_log off; + error_log off; + proxy_pass http://mjpgstreamer4/; + } + } + + map $http_upgrade $connection_upgrade { + default upgrade; + '' close; + } + upstream apiserver { + ip_hash; + server 127.0.0.1:7125; + } + + upstream mjpgstreamer1 { + ip_hash; + server 127.0.0.1:8080; + } + + upstream mjpgstreamer2 { + ip_hash; + server 127.0.0.1:8081; + } + + upstream mjpgstreamer3 { + ip_hash; + server 127.0.0.1:8082; + } + + upstream mjpgstreamer4 { + ip_hash; + server 127.0.0.1:8083; + } + +} diff --git a/files/moonraker/nginx.tar.gz b/files/moonraker/nginx.tar.gz new file mode 100644 index 0000000..0201db4 Binary files /dev/null and b/files/moonraker/nginx.tar.gz differ diff --git a/files/scripts/useful_macros.sh b/files/scripts/useful_macros.sh index f8151eb..39b5140 100755 --- a/files/scripts/useful_macros.sh +++ b/files/scripts/useful_macros.sh @@ -77,4 +77,4 @@ elif [ "$1" == "-reload_camera" ]; then else echo -e "Invalid argument. Usage: $0 [-backup_klipper | -restore_klipper | -backup_moonraker | -restore_moonraker | -reload_camera]" exit 1 -fi +fi \ No newline at end of file diff --git a/files/services/S50nginx b/files/services/S50nginx index f18a791..2bd89f9 100755 --- a/files/services/S50nginx +++ b/files/services/S50nginx @@ -9,13 +9,16 @@ NGINX_ARGS="-c /usr/data/nginx/nginx/nginx.conf" case "$1" in start) + echo "Starting nginx..." mkdir -p /var/log/nginx /var/tmp/nginx start-stop-daemon -S -p "$PIDFILE" --exec "$NGINX" -- $NGINX_ARGS ;; stop) + echo "Stopping nginx..." start-stop-daemon -K -x "$NGINX" -p "$PIDFILE" -o ;; reload|force-reload) + echo "Reloading nginx..." "$NGINX" -s reload ;; restart) diff --git a/files/services/S50usb_camera-dual b/files/services/S50usb_camera-dual new file mode 100755 index 0000000..782a880 --- /dev/null +++ b/files/services/S50usb_camera-dual @@ -0,0 +1,31 @@ +#!/bin/sh +# USB Camera Service +# Credit: destinal & Guilouz + +case "$1" in + start) + echo "Starting USB Camera..." + V4L_DEVS=$(v4l2-ctl --list-devices | grep -A1 usb | sed 's/^[[:space:]]*//g' | grep '^/dev') + CREALITY_CAMS=$(v4l2-ctl --list-devices | grep -E 'CREALITY' | wc -l) + if [ "x$V4L_DEVS" = "x" -o $CREALITY_CAMS -gt 0 ]; then + /opt/bin/mjpg_streamer -b -i "/opt/lib/mjpg-streamer/input_uvc.so -d /dev/video4 -r 1280x720 -f 15" -o "/opt/lib/mjpg-streamer/output_http.so -p 8080" + /opt/bin/mjpg_streamer -b -i "/opt/lib/mjpg-streamer/input_uvc.so -d /dev/video6 -r 1280x720 -f 15" -o "/opt/lib/mjpg-streamer/output_http.so -p 8081" + else + /opt/bin/mjpg_streamer -b -i "/opt/lib/mjpg-streamer/input_uvc.so -d /dev/video4 -r 1280x720 -f 15" -o "/opt/lib/mjpg-streamer/output_http.so -p 8080" + fi + ;; + stop) + echo "Stopping USB Camera..." + killall -q mjpg_streamer + ;; + restart|reload) + "$0" stop + sleep 1 + "$0" start + ;; + *) + echo "Usage: /etc/init.d/S50usb_camera {start|stop|restart}" + exit 1 +esac + +exit $? diff --git a/files/services/S50usb_camera-single b/files/services/S50usb_camera-single new file mode 100755 index 0000000..7ed7440 --- /dev/null +++ b/files/services/S50usb_camera-single @@ -0,0 +1,34 @@ +#!/bin/sh +# USB Camera Service +# Credit: destinal & Guilouz + +case "$1" in + start) + echo "Starting USB Camera..." + V4L_DEVS=$(v4l2-ctl --list-devices | grep -A1 usb | sed 's/^[[:space:]]*//g' | grep '^/dev') + CREALITY_CAMS=$(v4l2-ctl --list-devices | grep -E 'CREALITY|CCX2F3298' | wc -l) + if [ "x$V4L_DEVS" = "x" -o $CREALITY_CAMS -gt 0 ]; then + echo "Error: No third party camera found or you use a Creality camera!" + exit 1 + fi + PORT=8080 + for V4L_DEV in $V4L_DEVS; do + /opt/bin/mjpg_streamer -b -i "/opt/lib/mjpg-streamer/input_uvc.so -d $V4L_DEV -r 1280x720 -f 15" -o "/opt/lib/mjpg-streamer/output_http.so -p $PORT" + PORT=`expr $PORT + 1` + done + ;; + stop) + echo "Stopping USB Camera..." + killall -q mjpg_streamer + ;; + restart|reload) + "$0" stop + sleep 1 + "$0" start + ;; + *) + echo "Usage: /etc/init.d/S50usb_camera {start|stop|restart}" + exit 1 +esac + +exit $? diff --git a/files/services/S56moonraker_service b/files/services/S56moonraker_service index ee46be1..5240e73 100755 --- a/files/services/S56moonraker_service +++ b/files/services/S56moonraker_service @@ -12,36 +12,36 @@ PRINTER_LOGS_DIR=$PRINTER_DATA_DIR/logs PID_FILE=/var/run/moonraker.pid start() { - [ -d $PRINTER_DATA_DIR ] || mkdir -p $PRINTER_DATA_DIR - [ -d $PRINTER_CONFIG_DIR ] || mkdir -p $PRINTER_CONFIG_DIR - [ -d $PRINTER_LOGS_DIR ] || mkdir -p $PRINTER_LOGS_DIR - - rm -rf /usr/data/moonraker/tmp; mkdir -p /usr/data/moonraker/tmp - TMPDIR=/usr/data/moonraker/tmp HOME=/root start-stop-daemon -S -q -b -m -p $PID_FILE \ - --exec $PROG -- $PY_SCRIPT -d $PRINTER_DATA_DIR + + [ -d $PRINTER_DATA_DIR ] || mkdir -p $PRINTER_DATA_DIR + [ -d $PRINTER_CONFIG_DIR ] || mkdir -p $PRINTER_CONFIG_DIR + [ -d $PRINTER_LOGS_DIR ] || mkdir -p $PRINTER_LOGS_DIR + + HOME=/root start-stop-daemon -S -q -b -m -p $PID_FILE \ + --exec $PROG -- $PY_SCRIPT -d $PRINTER_DATA_DIR } stop() { - start-stop-daemon -K -q -p $PID_FILE + start-stop-daemon -K -q -p $PID_FILE } restart() { - stop - sleep 1 - start + stop + sleep 1 + start } case "$1" in start) - start - ;; + start + ;; stop) - stop - ;; + stop + ;; restart|reload) - restart - ;; + restart + ;; *) - echo "Usage: $0 {start|stop|restart}" - exit 1 + echo "Usage: $0 {start|stop|restart}" + exit 1 esac exit $? diff --git a/helper.sh b/helper.sh index 7e06157..f255e2b 100755 --- a/helper.sh +++ b/helper.sh @@ -6,6 +6,8 @@ clear HELPER_SCRIPT_FOLDER="$( cd "$( dirname "${0}" )" && pwd )" for script in "${HELPER_SCRIPT_FOLDER}/scripts/"*.sh; do . "${script}"; done for script in "${HELPER_SCRIPT_FOLDER}/scripts/menu/"*.sh; do . "${script}"; done +for script in "${HELPER_SCRIPT_FOLDER}/scripts/menu/3V3/"*.sh; do . "${script}"; done +for script in "${HELPER_SCRIPT_FOLDER}/scripts/menu/K1/"*.sh; do . "${script}"; done for script in "${HELPER_SCRIPT_FOLDER}/scripts/menu/KE/"*.sh; do . "${script}"; done function update_helper_script() { @@ -43,7 +45,7 @@ function update_menu() { echo -e " │ ${cyan}contain bug fixes, important changes or new features. ${white}│" echo -e " │ ${cyan}Please consider updating! ${white}│" hr - echo -e " │ See changelog here: ${yellow}https://tinyurl.com/223jc4zr ${white}│" + echo -e " │ See changelog here: ${yellow}https://tinyurl.com/3sf3bzck ${white}│" hr bottom_line local yn diff --git a/scripts/camera_settings_control.sh b/scripts/camera_settings_control.sh index dc8d89f..294c62c 100755 --- a/scripts/camera_settings_control.sh +++ b/scripts/camera_settings_control.sh @@ -28,7 +28,11 @@ function install_camera_settings_control(){ mkdir -p "$HS_CONFIG_FOLDER" fi echo -e "Info: Linking file..." - cp "$CAMERA_SETTINGS_URL" "$HS_CONFIG_FOLDER"/camera-settings.cfg + if v4l2-ctl --list-devices | grep -q 'CCX2F3298'; then + cp "$CAMERA_SETTINGS_NEBULA_URL" "$HS_CONFIG_FOLDER"/camera-settings.cfg + else + cp "$CAMERA_SETTINGS_URL" "$HS_CONFIG_FOLDER"/camera-settings.cfg + fi if grep -q "include Helper-Script/camera-settings" "$PRINTER_CFG" ; then echo -e "Info: Camera Settings configurations are already enabled in printer.cfg file..." else diff --git a/scripts/creality_web_interface.sh b/scripts/creality_web_interface.sh index 8898ee3..1b9ed31 100755 --- a/scripts/creality_web_interface.sh +++ b/scripts/creality_web_interface.sh @@ -31,28 +31,48 @@ function remove_creality_web_interface(){ case "${yn}" in Y|y) echo -e "${white}" - echo -e "Info: Disabling files..." - if [ -f /usr/bin/web-server ]; then - mv /usr/bin/web-server /usr/bin/web-server.disabled - fi - if [ -f /usr/bin/Monitor ]; then - mv /usr/bin/Monitor /usr/bin/Monitor.disabled - fi - echo -e "Info: Stopping services..." - set +e - killall -q Monitor - killall -q web-server - set -e if [ -d "$FLUIDD_FOLDER" ] && [ ! -d "$MAINSAIL_FOLDER" ]; then echo -e "Info: Applying changes..." - sed -i '/listen 4408 default_server;/a \ listen 80;' /usr/data/nginx/nginx/nginx.conf + if [ "$model" = "3V3" ]; then + sed -i '/listen 4408 default_server;/a \ listen 80;' /etc/nginx/nginx.conf + else + sed -i '/listen 4408 default_server;/a \ listen 80;' /usr/data/nginx/nginx/nginx.conf + fi + echo -e "Info: Disabling files..." + if [ -f /usr/bin/web-server ]; then + mv /usr/bin/web-server /usr/bin/web-server.disabled + fi + if [ -f /usr/bin/Monitor ]; then + mv /usr/bin/Monitor /usr/bin/Monitor.disabled + fi + echo -e "Info: Stopping services..." + set +e + killall -q Monitor + killall -q web-server + set -e echo -e "Info: Restarting Nginx service..." restart_nginx ok_msg "Creality Web Interface has been removed successfully!" echo -e " ${white}You can now connect to Fluidd Web Interface with ${yellow}http://$(check_ipaddress)${white}" elif [ ! -d "$FLUIDD_FOLDER" ] && [ -d "$MAINSAIL_FOLDER" ]; then echo -e "Info: Applying changes..." - sed -i '/listen 4409 default_server;/a \ listen 80;' /usr/data/nginx/nginx/nginx.conf + if [ "$model" = "3V3" ]; then + sed -i '/listen 4409 default_server;/a \ listen 80;' /etc/nginx/nginx.conf + else + sed -i '/listen 4409 default_server;/a \ listen 80;' /usr/data/nginx/nginx/nginx.conf + fi + echo -e "Info: Disabling files..." + if [ -f /usr/bin/web-server ]; then + mv /usr/bin/web-server /usr/bin/web-server.disabled + fi + if [ -f /usr/bin/Monitor ]; then + mv /usr/bin/Monitor /usr/bin/Monitor.disabled + fi + echo -e "Info: Stopping services..." + set +e + killall -q Monitor + killall -q web-server + set -e echo -e "Info: Restarting Nginx service..." restart_nginx ok_msg "Creality Web Interface has been removed successfully!" @@ -60,13 +80,28 @@ function remove_creality_web_interface(){ elif [ -d "$FLUIDD_FOLDER" ] && [ -d "$MAINSAIL_FOLDER" ]; then local interface_choice while true; do - echo read -p " ${white}Which Web Interface do you want to set as default (on port 80)? (${yellow}fluidd${white}/${yellow}mainsail${white}): ${yellow}" interface_choice case "${interface_choice}" in FLUIDD|fluidd) echo -e "${white}" echo -e "Info: Applying changes..." - sed -i '/listen 4408 default_server;/a \ listen 80;' /usr/data/nginx/nginx/nginx.conf + if [ "$model" = "3V3" ]; then + sed -i '/listen 4408 default_server;/a \ listen 80;' /etc/nginx/nginx.conf + else + sed -i '/listen 4408 default_server;/a \ listen 80;' /usr/data/nginx/nginx/nginx.conf + fi + echo -e "Info: Disabling files..." + if [ -f /usr/bin/web-server ]; then + mv /usr/bin/web-server /usr/bin/web-server.disabled + fi + if [ -f /usr/bin/Monitor ]; then + mv /usr/bin/Monitor /usr/bin/Monitor.disabled + fi + echo -e "Info: Stopping services..." + set +e + killall -q Monitor + killall -q web-server + set -e echo -e "Info: Restarting Nginx service..." restart_nginx ok_msg "Creality Web Interface has been removed successfully!" @@ -75,7 +110,23 @@ function remove_creality_web_interface(){ MAINSAIL|mainsail) echo -e "${white}" echo -e "Info: Applying changes..." - sed -i '/listen 4409 default_server;/a \ listen 80;' /usr/data/nginx/nginx/nginx.conf + if [ "$model" = "3V3" ]; then + sed -i '/listen 4409 default_server;/a \ listen 80;' /etc/nginx/nginx.conf + else + sed -i '/listen 4409 default_server;/a \ listen 80;' /usr/data/nginx/nginx/nginx.conf + fi + echo -e "Info: Disabling files..." + if [ -f /usr/bin/web-server ]; then + mv /usr/bin/web-server /usr/bin/web-server.disabled + fi + if [ -f /usr/bin/Monitor ]; then + mv /usr/bin/Monitor /usr/bin/Monitor.disabled + fi + echo -e "Info: Stopping services..." + set +e + killall -q Monitor + killall -q web-server + set -e echo -e "Info: Restarting Nginx service..." restart_nginx ok_msg "Creality Web Interface has been removed successfully!" @@ -104,6 +155,12 @@ function restore_creality_web_interface(){ case "${yn}" in Y|y) echo -e "${white}" + echo -e "Info: Restoring changes..." + if [ "$model" = "3V3" ]; then + sed -i '/listen 80;/d' /etc/nginx/nginx.conf + else + sed -i '/listen 80;/d' /usr/data/nginx/nginx/nginx.conf + fi echo -e "Info: Restoring files..." if [ -f /usr/bin/web-server.disabled ] && [ -f "$INITD_FOLDER"/S99start_app ]; then mv /usr/bin/web-server.disabled /usr/bin/web-server @@ -111,8 +168,6 @@ function restore_creality_web_interface(){ if [ -f /usr/bin/Monitor.disabled ] && [ ! -d "$GUPPY_SCREEN_FOLDER" ]; then mv /usr/bin/Monitor.disabled /usr/bin/Monitor fi - echo -e "Info: Restoring changes..." - sed -i '/listen 80;/d' /usr/data/nginx/nginx/nginx.conf echo -e "Info: Restarting services..." restart_nginx set +e diff --git a/scripts/fluidd.sh b/scripts/fluidd.sh index 6a8c1fc..3a02c03 100755 --- a/scripts/fluidd.sh +++ b/scripts/fluidd.sh @@ -14,6 +14,19 @@ function fluidd_message(){ bottom_line } +function fluidd_3v3_message(){ + top_line + title 'Fluidd' "${yellow}" + inner_line + hr + echo -e " │ ${cyan}Fluidd is a free and open-source Klipper Web interface for ${white}│" + echo -e " │ ${cyan}managing your 3d printer. ${white}│" + echo -e " │ ${cyan}This allows to have an updated version of Fluidd. ${white}│" + echo -e " │ ${cyan}It will be accessible on port 4408. ${white}│" + hr + bottom_line +} + function install_fluidd(){ fluidd_message local yn @@ -87,4 +100,85 @@ function remove_fluidd(){ error_msg "Please select a correct choice!";; esac done +} + +function install_fluidd_3v3(){ + fluidd_3v3_message + local yn + while true; do + install_msg "Updated Fluidd" yn + case "${yn}" in + Y|y) + echo -e "${white}" + echo -e "Info: Downloading Fluidd file..." + "$CURL" -L "$FLUIDD_URL" -o "$USR_DATA"/fluidd.zip + echo -e "Info: Creating directory..." + if [ -d "$FLUIDD_FOLDER" ]; then + rm -rf "$FLUIDD_FOLDER" + fi + mkdir -p "$FLUIDD_FOLDER" + mv "$USR_DATA"/fluidd.zip "$FLUIDD_FOLDER" + echo -e "Info: Extracting files..." + unzip "$FLUIDD_FOLDER"/fluidd.zip -d "$FLUIDD_FOLDER" + echo -e "Info: Deleting existing folders..." + rm -f "$FLUIDD_FOLDER"/fluidd.zip + rm -rf "$USR_SHARE"/fluidd + echo -e "Info: Linking files..." + ln -sf "$FLUIDD_FOLDER" "$USR_SHARE"/fluidd + if grep -q "#\[update_manager fluidd\]" "$MOONRAKER_CFG" ; then + echo -e "Info: Enabling Fluidd configurations for Update Manager..." + sed -i -e 's/^\s*#[[:space:]]*\[update_manager fluidd\]/[update_manager fluidd]/' -e '/^\[update_manager fluidd\]/,/^\s*$/ s/^\(\s*\)#/\1/' "$MOONRAKER_CFG" + else + echo -e "Info: Fluidd configurations are already enabled for Update Manager..." + fi + echo -e "Info: Restarting Nginx service..." + restart_nginx + echo -e "Info: Restarting Moonraker service..." + stop_moonraker + start_moonraker + ok_msg "Updated Fluidd has been installed successfully!" + echo -e " You can now connect to Fluidd Web Interface with ${yellow}http://$(check_ipaddress):4408${white}" + return;; + N|n) + error_msg "Installation canceled!" + return;; + *) + error_msg "Please select a correct choice!";; + esac + done +} + +function remove_fluidd_3v3(){ + fluidd_3v3_message + local yn + while true; do + remove_msg "Updated Fluidd" yn + case "${yn}" in + Y|y) + echo -e "${white}" + echo -e "Info: Removing files..." + rm -rf "$FLUIDD_FOLDER" + if grep -q "\[update_manager fluidd\]" "$MOONRAKER_CFG" ; then + echo -e "Info: Disabling Fluidd configurations for Update Manager..." + sed -i '/^\[update_manager fluidd\]/,/^\s*$/ s/^\(\s*\)\([^#]\)/#\1\2/' "$MOONRAKER_CFG" + else + echo -e "Info: Fluidd configurations are already disabled for Update Manager..." + fi + echo -e "Info: Restoring stock Fluidd version..." + rm -rf /overlay/upper/usr/share/fluidd + mount -o remount / + echo -e "Info: Restarting Nginx service..." + restart_nginx + echo -e "Info: Restarting Moonraker service..." + stop_moonraker + start_moonraker + ok_msg "Updated Fluidd has been removed successfully!" + return;; + N|n) + error_msg "Deletion canceled!" + return;; + *) + error_msg "Please select a correct choice!";; + esac + done } \ No newline at end of file diff --git a/scripts/git_backup.sh b/scripts/git_backup.sh index 002ee87..0a6ede0 100755 --- a/scripts/git_backup.sh +++ b/scripts/git_backup.sh @@ -25,23 +25,18 @@ function install_git_backup(){ if [ -f "$HS_CONFIG_FOLDER"/git-backup.cfg ]; then rm -f "$HS_CONFIG_FOLDER"/git-backup.cfg fi + if [ -d "$KLIPPER_CONFIG_FOLDER"/.git ]; then + rm -rf "$KLIPPER_CONFIG_FOLDER"/.git + fi + if [ -d "$HS_BACKUP_FOLDER"/git-backup ]; then + rm -rf "$HS_BACKUP_FOLDER"/git-backup + fi if [ ! -d "$HS_CONFIG_FOLDER" ]; then mkdir -p "$HS_CONFIG_FOLDER" fi echo -e "Info: Running Git Backup installer..." chmod 755 "$GIT_BACKUP_INSTALLER" sh "$GIT_BACKUP_INSTALLER" -i - echo -e "Info: Linking file..." - ln -sf "$GIT_BACKUP_URL" "$HS_CONFIG_FOLDER"/git-backup.cfg - if grep -q "include Helper-Script/git-backup" "$PRINTER_CFG" ; then - echo -e "Info: Git Backup configurations are already enabled in printer.cfg file..." - else - echo -e "Info: Adding Git Backup configurations in printer.cfg file..." - sed -i '/\[include printer_params\.cfg\]/a \[include Helper-Script/git-backup\.cfg\]' "$PRINTER_CFG" - fi - echo -e "Info: Restarting Klipper service..." - restart_klipper - ok_msg "Git Backup has been installed and configured successfully!" return;; N|n) error_msg "Installation canceled!" @@ -61,11 +56,24 @@ function remove_git_backup(){ Y|y) echo -e "${white}" echo -e "Info: Stopping services..." - /etc/init.d/S52Git-Backup stop + set +e + /etc/init.d/S52Git-Backup stop >/dev/null 2>&1 + killall -q git-backup.sh + killall -q inotifywait + set -e echo -e "Info: Removing files..." rm -f "$HS_CONFIG_FOLDER"/git-backup.cfg - rm -f "$INITD_FOLDER"/S52Git-Backup + if [ -f "$INITD_FOLDER"/S52Git-Backup ];then + rm -f "$INITD_FOLDER"/S52Git-Backup + fi + if [ -f "$INITD_FOLDER"/disabled.S52Git-Backup ];then + rm -f "$INITD_FOLDER"/disabled.S52Git-Backup + fi rm -rf "$KLIPPER_CONFIG_FOLDER"/.git + rm -rf "$HS_BACKUP_FOLDER"/git-backup + if [ ! -n "$(ls -A "$HS_BACKUP_FOLDER")" ]; then + rm -rf "$HS_BACKUP_FOLDER" + fi if grep -q "include Helper-Script/git-backup" "$PRINTER_CFG" ; then echo -e "Info: Removing Git Backup configurations in printer.cfg file..." sed -i '/include Helper-Script\/git-backup\.cfg/d' "$PRINTER_CFG" @@ -75,7 +83,6 @@ function remove_git_backup(){ if [ -f "$ENTWARE_FILE" ]; then echo -e "Info: Removing packages..." "$ENTWARE_FILE" --autoremove remove inotifywait - "$ENTWARE_FILE" --autoremove remove procps-ng-pkill fi if [ ! -n "$(ls -A "$HS_CONFIG_FOLDER")" ]; then rm -rf "$HS_CONFIG_FOLDER" diff --git a/scripts/guppy_screen.sh b/scripts/guppy_screen.sh index 8774e7e..52733de 100755 --- a/scripts/guppy_screen.sh +++ b/scripts/guppy_screen.sh @@ -24,28 +24,44 @@ function install_guppy_screen(){ if [ -f "$USR_DATA"/guppyscreen.tar.gz ]; then rm -f "$USR_DATA"/guppyscreen.tar.gz fi - if [ $K1 -eq 1 ]; then + if [ "$model" = "K1" ] || [ "$model" = "3V3" ]; then local theme_choice while true; do - read -p " Do you want to install it with ${green}Material Design ${white}or ${green}Z-Bolt ${white}theme? (${yellow}material${white}/${yellow}zbolt${white}): ${yellow}" theme_choice + read -p " Do you want to install ${green}Nightly Build ${white}or ${green}Release Build ${white}? (${yellow}nightly${white}/${yellow}release${white}): ${yellow}" theme_choice case "${theme_choice}" in - MATERIAL|material) + NIGHTLY|nightly) + echo -e "${white}" + echo -e "Info: Downloading Guppy Screen..." + "$CURL" -L https://github.com/ballaswag/guppyscreen/releases/download/nightly/guppyscreen.tar.gz -o "$USR_DATA"/guppyscreen.tar.gz + break;; + RELEASE|release) echo -e "${white}" echo -e "Info: Downloading Guppy Screen..." "$CURL" -L https://github.com/ballaswag/guppyscreen/releases/latest/download/guppyscreen.tar.gz -o "$USR_DATA"/guppyscreen.tar.gz break;; - ZBOLT|zbolt) - echo -e "${white}" - echo -e "Info: Downloading Guppy Screen..." - "$CURL" -L https://github.com/ballaswag/guppyscreen/releases/latest/download/guppyscreen-zbolt.tar.gz -o "$USR_DATA"/guppyscreen.tar.gz - break;; *) error_msg "Please select a correct choice!";; esac done else - echo -e "Info: Downloading Guppy Screen..." - "$CURL" -L https://github.com/ballaswag/guppyscreen/releases/latest/download/guppyscreen-smallscreen.tar.gz -o "$USR_DATA"/guppyscreen.tar.gz + local theme_choice + while true; do + read -p " Do you want to install ${green}Nightly Build ${white}or ${green}Release Build ${white}? (${yellow}nightly${white}/${yellow}release${white}): ${yellow}" theme_choice + case "${theme_choice}" in + NIGHTLY|nightly) + echo -e "${white}" + echo -e "Info: Downloading Guppy Screen..." + "$CURL" -L https://github.com/ballaswag/guppyscreen/releases/download/nightly/guppyscreen-smallscreen.tar.gz -o "$USR_DATA"/guppyscreen.tar.gz + break;; + RELEASE|release) + echo -e "${white}" + echo -e "Info: Downloading Guppy Screen..." + "$CURL" -L https://github.com/ballaswag/guppyscreen/releases/latest/download/guppyscreen-smallscreen.tar.gz -o "$USR_DATA"/guppyscreen.tar.gz + break;; + *) + error_msg "Please select a correct choice!";; + esac + done fi echo -e "Info: Installing files..." tar -xvf "$USR_DATA"/guppyscreen.tar.gz -C "$USR_DATA" @@ -114,7 +130,17 @@ function install_guppy_screen(){ mkdir -p "$KLIPPER_CONFIG_FOLDER"/GuppyScreen/scripts cp "$GUPPY_SCREEN_FOLDER"/scripts/*.cfg "$KLIPPER_CONFIG_FOLDER"/GuppyScreen cp "$GUPPY_SCREEN_FOLDER"/scripts/*.py "$KLIPPER_CONFIG_FOLDER"/GuppyScreen/scripts - ln -sf "$GUPPY_SCREEN_URL1" "$KLIPPER_CONFIG_FOLDER"/GuppyScreen/guppy_update.cfg + if [ "$model" = "K1" ]; then + ln -sf "$GUPPY_SCREEN_URL1" "$KLIPPER_CONFIG_FOLDER"/GuppyScreen/guppy_update.cfg + else + ln -sf "$GUPPY_SCREEN_3V3_URL" "$KLIPPER_CONFIG_FOLDER"/GuppyScreen/guppy_update.cfg + fi + if [ "$model" = "3V3" ]; then + if [ -f "$GUPPY_SCREEN_FOLDER"/guppyconfig.json ];then + rm -f "$GUPPY_SCREEN_FOLDER"/guppyconfig.json + fi + cp "$GUPPY_SCREEN_CONFIG_3V3_URL" "$GUPPY_SCREEN_FOLDER"/guppyconfig.json + fi chmod 775 "$GUPPY_SCREEN_URL2" if grep -q "include GuppyScreen" "$PRINTER_CFG" ; then echo -e "Info: Guppy Screen configurations are already enabled in printer.cfg file." @@ -128,11 +154,13 @@ function install_guppy_screen(){ else echo -e "Info: Stock configuration is already disabled in gcode_macro.cfg file..." fi - if grep -q '\[gcode_macro INPUTSHAPER\]' "$MACROS_CFG" ; then - echo -e "Info: Replacing stock configuration in gcode_macro.cfg file..." - sed -i 's/SHAPER_CALIBRATE AXIS=y/SHAPER_CALIBRATE/' "$MACROS_CFG" - else - echo -e "Info: Stock configuration is already replaced in gcode_macro.cfg file..." + if [ "$model" = "K1" ]; then + if grep -q '\[gcode_macro INPUTSHAPER\]' "$MACROS_CFG" ; then + echo -e "Info: Replacing stock configuration in gcode_macro.cfg file..." + sed -i 's/SHAPER_CALIBRATE AXIS=y/SHAPER_CALIBRATE/' "$MACROS_CFG" + else + echo -e "Info: Stock configuration is already replaced in gcode_macro.cfg file..." + fi fi sync echo -e "Info: Restarting Moonraker service..." @@ -221,11 +249,13 @@ function remove_guppy_screen(){ else echo -e "Info: Stock configuration is already enabled in gcode_macro.cfg file..." fi - if grep -q '\[gcode_macro INPUTSHAPER\]' "$MACROS_CFG" ; then - echo -e "Info: Restoring stock configuration in gcode_macro.cfg file..." - sed -i 's/SHAPER_CALIBRATE/SHAPER_CALIBRATE AXIS=y/' "$MACROS_CFG" - else - echo -e "Info: Stock configuration is already restored in gcode_macro.cfg file..." + if [ "$model" = "K1" ]; then + if grep -q '\[gcode_macro INPUTSHAPER\]' "$MACROS_CFG" ; then + echo -e "Info: Restoring stock configuration in gcode_macro.cfg file..." + sed -i 's/SHAPER_CALIBRATE/SHAPER_CALIBRATE AXIS=y/' "$MACROS_CFG" + else + echo -e "Info: Stock configuration is already restored in gcode_macro.cfg file..." + fi fi echo -e "Info: Restarting Moonraker service..." stop_moonraker diff --git a/scripts/improved_shapers.sh b/scripts/improved_shapers.sh index 9e152ce..41e2183 100755 --- a/scripts/improved_shapers.sh +++ b/scripts/improved_shapers.sh @@ -50,7 +50,7 @@ function install_improved_shapers(){ else echo -e "Info: [gcode_macro AUTOTUNE_SHAPERS] configurations are already disabled in gcode_macro.cfg file..." fi - if [ $K1 -eq 1 ]; then + if [ "$model" = "K1" ]; then if grep -q '\[gcode_macro INPUTSHAPER\]' "$MACROS_CFG" ; then echo -e "Info: Replacing [gcode_macro INPUTSHAPER] configurations in gcode_macro.cfg file..." sed -i 's/SHAPER_CALIBRATE AXIS=y/SHAPER_CALIBRATE/' "$MACROS_CFG" @@ -106,7 +106,7 @@ function remove_improved_shapers(){ else echo -e "Info: [gcode_macro AUTOTUNE_SHAPERS] configurations are already restored in gcode_macro.cfg file..." fi - if [ $K1 -eq 1 ]; then + if [ "$model" = "K1" ]; then if grep -q '\[gcode_macro INPUTSHAPER\]' "$MACROS_CFG" ; then echo -e "Info: Restoring [gcode_macro INPUTSHAPER] configurations in gcode_macro.cfg file..." sed -i 's/SHAPER_CALIBRATE/SHAPER_CALIBRATE AXIS=y/' "$MACROS_CFG" diff --git a/scripts/kamp.sh b/scripts/kamp.sh index eea113e..2e78f60 100755 --- a/scripts/kamp.sh +++ b/scripts/kamp.sh @@ -8,7 +8,10 @@ function kamp_message(){ inner_line hr echo -e " │ ${cyan}KAMP is an extension that allows to generate a mesh and ${white}│" - echo -e " │ ${cyan}purge line only in the area you really need it. ${white}│" + echo -e " │ ${cyan}purge line only in the area of the bed used by the objects ${white}│" + echo -e " │ ${cyan}being printed. When used, the method will automatically ${white}│" + echo -e " │ ${cyan}adjust the mesh parameters based on the area occupied by the ${white}│" + echo -e " │ ${cyan}defined print objects. ${white}│" hr bottom_line } @@ -37,8 +40,19 @@ function install_kamp(){ ln -sf "$KAMP_URL"/Line_Purge.cfg "$KAMP_FOLDER"/Line_Purge.cfg ln -sf "$KAMP_URL"/Prusa_Slicer.cfg "$KAMP_FOLDER"/Prusa_Slicer.cfg ln -sf "$KAMP_URL"/Smart_Park.cfg "$KAMP_FOLDER"/Smart_Park.cfg - ln -sf "$KAMP_URL"/Start_Print.cfg "$KAMP_FOLDER"/Start_Print.cfg + if [ "$model" = "K1" ]; then + ln -sf "$KAMP_URL"/Start_Print.cfg "$KAMP_FOLDER"/Start_Print.cfg + else + ln -sf "$KAMP_URL"/Start_Print-3v3.cfg "$KAMP_FOLDER"/Start_Print.cfg + fi cp "$KAMP_URL"/KAMP_Settings.cfg "$KAMP_FOLDER"/KAMP_Settings.cfg + ln -sf "$VIRTUAL_PINS_URL" "$VIRTUAL_PINS_FILE" + if grep -q "[virtual_pins]" "$PRINTER_CFG" ; then + echo -e "Info: Adding [virtual_pins] configuration in printer.cfg file..." + sed -i '/\[include sensorless.cfg\]/i [virtual_pins]' "$PRINTER_CFG" + else + echo -e "Info: [virtual_pins] configuration is already enabled in printer.cfg file..." + fi if grep -q "include Helper-Script/KAMP/KAMP_Settings" "$PRINTER_CFG" ; then echo -e "Info: KAMP configurations are already enabled in printer.cfg file..." else @@ -97,6 +111,14 @@ function remove_kamp(){ echo -e "${white}" echo -e "Info: Removing files..." rm -rf "$HS_CONFIG_FOLDER"/KAMP + rm -f "$KLIPPER_EXTRAS_FOLDER"/virtual_pins.py + rm -f "$KLIPPER_EXTRAS_FOLDER"/virtual_pins.pyc + if grep -q "[virtual_pins]" "$PRINTER_CFG" ; then + echo -e "Info: Removing [virtual_pins] configuration in printer.cfg file..." + sed -i '/\[virtual_pins\]/d' "$PRINTER_CFG" + else + echo -e "Info: [virtual_pins] configuration is already removed in printer.cfg file..." + fi if grep -q "include Helper-Script/KAMP/KAMP_Settings" "$PRINTER_CFG" ; then echo -e "Info: Removing KAMP configurations in printer.cfg file..." sed -i '/include Helper-Script\/KAMP\/KAMP_Settings\.cfg/d' "$PRINTER_CFG" @@ -123,4 +145,4 @@ function remove_kamp(){ error_msg "Please select a correct choice!";; esac done -} \ No newline at end of file +} diff --git a/scripts/m600_support.sh b/scripts/m600_support.sh index 8f1c834..81dcf3a 100755 --- a/scripts/m600_support.sh +++ b/scripts/m600_support.sh @@ -28,7 +28,11 @@ function install_m600_support(){ mkdir -p "$HS_CONFIG_FOLDER" fi echo -e "Info: Linking file..." - ln -sf "$M600_SUPPORT_URL" "$HS_CONFIG_FOLDER"/M600-support.cfg + if [ "$model" = "K1" ]; then + ln -sf "$M600_SUPPORT_URL" "$HS_CONFIG_FOLDER"/M600-support.cfg + else + ln -sf "$M600_SUPPORT_3V3_URL" "$HS_CONFIG_FOLDER"/M600-support.cfg + fi if grep -q "include Helper-Script/M600-support" "$PRINTER_CFG" ; then echo -e "Info: M600 Support configurations are already enabled in printer.cfg file..." else diff --git a/scripts/menu/3V3/customize_menu_3V3.sh b/scripts/menu/3V3/customize_menu_3V3.sh new file mode 100755 index 0000000..896d686 --- /dev/null +++ b/scripts/menu/3V3/customize_menu_3V3.sh @@ -0,0 +1,89 @@ +#!/bin/sh + +set -e + +function customize_menu_ui_3v3() { + top_line + title '[ CUSTOMIZE MENU ]' "${yellow}" + inner_line + hr + menu_option '1' 'Remove' 'Creality Web Interface' + menu_option '2' 'Restore' 'Creality Web Interface' + hr + menu_option '3' 'Install' 'Guppy Screen' + menu_option '4' 'Remove' 'Guppy Screen' + hr + menu_option '5' 'Install' 'Creality Dynamic Logos for Fluidd' + hr + inner_line + hr + bottom_menu_option 'b' 'Back to [Main Menu]' "${yellow}" + bottom_menu_option 'q' 'Exit' "${darkred}" + hr + version_line "$(get_script_version)" + bottom_line +} + +function customize_menu_3v3() { + clear + customize_menu_ui_3v3 + local customize_menu_opt + while true; do + read -p " ${white}Type your choice and validate with Enter: ${yellow}" customize_menu_opt + case "${customize_menu_opt}" in + 1) + if [ ! -d "$FLUIDD_FOLDER" ] && [ ! -d "$MAINSAIL_FOLDER" ]; then + error_msg "Updated Fluidd or Mainsail is needed, please install one of them first!" + elif [ ! -f "$CREALITY_WEB_FILE" ]; then + error_msg "Creality Web Interface is already removed!" + echo -e " ${darkred}Please restore Creality Web Interface first if you want to change the default Web Interface.${white}" + echo + else + run "remove_creality_web_interface" "customize_menu_ui_3v3" + fi;; + 2) + if [ -f "$CREALITY_WEB_FILE" ]; then + error_msg "Creality Web Interface is already present!" + elif [ ! -f "$INITD_FOLDER"/S99start_app ]; then + error_msg "Guppy Screen need to be removed first to restore Creality Web Interface!" + else + run "restore_creality_web_interface" "customize_menu_ui_3v3" + fi;; + 3) + if [ -d "$GUPPY_SCREEN_FOLDER" ]; then + error_msg "Guppy Screen is already installed!" + echo -e " ${darkred}Please remove Guppy Screen first if you want to change the theme.${white}" + echo + elif [ -d "$IMP_SHAPERS_FOLDER" ]; then + error_msg "Please remove Improved Shapers Calibrations first, Guppy Screen already use it!" + elif [ ! -f /lib/ld-2.29.so ]; then + error_msg "Make sure you're running 1.3.x.x firmware version!" + elif [ ! -f "$KLIPPER_SHELL_FILE" ]; then + error_msg "Klipper Gcode Shell Command is needed, please install it first!" + else + run "install_guppy_screen" "customize_menu_ui_3v3" + fi;; + 4) + if [ ! -d "$GUPPY_SCREEN_FOLDER" ]; then + error_msg "Guppy Screen is not installed!" + else + run "remove_guppy_screen" "customize_menu_ui_3v3" + fi;; + 5) + if [ -f "$FLUIDD_LOGO_FILE" ]; then + error_msg "Creality Dynamic Logos for Fluidd are already installed!" + elif [ ! -d "$FLUIDD_FOLDER" ]; then + error_msg "Updated Fluidd is needed, please install it first!" + else + run "install_creality_dynamic_logos" "customize_menu_ui_3v3" + fi;; + B|b) + clear; main_menu; break;; + Q|q) + clear; exit 0;; + *) + error_msg "Please select a correct choice!";; + esac + done + customize_menu_3v3 +} diff --git a/scripts/menu/3V3/info_menu_3V3.sh b/scripts/menu/3V3/info_menu_3V3.sh new file mode 100755 index 0000000..d0a5bff --- /dev/null +++ b/scripts/menu/3V3/info_menu_3V3.sh @@ -0,0 +1,97 @@ +#!/bin/sh + +set -e + +function check_folder_3v3() { + local folder_path="$1" + if [ -d "$folder_path" ]; then + echo -e "${green}✓" + else + echo -e "${red}✗" + fi +} + +function check_file_3v3() { + local file_path="$1" + if [ -f "$file_path" ]; then + echo -e "${green}✓" + else + echo -e "${red}✗" + fi +} + +function check_simplyprint_3v3() { + if grep -q "\[simplyprint\]" "$MOONRAKER_CFG"; then + echo -e "${green}✓" + else + echo -e "${red}✗" + fi +} + +function info_menu_ui_3v3() { + top_line + title '[ INFORMATIONS MENU ]' "${yellow}" + inner_line + hr + subtitle '•ESSENTIALS:' + info_line "$(check_folder_3v3 "$MOONRAKER_FOLDER")" 'Updated Moonraker' + info_line "$(check_folder_3v3 "$FLUIDD_FOLDER")" 'Updated Fluidd' + info_line "$(check_folder_3v3 "$MAINSAIL_FOLDER")" 'Mainsail' + hr + subtitle '•UTILITIES:' + info_line "$(check_file_3v3 "$ENTWARE_FILE")" 'Entware' + info_line "$(check_file_3v3 "$KLIPPER_SHELL_FILE")" 'Klipper Gcode Shell Command' + hr + subtitle '•IMPROVEMENTS:' + info_line "$(check_folder_3v3 "$KAMP_FOLDER")" 'Klipper Adaptive Meshing & Purging' + info_line "$(check_file_3v3 "$BUZZER_FILE")" 'Buzzer Support' + info_line "$(check_folder_3v3 "$IMP_SHAPERS_FOLDER")" 'Improved Shapers Calibrations' + info_line "$(check_file_3v3 "$USEFUL_MACROS_FILE")" 'Useful Macros' + info_line "$(check_file_3v3 "$SAVE_ZOFFSET_FILE")" 'Save Z-Offset Macros' + info_line "$(check_file_3v3 "$M600_SUPPORT_FILE")" 'M600 Support' + info_line "$(check_file_3v3 "$GIT_BACKUP_FILE")" 'Git Backup' + hr + subtitle '•CAMERA:' + info_line "$(check_file_3v3 "$TIMELAPSE_FILE")" 'Moonraker Timelapse' + info_line "$(check_file_3v3 "$CAMERA_SETTINGS_FILE")" 'Nebula Camera Settings Control' + info_line "$(check_file_3v3 "$USB_CAMERA_FILE")" 'USB Camera Support' + hr + subtitle '•REMOTE ACCESS:' + info_line "$(check_folder_3v3 "$OCTOEVERYWHERE_FOLDER")" 'OctoEverywhere' + info_line "$(check_folder_3v3 "$MOONRAKER_OBICO_FOLDER")" 'Obico' + info_line "$(check_folder_3v3 "$GUPPYFLO_FOLDER")" 'GuppyFLO' + info_line "$(check_folder_3v3 "$MOBILERAKER_COMPANION_FOLDER")" 'Mobileraker Companion' + info_line "$(check_folder_3v3 "$OCTOAPP_COMPANION_FOLDER")" 'OctoApp Companion' + info_line "$(check_simplyprint_3v3)" 'SimplyPrint' + hr + subtitle '•CUSTOMIZATION:' + info_line "$(check_file_3v3 "$CREALITY_WEB_FILE")" 'Creality Web Interface' + info_line "$(check_folder_3v3 "$GUPPY_SCREEN_FOLDER")" 'Guppy Screen' + info_line "$(check_file_3v3 "$FLUIDD_LOGO_FILE")" 'Creality Dynamic Logos for Fluidd' + hr + inner_line + hr + bottom_menu_option 'b' 'Back to [Main Menu]' "${yellow}" + bottom_menu_option 'q' 'Exit' "${darkred}" + hr + version_line "$(get_script_version)" + bottom_line +} + +function info_menu_3v3() { + clear + info_menu_ui_3v3 + local info_menu_opt + while true; do + read -p " ${white}Type your choice and validate with Enter: ${yellow}" info_menu_opt + case "${info_menu_opt}" in + B|b) + clear; main_menu; break;; + Q|q) + clear; exit 0;; + *) + error_msg "Please select a correct choice!";; + esac + done + info_menu_3v3 +} diff --git a/scripts/menu/3V3/install_menu_3V3.sh b/scripts/menu/3V3/install_menu_3V3.sh new file mode 100755 index 0000000..0f87bca --- /dev/null +++ b/scripts/menu/3V3/install_menu_3V3.sh @@ -0,0 +1,244 @@ +#!/bin/sh + +set -e + +function install_menu_ui_3v3() { + top_line + title '[ INSTALL MENU ]' "${yellow}" + inner_line + hr + subtitle '•ESSENTIALS:' + menu_option ' 1' 'Install' 'Updated Moonraker' + menu_option ' 2' 'Install' 'Updated Fluidd (port 4408)' + menu_option ' 3' 'Install' 'Mainsail (port 4409)' + hr + subtitle '•UTILITIES:' + menu_option ' 4' 'Install' 'Entware' + menu_option ' 5' 'Install' 'Klipper Gcode Shell Command' + hr + subtitle '•IMPROVEMENTS:' + menu_option ' 6' 'Install' 'Klipper Adaptive Meshing & Purging' + menu_option ' 7' 'Install' 'Buzzer Support' + menu_option ' 8' 'Install' 'Improved Shapers Calibrations' + menu_option ' 9' 'Install' 'Useful Macros' + menu_option '10' 'Install' 'Save Z-Offset Macros' + menu_option '11' 'Install' 'M600 Support' + menu_option '12' 'Install' 'Git Backup' + hr + subtitle '•CAMERA:' + menu_option '13' 'Install' 'Moonraker Timelapse' + menu_option '14' 'Install' 'Nebula Camera Settings Control' + menu_option '15' 'Install' 'USB Camera Support' + hr + subtitle '•REMOTE ACCESS:' + menu_option '16' 'Install' 'OctoEverywhere' + menu_option '17' 'Install' 'Moonraker Obico' + menu_option '18' 'Install' 'GuppyFLO' + menu_option '19' 'Install' 'Mobileraker Companion' + menu_option '20' 'Install' 'OctoApp Companion' + menu_option '21' 'Install' 'SimplyPrint' + hr + inner_line + hr + bottom_menu_option 'b' 'Back to [Main Menu]' "${yellow}" + bottom_menu_option 'q' 'Exit' "${darkred}" + hr + version_line "$(get_script_version)" + bottom_line +} + +function install_menu_3v3() { + clear + install_menu_ui_3v3 + local install_menu_opt + while true; do + read -p " ${white}Type your choice and validate with Enter: ${yellow}" install_menu_opt + case "${install_menu_opt}" in + 1) + if [ -d "$MOONRAKER_FOLDER" ]; then + error_msg "Updated Moonraker is already installed!" + else + run "install_moonraker_3v3" "install_menu_ui_3v3" + fi;; + 2) + if [ -d "$FLUIDD_FOLDER" ]; then + error_msg "Updated Fluidd is already installed!" + elif [ ! -d "$MOONRAKER_FOLDER" ]; then + error_msg "Updated Moonraker is needed, please install it first!" + else + run "install_fluidd_3v3" "install_menu_ui_3v3" + fi;; + 3) + if [ -d "$MAINSAIL_FOLDER" ]; then + error_msg "Mainsail is already installed!" + elif [ ! -d "$MOONRAKER_FOLDER" ]; then + error_msg "Updated Moonraker is needed, please install it first!" + else + run "install_mainsail" "install_menu_ui_3v3" + fi;; + 4) + if [ -f "$ENTWARE_FILE" ]; then + error_msg "Entware is already installed!" + else + run "install_entware" "install_menu_ui_3v3" + fi;; + 5) + if [ -f "$KLIPPER_SHELL_FILE" ]; then + error_msg "Klipper Gcode Shell Command is already installed!" + else + run "install_gcode_shell_command" "install_menu_ui_3v3" + fi;; + 6) + if [ -d "$KAMP_FOLDER" ]; then + error_msg "Klipper Adaptive Meshing & Purging is already installed!" + else + run "install_kamp" "install_menu_ui_3v3" + fi;; + 7) + if [ -f "$BUZZER_FILE" ]; then + error_msg "Buzzer Support is already installed!" + elif [ ! -f "$KLIPPER_SHELL_FILE" ]; then + error_msg "Klipper Gcode Shell Command is needed, please install it first!" + else + run "install_buzzer_support" "install_menu_ui_3v3" + fi;; + 8) + if [ -d "$IMP_SHAPERS_FOLDER" ]; then + error_msg "Improved Shapers Calibrations are already installed!" + elif [ -d "$GUPPY_SCREEN_FOLDER" ]; then + error_msg "Guppy Screen already has these features!" + elif [ ! -f "$KLIPPER_SHELL_FILE" ]; then + error_msg "Klipper Gcode Shell Command is needed, please install it first!" + else + run "install_improved_shapers" "install_menu_ui_3v3" + fi;; + 9) + if [ -f "$USEFUL_MACROS_FILE" ]; then + error_msg "Useful Macros are already installed!" + elif [ ! -f "$KLIPPER_SHELL_FILE" ]; then + error_msg "Klipper Gcode Shell Command is needed, please install it first!" + else + run "install_useful_macros" "install_menu_ui_3v3" + fi;; + 10) + if [ -f "$SAVE_ZOFFSET_FILE" ]; then + error_msg "Save Z-Offset Macros are already installed!" + else + run "install_save_zoffset_macros" "install_menu_ui_3v3" + fi;; + 11) + if [ -f "$M600_SUPPORT_FILE" ]; then + error_msg "M600 Support is already installed!" + else + run "install_m600_support" "install_menu_ui_3v3" + fi;; + 12) + if [ -f "$GIT_BACKUP_FILE" ]; then + error_msg "Git Backup is already installed!" + elif [ ! -f "$ENTWARE_FILE" ]; then + error_msg "Entware is needed, please install it first!" + elif [ ! -f "$KLIPPER_SHELL_FILE" ]; then + error_msg "Klipper Gcode Shell Command is needed, please install it first!" + else + run "install_git_backup" "install_menu_ui_3v3" + fi;; + 13) + if [ -f "$TIMELAPSE_FILE" ]; then + error_msg "Moonraker Timelapse is already installed!" + elif [ ! -f "$ENTWARE_FILE" ]; then + error_msg "Entware is needed, please install it first!" + else + run "install_moonraker_timelapse" "install_menu_ui_3v3" + fi;; + 14) + if [ -f "$CAMERA_SETTINGS_FILE" ]; then + error_msg "Nebula Camera Settings Control is already installed!" + elif ! v4l2-ctl --list-devices | grep -q 'CCX2F3298'; then + error_msg "Nebula camera not detected, please plug it in!" + elif [ ! -f "$KLIPPER_SHELL_FILE" ]; then + error_msg "Klipper Gcode Shell Command is needed, please install it first!" + else + run "install_camera_settings_control" "install_menu_ui_3v3" + fi;; + 15) + if [ -f "$USB_CAMERA_FILE" ]; then + error_msg "Camera USB Support is already installed!" + elif v4l2-ctl --list-devices | grep -qE 'CREALITY|CCX2F3298'; then + error_msg "It looks like you are using a Creality camera and it's not compatible!" + elif [ ! -f "$ENTWARE_FILE" ]; then + error_msg "Entware is needed, please install it first!" + else + run "install_usb_camera" "install_menu_ui_3v3" + fi;; + 16) + if [ -d "$OCTOEVERYWHERE_FOLDER" ]; then + error_msg "OctoEverywhere is already installed!" + elif [ ! -d "$MOONRAKER_FOLDER" ]; then + error_msg "Updated Moonraker is needed, please install it first!" + elif [ ! -d "$FLUIDD_FOLDER" ] && [ ! -d "$MAINSAIL_FOLDER" ]; then + error_msg "Updated Fluidd or Mainsail is needed, please install one of them first!" + elif [ ! -f "$ENTWARE_FILE" ]; then + error_msg "Entware is needed, please install it first!" + else + run "install_octoeverywhere" "install_menu_ui_3v3" + fi;; + 17) + if [ -d "$MOONRAKER_OBICO_FOLDER" ]; then + error_msg "Moonraker Obico is already installed!" + elif [ ! -d "$MOONRAKER_FOLDER" ]; then + error_msg "Updated Moonraker is needed, please install it first!" + elif [ ! -d "$FLUIDD_FOLDER" ] && [ ! -d "$MAINSAIL_FOLDER" ]; then + error_msg "Updated Fluidd or Mainsail is needed, please install one of them first!" + elif [ ! -f "$ENTWARE_FILE" ]; then + error_msg "Entware is needed, please install it first!" + else + run "install_moonraker_obico" "install_menu_ui_3v3" + fi;; + 18) + if [ ! -d "$MOONRAKER_FOLDER" ]; then + error_msg "Updated Moonraker is needed, please install it first!" + else + run "install_guppyflo" "install_menu_ui_3v3" + fi;; + 19) + if [ -d "$MOBILERAKER_COMPANION_FOLDER" ]; then + error_msg "Mobileraker Companion is already installed!" + elif [ ! -d "$MOONRAKER_FOLDER" ]; then + error_msg "Updated Moonraker is needed, please install it first!" + elif [ ! -d "$FLUIDD_FOLDER" ] && [ ! -d "$MAINSAIL_FOLDER" ]; then + error_msg "Fluidd or Mainsail is needed, please install one of them first!" + else + run "install_mobileraker_companion" "install_menu_ui_3v3" + fi;; + 20) + if [ -d "$OCTOAPP_COMPANION_FOLDER" ]; then + error_msg "OctoApp Companion is already installed!" + elif [ ! -d "$MOONRAKER_FOLDER" ]; then + error_msg "Updated Moonraker is needed, please install it first!" + elif [ ! -d "$FLUIDD_FOLDER" ] && [ ! -d "$MAINSAIL_FOLDER" ]; then + error_msg "Updated Fluidd or Mainsail is needed, please install one of them first!" + elif [ ! -f "$ENTWARE_FILE" ]; then + error_msg "Entware is needed, please install it first!" + else + run "install_octoapp_companion" "install_menu_ui_3v3" + fi;; + 21) + if grep -q "\[simplyprint\]" "$MOONRAKER_CFG"; then + error_msg "SimplyPrint is already installed!" + elif [ ! -d "$MOONRAKER_FOLDER" ]; then + error_msg "Updated Moonraker is needed, please install it first!" + elif [ ! -d "$FLUIDD_FOLDER" ] && [ ! -d "$MAINSAIL_FOLDER" ]; then + error_msg "Updated Fluidd or Mainsail is needed, please install one of them first!" + else + run "install_simplyprint" "install_menu_ui_3v3" + fi;; + B|b) + clear; main_menu; break;; + Q|q) + clear; exit 0;; + *) + error_msg "Please select a correct choice!";; + esac + done + install_menu_3v3 +} diff --git a/scripts/menu/3V3/remove_menu_3V3.sh b/scripts/menu/3V3/remove_menu_3V3.sh new file mode 100755 index 0000000..7b8296b --- /dev/null +++ b/scripts/menu/3V3/remove_menu_3V3.sh @@ -0,0 +1,212 @@ +#!/bin/sh + +set -e + +function remove_menu_ui_3v3() { + top_line + title '[ REMOVE MENU ]' "${yellow}" + inner_line + hr + subtitle '•ESSENTIALS:' + menu_option ' 1' 'Remove' 'Updated Moonraker' + menu_option ' 2' 'Remove' 'Updated Fluidd (port 4408)' + menu_option ' 3' 'Remove' 'Mainsail (port 4409)' + hr + subtitle '•UTILITIES:' + menu_option ' 6' 'Remove' 'Klipper Adaptive Meshing & Purging' + menu_option ' 7' 'Remove' 'Buzzer Support' + menu_option ' 8' 'Remove' 'Improved Shapers Calibrations' + menu_option ' 9' 'Remove' 'Useful Macros' + menu_option '10' 'Remove' 'Save Z-Offset Macros' + menu_option '11' 'Remove' 'M600 Support' + menu_option '12' 'Remove' 'Git Backup' + hr + subtitle '•CAMERA:' + menu_option '13' 'Remove' 'Moonraker Timelapse' + menu_option '14' 'Remove' 'Nebula Camera Settings Control' + menu_option '15' 'Remove' 'USB Camera Support' + hr + subtitle '•REMOTE ACCESS:' + menu_option '16' 'Remove' 'OctoEverywhere' + menu_option '17' 'Remove' 'Moonraker Obico' + menu_option '18' 'Remove' 'GuppyFLO' + menu_option '19' 'Remove' 'Mobileraker Companion' + menu_option '20' 'Remove' 'OctoApp Companion' + menu_option '21' 'Remove' 'SimplyPrint' + hr + inner_line + hr + bottom_menu_option 'b' 'Back to [Main Menu]' "${yellow}" + bottom_menu_option 'q' 'Exit' "${darkred}" + hr + version_line "$(get_script_version)" + bottom_line +} + +function remove_menu_3v3() { + clear + remove_menu_ui_3v3 + local remove_menu_opt + while true; do + read -p " ${white}Type your choice and validate with Enter: ${yellow}" remove_menu_opt + case "${remove_menu_opt}" in + 1) + if [ ! -d "$MOONRAKER_FOLDER" ]; then + error_msg "Updated Moonraker is not installed!" + else + run "remove_moonraker_3v3" "remove_menu_ui_3v3" + fi;; + 2) + if [ ! -d "$FLUIDD_FOLDER" ]; then + error_msg "Updated Fluidd is not installed!" + elif [ ! -f "$CREALITY_WEB_FILE" ] && [ ! -d "$MAINSAIL_FOLDER" ]; then + error_msg "Creality Web Interface is removed!" + echo -e " ${darkred}Please restore Creality Web Interface first if you want to remove Updated Fluidd.${white}" + echo + else + run "remove_fluidd_3v3" "remove_menu_ui_3v3" + fi;; + 3) + if [ ! -d "$MAINSAIL_FOLDER" ]; then + error_msg "Mainsail is not installed!" + elif [ ! -f "$CREALITY_WEB_FILE" ] && [ ! -d "$FLUIDD_FOLDER" ]; then + error_msg "Creality Web Interface is removed!" + echo -e " ${darkred}Please restore Creality Web Interface first if you want to remove Mainsail.${white}" + echo + else + run "remove_mainsail" "remove_menu_ui_3v3" + fi;; + 4) + if [ ! -f "$ENTWARE_FILE" ]; then + error_msg "Entware is not installed!" + elif [ -f "$TIMELAPSE_FILE" ]; then + error_msg "Entware is needed to use Moonraker Timelapse, please uninstall it first!" + elif [ -f "$GIT_BACKUP_FILE" ]; then + error_msg "Entware is needed to use Git Backup, please uninstall it first!" + elif [ -d "$OCTOEVERYWHERE_FOLDER" ]; then + error_msg "Entware is needed to use OctoEverywhere, please uninstall it first!" + elif [ -d "$MOONRAKER_OBICO_FOLDER" ]; then + error_msg "Entware is needed to use Moonraker Obico, please uninstall it first!" + elif [ ! -f "$USB_CAMERA_FILE" ]; then + error_msg "Entware is needed to use USB Camera Support, please uninstall it first!" + else + run "remove_entware" "remove_menu_ui_3v3" + fi;; + 5) + if [ ! -f "$KLIPPER_SHELL_FILE" ]; then + error_msg "Klipper Gcode Shell Command is not installed!" + elif [ -d "$GUPPY_SCREEN_FOLDER" ]; then + error_msg "Klipper Gcode Shell Command is needed to use Guppy Screen, please uninstall it first!" + elif [ -d "$IMP_SHAPERS_FOLDER" ]; then + error_msg "Klipper Gcode Shell Command is needed to use Improved Shapers Calibrations, please uninstall it first!" + elif [ -f "$GIT_BACKUP_FILE" ]; then + error_msg "Klipper Gcode Shell Command is needed to use Git Backup, please uninstall it first!" + else + run "remove_gcode_shell_command" "remove_menu_ui_3v3" + fi;; + 6) + if [ ! -d "$KAMP_FOLDER" ]; then + error_msg "Klipper Adaptive Meshing & Purging is not installed!" + else + run "remove_kamp" "remove_menu_ui_3v3" + fi;; + 7) + if [ ! -f "$BUZZER_FILE" ]; then + error_msg "Buzzer Support is not installed!" + else + run "remove_buzzer_support" "remove_menu_ui_3v3" + fi;; + 8) + if [ ! -d "$IMP_SHAPERS_FOLDER" ]; then + error_msg "Improved Shapers Calibrations are not installed!" + else + run "remove_improved_shapers" "remove_menu_ui_3v3" + fi;; + 9) + if [ ! -f "$USEFUL_MACROS_FILE" ]; then + error_msg "Useful Macros are not installed!" + else + run "remove_useful_macros" "remove_menu_ui_3v3" + fi;; + 10) + if [ ! -f "$SAVE_ZOFFSET_FILE" ]; then + error_msg "Save Z-Offset Macros are not installed!" + else + run "remove_save_zoffset_macros" "remove_menu_ui_3v3" + fi;; + 11) + if [ ! -f "$M600_SUPPORT_FILE" ]; then + error_msg "M600 Support is not installed!" + else + run "remove_m600_support" "remove_menu_ui_3v3" + fi;; + 12) + if [ ! -f "$GIT_BACKUP_FILE" ]; then + error_msg "Git Backup is not installed!" + else + run "remove_git_backup" "remove_menu_ui_3v3" + fi;; + 13) + if [ ! -f "$TIMELAPSE_FILE" ]; then + error_msg "Moonraker Timelapse is not installed!" + else + run "remove_moonraker_timelapse" "remove_menu_ui_3v3" + fi;; + 14) + if [ ! -f "$CAMERA_SETTINGS_FILE" ]; then + error_msg "Nebula Camera Settings Control is not installed!" + else + run "remove_camera_settings_control" "remove_menu_ui_3v3" + fi;; + 15) + if [ ! -f "$USB_CAMERA_FILE" ]; then + error_msg "USB Camera Support is not installed!" + else + run "remove_usb_camera" "remove_menu_ui_3v3" + fi;; + 16) + if [ ! -d "$OCTOEVERYWHERE_FOLDER" ]; then + error_msg "OctoEverywhere is not installed!" + else + run "remove_octoeverywhere" "remove_menu_ui_3v3" + fi;; + 17) + if [ ! -d "$MOONRAKER_OBICO_FOLDER" ]; then + error_msg "Moonraker Obico is not installed!" + else + run "remove_moonraker_obico" "remove_menu_ui_3v3" + fi;; + 18) + if [ ! -d "$GUPPYFLO_FOLDER" ]; then + error_msg "GuppyFLO is not installed!" + else + run "remove_guppyflo" "remove_menu_ui_3v3" + fi;; + 19) + if [ ! -d "$MOBILERAKER_COMPANION_FOLDER" ]; then + error_msg "Mobileraker Companion is not installed!" + else + run "remove_mobileraker_companion" "remove_menu_ui_3v3" + fi;; + 20) + if [ ! -d "$OCTOAPP_COMPANION_FOLDER" ]; then + error_msg "OctoApp Companion is not installed!" + else + run "remove_octoapp_companion" "remove_menu_ui_3v3" + fi;; + 21) + if ! grep -q "\[simplyprint\]" "$MOONRAKER_CFG"; then + error_msg "SimplyPrint is not installed!" + else + run "remove_simplyprint" "remove_menu_ui_3v3" + fi;; + B|b) + clear; main_menu; break;; + Q|q) + clear; exit 0;; + *) + error_msg "Please select a correct choice!";; + esac + done + remove_menu_3v3 +} diff --git a/scripts/menu/3V3/tools_menu_3V3.sh b/scripts/menu/3V3/tools_menu_3V3.sh new file mode 100755 index 0000000..c610f3d --- /dev/null +++ b/scripts/menu/3V3/tools_menu_3V3.sh @@ -0,0 +1,115 @@ +#!/bin/sh + +set -e + +function tools_menu_ui_3v3() { + top_line + title '[ TOOLS MENU ]' "${yellow}" + inner_line + hr + menu_option ' 1' 'Prevent updating' 'Klipper configuration files' + menu_option ' 2' 'Allow updating' 'Klipper configuration files' + menu_option ' 3' 'Fix' 'printing Gcode files from folder' + hr + menu_option ' 4' 'Enable' 'camera settings in Moonraker' + menu_option ' 5' 'Disable' 'camera settings in Moonraker' + hr + menu_option ' 6' 'Restart' 'Nginx service' + menu_option ' 7' 'Restart' 'Moonraker service' + menu_option ' 8' 'Restart' 'Klipper service' + hr + menu_option ' 9' 'Update' 'Entware packages' + hr + menu_option '10' 'Clear' 'cache' + menu_option '11' 'Clear' 'logs files' + hr + menu_option '12' 'Restore' 'a previous firmware' + hr + menu_option '13' 'Reset' 'factory settings' + hr + inner_line + hr + bottom_menu_option 'b' 'Back to [Main Menu]' "${yellow}" + bottom_menu_option 'q' 'Exit' "${darkred}" + hr + version_line "$(get_script_version)" + bottom_line +} + +function tools_menu_3v3() { + clear + tools_menu_ui_3v3 + local tools_menu_opt + while true; do + read -p " ${white}Type your choice and validate with Enter: ${yellow}" tools_menu_opt + case "${tools_menu_opt}" in + 1) + if [ -f "$INITD_FOLDER"/disabled.S55klipper_service ]; then + error_msg "Updating Klipper configuration files is already prevented!" + else + run "prevent_updating_klipper_files" "tools_menu_ui_3v3" + fi;; + 2) + if [ ! -f "$INITD_FOLDER"/disabled.S55klipper_service ]; then + error_msg "Updating Klipper configuration files is already allowed!" + else + run "allow_updating_klipper_files" "tools_menu_ui_3v3" + fi;; + 3) + if [ -f "$KLIPPER_KLIPPY_FOLDER"/gcode.py ]; then + run "printing_gcode_from_folder" "tools_menu_ui_3v3" + fi;; + 4) + if grep -q "^\[webcam Camera\]$" "$MOONRAKER_CFG"; then + error_msg "Camera settings are alredy enabled in Moonraker!" + else + run "enable_camera_settings" "tools_menu_ui_3v3" + fi;; + 5) + if grep -q "^#\[webcam Camera\]" "$MOONRAKER_CFG"; then + error_msg "Camera settings are alredy disabled in Moonraker!" + else + run "disable_camera_settings" "tools_menu_ui_3v3" + fi;; + 6) + if [ ! -d "$NGINX_FOLDER" ]; then + error_msg "Nginx is not installed!" + else + run "restart_nginx_action" "tools_menu_ui_3v3" + fi;; + 7) + if [ ! -d "$MOONRAKER_FOLDER" ]; then + error_msg "Moonraker is not installed!" + else + run "restart_moonraker_action" "tools_menu_ui_3v3" + fi;; + 8) + if [ ! -f "$INITD_FOLDER"/S55klipper_service ]; then + error_msg "Klipper service is not present!" + else + run "restart_klipper_action" "tools_menu_ui_3v3" + fi;; + 9) + if [ ! -f "$ENTWARE_FILE" ]; then + error_msg "Entware is not installed!" + else + run "update_entware_packages" "tools_menu_ui_3v3" + fi;; + 10) + run "clear_cache" "tools_menu_ui_3v3";; + 11) + run "clear_logs" "tools_menu_ui_3v3";; + 12) + run "restore_previous_firmware" "tools_menu_ui_3v3";; + 13) + run "reset_factory_settings" "tools_menu_ui_3v3";; + B|b) + clear; main_menu; break;; + Q|q) + clear; exit 0;; + *) + error_msg "Please select a correct choice!";; + esac + done + tools_menu_3v3 +} diff --git a/scripts/menu/customize_menu.sh b/scripts/menu/K1/customize_menu_K1.sh similarity index 89% rename from scripts/menu/customize_menu.sh rename to scripts/menu/K1/customize_menu_K1.sh index c51b45f..9f5bdcc 100755 --- a/scripts/menu/customize_menu.sh +++ b/scripts/menu/K1/customize_menu_K1.sh @@ -2,7 +2,7 @@ set -e -function customize_menu_ui() { +function customize_menu_ui_k1() { top_line title '[ CUSTOMIZE MENU ]' "${yellow}" inner_line @@ -27,9 +27,9 @@ function customize_menu_ui() { bottom_line } -function customize_menu() { +function customize_menu_k1() { clear - customize_menu_ui + customize_menu_ui_k1 local customize_menu_opt while true; do read -p " ${white}Type your choice and validate with Enter: ${yellow}" customize_menu_opt @@ -40,7 +40,7 @@ function customize_menu() { elif [ ! -d "$BOOT_DISPLAY_FOLDER" ]; then error_msg "Please use latest firmware to install Custom Boot Display!" else - run "install_custom_boot_display" "customize_menu_ui" + run "install_custom_boot_display" "customize_menu_ui_k1" fi;; 2) if [ ! -f "$BOOT_DISPLAY_FILE" ]; then @@ -48,17 +48,17 @@ function customize_menu() { elif [ ! -d "$BOOT_DISPLAY_FOLDER" ]; then error_msg "Please use latest firmware to restore Stock Boot Display!" else - run "remove_custom_boot_display" "customize_menu_ui" + run "remove_custom_boot_display" "customize_menu_ui_k1" fi;; 3) if [ ! -d "$FLUIDD_FOLDER" ] && [ ! -d "$MAINSAIL_FOLDER" ]; then - error_msg "Fluidd or Mainsail is needed, please install it first!" + error_msg "Fluidd or Mainsail is needed, please install one of them first!" elif [ ! -f "$CREALITY_WEB_FILE" ]; then error_msg "Creality Web Interface is already removed!" echo -e " ${darkred}Please restore Creality Web Interface first if you want to change the default Web Interface.${white}" echo else - run "remove_creality_web_interface" "customize_menu_ui" + run "remove_creality_web_interface" "customize_menu_ui_k1" fi;; 4) if [ -f "$CREALITY_WEB_FILE" ]; then @@ -66,7 +66,7 @@ function customize_menu() { elif [ ! -f "$INITD_FOLDER"/S99start_app ]; then error_msg "Guppy Screen need to be removed first to restore Creality Web Interface!" else - run "restore_creality_web_interface" "customize_menu_ui" + run "restore_creality_web_interface" "customize_menu_ui_k1" fi;; 5) if [ -d "$GUPPY_SCREEN_FOLDER" ]; then @@ -80,13 +80,13 @@ function customize_menu() { elif [ ! -f "$KLIPPER_SHELL_FILE" ]; then error_msg "Klipper Gcode Shell Command is needed, please install it first!" else - run "install_guppy_screen" "customize_menu_ui" + run "install_guppy_screen" "customize_menu_ui_k1" fi;; 6) if [ ! -d "$GUPPY_SCREEN_FOLDER" ]; then error_msg "Guppy Screen is not installed!" else - run "remove_guppy_screen" "customize_menu_ui" + run "remove_guppy_screen" "customize_menu_ui_k1" fi;; 7) if [ -f "$FLUIDD_LOGO_FILE" ]; then @@ -94,7 +94,7 @@ function customize_menu() { elif [ ! -d "$FLUIDD_FOLDER" ]; then error_msg "Fluidd is needed, please install it first!" else - run "install_creality_dynamic_logos" "customize_menu_ui" + run "install_creality_dynamic_logos" "customize_menu_ui_k1" fi;; B|b) clear; main_menu; break;; @@ -104,5 +104,5 @@ function customize_menu() { error_msg "Please select a correct choice!";; esac done - customize_menu + customize_menu_k1 } diff --git a/scripts/menu/K1/info_menu_K1.sh b/scripts/menu/K1/info_menu_K1.sh new file mode 100755 index 0000000..95c2f6b --- /dev/null +++ b/scripts/menu/K1/info_menu_K1.sh @@ -0,0 +1,101 @@ +#!/bin/sh + +set -e + +function check_folder_k1() { + local folder_path="$1" + if [ -d "$folder_path" ]; then + echo -e "${green}✓" + else + echo -e "${red}✗" + fi +} + +function check_file_k1() { + local file_path="$1" + if [ -f "$file_path" ]; then + echo -e "${green}✓" + else + echo -e "${red}✗" + fi +} + +function check_simplyprint_k1() { + if grep -q "\[simplyprint\]" "$MOONRAKER_CFG"; then + echo -e "${green}✓" + else + echo -e "${red}✗" + fi +} + +function info_menu_ui_k1() { + top_line + title '[ INFORMATIONS MENU ]' "${yellow}" + inner_line + hr + subtitle '•ESSENTIALS:' + info_line "$(check_folder_k1 "$MOONRAKER_FOLDER")" 'Moonraker & Nginx' + info_line "$(check_folder_k1 "$FLUIDD_FOLDER")" 'Fluidd' + info_line "$(check_folder_k1 "$MAINSAIL_FOLDER")" 'Mainsail' + hr + subtitle '•UTILITIES:' + info_line "$(check_file_k1 "$ENTWARE_FILE")" 'Entware' + info_line "$(check_file_k1 "$KLIPPER_SHELL_FILE")" 'Klipper Gcode Shell Command' + hr + subtitle '•IMPROVEMENTS:' + info_line "$(check_folder_k1 "$KAMP_FOLDER")" 'Klipper Adaptive Meshing & Purging' + info_line "$(check_file_k1 "$BUZZER_FILE")" 'Buzzer Support' + info_line "$(check_folder_k1 "$NOZZLE_CLEANING_FOLDER")" 'Nozzle Cleaning Fan Control' + info_line "$(check_file_k1 "$FAN_CONTROLS_FILE")" 'Fans Control Macros' + info_line "$(check_folder_k1 "$IMP_SHAPERS_FOLDER")" 'Improved Shapers Calibrations' + info_line "$(check_file_k1 "$USEFUL_MACROS_FILE")" 'Useful Macros' + info_line "$(check_file_k1 "$SAVE_ZOFFSET_FILE")" 'Save Z-Offset Macros' + info_line "$(check_file_k1 "$SCREWS_ADJUST_FILE")" 'Screws Tilt Adjust Support' + info_line "$(check_file_k1 "$M600_SUPPORT_FILE")" 'M600 Support' + info_line "$(check_file_k1 "$GIT_BACKUP_FILE")" 'Git Backup' + hr + subtitle '•CAMERA:' + info_line "$(check_file_k1 "$TIMELAPSE_FILE")" 'Moonraker Timelapse' + info_line "$(check_file_k1 "$CAMERA_SETTINGS_FILE")" 'Camera Settings Control' + info_line "$(check_file_k1 "$USB_CAMERA_FILE")" 'USB Camera Support' + hr + subtitle '•REMOTE ACCESS:' + info_line "$(check_folder_k1 "$OCTOEVERYWHERE_FOLDER")" 'OctoEverywhere' + info_line "$(check_folder_k1 "$MOONRAKER_OBICO_FOLDER")" 'Obico' + info_line "$(check_folder_k1 "$GUPPYFLO_FOLDER")" 'GuppyFLO' + info_line "$(check_folder_k1 "$MOBILERAKER_COMPANION_FOLDER")" 'Mobileraker Companion' + info_line "$(check_folder_k1 "$OCTOAPP_COMPANION_FOLDER")" 'OctoApp Companion' + info_line "$(check_simplyprint_k1)" 'SimplyPrint' + hr + subtitle '•CUSTOMIZATION:' + info_line "$(check_file_k1 "$BOOT_DISPLAY_FILE")" 'Custom Boot Display' + info_line "$(check_file_k1 "$CREALITY_WEB_FILE")" 'Creality Web Interface' + info_line "$(check_folder_k1 "$GUPPY_SCREEN_FOLDER")" 'Guppy Screen' + info_line "$(check_file_k1 "$FLUIDD_LOGO_FILE")" 'Creality Dynamic Logos for Fluidd' + hr + inner_line + hr + bottom_menu_option 'b' 'Back to [Main Menu]' "${yellow}" + bottom_menu_option 'q' 'Exit' "${darkred}" + hr + version_line "$(get_script_version)" + bottom_line +} + +function info_menu_k1() { + clear + info_menu_ui_k1 + local info_menu_opt + while true; do + read -p " ${white}Type your choice and validate with Enter: ${yellow}" info_menu_opt + case "${info_menu_opt}" in + B|b) + clear; main_menu; break;; + Q|q) + clear; exit 0;; + *) + error_msg "Please select a correct choice!";; + esac + done + info_menu_k1 +} diff --git a/scripts/menu/install_menu.sh b/scripts/menu/K1/install_menu_K1.sh similarity index 79% rename from scripts/menu/install_menu.sh rename to scripts/menu/K1/install_menu_K1.sh index e2fa220..fe32d52 100755 --- a/scripts/menu/install_menu.sh +++ b/scripts/menu/K1/install_menu_K1.sh @@ -2,7 +2,7 @@ set -e -function install_menu_ui() { +function install_menu_ui_k1() { top_line title '[ INSTALL MENU ]' "${yellow}" inner_line @@ -25,13 +25,13 @@ function install_menu_ui() { menu_option '11' 'Install' 'Useful Macros' menu_option '12' 'Install' 'Save Z-Offset Macros' menu_option '13' 'Install' 'Screws Tilt Adjust Support' - menu_option '14' 'Install' 'Virtual Pins Support' - menu_option '15' 'Install' 'M600 Support' - menu_option '16' 'Install' 'Git Backup' + menu_option '14' 'Install' 'M600 Support' + menu_option '15' 'Install' 'Git Backup' hr subtitle '•CAMERA:' - menu_option '17' 'Install' 'Moonraker Timelapse' - menu_option '18' 'Install' 'Camera Settings Control' + menu_option '16' 'Install' 'Moonraker Timelapse' + menu_option '17' 'Install' 'Camera Settings Control' + menu_option '18' 'Install' 'USB Camera Support' hr subtitle '•REMOTE ACCESS:' menu_option '19' 'Install' 'OctoEverywhere' @@ -50,9 +50,9 @@ function install_menu_ui() { bottom_line } -function install_menu() { +function install_menu_k1() { clear - install_menu_ui + install_menu_ui_k1 local install_menu_opt while true; do read -p " ${white}Type your choice and validate with Enter: ${yellow}" install_menu_opt @@ -61,7 +61,7 @@ function install_menu() { if [ -d "$MOONRAKER_FOLDER" ]; then error_msg "Moonraker and Nginx are already installed!" else - run "install_moonraker_nginx" "install_menu_ui" + run "install_moonraker_nginx" "install_menu_ui_k1" fi;; 2) if [ -d "$FLUIDD_FOLDER" ]; then @@ -69,7 +69,7 @@ function install_menu() { elif [ ! -d "$MOONRAKER_FOLDER" ] && [ ! -d "$NGINX_FOLDER" ]; then error_msg "Moonraker and Nginx are needed, please install them first!" else - run "install_fluidd" "install_menu_ui" + run "install_fluidd" "install_menu_ui_k1" fi;; 3) if [ -d "$MAINSAIL_FOLDER" ]; then @@ -77,27 +77,25 @@ function install_menu() { elif [ ! -d "$MOONRAKER_FOLDER" ] && [ ! -d "$NGINX_FOLDER" ]; then error_msg "Moonraker and Nginx are needed, please install them first!" else - run "install_mainsail" "install_menu_ui" + run "install_mainsail" "install_menu_ui_k1" fi;; 4) if [ -f "$ENTWARE_FILE" ]; then error_msg "Entware is already installed!" else - run "install_entware" "install_menu_ui" + run "install_entware" "install_menu_ui_k1" fi;; 5) if [ -f "$KLIPPER_SHELL_FILE" ]; then error_msg "Klipper Gcode Shell Command is already installed!" else - run "install_gcode_shell_command" "install_menu_ui" + run "install_gcode_shell_command" "install_menu_ui_k1" fi;; 6) if [ -d "$KAMP_FOLDER" ]; then error_msg "Klipper Adaptive Meshing & Purging is already installed!" - elif [ ! -f "$VIRTUAL_PINS_FILE" ]; then - error_msg "Virtual Pins Support is needed, please install it first!" else - run "install_kamp" "install_menu_ui" + run "install_kamp" "install_menu_ui_k1" fi;; 7) if [ -f "$BUZZER_FILE" ]; then @@ -105,19 +103,19 @@ function install_menu() { elif [ ! -f "$KLIPPER_SHELL_FILE" ]; then error_msg "Klipper Gcode Shell Command is needed, please install it first!" else - run "install_buzzer_support" "install_menu_ui" + run "install_buzzer_support" "install_menu_ui_k1" fi;; 8) if [ -d "$NOZZLE_CLEANING_FOLDER" ]; then error_msg "Nozzle Cleaning Fan Control is already installed!" else - run "install_nozzle_cleaning_fan_control" "install_menu_ui" + run "install_nozzle_cleaning_fan_control" "install_menu_ui_k1" fi;; 9) if [ -f "$FAN_CONTROLS_FILE" ]; then error_msg "Fans Control Macros are already installed!" else - run "install_fans_control_macros" "install_menu_ui" + run "install_fans_control_macros" "install_menu_ui_k1" fi;; 10) if [ -d "$IMP_SHAPERS_FOLDER" ]; then @@ -127,7 +125,7 @@ function install_menu() { elif [ ! -f "$KLIPPER_SHELL_FILE" ]; then error_msg "Klipper Gcode Shell Command is needed, please install it first!" else - run "install_improved_shapers" "install_menu_ui" + run "install_improved_shapers" "install_menu_ui_k1" fi;; 11) if [ -f "$USEFUL_MACROS_FILE" ]; then @@ -135,33 +133,27 @@ function install_menu() { elif [ ! -f "$KLIPPER_SHELL_FILE" ]; then error_msg "Klipper Gcode Shell Command is needed, please install it first!" else - run "install_useful_macros" "install_menu_ui" + run "install_useful_macros" "install_menu_ui_k1" fi;; 12) if [ -f "$SAVE_ZOFFSET_FILE" ]; then error_msg "Save Z-Offset Macros are already installed!" else - run "install_save_zoffset_macros" "install_menu_ui" + run "install_save_zoffset_macros" "install_menu_ui_k1" fi;; 13) if [ -f "$SCREWS_ADJUST_FILE" ]; then error_msg "Screws Tilt Adjust Support is already installed!" else - run "install_screws_tilt_adjust" "install_menu_ui" + run "install_screws_tilt_adjust" "install_menu_ui_k1" fi;; 14) - if [ -f "$VIRTUAL_PINS_FILE" ]; then - error_msg "Virtual Pins Support is already installed!" - else - run "install_virtual_pins" "install_menu_ui" - fi;; - 15) if [ -f "$M600_SUPPORT_FILE" ]; then error_msg "M600 Support is already installed!" else - run "install_m600_support" "install_menu_ui" + run "install_m600_support" "install_menu_ui_k1" fi;; - 16) + 15) if [ -f "$GIT_BACKUP_FILE" ]; then error_msg "Git Backup is already installed!" elif [ ! -f "$ENTWARE_FILE" ]; then @@ -169,25 +161,33 @@ function install_menu() { elif [ ! -f "$KLIPPER_SHELL_FILE" ]; then error_msg "Klipper Gcode Shell Command is needed, please install it first!" else - run "install_git_backup" "install_menu_ui" + run "install_git_backup" "install_menu_ui_k1" fi;; - 17) + 16) if [ -f "$TIMELAPSE_FILE" ]; then error_msg "Moonraker Timelapse is already installed!" elif [ ! -f "$ENTWARE_FILE" ]; then error_msg "Entware is needed, please install it first!" else - run "install_moonraker_timelapse" "install_menu_ui" + run "install_moonraker_timelapse" "install_menu_ui_k1" fi;; - 18) + 17) if [ -f "$CAMERA_SETTINGS_FILE" ]; then error_msg "Camera Settings Control is already installed!" - elif v4l2-ctl --list-devices | grep -q 'CCX2F3299'; then - error_msg "You have the new hardware version of the camera and it's not compatible!" + elif v4l2-ctl --list-devices | grep -q 'CCX2F3299' && [ ! -f "$INITD_FOLDER"/S50usb_camera ]; then + error_msg "This is not compatible with the new hardware version of the camera!" elif [ ! -f "$KLIPPER_SHELL_FILE" ]; then error_msg "Klipper Gcode Shell Command is needed, please install it first!" else - run "install_camera_settings_control" "install_menu_ui" + run "install_camera_settings_control" "install_menu_ui_k1" + fi;; + 18) + if [ -f "$USB_CAMERA_FILE" ]; then + error_msg "Camera USB Support is already installed!" + elif [ ! -f "$ENTWARE_FILE" ]; then + error_msg "Entware is needed, please install it first!" + else + run "install_usb_camera" "install_menu_ui_k1" fi;; 19) if [ -d "$OCTOEVERYWHERE_FOLDER" ]; then @@ -195,11 +195,11 @@ function install_menu() { elif [ ! -d "$MOONRAKER_FOLDER" ]; then error_msg "Moonraker and Nginx are needed, please install them first!" elif [ ! -d "$FLUIDD_FOLDER" ] && [ ! -d "$MAINSAIL_FOLDER" ]; then - error_msg "Fluidd or Mainsail is needed, please install it first!" + error_msg "Fluidd or Mainsail is needed, please install one of them first!" elif [ ! -f "$ENTWARE_FILE" ]; then error_msg "Entware is needed, please install it first!" else - run "install_octoeverywhere" "install_menu_ui" + run "install_octoeverywhere" "install_menu_ui_k1" fi;; 20) if [ -d "$MOONRAKER_OBICO_FOLDER" ]; then @@ -207,17 +207,17 @@ function install_menu() { elif [ ! -d "$MOONRAKER_FOLDER" ]; then error_msg "Moonraker and Nginx are needed, please install them first!" elif [ ! -d "$FLUIDD_FOLDER" ] && [ ! -d "$MAINSAIL_FOLDER" ]; then - error_msg "Fluidd or Mainsail is needed, please install it first!" + error_msg "Fluidd or Mainsail is needed, please install one of them first!" elif [ ! -f "$ENTWARE_FILE" ]; then error_msg "Entware is needed, please install it first!" else - run "install_moonraker_obico" "install_menu_ui" + run "install_moonraker_obico" "install_menu_ui_k1" fi;; 21) if [ ! -d "$MOONRAKER_FOLDER" ] && [ ! -d "$NGINX_FOLDER" ]; then error_msg "Moonraker and Nginx are needed, please install them first!" else - run "install_guppyflo" "install_menu_ui" + run "install_guppyflo" "install_menu_ui_k1" fi;; 22) if [ -d "$MOBILERAKER_COMPANION_FOLDER" ]; then @@ -225,9 +225,9 @@ function install_menu() { elif [ ! -d "$MOONRAKER_FOLDER" ]; then error_msg "Moonraker and Nginx are needed, please install them first!" elif [ ! -d "$FLUIDD_FOLDER" ] && [ ! -d "$MAINSAIL_FOLDER" ]; then - error_msg "Fluidd or Mainsail is needed, please install it first!" + error_msg "Fluidd or Mainsail is needed, please install one of them first!" else - run "install_mobileraker_companion" "install_menu_ui" + run "install_mobileraker_companion" "install_menu_ui_k1" fi;; 23) if [ -d "$OCTOAPP_COMPANION_FOLDER" ]; then @@ -235,11 +235,11 @@ function install_menu() { elif [ ! -d "$MOONRAKER_FOLDER" ]; then error_msg "Moonraker and Nginx are needed, please install them first!" elif [ ! -d "$FLUIDD_FOLDER" ] && [ ! -d "$MAINSAIL_FOLDER" ]; then - error_msg "Fluidd or Mainsail is needed, please install it first!" + error_msg "Fluidd or Mainsail is needed, please install one of them first!" elif [ ! -f "$ENTWARE_FILE" ]; then error_msg "Entware is needed, please install it first!" else - run "install_octoapp_companion" "install_menu_ui" + run "install_octoapp_companion" "install_menu_ui_k1" fi;; 24) if grep -q "\[simplyprint\]" "$MOONRAKER_CFG"; then @@ -247,9 +247,9 @@ function install_menu() { elif [ ! -d "$MOONRAKER_FOLDER" ]; then error_msg "Moonraker and Nginx are needed, please install them first!" elif [ ! -d "$FLUIDD_FOLDER" ] && [ ! -d "$MAINSAIL_FOLDER" ]; then - error_msg "Fluidd or Mainsail is needed, please install it first!" + error_msg "Fluidd or Mainsail is needed, please install one of them first!" else - run "install_simplyprint" "install_menu_ui" + run "install_simplyprint" "install_menu_ui_k1" fi;; B|b) clear; main_menu; break;; @@ -259,5 +259,5 @@ function install_menu() { error_msg "Please select a correct choice!";; esac done - install_menu + install_menu_k1 } diff --git a/scripts/menu/remove_menu.sh b/scripts/menu/K1/remove_menu_K1.sh similarity index 78% rename from scripts/menu/remove_menu.sh rename to scripts/menu/K1/remove_menu_K1.sh index 71c2206..50c3b82 100755 --- a/scripts/menu/remove_menu.sh +++ b/scripts/menu/K1/remove_menu_K1.sh @@ -2,7 +2,7 @@ set -e -function remove_menu_ui() { +function remove_menu_ui_k1() { top_line title '[ REMOVE MENU ]' "${yellow}" inner_line @@ -25,13 +25,13 @@ function remove_menu_ui() { menu_option '11' 'Remove' 'Useful Macros' menu_option '12' 'Remove' 'Save Z-Offset Macros' menu_option '13' 'Remove' 'Screws Tilt Adjust Support' - menu_option '14' 'Remove' 'Virtual Pins Support' - menu_option '15' 'Remove' 'M600 Support' - menu_option '16' 'Remove' 'Git Backup' + menu_option '14' 'Remove' 'M600 Support' + menu_option '15' 'Remove' 'Git Backup' hr subtitle '•CAMERA:' - menu_option '17' 'Remove' 'Moonraker Timelapse' - menu_option '18' 'Remove' 'Camera Settings Control' + menu_option '16' 'Remove' 'Moonraker Timelapse' + menu_option '17' 'Remove' 'Camera Settings Control' + menu_option '18' 'Remove' 'USB Camera Support' hr subtitle '•REMOTE ACCESS:' menu_option '19' 'Remove' 'OctoEverywhere' @@ -50,9 +50,9 @@ function remove_menu_ui() { bottom_line } -function remove_menu() { +function remove_menu_k1() { clear - remove_menu_ui + remove_menu_ui_k1 local remove_menu_opt while true; do read -p " ${white}Type your choice and validate with Enter: ${yellow}" remove_menu_opt @@ -61,7 +61,7 @@ function remove_menu() { if [ ! -d "$MOONRAKER_FOLDER" ] && [ ! -d "$NGINX_FOLDER" ]; then error_msg "Moonraker and Nginx are not installed!" else - run "remove_moonraker_nginx" "remove_menu_ui" + run "remove_moonraker_nginx" "remove_menu_ui_k1" fi;; 2) if [ ! -d "$FLUIDD_FOLDER" ]; then @@ -71,7 +71,7 @@ function remove_menu() { echo -e " ${darkred}Please restore Creality Web Interface first if you want to remove Fluidd.${white}" echo else - run "remove_fluidd" "remove_menu_ui" + run "remove_fluidd" "remove_menu_ui_k1" fi;; 3) if [ ! -d "$MAINSAIL_FOLDER" ]; then @@ -81,7 +81,7 @@ function remove_menu() { echo -e " ${darkred}Please restore Creality Web Interface first if you want to remove Mainsail.${white}" echo else - run "remove_mainsail" "remove_menu_ui" + run "remove_mainsail" "remove_menu_ui_k1" fi;; 4) if [ ! -f "$ENTWARE_FILE" ]; then @@ -94,8 +94,10 @@ function remove_menu() { error_msg "Entware is needed to use OctoEverywhere, please uninstall it first!" elif [ -d "$MOONRAKER_OBICO_FOLDER" ]; then error_msg "Entware is needed to use Moonraker Obico, please uninstall it first!" + elif [ ! -f "$USB_CAMERA_FILE" ]; then + error_msg "Entware is needed to use USB Camera Support, please uninstall it first!" else - run "remove_entware" "remove_menu_ui" + run "remove_entware" "remove_menu_ui_k1" fi;; 5) if [ ! -f "$KLIPPER_SHELL_FILE" ]; then @@ -108,126 +110,126 @@ function remove_menu() { error_msg "Klipper Gcode Shell Command is needed to use Guppy Screen, please uninstall it first!" elif [ -d "$IMP_SHAPERS_FOLDER" ]; then error_msg "Klipper Gcode Shell Command is needed to use Improved Shapers Calibrations, please uninstall it first!" - elif [ -d "$GIT_BACKUP_FOLDER" ]; then + elif [ -f "$GIT_BACKUP_FILE" ]; then error_msg "Klipper Gcode Shell Command is needed to use Git Backup, please uninstall it first!" elif [ -f "$USEFUL_MACROS_FILE" ]; then error_msg "Klipper Gcode Shell Command is needed to use Useful Macros, please uninstall it first!" else - run "remove_gcode_shell_command" "remove_menu_ui" + run "remove_gcode_shell_command" "remove_menu_ui_k1" fi;; 6) if [ ! -d "$KAMP_FOLDER" ]; then error_msg "Klipper Adaptive Meshing & Purging is not installed!" else - run "remove_kamp" "remove_menu_ui" + run "remove_kamp" "remove_menu_ui_k1" fi;; 7) if [ ! -f "$BUZZER_FILE" ]; then error_msg "Buzzer Support is not installed!" else - run "remove_buzzer_support" "remove_menu_ui" + run "remove_buzzer_support" "remove_menu_ui_k1" fi;; 8) if [ ! -d "$NOZZLE_CLEANING_FOLDER" ]; then error_msg "Nozzle Cleaning Fan Control is not installed!" else - run "remove_nozzle_cleaning_fan_control" "remove_menu_ui" + run "remove_nozzle_cleaning_fan_control" "remove_menu_ui_k1" fi;; 9) if [ ! -f "$FAN_CONTROLS_FILE" ]; then error_msg "Fans Control Macros are not installed!" else - run "remove_fans_control_macros" "remove_menu_ui" + run "remove_fans_control_macros" "remove_menu_ui_k1" fi;; 10) if [ ! -d "$IMP_SHAPERS_FOLDER" ]; then error_msg "Improved Shapers Calibrations are not installed!" else - run "remove_improved_shapers" "remove_menu_ui" + run "remove_improved_shapers" "remove_menu_ui_k1" fi;; 11) if [ ! -f "$USEFUL_MACROS_FILE" ]; then error_msg "Useful Macros are not installed!" else - run "remove_useful_macros" "remove_menu_ui" + run "remove_useful_macros" "remove_menu_ui_k1" fi;; 12) if [ ! -f "$SAVE_ZOFFSET_FILE" ]; then error_msg "Save Z-Offset Macros are not installed!" else - run "remove_save_zoffset_macros" "remove_menu_ui" + run "remove_save_zoffset_macros" "remove_menu_ui_k1" fi;; 13) if [ ! -f "$SCREWS_ADJUST_FILE" ]; then error_msg "Screws Tilt Adjust Support is not installed!" else - run "remove_screws_tilt_adjust" "remove_menu_ui" + run "remove_screws_tilt_adjust" "remove_menu_ui_k1" fi;; 14) - if [ ! -f "$VIRTUAL_PINS_FILE" ]; then - error_msg "Virtual Pins Support is not installed!" - else - run "remove_virtual_pins" "remove_menu_ui" - fi;; - 15) if [ ! -f "$M600_SUPPORT_FILE" ]; then error_msg "M600 Support is not installed!" else - run "remove_m600_support" "remove_menu_ui" + run "remove_m600_support" "remove_menu_ui_k1" fi;; - 16) + 15) if [ ! -f "$GIT_BACKUP_FILE" ]; then error_msg "Git Backup is not installed!" else - run "remove_git_backup" "remove_menu_ui" + run "remove_git_backup" "remove_menu_ui_k1" fi;; - 17) + 16) if [ ! -f "$TIMELAPSE_FILE" ]; then error_msg "Moonraker Timelapse is not installed!" else - run "remove_moonraker_timelapse" "remove_menu_ui" + run "remove_moonraker_timelapse" "remove_menu_ui_k1" fi;; - 18) + 17) if [ ! -f "$CAMERA_SETTINGS_FILE" ]; then error_msg "Camera Settings Control is not installed!" else - run "remove_camera_settings_control" "remove_menu_ui" + run "remove_camera_settings_control" "remove_menu_ui_k1" + fi;; + 18) + if [ ! -f "$USB_CAMERA_FILE" ]; then + error_msg "USB Camera Support is not installed!" + else + run "remove_usb_camera" "remove_menu_ui_k1" fi;; 19) if [ ! -d "$OCTOEVERYWHERE_FOLDER" ]; then error_msg "OctoEverywhere is not installed!" else - run "remove_octoeverywhere" "remove_menu_ui" + run "remove_octoeverywhere" "remove_menu_ui_k1" fi;; 20) if [ ! -d "$MOONRAKER_OBICO_FOLDER" ]; then error_msg "Moonraker Obico is not installed!" else - run "remove_moonraker_obico" "remove_menu_ui" + run "remove_moonraker_obico" "remove_menu_ui_k1" fi;; 21) if [ ! -d "$GUPPYFLO_FOLDER" ]; then error_msg "GuppyFLO is not installed!" else - run "remove_guppyflo" "remove_menu_ui" + run "remove_guppyflo" "remove_menu_ui_k1" fi;; 22) if [ ! -d "$MOBILERAKER_COMPANION_FOLDER" ]; then error_msg "Mobileraker Companion is not installed!" else - run "remove_mobileraker_companion" "remove_menu_ui" + run "remove_mobileraker_companion" "remove_menu_ui_k1" fi;; 23) if [ ! -d "$OCTOAPP_COMPANION_FOLDER" ]; then error_msg "OctoApp Companion is not installed!" else - run "remove_octoapp_companion" "remove_menu_ui" + run "remove_octoapp_companion" "remove_menu_ui_k1" fi;; 24) if ! grep -q "\[simplyprint\]" "$MOONRAKER_CFG"; then error_msg "SimplyPrint is not installed!" else - run "remove_simplyprint" "remove_menu_ui" + run "remove_simplyprint" "remove_menu_ui_k1" fi;; B|b) clear; main_menu; break;; @@ -237,5 +239,5 @@ function remove_menu() { error_msg "Please select a correct choice!";; esac done - remove_menu + remove_menu_k1 } diff --git a/scripts/menu/tools_menu.sh b/scripts/menu/K1/tools_menu_K1.sh similarity index 75% rename from scripts/menu/tools_menu.sh rename to scripts/menu/K1/tools_menu_K1.sh index 0ab61cb..a319899 100755 --- a/scripts/menu/tools_menu.sh +++ b/scripts/menu/K1/tools_menu_K1.sh @@ -2,7 +2,7 @@ set -e -function tools_menu_ui() { +function tools_menu_ui_k1() { top_line title '[ TOOLS MENU ]' "${yellow}" inner_line @@ -36,9 +36,9 @@ function tools_menu_ui() { bottom_line } -function tools_menu() { +function tools_menu_k1() { clear - tools_menu_ui + tools_menu_ui_k1 local tools_menu_opt while true; do read -p " ${white}Type your choice and validate with Enter: ${yellow}" tools_menu_opt @@ -47,62 +47,62 @@ function tools_menu() { if [ -f "$INITD_FOLDER"/disabled.S55klipper_service ]; then error_msg "Updating Klipper configuration files is already prevented!" else - run "prevent_updating_klipper_files" "tools_menu_ui" + run "prevent_updating_klipper_files" "tools_menu_ui_k1" fi;; 2) if [ ! -f "$INITD_FOLDER"/disabled.S55klipper_service ]; then error_msg "Updating Klipper configuration files is already allowed!" else - run "allow_updating_klipper_files" "tools_menu_ui" + run "allow_updating_klipper_files" "tools_menu_ui_k1" fi;; 3) if [ -f "$KLIPPER_KLIPPY_FOLDER"/gcode.py ]; then - run "printing_gcode_from_folder" "tools_menu_ui" + run "printing_gcode_from_folder" "tools_menu_ui_k1" fi;; 4) if grep -q "^\[webcam Camera\]$" "$MOONRAKER_CFG"; then error_msg "Camera settings are alredy enabled in Moonraker!" else - run "enable_camera_settings" "tools_menu_ui" + run "enable_camera_settings" "tools_menu_ui_k1" fi;; 5) if grep -q "^#\[webcam Camera\]" "$MOONRAKER_CFG"; then error_msg "Camera settings are alredy disabled in Moonraker!" else - run "disable_camera_settings" "tools_menu_ui" + run "disable_camera_settings" "tools_menu_ui_k1" fi;; 6) if [ ! -d "$NGINX_FOLDER" ]; then error_msg "Nginx is not installed!" else - run "restart_nginx_action" "tools_menu_ui" + run "restart_nginx_action" "tools_menu_ui_k1" fi;; 7) if [ ! -d "$MOONRAKER_FOLDER" ]; then error_msg "Moonraker is not installed!" else - run "restart_moonraker_action" "tools_menu_ui" + run "restart_moonraker_action" "tools_menu_ui_k1" fi;; 8) if [ ! -f "$INITD_FOLDER"/S55klipper_service ]; then error_msg "Klipper service is not present!" else - run "restart_klipper_action" "tools_menu_ui" + run "restart_klipper_action" "tools_menu_ui_k1" fi;; 9) if [ ! -f "$ENTWARE_FILE" ]; then error_msg "Entware is not installed!" else - run "update_entware_packages" "tools_menu_ui" + run "update_entware_packages" "tools_menu_ui_k1" fi;; 10) - run "clear_cache" "tools_menu_ui";; + run "clear_cache" "tools_menu_ui_k1";; 11) - run "clear_logs" "tools_menu_ui";; + run "clear_logs" "tools_menu_ui_k1";; 12) - run "restore_previous_firmware" "tools_menu_ui";; + run "restore_previous_firmware" "tools_menu_ui_k1";; 13) - run "reset_factory_settings" "tools_menu_ui";; + run "reset_factory_settings" "tools_menu_ui_k1";; B|b) clear; main_menu; break;; Q|q) @@ -111,5 +111,5 @@ function tools_menu() { error_msg "Please select a correct choice!";; esac done - tools_menu + tools_menu_k1 } diff --git a/scripts/menu/KE/customize_menu_KE.sh b/scripts/menu/KE/customize_menu_KE.sh index 340d24c..947fe18 100755 --- a/scripts/menu/KE/customize_menu_KE.sh +++ b/scripts/menu/KE/customize_menu_KE.sh @@ -33,7 +33,7 @@ function customize_menu_ke() { case "${customize_menu_opt}" in 1) if [ ! -d "$FLUIDD_FOLDER" ] && [ ! -d "$MAINSAIL_FOLDER" ]; then - error_msg "Fluidd or Mainsail is needed, please install it first!" + error_msg "Fluidd or Mainsail is needed, please install one of them first!" elif [ ! -f "$CREALITY_WEB_FILE" ]; then error_msg "Creality Web Interface is already removed!" echo -e " ${darkred}Please restore Creality Web Interface first if you want to change the default Web Interface.${white}" diff --git a/scripts/menu/KE/info_menu_KE.sh b/scripts/menu/KE/info_menu_KE.sh index 627b4c5..8540ec4 100755 --- a/scripts/menu/KE/info_menu_KE.sh +++ b/scripts/menu/KE/info_menu_KE.sh @@ -45,11 +45,12 @@ function info_menu_ui_ke() { subtitle '•IMPROVEMENTS:' info_line "$(check_folder_ke "$IMP_SHAPERS_FOLDER")" 'Improved Shapers Calibrations' info_line "$(check_file_ke "$SAVE_ZOFFSET_FILE")" 'Save Z-Offset Macros' - info_line "$(check_file_ke "$VIRTUAL_PINS_FILE")" 'Virtual Pins Support' info_line "$(check_file_ke "$GIT_BACKUP_FILE")" 'Git Backup' hr subtitle '•CAMERA:' info_line "$(check_file_ke "$TIMELAPSE_FILE")" 'Moonraker Timelapse' + info_line "$(check_file_ke "$CAMERA_SETTINGS_FILE")" 'Nebula Camera Settings Control' + info_line "$(check_file_ke "$USB_CAMERA_FILE")" 'USB Camera Support' hr subtitle '•REMOTE ACCESS:' info_line "$(check_folder_ke "$OCTOEVERYWHERE_FOLDER")" 'OctoEverywhere' diff --git a/scripts/menu/KE/install_menu_KE.sh b/scripts/menu/KE/install_menu_KE.sh index e3bbc8a..0b55f37 100755 --- a/scripts/menu/KE/install_menu_KE.sh +++ b/scripts/menu/KE/install_menu_KE.sh @@ -19,19 +19,20 @@ function install_menu_ui_ke() { subtitle '•IMPROVEMENTS:' menu_option ' 6' 'Install' 'Improved Shapers Calibrations' menu_option ' 7' 'Install' 'Save Z-Offset Macros' - menu_option ' 8' 'Install' 'Virtual Pins Support' - menu_option ' 9' 'Install' 'Git Backup' + menu_option ' 8' 'Install' 'Git Backup' hr subtitle '•CAMERA:' - menu_option '10' 'Install' 'Moonraker Timelapse' + menu_option ' 9' 'Install' 'Moonraker Timelapse' + menu_option '10' 'Install' 'Nebula Camera Settings Control' + menu_option '11' 'Install' 'USB Camera Support' hr subtitle '•REMOTE ACCESS:' - menu_option '11' 'Install' 'OctoEverywhere' - menu_option '12' 'Install' 'Moonraker Obico' - menu_option '13' 'Install' 'GuppyFLO' - menu_option '14' 'Install' 'Mobileraker Companion' - menu_option '15' 'Install' 'OctoApp Companion' - menu_option '16' 'Install' 'SimplyPrint' + menu_option '12' 'Install' 'OctoEverywhere' + menu_option '13' 'Install' 'Moonraker Obico' + menu_option '14' 'Install' 'GuppyFLO' + menu_option '15' 'Install' 'Mobileraker Companion' + menu_option '16' 'Install' 'OctoApp Companion' + menu_option '17' 'Install' 'SimplyPrint' hr inner_line hr @@ -100,12 +101,6 @@ function install_menu_ke() { run "install_save_zoffset_macros" "install_menu_ui_ke" fi;; 8) - if [ -f "$VIRTUAL_PINS_FILE" ]; then - error_msg "Virtual Pins Support is already installed!" - else - run "install_virtual_pins" "install_menu_ui_ke" - fi;; - 9) if [ -f "$GIT_BACKUP_FILE" ]; then error_msg "Git Backup is already installed!" elif [ ! -f "$ENTWARE_FILE" ]; then @@ -115,7 +110,7 @@ function install_menu_ke() { else run "install_git_backup" "install_menu_ui_ke" fi;; - 10) + 9) if [ -f "$TIMELAPSE_FILE" ]; then error_msg "Moonraker Timelapse is already installed!" elif [ ! -f "$ENTWARE_FILE" ]; then @@ -123,65 +118,85 @@ function install_menu_ke() { else run "install_moonraker_timelapse" "install_menu_ui_ke" fi;; + 10) + if [ -f "$CAMERA_SETTINGS_FILE" ]; then + error_msg "Nebula Camera Settings Control is already installed!" + elif ! v4l2-ctl --list-devices | grep -q 'CCX2F3298'; then + error_msg "Nebula camera not detected, please plug it in!" + elif [ ! -f "$KLIPPER_SHELL_FILE" ]; then + error_msg "Klipper Gcode Shell Command is needed, please install it first!" + else + run "install_camera_settings_control" "install_menu_ui_ke" + fi;; 11) + if [ -f "$USB_CAMERA_FILE" ]; then + error_msg "Camera USB Support is already installed!" + elif v4l2-ctl --list-devices | grep -qE 'CREALITY|CCX2F3298'; then + error_msg "It looks like you are using a Creality camera and it's not compatible!" + elif [ ! -f "$ENTWARE_FILE" ]; then + error_msg "Entware is needed, please install it first!" + else + run "install_usb_camera" "install_menu_ui_ke" + fi;; + 12) if [ -d "$OCTOEVERYWHERE_FOLDER" ]; then error_msg "OctoEverywhere is already installed!" elif [ ! -d "$MOONRAKER_FOLDER" ]; then error_msg "Moonraker and Nginx are needed, please install them first!" elif [ ! -d "$FLUIDD_FOLDER" ] && [ ! -d "$MAINSAIL_FOLDER" ]; then - error_msg "Fluidd or Mainsail is needed, please install it first!" + error_msg "Fluidd or Mainsail is needed, please install one of them first!" elif [ ! -f "$ENTWARE_FILE" ]; then error_msg "Entware is needed, please install it first!" else run "install_octoeverywhere" "install_menu_ui_ke" fi;; - 12) + 13) if [ -d "$MOONRAKER_OBICO_FOLDER" ]; then error_msg "Moonraker Obico is already installed!" elif [ ! -d "$MOONRAKER_FOLDER" ]; then error_msg "Moonraker and Nginx are needed, please install them first!" elif [ ! -d "$FLUIDD_FOLDER" ] && [ ! -d "$MAINSAIL_FOLDER" ]; then - error_msg "Fluidd or Mainsail is needed, please install it first!" + error_msg "Fluidd or Mainsail is needed, please install one of them first!" elif [ ! -f "$ENTWARE_FILE" ]; then error_msg "Entware is needed, please install it first!" else run "install_moonraker_obico" "install_menu_ui_ke" fi;; - 13) + 14) if [ ! -d "$MOONRAKER_FOLDER" ] && [ ! -d "$NGINX_FOLDER" ]; then error_msg "Moonraker and Nginx are needed, please install them first!" else run "install_guppyflo" "install_menu_ui_ke" fi;; - 14) + 15) if [ -d "$MOBILERAKER_COMPANION_FOLDER" ]; then error_msg "Mobileraker Companion is already installed!" elif [ ! -d "$MOONRAKER_FOLDER" ]; then error_msg "Moonraker and Nginx are needed, please install them first!" elif [ ! -d "$FLUIDD_FOLDER" ] && [ ! -d "$MAINSAIL_FOLDER" ]; then - error_msg "Fluidd or Mainsail is needed, please install it first!" + error_msg "Fluidd or Mainsail is needed, please install one of them first!" else run "install_mobileraker_companion" "install_menu_ui_ke" fi;; - 15) + 16) if [ -d "$OCTOAPP_COMPANION_FOLDER" ]; then error_msg "OctoApp Companion is already installed!" elif [ ! -d "$MOONRAKER_FOLDER" ]; then error_msg "Moonraker and Nginx are needed, please install them first!" elif [ ! -d "$FLUIDD_FOLDER" ] && [ ! -d "$MAINSAIL_FOLDER" ]; then - error_msg "Fluidd or Mainsail is needed, please install it first!" + error_msg "Fluidd or Mainsail is needed, please install one of them first!" elif [ ! -f "$ENTWARE_FILE" ]; then error_msg "Entware is needed, please install it first!" else run "install_octoapp_companion" "install_menu_ui_ke" fi;; - 16) + 17) if grep -q "\[simplyprint\]" "$MOONRAKER_CFG"; then error_msg "SimplyPrint is already installed!" elif [ ! -d "$MOONRAKER_FOLDER" ]; then error_msg "Moonraker and Nginx are needed, please install them first!" elif [ ! -d "$FLUIDD_FOLDER" ] && [ ! -d "$MAINSAIL_FOLDER" ]; then - error_msg "Fluidd or Mainsail is needed, please install it first!" + error_msg "Fluidd or Mainsail is needed, please install one of them first!" else run "install_simplyprint" "install_menu_ui_ke" fi;; diff --git a/scripts/menu/KE/remove_menu_KE.sh b/scripts/menu/KE/remove_menu_KE.sh index 74ee2e4..72f6dec 100755 --- a/scripts/menu/KE/remove_menu_KE.sh +++ b/scripts/menu/KE/remove_menu_KE.sh @@ -19,19 +19,20 @@ function remove_menu_ui_ke() { subtitle '•IMPROVEMENTS:' menu_option ' 6' 'Remove' 'Improved Shapers Calibrations' menu_option ' 7' 'Remove' 'Save Z-Offset Macros' - menu_option ' 8' 'Remove' 'Virtual Pins Support' - menu_option ' 9' 'Remove' 'Git Backup' + menu_option ' 8' 'Remove' 'Git Backup' hr subtitle '•CAMERA:' - menu_option '10' 'Remove' 'Moonraker Timelapse' + menu_option ' 9' 'Remove' 'Moonraker Timelapse' + menu_option '10' 'Install' 'Nebula Camera Settings Control' + menu_option '11' 'Remove' 'USB Camera Support' hr subtitle '•REMOTE ACCESS:' - menu_option '11' 'Remove' 'OctoEverywhere' - menu_option '12' 'Remove' 'Moonraker Obico' - menu_option '13' 'Remove' 'GuppyFLO' - menu_option '14' 'Remove' 'Mobileraker Companion' - menu_option '15' 'Remove' 'OctoApp Companion' - menu_option '16' 'Remove' 'SimplyPrint' + menu_option '12' 'Remove' 'OctoEverywhere' + menu_option '13' 'Remove' 'Moonraker Obico' + menu_option '14' 'Remove' 'GuppyFLO' + menu_option '15' 'Remove' 'Mobileraker Companion' + menu_option '16' 'Remove' 'OctoApp Companion' + menu_option '17' 'Remove' 'SimplyPrint' hr inner_line hr @@ -86,6 +87,8 @@ function remove_menu_ke() { error_msg "Entware is needed to use OctoEverywhere, please uninstall it first!" elif [ -d "$MOONRAKER_OBICO_FOLDER" ]; then error_msg "Entware is needed to use Moonraker Obico, please uninstall it first!" + elif [ ! -f "$USB_CAMERA_FILE" ]; then + error_msg "Entware is needed to use USB Camera Support, please uninstall it first!" else run "remove_entware" "remove_menu_ui_ke" fi;; @@ -96,7 +99,7 @@ function remove_menu_ke() { error_msg "Klipper Gcode Shell Command is needed to use Guppy Screen, please uninstall it first!" elif [ -d "$IMP_SHAPERS_FOLDER" ]; then error_msg "Klipper Gcode Shell Command is needed to use Improved Shapers Calibrations, please uninstall it first!" - elif [ -d "$GIT_BACKUP_FOLDER" ]; then + elif [ -f "$GIT_BACKUP_FILE" ]; then error_msg "Klipper Gcode Shell Command is needed to use Git Backup, please uninstall it first!" else run "remove_gcode_shell_command" "remove_menu_ui_ke" @@ -114,58 +117,64 @@ function remove_menu_ke() { run "remove_save_zoffset_macros" "remove_menu_ui_ke" fi;; 8) - if [ ! -f "$VIRTUAL_PINS_FILE" ]; then - error_msg "Virtual Pins Support is not installed!" - else - run "remove_virtual_pins" "remove_menu_ui_ke" - fi;; - 9) if [ ! -f "$GIT_BACKUP_FILE" ]; then error_msg "Git Backup is not installed!" else run "remove_git_backup" "remove_menu_ui_ke" fi;; - 10) + 9) if [ ! -f "$TIMELAPSE_FILE" ]; then error_msg "Moonraker Timelapse is not installed!" else run "remove_moonraker_timelapse" "remove_menu_ui_ke" fi;; + 10) + if [ ! -f "$CAMERA_SETTINGS_FILE" ]; then + error_msg "Nebula Camera Settings Control is not installed!" + else + run "remove_camera_settings_control" "remove_menu_ui_ke" + fi;; 11) + if [ ! -f "$USB_CAMERA_FILE" ]; then + error_msg "USB Camera Support is not installed!" + else + run "remove_usb_camera" "remove_menu_ui_3v3" + fi;; + 12) if [ ! -d "$OCTOEVERYWHERE_FOLDER" ]; then error_msg "OctoEverywhere is not installed!" else run "remove_octoeverywhere" "remove_menu_ui_ke" fi;; - 12) + 13) if [ ! -d "$MOONRAKER_OBICO_FOLDER" ]; then error_msg "Moonraker Obico is not installed!" else run "remove_moonraker_obico" "remove_menu_ui_ke" fi;; - 13) + 14) if [ ! -d "$GUPPYFLO_FOLDER" ]; then error_msg "GuppyFLO is not installed!" else run "remove_guppyflo" "remove_menu_ui_ke" fi;; - 14) + 15) if [ ! -d "$MOBILERAKER_COMPANION_FOLDER" ]; then error_msg "Mobileraker Companion is not installed!" else run "remove_mobileraker_companion" "remove_menu_ui_ke" fi;; - 15) + 16) if [ ! -d "$OCTOAPP_COMPANION_FOLDER" ]; then error_msg "OctoApp Companion is not installed!" else run "remove_octoapp_companion" "remove_menu_ui_ke" fi;; - 16) + 17) if ! grep -q "\[simplyprint\]" "$MOONRAKER_CFG"; then error_msg "SimplyPrint is not installed!" else - run "remove_simplyprint" "remove_menu_ui" + run "remove_simplyprint" "remove_menu_ui_ke" fi;; B|b) clear; main_menu; break;; diff --git a/scripts/menu/info_menu.sh b/scripts/menu/info_menu.sh deleted file mode 100755 index d6e9a23..0000000 --- a/scripts/menu/info_menu.sh +++ /dev/null @@ -1,101 +0,0 @@ -#!/bin/sh - -set -e - -function check_folder() { - local folder_path="$1" - if [ -d "$folder_path" ]; then - echo -e "${green}✓" - else - echo -e "${red}✗" - fi -} - -function check_file() { - local file_path="$1" - if [ -f "$file_path" ]; then - echo -e "${green}✓" - else - echo -e "${red}✗" - fi -} - -function check_simplyprint() { - if grep -q "\[simplyprint\]" "$MOONRAKER_CFG"; then - echo -e "${green}✓" - else - echo -e "${red}✗" - fi -} - -function info_menu_ui() { - top_line - title '[ INFORMATIONS MENU ]' "${yellow}" - inner_line - hr - subtitle '•ESSENTIALS:' - info_line "$(check_folder "$MOONRAKER_FOLDER")" 'Moonraker & Nginx' - info_line "$(check_folder "$FLUIDD_FOLDER")" 'Fluidd' - info_line "$(check_folder "$MAINSAIL_FOLDER")" 'Mainsail' - hr - subtitle '•UTILITIES:' - info_line "$(check_file "$ENTWARE_FILE")" 'Entware' - info_line "$(check_file "$KLIPPER_SHELL_FILE")" 'Klipper Gcode Shell Command' - hr - subtitle '•IMPROVEMENTS:' - info_line "$(check_folder "$KAMP_FOLDER")" 'Klipper Adaptive Meshing & Purging' - info_line "$(check_file "$BUZZER_FILE")" 'Buzzer Support' - info_line "$(check_folder "$NOZZLE_CLEANING_FOLDER")" 'Nozzle Cleaning Fan Control' - info_line "$(check_file "$FAN_CONTROLS_FILE")" 'Fans Control Macros' - info_line "$(check_folder "$IMP_SHAPERS_FOLDER")" 'Improved Shapers Calibrations' - info_line "$(check_file "$USEFUL_MACROS_FILE")" 'Useful Macros' - info_line "$(check_file "$SAVE_ZOFFSET_FILE")" 'Save Z-Offset Macros' - info_line "$(check_file "$SCREWS_ADJUST_FILE")" 'Screws Tilt Adjust Support' - info_line "$(check_file "$VIRTUAL_PINS_FILE")" 'Virtual Pins Support' - info_line "$(check_file "$M600_SUPPORT_FILE")" 'M600 Support' - info_line "$(check_file "$GIT_BACKUP_FILE")" 'Git Backup' - hr - subtitle '•CAMERA:' - info_line "$(check_file "$TIMELAPSE_FILE")" 'Moonraker Timelapse' - info_line "$(check_file "$CAMERA_SETTINGS_FILE")" 'Camera Settings Control' - hr - subtitle '•REMOTE ACCESS:' - info_line "$(check_folder "$OCTOEVERYWHERE_FOLDER")" 'OctoEverywhere' - info_line "$(check_folder "$MOONRAKER_OBICO_FOLDER")" 'Obico' - info_line "$(check_folder "$GUPPYFLO_FOLDER")" 'GuppyFLO' - info_line "$(check_folder "$MOBILERAKER_COMPANION_FOLDER")" 'Mobileraker Companion' - info_line "$(check_folder "$OCTOAPP_COMPANION_FOLDER")" 'OctoApp Companion' - info_line "$(check_simplyprint)" 'SimplyPrint' - hr - subtitle '•CUSTOMIZATION:' - info_line "$(check_file "$BOOT_DISPLAY_FILE")" 'Custom Boot Display' - info_line "$(check_file "$CREALITY_WEB_FILE")" 'Creality Web Interface' - info_line "$(check_folder "$GUPPY_SCREEN_FOLDER")" 'Guppy Screen' - info_line "$(check_file "$FLUIDD_LOGO_FILE")" 'Creality Dynamic Logos for Fluidd' - hr - inner_line - hr - bottom_menu_option 'b' 'Back to [Main Menu]' "${yellow}" - bottom_menu_option 'q' 'Exit' "${darkred}" - hr - version_line "$(get_script_version)" - bottom_line -} - -function info_menu() { - clear - info_menu_ui - local info_menu_opt - while true; do - read -p " ${white}Type your choice and validate with Enter: ${yellow}" info_menu_opt - case "${info_menu_opt}" in - B|b) - clear; main_menu; break;; - Q|q) - clear; exit 0;; - *) - error_msg "Please select a correct choice!";; - esac - done - info_menu -} diff --git a/scripts/menu/main_menu.sh b/scripts/menu/main_menu.sh index 15697ea..11d0557 100755 --- a/scripts/menu/main_menu.sh +++ b/scripts/menu/main_menu.sh @@ -2,7 +2,12 @@ set -e -if /usr/bin/get_sn_mac.sh model 2>&1 | grep -iq "K1"; then K1=1; else K1=0; fi +get_model=$( /usr/bin/get_sn_mac.sh model 2>&1 ) +if echo "$get_model" | grep -iq "K1"; then + model="K1" +elif echo "$get_model" | grep -iq "F001"; then + model="3V3" +fi function get_script_version() { local version @@ -21,30 +26,22 @@ function version_line() { function script_title() { local title - if [ $K1 -eq 0 ]; then - title="KE" + if [ "$model" = "K1" ]; then + title="K1 SERIES" + elif [ "$model" = "3V3" ]; then + title="ENDER-3 V3 SERIES" else - title="K1" + title="KE SERIES" fi echo "${title}" } -function fw_version() { - local firmware - if [ $K1 -eq 0 ]; then - firmware="1.1.0.12" - else - firmware="1.3.3.5" - fi - echo "${firmware}" -} - function main_menu_ui() { top_line - title "• HELPER SCRIPT FOR CREALITY $(script_title) SERIES •" "${blue}" + title "• HELPER SCRIPT FOR CREALITY $(script_title) •" "${blue}" title "Copyright © Cyril Guislain (Guilouz)" "${white}" inner_line - title "/!\\ ONLY USE IT WITH FIRMWARE $(fw_version) AND ABOVE /!\\" "${darkred}" + title "/!\\ ONLY USE THIS SCRIPT WITH LATEST FIRMWARE VERSION /!\\" "${darkred}" inner_line hr main_menu_option '1' '[Install]' 'Menu' @@ -71,41 +68,51 @@ function main_menu() { read -p "${white} Type your choice and validate with Enter: ${yellow}" main_menu_opt case "${main_menu_opt}" in 1) clear - if [ $K1 -eq 0 ]; then - install_menu_ke + if [ "$model" = "K1" ]; then + install_menu_k1 + elif [ "$model" = "3V3" ]; then + install_menu_3v3 else - install_menu + install_menu_ke fi break;; 2) clear - if [ $K1 -eq 0 ]; then - remove_menu_ke + if [ "$model" = "K1" ]; then + remove_menu_k1 + elif [ "$model" = "3V3" ]; then + remove_menu_3v3 else - remove_menu + remove_menu_ke fi break;; 3) clear - if [ $K1 -eq 0 ]; then - customize_menu_ke + if [ "$model" = "K1" ]; then + customize_menu_k1 + elif [ "$model" = "3V3" ]; then + customize_menu_3v3 else - customize_menu + customize_menu_ke fi break;; 4) clear backup_restore_menu break;; 5) clear - if [ $K1 -eq 0 ]; then - tools_menu_ke + if [ "$model" = "K1" ]; then + tools_menu_k1 + elif [ "$model" = "3V3" ]; then + tools_menu_3v3 else - tools_menu + tools_menu_ke fi main_ui;; 6) clear - if [ $K1 -eq 0 ]; then - info_menu_ke + if [ "$model" = "K1" ]; then + info_menu_k1 + elif [ "$model" = "3V3" ]; then + info_menu_3v3 else - info_menu + info_menu_ke fi break;; 7) clear diff --git a/scripts/moonraker_nginx.sh b/scripts/moonraker_nginx.sh index 8a8640f..3f8c9b4 100755 --- a/scripts/moonraker_nginx.sh +++ b/scripts/moonraker_nginx.sh @@ -16,6 +16,19 @@ function moonraker_nginx_message(){ bottom_line } +function moonraker_3v3_message(){ + top_line + title 'Updated Moonraker' "${yellow}" + inner_line + hr + echo -e " │ ${cyan}Moonraker is a Python 3 based web server that exposes APIs ${white}│" + echo -e " │ ${cyan}with which client applications may use to interact with ${white}│" + echo -e " │ ${cyan}Klipper firmware. ${white}│" + echo -e " │ ${cyan}This allows to have an updated version of Moonraker. ${white}│" + hr + bottom_line +} + function install_moonraker_nginx(){ moonraker_nginx_message local yn @@ -24,8 +37,10 @@ function install_moonraker_nginx(){ case "${yn}" in Y|y) echo -e "${white}" - echo -e "Info: Extracting files..." + echo -e "Info: Extracting Moonraker files..." tar -xvf "$MOONRAKER_URL1" -C "$USR_DATA" + echo -e "Info: Extracting Nginx files..." + tar -xvf "$NGINX_URL" -C "$USR_DATA" echo -e "Info: Copying services files..." if [ ! -f "$INITD_FOLDER"/S50nginx ]; then cp "$NGINX_SERVICE_URL" "$INITD_FOLDER"/S50nginx @@ -82,10 +97,12 @@ function remove_moonraker_nginx(){ Y|y) echo -e "${white}" echo -e "Info: Stopping Moonraker and Nginx services..." - cd /overlay/upper stop_moonraker stop_nginx echo -e "Info: Removing files..." + cd "$MOONRAKER_FOLDER"/moonraker-env/bin + python3 -m pip uninstall -y pyserial-asyncio==0.6 + cd rm -f "$INITD_FOLDER"/S50nginx rm -f "$INITD_FOLDER"/S56moonraker_service rm -f "$KLIPPER_CONFIG_FOLDER"/moonraker.conf @@ -107,4 +124,114 @@ function remove_moonraker_nginx(){ error_msg "Please select a correct choice!";; esac done +} + +function install_moonraker_3v3(){ + moonraker_3v3_message + local yn + while true; do + install_msg "Updated Moonraker" yn + case "${yn}" in + Y|y) + echo -e "${white}" + echo -e "Info: Stopping Moonraker and Nginx services..." + stop_moonraker + stop_nginx + echo -e "Info: Extracting files..." + tar -xvf "$MOONRAKER_URL1" -C "$USR_DATA" + echo -e "Info: Deleting existing folders..." + rm -rf "$USR_SHARE"/moonraker + rm -rf "$USR_SHARE"/moonraker-env + echo -e "Info: Linking files..." + ln -sf "$MOONRAKER_FOLDER"/moonraker "$USR_SHARE"/moonraker + ln -sf "$MOONRAKER_FOLDER"/moonraker-env "$USR_SHARE"/moonraker-env + if [ -f /etc/nginx/nginx.conf ]; then + echo -e "Info: Copying Nginx configuration file..." + mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.backup + cp "$NGINX_CONF_URL" /etc/nginx/nginx.conf + fi + echo -e "Info: Copying Moonraker configuration file..." + if [ -f "$KLIPPER_CONFIG_FOLDER"/moonraker.conf ]; then + rm -f "$KLIPPER_CONFIG_FOLDER"/moonraker.conf + fi + cp "$MOONRAKER_URL2" "$KLIPPER_CONFIG_FOLDER"/moonraker.conf + if [ -f "$PRINTER_DATA_FOLDER"/moonraker.asvc ]; then + rm -f "$PRINTER_DATA_FOLDER"/moonraker.asvc + fi + cp "$MOONRAKER_URL3" "$PRINTER_DATA_FOLDER"/moonraker.asvc + echo -e "Info: Applying changes from official repo..." + cd "$MOONRAKER_FOLDER"/moonraker + git stash; git checkout master; git pull + echo -e "Info: Installing Supervisor Lite..." + chmod 755 "$SUPERVISOR_URL" + ln -sf "$SUPERVISOR_URL" "$SUPERVISOR_FILE" + echo -e "Info: Installing Host Controls Support..." + chmod 755 "$SUDO_URL" + chmod 755 "$SYSTEMCTL_URL" + ln -sf "$SUDO_URL" "$SUDO_FILE" + ln -sf "$SYSTEMCTL_URL" "$SYSTEMCTL_FILE" + echo -e "Info: Installing necessary packages..." + cd "$MOONRAKER_FOLDER"/moonraker-env/bin + python3 -m pip install --no-cache-dir pyserial-asyncio==0.6 + echo -e "Info: Starting Nginx service..." + start_nginx + echo -e "Info: Starting Moonraker service..." + start_moonraker + ok_msg "Updated Moonraker has been installed successfully!" + return;; + N|n) + error_msg "Installation canceled!" + return;; + *) + error_msg "Please select a correct choice!";; + esac + done +} + +function remove_moonraker_3v3(){ + moonraker_3v3_message + local yn + while true; do + remove_msg "Updated Moonraker" yn + case "${yn}" in + Y|y) + echo -e "${white}" + echo -e "Info: Stopping Moonraker and Nginx services..." + stop_moonraker + stop_nginx + echo -e "Info: Removing files..." + cd "$MOONRAKER_FOLDER"/moonraker-env/bin + python3 -m pip uninstall -y pyserial-asyncio==0.6 + cd + rm -rf "$PRINTER_DATA_FOLDER"/comms + rm -rf "$MOONRAKER_FOLDER" + rm -f "$KLIPPER_CONFIG_FOLDER"/moonraker.conf + rm -f "$KLIPPER_CONFIG_FOLDER"/.moonraker.conf.bkp + rm -f "$PRINTER_DATA_FOLDER"/.moonraker.uuid + rm -f "$PRINTER_DATA_FOLDER"/moonraker.asvc + rm -f "$SUPERVISOR_FILE" + rm -f "$SUDO_FILE" + rm -f "$SYSTEMCTL_FILE" + if [ -f /etc/nginx/nginx.conf.backup ]; then + echo -e "Info: Restoring stock Nginx configuration..." + rm -f /etc/nginx/nginx.conf + mv /etc/nginx/nginx.conf.backup /etc/nginx/nginx.conf + fi + echo -e "Info: Restoring stock Moonraker version..." + rm -rf /overlay/upper/usr/share/moonraker + rm -rf /overlay/upper/usr/share/moonraker-env + mount -o remount / + echo -e "Info: Starting Nginx service..." + start_nginx + echo -e "Info: Starting Moonraker service..." + start_moonraker + ok_msg "Updated Moonraker has been removed successfully!" + return;; + N|n) + error_msg "Deletion canceled!" + return;; + *) + error_msg "Please select a correct choice!";; + esac + done } \ No newline at end of file diff --git a/scripts/paths.sh b/scripts/paths.sh index d05d5a2..ebebb95 100755 --- a/scripts/paths.sh +++ b/scripts/paths.sh @@ -17,6 +17,7 @@ function set_paths() { CURL="${HELPER_SCRIPT_FOLDER}/files/fixes/curl" INITD_FOLDER="/etc/init.d" USR_DATA="/usr/data" + USR_SHARE="/usr/share" PRINTER_DATA_FOLDER="$USR_DATA/printer_data" # Helper Script # @@ -38,7 +39,9 @@ function set_paths() { # Nginx # NGINX_FOLDER="${USR_DATA}/nginx" + NGINX_URL="${HS_FILES}/moonraker/nginx.tar.gz" NGINX_SERVICE_URL="${HS_FILES}/services/S50nginx" + NGINX_CONF_URL="${HS_FILES}/moonraker/nginx.conf" # Supervisor Lite # SUPERVISOR_FILE="/usr/bin/supervisorctl" @@ -56,6 +59,7 @@ function set_paths() { KLIPPER_KLIPPY_FOLDER="/usr/share/klipper/klippy" KLIPPER_SERVICE_URL="${HS_FILES}/services/S55klipper_service" KLIPPER_GCODE_URL="${HS_FILES}/fixes/gcode.py" + KLIPPER_GCODE_3V3_URL="${HS_FILES}/fixes/gcode_3v3.py" # Fluidd # FLUIDD_FOLDER="${USR_DATA}/fluidd" @@ -76,6 +80,8 @@ function set_paths() { # Klipper Adaptive Meshing & Purging # KAMP_FOLDER="${HS_CONFIG_FOLDER}/KAMP" KAMP_URL="${HS_FILES}/kamp" + VIRTUAL_PINS_FILE="${KLIPPER_EXTRAS_FOLDER}/virtual_pins.py" + VIRTUAL_PINS_URL="${HS_FILES}/klipper-virtual-pins/virtual_pins.py" # Buzzer Support # BUZZER_FILE="${HS_CONFIG_FOLDER}/buzzer-support.cfg" @@ -98,6 +104,7 @@ function set_paths() { # Useful Macros # USEFUL_MACROS_FILE="${HS_CONFIG_FOLDER}/useful-macros.cfg" USEFUL_MACROS_URL="${HS_FILES}/macros/useful-macros.cfg" + USEFUL_MACROS_3V3_URL="${HS_FILES}/macros/useful-macros-3v3.cfg" # Save Z-Offset Macros # SAVE_ZOFFSET_FILE="${HS_CONFIG_FOLDER}/save-zoffset.cfg" @@ -109,13 +116,10 @@ function set_paths() { SCREWS_ADJUST_K1_URL="${HS_FILES}/screws-tilt-adjust/screws-tilt-adjust-k1.cfg" SCREWS_ADJUST_K1M_URL="${HS_FILES}/screws-tilt-adjust/screws-tilt-adjust-k1max.cfg" - # Virtual Pins Support # - VIRTUAL_PINS_FILE="${KLIPPER_EXTRAS_FOLDER}/virtual_pins.py" - VIRTUAL_PINS_URL="${HS_FILES}/klipper-virtual-pins/virtual_pins.py" - # M600 Support # M600_SUPPORT_FILE="${HS_CONFIG_FOLDER}/M600-support.cfg" M600_SUPPORT_URL="${HS_FILES}/macros/M600-support.cfg" + M600_SUPPORT_3V3_URL="${HS_FILES}/macros/M600-support-3v3.cfg" # Git Backup # GIT_BACKUP_INSTALLER="${HS_FILES}/git-backup/git-backup.sh" @@ -130,6 +134,12 @@ function set_paths() { # Camera Settings Control # CAMERA_SETTINGS_FILE="${HS_CONFIG_FOLDER}/camera-settings.cfg" CAMERA_SETTINGS_URL="${HS_FILES}/camera-settings/camera-settings.cfg" + CAMERA_SETTINGS_NEBULA_URL="${HS_FILES}/camera-settings/camera-settings-nebula.cfg" + + # USB Camera Support + USB_CAMERA_FILE="${INITD_FOLDER}/S50usb_camera" + USB_CAMERA_SINGLE_URL="${HS_FILES}/services/S50usb_camera-single" + USB_CAMERA_DUAL_URL="${HS_FILES}/services/S50usb_camera-dual" # OctoEverywhere # OCTOEVERYWHERE_FOLDER="${USR_DATA}/octoeverywhere" @@ -165,6 +175,8 @@ function set_paths() { GUPPY_SCREEN_FOLDER="${USR_DATA}/guppyscreen" GUPPY_SCREEN_URL1="${HS_FILES}/guppy-screen/guppy_update.cfg" GUPPY_SCREEN_URL2="${HS_FILES}/guppy-screen/guppy-update.sh" + GUPPY_SCREEN_3V3_URL="${HS_FILES}/guppy-screen/guppy_update-3v3.cfg" + GUPPY_SCREEN_CONFIG_3V3_URL="${HS_FILES}/guppy-screen/guppyconfig-3v3.json" # Creality Dynamic Logos for Fluidd # FLUIDD_LOGO_FILE="${USR_DATA}/fluidd/logo_creality_v2.svg" diff --git a/scripts/tools.sh b/scripts/tools.sh index a6cae13..ac0b915 100755 --- a/scripts/tools.sh +++ b/scripts/tools.sh @@ -157,7 +157,12 @@ function printing_gcode_from_folder(){ rm -f "$KLIPPER_KLIPPY_FOLDER"/gcode.pyc fi echo -e "Info: Linking files..." - ln -sf "$KLIPPER_GCODE_URL" "$KLIPPER_KLIPPY_FOLDER"/gcode.py + if [ "$model" = "K1" ]; then + ln -sf "$KLIPPER_GCODE_URL" "$KLIPPER_KLIPPY_FOLDER"/gcode.py + fi + if [ "$model" = "3V3" ]; then + ln -sf "$KLIPPER_GCODE_3V3_URL" "$KLIPPER_KLIPPY_FOLDER"/gcode.py + fi echo -e "Info: Restarting Klipper service..." restart_klipper ok_msg "Fix has been applied successfully!" diff --git a/scripts/usb_camera.sh b/scripts/usb_camera.sh new file mode 100755 index 0000000..71852f1 --- /dev/null +++ b/scripts/usb_camera.sh @@ -0,0 +1,102 @@ +#!/bin/sh + +set -e + +function usb_camera_message(){ + top_line + title 'USB Camera Support' "${yellow}" + inner_line + hr + echo -e " │ ${cyan}This allows to use third-party camera from your printer's ${white}│" + echo -e " │ ${cyan}USB port. ${white}│" + hr + bottom_line +} + +function install_usb_camera(){ + usb_camera_message + local yn + while true; do + install_msg "USB Camera Support" yn + case "${yn}" in + Y|y) + echo -e "${white}" + echo -e "Info: Copying file..." + if [ "$model" = "K1" ]; then + cp "$USB_CAMERA_DUAL_URL" "$INITD_FOLDER"/S50usb_camera + else + cp "$USB_CAMERA_SINGLE_URL" "$INITD_FOLDER"/S50usb_camera + echo + echo -e " ${darkred}Be careful with the 1080p resolution!" + echo -e " It takes more resources and timelapses are larger and take longer to convert.${white}" + echo -e " 720p is a good compromise between quality and performance." + echo -e " Make sure your camera is compatible with the chosen resolution." + echo + local resolution + while true; do + read -p " What camera resolution do you want to apply? (${yellow}480p${white}/${yellow}720p${white}/${yellow}1080p${white}): ${yellow}" resolution + case "${resolution}" in + 480p|480P) + echo -e "${white}" + echo -e "Info: Applying change..." + sed -i 's/1280x720/640x480/g' "$INITD_FOLDER"/S50usb_camera + break;; + 720p|720P) + echo -e "${white}" + echo -e "Info: Applying change..." + break;; + 1080p|1080p) + echo -e "${white}" + echo -e "Info: Applying change..." + sed -i 's/1280x720/1920x1080/g' "$INITD_FOLDER"/S50usb_camera + break;; + *) + error_msg "Please select a correct choice!";; + esac + done + fi + chmod 755 "$INITD_FOLDER"/S50usb_camera + echo -e "Info: Installing necessary packages..." + "$ENTWARE_FILE" update && "$ENTWARE_FILE" install mjpg-streamer mjpg-streamer-input-http mjpg-streamer-input-uvc mjpg-streamer-output-http mjpg-streamer-www + echo -e "Info: Starting service..." + "$INITD_FOLDER"/S50usb_camera start + ok_msg "USB Camera Support has been installed successfully!" + return;; + N|n) + error_msg "Installation canceled!" + return;; + *) + error_msg "Please select a correct choice!";; + esac + done +} + +function remove_usb_camera(){ + usb_camera_message + local yn + while true; do + remove_msg "USB Camera Support" yn + case "${yn}" in + Y|y) + echo -e "${white}" + echo -e "Info: Stopping service..." + "$INITD_FOLDER"/S50usb_camera stop + echo -e "Info: Removing file..." + rm -f "$INITD_FOLDER"/S50usb_camera + echo -e "Info: Removing packages..." + "$ENTWARE_FILE" --autoremove remove mjpg-streamer-www + "$ENTWARE_FILE" --autoremove remove mjpg-streamer-output-http + "$ENTWARE_FILE" --autoremove remove mjpg-streamer-input-uvc + "$ENTWARE_FILE" --autoremove remove mjpg-streamer-input-http + "$ENTWARE_FILE" --autoremove remove mjpg-streamer + ok_msg "USB Camera Support has been removed successfully!" + echo -e " Please reboot your printer by using power switch on back!" + return;; + N|n) + error_msg "Deletion canceled!" + return;; + *) + error_msg "Please select a correct choice!";; + esac + done +} diff --git a/scripts/useful_macros.sh b/scripts/useful_macros.sh index fd806dc..4665eba 100755 --- a/scripts/useful_macros.sh +++ b/scripts/useful_macros.sh @@ -29,7 +29,11 @@ function install_useful_macros(){ mkdir -p "$HS_CONFIG_FOLDER" fi echo -e "Info: Linking file..." - ln -sf "$USEFUL_MACROS_URL" "$HS_CONFIG_FOLDER"/useful-macros.cfg + if [ "$model" = "K1" ]; then + ln -sf "$USEFUL_MACROS_URL" "$HS_CONFIG_FOLDER"/useful-macros.cfg + else + ln -sf "$USEFUL_MACROS_3V3_URL" "$HS_CONFIG_FOLDER"/useful-macros.cfg + fi if grep -q "include Helper-Script/useful-macros" "$PRINTER_CFG" ; then echo -e "Info: Useful Macros configurations are already enabled in printer.cfg file..." else diff --git a/scripts/virtual_pins.sh b/scripts/virtual_pins.sh deleted file mode 100755 index 096f1f4..0000000 --- a/scripts/virtual_pins.sh +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/sh - -set -e - -function virtual_pins_message(){ - top_line - title 'Virtual Pins Support' "${yellow}" - inner_line - hr - echo -e " │ ${cyan}It allows usage of virtual (simulated) pins in Klipper ${white}│" - echo -e " │ ${cyan}configurations files. ${white}│" - hr - bottom_line -} - -function install_virtual_pins(){ - virtual_pins_message - local yn - while true; do - install_msg "Virtual Pins Support" yn - case "${yn}" in - Y|y) - echo -e "${white}" - echo -e "Info: Linking file..." - ln -sf "$VIRTUAL_PINS_URL" "$VIRTUAL_PINS_FILE" - if grep -q "[virtual_pins]" "$PRINTER_CFG" ; then - echo -e "Info: Adding [virtual_pins] configuration in printer.cfg file..." - sed -i '/\[include sensorless.cfg\]/i [virtual_pins]' "$PRINTER_CFG" - else - echo -e "Info: [virtual_pins] configuration is already enabled in printer.cfg file..." - fi - echo -e "Info: Restarting Klipper service..." - restart_klipper - ok_msg "Virtual Pins Support has been installed successfully!" - return;; - N|n) - error_msg "Installation canceled!" - return;; - *) - error_msg "Please select a correct choice!";; - esac - done -} - -function remove_virtual_pins(){ - virtual_pins_message - local yn - while true; do - remove_msg "Virtual Pins Support" yn - case "${yn}" in - Y|y) - echo -e "${white}" - echo -e "Info: Removing file..." - rm -f "$KLIPPER_EXTRAS_FOLDER"/virtual_pins.py - rm -f "$KLIPPER_EXTRAS_FOLDER"/virtual_pins.pyc - if grep -q "[virtual_pins]" "$PRINTER_CFG" ; then - echo -e "Info: Removing [virtual_pins] configuration in printer.cfg file..." - sed -i '/\[virtual_pins\]/d' "$PRINTER_CFG" - else - echo -e "Info: [virtual_pins] configuration is already removed in printer.cfg file..." - fi - echo -e "Info: Restarting Klipper service..." - restart_klipper - ok_msg "Virtual Pins Support has been removed successfully!" - return;; - N|n) - error_msg "Deletion canceled!" - return;; - *) - error_msg "Please select a correct choice!";; - esac - done -} \ No newline at end of file