Commit Graph

7434 Commits

Author SHA1 Message Date
Guðni Már Gilbert c090868fa2 optimisation: reduce code size in M907
Change in memory:
Flash: -4 bytes
SRAM: 0 bytes
2023-07-25 15:02:49 +00:00
Guðni Már Gilbert 53c8bfa928 cleanup: remove unused variable
No change in memory
2023-07-25 15:02:49 +00:00
Guðni Már Gilbert 7029af05fa optimisation: reduce code size in pid_extruder()
Author: leptun

Change in memory:
Flash: -14 bytes
SRAM: 0 bytes
2023-07-25 15:02:49 +00:00
Guðni Már Gilbert 6623d45af9 optimisation: Tighter LCD timing
Author: leptun

Change in memory:
Flash: -14 bytes
SRAM: 0 bytes
2023-07-25 15:02:49 +00:00
Guðni Már Gilbert 5288d615f8 optimisation: lcd avoid streams
Author: leptun

Change in memory:
Flash: -124 bytes
SRAM: 0 bytes
2023-07-25 15:02:49 +00:00
Guðni Már Gilbert 5d880919f8 Align comment 2023-07-25 09:00:47 +02:00
Guðni Már Gilbert d5f4f6700d Optimise the acceleration limit checks
Kudos goes to Marlin FW

Change in memory:
Flash: -314 bytes
SRAM: 0 bytes
2023-07-25 09:00:47 +02:00
Guðni Már Gilbert 1984091c10 Rename axis_steps_per_sqr_second to max_acceleration_steps_per_s2 2023-07-25 09:00:47 +02:00
Guðni Már Gilbert c067318427 cleanup language menu
Change in memory:
Flash: -50 bytes
SRAM: 0 bytes
2023-07-25 08:58:52 +02:00
Guðni Már Gilbert 0ab10a9df6 tmc2130: chopconf: add comments to structure 2023-07-25 08:56:43 +02:00
Guðni Már Gilbert ed13d008d9 tmc2130: minor code cleanup
Using tmc2130_wr() instead makes the code a bit more
aligned and easier to read IMO

No change in memory
2023-07-25 08:56:43 +02:00
Guðni Már Gilbert 3819f7a473 tmc2130: Refactor code for setting/changing currents
- Always re-calculate the Vsense flag when the currents are changed
- Make sure Hold current is not larger than Run current
- Added SetCurrents() function from MMU FW
- Added MotorCurrents structure from MMU FW
- Various code size optimisations e.g. in power panic

Change in memory:
Flash: -10 bytes
SRAM: +4 bytes
2023-07-25 08:56:43 +02:00
Guðni Már Gilbert a87faba2bd tmc2130: pull TMC2130_CNSTOFF_E outside tmc2130_setup_chopper
We can probably improve tmc2130_chopper_config further by adding
a constructor.

No change in memory
2023-07-25 08:56:43 +02:00
Guðni Már Gilbert 664d4e2bbe tmc2130: chopconf: Add constructor to ChopConfU
Removed redundant initialisations which the constructor now takes care of

Change in memory:
Flash: +8 bytes
SRAM: 0 bytes
2023-07-25 08:56:43 +02:00
Guðni Már Gilbert bb8ebbb5e3 tmc2130: chopconf: simplify intpol config
Pull the preprocessor code outside tmc2130_setup_chopper

No change in memory
2023-07-25 08:56:43 +02:00
Guðni Már Gilbert 2d2ab6e889 tmc2130: chopconf: simplify dedge code
move dedge preprocessing out of tmc2130_setup_chopper

We can use default_dedge_bit to initialise
the dedge bit in the chopconf constuctor later

No change in memory
2023-07-25 08:56:43 +02:00
Guðni Már Gilbert 3842a5c98c optimisation: correctly reset registers in tmc2130_home_exit
Previously Z-axis would not be reset to
TMC2130_GCONF_DYNAMIC_SGSENS
in tmc2130_home_exit() when
TMC2130_STEALTH_Z is defined

Pulled configuration code into one common function
this ensures the registers are set correctly like in tmc2130_init()

Change in memory:
Flash: -206 bytes
SRAM: 0 bytes
2023-07-25 08:56:43 +02:00
Guðni Már Gilbert 60f1c2095f optimise tmc2130_setup_chopper further
Reduce code duplication

Change in memory:
Flash: -50 bytes
SRAM: 0 bytes
2023-07-25 08:56:43 +02:00
Guðni Már Gilbert ae1a7898dc optimisation: use union in for TMC2130 PWMCONF
Simplify writing the value to PWMCONF by
gathering all the bits into one dword.

Change in memory:
Flash: -128 bytes
SRAM: 0 bytes
2023-07-25 08:56:43 +02:00
Guðni Már Gilbert 06100e366c optimisation: use union in tmc2130_setup_chopper
An idea from the MMU FW

Change in memory:
Flash: -278 bytes
SRAM: 0 bytes
2023-07-25 08:56:43 +02:00
Guðni Már Gilbert 6aff3c761b XYZCal: reduce code size in go_manhattan
The variable always takes a value of subtraction
between two int16_t values. It will also fit into int16_t

Change in memory:
Flash: -50 bytes:
SRAM: 0 bytes
2023-07-24 08:15:03 +02:00
Guðni Már Gilbert 5cfdceb184 Remove redundant lcd_draw_update assignment
When scrolling through menu items, the rotation event on the knob
takes care of updating the LCD by setting lcd_draw_update.
The menu code doesn't need to do it as well.

Change in memory:
Flash: -6 bytes
SRAM: 0 bytes
2023-07-24 08:13:36 +02:00
Yuri D'Elia 1fea4a7335 catch2: Fix build with gcc13
Cherrypick of catch2 commit 52066dbc2a53f4c3ab2a418d03f93200a8245451 to
fix the build with gcc 13 without a full update.
2023-07-24 08:07:28 +02:00
Guðni Már Gilbert 57d780ccf9 PFW-1519 Hide Preload to MMU menu item if filament is detected
This is by far the simplest solution to prevent the user from sending
a Load command to the MMU when the FINDA or Filament sensor
is detecting a filament. This may even happen if the sensors are poorly positioned.

Either way a Load in this scenario will make the MMU seem to hang as the
state machine will reject the command.

We could add a full screen message to let the use know
but it would require some memory resources.

For now, just hide the menu item.

Change in memory:
Flash: +16 bytes
SRAM: 0 bytes
2023-07-24 08:05:50 +02:00
Addio d4733664a8
Fixed printer_smodel_check for MK3/S and possible older MMU machines (#4265)
Fixed printer_smodel_check for non MMU machines
Commit 136ef96 broke the compatibility check for MK3S without MMU.

May have fixed bug for older MMU machines.
Only comparing up to the length of the value from the g-code, would return equal on older MMU machines trying to run g-code sliced without the MMU.
Unfortunately if that is a feature, it will cause the different printer warning.
2023-07-21 16:02:32 +02:00
D.R.racer 43c823987c MMU version 3.0.0
PFW-1529
2023-07-20 12:44:29 +02:00
D.R.racer d67fc84b73 Relink MSG_DESC_INSPECT_FINDA in PO files 2023-07-20 12:32:30 +02:00
D.R.racer ffb6a2ae0c Generalize description of MMU MCU power errors
as requested in Prusa-Error-Codes PR#97

There will be more separate sources of MCU power errors in the future and reporting each of them separately doesn't make much sense
- especially when the only thing a user can do about it is to check the connectors.

So based on this, the error title has changed a bit (we are not using the full text description in 8bit FW)

Also, update perform the related changes in PO files + add (machine generated) translations.
2023-07-20 12:32:30 +02:00
Guðni Már Gilbert 03e7ff1983 power panic: optimise incrementing EEPROM statistics
Change in memory:
Flash: -26 bytes
SRAM: 0 bytes
2023-07-18 11:29:03 +02:00
Guðni Már Gilbert 2cd5ab2349 power panic: add readable flags and optimise ISR(INT4_vect)
Add more readable names for the EEPROM_UVLO values

Change in memory:
Flash: -14 bytes
SRAM: 0 bytes
2023-07-18 11:29:03 +02:00
Guðni Már Gilbert 4dc5d97ca9 power panic: remove unused EEPROM_UVLO_Z_MICROSTEPS
It isn't very helpful IMO to have unused code during power panic
it just complicates things.

Change in memory:
Flash: -32 bytes
SRAM: 0 bytes
2023-07-18 11:29:03 +02:00
Guðni Már Gilbert d5125c6b1e power panic: refactor log output on recovery
Use M114 to print coordinates for all axis. We save
a lot of memory by reusing the M114 code

Change in memory:
Flash: -184 bytes
SRAM: 0 bytes
2023-07-18 11:29:03 +02:00
Guðni Már Gilbert 005f9f0d24 power panic: Fix an error in saved position
planner_abort_hard() calls planner_reset_position() which
will set current_position vector to the machine position.
We want to save this position when there is no position already saved
(i.e. when there is no partial back-up or a saved print in RAM)

When a power outage comes, the printer is in the middle of a gcode move.
And at the moment a gcode is executed by the planner, the planner will update
current_position vector to the final destination vector. This means current_position
vector is invalidated during a power outage and so we must check what the
actual machine position is instead and save it.

This was working correctly before, this commit only fixes the regression
in my pull request.

Change in memory:
Flash: -2 bytes
SRAM: 0 bytes
2023-07-18 11:29:03 +02:00
Guðni Már Gilbert 5ee7ba84e3 fix build 2023-07-18 11:29:03 +02:00
Guðni Már Gilbert fa843a4a9b power panic: implement partial back up in RAM
A partial backup is needed in scenarios where the extruder may be
parked after a print is saved. For example during a blocking wait for the user in M600
Or during a MMU error screen.

A sudden power panic at this point would previously save the parked position
into EEPROM. When the print is recovered it would print in mid air.
2023-07-18 11:29:03 +02:00
Guðni Már Gilbert 10ed195531 power panic: use saved position consistently
1) current_position[Z_AXIS] is not always correct. saved_pos[Z_AXIS]
    should always represent the correct resume position for the Z-axis
2) Use the saved position to fetch the Z-offset value from
    the mesh bed leveling grid. In case the extruder is parked during
    power panic, the previous code may extract the wrong mesh
    bed leveling offset (due to extruder being located at different
    X and Y axis coordinates)
2023-07-18 11:29:03 +02:00
Guðni Már Gilbert 392c46c7ad power panic: pull INT4 string into PROGMEM
Change in memory:
Flash: -4 bytes
SRAM 0 bytes
2023-07-18 11:29:03 +02:00
Guðni Már Gilbert 6d902d6437 power panic: store saved_fan_speed in EEPROM
fanSpeed may have an outdated value
2023-07-18 11:29:03 +02:00
Guðni Már Gilbert 44bedcd941 power panic: cleanup: remove commented code 2023-07-18 11:29:03 +02:00
Guðni Már Gilbert 62a3d179f0 optimisation: read/write EEPROM_UVLO_SAVED_START_POSITION block
I verified via printf that sizeof(saved_start_position) = 16 (i.e. 4 float values)
We simply want to write 16 bytes to address
EEPROM_UVLO_SAVED_START_POSITION

Change in memory:
Flash: -160 bytes
SRAM: 0 bytes
2023-07-18 11:29:03 +02:00
Guðni Már Gilbert 6ccd12c7e8 power panic: re-use saved_pos
This allows us to restore the position of all axis saved in RAM

If the extruder had been parked to the side for example
due to filament runout. Then the original position (before parking)
should now be restored

Change in memory:
Flash: +40 bytes
SRAM: 0 bytes
2023-07-18 11:29:03 +02:00
Guðni Már Gilbert 97c27525d4 power panic: re-use saved_extruder_relative_mode
Change in memory:
Flash: +8 bytes
SRAM: 0 bytes
2023-07-18 11:29:03 +02:00
Guðni Már Gilbert a2ac513794 power panic: re-use target temps from RAM
If a print has been saved to RAM such as during a filament runout,
do not overwrite these saved values if a sudden
power panic appears.

Additionally, change the saved types to be the same as power panic when saving to RAM:
- Bed target temperature is uint8_t (0 to 255) instead of float
- Extruder target temperature is uint16_t instead of float

Doing this change allows us to re-use the same global variables and
avoid creating local variables during power panic.

Change in memory:
Flash: -246 bytes
SRAM: -5 bytes
2023-07-18 11:29:03 +02:00
Guðni Már Gilbert b65c500f25 power panic: Add comments about conserving power 2023-07-18 11:29:03 +02:00
Guðni Már Gilbert a45e432030 power panic: Re-use code to save feedrate, segment index, and start position
Saves ~80B of Flash
2023-07-18 11:29:03 +02:00
Guðni Már Gilbert 67403603ed power panic: Re-use saving print file state
This also adds the Gcode position into EEPROM
for Octoprint/PrusaLink prints.
Though the recovery part doesn't support that yet.
2023-07-18 11:29:03 +02:00
Guðni Már Gilbert 2902fcaa71 power panic: Add two functions
These functions should be able to be re-used during a power panic

- save_print_file_state
- restore_print_file_state

No functional change at the moment.
2023-07-18 11:29:03 +02:00
Guðni Már Gilbert 526a1dcc63 power panic: Move code into a separate file 2023-07-18 11:29:03 +02:00
Guðni Már Gilbert 5295bfa040 Remove dead macro timer02_set_pwm0
It looks like it was removed here
https://github.com/prusa3d/Prusa-Firmware/pull/1979
4 years ago

No change in memory
2023-07-14 14:28:14 +02:00
Guðni Már Gilbert b6572066f4 optimisation: compare uint16_t against uint16_t
We're assigning step_rate with the 16-bit value of final_rate
I would expect the comparison to be 16-bit also then.

Change in memory:
Flash: -32 bytes
SRAM: 0 bytes
2023-07-13 11:11:45 +02:00