4.2.1. Delta

class fluxclient.sdk.delta.Delta(wrapped_socket, client_key, exit_callback=None, blocking=True)

Delta is an instance that presents the device in SDK mode, which allows users to control motions of the machine freely.

classmethod connect_delta(target=None, ip=None, client_key=None, password=None, kick=False, blocking=True)

Creates a Delta instance

Parameters:
  • uuid (str) – Device’s UUID, optional
  • ip (str) – Device’s IP, optional
  • password (str) – Device’s password
  • kick (bool) – Force to kick other users
  • blocking (bool) – Blocking means python will only send commands when prior commands are finished.
atomic_status(new_staus=None)

Returns the index, queue_left of commands buffer

get_result(index, wait=True)

Acquires the result of certain index from Delta

delta_status()

Loop thread function that collects and updates delta’s status and command’s output

get_position()

Gets the current position of toolhead

Returns:coordinate of each tower
Return type:(float, float, float)
>>> f.get_position()
(0, 0, 280)
home()

Sets each axis back to home.

Returns:command index and the coordinate where the toolhead originally is
Return type:(int, (float, float, float))
>>> f.home()
(0, (20.0, 20.0, 20.0))
>>> f.get_position()
(0, 0, 280)
move(x=None, y=None, z=None, speed=None, relative=False, **kargs)

Move the toolhead to (x, y, z)

Parameters:
  • x (float) – x coordinate, optional
  • y (float) – y coordinate, optional
  • z (float) – z coordinate, optional
  • speed (int) – moving speed, should be within [20, 8000], optional
  • relative (bool) – moving relatively or not, default: False
  • E1 (float) – position mortor E1 move , optional
  • E2 (float) – position mortor E2 move , optional
  • E3 (float) – position mortor E3 move , optional
Returns:

position after moving command

Return type:

(float, float, float)

Raises:

ValueError – if trying to the exceed the limitation of machine

  • basic usage
>>> f.get_position()
(0.0, 0.0, 280.0)
>>> f.move(50, 40, 30)
(50.0, 40.0, 30.0)
>>> f.move(x=80)  # only sets the coordinate you want
(80.0, 40.0, 30.0)
>>> f.move(x=-10, relative=True)  # using relative flag
(70.0, 40.0, 30.0)
>>> f.move(z=-100)
ValueError: Invalid coordinate
  • control motor during moving
>>> f.move(50, 40, 30, E1=10)
(50.0, 40.0, 30.0)
get_position_motor(motor)

Gets the current position of specified motor

Parameters:motor (str) – name of the motor, should be one of the "E1", "E2", "E3"
Returns:the current position of specified motor
Return type:float
Raises:ValueError – raise error if using undifine motor name
>>> f.get_position_motor("E1")
12.34
move_motor(E1=None, E2=None, E3=None, speed=None)

Moves stepper motors

Parameters:
  • E1 (float) – position to move, optional
  • E2 (float) – position to move, optional
  • E3 (float) – position to move, optional
  • speed (int) – moving speed, should be within [20, 8000], optional
>>> f.move_motor(E1=10)
>>> f.move_motor(E1=10, E2=10)
lock_motor()

Locks all motor.

>>> f.lock_motor('XYZ')
release_motor()

Releases all motor.

Note

If you ever released stepper motors, You have to home() before calling move() them.

>>> f.release_motor()
get_position_laser(laser)

Finds out whether the laser is on

Parameters:laser (str) – Which laser, should be "L" or "R"
Raises:ValueError – if the laser parameter is not "L" or "R"
>>> f.get_position_laser('L')
True
turn_laser(laser, on)

Controls the scanning laser

Parameters:
  • laser (str) – Which laser, should be "L" or "R"
  • on (bool) – turn on or off the laser
Raises:

ValueError – if the laser parameter is not "L" or "R"

>>> f.turn_laser('L', True)  # Turn on left laser
True
>>> f.turn_laser('R', False)  # Turn off right laser
False
get_image()

Takes a picture with Delta’s built in camera

Returns:a image object
Return type:PIL.Image.Image
serial_write(buf)

Writes buffer or string to extension port

Parameters:buf (str/bytes) – data sent in extension port
Return type:(int, None): (command_index, None)
>>> f.serial_write(b'PING')  # write bytes
(1, None)
>>> f.serial_write('Hello')  # write string
(2, None)
serial_read(timeout=0)

Reads a chunck from extension port Returns b’’ if timeout happened

Parameters:timeout (int) – timeout trying to read data, default 0
Return type:bytes: a chunck read from extension port
>>> delta.serial_read(timeout=10)
b'PONG'
disable_motor(motor)

Enables motor control

Parameters:

motor (str) – Which motor to disable, should be one of "XYZ", "E1", "E2", "E3"

Raises:
  • TypeError – motor is not str
  • ValueError – if the motor’s name is not one of "XYZ", "E1", "E2", "E3"
enable_motor(motor)

Disables a motor

Parameters:

motor (str) – Which motor to enable, should be one of "XYZ", "E1", "E2", "E3"

Raises:
  • TypeError – motor is not str
  • ValueError – if the motor’s name is not one of "XYZ", "E1", "E2", "E3"
get_head_profile()

Gets the basic toolhead info(immutable data).

Returns:command index and dict consist of toolhead’s basic information
Return type:(int, dict)
>>> f.get_head_profile()  # no tool head connected
(0, {"module": "N/A"})
>>> f.get_head_profile()  # print head
(0, {"version": "1.0.8", "module": "EXTRUDER", "id": "203236325346430100240001", "vendor": "FLUX .inc"})
>>> f.get_head_profile()  # laser head
(0, {"version": "1.0.3", "module": "LASER", "id":"203236325346430100260004", "vendor": "FLUX .inc"})

Note

For current toolhead status use get_head_status()

get_head_status()

Gets the current toolhead status(mutable data).

Returns:dict consist of toolhead’s currrent information
Return type:dict
>>> flux.get_head_status()
{"real temp": [24.8], "target fan": [0.0], "target temp":[nan]}

Note

For basic toolhead information use get_head_profile()

set_temp(temp, index=0)

Sets the temperature of print head

Parameters:

power (number) – The power of print head, should be within [0.0, 200.0]

Raises:
  • TypeError – if temp is not a number
  • ValueError – if the temp is not in [0.0, 200.0]
  • RuntimeError – if using wrong type of toolhead
>>> f.set_temp(200)
set_fan(speed, toolhead_index=0)

Sets the speed of toolhead’s fan

Parameters:

speed (number) – The power of laser head, should be within [0.0, 1.0]

Raises:
  • TypeError – if speed is not a number
  • ValueError – if the power is not in [0.0, 1.0]
  • RuntimeError – if using wrong type of toolhead
>>> f.set_fan(0.5)
set_power(power)

Sets the power of laser toolhead

Parameters:

power (number) – The power of laser head, should be within [0.0, 1.0]

Raises:
  • TypeError – if power is not a number
  • ValueError – if the power is not in [0.0, 1.0]
  • RuntimeError – if using wrong type of toolhead
>>> f.set_power(0.5)
set_head(head_type)

Sets the tool head want to use :param str head_type: head_type, should be one of ‘EXTRUDER’, ‘LASER’, ‘N/A’

set_headerror_callback(callback_function)

Sets the callback function handling tool head error :param funciton callback_function: a callable function that take head error code as parameter

get_fsr()

Gets the current force sensor reading.

Returns:command index and dict consist of each axis’ currrent reading
Return type:(int, dict)
>>> flux.get_fsr()
(0, {'X': 3889.15, 'Y': 3958.45, 'Z': 3715.9})
get_value()

Gets some other sensor’s reading.

Returns:command index and dict consist of whether switch is triggered
Return type:(int, dict)

F0: filament sensor 0

F1: filament sensor 1

MB: Mainboard Button

>>> flux.get_value()
(0, {'F0': True, 'MB': False, 'F1': True})
close()

Disconnects from delta