Commit Graph

649 Commits (f4388b8d2079731438b686b725991fdd64b7b3f7)

Author SHA1 Message Date
D.R.racer f4388b8d20 ToolChange: don't disengage Idler after unload, but engage next slot immediately 2025-12-01 10:48:28 +01:00
D.R.racer 5d8fa524fb Registers: drop support for direct R/W memory. Use R/W functions instead. Saves 56B 2025-12-01 10:48:28 +01:00
D.R.racer 42cb40eeb9 Obey PulleySlowFeedrate in all operations 2025-12-01 10:48:28 +01:00
D.R.racer 06f41bf1e6 Idea: EngageIntermediate before unload and wait for signal 2025-12-01 10:48:28 +01:00
Guðni Már Gilbert b6bdd55def pulley: HomeBack state is never used
Also remove unused FinishHomingAndPlanMoveToParkPos.
2025-12-01 08:52:47 +01:00
Guðni Már Gilbert c1aa190d05 optimise GPIO read/write
Instead of performing a bitwise shift operation on every GPIO read/write. Do it at compile-time and use bit mask instead.

The pin number itself is not used anywhere.

The change saves 108 bytes of flash memory
2025-12-01 08:52:24 +01:00
Guðni Már Gilbert 39b24f8b43 PFW-1480 Process the Mode command 2025-11-05 14:50:26 +01:00
Guðni Már Gilbert 22a8f1df57 main: reduce duplicate code
Change in memory:
Flash: -36 bytes
SRAM: 0 bytes
2025-10-30 07:51:30 +01:00
Alex Voinea 5e50516fe7 Use single banks for CDC 2025-10-30 07:45:38 +01:00
Alex Voinea 454619bfd4 USB manual PLL control 2025-10-30 07:45:38 +01:00
Guðni Már Gilbert f240bb24d1 idler: adjust distance threshold
Before, the axis limits had an error of 25° so 225° would actually be measured as 250°.

Now after fixing axisUnitToTruncatedUnit to return a more accurate value, the new values are lower. Adjust the distances by 20° to offset previous error.
2025-10-30 07:43:35 +01:00
Guðni Már Gilbert 4e4e2df739 Improve accuracy in axisUnitToTruncatedUnit
When converting 800mm/s2, it would be truncated to 795mm/s2 for the pulley. This is due to cutting out significant decimal digits.

Instead let's multiply in floating point, this needs quite a bit of resources. So to optimise against this, multiply with the recoprical. Then the cost is not more than 20 bytes.

Testing:
M707 A0x0e; Read Pulley Acceleration (default at boot up is 800mm/s2)
M708 A0x0e X790 ; Set Pulley Acceleration to 790mm/s2
M707 A0x0e; Read Pulley Acceleration (should be 790mm/s2)

The results before this commit:

M707 A0x0e -> returns 805
M708 A0x0e X790 ; Set Pulley Acceleration to 790mm/s2
M707 A0x0e; returns 795

After this commit:

M707 A0x0e -> returns 799
M708 A0x0e X790 ; Set Pulley Acceleration to 790mm/s2
M707 A0x0e; returns 789

NOTE:
axisUnitToTruncatedUnit is used in Idler homing, selector homing, and pulley positioning. I am not sure yet how this improvement will affect those areas.
2025-10-30 07:43:35 +01:00
Guðni Már Gilbert b8ed9abc7f registers: fix unit of acceleration values
When reading or setting the value, the driver is expecting steps_t which is a axis scaled value.

This increases the memory footprint quite a bit. But now if you set 800mm/s2, you should get a similar value back.

Flash: +132 bytes
SRAM: 0 bytes
2025-10-30 07:43:35 +01:00
gudnimg e28ab28824 registers: support writing axis acceleration value
The read operation now returns the actual used value instead of the maximum allowed acceleration value.

Change in memory:
Flash: + 78 bytes
SRAM: 0 bytes
2025-10-30 07:43:35 +01:00
Guðni Már Gilbert dc68b70cff idler: reduce duplicate code
Change in memory:
Flash: 54 bytes
SRAM: 0 bytes
2025-01-02 11:30:35 +01:00
Guðni Már Gilbert 0eeef4cafd registers: remove obsolete comment
The registers were moved into program memory in FW 3.0.1

See for reference the relevant pull request:
https://github.com/prusa3d/Prusa-Firmware-MMU/pull/287
2024-12-25 10:25:00 +00:00
Guðni Már Gilbert 4ab07d627a optimisation: compare uint16_t against uint16_t
AxisDistance returns uint16_t type and is currently compared with long double axis length. The axis lengths fit easily into uint16_t:

selectorLimits.lenght = 75
idlerLimits.lenght = 225

Change in memory:
Flash: -122 bytes
SRAM: 0 bytes
2024-12-24 13:44:55 +00:00
Guðni Már Gilbert 0a205e41ff optimisation: set enum types explictly to uint8_t
This commit produces the same savings as the compiler options -fshort-enums. Except by setting the types manually we save also 2 bytes of SRAM.

By default, the enum type is 2 bytes, with we can explictly set it to one byte when applicable to reduce code size.

Almost all the savings from from 'enum Mode' in leds.h.

Change in memory:
Flash: -116 bytes
SRAM: -2 bytes
2024-12-24 13:39:41 +00:00
Alex Voinea 3cd341f95f Update comment to reflect changes 2024-03-15 14:09:55 +01:00
Alex Voinea 5d0f772270 Move the version information after the ISR vectors 2024-03-15 14:09:55 +01:00
Alex Voinea 3ee1e22e9a Make the size of the code properly include the version information 2024-03-15 14:09:55 +01:00
Alex Voinea ef23490a49 Add version information at the end of flash 2024-03-15 14:09:55 +01:00
Daniel Čejchan d510e1e482 Add RawProgressCode & ProgressCode::_cnt 2024-01-03 14:25:29 +01:00
D.R.racer 19a0cd3ebb Add cutLength register (0x23) 2023-11-03 14:19:27 +01:00
gudnimg 03b0d6f776 eject filament: remove two unused constants
No change in memory
2023-09-18 07:34:46 +02:00
Guðni Már Gilbert 18a040c278 cut filament: remove two unused constants 2023-09-18 07:34:46 +02:00
3d-gussner c90db080e5 Update to MMU3 2023-08-22 16:11:10 +02:00
Guðni Már Gilbert b9677f922a Optimisation: make constructors constexpr
Cppcheck was complaining some member variables
are not initialised in the constructor.

Change in memory:
Flash: -186 bytes
SRAM: -15 bytes
2023-08-21 06:30:25 +02:00
Guðni Már Gilbert 8e7f3d8b96 optimisation: sg_filter_threshold not initialised in constructor
Caught with Cppcheck

Change in memory:
Flash: -26 bytes
SRAM: 0 bytes
2023-08-21 06:30:25 +02:00
D.R.racer fbda9faa2a Set maximum bowden length to 1m 2023-08-10 16:08:07 +02:00
D.R.racer 11d205484b Update bowden length register documentation 2023-08-10 16:08:07 +02:00
D.R.racer 0419bdefd7 Perform up to maximumBowdenLength while unloading to FINDA
+ update unit tests to match the changed implementation
2023-08-10 16:08:07 +02:00
D.R.racer 19aa7ce2c7 Fixup sizeof register array after rebase 2023-08-10 16:08:07 +02:00
D.R.racer 41f5d29083 Set correct default bowden length 2023-08-10 16:08:07 +02:00
D.R.racer 3a105cab4a Introduce bowden length RW register (no runtime autotune)
contains updated unit tests
2023-08-10 16:08:07 +02:00
D.R.racer 77a8788821 Refactor registers a bit to make unit tests work again 2023-08-10 08:11:52 +02:00
D.R.racer 93a344bde8 Push the compiler into the optimization
It looks like copying the RegisterRec into a local variable (as it has been here before)
seems to confuse the compiler which then refuses to optimize the calls.
With this simple tweak the code is actually 8B shorter than before (while retaining the saved ~170B of RAM)
2023-08-10 08:11:52 +02:00
Guðni Már Gilbert 96985c1502 Fix unit test build
GCC 12 doesn't know AVR pgm_read_ptr()
2023-08-10 08:11:52 +02:00
Guðni Már Gilbert 1661132819 Move MMU registers into PROGMEM
Change in memory:
Flash: +34 bytes
SRAM: -170 bytes
2023-08-10 08:11:52 +02:00
D.R.racer f164a8afa0 Enforce specific ErrorCodes bitmask values 2023-07-28 17:11:43 +02:00
Guðni Már Gilbert 169925fc9f fixup
No change in memory
2023-07-28 17:11:43 +02:00
Guðni Már Gilbert 5293547094 optimisation: Add << operator to ErrorCode
Change in memory:
Flash: -54 bytes
SRAM: 0 bytes
2023-07-28 17:11:43 +02:00
Yuri D'Elia aaee8cab30 CircularIndex: optimize further for non-power-of-two sizes
- Improve count() for non-power-of-two sizes by handling wrap-around
- Improve full() to use always use count(), which is cheaper in both
  scenarios now
2023-07-28 15:48:14 +02:00
Yuri D'Elia 1979d02027 CircularIndex: Fix non-power-of-two sizes
Add back the option to use CircularIndex even for non-power-of-two sizes
for the future.
2023-07-28 15:48:14 +02:00
Guðni Már Gilbert 1633d9af9b Optimise CircularIndex count
No change in memory
2023-06-12 07:42:25 +02:00
Guðni Már Gilbert edec4708b5 MMU-239 Add unit test for FINDA flickering when ejecting filament
The test case test the error recovery on all MMU slots.
2023-06-12 07:39:25 +02:00
Guðni Már Gilbert 48ea52bd47 Minor header cleanup 2023-06-12 07:39:25 +02:00
Guðni Már Gilbert ddc962067c Fix missing ErrorCode::RUNNING
This is needed in case we are recovering
from FINDA_FLICKERS
2023-06-12 07:39:25 +02:00
Guðni Már Gilbert 20a2ee7d56 Fix false FINDA_FLICKERS on Toolchange retry
Delay reporting the cut command finished until the selector has returned
back to the cutting slot. This was done by adding ProgressCode::Homing
to the Cut Filament state machine. ProgressCode::ReturningSelector is
then used to wait for the selector to return back to the cut slot after
homing becomes valid again. Only then is the cut operation reported
finished and a new command can be processed e.g. Toolchange.

Change in memory:
Flash: +16 bytes
SRAM: 0 bytes
2023-06-12 07:04:51 +02:00
3d-gussner 6532a435d2 Update doxygen pulley values 2023-05-05 10:40:51 +02:00