aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/gcode.py
Commit message (Collapse)AuthorAgeFilesLines
* respond: An extra for sending messages to the printer host. (#1053)Alec B. Plumb2019-01-021-2/+2
| | | | | | | | | | | | I have made one change to `gcode.py` to support quoted parameter values. I have added support for the basic `M118` command (see https://reprap.org/wiki/G-code#M118:_Echo_message_on_host). I have also added a `RESPOND` command that takes extended parameters. `ECHO` might be a better name than `RESPOND` but is already defined in `gcode.py`. Signed-off-by: Alec B. Plumb <alec@etherwalker.com>
* heater: take a gcode_id when setting up a heater (#1028)john--2019-01-021-19/+16
| | | | | Allow an arbitrary gcode_id to be supplied during heater setup. This allows future extras to register additional IDs beyond B, and T#. Signed-off-by: John Jardine <john@gprime.net>
* gcode: Minor change to make M220 command take effect immediately (#1000)bondus2019-01-021-2/+2
| | | | | | This makes M220 (change print speed) command effect the next move command (G0/G1). Before it only made a differenc once a G0/G1 command with an F parameter was executed. Signed-off-by: Pontus Borg <liquidpontus@yahoo.se>
* gcode: process_batch() should execute commands atomicallyKevin O'Connor2018-10-281-13/+16
| | | | | | | Update the process_batch() method so that it will not interleave commands read from the input fd with the batched commands. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* homing: Pass printer instead of toolhead object to Homing classKevin O'Connor2018-10-161-1/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Report state message after any error in a STATUS responseKevin O'Connor2018-10-131-1/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Remove "Preparing to restart" messageKevin O'Connor2018-10-131-1/+0
| | | | | | | Now that "Klipper state" messages are proactively sent, it is redundant to send the "preparing to restart" message. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: modify get_status method to output more info (#651)Janar Sööt2018-09-171-1/+16
| | | Signed-off-by: Janar Sööt <janar.soot@gmail.com>
* gcode: Send proactive state messagesKevin O'Connor2018-09-121-4/+11
| | | | | | Send a g-code info message on printer state changes. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Catch errors on fd read and writeKevin O'Connor2018-09-121-6/+16
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: M117 fixArksine2018-08-221-0/+6
| | | | | | Resolves issue where M117 is not correctly executed when the message begins with numeric or special character. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
* kinematics: Convert get_rails() method to get_steppers()Kevin O'Connor2018-07-161-4/+1
| | | | | | | All callers of get_rails() actually just want the steppers, so return them directly. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* query_endstops: Move QUERY_ENDSTOP command to it own extras/ moduleKevin O'Connor2018-07-161-8/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Move kinematic modules to new kinematics/ directoryKevin O'Connor2018-07-121-3/+3
| | | | | | | | Move extruder.py, cartesian.py, corexy.py, and delta.py to a new kinematics/ sub-directory. This is intended to make adding new kinematics a little easier. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: fix for GET_POSITION (#454)Eric Callahan2018-07-031-1/+4
| | | Signed-off-by: Eric Callahan <arksine.code@gmail.com>
* gcode: Add run_script() method that is valid from non-command contextsKevin O'Connor2018-06-301-0/+11
| | | | | | | Add an ability to run a series of g-code commands from a reactor callback that isn't part of the normal g-code command processing. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Rename run_script() to run_script_from_command()Kevin O'Connor2018-06-301-3/+3
| | | | | | | Emphasize that the run_script() method is only valid when run from a g-code command. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* delta: Rename get_position() to calc_position()Kevin O'Connor2018-06-221-1/+1
| | | | | | | | Calculating the cartesian position from the stepper positions can be complex and cpu intensive, so rename it to calc_position() to be more descriptive. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Don't peak into PrinterStepper membersKevin O'Connor2018-06-221-3/+2
| | | | | | | Add additional wrapper functions so that no outside callers need to peak into the member variables of PrinterStepper. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Add a get_name() method to PrinterStepperKevin O'Connor2018-06-221-2/+3
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Return an error code if batch input results in an errorKevin O'Connor2018-06-161-1/+3
| | | | | | | When reading from a debug input file, propagate any errors to the program return status. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: mux command is already registered error print fixedcruwaller2018-06-011-1/+1
| | | | Signed-off-by: Petri Honkala <cruwaller@gmail.com>
* gcode: Apply SET_GCODE_OFFSET to next move commandKevin O'Connor2018-05-291-1/+3
| | | | | | | | Apply the changes made by a SET_GCODE_OFFSET command to the next move, even if the move is relative to the last movement. This allows the command to implement "babystepping" requests. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Reset extrude_factor and extruder position on a tool changeKevin O'Connor2018-05-201-0/+2
| | | | | | | The extrude_factor and extruder position are specific to the current extruder, so reset them to default values on a Tn command. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Raise an error if a duplicate command is registeredKevin O'Connor2018-05-201-0/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Add ability to register a "mux" commandKevin O'Connor2018-05-201-0/+23
| | | | | | | | | | It's common to add commands that dispatch to a particular object instance depending on the value of a command parameter. (For example, the command "SET_SERVO SERVO=xyz" wants to be handled by the particular "xyz" servo instance.) Add a register_mux_command() helper to gcode.py make it easier to do this. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Add minval/maxval/above/below options to get_X parsersKevin O'Connor2018-04-201-29/+40
| | | | | | Add value checking to gcode parameter parsing code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Add a SET_GCODE_OFFSET commandKevin O'Connor2018-04-201-1/+14
| | | | | | | | The M206 command is confusing (it uses negative offsets) and isn't very flexible. Add a new SET_GCODE_OFFSET command to make it easier to add virtual offsets to gcode commands. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Rename homing_add to homing_offsetKevin O'Connor2018-04-201-17/+17
| | | | | | | | | The M206 command is confusing as positive values in that command result in negative offsets to future g-code commands. Perform the parameter negation in the M206 command instead of storing it that way internally. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pid_calibrate: Move PID calibration logic from heater.py to new fileKevin O'Connor2018-03-181-13/+1
| | | | | | | | Drop support for M303 and PID_TUNE, and replace it with a new PID_CALIBRATE command. Move the logic for this command from heater.py to a new pid_calibrate.py file in the extras/ directory. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Position returned by M114 should be relative to last G92Kevin O'Connor2018-03-151-13/+40
| | | | | | | | It looks like OctoPrint is expecting the result from M114 to be relative to the last G92 command. Also, introduce GET_POSITION to report the actual location that the printer is at. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: On a multi-line error message, report the first line twiceKevin O'Connor2018-03-121-2/+2
| | | | | | | | Report the first line of a multi-line error message twice - once as part of the informational content, and once with the "!!" error prefix. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* display: Add initial support for LCD screens attached to an MCUKevin O'Connor2018-03-061-0/+3
| | | | | | | | Add support for displaying basic status information on ST7920 and HD44780 based LCDs that are attached directly to a micro-controller. Signed-off-by: Marcio Teixeira <marcio@alephobjects.com> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* virtual_sdcard: Initial support for virtual sdcardKevin O'Connor2018-02-111-1/+12
| | | | | | | | Add support for directly printing from a local file on the host. This may be useful if the host cpu is not fast enough to run OctoPrint well. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Introduce request_restart() methodKevin O'Connor2018-02-111-20/+12
| | | | | | | Use request_restart() method instead of prep_restart() and motor_heater_off(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Extract special cases from process_data()Kevin O'Connor2018-02-111-20/+28
| | | | | | | Handle the unlikely case of pending commands in a new method process_pending(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Allow any stats producer to determine when stats are neededKevin O'Connor2018-02-051-1/+1
| | | | | | | | Instead of using the toolhead class to determine if stats should be reported, allow every printer object with a stats() callback to determine if stats are needed. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Make sure need_ack is always restored on run_script()Kevin O'Connor2018-02-021-3/+5
| | | | | | Restore need_ack even on a G-Code exception. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Keep reading input to check for M112 (emergency stop)Kevin O'Connor2018-02-021-11/+26
| | | | | | | | | | | | OctoPrint (and other software) will sometimes send additional commands even if the previous command has not yet responded with an "ok". Change the g-code input reading code to keep reading input so that an M112 can be detected (and processed out-of-order). To avoid the extreme case where one writes an entire g-code file to the input without any pacing, disable the input reading if more than 20 commands are pending. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Propagate errors from run_script()Kevin O'Connor2018-02-011-0/+4
| | | | | | | If the script being run raises an error, then stop running that script and return the error to the caller. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Ack even empty linesKevin O'Connor2018-02-011-2/+2
| | | | | | An empty input line should still return an "ok" message. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* bed_tilt: Add support for automatic bed tilt move transformationKevin O'Connor2018-01-281-3/+14
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Support generic printer_state() and stats() callbacksKevin O'Connor2018-01-281-9/+12
| | | | | | | | | | | Instead of hardcoding which objects are called on state transitions, allow any "printer object" to be invoked if it has a printer_state() method. Convert connect, ready, shutdown, and disconnect callbacks to this mechanism. Similarly, allow all printer objects to provide a stats() callback. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Add access methods and avoid peeking into the printer classesKevin O'Connor2018-01-281-5/+5
| | | | | | | | | Add get_reactor(), lookup_object(), lookup_module_objects(), and set_rollover_info() to the main Printer class so that callers do not need to peek into the class' members. Similarly, add get_printer() and get_name() methods to the ConfigWrapper class. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Add a run_script() helper method to run g-code scriptsKevin O'Connor2018-01-281-4/+4
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Extend register_command() so that it can also unregister a commandKevin O'Connor2018-01-281-0/+6
| | | | | | | If register_command() is passed None as the function to call, then treat it as an unregister command request. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Use reset_last_position() from cmd_G28()Kevin O'Connor2018-01-161-2/+1
| | | | | | | Use the existing reset_last_position() code in cmd_G28() instead of manually implementing the logic. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Add support for M221 (set extrude factor) g-code commandKevin O'Connor2018-01-031-12/+32
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Add support for M220 (set speed factor) g-code commandKevin O'Connor2018-01-031-4/+11
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Don't wait for temperature if the temperature is disabledKevin O'Connor2018-01-031-1/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>