aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/mcu.py
Commit message (Collapse)AuthorAgeFilesLines
...
* clocksync: Don't export get_last_clock()Kevin O'Connor2017-09-191-32/+18
| | | | | | | Everywhere the data in get_last_clock() is used can be done just as easily with estimated_print_time(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* clocksync: Move clock synchronization code into new fileKevin O'Connor2017-09-191-12/+19
| | | | | | | Move the low-level clock synchronization code from serialhdl.py to a new file clocksync.py. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Update file purpose commentKevin O'Connor2017-09-191-1/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Pass print_time directly to MCU callsKevin O'Connor2017-09-191-48/+44
| | | | | | | | | Now that the print_time is always synchronized with the mcu_time, there is no longer a need to track mcu_time as a separate quantity. Eliminate references to mcu_time from the code and pass print_time directly in its place. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Synchronize print_time to main mcu's timeKevin O'Connor2017-09-191-29/+12
| | | | | | | | Instead of starting the print_time at zero, start it at the estimated time of the main mcu's clock. This simplifies the code and it ensures that print_time never goes backwards. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepcompress: Return number of steps traveled from stepcompress_push()Kevin O'Connor2017-09-131-7/+4
| | | | | | | Return the same information from stepcompress_push() that is returned from stepcompress_push_const() and stpcompress_push_delta(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pins: Don't pass mcu_freq to update_command()Kevin O'Connor2017-09-131-2/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Limit value range of PWM and digital outputs prior to transmissionKevin O'Connor2017-09-061-10/+7
| | | | | | | Make sure schedule_digital_out and schedule_pwm_out commands always go out with a value that is in range for the particular command. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Improve error descriptions in Common_MCU_errorsKevin O'Connor2017-09-061-2/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Provide some further help on common MCU shutdown errorsKevin O'Connor2017-09-051-2/+28
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Limit ADC min/max range to a 16bit integerKevin O'Connor2017-09-051-2/+3
| | | | | | | | | Make sure the ADC range sent to the MCU can be encoded into a 16bit integer. Otherwise, if the provided min_temp/max_temp was outside the range of possible values it could result in a spurious mcu shutdown. In particular, the AD595 could not properly encode a min_temp of zero. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pru: Support config_reset command to manually reset mcuKevin O'Connor2017-09-031-10/+26
| | | | | | | Add support for resetting the MCU via a software only mechanism. This is useful on the PRU. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Add get_mcu() call to the mcu oid objectsKevin O'Connor2017-08-291-7/+10
| | | | | | | | | Allow external code to obtain the mcu object that controls a pin setup with setup_pin(). Also, don't bother defining print_to_mcu_time() and system_to_mcu_time() on each pin object as they can be obtained via the new get_mcu() method. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Fix bug causing corexy to not work (introduced in 9d75c3b0)Kevin O'Connor2017-08-291-2/+2
| | | | | | | | | Commit 9d75c3b0 changed the order of allocation for mcu oid integer ids. However, the stepper oids must always be allocated before endstop oids so that corexy can register multiple steppers on a single endstop. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Drop support for TICKS() expansion in mcu config commandsKevin O'Connor2017-08-261-10/+11
| | | | | | | It's no longer necessary to use the TICKS() hack as the config commands are now all generated after the mcu speed is known. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* chipmisc: Add support for statically configured output pinsKevin O'Connor2017-08-261-12/+40
| | | | | | | 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>
* 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>