aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/gcode.py
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* gcode: Dump internal g-code state in dump_debug()Kevin O'Connor2017-12-211-0/+7
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Group similar G-Code commands togetherKevin O'Connor2017-12-211-44/+49
| | | | | | | Group commands by category instead of listing them in numerical order. This is just code movement; no code changes. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* homing: Directly interact with the kinematic class on query_endstops()Kevin O'Connor2017-12-061-7/+2
| | | | | | Move the query_endstop logic out of toolhead.py and into homing.py. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* homing: Directly interact with the kinematic class when homingKevin O'Connor2017-12-061-2/+2
| | | | | | | Move the homing logic out of toolhead.py and into homing.py. This simplifies the toolhead logic and centralizes the homing code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Move SET_SERVO command from gcode.py to chipmisc.pyKevin O'Connor2017-12-061-14/+6
| | | | | | | Now that commands can be registered dynamically, move the code for SET_SERVO from gcode.py to the PrinterServo() class in chipmisc.py. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Rework gcode handler setup to allow dynamic command registrationKevin O'Connor2017-12-061-17/+21
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Add a get_str() methodKevin O'Connor2017-12-061-17/+10
| | | | | | | Add a get_str() method that can extract a required parameter from a g-code command. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Simplify exception handlingKevin O'Connor2017-12-061-19/+16
| | | | | | | | Translate caught exceptions into a gcode.error() exception. This way there is one standard place to invoke respond_error(). Also, always reset the last_position on a handled error. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Always allow M112 commandKevin O'Connor2017-12-061-0/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Rework shutdown handlingKevin O'Connor2017-10-121-21/+21
| | | | | | | | | If an MCU signals a shutdown from the background thread, notify the main thread and handle the shutdown there. Dispatch shutdown handling from the main Printer() class instead of from the Toolhead class. This simplifies the shutdown logic. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* adccmds: Continue to query analog inputs after a shutdownKevin O'Connor2017-10-121-6/+6
| | | | | | | | Continue to sample the ADC input pins even if the MCU goes into a shutdown state. This enables the printer to continue reporting temperatures even on an mcu error. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Don't warn on fan not present if input is from a fileKevin O'Connor2017-10-111-1/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Report the raw MCU position from the M114 commandKevin O'Connor2017-10-031-3/+3
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Carry over #original and #command in get_extended_params()Kevin O'Connor2017-10-021-1/+3
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Make dump_debug() output atomicKevin O'Connor2017-09-271-2/+4
| | | | | | | Build a single (very large) logging message with the debug state. This prevents the output from being fragmented. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Exit if a shutdown occurs while running in batch modeKevin O'Connor2017-09-271-0/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* chipmisc: Add initial support for servosKevin O'Connor2017-09-201-8/+38
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Fix error that could cause commands to be processed out of orderKevin O'Connor2017-09-021-7/+5
| | | | | | | | | | | | | | | | Commit d0932009 changed the way command handling was performed, and commit 95950949 fixed a defect in that commit. Unfortunately, the fix was incomplete. If multiple commands were sent to Klippy without waiting for an "ok" response from Klippy, then it was possible for those additional commands to be queued and processed after subsequent commands. This would result in commands being processed out of order. Fix this by only reregistering the input fd in the greenlet that performs the unregistration of the fd. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Add an ECHO command for debugging purposesKevin O'Connor2017-09-021-1/+4
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Move restart logic into Printer() classKevin O'Connor2017-08-261-2/+2
| | | | | | | Move the restart logic out of main() and into Printer.run(). This simplifies the code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Avoid directly accessing the printer.mcu fieldKevin O'Connor2017-08-261-1/+1
| | | | | | | Lookup the mcu object from the printer objects and store it locally in the toolhead class. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Store printer startup parameters in new "start_args" dictionaryKevin O'Connor2017-08-251-7/+6
| | | | | | | | | Store pertinent information from the software startup in a dictionary that the various printer components can access instead of in individual variables in the Printer() class. This makes it easier to add future command-line options. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Don't wait for moves to finish if both debug input and outputKevin O'Connor2017-07-231-1/+2
| | | | | | Don't wait for moves to finish if the output is going to a debug file. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Improve end-of-file handling when input is a debug fileKevin O'Connor2017-07-211-7/+10
| | | | | | | | | Wait for any pending moves to be fully handled before exiting. Make sure the wait is done inside the "self.is_processing_data" check to avoid infinite recursion. Don't keep reading from the file while waiting to exit. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Log g-code error responsesKevin O'Connor2017-07-171-2/+3
| | | | | | Be sure to log g-code errors even if debug logging is not enabled. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Fix regression causing lost asynchronous commandsKevin O'Connor2017-06-111-1/+2
| | | | | | | | Commit d0932009 introduced an error that could cause lost input in cases where the sender did not wait for an "ok" message before sending the next command. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>