Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions bambulabs_api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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:
"""
Expand Down
15 changes: 13 additions & 2 deletions bambulabs_api/ftp_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]:
Expand Down
24 changes: 11 additions & 13 deletions bambulabs_api/mqtt_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand All @@ -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"
}
})

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down