aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/mcu.py
Commit message (Collapse)AuthorAgeFilesLines
...
* mcu: Track stepqueues separately from steppersKevin O'Connor2017-08-251-6/+6
| | | | | | | | The MCU() class needs to track the stepqueues so that it can initialize the steppersync object. Track the stepqueues directly instead of via the list of steppers. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Track oids separately from objects requiring a build_config() callbackKevin O'Connor2017-08-251-13/+18
| | | | | | | | Track the oid count separately from the configurable object count - this way it is possible to have internal objects that don't require an oid in the mcu. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Eliminate "init callback" phase during connectKevin O'Connor2017-08-251-28/+21
| | | | | | | | It's not necessary to register and execute "init callbacks" when configuring the mcu. Instead, have each mcu object produce its init messages in the build_config() callback. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pins: Support registering arbitrary chips that supply configurable pinsKevin O'Connor2017-08-251-66/+76
| | | | | | | | | 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-11/+22
| | | | | | | | | 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>
* irq: Support sleeping when mcu is idleKevin O'Connor2017-07-171-2/+4
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Support converting from a system time to an mcu timeKevin O'Connor2017-07-171-0/+6
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Use newer "except XYZError as e" python syntaxKevin O'Connor2017-06-101-1/+1
| | | | | | Use the newer syntax for python exceptions. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serialhdl: Support working with pseudo serial devicesKevin O'Connor2017-05-151-1/+5
| | | | | | | Support working with devices that aren't really serial ports and thus do not have a baud rate. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pwmcmds: Export the maximum PWM valueKevin O'Connor2017-05-151-4/+8
| | | | | | | Instead of assuming the maximum PWM value is 255, export a constant from the firmware to the host with the maximum value. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* queuelogger: Add critical information to each logfile on rolloverKevin O'Connor2017-05-011-0/+11
| | | | | | | 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>
* mcu: No need to log mcu_stats debuggingKevin O'Connor2017-04-141-1/+0
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Change "Synchronizing mcu clock" logging to debugKevin O'Connor2017-04-141-1/+4
| | | | | | | Always log the last synchronized clock during a shutdown event, and use debug level for normal reports. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Remove CLEAR_SHUTDOWN commandKevin O'Connor2017-04-131-5/+0
| | | | | | | | 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: Make sure a FIRMWARE_RESTART actually resets the mcuKevin O'Connor2017-04-131-0/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* hub-ctrl: Add support for micro-controller reset via RPi usb power togglingKevin O'Connor2017-04-131-9/+25
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Support reset commandKevin O'Connor2017-04-131-4/+27
| | | | | | | 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-1/+2
| | | | | | | Verify that numeric parameters are in a sane range when reading the config. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* delta: Make it clear that a "virtual tower" is createdKevin O'Connor2017-04-071-6/+4
| | | | | | | | | | | The delta code calculates a "virtual tower" along the line of movement. Rework the variable names and comments to make it clear that this is occurring. It is not necessary to pass the start_pos variable to the C code as it is simple to update the start_pos at the start of each movement. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepcompress: Merge stepcompress_delta_const and stepcompress_delta_accelKevin O'Connor2017-04-071-16/+3
| | | | | | | | It's not necessary to have separate C delta kinematic functions for constant acceleration and constant velocity as constant velocity can be obtained by using a constant acceleration of zero. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepcompress: Pass delta velocity and acceleration directly to C codeKevin O'Connor2017-04-071-22/+13
| | | | | | | | Update the C delta kinematic code to take velocity and acceleration directly in step distances and clock ticks. This simplifies the mcu.py python code as it only needs to do unit and axis conversion. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepcompress: Merge stepcompress_push_accel() and stepcompress_push_const()Kevin O'Connor2017-04-071-10/+1
| | | | | | | | It's not necessary to have separate C functions for constant acceleration and constant velocity as constant velocity can be obtained by using a constant acceleration of zero. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepcompress: Pass constant velocity and acceleration directly to C codeKevin O'Connor2017-04-071-17/+9
| | | | | | | | Update the C code to take velocity and acceleration directly in step distances and clock ticks. This simplifies the mcu.py python code as it only needs to do unit and axis conversion. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Change mcu_stepper.set_position() to take a location in millimetersKevin O'Connor2017-04-071-3/+7
| | | | | | | | | | Update the set_position() method to convert from millimeters to absolute step position. Also, update PrinterStepper.get_homed_offset() and mcu_stepper.get_commanded_position() to return millimeters. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Don't export the commanded_position variable from mcu_stepperKevin O'Connor2017-04-071-15/+17
| | | | | | | | | | Now that the kinematic classes call the mcu_stepper with millimeters and seconds it is no longer necessary for them to directly access the stepper's position in absolute steps. Rename mcu_stepper.commanded_position to mcu_stepper._commanded_pos to make clear it is not a variable intended to be externally accessed. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Pass delta velocity and acceleration directly to mcu_stepperKevin O'Connor2017-04-071-15/+25
| | | | | | | | Rework the parameters of step_delta_const() and step_delta_accel() so that they take velocity and acceleration directly in millimeters and seconds. This simplifies the delta.py kinematic code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Pass constant velocity and acceleration directly to mcu_stepperKevin O'Connor2017-04-071-12/+28
| | | | | | | | Rename step_sqrt/step_factor to step_accel/step_const and have them directly take the velocity and acceleration in millimeters and seconds. This simplifies the kinematic classes. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Rename self.ffi_lib to self._ffi_libKevin O'Connor2017-04-041-18/+19
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* endstop: Support halting more than one stepper on triggerKevin O'Connor2017-04-031-9/+21
| | | | | | | | Extend the endstop code so that more than one stepper can be halted during endstop homing. Some kinematic setups (eg, corexy) require an endstop to support this. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Log the mcu clock each time print_time is synchronizedKevin O'Connor2017-03-301-1/+4
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Defer MCU_adc register_msg until ready to receive messagesKevin O'Connor2017-03-161-3/+3
| | | | | | Register the callback handler only after it's required state is setup. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Eliminate high-level build_config phaseKevin O'Connor2017-03-131-5/+5
| | | | | | | | | | 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>
* mcu: Delay setting of mcu_stepper.min_stop_intervalKevin O'Connor2017-03-131-18/+25
| | | | | | | | | Create a separate callback for setting the min_stop_interval. Also, move the setting of the stepper max_error from the stepper configs to the mcu config and rename it to max_stepper_error. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Allow each oid object to define its own build_config() methodKevin O'Connor2017-03-131-58/+81
| | | | | | | | Create a build_config() method on each oid object and call it just after connecting to the MCU. Move code that requires a connected state from the oid init to its new build_config method. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Support config mechanism for translating seconds to clock ticksKevin O'Connor2017-03-131-17/+14
| | | | | | | Introduce a TICKS() macro during config parsing that will translate time in seconds to time in clock ticks. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pins: Simplify pin map alias setupKevin O'Connor2017-03-131-5/+2
| | | | | | | | Use map_pins() to obtain the pin mapping - don't export mcu_to_pins(). The functionality of mcu_to_pins() can be obtained by calling map_pins() with name=None. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Introduce stepper_get_position command and remove from endstop.cKevin O'Connor2017-03-091-8/+11
| | | | | | | | Move the logic to calculate and report the stepper's current position from endstop.c to stepper.c. This localizes the stepper code into stepper.c. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Support inverted PWM pinsKevin O'Connor2017-03-091-4/+8
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Support FIRMWARE_RESTART commandKevin O'Connor2017-03-081-2/+14
| | | | | | | | 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>
* mcu: Improve error messages on failure to config printerKevin O'Connor2017-03-081-2/+9
| | | | | | | Don't report a CRC mismatch if a shutdown or other failure occurs during config - instead report the appropriate details. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* fan: Default to using software PWMKevin O'Connor2017-03-081-5/+5
| | | | | | | Not all hardware has PWM support and there is no compelling reason to use hardware PWM for fans. Change the default to use software PWM. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* heater: Support max_power setting for heatersKevin O'Connor2017-03-031-1/+3
| | | | | | | | Change the mcu PWM value from an integer (0-255) to a float (0. - 1.). Add support for limiting the maximum power (as measured over a sufficiently long duration) to a particular heater. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Rework lookahead flush to be more stable during high cpuKevin O'Connor2017-02-121-1/+1
| | | | | | | | | | | | | | | | | Change the lookahead queue so that it attempts to buffer at least buffer_time_high amount of moves when first starting a print. This helps ensure the buffer is normally always full. If the buffer falls below buffer_time_low then it is either due to the end of a print or because octoprint/klippy is unable to keep up. Change the code so that in this case the lookahead queue will attempt to gather buffer_time_high amount of moves before restarting movement. Update the default buffer_time_low to 1 second and buffer_time_high to 2 seconds. With the above changes a smaller buffer_time_high and a larger buffer_time_low are more practical. 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-6/+8
| | | | | | | | | | | | | 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>
* stepcompress: Propagate errors back to python codeKevin O'Connor2017-02-061-17/+34
| | | | | | | Propagate error codes back to the python code and raise an exception on an error. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Warn the user on common errors due to old firmwareKevin O'Connor2017-01-101-5/+5
| | | | | | | | 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>
* basecmd: Improve accuracy of stats "sumsq" variableKevin O'Connor2017-01-091-4/+5
| | | | | | | | | | | | Use a base of 256 instead of 65536 when calculating the sum of the square of the clock differences in the stats. This makes the calculation more accurate. Export the new base via DECL_CONSTANT for the host to access. Use DIV_ROUND_UP() when adjusting for the base to ensure no lost ticks. Do the division after multiplication in the common case where the time between stats_task() invocations is less than 64K ticks. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Change the default baud rate to 250000Kevin O'Connor2017-01-021-1/+1
| | | | | | | Update the default baud rate in mcu.py to 250000 (as that is the default in all other places). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepcompress: Using normal message priority system during homingKevin O'Connor2016-12-301-5/+6
| | | | | | | | | | | | | | The endstop homing system requires all queue_step commands be in the MCU's 'move queue' before endstop checking starts. Use the normal message priority system to request that stepper queue_step commands are received prior to the start of the end_stop_home command. This simplifies the code and removes the need for special serial queue flushing. This also fixes a bug in homing operations that take longer than 2^31 clock ticks. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Don't call steppersync_flush if steppersync not createdKevin O'Connor2016-12-281-0/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>