aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/klippy.py
Commit message (Collapse)AuthorAgeFilesLines
* klippy: Reword the error messages during config file parsingKevin O'Connor2018-04-201-5/+5
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* heater: Add PrinterHeaters class that stores all sensors and heatersKevin O'Connor2018-04-041-3/+3
| | | | | | | | | | | | Add a PrinterHeaters class that can stores references to available temperature sensors and stores references to instantiated heaters. Add a extras/heater_bed.py file and delay instantiation of the heater_bed object. This allows the heater.py module to be imported earlier during the setup phase, and allows the PrinterHeaters class to be available for registering sensors and heaters. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Automatically clear rollover_info on each restartKevin O'Connor2018-04-031-9/+10
| | | | | | | Automatically clear the information printed at the start of each log file rollover on a klippy internal restart. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* output_pin: Move pwm and digital output pins to new module in extras/Kevin O'Connor2018-03-171-2/+2
| | | | | | | | Rename the digital_output, pwm_output, and static_pwm_output config sections to output_pin and move to a new module in the extras/ directory. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Rework starting error messageKevin O'Connor2018-03-121-1/+1
| | | | | | | Commit 9bc4239e now emphasizes the first line of a multi-line error message, so rework startup_message to conform to that. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Allow external callers of try_load_module()Kevin O'Connor2018-03-111-2/+2
| | | | | | | It can be useful to automatically pull in a module in the extras/ directory. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Allow any stats producer to determine when stats are neededKevin O'Connor2018-02-051-7/+3
| | | | | | | | 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>
* klippy: Introduce load_config_prefix() for modules that take parametersKevin O'Connor2018-02-031-2/+8
| | | | | | | | Use both load_config() and load_config_prefix() functions when dynamically loading a module from the extras directory - if the config section name has parameters in it then use load_config_prefix(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: No need to store fileconfig in main printer objectKevin O'Connor2018-02-031-24/+22
| | | | | | Just pass the fileconfig reference to the ConfigWrapper instances. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* fan: Move fan code to extras directoryKevin O'Connor2018-01-281-2/+2
| | | | | | | The print cooling fan and printer heater_fan are independent modules that can reside in the extras directory. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Add support for dynamic loading of python modulesKevin O'Connor2018-01-281-3/+17
| | | | | | | | Check if a config section matches a python filename in the klippy/extras/ directory. If it does, load that python code to handle the config section. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Support generic printer_state() and stats() callbacksKevin O'Connor2018-01-281-27/+30
| | | | | | | | | | | 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-12/+37
| | | | | | | | | 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: Move SET_SERVO command from gcode.py to chipmisc.pyKevin O'Connor2017-12-061-1/+1
| | | | | | | 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>
* klippy: Always recommend a FIRMWARE_RESTART on a shutdown eventKevin O'Connor2017-12-031-6/+3
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Rework shutdown handlingKevin O'Connor2017-10-121-32/+41
| | | | | | | | | 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>
* klippy: Avoid using '%' syntax when calling logging moduleKevin O'Connor2017-09-271-3/+3
| | | | | | | The logging module can build strings directly from printf syntax - no need to build the string first. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Initial support for multiple micro-controllersKevin O'Connor2017-09-201-10/+22
| | | | | | | | | Add initial support for controlling multiple independent micro-controllers from a single Klippy host instance. Add basic support for synchronizing the clocks of the additional mcus to the main mcu's clock. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Separate is_active() code from stats() codeKevin O'Connor2017-09-191-2/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Do not start stats timer until after connect completesKevin O'Connor2017-09-191-7/+3
| | | | | | | Generating stats during connect leads to potential use of not yet initialized variables. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* fan: Allow heater_fan to work with heater_bedKevin O'Connor2017-09-071-6/+7
| | | | | | | Fix order of init error preventing heater_fan from being used with heater_bed. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Provide some further help on common MCU shutdown errorsKevin O'Connor2017-09-051-2/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Eliminate set_max_jerk() from kinematic classesKevin O'Connor2017-09-031-2/+2
| | | | | | | | Allow the kinematic classes to query the max velocity, max accel, and max halt velocity from the toolhead class instead of having the toolhead class call into the kinematic classes with those values. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Move restart logic into Printer() classKevin O'Connor2017-08-261-26/+15
| | | | | | | Move the restart logic out of main() and into Printer.run(). This simplifies the code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Rename internal functions so that they are prefaced with "_"Kevin O'Connor2017-08-261-8/+8
| | | | | | | Preface the internal functions to make it more clear which functions are interfaces to external code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* chipmisc: Add support for statically configured output pinsKevin O'Connor2017-08-261-2/+2
| | | | | | | Allow digital and PWM output pins to be setup via new config sections. This makes it easier to setup pin configurations. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pins: Support registering arbitrary chips that supply configurable pinsKevin O'Connor2017-08-251-6/+6
| | | | | | | | | Allow multiple chips to provide pin mappings (not just the main mcu chip). Move the pin parsing from the mcu.py code to pins.py and support mapping from pin descriptions to their corresponding chips and parameters. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Store printer startup parameters in new "start_args" dictionaryKevin O'Connor2017-08-251-50/+31
| | | | | | | | | 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>
* fan: Add support for heater_fan objectsKevin O'Connor2017-07-171-0/+3
| | | | | | | Add support for fans designed to cool the components of an extruder or heater. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* build: Request python2 for all directly executed python binariesKevin O'Connor2017-06-271-1/+1
| | | | | | | Some systems point python to python3 instead of python2 - explicitly request python2 to avoid conflicts. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Make sure to always sleep before retrying next stats() callKevin O'Connor2017-06-151-2/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Use newer "except XYZError as e" python syntaxKevin O'Connor2017-06-101-4/+4
| | | | | | Use the newer syntax for python exceptions. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Allow each module to define their config sectionsKevin O'Connor2017-06-091-11/+8
| | | | | | | | Create add_printer_objects() functions in the fan, heater, extruder, and toolhead modules. Create the necessary printer component objects from this call instead of placing the code directly in klippy.py. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Prefer python dictionary comprehension to dict() callKevin O'Connor2017-06-061-1/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* queuelogger: Add critical information to each logfile on rolloverKevin O'Connor2017-05-011-13/+22
| | | | | | | When the log file does a rollover, start the top of the log with critical system information (eg, software versions). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Don't log stats when the printer is idleKevin O'Connor2017-04-141-8/+11
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Remove CLEAR_SHUTDOWN commandKevin O'Connor2017-04-131-3/+3
| | | | | | | | Advice users to issue a FIRMWARE_RESTART command on a printer shutdown event, and remove support for CLEAR_SHUTDOWN. A full mcu reset is preferable and it simplifies the interface. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Support reset commandKevin O'Connor2017-04-131-1/+1
| | | | | | | Extend the FIRMWARE_RESTART command so that it can use the firmware "reset" command instead of the "arduino" mechanism. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Support minimum/maximum value checks on configuration variablesKevin O'Connor2017-04-111-6/+27
| | | | | | | Verify that numeric parameters are in a sane range when reading the config. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Log python info at start of logKevin O'Connor2017-03-161-0/+2
| | | | | | Log the python version and startup command parameters to the log. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Eliminate high-level build_config phaseKevin O'Connor2017-03-131-12/+6
| | | | | | | | | | Now that the mcu objects can be created prior to connecting to the mcu, it is no longer necessary to separate the init and build_config phases in the high-level code. Move the mcu objection creation from the build_config phase to the init phase and eliminate the build_config phase. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Eliminate build_config() methodKevin O'Connor2017-03-131-2/+1
| | | | | | Lookup the printer components during the set_printer_ready() callback. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Support FIRMWARE_RESTART commandKevin O'Connor2017-03-081-10/+26
| | | | | | | | Add initial support for micro-controller resets via the Arduino reset mechanism. Also, automatically attempt a firmware restart if the printer CRC does not match. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Log the type of cpu the host is running onKevin O'Connor2017-02-121-0/+1
| | | | | | | | Report in the log the host CPU type and count. This helps distinguish between different rpi versions when debugging the log from a problem report. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Fix omission causing gcode dump to not functionKevin O'Connor2017-02-121-2/+4
| | | | | | Fix bug that broke the gcode command dump after a shutdown. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* reactor: Use the system monotonic clock instead of the normal system clockKevin O'Connor2017-02-061-1/+5
| | | | | | | | | | | | | The normal system clock can have sudden jumps if the system clock is changed. Use the system monotonic clock to avoid these sudden changes in time. It appears the Raspbian OS (which is used by OctoPi) is setup to update the system clock upon network connectivity. This could cause sudden system clock changes which could lead to Klippy processing errors. Using the monotonic clock eliminates these issues. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Increase precision of reported statistics timestampKevin O'Connor2017-01-101-1/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Warn the user on common errors due to old firmwareKevin O'Connor2017-01-101-0/+14
| | | | | | | | Check for msgproto.error and warn the user about version firmware version mismatch. Raise msgproto.error when extracting firmware constants. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Add support for M115 commandKevin O'Connor2016-12-281-3/+5
| | | | | | Support querying the firmware type and version. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Log the contents of the config file at startupKevin O'Connor2016-12-241-0/+10
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>