- Introduced G-code command descriptions and a lookup function for tooltips in the new commands.js file. - Implemented G-code language support in CodeMirror with syntax highlighting and tooltip functionality in the new index.js file. - Updated codeBlockEditorUtils.js to include G-code language support, allowing for enhanced editing capabilities for G-code files.
103 lines
3.1 KiB
JavaScript
103 lines
3.1 KiB
JavaScript
/**
|
|
* G-code command descriptions for hover tooltips.
|
|
* Adapted from gcode-lang-codemirror (MIT):
|
|
* https://github.com/oneislandearth/gcode-lang-codemirror
|
|
*/
|
|
export const GCodeCommands = {
|
|
G0: 'Rapid movement',
|
|
G1: 'Linear movement',
|
|
G2: 'Clockwise arc movement',
|
|
G3: 'Counter-clockwise arc movement',
|
|
G4: 'Dwell (wait P milliseconds or S seconds)',
|
|
G10: 'Retract (firmware retraction)',
|
|
G11: 'Recover (firmware retraction)',
|
|
G20: 'Set units to inches',
|
|
G21: 'Set units to millimeters',
|
|
G28: 'Home axes',
|
|
G29: 'Automatic bed leveling',
|
|
G80: 'Mesh bed leveling (Prusa) / cancel canned cycle',
|
|
G90: 'Use absolute positioning',
|
|
G91: 'Use relative positioning',
|
|
G92: 'Set current position',
|
|
M0: 'Stop after the buffer is empty',
|
|
M17: 'Enable stepper motors',
|
|
M18: 'Disable stepper motors',
|
|
M20: 'List SD card files',
|
|
M21: 'Initialize (mount) SD card',
|
|
M22: 'Release (unmount) SD card',
|
|
M23: 'Select SD file for printing',
|
|
M24: 'Start / resume SD print',
|
|
M25: 'Pause SD print',
|
|
M26: 'Set SD position in bytes',
|
|
M27: 'Report SD print status',
|
|
M28: 'Start writing to SD card',
|
|
M29: 'Stop writing to SD card',
|
|
M40: 'Eject part',
|
|
M42: 'Set pin state / stop if out of material',
|
|
M73: 'Set print progress',
|
|
M80: 'Turn ATX power on',
|
|
M81: 'Turn ATX power off',
|
|
M82: 'Extruder absolute mode',
|
|
M83: 'Extruder relative mode',
|
|
M84: 'Disable idle hold / steppers',
|
|
M92: 'Set steps per unit',
|
|
M104: 'Set extruder temperature',
|
|
M105: 'Get temperatures',
|
|
M106: 'Set fan speed',
|
|
M107: 'Turn fan off',
|
|
M109: 'Set extruder temperature and wait',
|
|
M110: 'Set current line number',
|
|
M112: 'Emergency stop',
|
|
M114: 'Get current position',
|
|
M115: 'Get firmware version and capabilities',
|
|
M117: 'Set LCD / status message',
|
|
M119: 'Get endstop status',
|
|
M140: 'Set bed temperature',
|
|
M141: 'Set chamber temperature',
|
|
M190: 'Set bed temperature and wait',
|
|
M191: 'Set chamber temperature and wait',
|
|
M220: 'Set feedrate percentage',
|
|
M221: 'Set flow percentage',
|
|
M300: 'Beep (S Hz for P ms)',
|
|
M600: 'Filament change',
|
|
M601: 'Pause print (Prusa)',
|
|
M862: 'G-code compatibility check (Prusa)',
|
|
M900: 'Linear / pressure advance (K)',
|
|
T0: 'Select tool / extruder 0',
|
|
T1: 'Select tool / extruder 1',
|
|
X: 'X axis',
|
|
Y: 'Y axis',
|
|
Z: 'Z axis',
|
|
E: 'Extruder axis',
|
|
A: 'A axis',
|
|
B: 'B axis',
|
|
C: 'C axis',
|
|
F: 'Feedrate',
|
|
S: 'Speed, temperature, or value',
|
|
P: 'Parameter / time',
|
|
I: 'Arc X offset / parameter',
|
|
J: 'Arc Y offset / parameter',
|
|
K: 'Arc Z offset / linear advance',
|
|
R: 'Arc radius / RPM'
|
|
}
|
|
|
|
export function lookupGCodeCommand(word) {
|
|
const upper = String(word || '').toUpperCase()
|
|
const commandMatch = upper.match(/^([GMT])0*(\d+)(\.\d+)?/)
|
|
if (commandMatch) {
|
|
const base = commandMatch[1] + String(parseInt(commandMatch[2], 10))
|
|
const canonical = base + (commandMatch[3] || '')
|
|
return (
|
|
GCodeCommands[canonical] ||
|
|
GCodeCommands[base] ||
|
|
GCodeCommands[upper] ||
|
|
null
|
|
)
|
|
}
|
|
const axis = upper.charAt(0)
|
|
if (axis && GCodeCommands[axis]) {
|
|
return GCodeCommands[axis]
|
|
}
|
|
return null
|
|
}
|