better subclassin for Marlin. fixed missing six import for LinuxCNC

This commit is contained in:
Jesus Zen Droïd 2024-03-09 14:11:05 +01:00
parent 5692fe233c
commit ada8ebfa13
10 changed files with 485 additions and 743 deletions

View File

@ -14,6 +14,8 @@ for python.
pip install -e .
```
Make sure you set `_DEFAULT_` to the dialect you want to use in `src/pygcode/dialects/__init__.py`
# Documentation

View File

@ -60,7 +60,7 @@ __all__ = [
'GCodeCannedCycleReturnPrevLevel',
'GCodeCannedCycleReturnToR',
'GCodeCannedReturnMode',
'GCodeCoolant',
'GCodeCoolantHeaters',
'GCodeCoolantFloodOn',
'GCodeCoolantMistOn',
'GCodeCoolantOff',
@ -143,7 +143,7 @@ __all__ = [
'GCodeSetPredefinedPosition',
'GCodeSpeedAndFeedOverrideOff',
'GCodeSpeedAndFeedOverrideOn',
'GCodeSpindle',
'GCodeToolState',
'GCodeSpindleConstantSurfaceSpeedMode',
'GCodeSpindleRPMMode',
'GCodeSpindleSpeed',
@ -157,7 +157,7 @@ __all__ = [
'GCodeStraightProbe',
'GCodeThreadingCycle',
'GCodeToolChange',
'GCodeToolLength',
'GCodeToolGeometry',
'GCodeToolLengthOffset',
'GCodeToolSetCurrent',
'GCodeUnit',
@ -212,7 +212,7 @@ match get_default_dialect():
# - GCodeCannedReturnMode:
# G98 - GCodeCannedCycleReturnPrevLevel: G98: Canned Cycle Return to the level set prior to cycle start
# G99 - GCodeCannedCycleReturnToR: G99: Canned Cycle Return to the level set by R
# - GCodeCoolant:
# - GCodeCoolantHeaters:
# M08 - GCodeCoolantFloodOn: M8: turn flood coolant on
# M07 - GCodeCoolantMistOn: M7: turn mist coolant on
# M09 - GCodeCoolantOff: M9: turn all coolant off
@ -309,7 +309,7 @@ match get_default_dialect():
# M60 - GCodePalletChangePause: M60: Pallet Change Pause
# M00 - GCodePauseProgram: M0: Program Pause
# M01 - GCodePauseProgramOptional: M1: Program Pause (optional)
# - GCodeSpindle:
# - GCodeToolState:
# M19 - GCodeOrientSpindle: M19: Orient Spindle
# - GCodeSpindleSpeedMode:
# G96 - GCodeSpindleConstantSurfaceSpeedMode: G96: Spindle Constant Surface Speed
@ -318,7 +318,7 @@ match get_default_dialect():
# M04 - GCodeStartSpindleCCW: M4: Start Spindle Counter-Clockwise
# M03 - GCodeStartSpindleCW: M3: Start Spindle Clockwise
# M05 - GCodeStopSpindle: M5: Stop Spindle
# - GCodeToolLength:
# - GCodeToolGeometry:
# G43.2 - GCodeAddToolLengthOffset: G43.2: Appkly Additional Tool Length Offset
# G49 - GCodeCancelToolLengthOffset: G49: Cancel Tool Length Compensation
# G43.1 - GCodeDynamicToolLengthOffset: G43.1: Dynamic Tool Length Offset
@ -347,7 +347,7 @@ match get_default_dialect():
GCodeCannedCycleReturnPrevLevel,
GCodeCannedCycleReturnToR,
GCodeCannedReturnMode,
GCodeCoolant,
GCodeCoolantHeaters,
GCodeCoolantFloodOn,
GCodeCoolantMistOn,
GCodeCoolantOff,
@ -430,7 +430,7 @@ match get_default_dialect():
GCodeSetPredefinedPosition,
GCodeSpeedAndFeedOverrideOff,
GCodeSpeedAndFeedOverrideOn,
GCodeSpindle,
GCodeToolState,
GCodeSpindleConstantSurfaceSpeedMode,
GCodeSpindleRPMMode,
GCodeSpindleSpeed,
@ -444,7 +444,7 @@ match get_default_dialect():
GCodeStraightProbe,
GCodeThreadingCycle,
GCodeToolChange,
GCodeToolLength,
GCodeToolGeometry,
GCodeToolLengthOffset,
GCodeToolSetCurrent,
GCodeUnit,

View File

@ -1,4 +1,4 @@
# vim: ts=4, number
# vim: ts=4 number
import sys
from collections import defaultdict
from copy import copy
@ -151,7 +151,7 @@ match get_default_dialect():
case 'prusa':
from .gcodes_prusa import *
case _:
from .gcodes_legacy import *
from .gcodes_linuxcnc import *
# ======================= Utilities =======================

View File

@ -1,7 +1,20 @@
from .gcodes import MODAL_GROUP_MAP
from .words import Word, text2words
import six
"""
These class types can be used by external programs to classify the type of instructions
see class comments and marlin_gcode.py for examples.
The granularity of the class naming, while it has no functional use while parsing, can however
be useful when it will come to translating from one dialect to another.
When unsure what class a command should be a (semantic) subclass off, we try to keeps together
things that are related to each other (ie. SD card stuff)
"""
class GCode(object):
""" base gcode class ; prefer not to use it """
# Defining Word
word_key = None # Word instance to use in lookup
word_matches = None # function (secondary)
@ -254,6 +267,8 @@ class GCodeProgramName(GCodeDefinition):
# ======================= Motion =======================
class GCodeMotion(GCode):
""" any command that will move the machine and has XYZ... parameters attached
ie. the host is able to kow the machine position after such a command """
param_letters = set('XYZABCUVW')
modal_group = MODAL_GROUP_MAP['motion']
exec_order = 242
@ -315,32 +330,42 @@ class GCodeCannedCycle(GCode):
machine.move_to(**moveto_coords)
# ======================= Return Mode in Canned Cycles =======================
class GCodeCannedReturnMode(GCode):
modal_group = MODAL_GROUP_MAP['canned_cycles_return']
exec_order = 220
# ======================= Distance Mode =======================
class GCodeDistanceMode(GCode):
""" for points of reference to use, and things such as working by radius or diameter (somewhat modal) """
exec_order = 210
# ======================= Feed Rate Mode =======================
class GCodeFeedRateMode(GCode):
""" how feedrates will be interpreted """
modal_group = MODAL_GROUP_MAP['feed_rate_mode']
exec_order = 30
# ======================= Spindle Control =======================
class GCodeSpindle(GCode):
# ======================= Spindle/Tool Control =======================
class GCodeToolState(GCode):
word_letter = 'M'
exec_order = 90
# ======================= Coolant =======================
class GCodeCoolant(GCode):
# ======================= Coolant & Heaters =======================
class GCodeCoolantHeaters(GCode):
""" all cooling, heating and ventilation systems EXCEPT nozzle temperatures (see GCodeToolState) """
word_letter = 'M'
modal_group = MODAL_GROUP_MAP['coolant']
exec_order = 110
# ======================= Tool Length =======================
class GCodeToolLength(GCode):
# ======================= Tool Geometry =======================
class GCodeToolGeometry(GCode):
""" tool lengths and offsets """
modal_group = MODAL_GROUP_MAP['tool_length_offset']
exec_order = 180
@ -353,6 +378,7 @@ class GCodeProgramControl(GCode):
# ======================= Units =======================
class GCodeUnit(GCode):
""" selects a unit system (somewhat modal) """
modal_group = MODAL_GROUP_MAP['units']
exec_order = 160
@ -381,21 +407,17 @@ class GCodePlaneSelect(GCode):
normal = None # Vector3
# ======================= Cutter Radius Compensation =======================
class GCodeCutterRadiusComp(GCode):
class GCodeCutterRadiusComp(GCodeToolGeometry):
modal_group = MODAL_GROUP_MAP['cutter_diameter_comp']
exec_order = 170
# ======================= Path Control Mode =======================
class GCodePathControlMode(GCode):
""" codes that will affect the path and motion either by allowing greater deviation
from the theoretical path or by inducing greater deviation (includes acceleration and jerk)"""
modal_group = MODAL_GROUP_MAP['control_mode']
exec_order = 200
# ======================= Return Mode in Canned Cycles =======================
class GCodeCannedReturnMode(GCode):
modal_group = MODAL_GROUP_MAP['canned_cycles_return']
exec_order = 220
# ======================= Other Modal Codes =======================
class GCodeOtherModal(GCode):
pass
@ -410,6 +432,7 @@ class GCodeSelectCoordinateSystem(GCodeOtherModal):
# ======================= Flow-control Codes =======================
class GCodeIO(GCode):
""" pretty much anything that reads and writes on digital pins and not related to motion and temperatures """
word_letter = 'M'
exec_order = 70
@ -424,3 +447,18 @@ class GCodeNonModal(GCode):
pass
# ======================= Machine Configuration and Calibration Codes =======================
class GCodeMachineRoutines(GCode):
""" standard routines that WILL induce movement such as homing, tool changes.. """
class GCodeAssistedRoutines(GCodeMachineRoutines):
""" machine routines that require user intervention """
class GCodeCalibrationRoutines(GCode):
""" machine routines that are used for calibration purposes """
class GCodeMachineConfig(GCode):
""" configuration parameters that will not significantly alter the machine behaviour """
class GCodeMachineState(GCode):
""" mostly for commands that report the machine state to the host """

View File

@ -237,7 +237,7 @@ class GCodeUnitsPerRevolution(GCodeFeedRateMode):
# M19 Orient Spindle
# G96, G97 S D Spindle Control Mode
class GCodeStartSpindle(GCodeSpindle):
class GCodeStartSpindle(GCodeToolState):
"""M3,M4: Start Spindle Clockwise"""
modal_group = MODAL_GROUP_MAP['spindle']
@ -253,19 +253,19 @@ class GCodeStartSpindleCCW(GCodeStartSpindle):
word_key = Word('M', 4)
class GCodeStopSpindle(GCodeSpindle):
class GCodeStopSpindle(GCodeToolState):
"""M5: Stop Spindle"""
#param_letters = set('S') # S is it's own gcode, makes no sense to be here
word_key = Word('M', 5)
modal_group = MODAL_GROUP_MAP['spindle']
class GCodeOrientSpindle(GCodeSpindle):
class GCodeOrientSpindle(GCodeToolState):
"""M19: Orient Spindle"""
word_key = Word('M', 19)
class GCodeSpindleSpeedMode(GCodeSpindle):
class GCodeSpindleSpeedMode(GCodeToolState):
word_letter = 'G'
modal_group = MODAL_GROUP_MAP['spindle_speed_mode']
@ -287,17 +287,17 @@ class GCodeSpindleRPMMode(GCodeSpindleSpeedMode):
# CODE PARAMETERS DESCRIPTION
# M7, M8, M9 Coolant Control
class GCodeCoolantMistOn(GCodeCoolant):
class GCodeCoolantMistOn(GCodeCoolantHeaters):
"""M7: turn mist coolant on"""
word_key = Word('M', 7)
class GCodeCoolantFloodOn(GCodeCoolant):
class GCodeCoolantFloodOn(GCodeCoolantHeaters):
"""M8: turn flood coolant on"""
word_key = Word('M', 8)
class GCodeCoolantOff(GCodeCoolant):
class GCodeCoolantOff(GCodeCoolantHeaters):
"""M9: turn all coolant off"""
word_key = Word('M', 9)
@ -309,24 +309,24 @@ class GCodeCoolantOff(GCodeCoolant):
# G43.2 H Apply additional Tool Length Offset
# G49 Cancel Tool Length Compensation
class GCodeToolLengthOffset(GCodeToolLength):
class GCodeToolLengthOffset(GCodeToolGeometry):
"""G43: Tool Length Offset"""
param_letters = set('H')
word_key = Word('G', 43)
class GCodeDynamicToolLengthOffset(GCodeToolLength):
class GCodeDynamicToolLengthOffset(GCodeToolGeometry):
"""G43.1: Dynamic Tool Length Offset"""
word_key = Word('G', 43.1)
class GCodeAddToolLengthOffset(GCodeToolLength):
class GCodeAddToolLengthOffset(GCodeToolGeometry):
"""G43.2: Appkly Additional Tool Length Offset"""
param_letters = set('H')
word_key = Word('G', 43.2)
class GCodeCancelToolLengthOffset(GCodeToolLength):
class GCodeCancelToolLengthOffset(GCodeToolGeometry):
"""G49: Cancel Tool Length Compensation"""
word_key = Word('G', 49)

View File

@ -1,137 +1,70 @@
100,104c100,104
< class GCodeBedLevelingPointg1(GCodeMotion):
86,89c86,89
< class GCodeBedLeveling3Pointg1(GCodeMachineRoutines):
< """G29: Probe the bed and enable leveling compensation."""
< param_letters = "ACOQEDJV"
< dialects = ['marlin2']
< word_key = Word('G', 29)
---
> #class GCodeBedLevelingPointg1(GCodeMotion):
> #class GCodeBedLeveling3Pointg1(GCodeMachineRoutines):
> # """G29: Probe the bed and enable leveling compensation."""
> # param_letters = "ACOQEDJV"
> # dialects = ['marlin2']
> # word_key = Word('G', 29)
112,134c112,134
< class GCodeBedLevelingLinearg2(GCodeMotion):
96,109c96,109
< class GCodeBedLevelingLinearg2(GCodeMachineRoutines):
< """G29: Probe the bed and enable leveling compensation."""
< param_letters = "ACOQXYPSEDTHFBLRJV"
< dialects = ['marlin2']
< word_key = Word('G', 29)
<
< class GCodeBedLevelingManualm1(GCodeMotion):
< class GCodeBedLevelingManualm1(GCodeMachineRoutines):
< """G29: Measure Z heights in a grid, enable leveling compensation"""
< param_letters = "SIJXYZ"
< dialects = ['marlin2']
< word_key = Word('G', 29)
<
< class GCodeBedLeveling(GCodeMotion):
< class GCodeBedLeveling(GCodeMachineRoutines):
< """G29: Probe the bed and enable leveling compensation"""
< param_letters = ""
< dialects = ['marlin2']
< word_key = Word('G', 29)
<
< class GCodeBedLevelingUnifiedm3(GCodeMotion):
< """G29: Probe the bed and enable leveling compensation."""
< param_letters = "ABCDEFHIJKLPQRSTUVWXY"
< dialects = ['marlin2']
< word_key = Word('G', 29)
---
> #class GCodeBedLevelingLinearg2(GCodeMotion):
> #class GCodeBedLevelingLinearg2(GCodeMachineRoutines):
> # """G29: Probe the bed and enable leveling compensation."""
> # param_letters = "ACOQXYPSEDTHFBLRJV"
> # dialects = ['marlin2']
> # word_key = Word('G', 29)
>
> #class GCodeBedLevelingManualm1(GCodeMotion):
> #class GCodeBedLevelingManualm1(GCodeMachineRoutines):
> # """G29: Measure Z heights in a grid, enable leveling compensation"""
> # param_letters = "SIJXYZ"
> # dialects = ['marlin2']
> # word_key = Word('G', 29)
>
> #class GCodeBedLeveling(GCodeMotion):
> #class GCodeBedLeveling(GCodeMachineRoutines):
> # """G29: Probe the bed and enable leveling compensation"""
> # param_letters = ""
> # dialects = ['marlin2']
> # word_key = Word('G', 29)
>
> #class GCodeBedLevelingUnifiedm3(GCodeMotion):
> # """G29: Probe the bed and enable leveling compensation."""
> # param_letters = "ABCDEFHIJKLPQRSTUVWXY"
> # dialects = ['marlin2']
> # word_key = Word('G', 29)
160,164c160,164
< class GCodeMechanicalGantryCalibrationb(GCodeMotion):
136,139c136,139
< class GCodeMechanicalGantryCalibrationb(GCodeMachineRoutines):
< """G34: Modern replacement for Průša's TMC_Z_CALIBRATION"""
< param_letters = "SZ"
< dialects = ['marlin2']
< word_key = Word('G', 34)
---
> #class GCodeMechanicalGantryCalibrationb(GCodeMotion):
> #class GCodeMechanicalGantryCalibrationb(GCodeMachineRoutines):
> # """G34: Modern replacement for Průša's TMC_Z_CALIBRATION"""
> # param_letters = "SZ"
> # dialects = ['marlin2']
> # word_key = Word('G', 34)
425,432c425,426
< """M43: Get information about pins."""
< param_letters = "PWETSI"
< dialects = ['marlin2']
< word_key = Word('M', 43)
<
< class GCodeTogglePinsb(GCodeDigitalOutput):
< """M43T: Get information about pins."""
< param_letters = "SLIRW"
---
> """M43: Get information about pins / set pins"""
> param_letters = "PWETSIRL"
652c646
< class GCodeBaricudaOpen(GCodeDigitalOutput):
---
> class GCodeBaricuda1Open(GCodeDigitalOutput):
658c652
< class GCodeBaricudaClose(GCodeDigitalOutput):
---
> class GCodeBaricuda1Close(GCodeDigitalOutput):
664,665c658
< # TODO: duplicate class name BaricudaOpen
< class GCodeBaricudaOpen(GCodeDigitalOutput):
---
> class GCodeBaricuda2Open(GCodeDigitalOutput):
671,672c664
< # TODO: duplicate class name BaricudaClose
< class GCodeBaricudaClose(GCodeDigitalOutput):
---
> class GCodeBaricuda2Close(GCodeDigitalOutput):
768,769c760
< # TODO: duplicate class name SetLaserCoolerTemperature
< class GCodeSetLaserCoolerTemperature(GCodeCoolant):
---
> class GCodeWaitForLaserCoolerTemperature(GCodeCoolant):
775c766
< class GCodeSetFilamentDiameter(GCodeOtherModal):
---
> class GCodeSetFilamentDiameterVolumetric(GCodeOtherModal):
1051d1041
< # TODO: duplicate class name SetFilamentDiameter
1250,1254c1240,1244
< class GCodeDeltaConfiguration(GCodeOtherModal):
1045,1048c1045,1048
< class GCodeDeltaConfiguration(GCodeMachineConfig):
< """M665: Set delta geometry values"""
< param_letters = "HLRSXYZABC"
< dialects = ['marlin2']
< word_key = Word('M', 665)
---
> #class GCodeDeltaConfiguration(GCodeOtherModal):
> #class GCodeDeltaConfiguration(GCodeMachineConfig):
> # """M665: Set delta geometry values"""
> # param_letters = "HLRSXYZABC"
> # dialects = ['marlin2']
> # word_key = Word('M', 665)
1268,1272c1258,1262
< class GCodeSetDeltaEndstopAdjustmentsa(GCodeOtherModal):
1060,1063c1060,1063
< class GCodeSetDeltaEndstopAdjustmentsa(GCodeMachineConfig):
< """M666: Set Delta endstop adjustments"""
< param_letters = "XYZ"
< dialects = ['marlin2']
< word_key = Word('M', 666)
---
> #class GCodeSetDeltaEndstopAdjustmentsa(GCodeOtherModal):
> #class GCodeSetDeltaEndstopAdjustmentsa(GCodeMachineConfig):
> # """M666: Set Delta endstop adjustments"""
> # param_letters = "XYZ"
> # dialects = ['marlin2']
> # word_key = Word('M', 666)

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
from .gcodes_base import *
from .gcodes_legacy import *
from .gcodes_linuxcnc import *
# ======================= Prusa =======================
# CODE PARAMETERS DESCRIPTION

View File

@ -27,7 +27,7 @@ match get_default_dialect():
GCodeMillimeterUnits as GCodeUseMillimeters,
)
case _:
from .gcodes_legacy import (
from .gcodes_linuxcnc import (
GCodeIncrementalDistanceMode,
GCodeUseInches, GCodeUseMillimeters,
)

View File

@ -10,50 +10,50 @@ class_types = {
# unused: GCodePathControlMode
# unused: GCodeProgramControl
'g000': 'GCodeMotion', # LinearMove
'g002': 'GCodeArcMove', # ArcOrCircleMove
'g002': 'GCodeArcMove', # GCodeMotion > ArcOrCircleMove
'g004': 'GCode', # Dwell
'g005': 'GCodeMotion', # BzierCubicSpline
'g005': 'GCodeMotion', # BezierCubicSpline
'g006': 'GCodeMotion', # DirectStepperMove
'g010': 'GCode', # Retract
'g011': 'GCode', # Recover
'g012': 'GCodeMotion', # CleanTheNozzle
'g010': 'GCodeMachineRoutines', # Retract
'g011': 'GCodeMachineRoutines', # Recover
'g012': 'GCodeMachineRoutines', # CleanTheNozzle
'g017': 'GCodePlaneSelect', # CncWorkspacePlanes
'g020': 'GCodeUnit', # InchUnits
'g021': 'GCodeUnit', # MillimeterUnits
'g026': 'GCodeMotion', # MeshValidationPattern
'g027': 'GCodeMotion', # ParkToolhead
'g028': 'GCodeMotion', # AutoHome
'g029': 'GCodeMotion', # BedLeveling
'g029g1': 'GCodeMotion', # BedLevelingPoint
'g029m2': 'GCodeMotion', # BedLevelingBilinear
'g029g2': 'GCodeMotion', # BedLevelingLinear
'g029m1': 'GCodeMotion', # BedLevelingManual
'g029m3': 'GCodeMotion', # BedLevelingUnified
'g030': 'GCodeMotion', # SingleZProbe
'g031': 'GCodeMotion', # DockSled
'g032': 'GCodeMotion', # UndockSled
'g033': 'GCodeMotion', # DeltaAutoCalibration
'g034b': 'GCodeMotion', # MechanicalGantryCalibration
'g034a': 'GCodeMotion', # ZSteppersAutoAlignment
'g035': 'GCodeMotion', # TrammingAssistant
'g038': 'GCodeMotion', # ProbeTarget
'g042': 'GCodeSelectCoordinateSystem', # MoveToMeshCoordinate
'g053': 'GCodeSelectCoordinateSystem', # MoveInMachineCoordinates
'g026': 'GCodeAssistedRoutines', # MeshValidationPattern
'g027': 'GCodeMachineRoutines', # ParkToolhead
'g028': 'GCodeMachineRoutines', # AutoHome
'g029': 'GCodeMachineRoutines', # BedLeveling
'g029g1': 'GCodeMachineRoutines', # BedLevelingPoint
'g029m2': 'GCodeMachineRoutines', # BedLevelingBilinear
'g029g2': 'GCodeMachineRoutines', # BedLevelingLinear
'g029m1': 'GCodeMachineRoutines', # BedLevelingManual
'g029m3': 'GCodeMachineRoutines', # BedLevelingUnified
'g030': 'GCodeMachineRoutines', # SingleZProbe
'g031': 'GCodeMachineRoutines', # DockSled
'g032': 'GCodeMachineRoutines', # UndockSled
'g033': 'GCodeMachineRoutines', # DeltaAutoCalibration
'g034b': 'GCodeMachineRoutines', # MechanicalGantryCalibration
'g034a': 'GCodeMachineRoutines', # ZSteppersAutoAlignment
'g035': 'GCodeAssistedRoutines', # TrammingAssistant
'g038': 'GCodeMachineRoutines', # ProbeTarget
'g042': 'GCodeMotion', # MoveToMeshCoordinate
'g053': 'GCodeMotion', # MoveInMachineCoordinates
'g054': 'GCodeSelectCoordinateSystem', # WorkspaceCoordinateSystem
'g060': 'GCode', # SaveCurrentPosition
'g060': 'GCodeOtherModal', # SaveCurrentPosition
'g061': 'GCodeMotion', # ReturnToSavedPosition
'g076': 'GCodeOtherModal', # ProbeTemperatureCalibration
'g080': 'GCode', # CancelCurrentMotionMode
'g076': 'GCodeMachineRoutines', # ProbeTemperatureCalibration
'g080': 'GCodeOtherModal', # CancelCurrentMotionMode
'g090': 'GCodeOtherModal', # AbsolutePositioning
'g091': 'GCodeOtherModal', # RelativePositioning
'g092': 'GCodeOtherModal', # SetPosition
'g425': 'GCodeOtherModal', # BacklashCalibration
'm0000': 'GCodeOtherModal', # UnconditionalStop
'm0003': 'GCodeSpindle', # SpindleCwLaserOn
'm0004': 'GCodeSpindle', # SpindleCcwLaserOn
'm0005': 'GCodeSpindle', # SpindleLaserOff
'm0007': 'GCodeCoolant', # CoolantControls
'm0010': 'GCodeDigitalOutput', # VacuumBlowerControl
'g425': 'GCodeMachineRoutines', # BacklashCalibration
'm0000': 'GCodeProgramControl', # UnconditionalStop
'm0003': 'GCodeToolState', # SpindleCwLaserOn
'm0004': 'GCodeToolState', # SpindleCcwLaserOn
'm0005': 'GCodeToolState', # SpindleLaserOff
'm0007': 'GCodeCoolantHeaters', # CoolantControls
'm0010': 'GCodeIO', # VacuumBlowerControl
'm0016': 'GCodeOtherModal', # ExpectedPrinterCheck
'm0017': 'GCodeOtherModal', # EnableSteppers
'm0018': 'GCodeOtherModal', # DisableSteppers
@ -61,26 +61,26 @@ class_types = {
'm0021': 'GCodeIO', # InitSdCard
'm0022': 'GCodeIO', # ReleaseSdCard
'm0023': 'GCodeIO', # SelectSdFile
'm0024': 'GCodeOtherModal', # StartOrResumeSdPrint
'm0025': 'GCodeOtherModal', # PauseSdPrint
'm0026': 'GCodeIO', # SetSdPosition
'm0027': 'GCodeNonModal', # ReportSdPrintStatus
'm0024': 'GCodeProgramControl', # StartOrResumeSdPrint
'm0025': 'GCodeProgramControl', # PauseSdPrint
'm0026': 'GCodeProgramControl', # SetSdPosition
'm0027': 'GCodeMachineState', # ReportSdPrintStatus
'm0028': 'GCodeIO', # StartSdWrite
'm0029': 'GCodeIO', # StopSdWrite
'm0030': 'GCodeIO', # DeleteSdFile
'm0031': 'GCode', # PrintTime
'm0032': 'GCodeIO', # SelectAndStart
'm0031': 'GCodeMachineState', # ReportPrintTime
'm0032': 'GCodeProgramControl', # SelectAndStart
'm0033': 'GCodeIO', # GetLongPath
'm0034': 'GCodeIO', # SdcardSorting
'm0042': 'GCodeDigitalOutput', # SetPinState
'm0042': 'GCodeIO', # SetPinState
'm0043': 'GCodeIO', # DebugPins
'm0043b': 'GCodeDigitalOutput', # TogglePins
'm0048': 'GCodeMotion', # ProbeRepeatabilityTest
'm0073': 'GCode', # SetPrintProgress
'm0075': 'GCodeOtherModal', # StartPrintJobTimer
'm0076': 'GCodeOtherModal', # PausePrintJobTimer
'm0077': 'GCodeOtherModal', # StopPrintJobTimer
'm0078': 'GCode', # PrintJobStats
'm0043b': 'GCodeIO', # TogglePins
'm0048': 'GCodeMachineRoutines', # ProbeRepeatabilityTest
'm0073': 'GCodeNonModal', # SetPrintProgress
'm0075': 'GCodeProgramControl', # StartPrintJobTimer
'm0076': 'GCodeProgramControl', # PausePrintJobTimer
'm0077': 'GCodeProgramControl', # StopPrintJobTimer
'm0078': 'GCodeMachineState', # PrintJobStats
'm0080': 'GCodeOtherModal', # PowerOn
'm0081': 'GCodeOtherModal', # PowerOff
'm0082': 'GCodeOtherModal', # EAbsolute
@ -88,168 +88,168 @@ class_types = {
'm0085': 'GCodeOtherModal', # InactivityShutdown
'm0086': 'GCodeOtherModal', # HotendIdleTimeout
'm0087': 'GCodeOtherModal', # DisableHotendIdleTimeout
'm0092': 'GCodeUnit', # SetAxisStepsPerUnit
'm0100': 'GCodeNonModal', # FreeMemory
'm0102': 'GCodeOtherModal', # ConfigureBedDistanceSensor
'm0104': 'GCodeOtherModal', # SetHotendTemperature
'm0105': 'GCodeNonModal', # ReportTemperatures
'm0106': 'GCodeDigitalOutput', # SetFanSpeed
'm0107': 'GCodeDigitalOutput', # FanOff
'm0108': 'GCodeOtherModal', # BreakAndContinue
'm0109': 'GCode', # WaitForHotendTemperature
'm0092': 'GCodeOtherModal', # SetAxisStepsPerUnit
'm0100': 'GCodeMachineState', # FreeMemory
'm0102': 'GCodeMachineRoutines', # ConfigureBedDistanceSensor
'm0104': 'GCodeToolState', # SetHotendTemperature
'm0105': 'GCodeMachineState', # ReportTemperatures
'm0106': 'GCodeCoolantHeaters', # SetFanSpeed
'm0107': 'GCodeCoolantHeaters', # FanOff
'm0108': 'GCodeProgramControl', # BreakAndContinue
'm0109': 'GCodeToolState', # WaitForHotendTemperature
'm0110': 'GCodeOtherModal', # SetLineNumber
'm0111': 'GCodeOtherModal', # DebugLevel
'm0112': 'GCodeOtherModal', # FullShutdown
'm0113': 'GCode', # HostKeepalive
'm0114': 'GCodeNonModal', # GetCurrentPosition
'm0115': 'GCodeNonModal', # FirmwareInfo
'm0117': 'GCodeIO', # SetLcdMessage
'm0118': 'GCodeIO', # SerialPrint
'm0119': 'GCodeIO', # EndstopStates
'm0120': 'GCodeIO', # EnableEndstops
'm0121': 'GCodeIO', # DisableEndstops
'm0122': 'GCodeIO', # TmcDebugging
'm0123': 'GCodeIO', # FanTachometers
'm0125': 'GCodeMotion', # ParkHead
'm0126': 'GCodeDigitalOutput', # BaricudaOpen
'm0127': 'GCodeDigitalOutput', # BaricudaClose
'm0128': 'GCodeDigitalOutput', # BaricudaOpen
'm0129': 'GCodeDigitalOutput', # BaricudaClose
'm0140': 'GCodeOtherModal', # SetBedTemperature
'm0141': 'GCodeOtherModal', # SetChamberTemperature
'm0143': 'GCodeCoolant', # SetLaserCoolerTemperature
'm0145': 'GCodeOtherModal', # SetMaterialPreset
'm0113': 'GCodeMachineState', # HostKeepalive
'm0114': 'GCodeMachineState', # GetCurrentPosition
'm0115': 'GCodeMachineState', # FirmwareInfo
'm0117': 'GCodeMachineState', # SetLcdMessage
'm0118': 'GCodeMachineState', # SerialPrint
'm0119': 'GCodeMachineState', # EndstopStates
'm0120': 'GCodeOtherModal', # EnableEndstops
'm0121': 'GCodeOtherModal', # DisableEndstops
'm0122': 'GCodeMachineState', # TmcDebugging
'm0123': 'GCodeMachineState', # FanTachometers
'm0125': 'GCodeMachineRoutines', # ParkHead
'm0126': 'GCodeDigitalOutput', # Baricuda1Open
'm0127': 'GCodeDigitalOutput', # Baricuda1Close
'm0128': 'GCodeDigitalOutput', # Baricuda2Open
'm0129': 'GCodeDigitalOutput', # Baricuda2Close
'm0140': 'GCodeCoolantHeaters', # SetBedTemperature
'm0141': 'GCodeCoolantHeaters', # SetChamberTemperature
'm0143': 'GCodeCoolantHeaters', # SetLaserCoolerTemperature
'm0145': 'GCodeNonModal', # SetMaterialPreset
'm0149': 'GCodeUnit', # SetTemperatureUnits
'm0150': 'GCodeDigitalOutput', # SetRgbWColor
'm0154': 'GCodeNonModal', # PositionAutoReport
'm0155': 'GCodeNonModal', # TemperatureAutoReport
'm0155': 'GCodeMachineState', # TemperatureAutoReport
'm0163': 'GCodeOtherModal', # SetMixFactor
'm0164': 'GCodeOtherModal', # SaveMix
'm0165': 'GCodeOtherModal', # SetMix
'm0166': 'GCodeOtherModal', # GradientMix
'm0190': 'GCode', # WaitForBedTemperature
'm0191': 'GCode', # WaitForChamberTemperature
'm0192': 'GCode', # WaitForProbeTemperature
'm0193': 'GCodeCoolant', # SetLaserCoolerTemperature
'm0190': 'GCodeCoolantHeaters', # WaitForBedTemperature
'm0191': 'GCodeCoolantHeaters', # WaitForChamberTemperature
'm0192': 'GCodeToolState', # WaitForProbeTemperature
'm0193': 'GCodeCoolantHeaters', # SetLaserCoolerTemperature
'm0200': 'GCodeOtherModal', # SetFilamentDiameter
'm0201': 'GCodeNonModal', # PrintTravelMoveLimits
'm0203': 'GCodeFeedRateMode', # SetMaxFeedrate
'm0204': 'GCodeOtherModal', # SetStartingAcceleration
'm0205': 'GCodeOtherModal', # SetAdvancedSettings
'm0206': 'GCodeOtherModal', # SetHomeOffsets
'm0207': 'GCodeOtherModal', # SetFirmwareRetraction
'm0208': 'GCodeOtherModal', # FirmwareRecover
'm0209': 'GCodeOtherModal', # SetAutoRetract
'm0201': 'GCodePathControlMode', # PrintTravelMoveLimits
'm0203': 'GCodePathControlMode', # SetMaxFeedrate
'm0204': 'GCodePathControlMode', # SetStartingAcceleration
'm0205': 'GCodePathControlMode', # SetAdvancedSettings
'm0206': 'GCodeMachineConfig', # SetHomeOffsets
'm0207': 'GCodeMachineConfig', # FirmwareRetractionSettings
'm0208': 'GCodeMachineConfig', # FirmwareRecoverSettings
'm0209': 'GCodeMachineConfig', # SetAutoRetract
'm0211': 'GCodeOtherModal', # SoftwareEndstops
'm0217': 'GCodeOtherModal', # FilamentSwapParameters
'm0218': 'GCodeOtherModal', # SetHotendOffset
'm0217': 'GCodeMachineConfig', # FilamentSwapParameters
'm0218': 'GCodeToolGeometry', # SetHotendOffset
'm0220': 'GCodeFeedRateMode', # SetFeedratePercentage
'm0221': 'GCodeOtherModal', # SetFlowPercentage
'm0221': 'GCodeFeedRateMode', # SetFlowPercentage
'm0226': 'GCodeIO', # WaitForPinState
'm0240': 'GCodeIO', # TriggerCamera
'm0250': 'GCodeIO', # LcdContrast
'm0255': 'GCodeIO', # LcdSleepBacklightTimeout
'm0256': 'GCodeIO', # LcdBrightness
'm0260': 'GCodeDigitalOutput', # ICSend
'm0261': 'GCodeIO', # ICRequest
'm0240': 'GCodeDigitalOutput', # TriggerCamera
'm0250': 'GCodeDigitalOutput', # LcdContrast
'm0255': 'GCodeDigitalOutput', # LcdSleepBacklightTimeout
'm0256': 'GCodeDigitalOutput', # LcdBrightness
'm0260': 'GCodeIO', # I2CSend
'm0261': 'GCodeIO', # I2CRequest
'm0280': 'GCodeIO', # ServoPosition
'm0281': 'GCodeOtherModal', # EditServoAngles
'm0282': 'GCodeOtherModal', # DetachServo
'm0281': 'GCodeIO', # EditServoAngles
'm0282': 'GCodeIO', # DetachServo
'm0290': 'GCodeMotion', # Babystep
'm0300': 'GCodeDigitalOutput', # PlayTone
'm0301': 'GCodeOtherModal', # SetHotendPid
'm0301': 'GCodeMachineConfig', # SetHotendPid
'm0302': 'GCodeOtherModal', # ColdExtrude
'm0303': 'GCodeOtherModal', # PidAutotune
'm0304': 'GCodeOtherModal', # SetBedPid
'm0305': 'GCodeOtherModal', # UserThermistorParameters
'm0306': 'GCodeOtherModal', # ModelPredictiveTempControl
'm0350': 'GCodeOtherModal', # SetMicroStepping
'm0351': 'GCodeOtherModal', # SetMicrostepPins
'm0303': 'GCodeCalibrationRoutines', # PidAutotune
'm0304': 'GCodeMachineConfig', # SetBedPid
'm0305': 'GCodeMachineConfig', # UserThermistorParameters
'm0306': 'GCodeMachineConfig', # ModelPredictiveTempControl
'm0350': 'GCodeMachineConfig', # SetMicroStepping
'm0351': 'GCodeMachineConfig', # SetMicrostepPins
'm0355': 'GCodeDigitalOutput', # CaseLightControl
'm0360': 'GCodeMotion', # ScaraThetaA
'm0361': 'GCodeMotion', # ScaraThetaB
'm0362': 'GCodeMotion', # ScaraPsiA
'm0363': 'GCodeMotion', # ScaraPsiB
'm0364': 'GCodeMotion', # ScaraPsiC
'm0360': 'GCodeCalibrationRoutines', # ScaraThetaA
'm0361': 'GCodeCalibrationRoutines', # ScaraThetaB
'm0362': 'GCodeCalibrationRoutines', # ScaraPsiA
'm0363': 'GCodeCalibrationRoutines', # ScaraPsiB
'm0364': 'GCodeCalibrationRoutines', # ScaraPsiC
'm0380': 'GCodeDigitalOutput', # ActivateSolenoid
'm0381': 'GCodeDigitalOutput', # DeactivateSolenoids
'm0400': 'GCodeOtherModal', # FinishMoves
'm0400': 'GCodeNonModal', # FinishMoves
'm0401': 'GCodeDigitalOutput', # DeployProbe
'm0402': 'GCodeDigitalOutput', # StowProbe
'm0403': 'GCodeOtherModal', # MmuFilamentType
'm0404': 'GCodeOtherModal', # SetFilamentDiameter
'm0405': 'GCodeOtherModal', # FilamentWidthSensorOn
'm0406': 'GCodeOtherModal', # FilamentWidthSensorOff
'm0407': 'GCodeNonModal', # FilamentWidth
'm0410': 'GCodeOtherModal', # Quickstop
'm0412': 'GCodeOtherModal', # FilamentRunout
'm0413': 'GCodeOtherModal', # PowerLossRecovery
'm0420': 'GCodeNonModal', # BedLevelingState
'm0421': 'GCodeOtherModal', # SetMeshValue
'm0422': 'GCodeOtherModal', # SetZMotorXy
'm0423': 'GCodeOtherModal', # XTwistCompensation
'm0425': 'GCodeOtherModal', # BacklashCompensation
'm0428': 'GCodeOtherModal', # HomeOffsetsHere
'm0430': 'GCodeOtherModal', # PowerMonitor
'm0486': 'GCodeOtherModal', # CancelObjects
'm0493': 'GCodeOtherModal', # FixedTimeMotion
'm0500': 'GCodeNonModal', # SaveSettings
'm0501': 'GCodeOtherModal', # RestoreSettings
'm0502': 'GCodeOtherModal', # FactoryReset
'm0503': 'GCodeNonModal', # ReportSettings
'm0403': 'GCodeMachineConfig', # Mmu2FilamentType
'm0404': 'GCodeMachineConfig', # SetFilamentDiameter
'm0405': 'GCodeMachineConfig', # FilamentWidthSensorOn
'm0406': 'GCodeMachineConfig', # FilamentWidthSensorOff
'm0407': 'GCodeMachineConfig', # FilamentWidth
'm0410': 'GCodeProgramControl', # Quickstop
'm0412': 'GCodeMachineConfig', # FilamentRunout
'm0413': 'GCodeMachineConfig', # PowerLossRecovery
'm0420': 'GCodeMachineConfig', # BedLevelingState
'm0421': 'GCodeMachineConfig', # SetMeshValue
'm0422': 'GCodeMachineConfig', # SetZMotorXy
'm0423': 'GCodeMachineConfig', # XTwistCompensation
'm0425': 'GCodeMachineConfig', # BacklashCompensation
'm0428': 'GCodeMachineConfig', # HomeOffsetsHere
'm0430': 'GCodeNonModal', # PowerMonitor
'm0486': 'GCodeProgramControl', # CancelObjects
'm0493': 'GCodePathControlMode', # FixedTimeMotion
'm0500': 'GCodeMachineConfig', # SaveSettings
'm0501': 'GCodeMachineConfig', # RestoreSettings
'm0502': 'GCodeMachineConfig', # FactoryReset
'm0503': 'GCodeMachineConfig', # ReportSettings
'm0504': 'GCodeNonModal', # ValidateEepromContents
'm0510': 'GCodeOtherModal', # LockMachine
'm0511': 'GCodeOtherModal', # UnlockMachine
'm0512': 'GCodeNonModal', # SetPasscode
'm0524': 'GCodeOtherModal', # AbortSdPrint
'm0540': 'GCodeNonModal', # EndstopsAbortSd
'm0569': 'GCodeOtherModal', # SetTmcSteppingMode
'm0575': 'GCodeOtherModal', # SerialBaudRate
'm0592': 'GCodeOtherModal', # NonlinearExtrusionControl
'm0593': 'GCodeOtherModal', # ZvInputShaping
'm0600': 'GCode', # FilamentChange
'm0603': 'GCodeOtherModal', # ConfigureFilamentChange
'm0605': 'GCodeOtherModal', # MultiNozzleMode
'm0665': 'GCodeOtherModal', # DeltaConfiguration
'm0665b': 'GCodeOtherModal', # ScaraConfiguration
'm0666b': 'GCodeOtherModal', # SetDualEndstopOffsets
'm0666a': 'GCodeOtherModal', # SetDeltaEndstopAdjustments
'm0672': 'GCodeOtherModal', # DuetSmartEffectorSensitivity
'm0701': 'GCodeOtherModal', # LoadFilament
'm0702': 'GCodeOtherModal', # UnloadFilament
'm0710': 'GCodeOtherModal', # ControllerFanSettings
'm7219': 'GCodeDigitalOutput', # MaxControl
'm0808': 'GCodeOtherModal', # RepeatMarker
'm0810': 'GCodeOtherModal', # GCodeMacros
'm0851': 'GCodeOtherModal', # XyzProbeOffset
'm0852': 'GCodeOtherModal', # BedSkewCompensation
'm0860': 'GCodeOtherModal', # ICPositionEncoders
'm0871': 'GCodeOtherModal', # ProbeTemperatureConfig
'm0876': 'GCode', # HandlePromptResponse
'm0900': 'GCodeOtherModal', # LinearAdvanceFactor
'm0906': 'GCodeOtherModal', # StepperMotorCurrent
'm0907': 'GCodeOtherModal', # SetMotorCurrent
'm0908': 'GCodeOtherModal', # SetTrimpotPins
'm0909': 'GCodeNonModal', # DacPrintValues
'm0910': 'GCodeNonModal', # CommitDacToEeprom
'm0911': 'GCode', # TmcOtPreWarnCondition
'm0912': 'GCode', # ClearTmcOtPreWarn
'm0913': 'GCodeOtherModal', # SetHybridThresholdSpeed
'm0914': 'GCodeOtherModal', # TmcBumpSensitivity
'm0915': 'GCode', # TmcZAxisCalibration
'm0916': 'GCode', # LThermalWarningTest
'm0917': 'GCode', # LOvercurrentWarningTest
'm0918': 'GCode', # LSpeedWarningTest
'm0919': 'GCodeOtherModal', # TmcChopperTiming
'm0512': 'GCodeMachineConfig', # SetPasscode
'm0524': 'GCodeProgramControl', # AbortSdPrint
'm0540': 'GCodeMachineConfig', # EndstopsAbortSd
'm0569': 'GCodeMachineConfig', # SetTmcSteppingMode
'm0575': 'GCodeMachineConfig', # SerialBaudRate
'm0592': 'GCodeMachineConfig', # NonlinearExtrusionControl
'm0593': 'GCodeCalibrationRoutines', # ZvInputShaping
'm0600': 'GCodeMachineRoutines', # FilamentChange
'm0603': 'GCodeMachineConfig', # ConfigureFilamentChange
'm0605': 'GCodeMachineConfig', # MultiNozzleMode
'm0665': 'GCodeMachineConfig', # DeltaConfiguration
'm0665b': 'GCodeMachineConfig', # ScaraConfiguration
'm0666b': 'GCodeMachineConfig', # SetDualEndstopOffsets
'm0666a': 'GCodeMachineConfig', # SetDeltaEndstopAdjustments
'm0672': 'GCodeMachineConfig', # DuetSmartEffectorSensitivity
'm0701': 'GCodeMachineRoutines', # LoadFilament
'm0702': 'GCodeMachineRoutines', # UnloadFilament
'm0710': 'GCodeMachineConfig', # ControllerFanSettings
'm7219': 'GCodeDigitalOutput', # MAX7219Control
'm0808': 'GCodeProgramControl', # RepeatMarker
'm0810': 'GCodeProgramControl', # GCodeMacros
'm0851': 'GCodeToolGeometry', # XyzProbeOffset
'm0852': 'GCodeMachineConfig', # BedSkewCompensation
'm0860': 'GCodeMachineConfig', # I2CPositionEncoders
'm0871': 'GCodeMachineConfig', # ProbeTemperatureConfig
'm0876': 'GCodeMachineConfig', # HandlePromptResponse
'm0900': 'GCodeMachineConfig', # LinearAdvanceFactor
'm0906': 'GCodeMachineConfig', # TrinamicStepperMotorCurrent
'm0907': 'GCodeMachineConfig', # TrimpotStepperMotorCurrent
'm0908': 'GCodeMachineConfig', # SetTrimpotPins
'm0909': 'GCodeMachineState', # ReportDacStepperCurrent
'm0910': 'GCodeMachineState', # CommitDacToEeprom
'm0911': 'GCodeMachineState', # TmcOtPreWarnCondition
'm0912': 'GCodeMachineState', # ClearTmcOtPreWarn
'm0913': 'GCodeMachineConfig', # SetHybridThresholdSpeed
'm0914': 'GCodeMachineConfig', # TmcBumpSensitivity
'm0915': 'GCodeCalibrationRoutines', # TmcZAxisCalibration
'm0916': 'GCodeCalibrationRoutines', # L6474ThermalWarningTest
'm0917': 'GCodeCalibrationRoutines', # L6474OvercurrentWarningTest
'm0918': 'GCodeCalibrationRoutines', # L6474SpeedWarningTest
'm0919': 'GCodeMachineConfig', # TmcChopperTiming
'm0928': 'GCodeIO', # StartSdLogging
'm0951': 'GCodeOtherModal', # MagneticParkingExtruder
'm0951': 'GCodeMachineConfig', # MagneticParkingExtruder
'm0993': 'GCodeIO', # BackUpFlashSettingsToSd
'm0994': 'GCodeIO', # RestoreFlashFromSd
'm0995': 'GCodeIO', # TouchScreenCalibration
'm0997': 'GCode', # FirmwareUpdate
'm0997': 'GCodeMachineConfig', # FirmwareUpdate
'm0999': 'GCodeOtherModal', # StopRestart
't0000': 'GCodeOtherModal', # SelectOrReportTool
't0001': 'GCode', # MmuSpecialCommands
't0001': 'GCodeOtherModal', # MmuSpecialCommands
}
extra_attributes = {
@ -257,8 +257,13 @@ extra_attributes = {
'g021': ['unit_id = 1'], # MillimeterUnits
}
valid_chars = ascii_letters + '_' + ''.join(str(i) for i in range(10))
def sanitize(string):
return ''.join([char if char in ascii_letters else '' for char in string])
""" clean a string so it's suitable to act as a class name
NOTE: does not replace accented characters by their closest equivalent """
x = lambda w: w[0].upper() + w[1:]
return ''.join([char if char in valid_chars else '' for char in ''.join([x(word) for word in string.split(' ')])])
def code_val(string):
try:
@ -291,7 +296,7 @@ def extract_data(filename):
code = int(code)
elif line.startswith('title: '):
title = line[7:].rstrip()
class_name = sanitize(title.title())
class_name = sanitize(title)
elif line.startswith('codes: '):
codes = line[8:-2].replace(' ','').split(',')
elif line.startswith('brief: '):
@ -305,7 +310,6 @@ def extract_data(filename):
out += f'''class {comment}GCode{class_name}{name_suffix}({class_types[tag]}):
"""{', '.join(codes)}: {brief}"""
param_letters = "{''.join(param_letters)}"
dialects = ['marlin2']
'''
if len(codes) > 1:
@ -333,7 +337,7 @@ if __name__ == '__main__':
all_classes = []
print("# DO NOT EDIT - file generated with pygcode/src/pygcode/tools/marlin_parse_MarlinDocumentation.py\nfrom .gcodes_base import *\n")
print("# TODO: manual changes have been made! see pygcode/src/pygcode/gcode_marlin.patch", file=stderr)
print("# NOTE: it is likely manual changes have been made to the previous output! see pygcode/src/pygcode/gcode_marlin.patch", file=stderr)
for filename in argv[1:]:
name, body = extract_data(filename)