-
-
Notifications
You must be signed in to change notification settings - Fork 70
/
OctoPrintOutputController.py
34 lines (28 loc) · 1.27 KB
/
OctoPrintOutputController.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Copyright (c) 2022 Aldo Hoeben / fieldOfView
# OctoPrintPlugin is released under the terms of the AGPLv3 or higher.
from cura.PrinterOutput.GenericOutputController import GenericOutputController
try:
# Cura 4.1 and newer
from cura.PrinterOutput.PrinterOutputDevice import (
PrinterOutputDevice,
ConnectionState,
)
from cura.PrinterOutput.Models.PrinterOutputModel import PrinterOutputModel
except ImportError:
# Cura 3.5 - Cura 4.0
from cura.PrinterOutputDevice import PrinterOutputDevice, ConnectionState
from cura.PrinterOutput.PrinterOutputModel import PrinterOutputModel
class OctoPrintOutputController(GenericOutputController):
def __init__(self, output_device: "PrinterOutputDevice") -> None:
super().__init__(output_device)
def moveHead(self, printer: "PrinterOutputModel", x, y, z, speed) -> None:
axis_information = self._output_device.getAxisInformation()
if axis_information["x"].inverted:
x = -x
if axis_information["y"].inverted:
y = -y
if axis_information["z"].inverted:
z = -z
self._output_device.sendCommand("G91")
self._output_device.sendCommand("G0 X%s Y%s Z%s F%s" % (x, y, z, speed))
self._output_device.sendCommand("G90")