diff --git a/config_loader.py b/config_loader.py index 807f911..bff37de 100644 --- a/config_loader.py +++ b/config_loader.py @@ -57,10 +57,12 @@ def _load_config_file(path: pathlib.Path): "MQTT_PASSWORD": (CONFIG_SECTION_CONNECTION, "password"), "MODE_ID": (CONFIG_SECTION_CONNECTION, "mode_id"), "DEVICE_ID": (CONFIG_SECTION_CONNECTION, "device_id"), - "DEFAULT_AMS_SLOT": (CONFIG_SECTION_PRINT, "default_ams_slot"), - "AUTO_LEVELING": (CONFIG_SECTION_PRINT, "auto_leveling"), - "CAMERA_ON_PRINT": (CONFIG_SECTION_PRINT, "camera_on_print"), - "WEB_UPLOAD_WARNING": (CONFIG_SECTION_PRINT, "web_upload_warning"), + "DEFAULT_AMS_SLOT": (CONFIG_SECTION_PRINT, "default_ams_slot"), + "AUTO_LEVELING": (CONFIG_SECTION_PRINT, "auto_leveling"), + "VIBRATION_COMPENSATION": (CONFIG_SECTION_PRINT, "vibration_compensation"), + "FLOW_CALIBRATION": (CONFIG_SECTION_PRINT, "flow_calibration"), + "CAMERA_ON_PRINT": (CONFIG_SECTION_PRINT, "camera_on_print"), + "WEB_UPLOAD_WARNING": (CONFIG_SECTION_PRINT, "web_upload_warning"), "BRIDGE_PRINTER_NAME": (CONFIG_SECTION_BRIDGE, "printer_name"), } for env_key, (section, option) in mapping.items(): @@ -95,10 +97,12 @@ def migrate_env_to_config(env_path: pathlib.Path, config_path: pathlib.Path): "device_id": env_vals.get("DEVICE_ID", ""), } cfg[CONFIG_SECTION_PRINT] = { - "default_ams_slot": env_vals.get("DEFAULT_AMS_SLOT", "auto"), - "auto_leveling": env_vals.get("AUTO_LEVELING", "1"), - "camera_on_print": env_vals.get("CAMERA_ON_PRINT", "0"), - "web_upload_warning": env_vals.get("WEB_UPLOAD_WARNING", "1"), + "default_ams_slot": env_vals.get("DEFAULT_AMS_SLOT", "auto"), + "auto_leveling": env_vals.get("AUTO_LEVELING", "1"), + "vibration_compensation": env_vals.get("VIBRATION_COMPENSATION", "0"), + "flow_calibration": env_vals.get("FLOW_CALIBRATION", "0"), + "camera_on_print": env_vals.get("CAMERA_ON_PRINT", "0"), + "web_upload_warning": env_vals.get("WEB_UPLOAD_WARNING", "1"), } cfg[CONFIG_SECTION_BRIDGE] = { "poll_interval": "3", @@ -256,6 +260,8 @@ PASSWORD = get("MQTT_PASSWORD", "") MODE_ID = get("MODE_ID", "") DEVICE_ID = get("DEVICE_ID", "") DEFAULT_AMS_SLOT = get("DEFAULT_AMS_SLOT", "auto") -AUTO_LEVELING = int(get("AUTO_LEVELING","1")) -CAMERA_ON_PRINT = int(get("CAMERA_ON_PRINT","0")) -WEB_UPLOAD_WARNING = int(get("WEB_UPLOAD_WARNING", "1")) +AUTO_LEVELING = int(get("AUTO_LEVELING", "1")) +VIBRATION_COMPENSATION = int(get("VIBRATION_COMPENSATION", "0")) +FLOW_CALIBRATION = int(get("FLOW_CALIBRATION", "0")) +CAMERA_ON_PRINT = int(get("CAMERA_ON_PRINT", "0")) +WEB_UPLOAD_WARNING = int(get("WEB_UPLOAD_WARNING", "1")) diff --git a/kobrax_moonraker_bridge.py b/kobrax_moonraker_bridge.py index 37b8f29..f95ea1a 100644 --- a/kobrax_moonraker_bridge.py +++ b/kobrax_moonraker_bridge.py @@ -2197,7 +2197,9 @@ class KobraXBridge: ams_box_mapping = self._build_auto_ams_box_mapping() use_ams = len(ams_box_mapping) > 0 - auto_leveling = getattr(self._args, "auto_leveling", 1) + auto_leveling = getattr(self._args, "auto_leveling", 1) + vibration_compensation = getattr(self._args, "vibration_compensation", 0) + flow_calibration = getattr(self._args, "flow_calibration", 0) filename = gcode_file["filename"] file_path = gcode_file["path"] @@ -2219,8 +2221,8 @@ class KobraXBridge: }, "task_settings": { "auto_leveling": auto_leveling, - "vibration_compensation": 0, - "flow_calibration": 0, + "vibration_compensation": vibration_compensation, + "flow_calibration": flow_calibration, "dry_mode": 0, "ai_settings": {"status": 0, "count": 0, "type": 1}, "timelapse": {"status": 0, "count": 0, "type": 64}, @@ -2619,7 +2621,9 @@ class KobraXBridge: use_ams = len(loaded) > 0 ams_box_mapping = self._build_auto_ams_box_mapping(loaded_slots=loaded) log.debug(f"AMS-Slots: {len(loaded)} gemappt (genutzte Paints: {used_paint_indices}) → {[i for i, _ in loaded]}") - auto_leveling = getattr(self._args, "auto_leveling", 1) + auto_leveling = getattr(self._args, "auto_leveling", 1) + vibration_compensation = getattr(self._args, "vibration_compensation", 0) + flow_calibration = getattr(self._args, "flow_calibration", 0) payload = { "taskid": "-1", "url": url, @@ -2635,8 +2639,8 @@ class KobraXBridge: }, "task_settings": { "auto_leveling": auto_leveling, - "vibration_compensation": 0, - "flow_calibration": 0, + "vibration_compensation": vibration_compensation, + "flow_calibration": flow_calibration, "dry_mode": 0, "ai_settings": {"status": 0, "count": 0, "type": 1}, "timelapse": {"status": 0, "count": 0, "type": 64}, @@ -2707,7 +2711,9 @@ class KobraXBridge: ams_box_mapping = self._build_auto_ams_box_mapping() use_ams = len(ams_box_mapping) > 0 - auto_leveling = getattr(self._args, "auto_leveling", 1) + auto_leveling = getattr(self._args, "auto_leveling", 1) + vibration_compensation = getattr(self._args, "vibration_compensation", 0) + flow_calibration = getattr(self._args, "flow_calibration", 0) url = self._state.get("last_upload_url", "") filesize = self._state.get("last_upload_size", 0) md5 = self._state.get("last_upload_md5", "") @@ -2727,8 +2733,8 @@ class KobraXBridge: }, "task_settings": { "auto_leveling": auto_leveling, - "vibration_compensation": 0, - "flow_calibration": 0, + "vibration_compensation": vibration_compensation, + "flow_calibration": flow_calibration, "dry_mode": 0, "ai_settings": {"status": 0, "count": 0, "type": 0}, "timelapse": {"status": 0, "count": 0, "type": 0}, @@ -3526,10 +3532,12 @@ class KobraXBridge: "password": self._args.password, "mode_id": self._args.mode_id, "device_id": self._args.device_id, - "default_ams_slot": getattr(self._args, "default_ams_slot", "auto"), - "auto_leveling": getattr(self._args, "auto_leveling", 1), - "camera_on_print": getattr(self._args, "camera_on_print", 0), - "web_upload_warning": getattr(self._args, "web_upload_warning", 1), + "default_ams_slot": getattr(self._args, "default_ams_slot", "auto"), + "auto_leveling": getattr(self._args, "auto_leveling", 1), + "vibration_compensation": getattr(self._args, "vibration_compensation", 0), + "flow_calibration": getattr(self._args, "flow_calibration", 0), + "camera_on_print": getattr(self._args, "camera_on_print", 0), + "web_upload_warning": getattr(self._args, "web_upload_warning", 1), "ace_dry_presets": self._ace_dry_presets, }) @@ -3556,10 +3564,12 @@ class KobraXBridge: cfg.set("connection", "password", str(data.get("password", self._args.password or ""))) cfg.set("connection", "mode_id", str(data.get("mode_id", self._args.mode_id or ""))) cfg.set("connection", "device_id", str(data.get("device_id", self._args.device_id or ""))) - cfg.set("print", "default_ams_slot", str(data.get("default_ams_slot", getattr(self._args, "default_ams_slot", "auto")))) - cfg.set("print", "auto_leveling", str(data.get("auto_leveling", getattr(self._args, "auto_leveling", 1)))) - cfg.set("print", "camera_on_print", str(int(bool(data.get("camera_on_print", getattr(self._args, "camera_on_print", 0)))))) - cfg.set("print", "web_upload_warning", str(int(bool(data.get("web_upload_warning", getattr(self._args, "web_upload_warning", 1)))))) + cfg.set("print", "default_ams_slot", str(data.get("default_ams_slot", getattr(self._args, "default_ams_slot", "auto")))) + cfg.set("print", "auto_leveling", str(data.get("auto_leveling", getattr(self._args, "auto_leveling", 1)))) + cfg.set("print", "vibration_compensation", str(int(bool(data.get("vibration_compensation", getattr(self._args, "vibration_compensation", 0)))))) + cfg.set("print", "flow_calibration", str(int(bool(data.get("flow_calibration", getattr(self._args, "flow_calibration", 0)))))) + cfg.set("print", "camera_on_print", str(int(bool(data.get("camera_on_print", getattr(self._args, "camera_on_print", 0)))))) + cfg.set("print", "web_upload_warning", str(int(bool(data.get("web_upload_warning", getattr(self._args, "web_upload_warning", 1)))))) if not cfg.has_option("bridge", "poll_interval"): cfg.set("bridge", "poll_interval", "3") printer_name = str(data.get("printer_name", "")).strip() @@ -4602,9 +4612,11 @@ def main(): parser.add_argument("--mode-id", default=env_loader.MODE_ID) parser.add_argument("--device-id", default=env_loader.DEVICE_ID) parser.add_argument("--default-ams-slot",default=env_loader.DEFAULT_AMS_SLOT) - parser.add_argument("--auto-leveling", type=int, default=env_loader.AUTO_LEVELING) - parser.add_argument("--camera-on-print", type=int, default=env_loader.CAMERA_ON_PRINT) - parser.add_argument("--web-upload-warning", type=int, default=env_loader.WEB_UPLOAD_WARNING) + parser.add_argument("--auto-leveling", type=int, default=env_loader.AUTO_LEVELING) + parser.add_argument("--vibration-compensation", type=int, default=env_loader.VIBRATION_COMPENSATION) + parser.add_argument("--flow-calibration", type=int, default=env_loader.FLOW_CALIBRATION) + parser.add_argument("--camera-on-print", type=int, default=env_loader.CAMERA_ON_PRINT) + parser.add_argument("--web-upload-warning", type=int, default=env_loader.WEB_UPLOAD_WARNING) parser.add_argument("--host", default="0.0.0.0", help="Bind-Adresse für den Bridge-Server") diff --git a/web/themes/default/app.js b/web/themes/default/app.js index 04e5bc2..1814853 100644 --- a/web/themes/default/app.js +++ b/web/themes/default/app.js @@ -323,6 +323,8 @@ function applyLang(){ setText('lbl-default-slot',T.settings_default_slot); setText('opt-slot-auto',T.settings_slot_auto); setText('lbl-auto-leveling',T.settings_auto_leveling); + setText('lbl-vibration-compensation',T.settings_vibration_compensation); + setText('lbl-flow-calibration',T.settings_flow_calibration); setText('lbl-camera-on-print',T.settings_camera_on_print); setText('lbl-web-upload-warning',T.settings_web_upload_warning); @@ -890,6 +892,8 @@ function openSettings(){ document.getElementById('s-mode-id').value=d.mode_id||''; document.getElementById('s-default-slot').value=d.default_ams_slot||'auto'; document.getElementById('s-auto-leveling').checked=(d.auto_leveling===undefined?true:!!d.auto_leveling); + var vc=document.getElementById('s-vibration-compensation');if(vc)vc.checked=!!d.vibration_compensation; + var fc=document.getElementById('s-flow-calibration');if(fc)fc.checked=!!d.flow_calibration; var cop=document.getElementById('s-camera-on-print');if(cop)cop.checked=!!d.camera_on_print; var wuw=document.getElementById('s-web-upload-warning');if(wuw)wuw.checked=(d.web_upload_warning===undefined?true:!!d.web_upload_warning); }); @@ -1146,8 +1150,10 @@ function saveSettings(){ device_id: document.getElementById('s-device-id').value, mode_id: document.getElementById('s-mode-id').value, default_ams_slot: document.getElementById('s-default-slot').value, - auto_leveling: document.getElementById('s-auto-leveling').checked?1:0, - camera_on_print: (document.getElementById('s-camera-on-print')||{}).checked?1:0, + auto_leveling: document.getElementById('s-auto-leveling').checked?1:0, + vibration_compensation: (document.getElementById('s-vibration-compensation')||{}).checked?1:0, + flow_calibration: (document.getElementById('s-flow-calibration')||{}).checked?1:0, + camera_on_print: (document.getElementById('s-camera-on-print')||{}).checked?1:0, web_upload_warning:webUploadWarning, }).then(function(){ btn.textContent=T.update_restarting; diff --git a/web/themes/default/index.html b/web/themes/default/index.html index 803d2af..b6f5bbf 100644 --- a/web/themes/default/index.html +++ b/web/themes/default/index.html @@ -102,6 +102,14 @@ + +