diff --git a/bambulabs_api/client.py b/bambulabs_api/client.py index 39f776a..d104a6d 100644 --- a/bambulabs_api/client.py +++ b/bambulabs_api/client.py @@ -347,12 +347,13 @@ def upload_file(self, file: BinaryIO, filename: str = "ftp_upload.gcode") -> str return "No file uploaded." def start_print(self, filename: str, - plate_number: int | str, + plate_number: int | str = 1, use_ams: bool = True, ams_mapping: list[int] = [0], skip_objects: list[int] | None = None, flow_calibration: bool = True, - ) -> bool: + bed_leveling: bool = True, + ) -> bool: """ Start printing a file. @@ -383,7 +384,8 @@ def start_print(self, filename: str, use_ams, ams_mapping, skip_objects, - flow_calibration) + flow_calibration, + bed_leveling) def stop_print(self) -> bool: """ diff --git a/bambulabs_api/ftp_client.py b/bambulabs_api/ftp_client.py index a05a7e3..495c45f 100644 --- a/bambulabs_api/ftp_client.py +++ b/bambulabs_api/ftp_client.py @@ -102,8 +102,19 @@ def wrapper(self: 'PrinterFTPClient', *args, **kwargs) -> Any: @connect_and_run def upload_file(self, file: BinaryIO, file_path: str) -> str: - return self.ftps.storbinary(f'STOR {file_path}', file, blocksize=32768, - callback=lambda x: logger.debug(f"Uploaded {x} bytes")) # noqa # pylint: disable=logging-fstring-interpolation + total_bytes = 0 + def upload_callback(data: bytes): + nonlocal total_bytes + total_bytes += len(data) + logger.info(f"Total uploaded {total_bytes} bytes") + logger.debug(f"Uploaded {data} bytes") + + return self.ftps.storbinary( + f'STOR {file_path}', + file, + blocksize=32768, + callback=upload_callback + ) @connect_and_run def list_directory(self, path: str | None = None) -> tuple[str, list[str]]: diff --git a/bambulabs_api/mqtt_client.py b/bambulabs_api/mqtt_client.py index d2b06bf..d6b2db3 100644 --- a/bambulabs_api/mqtt_client.py +++ b/bambulabs_api/mqtt_client.py @@ -470,7 +470,8 @@ def start_print_3mf(self, filename: str, ams_mapping: list[int] = [0], skip_objects: list[int] | None = None, flow_calibration: bool = True, - ) -> bool: + bed_leveling: bool = True, + ) -> bool: """ Start the print @@ -500,7 +501,7 @@ def start_print_3mf(self, filename: str, "command": "project_file", "param": plate_location, "file": filename, - "bed_leveling": True, + "bed_leveling": bool(bed_leveling), "bed_type": "textured_plate", "flow_cali": bool(flow_calibration), "vibration_cali": True, @@ -515,20 +516,19 @@ def start_print_3mf(self, filename: str, def set_onboard_printer_timelapse(self, enable: bool = True): """ - Enable/disable the printer's onboard timelapse/video - functionality. + Enable/disable the printer's onboard timelapse/video functionality. Args: - enable (bool): object list to skip objects. + enable (bool): True to enable recording, False to disable it. Defaults to True. Returns: - bool: if publish command is successful. + bool: True if the publish command is successful, False otherwise. """ return self.__publish_command({ "camera": { "command": "ipcam_record_set", - "control": "disable" if not enable else "enable" + "control": "enable" if enable else "disable" } }) @@ -853,14 +853,12 @@ def set_nozzle_temperature( """ Set the nozzle temperature. Note P1 firmware version above 01.06 does not support M104. M109 is used instead (set and wait for temperature). - To prevent long wait times, if temperature is set to below 40 deg cel, + To prevent long wait times, if temperature is set to below 60 deg cel, no temperature is set, override flag is provided to circumvent this. Args: - temperature (int): The temperature to set the bed to + temperature (int): The temperature to set the nozzle to override (bool): Whether to override guards. Default to False - Args: - temperature (int): temperature to set the nozzle to Returns: bool: success of setting the nozzle temperature @@ -870,8 +868,8 @@ def set_nozzle_temperature( else: if temperature < 60 and not override: logger.warning( - "Attempting to set low bed temperature not recommended. " - "Set override flag to true to if you're sure you want to " + "Attempting to set low nozzle temperature not recommended. " + "Set override flag to true if you're sure you want to " f"run M109 S{temperature};" ) return False