Compare commits

...

225 Commits

Author SHA1 Message Date
3d-gussner f3e0dfd481
Merge pull request #4858 from 3d-gussner/MK3_build_tags
Add `t` and `c` build
2025-08-19 08:52:51 +02:00
3d-gussner 7731024edb
Merge pull request #4859 from 3d-gussner/MK3_Fix_M256
Fix M256 S mode
2025-04-22 22:03:53 +02:00
3d-gussner f915455dae Fix M256 S parameter 2025-04-22 18:42:22 +02:00
3d-gussner 295142a010 Fix semantic versioning 2025-04-16 07:31:41 +02:00
3d-gussner 242bc9d7a8 Prepare also draft releases when `t` or `c` tags are created 2025-04-16 07:20:29 +02:00
3d-gussner 88730dca2a Update github action to build `t` test (Alpha, Beta, RC) and `c` community tags 2025-04-16 06:51:17 +02:00
3d-gussner 66797abf84 Add `c`ommunity tag 2025-04-16 06:08:48 +02:00
3d-gussner 26ed278d02
Merge pull request #4763 from sarusani/RemoveLoadMenuOnAutoload
Remove lcd_menu_AutoLoadFilament
2025-03-10 08:17:12 +01:00
3d-gussner 6c6476cc6c
Merge pull request #4851 from 3d-gussner/MK3_LCD_Brightness
Add M256 [ B | D | S | T ]
2025-02-28 20:00:33 +01:00
3d-gussner a7682997f4 Optimisation, thanks @gudnimg 2025-02-28 07:56:51 +01:00
3d-gussner 34450f52a8 Add M256
- Removed hardcoded values and added
  - LCD_BACKLIGHT_LEVEL_HIGH 130
  - LCD_BACKLIGHT_LEVEL_LOW 50
  - LCD_BACKLIGHT_FORCE_ON 30
  - LCD_BACKLIGHT_TIMEOUT 15
2025-02-26 13:35:29 +01:00
3d-gussner a29c246af1
Merge pull request #4846 from 3d-gussner/MK3_M300_duration_set_4s_limit
M300 set 3.5s duration limit
2025-02-13 10:52:28 +01:00
sarusani 29907639ae Remove lcd_menu_AutoLoadFilament 2025-02-12 11:42:55 +01:00
3d-gussner c40af0c896 M300 set 3.5s duration limit 2025-02-11 17:59:50 +01:00
3d-gussner 9fb034a985
Merge pull request #4847 from 3d-gussner/MK3_action_cache_v4
Change actions/cache to v4
2025-02-11 17:57:34 +01:00
3d-gussner 1965743ba2 Change actions/cache to v4 2025-02-11 17:31:28 +01:00
3d-gussner c798754ec2
Merge pull request #4845 from 3d-gussner/MK3_workflow_atrifacts_v4
Update upload-atrifacts to version 4 as 3 is deprecated
2025-02-11 16:55:27 +01:00
sarusani e80c9fa315 Align MIN_Z raise for unload & load
Align values for load and unload to prevent movement between unload & load operations.
2025-02-11 06:03:43 +01:00
Anna Snoeijs 1a0e0a804f Added description on how to install dependencies on Fedora based distributions 2025-02-11 06:00:32 +01:00
3d-gussner c21dc36507 Update upload-atrifacts to version 4 as 3 is deprecated 2025-02-11 05:55:58 +01:00
3d-gussner e10c8d9c5a Fix rebase issue fix 2024-12-30 13:58:58 +01:00
3d-gussner 477d7ae5ef Add multiscreen message with `Cont.|Cancel`
Remove `Continue?` from some mesages to save "translation space" and replace multiscreen from `Yes|No` to `Cont.|Cancel`
Remove `Print canceled.` from check messages to save again "translation sapce" and after confirming the message the Status Line shows that it has been stopped.

fix rebase issue
2024-12-30 13:58:58 +01:00
3d-gussner ee4d8bb5e5 Fix lcd_status_message_level 2024-12-30 13:57:58 +01:00
3d-gussner 80cb13003e Show filename after SD print finished 2024-12-30 13:57:58 +01:00
gudnimg 901f63e90f remove incomplete dual stepper configuration
If either Y_DUAL_STEPPER_DRIVERS or Z_DUAL_STEPPER_DRIVERS is defined
the compilation will fail with an error message. This configuration will likely
never be fully implemented unless someone from the community steps up.
2024-12-30 13:57:08 +01:00
3d-gussner 3ea620c27a Eject translations in German and Dutch not shorten as it fits now the multiple choice. 2024-12-24 07:52:50 +01:00
3d-gussner a704b99d81 Fix multiple choice
Fixes #4819
2024-12-24 07:52:50 +01:00
gudnimg d3f95592c1 Convert uart2.c to a C++ file 2024-11-27 09:16:41 +01:00
gudnimg 6b01929382 Trim empty lines 2024-11-27 09:16:41 +01:00
gudnimg 4a0973941f Mark uart2_putchar and uart2_getchar as static 2024-11-27 09:16:41 +01:00
gudnimg 51e81217dd Remove unhelpful comments and constants 2024-11-27 09:16:41 +01:00
gudnimg 18bda84876 remove unused function uart2_rx_str_P 2024-11-27 09:16:41 +01:00
3d-gussner b7e3216944
Merge pull request #4811 from 3d-gussner/MK3_new_1st_layer_cal
Optimze and new first layer calibration
2024-11-27 09:10:04 +01:00
3d-gussner b67554eb01 Switch back from `%g` to `.4f`
Set short length so the square is printed in the middle of the bed
Both purge lines with and without MMU end at X=202.5 to get the square in the middle of the bed
2024-11-20 12:10:33 +01:00
Alexandra Voinea 7a47bf30be Fix end of meander overextrusion with new pattern 2024-11-20 09:28:21 +01:00
Alexandra Voinea 24ce71eded Optimize meander moves 2024-11-20 09:11:18 +01:00
Alexandra Voinea 519724b53d Ensure all meander moves are done using relative mode
Without this the first vertical move of the new meander would be slightly longer than expected due to using absolute moves from a negative Y starting position
2024-11-20 08:57:36 +01:00
Alexandra Voinea 81d124affd Minor nitpicks 2024-11-20 08:52:12 +01:00
Alexandra Voinea 13d12c0ffa Get rid of float casts 2024-11-20 08:38:19 +01:00
gudnimg e84ade3542 optimisation: combine a few functions calls into one
Change in memory:
Flash: -34 bytes
SRAM: 0 bytes
2024-11-19 19:50:12 +01:00
Alex Voinea 658df9d04d Extract G91 to messages.h/cpp 2024-11-18 10:12:05 +01:00
Alex Voinea 1319af8a12 Ensure that a correct feedrate is used at all times 2024-11-18 10:09:10 +01:00
Alex Voinea 44f9b953c5 remove unused step parameter in lay1cal sqaure 2024-11-18 09:51:02 +01:00
gudnimg 0b5afa3092 Unload the filament at parked position
We don't want to unload while the nozzle is still smudged against the bed.
2024-11-18 09:45:51 +01:00
gudnimg a0278b2844 Fix an issue where MMU unloads filament while its cooling down
Change in memory:
Flash: -6 bytes
SRAM: 0 bytes
2024-11-18 09:45:51 +01:00
3d-gussner d1470d8abc New first layer calibration
- changed to relative mode to save buffer and code size
- added NEW_FIRST_LAYER_CAL to perform 1st layer cal from front to back
2024-11-14 14:45:25 +01:00
3d-gussner d8d058a63b
Add Set parameter in M78 Statistics gcode (#4809)
* Add Set Statistics

* EEPROM_FILAMENTUSED is in centimeter and not meter
Fix few things

* Fix typo
2024-11-14 08:20:39 +01:00
3d-gussner 0fb17b1643
Merge pull request #4805 from 3d-gussner/MK3_Fix_MMU
Remove hardcoded MMU tool count
2024-11-10 11:56:55 +01:00
3d-gussner cdb6635eac Remove hardcoded MMU tool count
- Preload to MMU -> All
- Loading Test -> All
- SpoolJoin
2024-10-29 15:50:01 +01:00
3d-gussner ef3527eb0f
Merge pull request #4782 from 3d-gussner/MK3_3141_po
Update po files
2024-09-24 16:45:16 +02:00
3d-gussner 21084af026 Update po files 2024-09-24 16:37:43 +02:00
3d-gussner 24bfa8db59
Merge pull request #4780 from leptun/MBL_relax_tight_thresholds
Further relax the MBL tight threshold
2024-09-24 13:47:02 +02:00
Alex Voinea f12683f3ff Further relax the MBL tight threshold 2024-09-24 10:33:23 +02:00
3d-gussner aa4de7ae7e
Merge pull request #4773 from 3d-gussner/MK3_fix_unload
PFW-1561 Fix MMU unload issue
2024-09-23 07:39:18 +02:00
3d-gussner 402b9ed93a Add `#ifdef FANCHECK` thanks @gudnimg 2024-09-23 07:00:17 +02:00
3d-gussner 65a26e882b Enable Tune menu during fan check issues, user can then disable the fan check if needed.
Send //action:cancel when LCD Stop print is selected.
2024-09-18 16:09:46 +02:00
3d-gussner 29c920c801 Fix MMU unload issue after a fan check issue has been solved 2024-09-18 16:09:46 +02:00
3d-gussner ab5c7ac6c6
Merge pull request #4772 from gudnimg/FW-1562
PFW-1562 Fix an issue where safety timer is not handled correctly in `mFilamentPrompt` menu
2024-09-17 16:30:37 +02:00
gudnimg de092b35d5 PFW-1562 Fix an issue where safety timer is not handled correctly in mFilamentPrompt menu 2024-09-15 10:28:10 +00:00
3d-gussner 5aa67489da
Merge pull request #4768 from 3d-gussner/MK3_3141_test_prep
Prepare FW 3.14.1 for testing
2024-09-04 09:54:21 +02:00
3d-gussner 7d3032c001 Bump up version to FW3.14.1-RC1-8225 2024-09-04 09:33:47 +02:00
3d-gussner 2c621e025a Update pot and po files 2024-09-04 09:32:30 +02:00
3d-gussner 6ea47967da
Merge pull request #4765 from leptun/MBL_fixes
Region MBL fixes
2024-09-04 07:42:48 +02:00
3d-gussner 4e9e20c67f
Merge pull request #4766 from gudnimg/remove-sm4_line_xyze_ui
Remove sm4 line xyze UI
2024-09-03 15:22:56 +02:00
3d-gussner 2fed2f00f7
Update Czech translation
Thanks to @DRracer
2024-09-03 13:27:53 +02:00
3d-gussner 1c0a59f7c9
Update Hungarian translation
Thanks to @AttilaSVK
2024-09-03 11:47:14 +02:00
3d-gussner 3facdb4576 Add new message and translations 2024-09-03 09:34:18 +02:00
Alex Voinea cb502ee7bc Update MSG_MBL_FAILED translations
Thanks @3d-gussner
2024-09-03 09:28:16 +02:00
Alex Voinea b614b9c43d Do not prompt for steel sheet on bed during XYZ calibration
Thanks @3d-gussner
2024-09-03 09:28:16 +02:00
Alex Voinea b58d2ecccb Prompt user for Z calibration after failed MBL with yes-no screen 2024-09-03 09:28:15 +02:00
Alex Voinea 357b68cf76 Ask for steel sheet on bed during Z calibration 2024-09-03 09:28:15 +02:00
Alex Voinea d2119c24e1 Prompt Z calibration when 7x7 MBL is enabled 2024-09-03 09:28:15 +02:00
Alex Voinea 8196e48684 Reduce number of Z realignments before Z calibration is requested 2024-09-03 09:28:15 +02:00
Alex Voinea d8e3c2b481 Relax 3x3 MBL threshold 2024-09-03 09:28:15 +02:00
3d-gussner 83c43fba02
Merge pull request #4767 from gudnimg/linearity-correction-opt-v2
optimisation: Simplify saving linearity correction
2024-09-02 11:18:44 +02:00
Guðni Már Gilbert b3a682d330 Always re-init the TMC drivers after leaving linearity correction menu
Change in memory:
Flash: -22 bytes
SRAM: 0 bytes
2024-09-01 22:14:25 +00:00
gudnimg 312f79c5f5 optimisation: Simplify saving linearity correction
Keep in mind that the EEPROM addresses are in descending order. This means we
can't use eeprom_read_block() or eeprom_update_block()

Address --> Axis
3831 --> X-axis
3830 --> Y-axis
3829 --> Z-axis
3828 --> E-axis

Change in memory:
Flash: -118 bytes
SRAM: 0 bytes
2024-09-01 12:34:00 +00:00
Guðni Már Gilbert aa8569600c Fix build and make sm4 a C++ file 2024-09-01 12:12:24 +00:00
Guðni Már Gilbert a2d45e5d11 cleanup: remove unused global sm4_cpu_time 2024-09-01 12:11:56 +00:00
Guðni Már Gilbert f115adf894 cleanup: remove unused function sm4_get_dir 2024-09-01 12:11:56 +00:00
Guðni Már Gilbert 5a5c68f563 cleanup: remove unused function sm4_get_dir_bits 2024-09-01 12:11:56 +00:00
Guðni Már Gilbert 7d3c416d04 cleanup: remove unused function sm4_line_xyze_ui
No change in code size. Reason for removing this function
is just to reduce lines of code that is maintained.
2024-09-01 12:11:22 +00:00
3d-gussner 6c99a4463e
Merge pull request #4755 from sarusani/AddLoadIfAutoloadDisabled
Add "load filament" if autoload is disabled
2024-08-30 17:11:37 +02:00
sarusani a259482b6b Add load option if autoload is disabled 2024-08-30 14:48:45 +02:00
3d-gussner 923f926223
Merge pull request #4749 from gudnimg/remove-auto-bed-leveling
Remove legacy Auto Bed Leveling code
2024-08-30 10:44:50 +02:00
3d-gussner d3c326de99
Merge pull request #4727 from gudnimg/improve-missing-filament
PFW-1559 Add filament presence check at start of print
2024-08-30 10:44:05 +02:00
Guðni Már Gilbert af6fbb13de
Merge pull request #8 from 3d-gussner/MK3_fix_PR4727
Fix LCD output and add translations
2024-08-30 08:35:27 +00:00
3d-gussner 56de4bf53b Update Community translation list
- Croatian, Swedish and Norwegian are inactive since the last few translation review requests have not been done
2024-08-30 08:14:23 +02:00
3d-gussner b9b32b0d9f Update Slovak translation
Thanks to @ingbrzy @shatter136
2024-08-28 12:07:20 +02:00
3d-gussner 6af6b402cc Update Czech and Italian translations
Thanks to @DRRacer and @wavexx
2024-08-28 11:29:28 +02:00
3d-gussner 1a717986c1 Update Hungarian translation
Thanks to @AttilaSVK
2024-08-27 07:11:32 +02:00
3d-gussner 6fa80045b5 Another Dutch translation fix 2024-08-26 14:15:31 +02:00
3d-gussner ff9a476121 Update Dutch translation
Thanks to @stelgenhof
2024-08-26 14:13:28 +02:00
3d-gussner e90b536c9b Update Romainian translations
Thanks to @petrubecheru and @Hauzman
2024-08-26 13:46:23 +02:00
3d-gussner b353f1f008 Add missing translations
Used `trans -b :cs+de+es+fr+hr+hu+it+nl+no+pl+ro+sk+sv "<text>"` to translate
Looked at pre-translated text to reuse as much as possible.
2024-08-26 10:02:56 +02:00
3d-gussner c1360d7bfb Fix LCD output
Configuration->HW Setup->Checks showed `a`

MSG_FILAMENT `Filament` can only be 8 chars long and only ES and IT had `Filemanto` as translation.
But as ES the `o` in `Filamento` was overwritten by `[Estricto]` I removed the MSG_FILAMENT to be translated.
Saves few bytes.
2024-08-26 09:20:05 +02:00
gudnimg f7e3195d78 Remove CUSTOM_M_CODES define 2024-08-24 16:33:00 +00:00
Guðni Már Gilbert 2b1c49dae2 Remove legacy Auto Bed Leveling code
The goal is to clean up the project
2024-08-24 07:11:38 +00:00
Guðni Már Gilbert f5fe658728 fixup after rebase 2024-08-24 07:10:24 +00:00
Guðni Már Gilbert 5e66e71a48 Check if MMU is enabled by reading EEPROM 2024-08-24 07:10:24 +00:00
gudnimg 4ed5b36199 Use a fresh EEPROM cell for the new value 2024-08-24 07:10:24 +00:00
gudnimg 40d3830e6d Simplify filament_presence_check usage
Pull all checks needed into the function such that the caller
only needs to check the return value

Also added description for the filament_presence_check function
2024-08-24 07:10:23 +00:00
gudnimg 75c980c4e7 optimisation: deduplicate more code
Change in memory:
Flash: -54 bytes
SRAM: 0 bytes
2024-08-24 07:10:23 +00:00
Guðni Már Gilbert b7caf36207 optimisation: deduplicate printer check toggle menus
This saves ~100B of flash
2024-08-24 07:10:23 +00:00
Guðni Már Gilbert bf72ecc3f9 Add filament presence check at start of print
A new menu setting is added to configure how strict the check should be.

- None: No check is performed
- Warning (default): The user is warned about missing and is prompted to continue with Yes/No. If No is selected, the print is aborted. If no user input is given (e.g. from host printing) then the warning will expire in 30 seconds and assume the Yes option was selected
- Strict: If the filament is not detected when a print is started, it is immediately canceled.

The check is currently performed on G-codes: M24 and M75. Starting a SD print and Host print respectively.
2024-08-24 07:10:23 +00:00
3d-gussner 055f601ad3
Merge pull request #4751 from sarusani/FilamentRunoutActions
Send host actions on filament runout
2024-08-23 15:13:08 +02:00
3d-gussner 96d6192be5
Merge pull request #4760 from 3d-gussner/MK3_New_github_issue_templates
New GitHub issue templates
2024-08-23 14:52:02 +02:00
3d-gussner d3cec58a7a
Merge pull request #4761 from 3d-gussner/MK3_MMU303
Update MMU version to 3.0.3
2024-08-23 14:40:41 +02:00
3d-gussner 8fe73a0dc2 Update to MMU FW 3.0.3 2024-08-23 14:31:49 +02:00
3d-gussner c27fb616e0
Merge pull request #4737 from sarusani/ReplaceSetReadyMenuEntry
Allow to replace Set Ready menu entry
2024-08-23 14:30:44 +02:00
3d-gussner 7d66cd1ca0
Merge pull request #4758 from sarusani/CheckFSBeforeNozzleChange
Abort nozzle change if filament is loaded
2024-08-23 11:18:28 +02:00
sarusani a2022471ce Send host actions on filament runout 2024-08-23 10:44:38 +02:00
sarusani a9e7f387e8 Replace Set Ready menu entry
Replace "Set Ready"/"Set nor Ready" menu entry with "Print from host" entry.
Use "action:start" instead of "action:ready"
2024-08-23 10:24:01 +02:00
sarusani 64d9f201da Exit Nozzle Change if filament is loaded
Abort Nozzle change if fsensor is enabled and filament is present.
2024-08-23 10:12:01 +02:00
3d-gussner 2f7715a0b0
Merge pull request #4759 from Panayiotis-git/MK3_M600_Filament_name
PFW-1204: M600 - Show filament name at the Insert filament prompt
2024-08-22 16:26:58 +02:00
3d-gussner 0e84d0bb41 Update some text 2024-08-22 14:45:15 +02:00
Panayiotis-git 815b68678d M600 - Show filament name at the Insert filament prompt 2024-08-21 20:56:13 +03:00
3d-gussner f64f2bbe68
Merge pull request #4747 from gudnimg/minor-fixes-for-future-tests
Fix compiler warning and add missing includes in unit test environment
2024-08-20 11:14:06 +02:00
3d-gussner e2e6999887
Merge pull request #4753 from gudnimg/remove-HEATER_BED_DUTY_CYCLE_DIVIDER
Remove dead configuration `HEATER_BED_DUTY_CYCLE_DIVIDER`
2024-08-19 08:47:22 +02:00
Guðni Már Gilbert 3da141b3a7 Remove dead configuration HEATER_BED_DUTY_CYCLE_DIVIDER
Setting HEATER_BED_DUTY_CYCLE_DIVIDER has no effect on the firmware
2024-08-15 17:58:07 +00:00
3d-gussner 21fc1ddf00
Merge pull request #4750 from sarusani/LessZAxisMovementOnManualFilamentUnload
Lower MIN_Z_FOR_UNLOAD
2024-08-14 13:03:32 +02:00
sarusani d3f2dce430 Lower MIN_Z_FOR_UNLOAD
Sync value with Buddy firmware
2024-08-14 12:09:41 +02:00
3d-gussner 2f9dafcf97 Fix even more syntax 2024-08-14 11:16:49 +02:00
3d-gussner dad1e4081e Fix more syntax issues 2024-08-14 11:08:47 +02:00
3d-gussner be6c85cf0c Fix syntax 2024-08-14 11:04:39 +02:00
3d-gussner 8b2074e808 New github issue templates 2024-08-14 10:40:31 +02:00
Guðni Már Gilbert 80f27618c9 Marlin: drop lcd.h include
Only include it where needed
2024-08-13 23:40:18 +00:00
Guðni Már Gilbert 41245b2a59 Marlin: drop mmu2.h include
We should only be including it where needed
2024-08-13 23:26:09 +00:00
Guðni Már Gilbert 835caa0230 mesh_bed_calibration: drop Marlin.h include 2024-08-13 23:23:21 +00:00
Guðni Már Gilbert 0153eb05a1 util: add stdio.h include for sprintf_P 2024-08-09 14:57:07 +00:00
Guðni Már Gilbert a1fcb8564e util: reorder includes alphabetically
Place system includes on top
2024-08-09 14:57:07 +00:00
gudnimg f628c5f912 util: should include avr/eeprom.h
The file is calling eeprom_read_byte and should include avr/eeprom.h
2024-08-09 14:57:07 +00:00
gudnimg 9ae8beacc6 eeprom: add missing include stddef.h
Fixes compiler warning in test environment:

Prusa-Firmware/Firmware/eeprom.h:712:51: error: ‘size_t’ has not been declared
712 | bool eeprom_is_initialized_block(const void *__p, size_t __n);
      |
2024-08-09 14:57:07 +00:00
gudnimg ad1e3cb12a Configuration: missing stdint.h include
The following error is raised in unit testing environment:

Prusa-Firmware/Firmware/Configuration.h:16:14: error: ‘uint16_t’ does not name a type
   16 | extern const uint16_t _nPrinterType;
2024-08-09 14:57:07 +00:00
gudnimg 10d156b28c tests: Fix a compiler warning in tests -fpermissive
Prusa-Firmware/tests/../Firmware/util.h:114:25: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive]
  114 |         pStrEnd = strchr(this->ptr, '"');
      |                   ~~~~~~^~~~~~~~~~~~~~~~
      |                         |
      |                         const char*
2024-08-09 14:57:07 +00:00
3d-gussner 428091b7c7
Merge pull request #4736 from gudnimg/cleanup_recursion_hack
Remove recursion workaround in Nozzle Change
2024-08-08 11:17:28 +02:00
3d-gussner 80148a862d
Merge pull request #4744 from 3d-gussner/MK3_Update_Stale_bot
Update Stale bot message
2024-08-07 06:48:43 +02:00
3d-gussner bf19b34e11
Merge pull request #4746 from gudnimg/fix-broken-unit-tests-pipeline
tests: test_run_all target must depend on tests executable
2024-08-06 14:58:47 +02:00
gudnimg 0a60eb435c tests: test_run_all target must depend on tests executable
Otherwise the tests and Catch2 isn't built
2024-08-06 10:29:44 +00:00
3d-gussner ebbd58c6e2
Merge pull request #4733 from gudnimg/upgrade-ninja
Upgrade ninja from 1.10.2 to 1.12.1
2024-08-06 06:19:06 +02:00
3d-gussner ed3867ab09
Merge pull request #4745 from gudnimg/readme_update
Update Python version in README
2024-08-06 06:11:21 +02:00
Guðni Már Gilbert b2c17960df Update Python version in README
Python 3.6 and 3.7 are EOL
2024-08-05 17:16:10 +00:00
3d-gussner decebab9d4 Update Stale bot message 2024-08-05 09:36:27 +02:00
Guðni Már Gilbert c795b3956c
Merge pull request #4741 from gudnimg/cleanup_followup_gudni
PR 4739 follow-up (two things were missed)
2024-08-03 20:11:59 +00:00
gudnimg efc4cc4996 Remove unused enum MeshLevelingState 2024-08-03 16:48:08 +00:00
gudnimg 15670f21bd lcd_pick_babystep() doesn't exist anywhere 2024-08-03 16:32:41 +00:00
gudnimg 371c040e8a EEPROM_BABYSTEP_Z0 is no longer used anywhere in the code base 2024-08-03 16:32:20 +00:00
Guðni Már Gilbert 25a11bb7d7 Forbid LcdUpdateDisabler to call lcd_update()
The fixes a scenario where:

lcd_status_screen() calls lcd_commands() upon exiting
lcd_show_fullscreen_message_and_wait_P(_T(MSG_NOZZLE_CNG_READ_HELP));
and so not allowing the user to leave the screen since it will keep being rendered endlessly.

This change only affects lcd_show_fullscreen_message_and_wait_P
2024-08-03 15:43:08 +00:00
Guðni Már Gilbert f96cc2f400 cleanup recursion workaround in nozzle change
This fix is no longer needed today.

LCD knob clicks / and rotation, take care of updating lcd_draw_update.

The real bug was likely lcd_show_multiscreen_message_yes_no_and_wait_P calling lcd_update(), this is fixed now since.
2024-08-03 15:43:08 +00:00
Guðni Már Gilbert 48f7cd5270 Upgrade ninja from 1.10.2 to 1.12.1
The update brings better support for Windows :)

Changelogs:
* https://github.com/ninja-build/ninja/releases/tag/v1.12.1
* https://github.com/ninja-build/ninja/releases/tag/v1.12.0
* https://github.com/ninja-build/ninja/releases/tag/v1.11.1
* https://github.com/ninja-build/ninja/releases/tag/v1.11.0
2024-08-03 15:38:02 +00:00
Guðni Már Gilbert a926675c35 bootstrap: fix DeprecationWarning
DeprecationWarning: Python 3.14 will, by default, filter extracted tar archives and reject files or modify their metadata. Use the filter argument to control this behavior.

See:
https://docs.python.org/3.12/library/tarfile.html#tarfile-extraction-filter
2024-08-03 15:38:02 +00:00
Guðni Már Gilbert ff16bfd8fa
Merge pull request #4739 from gudnimg/prune-disabled-code
Remove a bit of unused code which is disabled at compile time
2024-08-03 10:34:40 +00:00
Guðni Már Gilbert 23f92b24b8
Merge pull request #4735 from gudnimg/cleanup-dead-variable
Remove commented variable `load_filament_time`
2024-08-02 16:10:17 +00:00
Guðni Már Gilbert 04a7175cc7 Remove LARGE_FLASH preprocessor symbol
It's not very useful as is ... probably remnant from Marlin 1
2024-07-31 12:06:35 +00:00
Guðni Már Gilbert 81f1ec4975 Remove unused messages 2024-07-31 11:57:49 +00:00
Guðni Már Gilbert 0d45228dbd Remove commented lcd_update_enable(true) 2024-07-31 11:15:39 +00:00
gudnimg 396a8ca4f9 Remove VT100 code 2024-07-31 10:35:18 +00:00
gudnimg eb7969441a Remove Servo..h/cpp 2024-07-31 10:31:05 +00:00
gudnimg 2cbbdbacd5 Remove a bit of unused code which is disabled at compile time
Some of these have been used > 6 years and don't compile anymore.

Reason to want this removed is just to reduce the code we maintain
2024-07-31 09:53:45 +00:00
Guðni Már Gilbert 3f650a24aa
Merge pull request #4738 from sarusani/OptimzeEnum
Add type to enum
2024-07-30 20:01:17 +00:00
sarusani d485e4fb0b Add type to save 50B
Saves 50bytes
2024-07-30 15:15:05 +02:00
Guðni Már Gilbert bb1bb4d717 Remove commented variable load_filament_time 2024-07-28 17:41:23 +00:00
3d-gussner 5119e47419
Merge pull request #4728 from gudnimg/fix-mFilamentPrompt-timeout
Fix regression introduced in 3.13.0 where `mFilamentPrompt` menu times out after 30 seconds
2024-07-26 15:33:12 +02:00
gudnimg 8382815110 Fix inconsistent indendation in mFilamentPrompt() 2024-07-26 11:55:32 +00:00
gudnimg faa01b5a5f Fix an issue where mFilamentPrompt menu times out
Fixes a regression introduced in 3.13.0 here: a7e9ccfb57 (diff-5fbfdca43c192573e31d8e78d255c510fb6e213b118cf38173277ec2a2163880R7462)

Before 3.13.0, the menu never timed out until the safety timer turned off the heaters
After 3.13.0, the menu times out after 30 seconds.

The commit restores pre-3.13.0 behavior
2024-07-26 11:52:20 +00:00
3d-gussner cea5f70974
Merge pull request #4710 from Tirpitz93/fix-dev-and-dirty-cmake
Fix String substitution when `DEV` flavour is built dirty
2024-07-25 08:46:28 +02:00
3d-gussner 3722a17e5a
Merge pull request #4647 from gudnimg/mmu-sync-april
MMU maintenance: Sync with 32-bit FW a little bit
2024-07-24 10:02:24 +02:00
gudnimg 4dc9fd4972 MMU: revert fallthrough in LogicStep 2024-07-23 15:55:47 +00:00
3d-gussner 3cb722403b
Merge pull request #4717 from gudnimg/fix-unconsumed-button-press
Fix an issue in manual fan check where prior knob clicks are not consumed
2024-07-16 08:57:30 +02:00
gudnimg a7004cd067 Fix an issue in manual fan check where prior knob clicks are not consumed 2024-07-15 13:52:30 +00:00
3d-gussner 39c8c4f560
Merge pull request #4659 from 3d-gussner/MK3_build_script
PFW-1460 Update build scripts
2024-07-12 08:36:32 +02:00
3d-gussner 62a1c1478d
Merge pull request #4708 from 3d-gussner/MK3_Cmake_workaround_wildcard_issue_non_Linux
Cmake workaround wildcard issue non linux system
2024-07-12 08:35:34 +02:00
3d-gussner 2ed3ee8410
Merge pull request #4280 from sarusani/DelayZAxisonAutoload
Delay Z-Axis on Autoload
2024-07-11 09:00:50 +02:00
lselter 695ba5d5db Fix String substitution when `DEV` flavour is built with a dirty local version both instances of -D were replaced with commit count 2024-07-09 15:44:40 +01:00
3d-gussner f687fe3e2e Fix MK2.5/S builds on Windows 2024-07-09 16:07:02 +02:00
3d-gussner d769fcc094 Workaround for Windows/Mac wildcard issue
Only zip MK2.5/S and E3DREVO on Linux
2024-07-09 15:43:52 +02:00
gudnimg 99e306f4a3 MMU: minor formatting sync 2024-07-06 17:24:40 +00:00
gudnimg d548bb68fd MMU: revert WaitForHotendTargetTempBeep(); position in code
The 8-bit FW uses a different Fullscreen UI which doesn't show the current temperature. So, for now, keep calling WaitForHotendTargetTempBeep  before showing the full-screen message.
2024-07-06 16:55:32 +00:00
Guðni Már Gilbert 09f1d85e9c MMU: Revert changes to execute_extruder_sequence loop
The previous for-loop is more memory efficient and saves 20 bytes of Flash
2024-07-06 16:55:32 +00:00
Guðni Már Gilbert 61b4270129 MMU: allow inlining UInt16ToHex
Saves 22 bytes of Flash
2024-07-06 16:55:32 +00:00
Guðni Már Gilbert 592fc56bfc MMU: Sync code with 32-bit
The changes in this commit are mainly formatting

But there are some changes like adding a new function planner_draining()
2024-07-06 16:55:32 +00:00
sarusani 5efae44eb7 Delay Z-Axis on Autoload
Delay z-axis movement when the operators hand is close to the printhead.
2024-07-05 16:12:07 +02:00
3d-gussner 72ffc28952 Add build.py 2024-07-05 09:06:22 +02:00
3d-gussner e405e9140c
Merge pull request #4687 from 3d-gussner/MK3_Replace_hard_coded_values_1
Replace hardcoded values
2024-07-05 07:54:07 +02:00
3d-gussner bc48d34a2f Replace hradecoded XYZ Z correction value with Z_MAX_POS_XYZ_CALIBRATION_CORRECTION 2024-07-04 10:12:38 +02:00
3d-gussner 152b290d1d
Merge pull request #4689 from 3d-gussner/MK3_PFW-964
PFW-964: Skip filament unload/load after Shipping factory reset
2024-07-03 13:20:49 +02:00
3d-gussner 3c7ae1e9fc
Merge pull request #4690 from 3d-gussner/MK3_Documentation
Update doxygen documentation remove white spaces
2024-05-30 14:43:29 +02:00
3d-gussner ac63fafc33
Merge pull request #4696 from 3d-gussner/MK3_Fix_cmake_MK25S_build
Fix cmake build of MK2.5 and MK25S
2024-05-30 14:42:13 +02:00
3d-gussner db64997687 Add `${FW_LANG_PATCH}.bin` to DEPENDS 2024-05-30 08:21:51 +02:00
3d-gussner 827c3025a4 Fix cmake build of MK2.5 and MK25S 2024-05-29 18:01:53 +02:00
3d-gussner 45a223a1f9 Remove White spaces 2024-05-20 19:09:03 +02:00
3d-gussner e110153ee2 Cleanup doxgen documentation and white spaces 2024-05-20 18:35:09 +02:00
3d-gussner 9a56f1e4c1 Skip filament unload/load after Shipping factory reset
when MMU is enabled. With MMU enabled no filament should be
loaded while idle.
2024-05-16 12:48:49 +02:00
3d-gussner eaeb722adb
Merge pull request #4681 from gudnimg/add-workaround-for-tune-button
MMU: Add workaround for broken Tune button
2024-05-06 12:50:41 +02:00
Guðni Már Gilbert 6f915ee401 MMU: Add workaround for broken Tune button
If the MMU is processing a command, the Tune button can't be executed.

Change in memory:
Flash: +16 bytes
SRAM: 0 bytes
2024-05-04 00:22:17 +00:00
3d-gussner abdee5b7f3
Merge pull request #4679 from 3d-gussner/MK3_Crash_detect_raise_z
Replace hard coded crash z lift value with Pause Z lift value.
2024-05-03 08:08:48 +02:00
3d-gussner 08d26fdee2 Replace hard coded crash z lift value with Z lift value.
With `M125 Z<value>` you can set the Z lift value via gcode as requested.
Fixes #3419
2024-05-02 11:37:13 +02:00
gudnimg 28502a2b6e optimisation: remove 1 more call to __divsf3
Changing (feedrate * feedmultiply) / 6000.f
to (feedrate * feedmultiply) * (1.f / 6000.f)

Replaces the call to __divsf3 with __mulsf3 which is better

No change in memory
2024-04-23 09:18:45 +02:00
Guðni Már Gilbert 2c46e1b344 optimisation: remove 3 calls to __divsf3
Change in memory:
Flash: -34 bytes
SRAM: 0 bytes
2024-04-23 09:18:45 +02:00
3d-gussner d22245b482
Merge pull request #4658 from 3d-gussner/MK3_PFW-762_Ambient_shutdown_80C
PFW-762 ambient shutdown at 80 C
2024-04-19 15:06:03 +02:00
3d-gussner e8d55486fe
Merge pull request #4661 from gudnimg/PFW-1557
PFW-1557 MMU: Improve unload handling when print is aborted
2024-04-15 15:13:09 +02:00
3d-gussner 6e40fe05fc
Merge pull request #4657 from 3d-gussner/MK3_PP_ACCEL_JERK
Add max acceleration mm per s2, feedrates and jerk save and restor du…
2024-04-15 15:11:57 +02:00
3d-gussner 34591f0465
Merge pull request #4663 from 3d-gussner/MK3_Fix_Autoreport
Fix Autoreport
2024-04-15 15:06:12 +02:00
3d-gussner 51b119a3ec Fix Autoreport broken in 3957dc91aa 2024-04-15 12:09:43 +02:00
3d-gussner 1292a82f70 Fix typos 2024-04-15 07:45:36 +02:00
3d-gussner f50e754f26 Use of `eeprom_update_block_notify` and `eeprom_read_block` reduces the flash usage a lot.
Thanks to @gudnimg
2024-04-15 07:45:36 +02:00
3d-gussner 5c0e014215 Add max acceleration mm per s2, feedrates and jerk save and restor during power panic
Thanks to @wavexx in #2456
2024-04-15 07:45:36 +02:00
gudnimg 16dfcfeb9a MMU: Improve unload handling when print is aborted
- Don't allow re-heating the nozzle or the MMU to unload the filament if the print was aborted by a temperature error
- Allow MMU to unload filament if there is no temperature error, and there is no fan error when Fan check is enabled
- When Fan check is disabled, the MMU may unload if there is no temperature error

Change in memory:
Flash: +14 bytes
SRAM: 0 bytes

PFW-1557
2024-04-14 12:07:56 +00:00
3d-gussner 52ac95f082
Merge pull request #4600 from sarusani/ChangeRevoNozzleChangeMenu
Adjust Nozzle Change Menu For Quick Change Nozzles
2024-04-11 19:19:01 +02:00
3d-gussner 361ce65e5c
Merge pull request #4644 from sarusani/AddEjectToFilamentLoadMSG
Add Eject Option To Filament Load Message
2024-04-11 19:18:42 +02:00
3d-gussner 36282aae1b Change Ambient board thermistor safety shutdown to 80 C 2024-04-10 17:56:26 +02:00
3d-gussner 5b96ff6d37
Merge pull request #4656 from 3d-gussner/MK3_PP_EXT_MINTEMP
Add Extrude mintemp save and restore during power panic
2024-04-09 18:44:47 +02:00
sarusani bc04f16906 Adjust Nozzle Change Menu For Quick Change Nozzles
- Show warning if extruder temp is > 40 degrees
- Use fan to speed up cooldown
- Show confirmation msg
- Show nozzle diameter setting after nozzle change
2024-04-09 16:12:46 +02:00
sarusani bd935db31e Add Eject Option To Filament Load Message 2024-04-09 15:50:17 +02:00
3d-gussner e5d504b855 Add Extrude mintemp save and restore during power panic
Thanks to @wavexx in #3008
2024-04-09 09:34:24 +02:00
3d-gussner 02822c59ad
Merge pull request #4591 from gudnimg/cleanup_cancel_heatup
Remove redundant ` cancel_heatup` assignment
2024-04-09 08:17:09 +02:00
3d-gussner fbbcdd0808
Merge pull request #4613 from gudnimg/optimise-axis_ustep_resolution
optimisation: initialise `axis_ustep_resolution` in EEPROM
2024-04-08 16:13:52 +02:00
Guðni Már Gilbert 022eaa1820
Merge pull request #4645 from gudnimg/full-screen-code-duplicate
ultralcd: merge two functions into one as cleanup
2024-04-06 13:50:48 +00:00
3d-gussner ed9d7f3ac1 ultralcd: merge two functions into one
lcd_show_fullscreen_message_yes_no_and_wait_P and lcd_show_multiscreen_message_yes_no_and_wait_P
are the same function. Let's drop one of them so we only have one symbol for the function.

No change in memory

Fix rebase
2024-04-05 19:33:15 +02:00
3d-gussner a4a7b09fe7
Merge pull request #4651 from 3d-gussner/MK3_Fix_Insert_filament_fr_hu
Fix issue Insert filament ... message in French and Hungarian
2024-04-04 09:20:48 +02:00
3d-gussner c515038e7d
Merge pull request #4650 from 3d-gussner/MK3_LCD_Menu_cleanup
LCD_Menu_cleanup
2024-04-04 09:19:50 +02:00
3d-gussner feebac54fc Fix issue #4424
Fix rebase
2024-04-04 09:08:44 +02:00
3d-gussner b3a410abdc Fix #3361 2024-04-04 09:04:48 +02:00
Guðni Már Gilbert 0a727d8573 optimisation: initialise axis_ustep_resolution in EEPROM
When the cs variable is loaded into RAM, cs.axis_ustep_resolution will always have some value and none of the 0xff values.

Change in memory:
Flash: -40 bytes
SRAM: 0 bytes
2024-02-24 15:46:32 +00:00
gudnimg 020239687a Remove redundant cancel_heatup assignment
cancel_heatup is set to false inside wait_for_heater()
there is no need to do it before the function call

Change in memory:
Flash: -4 bytes
SRAM: 0 bytes
2024-02-04 12:15:58 +00:00
174 changed files with 11337 additions and 14810 deletions

View File

@ -1,34 +0,0 @@
---
name: Bug report
about: Create a report to help us improve
title: "[BUG]<Enter comprehensive title>"
labels: bug
assignees: ''
---
<!--
Please, before you create a new bug report, please make sure you searched in open and closed issues and couldn't find anything that matches.
-->
**Printer type** - [e.g. MK3S, MK3, MK2.5S, MK2.5, MK2S, MK2]
**Printer firmware version** - [e.g. 3.8.1, 3.8.1-RC1, ...]
**MMU upgrade** - [e.g. MMU2S, MMU2, MMU1]
**MMU upgrade firmware version** - [e.g. 1.0.6, 1.0.6-RC2, ...]
**SD card or USB/Octoprint**
Please let us know if you print via SD card or USB/Octoprint
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Please describe steps to reproduce the behavior.
**Expected behavior**
A clear and concise description of what you expected to happen.
**G-code**
Please attach a G-code. This will make it easier for us to replicate the error.
**Video**
Please attach a video. It usually helps to solve the problem.

96
.github/ISSUE_TEMPLATE/bug_report.yml vendored Normal file
View File

@ -0,0 +1,96 @@
name: Bug report
description: File a bug report
title: '[BUG] '
labels:
- bug
body:
- type: markdown
attributes:
value: |
Before you create a new bug report, please check if an issue with it already exists (either open or closed) by using the search bar on the issues page. If it does, comment there. Even if it's closed, we can reopen it based on your comment.
- type: dropdown
id: printer_model
attributes:
label: Printer model
description: Enter the printer model(s) where you encountered the issue
options:
- MK3S/+
- MK3
- MK2.5S
- MK2.5
validations:
required: true
- type: dropdown
id: mmu_model
attributes:
label: MMU model
description: Enter the MMU model(s) where you encountered the issue
multiple: false
options:
- No-MMU
- MMU3
- MMU2S
validations:
required: true
- type: input
id: firmware_version
attributes:
label: Firmware versions
description: |
If you're using a custom firmware (not downloaded from Prusa), please note that!
placeholder: '3.14.0, 3.12.0-RC1, 3.14.0 and 3.0.2...'
validations:
required: true
- type: input
id: optional_upgrades
attributes:
label: Upgrades and modifications
description: 'If your printer has upgrades or was modified, please note that! If not, please write None or leave blank.'
placeholder: |
None, custom extruder/hotend (which), different frame, ...
- type: dropdown
id: printing_from
attributes:
label: Printing from...
multiple: false
options:
- SD Card
- PrusaLink
- PrusaConnect
- OctoPrint
- Other host software
validations:
required: true
- type: textarea
id: description
attributes:
label: Describe the bug
description: Write a concise description of the bug.
validations:
required: true
- type: textarea
id: reproduction
attributes:
label: How to reproduce
description: |
If you are able to reproduce the issue - meaning that you can trigger it yourself by following certain steps - please describe the step-by-step process in as much detail as possible!
- type: textarea
id: expected_behavior
attributes:
label: Expected behavior
description: |
If the printer did something unexpected, or if the procedure is missing a step that would resolve the issue, please provide a step-by-step process of how it should behave.
- type: textarea
id: files
attributes:
label: Files
description: |
Provide at least one of these (ideally as many as you can) to help developers track down the bug.
*To upload files, compress them into a .zip file and drag them to the text area to upload.* Images and videos can be uploaded directly.
- **gcode** file
- **3mf project** which includes the model and printer settings
- **video** or **photos** of the issue happening
**Crash dump: Do not share the file publicly**, as the crash dump contains a raw snapshot of the printer's memory and may include unencrypted sensitive information.
Please send the crash dump file to Prusa by emailing it to reports@prusa3d.com and referencing this issue. In reply to the email, you will be automatically assigned a reference code to be mentioned in the issue. Sharing this file is important and helps us investigate the bug.

View File

@ -1,17 +0,0 @@
---
name: Community
about: Related to "Community made" features
title: "[Community made] <Enter comprehensive title>"
labels: community_made
assignees: ''
---
Prusa Research will NOT follow up these issues!
The maintainers of the "Community made" feature should/will react.
Please, before you create a new "Community made" ticket, please make sure you searched in open and closed issues and couldn't find anything that matches.
**Which Community made feature do you want to address?**
**What is your request/question/suggestion?**

25
.github/ISSUE_TEMPLATE/community.yml vendored Normal file
View File

@ -0,0 +1,25 @@
name: Community
description: Related to "Community made" features
title: '[Community made] '
labels:
- community_made
body:
- type: markdown
attributes:
value: >
Prusa Research will NOT follow up these issues!
The maintainers of the "Community made" feature should/will react.
Please, before you create a new "Community made" ticket, please make sure you searched in open and closed issues and couldn't find anything that matches.
- type: textarea
id: which_community
attributes:
label: Which Community made feature do you want to address?
validations:
required: true
- type: textarea
id: What_about_community
attributes:
label: What is your request/question/suggestion?
validations:
required: true

11
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@ -0,0 +1,11 @@
contact_links:
- name: Do you need Support?
url: https://help.prusa3d.com/article/customer-support_2287
about: If you are not sure whether what you are reporting is a bug, please contact our support team first. We are providing full 24/7 customer support.
- name: Knowledge Base
url: https://help.prusa3d.com/
about: We have a comprehensive help documentation that could be helpful for troubleshooting.
- name: Prusa Forum
url: https://forum.prusa3d.com/
about: Please get in touch on our Prusa Forum! (Not an official support channel)
blank_issues_enabled: false

View File

@ -1,20 +0,0 @@
---
name: Enhancement
about: Suggest an idea for this project
title: " [ENHANCEMENT]<Enter comprehensive title>"
labels: enhancement
assignees: ''
---
Please, before you create a new feature request, please make sure you searched in open and closed issues and couldn't find anything that matches.
Enter what type of printer or upgrade the enhancement applies to.
**Printer type** - [e.g. MK3S, MK3, MK2.5S, MK2.5, MK2S, MK2]
**MMU Upgrade** - [e.g. MMU2S, MMU2, MMU1]
**Is your enhancement related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.

35
.github/ISSUE_TEMPLATE/enhancement.yml vendored Normal file
View File

@ -0,0 +1,35 @@
name: Enhancement
description: Suggest an improvement of the existing functionality
title: '[ENHANCEMENT] '
labels:
- enhancement
body:
- type: markdown
attributes:
value: |
Before you create a new enhancement, please check if an issue with it already exists (either open or closed) by using the search bar on the issues page.
- type: checkboxes
id: printer_model
attributes:
label: Printer model
description: Select the printer model(s) where you would like this enhancement
options:
- label: MK3S/+
- label: MK3
- label: MK2.5S
- label: MK2.5
validations:
required: true
- type: textarea
id: description
attributes:
label: Describe the enhancement
description: How would this enhancement improve your experience? Do you have a specific use case where this enhancemnet is especially needed?
validations:
required: true
- type: textarea
id: expected_functionality
attributes:
label: Expected functionality
description: |
Describe the way the enhancement would change existing functionality. You can also describe it in a step-by-step basis if applicable.

View File

@ -1,20 +0,0 @@
---
name: Feature request
about: Suggest an idea for this project
title: "[FEATURE REQUEST]<Enter comprehensive title>"
labels: feature request
assignees: ''
---
Please, before you create a new feature request, please make sure you searched in open and closed issues and couldn't find anything that matches.
If it makes sense, enter what type of printer or upgrade the feature request applies to.
**Printer type** - [e.g. MK3S, MK3, MK2.5S, MK2.5, MK2S, MK2]
**MMU Upgrade** - [e.g. MMU2S, MMU2, MMU1]
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.

View File

@ -0,0 +1,35 @@
name: Feature request
description: Suggest new functionality
title: '[FEATURE REQUEST] '
labels:
- feature request
body:
- type: markdown
attributes:
value: |
Before you create a new feature request, please check if an issue with it already exists (either open or closed) by using the search bar on the issues page.
- type: checkboxes
id: printer_model
attributes:
label: Printer model
description: Select the printer model(s) where you would like this feature
options:
- label: MK3S/+
- label: MK3
- label: MK2.5S
- label: MK2.5
validations:
required: true
- type: textarea
id: description
attributes:
label: Describe the feature
description: How would this feature improve the printer? Are there specific use cases where this would be beneficial? Describe how you would use it.
validations:
required: true
- type: textarea
id: expected_functionality
attributes:
label: Expected functionality
description: |
Describe the way the feature would work. You can also describe it in a step-by-step basis if applicable.

View File

@ -1,12 +0,0 @@
---
name: Question
about: What do you want to know?
title: "[QUESTION]<Enter comprehensive title>"
labels: question
assignees: ''
---
Please, before you create a new question, please make sure you searched in open and closed issues and couldn't find anything that matches.
**What is your question?**

16
.github/ISSUE_TEMPLATE/question.yml vendored Normal file
View File

@ -0,0 +1,16 @@
name: Question
description: Ask a firmware specific question
title: '[QUESTION] '
labels:
- question
body:
- type: markdown
attributes:
value: |
Before you create a new question, please check if an issue with it already exists (either open or closed) by using the search bar on the issues page.
- type: textarea
id: question
attributes:
label: Question
validations:
required: true

View File

@ -8,6 +8,8 @@ on:
branches: [ MK3, MK3_* ]
tags:
- 'v*'
- 't*'
- 'c*'
env:
GH_ANNOTATIONS: 1
@ -41,7 +43,7 @@ jobs:
fetch-depth: 0
- name: Cache Dependencies
uses: actions/cache@v4.0.0
uses: actions/cache@v4
id: cache-pkgs
with:
path: ".dependencies"
@ -63,16 +65,17 @@ jobs:
- name: Upload artifacts
if: ${{ !github.event.pull_request }}
uses: actions/upload-artifact@v3.1.1
uses: actions/upload-artifact@v4
with:
name: Firmware
path: build/*.hex
- name: RELEASE THE KRAKEN
if: startsWith(github.ref, 'refs/tags/v')
if: startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/tags/t') || startsWith(github.ref, 'refs/tags/c')
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: ${{ github.ref_name }}
draft: true
files: |
${{ github.workspace }}/build/release/*.hex
@ -106,7 +109,7 @@ jobs:
fetch-depth: 0
- name: Cache Dependencies
uses: actions/cache@v4.0.0
uses: actions/cache@v4
id: cache-pkgs
with:
path: ".dependencies"
@ -154,7 +157,7 @@ jobs:
fetch-depth: 0
- name: Cache Dependencies
uses: actions/cache@v4.0.0
uses: actions/cache@v4
id: cache-pkgs
with:
path: ".dependencies"

View File

@ -26,7 +26,7 @@ jobs:
uses: actions/checkout@v4
- name: Cache Dependencies
uses: actions/cache@v4.0.0
uses: actions/cache@v4
id: cache-pkgs
with:
path: ".dependencies"

View File

@ -16,9 +16,9 @@ jobs:
repo-token: ${{ secrets.GITHUB_TOKEN }}
# Don't ever mark PRs as stale.
days-before-pr-stale: -1
stale-issue-message: 'This issue has been flagged as stale because it has been open for 60 days with no activity. The issue will be closed in 7 days unless someone removes the "stale" label or adds a comment.'
close-issue-message: 'This issue has been closed due to lack of recent activity. Please consider opening a new one if needed.'
# Don't act on things assigned to a milestone or assigned to someone.
stale-issue-message: 'Thank you for your contribution to our project. This issue has not received any updates for 60 days and may be considered "stale." If this issue is still important to you, please add an update within the next 7 days to keep it open. Administrators can manually reopen the issue if necessary.'
close-issue-message: 'This issue has been closed due to lack of recent activity. Please consider opening a new one if needed.'
# Don't act on things assigned to a milestone or assigned to someone.
exempt-all-milestones: true
exempt-all-assignees: true
enable-statistics: true

View File

@ -3,7 +3,7 @@
"name": "avr-gcc",
"toolchainFile": "${workspaceFolder}/cmake/AvrGcc.cmake",
"cmakeSettings": {
"CMAKE_MAKE_PROGRAM": "${workspaceFolder}/.dependencies/ninja-1.10.2/ninja",
"CMAKE_MAKE_PROGRAM": "${workspaceFolder}/.dependencies/ninja-1.12.1/ninja",
"CMAKE_BUILD_TYPE": "Release"
}
}

View File

@ -53,11 +53,12 @@ message(STATUS "Project version (Configuration.h): ${PROJECT_VERSION}")
#message(STATUS "Project version commit number....: ${PROJECT_VERSION_COMMIT}") #For debuging
message(STATUS "Filename suffix..................: ${FN_VERSION_SUFFIX}")
message(STATUS "Filename debug suffix ...........: ${FN_VERSION_DEBUG_SUFFIX}")
#message(STATUS "Host OS .........................: ${CMAKE_HOST_SYSTEM_NAME}")
# testing
# SET(FW_COMMIT_DSC "v3.13.0-1234")
if(NOT "${PROJECT_VERSION_HASH}" STREQUAL "UNKNOWN" AND NOT "${FW_COMMIT_DSC}" MATCHES ".+NOTFOUND.+") # else -> no commit hash is known... likely no git.
string(REGEX MATCH "[v|t]([0-9]+)\.([0-9]+)\.([0-9]+)-?(${DEV_TAG_REGEX})?([0-9]+)?-([0-9]+)" TAG_VERSION "${FW_COMMIT_DSC}")
string(REGEX MATCH "[v|t|c]([0-9]+)\.([0-9]+)\.([0-9]+)-?(${DEV_TAG_REGEX})?([0-9]+)?-([0-9]+)" TAG_VERSION "${FW_COMMIT_DSC}")
if (CMAKE_MATCH_4) # Do we have a build type?
decode_flavor_code(PROJECT_VER_TAG_FLV "${CMAKE_MATCH_4}" "${CMAKE_MATCH_5}")
@ -245,15 +246,13 @@ set(FW_SOURCES
power_panic.cpp
printer_state.cpp
Prusa_farm.cpp
qr_solve.cpp
rbuf.c
Sd2Card.cpp
SdBaseFile.cpp
SdFatUtil.cpp
SdFile.cpp
SdVolume.cpp
Servo.cpp
sm4.c
sm4.cpp
sound.cpp
speed_lookuptable.cpp
spi.c
@ -269,10 +268,9 @@ set(FW_SOURCES
tmc2130.cpp
tone04.c
twi.cpp
uart2.c
uart2.cpp
ultralcd.cpp
util.cpp
vector_3.cpp
xflash.c
xflash_dump.cpp
xyzcal.cpp
@ -565,10 +563,10 @@ function(fw_add_variant variant_name)
# Patched binary with pre-baked secondary language
add_custom_command(
OUTPUT ${FW_LANG_FINAL}.bin
COMMAND ${CMAKE_OBJCOPY} -O binary ${FW_LANG_BASE} ${FW_LANG_FINAL}.bin
COMMAND ${CMAKE_COMMAND} -E copy ${FW_LANG_PATCH}.bin ${FW_LANG_FINAL}.bin
COMMAND "${Python3_EXECUTABLE}" ${CMAKE_SOURCE_DIR}/lang/lang-patchsec.py ${FW_LANG_BASE} ${LANG_BIN}
${FW_LANG_FINAL}.bin
DEPENDS ${FW_LANG_BASE} ${LANG_BIN}
DEPENDS ${FW_LANG_BASE} ${FW_LANG_PATCH}.bin ${LANG_BIN}
COMMENT "Generating ${FW_LANG_FINAL}.bin"
)
@ -588,13 +586,15 @@ function(fw_add_variant variant_name)
list(APPEND ALL_VARIANT_HEXES ${FW_LANG_FINAL})
endforeach()
add_custom_target("${variant_name}-All-Languages" DEPENDS ${ALL_VARIANT_HEXES})
add_custom_command(TARGET "${variant_name}-All-Languages"
POST_BUILD
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E make_directory "release"
COMMAND ${CMAKE_COMMAND} -E tar "cfv" "release/${variant_name}_${FN_VERSION_SUFFIX}.zip" --format=zip ${variant_name}_${FN_VERSION_SUFFIX}_en*.hex
BYPRODUCTS "${CMAKE_BINARY_DIR}/release/${variant_name}_${FN_VERSION_SUFFIX}.zip"
)
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
add_custom_command(TARGET "${variant_name}-All-Languages"
POST_BUILD
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E make_directory "release"
COMMAND ${CMAKE_COMMAND} -E tar "cfv" "release/${variant_name}_${FN_VERSION_SUFFIX}.zip" --format=zip ${variant_name}_${FN_VERSION_SUFFIX}_en*.hex
BYPRODUCTS "${CMAKE_BINARY_DIR}/release/${variant_name}_${FN_VERSION_SUFFIX}.zip"
)
endif()
add_dependencies(ALL_MULTILANG "${variant_name}-All-Languages")
endif()
endfunction()
@ -639,13 +639,15 @@ endif()
SET(REVO_FW_ZIP_NAME "E3D_REVO_FW_MK3_MK3S_MK3S+_${FN_VERSION_SUFFIX}.zip")
add_custom_command(TARGET ALL_MULTILANG
POST_BUILD
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/release
BYPRODUCTS ${CMAKE_BINARY_DIR}/release/${REVO_FW_ZIP_NAME}
COMMAND ${CMAKE_COMMAND} -E tar "cfv" "${REVO_FW_ZIP_NAME}" --format=zip *E3DREVO*.hex
COMMAND ${CMAKE_COMMAND} -E rm *E3DREVO*.hex
)
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
add_custom_command(TARGET ALL_MULTILANG
POST_BUILD
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/release
BYPRODUCTS ${CMAKE_BINARY_DIR}/release/${REVO_FW_ZIP_NAME}
COMMAND ${CMAKE_COMMAND} -E tar "cfv" "${REVO_FW_ZIP_NAME}" --format=zip *E3DREVO*.hex
COMMAND ${CMAKE_COMMAND} -E rm *E3DREVO*.hex
)
endif()
#
# Tests

View File

@ -16,7 +16,7 @@ Help `./PF-build.sh -h`
# MK404 Simulator
## MK404-build.sh
## MK404-build.sh
**MK404 is a community 3d printer simulator created by @vintagepc**
Please checkout and support his github repository [MK404](https://github.com/vintagepc/MK404) and the [MK404 Wiki](https://github.com/vintagepc/MK404/wiki)

View File

@ -15,7 +15,7 @@
void SendColors(byte red, byte grn, byte blu)
{
Wire.begin();
Wire.begin();
Wire.beginTransmission(0x09);
Wire.write('o'); //to disable ongoing script, only needs to be used once
Wire.write('n');

View File

@ -1,6 +1,7 @@
#ifndef CONFIGURATION_H
#define CONFIGURATION_H
#include <stdint.h>
#include "boards.h"
#define STR_HELPER(x) #x
@ -20,9 +21,9 @@ extern const char _sPrinterMmuName[] PROGMEM;
#ifndef CMAKE_CONTROL
#define FW_MAJOR 3
#define FW_MINOR 14
#define FW_REVISION 0
#define FW_COMMITNR 7945
#define FW_FLAVOR BETA //uncomment if DEV, ALPHA, BETA or RC
#define FW_REVISION 1
#define FW_COMMITNR 8225
#define FW_FLAVOR RC //uncomment if DEV, ALPHA, BETA or RC
#define FW_FLAVERSION 1 //uncomment if FW_FLAVOR is defined and versioning is needed. Limited to max 8.
#endif
@ -121,13 +122,6 @@ extern const char _sPrinterMmuName[] PROGMEM;
#define TEMP_HYSTERESIS 5 // (degC) range of +/- temperatures considered "close" to the target one
#define TEMP_WINDOW 1 // (degC) Window around target to start the residency timer x degC early.
// If your bed has low resistance e.g. .6 ohm and throws the fuse you can duty cycle it to reduce the
// average current. The value should be an integer and the heat bed will be turned on for 1 interval of
// HEATER_BED_DUTY_CYCLE_DIVIDER intervals.
//#define HEATER_BED_DUTY_CYCLE_DIVIDER 4
// If you want the M105 heater power reported in watts, define the BED_WATTS, and (shared for all extruders) EXTRUDER_WATTS
//#define EXTRUDER_WATTS (12.0*12.0/6.7) // P=I^2/R
//#define BED_WATTS (12.0*12.0/1.1) // P=I^2/R
@ -290,124 +284,6 @@ your extruder heater takes 2 minutes to hit the target on heating.
#define HOME_Z_SEARCH_THRESHOLD 0.15f // Threshold of the Z height in calibration
//============================= Bed Auto Leveling ===========================
//#define ENABLE_AUTO_BED_LEVELING // Delete the comment to enable (remove // at the start of the line)
#define Z_PROBE_REPEATABILITY_TEST // If not commented out, Z-Probe Repeatability test will be included if Auto Bed Leveling is Enabled.
#ifdef ENABLE_AUTO_BED_LEVELING
// There are 2 different ways to pick the X and Y locations to probe:
// - "grid" mode
// Probe every point in a rectangular grid
// You must specify the rectangle, and the density of sample points
// This mode is preferred because there are more measurements.
// It used to be called ACCURATE_BED_LEVELING but "grid" is more descriptive
// - "3-point" mode
// Probe 3 arbitrary points on the bed (that aren't colinear)
// You must specify the X & Y coordinates of all 3 points
#define AUTO_BED_LEVELING_GRID
// with AUTO_BED_LEVELING_GRID, the bed is sampled in a
// AUTO_BED_LEVELING_GRID_POINTSxAUTO_BED_LEVELING_GRID_POINTS grid
// and least squares solution is calculated
// Note: this feature occupies 10'206 byte
#ifdef AUTO_BED_LEVELING_GRID
// set the rectangle in which to probe
#define LEFT_PROBE_BED_POSITION 15
#define RIGHT_PROBE_BED_POSITION 170
#define BACK_PROBE_BED_POSITION 180
#define FRONT_PROBE_BED_POSITION 20
// set the number of grid points per dimension
// I wouldn't see a reason to go above 3 (=9 probing points on the bed)
#define AUTO_BED_LEVELING_GRID_POINTS 2
#else // not AUTO_BED_LEVELING_GRID
// with no grid, just probe 3 arbitrary points. A simple cross-product
// is used to esimate the plane of the print bed
#define ABL_PROBE_PT_1_X 15
#define ABL_PROBE_PT_1_Y 180
#define ABL_PROBE_PT_2_X 15
#define ABL_PROBE_PT_2_Y 20
#define ABL_PROBE_PT_3_X 170
#define ABL_PROBE_PT_3_Y 20
#endif // AUTO_BED_LEVELING_GRID
// these are the offsets to the probe relative to the extruder tip (Hotend - Probe)
// X and Y offsets must be integers
#define X_PROBE_OFFSET_FROM_EXTRUDER -25
#define Y_PROBE_OFFSET_FROM_EXTRUDER -29
#define Z_PROBE_OFFSET_FROM_EXTRUDER -12.35
#define Z_RAISE_BEFORE_HOMING 5 // (in mm) Raise Z before homing (G28) for Probe Clearance.
// Be sure you have this distance over your Z_MAX_POS in case
#define XY_TRAVEL_SPEED 8000 // X and Y axis travel speed between probes, in mm/min
#define Z_RAISE_BEFORE_PROBING 15 //How much the extruder will be raised before traveling to the first probing point.
#define Z_RAISE_BETWEEN_PROBINGS 5 //How much the extruder will be raised when traveling from between next probing points
//#define Z_PROBE_SLED // turn on if you have a z-probe mounted on a sled like those designed by Charles Bell
//#define SLED_DOCKING_OFFSET 5 // the extra distance the X axis must travel to pickup the sled. 0 should be fine but you can push it further if you'd like.
//If defined, the Probe servo will be turned on only during movement and then turned off to avoid jerk
//The value is the delay to turn the servo off after powered on - depends on the servo speed; 300ms is good value, but you can try lower it.
// You MUST HAVE the SERVO_ENDSTOPS defined to use here a value higher than zero otherwise your code will not compile.
// #define PROBE_SERVO_DEACTIVATION_DELAY 300
//If you have enabled the Bed Auto Leveling and are using the same Z Probe for Z Homing,
//it is highly recommended you let this Z_SAFE_HOMING enabled!
//#define Z_SAFE_HOMING // This feature is meant to avoid Z homing with probe outside the bed area.
// When defined, it will:
// - Allow Z homing only after X and Y homing AND stepper drivers still enabled
// - If stepper drivers timeout, it will need X and Y homing again before Z homing
// - Position the probe in a defined XY point before Z Homing when homing all axis (G28)
// - Block Z homing only when the probe is outside bed area.
#ifdef Z_SAFE_HOMING
#define Z_SAFE_HOMING_X_POINT (X_MAX_LENGTH/2) // X point for Z homing when homing all axis (G28)
#define Z_SAFE_HOMING_Y_POINT (Y_MAX_LENGTH/2) // Y point for Z homing when homing all axis (G28)
#endif
#ifdef AUTO_BED_LEVELING_GRID // Check if Probe_Offset * Grid Points is greater than Probing Range
#if X_PROBE_OFFSET_FROM_EXTRUDER < 0
#if (-(X_PROBE_OFFSET_FROM_EXTRUDER * AUTO_BED_LEVELING_GRID_POINTS) >= (RIGHT_PROBE_BED_POSITION - LEFT_PROBE_BED_POSITION))
#error "The X axis probing range is not enough to fit all the points defined in AUTO_BED_LEVELING_GRID_POINTS"
#endif
#else
#if ((X_PROBE_OFFSET_FROM_EXTRUDER * AUTO_BED_LEVELING_GRID_POINTS) >= (RIGHT_PROBE_BED_POSITION - LEFT_PROBE_BED_POSITION))
#error "The X axis probing range is not enough to fit all the points defined in AUTO_BED_LEVELING_GRID_POINTS"
#endif
#endif
#if Y_PROBE_OFFSET_FROM_EXTRUDER < 0
#if (-(Y_PROBE_OFFSET_FROM_EXTRUDER * AUTO_BED_LEVELING_GRID_POINTS) >= (BACK_PROBE_BED_POSITION - FRONT_PROBE_BED_POSITION))
#error "The Y axis probing range is not enough to fit all the points defined in AUTO_BED_LEVELING_GRID_POINTS"
#endif
#else
#if ((Y_PROBE_OFFSET_FROM_EXTRUDER * AUTO_BED_LEVELING_GRID_POINTS) >= (BACK_PROBE_BED_POSITION - FRONT_PROBE_BED_POSITION))
#error "The Y axis probing range is not enough to fit all the points defined in AUTO_BED_LEVELING_GRID_POINTS"
#endif
#endif
#endif
#endif // ENABLE_AUTO_BED_LEVELING
// The position of the homing switches
//#define MANUAL_HOME_POSITIONS // If defined, MANUAL_*_HOME_POS below will be used
//#define BED_CENTER_AT_0_0 // If defined, the center of the bed is at (X=0, Y=0)
@ -425,17 +301,6 @@ your extruder heater takes 2 minutes to hit the target on heating.
//=============================Additional Features===========================
//===========================================================================
// Custom M code points
#define CUSTOM_M_CODES
#ifdef CUSTOM_M_CODES
#ifdef ENABLE_AUTO_BED_LEVELING
#define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851
#define Z_PROBE_OFFSET_RANGE_MIN -15
#define Z_PROBE_OFFSET_RANGE_MAX -5
#endif // ENABLE_AUTO_BED_LEVELING
#endif // CUSTOM_M_CODES
// Host Keepalive
//
// When enabled Marlin will send a busy status message to the host
@ -459,6 +324,10 @@ your extruder heater takes 2 minutes to hit the target on heating.
#define SDSUPPORT
#define LCD_WIDTH 20
#define LCD_HEIGHT 4
#define LCD_BACKLIGHT_LEVEL_HIGH 130
#define LCD_BACKLIGHT_LEVEL_LOW 50
#define LCD_BACKLIGHT_FORCE_ON 30
#define LCD_BACKLIGHT_TIMEOUT 15
// Increase the FAN pwm frequency. Removes the PWM noise but increases heating in the FET/Arduino
@ -489,26 +358,12 @@ your extruder heater takes 2 minutes to hit the target on heating.
//define BlinkM/CyzRgb Support
//#define BLINKM
/*********************************************************************\
* R/C SERVO support
* Sponsored by TrinityLabs, Reworked by codexmas
**********************************************************************/
// Number of servos
//
// If you select a configuration below, this will receive a default value and does not need to be set manually
// set it manually if you have more servos than extruders and wish to manually control some
// leaving it undefined or defining as 0 will disable the servo subsystem
// If unsure, leave commented / disabled
//
//#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command
#define DEFAULT_NOMINAL_FILAMENT_DIA 1.75 //Enter the diameter (in mm) of the filament generally used (3.0 mm or 1.75 mm). Used by the volumetric extrusion.
// Try to maintain a minimum distance from the bed even when Z is
// unknown when doing the following operations
#define MIN_Z_FOR_LOAD 50 // lcd filament loading or autoload
#define MIN_Z_FOR_UNLOAD 50 // lcd filament unloading
#define MIN_Z_FOR_LOAD 35 // lcd filament loading or autoload (values for load and unload have been unified to prevent movement between unload & load operations!)
#define MIN_Z_FOR_UNLOAD 35 // lcd filament unloading
#define MIN_Z_FOR_SWAP 27 // filament change (including M600)
#define MIN_Z_FOR_PREHEAT 10 // lcd preheat

View File

@ -106,6 +106,9 @@ void Config_PrintSettings(uint8_t level)
#ifdef THERMAL_MODEL
thermal_model_report_settings();
#endif
printf_P(PSTR(
"%SStatistics:\n%S M78 S%lu T%lu\n"),
echomagic, echomagic, eeprom_read_dword((uint32_t *)EEPROM_FILAMENTUSED), eeprom_read_dword((uint32_t *)EEPROM_TOTALTIME));
}
#endif
@ -116,10 +119,6 @@ static_assert (EXTRUDERS == 1, "ConfigurationStore M500_conf not implemented for
static_assert (NUM_AXIS == 4, "ConfigurationStore M500_conf not implemented for more axis."
"Fix axis_steps_per_mm max_feedrate_normal max_acceleration_mm_per_s2_normal max_jerk max_feedrate_silent"
" max_acceleration_mm_per_s2_silent array size.");
#ifdef ENABLE_AUTO_BED_LEVELING
static_assert (false, "zprobe_zoffset was not initialized in printers in field to -(Z_PROBE_OFFSET_FROM_EXTRUDER), so it contains"
"0.0, if this is not acceptable, increment EEPROM_VERSION to force use default_conf");
#endif
static_assert (sizeof(M500_conf) == 209, "sizeof(M500_conf) has changed, ensure that EEPROM_VERSION has been incremented, "
"or if you added members in the end of struct, ensure that historically uninitialized values will be initialized."
@ -206,7 +205,7 @@ bool Config_RetrieveSettings()
eeprom_init_default_byte(&EEPROM_M500_base->n_arc_correction, pgm_read_byte(&default_conf.n_arc_correction));
eeprom_init_default_word(&EEPROM_M500_base->min_arc_segments, pgm_read_word(&default_conf.min_arc_segments));
eeprom_init_default_word(&EEPROM_M500_base->arc_segments_per_sec, pgm_read_word(&default_conf.arc_segments_per_sec));
// Initialize the travel_acceleration in eeprom if not already
eeprom_init_default_float(&EEPROM_M500_base->travel_acceleration, pgm_read_float(&default_conf.travel_acceleration));
@ -214,6 +213,10 @@ bool Config_RetrieveSettings()
eeprom_init_default_block(&EEPROM_M500_base->max_feedrate_silent, sizeof(EEPROM_M500_base->max_feedrate_silent), default_conf.max_feedrate_silent);
eeprom_init_default_block(&EEPROM_M500_base->max_acceleration_mm_per_s2_silent, sizeof(EEPROM_M500_base->max_acceleration_mm_per_s2_silent), default_conf.max_acceleration_mm_per_s2_silent);
#ifdef TMC2130
eeprom_init_default_block(&EEPROM_M500_base->axis_ustep_resolution, sizeof(EEPROM_M500_base->axis_ustep_resolution), default_conf.axis_ustep_resolution);
#endif // TMC2130
// load the CS to RAM
eeprom_read_block(reinterpret_cast<uint8_t*>(&cs), reinterpret_cast<uint8_t*>(EEPROM_M500_base), sizeof(cs));
calculate_extruder_multipliers();
@ -230,11 +233,6 @@ bool Config_RetrieveSettings()
if (cs.max_acceleration_mm_per_s2_silent[j] > SILENT_MAX_ACCEL_XY)
cs.max_acceleration_mm_per_s2_silent[j] = SILENT_MAX_ACCEL_XY;
}
if(cs.axis_ustep_resolution[X_AXIS] == 0xff){ cs.axis_ustep_resolution[X_AXIS] = TMC2130_USTEPS_XY; }
if(cs.axis_ustep_resolution[Y_AXIS] == 0xff){ cs.axis_ustep_resolution[Y_AXIS] = TMC2130_USTEPS_XY; }
if(cs.axis_ustep_resolution[Z_AXIS] == 0xff){ cs.axis_ustep_resolution[Z_AXIS] = TMC2130_USTEPS_Z; }
if(cs.axis_ustep_resolution[E_AXIS] == 0xff){ cs.axis_ustep_resolution[E_AXIS] = TMC2130_USTEPS_E; }
tmc2130_set_res(X_AXIS, cs.axis_ustep_resolution[X_AXIS]);
tmc2130_set_res(Y_AXIS, cs.axis_ustep_resolution[Y_AXIS]);
@ -272,7 +270,7 @@ void Config_ResetDefault()
// steps per sq second need to be updated to agree with the units per sq second
reset_acceleration_rates();
#ifdef PIDTEMP
updatePID();
#endif//PIDTEMP

View File

@ -19,7 +19,7 @@ typedef struct
uint32_t min_segment_time_us; //!< (µs) M205 B
float max_jerk[4]; //!< Jerk is a maximum immediate velocity change.
float add_homing[3];
float zprobe_zoffset; //!< Only used with define ENABLE_AUTO_BED_LEVELING
float zprobe_zoffset; //!< unused
float Kp;
float Ki;
float Kd;

View File

@ -54,7 +54,7 @@
/**
* Auto-report all at once with M155 S<seconds> C[bitmask] with single timer
*
*
* bit 0 = Auto-report temperatures
* bit 1 = Auto-report fans
* bit 2 = Auto-report position
@ -125,34 +125,6 @@
#endif //End auto min/max positions
//END AUTOSET LOCATIONS OF LIMIT SWITCHES -ZP
// A single Z stepper driver is usually used to drive 2 stepper motors.
// Uncomment this define to utilize a separate stepper driver for each Z axis motor.
// Only a few motherboards support this, like RAMPS, which have dual extruder support (the 2nd, often unused, extruder driver is used
// to control the 2nd Z axis stepper motor). The pins are currently only defined for a RAMPS motherboards.
// On a RAMPS (or other 5 driver) motherboard, using this feature will limit you to using 1 extruder.
//#define Z_DUAL_STEPPER_DRIVERS
#ifdef Z_DUAL_STEPPER_DRIVERS
#undef EXTRUDERS
#define EXTRUDERS 1
#endif
// Same again but for Y Axis.
//#define Y_DUAL_STEPPER_DRIVERS
// Define if the two Y drives need to rotate in opposite directions
#define INVERT_Y2_VS_Y_DIR 1
#ifdef Y_DUAL_STEPPER_DRIVERS
#undef EXTRUDERS
#define EXTRUDERS 1
#endif
#if defined (Z_DUAL_STEPPER_DRIVERS) && defined (Y_DUAL_STEPPER_DRIVERS)
#error "You cannot have dual drivers for both Y and Z"
#endif
//homing hits the endstop, then retracts by this distance, before it tries to slowly bump again:
#define X_HOME_RETRACT_MM 5
#define Y_HOME_RETRACT_MM 5
@ -229,7 +201,7 @@
* limit is exceeded.
*/
#define SDCARD_SORT_ALPHA //Alphabetical sorting of SD files menu
// SD Card Sorting options
#ifdef SDCARD_SORT_ALPHA
#define SD_SORT_TIME 0
@ -238,11 +210,11 @@
#define INSERTSORT
// #define SORTING_DUMP
// #define SORTING_SPEEDTEST
#define SDSORT_LIMIT 100 // Maximum number of sorted items (10-256).
#define FOLDER_SORTING -1 // -1=above 0=none 1=below
#endif
#if defined(SDCARD_SORT_ALPHA)
#define HAS_FOLDER_SORTING (FOLDER_SORTING)
#endif
@ -392,7 +364,7 @@ const unsigned int dropsegments=5; //everything with less than this number of st
/**
* Enable M120/M121 G-code commands
*
*
*/
//#define M120_M121_ENABLED //Be careful enabling and using these G-code commands.

View File

@ -162,19 +162,19 @@ void dcode_core(daddr_t addr_start, const daddr_t addr_end, const dcode_mem_t ty
### D3 - Read/Write EEPROM <a href="https://reprap.org/wiki/G-code#D3:_Read.2FWrite_EEPROM">D3: Read/Write EEPROM</a>
This command can be used without any additional parameters. It will read the entire eeprom.
#### Usage
D3 [ A | C | X ]
#### Parameters
- `A` - Address (x0000-x0fff)
- `C` - Count (1-4096)
- `X` - Data (hex)
#### Notes
- The hex address needs to be lowercase without the 0 before the x
- Count is decimal
- Count is decimal
- The hex data needs to be lowercase
*/
void dcode_3()
{
@ -191,21 +191,14 @@ void dcode_3()
#include <avr/wdt.h>
#include "bootapp.h"
#if 0
extern float current_temperature_pinda;
extern float axis_steps_per_mm[NUM_AXIS];
#define LOG(args...) printf(args)
#endif //0
#define LOG(args...)
/*!
*
### D-1 - Endless Loop <a href="https://reprap.org/wiki/G-code#G28:_Move_to_Origin_.28Home.29">D-1: Endless Loop</a>
D-1
*
*/
void dcode__1()
@ -220,9 +213,9 @@ void dcode__1()
/*!
### D0 - Reset <a href="https://reprap.org/wiki/G-code#D0:_Reset">D0: Reset</a>
#### Usage
D0 [ B ]
#### Parameters
- `B` - Bootloader
*/
@ -245,9 +238,9 @@ void dcode_0()
/*!
*
### D1 - Clear EEPROM and RESET <a href="https://reprap.org/wiki/G-code#D1:_Clear_EEPROM_and_RESET">D1: Clear EEPROM and RESET</a>
D1
*
*/
void dcode_1()
@ -287,13 +280,13 @@ void dcode_2()
#ifdef DEBUG_DCODES
/*!
### D4 - Read/Write PIN <a href="https://reprap.org/wiki/G-code#D4:_Read.2FWrite_PIN">D4: Read/Write PIN</a>
To read the digital value of a pin you need only to define the pin number.
#### Usage
D4 [ P | F | V ]
#### Parameters
- `P` - Pin (0-255)
- `F` - Function in/out (0/1)
@ -335,20 +328,19 @@ void dcode_4()
### D5 - Read/Write FLASH <a href="https://reprap.org/wiki/G-code#D5:_Read.2FWrite_FLASH">D5: Read/Write Flash</a>
This command can be used without any additional parameters. It will read the 1kb FLASH.
#### Usage
D5 [ A | C | X | E ]
#### Parameters
- `A` - Address (x00000-x3ffff)
- `C` - Count (1-8192)
- `X` - Data (hex)
- `E` - Erase
#### Notes
- The hex address needs to be lowercase without the 0 before the x
- Count is decimal
- Count is decimal
- The hex data needs to be lowercase
*/
void dcode_5()
{
@ -457,9 +449,9 @@ void dcode_7()
/*!
### D8 - Read/Write PINDA <a href="https://reprap.org/wiki/G-code#D8:_Read.2FWrite_PINDA">D8: Read/Write PINDA</a>
#### Usage
D8 [ ? | ! | P | Z ]
#### Parameters
- `?` - Read PINDA temperature shift values
- `!` - Reset PINDA temperature shift values to default
@ -510,11 +502,11 @@ void dcode_8()
/*!
### D9 - Read ADC <a href="https://reprap.org/wiki/G-code#D9:_Read.2FWrite_ADC">D9: Read ADC</a>
#### Usage
D9 [ I | V ]
#### Parameters
- `I` - ADC channel index
- `I` - ADC channel index
- `0` - Heater 0 temperature
- `1` - Heater 1 temperature
- `2` - Bed temperature
@ -618,9 +610,9 @@ void dcode_12()
### D80 - Bed check <a href="https://reprap.org/wiki/G-code#D80:_Bed_check">D80: Bed check</a>
This command will log data to SD card file "mesh.txt".
#### Usage
D80 [ E | F | G | H | I | J ]
#### Parameters
- `E` - Dimension X (default 40)
- `F` - Dimention Y (default 40)
@ -658,9 +650,9 @@ void dcode_80()
### D81 - Bed analysis <a href="https://reprap.org/wiki/G-code#D81:_Bed_analysis">D80: Bed analysis</a>
This command will log data to SD card file "wldsd.txt".
#### Usage
D81 [ E | F | G | H | I | J ]
#### Parameters
- `E` - Dimension X (default 40)
- `F` - Dimention Y (default 40)
@ -684,9 +676,9 @@ void dcode_81()
if (code_seen("H")) { strchr_pointer+=1; points_y = code_value(); }
if (code_seen("I")) { strchr_pointer+=1; offset_x = code_value(); }
if (code_seen("J")) { strchr_pointer+=1; offset_y = code_value(); }
bed_analysis(dimension_x,dimension_y,points_x,points_y,offset_x,offset_y);
}
#endif //HEATBED_ANALYSIS
@ -713,11 +705,11 @@ extern void st_synchronize();
/*!
### D2130 - Trinamic stepper controller <a href="https://reprap.org/wiki/G-code#D2130:_Trinamic_stepper_controller">D2130: Trinamic stepper controller</a>
@todo Please review by owner of the code. RepRap Wiki Gcode needs to be updated after review of owner as well.
#### Usage
D2130 [ Axis | Command | Subcommand | Value ]
#### Parameters
- Axis
- `X` - X stepper driver
@ -746,21 +738,21 @@ extern void st_synchronize();
- `0, 180 --> 250` - Off
- `0.9 --> 1.25` - Valid values (recommended is 1.1)
- `@` - Home calibrate axis
Examples:
D2130E?wave
Print extruder microstep linearity compensation curve
D2130E!wave0
Disable extruder linearity compensation curve, (sine curve is used)
D2130E!wave220
(sin(x))^1.1 extruder microstep compensation curve used
Notes:
For more information see https://www.trinamic.com/fileadmin/assets/Products/ICs_Documents/TMC2130_datasheet.pdf
*
@ -870,9 +862,9 @@ void dcode_2130()
/*!
### D9125 - PAT9125 filament sensor <a href="https://reprap.org/wiki/G-code#D9:_Read.2FWrite_ADC">D9125: PAT9125 filament sensor</a>
#### Usage
D9125 [ ? | ! | R | X | Y | L ]
#### Parameters
- `?` - Print values
- `!` - Print values

View File

@ -8,6 +8,7 @@
#include "language.h"
#include "menu.h"
#include "messages.h"
#include "mmu2.h"
#include "planner.h"
#include "temperature.h"
#include "ultralcd.h"
@ -148,6 +149,7 @@ void Filament_sensor::triggerFilamentRemoved() {
void Filament_sensor::filRunout() {
// SERIAL_ECHOLNPGM("filRunout");
sendHostNotification_P(MSG_FILAMENT_RUNOUT_DETECTED);
runoutEnabled = false;
autoLoadEnabled = false;
stop_and_save_print_to_ram(0, 0);
@ -311,22 +313,7 @@ bool IR_sensor_analog::checkVoltage(uint16_t raw) {
puts_P(PSTR("fsensor v0.4 in fault range 4.6-5V - unconnected"));
return false;
}
/// newer IR sensor cannot normally produce 0-0.3V, this is considered a failure
#if 0 // Disabled as it has to be decided if we gonna use this or not.
if(IRsensor_Hopen_TRESHOLD <= raw && raw <= IRsensor_VMax_TRESHOLD) {
puts_P(PSTR("fsensor v0.4 in fault range 0.0-0.3V - wrong IR sensor"));
return false;
}
#endif
}
/// If IR sensor is "uknown state" and filament is not loaded > 1.5V return false
#if 0
#error "I really think this code can't be enabled anymore because we are constantly checking this voltage."
if((sensorRevision == SensorRevision::_Undef) && (raw > IRsensor_Lmax_TRESHOLD)) {
puts_P(PSTR("Unknown IR sensor version and no filament loaded detected."));
return false;
}
#endif
// otherwise the IR fsensor is considered working correctly
return true;
}

View File

@ -21,7 +21,7 @@ public:
};
/// Base class Filament sensor
///
///
/// Ideally, there could have been a nice class hierarchy of filament sensor types with common functionality
/// extracted into this base class.
/// But:
@ -37,43 +37,43 @@ public:
ready,
error,
};
enum class SensorActionOnError : uint8_t {
_Continue = 0,
_Pause = 1,
_Undef = EEPROM_EMPTY_VALUE
};
static void setEnabled(bool enabled);
void setAutoLoadEnabled(bool state, bool updateEEPROM = false);
bool getAutoLoadEnabled() const { return autoLoadEnabled; }
void setRunoutEnabled(bool state, bool updateEEPROM = false);
bool getRunoutEnabled() const { return runoutEnabled; }
void setActionOnError(SensorActionOnError state, bool updateEEPROM = false);
SensorActionOnError getActionOnError() const { return sensorActionOnError; }
bool getFilamentLoadEvent() const { return postponedLoadEvent; }
bool isError() const { return state == State::error; }
bool isReady() const { return state == State::ready; }
bool isEnabled() const { return state != State::disabled; }
protected:
void settings_init_common();
bool checkFilamentEvents();
void triggerFilamentInserted();
void triggerFilamentRemoved();
void filRunout();
void triggerError();
State state;
bool autoLoadEnabled;
bool runoutEnabled;
@ -109,37 +109,37 @@ public:
void init();
bool update();
void voltUpdate(uint16_t raw);
uint16_t __attribute__((noinline)) getVoltRaw();
enum class SensorRevision : uint8_t {
_Old = 0,
_Rev04 = 1,
_Undef = EEPROM_EMPTY_VALUE
};
SensorRevision getSensorRevision() const { return sensorRevision; }
const char* __attribute__((noinline)) getIRVersionText();
void setSensorRevision(SensorRevision rev, bool updateEEPROM = false);
constexpr static uint16_t IRsensor_Ldiode_TRESHOLD = Voltage2Raw(0.3F); // ~0.3V, raw value=982
constexpr static uint16_t IRsensor_Lmax_TRESHOLD = Voltage2Raw(1.5F); // ~1.5V (0.3*Vcc), raw value=4910
constexpr static uint16_t IRsensor_Hmin_TRESHOLD = Voltage2Raw(3.0F); // ~3.0V (0.6*Vcc), raw value=9821
constexpr static uint16_t IRsensor_Hopen_TRESHOLD = Voltage2Raw(4.6F); // ~4.6V (N.C. @ Ru~20-50k, Rd'=56k, Ru'=10k), raw value=15059
constexpr static uint16_t IRsensor_VMax_TRESHOLD = Voltage2Raw(5.F); // ~5V, raw value=16368
private:
SensorRevision sensorRevision;
bool voltReady; // set by the adc ISR, therefore avoid accessing the variable directly but use getVoltReady()
bool getVoltReady()const;
void clearVoltReady();
uint16_t voltRaw; // set by the adc ISR, therefore avoid accessing the variable directly but use getVoltRaw()
bool checkVoltage(uint16_t raw);
uint16_t minVolt = Voltage2Raw(6.F);
uint16_t maxVolt = 0;
uint16_t nFSCheckCount;
@ -165,14 +165,14 @@ public:
#ifdef FSENSOR_PROBING
bool probeOtherType(); //checks if the wrong fsensor type is detected.
#endif
void setJamDetectionEnabled(bool state, bool updateEEPROM = false);
bool getJamDetectionEnabled() const { return jamDetection; }
void stStep(bool rev) { //from stepper isr
stepCount += rev ? -1 : 1;
}
void settings_init();
private:
static constexpr uint16_t pollingPeriod = 10; //[ms]
@ -180,23 +180,23 @@ private:
ShortTimer pollingTimer;
uint8_t filter;
uint8_t filterFilPresent;
bool jamDetection;
int16_t oldPos;
int16_t stepCount;
int16_t chunkSteps;
uint8_t jamErrCnt;
constexpr void calcChunkSteps(float u) {
chunkSteps = (int16_t)(1.25 * u); //[mm]
}
int16_t getStepCount();
void resetStepCount();
void filJam();
bool updatePAT9125();
};
#endif //(FILAMENT_SENSOR_TYPE == FSENSOR_PAT9125)

View File

@ -21,7 +21,6 @@
#include "Configuration.h"
#include "pins.h"
#include "Timer.h"
#include "mmu2.h"
#include "printer_state.h"
#ifndef AT90USB
@ -64,8 +63,6 @@
#define MYSERIAL MSerial
#endif
#include "lcd.h"
#define SERIAL_PROTOCOL(x) (MYSERIAL.print(x))
#define SERIAL_PROTOCOL_F(x,y) (MYSERIAL.print(x,y))
#define SERIAL_PROTOCOLPGM(x) (serialprintPGM(PSTR(x)))
@ -124,35 +121,20 @@ void manage_inactivity(bool ignore_stepper_queue=false);
#endif
#if defined(Y_ENABLE_PIN) && Y_ENABLE_PIN > -1
#ifdef Y_DUAL_STEPPER_DRIVERS
#define enable_y() { WRITE(Y_ENABLE_PIN, Y_ENABLE_ON); WRITE(Y2_ENABLE_PIN, Y_ENABLE_ON); }
#define disable_y() { WRITE(Y_ENABLE_PIN,!Y_ENABLE_ON); WRITE(Y2_ENABLE_PIN, !Y_ENABLE_ON); axis_known_position[Y_AXIS] = false; }
#else
#define enable_y() WRITE(Y_ENABLE_PIN, Y_ENABLE_ON)
#define disable_y() { WRITE(Y_ENABLE_PIN,!Y_ENABLE_ON); axis_known_position[Y_AXIS] = false; }
#endif
#define enable_y() WRITE(Y_ENABLE_PIN, Y_ENABLE_ON)
#define disable_y() { WRITE(Y_ENABLE_PIN,!Y_ENABLE_ON); axis_known_position[Y_AXIS] = false; }
#else
#define enable_y() ;
#define disable_y() ;
#endif
#if defined(Z_ENABLE_PIN) && Z_ENABLE_PIN > -1
#if defined(Z_ENABLE_PIN) && Z_ENABLE_PIN > -1
#if defined(Z_AXIS_ALWAYS_ON)
#ifdef Z_DUAL_STEPPER_DRIVERS
#define poweron_z() { WRITE(Z_ENABLE_PIN, Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN, Z_ENABLE_ON); }
#define poweroff_z() { WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN,!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; }
#else
#define poweron_z() WRITE(Z_ENABLE_PIN, Z_ENABLE_ON)
#define poweroff_z() {}
#endif
#else
#ifdef Z_DUAL_STEPPER_DRIVERS
#define poweron_z() { WRITE(Z_ENABLE_PIN, Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN, Z_ENABLE_ON); }
#define poweroff_z() { WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN,!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; }
#else
#define poweron_z() WRITE(Z_ENABLE_PIN, Z_ENABLE_ON)
#define poweroff_z() { WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; }
#endif
#endif
#else
#define poweron_z() {}
@ -351,7 +333,7 @@ bool babystep_allowed_strict();
extern void calculate_extruder_multipliers();
// Similar to the default Arduino delay function,
// Similar to the default Arduino delay function,
// but it keeps the background tasks running.
extern void delay_keep_alive(unsigned int ms);
@ -367,9 +349,6 @@ void bed_analysis(float x_dimension, float y_dimension, int x_points_num, int y_
void bed_check(float x_dimension, float y_dimension, int x_points_num, int y_points_num, float shift_x, float shift_y);
#endif //HEATBED_ANALYSIS
float temp_comp_interpolation(float temperature);
#if 0
void show_fw_version_warnings();
#endif
uint8_t check_printer_version();
#ifdef PINDA_THERMISTOR
@ -417,7 +396,7 @@ extern uint8_t calc_percent_done();
/*enum MarlinBusyState {
NOT_BUSY, // Not in a handler
IN_HANDLER, // Processing a GCode
IN_PROCESS, // Known to be blocking command input (as in G29)
IN_PROCESS, // Known to be blocking command input
PAUSED_FOR_USER, // Blocking pending any input
PAUSED_FOR_INPUT // Blocking pending text input (concept)
};*/
@ -457,10 +436,10 @@ void gcode_M701(float fastLoadLength, uint8_t mmuSlotIndex);
#define UVLO !(PINE & (1<<4))
void M600_load_filament();
void M600_load_filament_movements();
void M600_load_filament(const char* filament_name);
void M600_load_filament_movements(const char* filament_name);
void M600_wait_for_user();
bool M600_check_state_and_repeat();
bool M600_check_state_and_repeat(const char* filament_name);
void load_filament_final_feed();
void marlin_wait_for_click();
float raise_z(float delta);

View File

@ -15,7 +15,7 @@
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Modified 23 November 2006 by David A. Mellis
Modified 28 September 2010 by Mark Sproul
*/
@ -26,7 +26,7 @@
uint8_t selectedSerialPort = 0;
#ifndef AT90USB
// this next line disables the entire HardwareSerial.cpp,
// this next line disables the entire HardwareSerial.cpp,
// this is so I can support Attiny series and any other chip without a UART
#if defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H)
@ -129,8 +129,8 @@ void MarlinSerial::begin(long baud)
sbi(M_UCSRxB, M_RXENx);
sbi(M_UCSRxB, M_TXENx);
sbi(M_UCSRxB, M_RXCIEx);
if (selectedSerialPort == 1) { //set up also the second serial port
if (selectedSerialPort == 1) { //set up also the second serial port
if (useU2X) {
UCSR1A = 1 << U2X1;
baud_setting = (F_CPU / 4 / baud - 1) / 2;
@ -142,7 +142,7 @@ void MarlinSerial::begin(long baud)
// assign the baud_setting, a.k.a. ubbr (USART Baud Rate Register)
UBRR1H = baud_setting >> 8;
UBRR1L = baud_setting;
sbi(UCSR1B, RXEN1);
sbi(UCSR1B, TXEN1);
sbi(UCSR1B, RXCIE1);
@ -250,7 +250,7 @@ void MarlinSerial::print(double n, int digits)
void MarlinSerial::println(void)
{
// print('\r');
print('\n');
print('\n');
}
/*void MarlinSerial::println(const String &s)
@ -311,13 +311,13 @@ void MarlinSerial::println(double n, int digits)
void MarlinSerial::printNumber(unsigned long n, uint8_t base)
{
unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars.
unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars.
uint8_t i = 0;
if (n == 0) {
print('0');
return;
}
}
while (n > 0) {
buf[i++] = n % base;
@ -330,8 +330,8 @@ void MarlinSerial::printNumber(unsigned long n, uint8_t base)
'A' + buf[i - 1] - 10));
}
void MarlinSerial::printFloat(double number, uint8_t digits)
{
void MarlinSerial::printFloat(double number, uint8_t digits)
{
// Handle negative numbers
if (number < 0.0)
{
@ -343,7 +343,7 @@ void MarlinSerial::printFloat(double number, uint8_t digits)
double rounding = 0.5;
for (uint8_t i=0; i<digits; ++i)
rounding /= 10.0;
number += rounding;
// Extract the integer part of the number and print it
@ -353,7 +353,7 @@ void MarlinSerial::printFloat(double number, uint8_t digits)
// Print the decimal point, but only if there are digits beyond
if (digits > 0)
print('.');
print('.');
// Extract digits from the remainder one at a time
while (digits-- > 0)
@ -361,8 +361,8 @@ void MarlinSerial::printFloat(double number, uint8_t digits)
remainder *= 10.0;
int toPrint = int(remainder);
print(toPrint);
remainder -= toPrint;
}
remainder -= toPrint;
}
}
// Preinstantiate Objects //////////////////////////////////////////////////////

View File

@ -23,7 +23,7 @@
#define MarlinSerial_h
#include "Marlin.h"
#if !defined(SERIAL_PORT)
#if !defined(SERIAL_PORT)
#define SERIAL_PORT 0
#endif
@ -34,7 +34,7 @@
(SERIAL_PORT == 3 && defined(UBRR3H)))
#define HAS_UART
#endif
// These are macros to build serial port register names for the selected SERIAL_PORT (C preprocessor
// requires two levels of indirection to expand macro values properly)
#if SERIAL_PORT == 0 && (!defined(UBRR0H) || !defined(UDR0)) // use un-numbered registers if necessary
@ -43,15 +43,15 @@
#define SERIAL_REGNAME(registerbase,number,suffix) _REGNAME(registerbase, number, suffix)
#endif
// Registers used by MarlinSerial class (these are expanded
// Registers used by MarlinSerial class (these are expanded
// depending on selected serial port
#define M_UCSRxA SERIAL_REGNAME(UCSR,SERIAL_PORT,A) // defines M_UCSRxA to be UCSRnA where n is the serial port number
#define M_UCSRxB SERIAL_REGNAME(UCSR,SERIAL_PORT,B)
#define M_RXENx SERIAL_REGNAME(RXEN,SERIAL_PORT,)
#define M_TXENx SERIAL_REGNAME(TXEN,SERIAL_PORT,)
#define M_RXCIEx SERIAL_REGNAME(RXCIE,SERIAL_PORT,)
#define M_UDREx SERIAL_REGNAME(UDRE,SERIAL_PORT,)
#define M_UDRx SERIAL_REGNAME(UDR,SERIAL_PORT,)
#define M_UCSRxB SERIAL_REGNAME(UCSR,SERIAL_PORT,B)
#define M_RXENx SERIAL_REGNAME(RXEN,SERIAL_PORT,)
#define M_TXENx SERIAL_REGNAME(TXEN,SERIAL_PORT,)
#define M_RXCIEx SERIAL_REGNAME(RXCIE,SERIAL_PORT,)
#define M_UDREx SERIAL_REGNAME(UDRE,SERIAL_PORT,)
#define M_UDRx SERIAL_REGNAME(UDR,SERIAL_PORT,)
#define M_UBRRxH SERIAL_REGNAME(UBRR,SERIAL_PORT,H)
#define M_UBRRxL SERIAL_REGNAME(UBRR,SERIAL_PORT,L)
#define M_RXCx SERIAL_REGNAME(RXC,SERIAL_PORT,)
@ -97,7 +97,7 @@ class MarlinSerial //: public Stream
static int peek(void);
static int read(void);
static void flush(void);
static /*FORCE_INLINE*/ int available(void)
{
return (unsigned int)(RX_BUFFER_SIZE + rx_buffer.head - rx_buffer.tail) % RX_BUFFER_SIZE;
@ -124,7 +124,7 @@ class MarlinSerial //: public Stream
UDR1 = c;
}
}
static void checkRx(void)
{
if (selectedSerialPort == 0) {
@ -177,15 +177,15 @@ class MarlinSerial //: public Stream
}
}
}
private:
static void printNumber(unsigned long, uint8_t);
static void printFloat(double, uint8_t);
public:
static /*FORCE_INLINE*/ void write(const char *str)
{
while (*str)
@ -205,7 +205,7 @@ class MarlinSerial //: public Stream
write(s[i]);
}
}*/
static FORCE_INLINE void print(const char *str)
{
write(str);

File diff suppressed because it is too large Load Diff

View File

@ -8,6 +8,7 @@
#include "ultralcd.h"
#include "Filament_sensor.h"
#include "language.h"
#include "lcd.h"
#include "stopwatch.h"
#ifdef PRUSA_FARM
@ -132,7 +133,7 @@ static void lcd_connect_printer() {
int i = 0;
int t = 0;
lcd_puts_at_P(0, 0, PSTR("Connect printer to"));
lcd_puts_at_P(0, 0, PSTR("Connect printer to"));
lcd_puts_at_P(0, 1, PSTR("monitoring or hold"));
lcd_puts_at_P(0, 2, PSTR("the knob to continue"));
while (no_response) {
@ -145,7 +146,7 @@ static void lcd_connect_printer() {
t = 0;
}
if (READ(BTN_ENC)) { //if button is not pressed
i = 0;
i = 0;
lcd_puts_at_P(0, 3, PSTR(" "));
}
if (i != 0)
@ -232,7 +233,7 @@ void prusa_statistics(uint8_t _message) {
const uint8_t _fil_nr = 0;
if (!farm_mode)
return;
switch (_message) {
case 0: // default message
if (busy_state == PAUSED_FOR_USER) {
@ -389,7 +390,7 @@ void prusa_statistics_update_from_lcd_update() {
}
void farm_mode_init() {
farm_mode = eeprom_init_default_byte((uint8_t*)EEPROM_FARM_MODE, 0);
farm_mode = eeprom_init_default_byte((uint8_t*)EEPROM_FARM_MODE, 0);
if (farm_mode) {
no_response = true; //we need confirmation by recieving PRUSA thx
prusa_statistics(8);
@ -410,7 +411,7 @@ void farm_mode_init() {
bool farm_prusa_code_seen() {
if (!farm_mode)
return false;
if (code_seen_P(PSTR("PRN"))) { // PRUSA PRN
printf_P(_N("%u"), status_number);
}
@ -441,7 +442,7 @@ bool farm_prusa_code_seen() {
else {
return false;
}
return true;
}

View File

@ -767,7 +767,7 @@ uint8_t Sd2Card::waitStartBlock(void) {
return false;
}
// Toshiba FlashAir support, copied from
// Toshiba FlashAir support, copied from
// https://flashair-developers.com/en/documents/tutorials/arduino/
// However, the official website was closed in September 2019.
// There is an archived website (written in Japanese).
@ -783,7 +783,7 @@ uint8_t Sd2Card::readExt(uint32_t arg, uint8_t* dst, uint16_t count) {
error(SD_CARD_ERROR_CMD48);
goto fail;
}
// wait for start block token.
if (!waitStartBlock()) {
goto fail;
@ -793,7 +793,7 @@ uint8_t Sd2Card::readExt(uint32_t arg, uint8_t* dst, uint16_t count) {
for (i = 0; i < count; ++i) {
dst[i] = spiRec();
}
// skip dummy bytes and 16-bit crc.
for (; i < 514; ++i) {
spiRec();
@ -815,19 +815,19 @@ uint8_t Sd2Card::readExt(uint32_t arg, uint8_t* dst, uint16_t count) {
* \return The value one, true, is returned for success and
* the value zero, false, is returned for failure.
*/
uint8_t Sd2Card::readExtMemory(uint8_t mio, uint8_t func,
uint8_t Sd2Card::readExtMemory(uint8_t mio, uint8_t func,
uint32_t addr, uint16_t count, uint8_t* dst) {
uint32_t offset = addr & 0x1FF;
if (offset + count > 512) count = 512 - offset;
if (count == 0) return true;
uint32_t arg =
(((uint32_t)mio & 0x1) << 31) |
uint32_t arg =
(((uint32_t)mio & 0x1) << 31) |
(mio ? (((uint32_t)func & 0x7) << 28) : (((uint32_t)func & 0xF) << 27)) |
((addr & 0x1FFFF) << 9) |
((count - 1) & 0x1FF);
return readExt(arg, dst, count);
}

View File

@ -174,7 +174,7 @@ class Sd2Card {
/**
* Read a card's CID register. The CID contains card identification
* information such as Manufacturer ID, Product name, Product serial
* number and Manufacturing date.
* number and Manufacturing date.
*
* \param[out] cid pointer to area for returned data.
*
@ -243,4 +243,4 @@ class Sd2Card {
#endif // Sd2Card_h
#endif
#endif

View File

@ -1115,7 +1115,7 @@ int8_t SdBaseFile::readDir(dir_t* dir, char* longFilename) {
int16_t n;
// if not a directory file or miss-positioned return an error
if (!isDir() || (0X1F & curPosition_)) return -1;
//If we have a longFilename buffer, mark it as invalid. If we find a long filename it will be filled automaticly.
if (longFilename != NULL)
{

View File

@ -281,7 +281,7 @@ class SdBaseFile {
static void printFatDate(uint16_t fatDate);
static void printFatTime( uint16_t fatTime);
bool printName();
protected:
protected:
int16_t read();
int16_t read(void* buf, uint16_t nbyte);
public:

View File

@ -468,29 +468,29 @@ uint32_t const FAT32MASK = 0X0FFFFFFF;
* \brief FAT short directory entry
*
* Short means short 8.3 name, not the entry size.
*
* Date Format. A FAT directory entry date stamp is a 16-bit field that is
*
* Date Format. A FAT directory entry date stamp is a 16-bit field that is
* basically a date relative to the MS-DOS epoch of 01/01/1980. Here is the
* format (bit 0 is the LSB of the 16-bit word, bit 15 is the MSB of the
* format (bit 0 is the LSB of the 16-bit word, bit 15 is the MSB of the
* 16-bit word):
*
* Bits 9-15: Count of years from 1980, valid value range 0-127
*
* Bits 9-15: Count of years from 1980, valid value range 0-127
* inclusive (1980-2107).
*
*
* Bits 5-8: Month of year, 1 = January, valid value range 1-12 inclusive.
*
* Bits 0-4: Day of month, valid value range 1-31 inclusive.
*
* Time Format. A FAT directory entry time stamp is a 16-bit field that has
* a granularity of 2 seconds. Here is the format (bit 0 is the LSB of the
* a granularity of 2 seconds. Here is the format (bit 0 is the LSB of the
* 16-bit word, bit 15 is the MSB of the 16-bit word).
*
*
* Bits 11-15: Hours, valid value range 0-23 inclusive.
*
*
* Bits 5-10: Minutes, valid value range 0-59 inclusive.
*
*
* Bits 0-4: 2-second count, valid value range 0-29 inclusive (0 - 58 seconds).
*
*
* The valid time range is from Midnight 00:00:00 to 23:59:58.
*/
struct directoryEntry {
@ -548,7 +548,7 @@ struct directoryEntry {
*
* directoryVFATEntries are found in the same list as normal directoryEntry.
* But have the attribute field set to DIR_ATT_LONG_NAME.
*
*
* Long filenames are saved in multiple directoryVFATEntries.
* Each entry containing 13 UTF-16 characters.
*/

View File

@ -45,7 +45,7 @@ int SdFatUtil::FreeRam() {
#endif // __arm
void SdFatUtil::set_stack_guard()
{
{
uint32_t *stack_guard;
stack_guard = (uint32_t*)(&__bss_end + STACK_GUARD_MARGIN);

View File

@ -87,7 +87,7 @@ int16_t SdFile::readFilteredGcode(){
// It may seem unreasonable to copy the variable into a local one and copy it back at the end of this method,
// but there is an important point of view: the compiler is unsure whether it can optimize the reads/writes
// to gfReadPtr within this method, because it is a class member variable.
// to gfReadPtr within this method, because it is a class member variable.
// The compiler cannot see, if omitting read/write won't have any incorrect side-effects to the rest of the whole FW.
// So this trick explicitly states, that rdPtr is a local variable limited to the scope of this method,
// therefore the compiler can omit read/write to it (keep it in registers!) as it sees fit.
@ -96,7 +96,7 @@ int16_t SdFile::readFilteredGcode(){
// the same applies to gfXBegin, codesize dropped another 100B!
const uint8_t *blockBuffBegin = gfBlockBuffBegin();
uint8_t consecutiveCommentLines = 0;
while( *rdPtr == ';' ){
for(;;){
@ -104,8 +104,8 @@ int16_t SdFile::readFilteredGcode(){
//while( *(++gfReadPtr) != '\n' ); // skip until a newline is found - suboptimal code!
// Wondering, why this "nice while cycle" is done in such a weird way using a separate find_endl() function?
// Have a look at the ASM code GCC produced!
// At first - a separate find_endl() makes the compiler understand,
// At first - a separate find_endl() makes the compiler understand,
// that I don't need to store gfReadPtr every time, I'm only interested in the final address where the '\n' was found
// - the cycle can run on CPU registers only without touching memory besides reading the character being compared.
// Not only makes the code run considerably faster, but is also 40B shorter!
@ -118,7 +118,7 @@ int16_t SdFile::readFilteredGcode(){
// 11c62: sbci r19, 0xFF ; 255
// 11c64: ld r22, Z
// 11c66: cpi r22, 0x0A ; 10
// 11c68: brne .-12 ; 0x11c5e <get_command()+0x524>
// 11c68: brne .-12 ; 0x11c5e <get_command()+0x524>
// Still, even that was suboptimal as the compiler seems not to understand the usage of ld r22, Z+ (the plus is important)
// aka automatic increment of the Z register (R30:R31 pair)
@ -153,7 +153,7 @@ emit_char:
{
gfUpdateCurrentPosition( rdPtr - start + 1 );
int16_t rv = *rdPtr++;
if( curPosition_ >= fileSize_ ){
// past the end of file
goto eof_or_fail;
@ -200,7 +200,7 @@ bool SdFile::gfComputeNextFileBlock() {
// SHR by 9 means skip the last byte and shift just 3 bytes by 1
// -> should be 8 instructions... and not the horrible loop shifting 4 bytes at once
// still need to get some work on this
gfBlock = vol_->rootDirStart() + (curPosition_ >> 9);
gfBlock = vol_->rootDirStart() + (curPosition_ >> 9);
} else {
uint8_t blockOfCluster = vol_->blockOfCluster(curPosition_);
if (gfOffset == 0 && blockOfCluster == 0) {

View File

@ -35,19 +35,19 @@
*/
class SdFile : public SdBaseFile/*, public Print*/ {
// GCode filtering vars and methods - due to optimization reasons not wrapped in a separate class
// beware - this read ptr is manipulated inside just 2 methods - readFilteredGcode and gfReset
// If you even want to call gfReset from readFilteredGcode, you must make sure
// to update gfReadPtr inside readFilteredGcode from a local copy (see explanation of this trick in readFilteredGcode)
const uint8_t *gfReadPtr;
uint32_t gfBlock; // remember the current file block to be kept in cache - due to reuse of the memory, the block may fall out a must be read back
uint16_t gfOffset;
const uint8_t *gfBlockBuffBegin()const;
void gfReset();
bool gfEnsureBlock();
bool gfComputeNextFileBlock();
void gfUpdateCurrentPosition(uint16_t inc);
@ -59,7 +59,7 @@ public:
#else
void write(uint8_t b);
#endif
bool openFilteredGcode(SdBaseFile* dirFile, const char* path);
int16_t readFilteredGcode();
bool seekSetFilteredGcode(uint32_t pos);

View File

@ -1,344 +0,0 @@
/*
Servo.cpp - Interrupt driven Servo library for Arduino using 16 bit timers- Version 2
Copyright (c) 2009 Michael Margolis. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
A servo is activated by creating an instance of the Servo class passing the desired pin to the attach() method.
The servos are pulsed in the background using the value most recently written using the write() method
Note that analogWrite of PWM on pins associated with the timer are disabled when the first servo is attached.
Timers are seized as needed in groups of 12 servos - 24 servos use two timers, 48 servos will use four.
The methods are:
Servo - Class for manipulating servo motors connected to Arduino pins.
attach(pin ) - Attaches a servo motor to an i/o pin.
attach(pin, min, max ) - Attaches to a pin setting min and max values in microseconds
default min is 544, max is 2400
write() - Sets the servo angle in degrees. (invalid angle that is valid as pulse in microseconds is treated as microseconds)
writeMicroseconds() - Sets the servo pulse width in microseconds
read() - Gets the last written servo pulse width as an angle between 0 and 180.
readMicroseconds() - Gets the last written servo pulse width in microseconds. (was read_us() in first release)
attached() - Returns true if there is a servo attached.
detach() - Stops an attached servos from pulsing its i/o pin.
*/
#include "Configuration.h"
#ifdef NUM_SERVOS
#include <avr/interrupt.h>
#include <Arduino.h>
#include "Servo.h"
#define usToTicks(_us) (( clockCyclesPerMicrosecond()* _us) / 8) // converts microseconds to tick (assumes prescale of 8) // 12 Aug 2009
#define ticksToUs(_ticks) (( (unsigned)_ticks * 8)/ clockCyclesPerMicrosecond() ) // converts from ticks back to microseconds
#define TRIM_DURATION 2 // compensation ticks to trim adjust for digitalWrite delays // 12 August 2009
//#define NBR_TIMERS (MAX_SERVOS / SERVOS_PER_TIMER)
static servo_t servos[MAX_SERVOS]; // static array of servo structures
static volatile int8_t Channel[_Nbr_16timers ]; // counter for the servo being pulsed for each timer (or -1 if refresh interval)
uint8_t ServoCount = 0; // the total number of attached servos
// convenience macros
#define SERVO_INDEX_TO_TIMER(_servo_nbr) ((timer16_Sequence_t)(_servo_nbr / SERVOS_PER_TIMER)) // returns the timer controlling this servo
#define SERVO_INDEX_TO_CHANNEL(_servo_nbr) (_servo_nbr % SERVOS_PER_TIMER) // returns the index of the servo on this timer
#define SERVO_INDEX(_timer,_channel) ((_timer*SERVOS_PER_TIMER) + _channel) // macro to access servo index by timer and channel
#define SERVO(_timer,_channel) (servos[SERVO_INDEX(_timer,_channel)]) // macro to access servo class by timer and channel
#define SERVO_MIN() (MIN_PULSE_WIDTH - this->min * 4) // minimum value in uS for this servo
#define SERVO_MAX() (MAX_PULSE_WIDTH - this->max * 4) // maximum value in uS for this servo
/************ static functions common to all instances ***********************/
static inline void handle_interrupts(timer16_Sequence_t timer, volatile uint16_t *TCNTn, volatile uint16_t* OCRnA)
{
if( Channel[timer] < 0 )
*TCNTn = 0; // channel set to -1 indicated that refresh interval completed so reset the timer
else{
if( SERVO_INDEX(timer,Channel[timer]) < ServoCount && SERVO(timer,Channel[timer]).Pin.isActive == true )
digitalWrite( SERVO(timer,Channel[timer]).Pin.nbr,LOW); // pulse this channel low if activated
}
Channel[timer]++; // increment to the next channel
if( SERVO_INDEX(timer,Channel[timer]) < ServoCount && Channel[timer] < SERVOS_PER_TIMER) {
*OCRnA = *TCNTn + SERVO(timer,Channel[timer]).ticks;
if(SERVO(timer,Channel[timer]).Pin.isActive == true) // check if activated
digitalWrite( SERVO(timer,Channel[timer]).Pin.nbr,HIGH); // its an active channel so pulse it high
}
else {
// finished all channels so wait for the refresh period to expire before starting over
if( ((unsigned)*TCNTn) + 4 < usToTicks(REFRESH_INTERVAL) ) // allow a few ticks to ensure the next OCR1A not missed
*OCRnA = (unsigned int)usToTicks(REFRESH_INTERVAL);
else
*OCRnA = *TCNTn + 4; // at least REFRESH_INTERVAL has elapsed
Channel[timer] = -1; // this will get incremented at the end of the refresh period to start again at the first channel
}
}
#ifndef WIRING // Wiring pre-defines signal handlers so don't define any if compiling for the Wiring platform
// Interrupt handlers for Arduino
#if defined(_useTimer1)
SIGNAL (TIMER1_COMPA_vect)
{
handle_interrupts(_timer1, &TCNT1, &OCR1A);
}
#endif
#if defined(_useTimer3)
SIGNAL (TIMER3_COMPA_vect)
{
handle_interrupts(_timer3, &TCNT3, &OCR3A);
}
#endif
#if defined(_useTimer4)
SIGNAL (TIMER4_COMPA_vect)
{
handle_interrupts(_timer4, &TCNT4, &OCR4A);
}
#endif
#if defined(_useTimer5)
SIGNAL (TIMER5_COMPA_vect)
{
handle_interrupts(_timer5, &TCNT5, &OCR5A);
}
#endif
#elif defined WIRING
// Interrupt handlers for Wiring
#if defined(_useTimer1)
void Timer1Service()
{
handle_interrupts(_timer1, &TCNT1, &OCR1A);
}
#endif
#if defined(_useTimer3)
void Timer3Service()
{
handle_interrupts(_timer3, &TCNT3, &OCR3A);
}
#endif
#endif
static void initISR(timer16_Sequence_t timer)
{
#if defined (_useTimer1)
if(timer == _timer1) {
TCCR1A = 0; // normal counting mode
TCCR1B = _BV(CS11); // set prescaler of 8
TCNT1 = 0; // clear the timer count
#if defined(__AVR_ATmega8__)|| defined(__AVR_ATmega128__)
TIFR |= _BV(OCF1A); // clear any pending interrupts;
TIMSK |= _BV(OCIE1A) ; // enable the output compare interrupt
#else
// here if not ATmega8 or ATmega128
TIFR1 |= _BV(OCF1A); // clear any pending interrupts;
TIMSK1 |= _BV(OCIE1A) ; // enable the output compare interrupt
#endif
#if defined(WIRING)
timerAttach(TIMER1OUTCOMPAREA_INT, Timer1Service);
#endif
}
#endif
#if defined (_useTimer3)
if(timer == _timer3) {
TCCR3A = 0; // normal counting mode
TCCR3B = _BV(CS31); // set prescaler of 8
TCNT3 = 0; // clear the timer count
#if defined(__AVR_ATmega128__)
TIFR |= _BV(OCF3A); // clear any pending interrupts;
ETIMSK |= _BV(OCIE3A); // enable the output compare interrupt
#else
TIFR3 = _BV(OCF3A); // clear any pending interrupts;
TIMSK3 = _BV(OCIE3A) ; // enable the output compare interrupt
#endif
#if defined(WIRING)
timerAttach(TIMER3OUTCOMPAREA_INT, Timer3Service); // for Wiring platform only
#endif
}
#endif
#if defined (_useTimer4)
if(timer == _timer4) {
TCCR4A = 0; // normal counting mode
TCCR4B = _BV(CS41); // set prescaler of 8
TCNT4 = 0; // clear the timer count
TIFR4 = _BV(OCF4A); // clear any pending interrupts;
TIMSK4 = _BV(OCIE4A) ; // enable the output compare interrupt
}
#endif
#if defined (_useTimer5)
if(timer == _timer5) {
TCCR5A = 0; // normal counting mode
TCCR5B = _BV(CS51); // set prescaler of 8
TCNT5 = 0; // clear the timer count
TIFR5 = _BV(OCF5A); // clear any pending interrupts;
TIMSK5 = _BV(OCIE5A) ; // enable the output compare interrupt
}
#endif
}
static void finISR(timer16_Sequence_t timer)
{
//disable use of the given timer
#if defined WIRING // Wiring
if(timer == _timer1) {
#if defined(__AVR_ATmega1281__)||defined(__AVR_ATmega2561__)
TIMSK1 &= ~_BV(OCIE1A) ; // disable timer 1 output compare interrupt
#else
TIMSK &= ~_BV(OCIE1A) ; // disable timer 1 output compare interrupt
#endif
timerDetach(TIMER1OUTCOMPAREA_INT);
}
else if(timer == _timer3) {
#if defined(__AVR_ATmega1281__)||defined(__AVR_ATmega2561__)
TIMSK3 &= ~_BV(OCIE3A); // disable the timer3 output compare A interrupt
#else
ETIMSK &= ~_BV(OCIE3A); // disable the timer3 output compare A interrupt
#endif
timerDetach(TIMER3OUTCOMPAREA_INT);
}
#else
//For arduino - in future: call here to a currently undefined function to reset the timer
#endif
}
static bool isTimerActive(timer16_Sequence_t timer)
{
// returns true if any servo is active on this timer
for(uint8_t channel=0; channel < SERVOS_PER_TIMER; channel++) {
if(SERVO(timer,channel).Pin.isActive == true)
return true;
}
return false;
}
/****************** end of static functions ******************************/
Servo::Servo()
{
if( ServoCount < MAX_SERVOS) {
this->servoIndex = ServoCount++; // assign a servo index to this instance
servos[this->servoIndex].ticks = usToTicks(DEFAULT_PULSE_WIDTH); // store default values - 12 Aug 2009
}
else
this->servoIndex = INVALID_SERVO ; // too many servos
}
uint8_t Servo::attach(int pin)
{
return this->attach(pin, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH);
}
uint8_t Servo::attach(int pin, int min, int max)
{
if(this->servoIndex < MAX_SERVOS ) {
#if defined (ENABLE_AUTO_BED_LEVELING) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
if (pin > 0) this->pin = pin; else pin = this->pin;
#endif
pinMode( pin, OUTPUT) ; // set servo pin to output
servos[this->servoIndex].Pin.nbr = pin;
// todo min/max check: abs(min - MIN_PULSE_WIDTH) /4 < 128
this->min = (MIN_PULSE_WIDTH - min)/4; //resolution of min/max is 4 uS
this->max = (MAX_PULSE_WIDTH - max)/4;
// initialize the timer if it has not already been initialized
timer16_Sequence_t timer = SERVO_INDEX_TO_TIMER(servoIndex);
if(isTimerActive(timer) == false)
initISR(timer);
servos[this->servoIndex].Pin.isActive = true; // this must be set after the check for isTimerActive
}
return this->servoIndex ;
}
void Servo::detach()
{
servos[this->servoIndex].Pin.isActive = false;
timer16_Sequence_t timer = SERVO_INDEX_TO_TIMER(servoIndex);
if(isTimerActive(timer) == false) {
finISR(timer);
}
}
void Servo::write(int value)
{
if(value < MIN_PULSE_WIDTH)
{ // treat values less than 544 as angles in degrees (valid values in microseconds are handled as microseconds)
if(value < 0) value = 0;
if(value > 180) value = 180;
value = map(value, 0, 180, SERVO_MIN(), SERVO_MAX());
}
this->writeMicroseconds(value);
}
void Servo::writeMicroseconds(int value)
{
// calculate and store the values for the given channel
byte channel = this->servoIndex;
if( (channel < MAX_SERVOS) ) // ensure channel is valid
{
if( value < SERVO_MIN() ) // ensure pulse width is valid
value = SERVO_MIN();
else if( value > SERVO_MAX() )
value = SERVO_MAX();
value = value - TRIM_DURATION;
value = usToTicks(value); // convert to ticks after compensating for interrupt overhead - 12 Aug 2009
uint8_t oldSREG = SREG;
cli();
servos[channel].ticks = value;
SREG = oldSREG;
}
}
int Servo::read() // return the value as degrees
{
return map( this->readMicroseconds()+1, SERVO_MIN(), SERVO_MAX(), 0, 180);
}
int Servo::readMicroseconds()
{
unsigned int pulsewidth;
if( this->servoIndex != INVALID_SERVO )
pulsewidth = ticksToUs(servos[this->servoIndex].ticks) + TRIM_DURATION ; // 12 aug 2009
else
pulsewidth = 0;
return pulsewidth;
}
bool Servo::attached()
{
return servos[this->servoIndex].Pin.isActive ;
}
#endif

View File

@ -1,135 +0,0 @@
/*
Servo.h - Interrupt driven Servo library for Arduino using 16 bit timers- Version 2
Copyright (c) 2009 Michael Margolis. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
A servo is activated by creating an instance of the Servo class passing the desired pin to the attach() method.
The servos are pulsed in the background using the value most recently written using the write() method
Note that analogWrite of PWM on pins associated with the timer are disabled when the first servo is attached.
Timers are seized as needed in groups of 12 servos - 24 servos use two timers, 48 servos will use four.
The sequence used to seize timers is defined in timers.h
The methods are:
Servo - Class for manipulating servo motors connected to Arduino pins.
attach(pin ) - Attaches a servo motor to an i/o pin.
attach(pin, min, max ) - Attaches to a pin setting min and max values in microseconds
default min is 544, max is 2400
write() - Sets the servo angle in degrees. (invalid angle that is valid as pulse in microseconds is treated as microseconds)
writeMicroseconds() - Sets the servo pulse width in microseconds
read() - Gets the last written servo pulse width as an angle between 0 and 180.
readMicroseconds() - Gets the last written servo pulse width in microseconds. (was read_us() in first release)
attached() - Returns true if there is a servo attached.
detach() - Stops an attached servos from pulsing its i/o pin.
*/
#ifndef Servo_h
#define Servo_h
#include <inttypes.h>
/*
* Defines for 16 bit timers used with Servo library
*
* If _useTimerX is defined then TimerX is a 16 bit timer on the current board
* timer16_Sequence_t enumerates the sequence that the timers should be allocated
* _Nbr_16timers indicates how many 16 bit timers are available.
*
*/
// Say which 16 bit timers can be used and in what order
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
#define _useTimer5
//#define _useTimer1
#define _useTimer3
#define _useTimer4
//typedef enum { _timer5, _timer1, _timer3, _timer4, _Nbr_16timers } timer16_Sequence_t ;
typedef enum { _timer5, _timer3, _timer4, _Nbr_16timers } timer16_Sequence_t ;
#elif defined(__AVR_ATmega32U4__)
//#define _useTimer1
#define _useTimer3
//typedef enum { _timer1, _Nbr_16timers } timer16_Sequence_t ;
typedef enum { _timer3, _Nbr_16timers } timer16_Sequence_t ;
#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
#define _useTimer3
//#define _useTimer1
//typedef enum { _timer3, _timer1, _Nbr_16timers } timer16_Sequence_t ;
typedef enum { _timer3, _Nbr_16timers } timer16_Sequence_t ;
#elif defined(__AVR_ATmega128__) ||defined(__AVR_ATmega1281__) || defined(__AVR_ATmega1284P__) ||defined(__AVR_ATmega2561__)
#define _useTimer3
//#define _useTimer1
//typedef enum { _timer3, _timer1, _Nbr_16timers } timer16_Sequence_t ;
typedef enum { _timer3, _Nbr_16timers } timer16_Sequence_t ;
#else // everything else
//#define _useTimer1
//typedef enum { _timer1, _Nbr_16timers } timer16_Sequence_t ;
typedef enum { _Nbr_16timers } timer16_Sequence_t ;
#endif
#define Servo_VERSION 2 // software version of this library
#define MIN_PULSE_WIDTH 544 // the shortest pulse sent to a servo
#define MAX_PULSE_WIDTH 2400 // the longest pulse sent to a servo
#define DEFAULT_PULSE_WIDTH 1500 // default pulse width when servo is attached
#define REFRESH_INTERVAL 20000 // minimum time to refresh servos in microseconds
#define SERVOS_PER_TIMER 12 // the maximum number of servos controlled by one timer
#define MAX_SERVOS (_Nbr_16timers * SERVOS_PER_TIMER)
#define INVALID_SERVO 255 // flag indicating an invalid servo index
typedef struct {
uint8_t nbr :6 ; // a pin number from 0 to 63
uint8_t isActive :1 ; // true if this channel is enabled, pin not pulsed if false
} ServoPin_t ;
typedef struct {
ServoPin_t Pin;
unsigned int ticks;
} servo_t;
class Servo
{
public:
Servo();
uint8_t attach(int pin); // attach the given pin to the next free channel, sets pinMode, returns channel number or 0 if failure
uint8_t attach(int pin, int min, int max); // as above but also sets min and max values for writes.
void detach();
void write(int value); // if value is < 200 it is treated as an angle, otherwise as pulse width in microseconds
void writeMicroseconds(int value); // Write pulse width in microseconds
int read(); // returns current pulse width as an angle between 0 and 180 degrees
int readMicroseconds(); // returns current pulse width in microseconds for this servo (was read_us() in first release)
bool attached(); // return true if this servo is attached, otherwise false
#if defined (ENABLE_AUTO_BED_LEVELING) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
int pin; // store the hardware pin of the servo
#endif
private:
uint8_t servoIndex; // index into the channel data for this servo
int8_t min; // minimum is this value times 4 added to MIN_PULSE_WIDTH
int8_t max; // maximum is this value times 4 added to MAX_PULSE_WIDTH
};
#endif

View File

@ -55,7 +55,7 @@ uint8_t SpoolJoin::nextSlot()
SERIAL_ECHOPGM("SpoolJoin: ");
SERIAL_ECHO((int)currentMMUSlot);
if (currentMMUSlot >= 4) currentMMUSlot = 0;
if (currentMMUSlot >= MMU_FILAMENT_COUNT-1) currentMMUSlot = 0;
else currentMMUSlot++;
SERIAL_ECHOPGM(" -> ");

View File

@ -11,12 +11,12 @@
static const char duplicate_Tcode_ignored[] PROGMEM = "Duplicate T-code ignored.";
inline bool IsInvalidTCode(char *const s, uint8_t i) {
return ((s[i] < '0' || s[i] > '4') && s[i] != '?' && s[i] != 'x' && s[i] != 'c');
inline bool IsInvalidTCode(char *const s, uint8_t i) {
return ((s[i] < '0' || s[i] > '4') && s[i] != '?' && s[i] != 'x' && s[i] != 'c');
}
inline void TCodeInvalid() {
SERIAL_ECHOLNPGM("Invalid T code.");
inline void TCodeInvalid() {
SERIAL_ECHOLNPGM("Invalid T code.");
}
void TCodes(char *const strchr_pointer, const uint8_t codeValue) {
@ -31,7 +31,7 @@ void TCodes(char *const strchr_pointer, const uint8_t codeValue) {
} else if (strchr_pointer[index] == 'x' || strchr_pointer[index] == '?'){
// load to extruder gears; if mmu is not present do nothing
if (MMU2::mmu2.Enabled()) {
MMU2::mmu2.tool_change(strchr_pointer[index], choose_menu_P(_T(MSG_SELECT_FILAMENT), _T(MSG_FILAMENT)));
MMU2::mmu2.tool_change(strchr_pointer[index], choose_menu_P(_T(MSG_SELECT_FILAMENT), MSG_FILAMENT));
}
} else if (strchr_pointer[index] == 'c'){
// load from extruder gears to nozzle (nozzle should be preheated)
@ -40,7 +40,7 @@ void TCodes(char *const strchr_pointer, const uint8_t codeValue) {
}
} else { // Process T0 ... T4
if (MMU2::mmu2.Enabled()) {
if (codeValue == MMU2::mmu2.get_current_tool()){
if (codeValue == MMU2::mmu2.get_current_tool()){
// don't execute the same T-code twice in a row
puts_P(duplicate_Tcode_ignored);
} else {

View File

@ -17,7 +17,7 @@ bool backlightSupport = 0; //only if it's true will any of the settings be visib
uint8_t backlightLevel_HIGH = 0;
uint8_t backlightLevel_LOW = 0;
uint8_t backlightMode = BACKLIGHT_MODE_BRIGHT;
int16_t backlightTimer_period = 10;
int16_t backlightTimer_period = LCD_BACKLIGHT_TIMEOUT;
LongTimer backlightTimer;
static void backlightTimer_reset() //used for resetting the timer and waking the display. Triggered on user interactions.
@ -32,7 +32,7 @@ void force_bl_on(bool section_start)
if (section_start)
{
backlightMode = BACKLIGHT_MODE_BRIGHT;
if (backlightLevel_HIGH < 30) backlightLevel_HIGH = 30;
if (backlightLevel_HIGH < LCD_BACKLIGHT_FORCE_ON) backlightLevel_HIGH = LCD_BACKLIGHT_FORCE_ON;
}
else
{
@ -45,7 +45,7 @@ void force_bl_on(bool section_start)
void backlight_wake(const uint8_t flashNo)
{
if (!backlightSupport) return;
if (flashNo)
{
uint8_t backlightMode_bck = backlightMode;
@ -71,7 +71,7 @@ void backlight_save() //saves all backlight data to eeprom.
void backlight_update()
{
if (!backlightSupport) return;
if (backlightMode == BACKLIGHT_MODE_AUTO)
{
if (backlightTimer.expired((uint32_t)backlightTimer_period * 1000ul)) analogWrite(LCD_BL_PIN, backlightLevel_LOW);
@ -93,9 +93,9 @@ void backlight_init()
//initialize backlight
backlightMode = eeprom_init_default_byte((uint8_t *)EEPROM_BACKLIGHT_MODE, BACKLIGHT_MODE_AUTO);
backlightLevel_HIGH = eeprom_init_default_byte((uint8_t *)EEPROM_BACKLIGHT_LEVEL_HIGH, 130);
backlightLevel_LOW = eeprom_init_default_byte((uint8_t *)EEPROM_BACKLIGHT_LEVEL_LOW, 50);
backlightTimer_period = eeprom_init_default_word((uint16_t *)EEPROM_BACKLIGHT_TIMEOUT, 10); // in seconds
backlightLevel_HIGH = eeprom_init_default_byte((uint8_t *)EEPROM_BACKLIGHT_LEVEL_HIGH, LCD_BACKLIGHT_LEVEL_HIGH);
backlightLevel_LOW = eeprom_init_default_byte((uint8_t *)EEPROM_BACKLIGHT_LEVEL_LOW, LCD_BACKLIGHT_LEVEL_LOW);
backlightTimer_period = eeprom_init_default_word((uint16_t *)EEPROM_BACKLIGHT_TIMEOUT, LCD_BACKLIGHT_TIMEOUT); // in seconds
SET_OUTPUT(LCD_BL_PIN);
backlightTimer_reset();

View File

@ -35,20 +35,20 @@ CardReader::CardReader()
lastnr=0;
//power to SD reader
#if SDPOWER > -1
SET_OUTPUT(SDPOWER);
SET_OUTPUT(SDPOWER);
WRITE(SDPOWER,HIGH);
#endif //SDPOWER
autostart_atmillis.start(); // reset timer
}
char *createFilename(char *buffer,const dir_t &p) //buffer>12characters
{
char *pos=buffer;
for (uint8_t i = 0; i < 11; i++)
for (uint8_t i = 0; i < 11; i++)
{
if (p.name[i] == ' ')continue;
if (i == 8)
if (i == 8)
{
*pos++='.';
}
@ -74,7 +74,7 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m
_incrementer() {recursionCnt++;}
~_incrementer() {recursionCnt--;}
} recursionCntIncrementer;
dir_t p;
uint8_t cnt = 0;
// Read the next entry from a directory
@ -103,10 +103,10 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m
// Serial.print(path);
// Get a new directory object using the full path
// and dive recursively into it.
if (lsParams.LFN)
printf_P(PSTR("DIR_ENTER: %s \"%s\"\n"), path, longFilename[0] ? longFilename : lfilename);
SdFile dir;
if (!dir.open(parent, lfilename, O_READ)) {
//SERIAL_ECHO_START();
@ -115,7 +115,7 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m
}
lsDive(path, dir, NULL, lsAction, lsParams);
// close() is done automatically by destructor of SdFile
if (lsParams.LFN)
puts_P(PSTR("DIR_EXIT"));
}
@ -126,15 +126,15 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m
case LS_Count:
nrFiles++;
break;
case LS_SerialPrint:
createFilename(filename, p);
SERIAL_PROTOCOL(prepend);
SERIAL_PROTOCOL(filename);
MYSERIAL.write(' ');
SERIAL_PROTOCOL(p.fileSize);
if (lsParams.timestamp)
{
crmodDate = p.lastWriteDate;
@ -145,14 +145,14 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m
}
printf_P(PSTR(" %#lx"), ((uint32_t)crmodDate << 16) | crmodTime);
}
if (lsParams.LFN)
printf_P(PSTR(" \"%s\""), LONGEST_FILENAME);
SERIAL_PROTOCOLLN();
manage_heater();
break;
case LS_GetFilename:
//SERIAL_ECHOPGM("File: ");
createFilename(filename, p);
@ -219,12 +219,12 @@ void CardReader::mount(bool doPresort/* = true*/)
SERIAL_ERROR_START;
SERIAL_ERRORLNRPGM(_n("volume.init failed"));////MSG_SD_VOL_INIT_FAIL
}
else if (!root.openRoot(&volume))
else if (!root.openRoot(&volume))
{
SERIAL_ERROR_START;
SERIAL_ERRORLNRPGM(_n("openRoot failed"));////MSG_SD_OPENROOT_FAIL
}
else
else
{
mounted = true;
SERIAL_ECHO_START;
@ -276,7 +276,7 @@ void CardReader::openLogFile(const char* name)
}
void CardReader::getDirName(char* name, uint8_t level)
{
{
workDirParents[level].getFilename(name);
}
@ -291,7 +291,7 @@ void CardReader::getAbsFilename(char *t)
for(uint8_t i=0;i<workDirDepth;i++)
{
workDirParents[i].getFilename(t); //SDBaseFile.getfilename!
while(*t!=0 && cnt< MAXPATHNAMELENGTH)
while(*t!=0 && cnt< MAXPATHNAMELENGTH)
{t++;cnt++;} //crawl counter forward.
}
if(cnt < MAXPATHNAMELENGTH - FILENAME_LENGTH)
@ -386,7 +386,7 @@ static const char ofWritingToFile[] PROGMEM = "Writing to file: ";
void CardReader::openFileReadFilteredGcode(const char* name, bool replace_current/* = false*/){
if(!mounted)
return;
if(file.isOpen()){ //replacing current file by new file, or subfile call
if(!replace_current){
if((int)file_subcall_ctr>(int)SD_PROCEDURE_DEPTH-1){
@ -396,15 +396,15 @@ void CardReader::openFileReadFilteredGcode(const char* name, bool replace_curren
kill(ofKill);
return;
}
SERIAL_ECHO_START;
SERIAL_ECHORPGM(ofSubroutineCallTgt);
SERIAL_ECHO(name);
SERIAL_ECHORPGM(ofParent);
//store current filename and position
getAbsFilename(filenames[file_subcall_ctr]);
SERIAL_ECHO(filenames[file_subcall_ctr]);
SERIAL_ECHORPGM(ofPos);
SERIAL_ECHOLN(sdpos);
@ -423,11 +423,11 @@ void CardReader::openFileReadFilteredGcode(const char* name, bool replace_curren
SERIAL_ECHOLN(name);
}
sdprinting = false;
const char *fname=name;
if (!diveSubfolder(fname))
return;
if (file.openFilteredGcode(curDir, fname)) {
getfilename(0, fname);
filesize = file.fileSize();
@ -436,7 +436,7 @@ void CardReader::openFileReadFilteredGcode(const char* name, bool replace_curren
SERIAL_PROTOCOLRPGM(ofSize);////MSG_SD_SIZE
SERIAL_PROTOCOLLN(filesize);
sdpos = 0;
SERIAL_PROTOCOLLNRPGM(ofFileSelected);////MSG_SD_FILE_SELECTED
lcd_setstatuspgm(ofFileSelected);
scrollstuff = 0;
@ -463,15 +463,15 @@ void CardReader::openFileWrite(const char* name)
kill(ofKill);
return;
}
SERIAL_ECHO_START;
SERIAL_ECHORPGM(ofSubroutineCallTgt);
SERIAL_ECHO(name);
SERIAL_ECHORPGM(ofParent);
//store current filename and position
getAbsFilename(filenames[file_subcall_ctr]);
SERIAL_ECHO(filenames[file_subcall_ctr]);
SERIAL_ECHORPGM(ofPos);
SERIAL_ECHOLN(sdpos);
@ -488,11 +488,11 @@ void CardReader::openFileWrite(const char* name)
SERIAL_ECHOLN(name);
}
sdprinting = false;
const char *fname=name;
if (!diveSubfolder(fname))
return;
//write
if (!file.open(curDir, fname, O_CREAT | O_APPEND | O_WRITE | O_TRUNC)){
SERIAL_PROTOCOLRPGM(MSG_SD_OPEN_FILE_FAIL);
@ -504,7 +504,7 @@ void CardReader::openFileWrite(const char* name)
SERIAL_PROTOCOLRPGM(ofWritingToFile);////MSG_SD_WRITE_TO_FILE
printAbsFilenameFast();
SERIAL_PROTOCOLLN();
SERIAL_PROTOCOLLNRPGM(ofFileSelected);////MSG_SD_FILE_SELECTED
lcd_setstatuspgm(ofFileSelected);
scrollstuff = 0;
@ -521,7 +521,7 @@ void CardReader::removeFile(const char* name)
if (!diveSubfolder(fname))
return;
if (file.remove(curDir, fname))
if (file.remove(curDir, fname))
{
SERIAL_PROTOCOLPGM("File deleted:");
SERIAL_PROTOCOLLN(fname);
@ -536,7 +536,7 @@ void CardReader::removeFile(const char* name)
SERIAL_PROTOCOL(fname);
SERIAL_PROTOCOLLN('.');
}
}
uint32_t CardReader::getFileSize()
@ -562,7 +562,7 @@ void CardReader::getStatus(bool arg_P)
}
else
SERIAL_PROTOCOLLN(LONGEST_FILENAME);
SERIAL_PROTOCOLRPGM(_N("SD printing byte "));////MSG_SD_PRINTING_BYTE
SERIAL_PROTOCOL(sdpos);
SERIAL_PROTOCOL('/');
@ -605,7 +605,7 @@ void CardReader::checkautostart(bool force)
{
// The SD start is delayed because otherwise the serial cannot answer
// fast enough to make contact with the host software.
static bool autostart_stilltocheck = true;
static bool autostart_stilltocheck = true;
if(!force)
{
if(!autostart_stilltocheck)
@ -620,7 +620,7 @@ void CardReader::checkautostart(bool force)
if(!mounted) //fail
return;
}
char autoname[30];
sprintf_P(autoname, PSTR("auto%i.g"), lastnr);
for(int8_t i=0;i<(int8_t)strlen(autoname);i++)
@ -628,9 +628,9 @@ void CardReader::checkautostart(bool force)
dir_t p;
root.rewind();
bool found=false;
while (root.readDir(p, NULL) > 0)
while (root.readDir(p, NULL) > 0)
{
for(int8_t i=0;i<(int8_t)strlen((char*)p.name);i++)
p.name[i]=tolower(p.name[i]);
@ -657,17 +657,17 @@ void CardReader::closefile(bool store_location)
{
file.sync();
file.close();
saving = false;
saving = false;
logging = false;
if(store_location)
{
//future: store printer state, filename and position for continuing a stopped print
// so one can unplug the printer and continue printing the next day.
}
}
void CardReader::getfilename(uint16_t nr, const char * const match/*=NULL*/)
@ -676,7 +676,7 @@ void CardReader::getfilename(uint16_t nr, const char * const match/*=NULL*/)
nrFiles=nr;
curDir->rewind();
lsDive("",*curDir,match, LS_GetFilename);
}
void CardReader::getfilename_simple(uint16_t entry, const char * const match/*=NULL*/)
@ -709,10 +709,10 @@ bool CardReader::chdir(const char * relpath, bool doPresort)
{
SdFile newfile;
SdFile *parent=&root;
if(workDir.isOpen())
parent=&workDir;
if(!newfile.open(*parent,relpath, O_READ) || ((workDirDepth + 1) >= MAX_DIR_DEPTH))
{
SERIAL_ECHO_START;
@ -789,7 +789,7 @@ void CardReader::getfilename_afterMaxSorting(uint16_t entry, const char * const
void CardReader::presort() {
// Throw away old sort index
flush_presort();
if (IS_SD_INSERTED == false) return; //sorting is not used in farm mode
uint8_t sdSort = eeprom_read_byte((uint8_t*)EEPROM_SD_SORT);
@ -808,7 +808,7 @@ void CardReader::presort() {
}
sort_count = fileCnt;
// Init sort order.
for (uint16_t i = 0; i < fileCnt; i++) {
if (!IS_SD_INSERTED) return;
@ -867,14 +867,14 @@ void CardReader::presort() {
uint16_t j = i;
for (; j > 0; --j){
if (!IS_SD_INSERTED) return;
#ifdef SORTING_DUMP
for (uint16_t z = 0; z < fileCnt; z++){
printf_P(PSTR("%2u "), sort_entries[z]);
}
MYSERIAL.println();
#endif
manage_heater();
const uint16_t o2 = sort_entries[j - 1];
@ -894,7 +894,7 @@ void CardReader::presort() {
} else {
#ifdef SORTING_DUMP
puts_P(PSTR("shift"));
#endif
#endif
sort_entries[j] = o2;
}
}
@ -957,7 +957,7 @@ void CardReader::presort() {
#ifdef SORTING_DUMP
puts_P(PSTR("swap"));
#endif
sort_entries[j] = o2;
sort_entries[j + 1] = o1;
didSwap = true;
@ -966,11 +966,11 @@ void CardReader::presort() {
if (!didSwap) break;
} //end of bubble sort loop
#endif
#ifdef SORTING_SPEEDTEST
printf_P(PSTR("sortingSpeedtestTimer:%lu\n"), sortingSpeedtestTimer.elapsed());
#endif //SORTING_SPEEDTEST
#ifdef SORTING_DUMP
for (uint16_t z = 0; z < fileCnt; z++)
printf_P(PSTR("%2u "), sort_entries[z]);

View File

@ -12,7 +12,7 @@ class CardReader
{
public:
CardReader();
enum LsAction : uint8_t
{
LS_SerialPrint,
@ -26,14 +26,14 @@ public:
inline ls_param():LFN(0), timestamp(0) { }
inline ls_param(bool LFN, bool timestamp):LFN(LFN), timestamp(timestamp) { }
} __attribute__((packed));
void mount(bool doPresort = true);
void write_command(char *buf);
void write_command_no_newline(char *buf);
//files auto[0-9].g on the sd card are performed in a row
//this is to delay autostart and hence the initialisaiton of the sd card to some seconds after the normal init, so the device is available quick after a reset
void checkautostart(bool x);
void checkautostart(bool x);
void openFileWrite(const char* name);
void openFileReadFilteredGcode(const char* name, bool replace_current = false);
void openLogFile(const char* name);
@ -49,12 +49,11 @@ public:
void getfilename_simple(uint16_t entry, const char * const match = NULL);
void getfilename_next(uint32_t position, const char * const match = NULL);
uint16_t getnrfilenames();
void getAbsFilename(char *t);
void printAbsFilenameFast();
void getDirName(char* name, uint8_t level);
uint8_t getWorkDirDepth();
void ls(ls_param params);
bool chdir(const char * relpath, bool doPresort);
@ -90,7 +89,7 @@ public:
public:
bool saving;
bool logging;
bool sdprinting ;
bool sdprinting;
bool mounted;
char filename[FILENAME_LENGTH];
// There are scenarios when simple modification time is not enough (on MS Windows)
@ -147,7 +146,7 @@ extern CardReader card;
#define IS_SD_PRINTING (card.sdprinting)
#if (SDCARDDETECT > -1)
# ifdef SDCARDDETECTINVERTED
# ifdef SDCARDDETECTINVERTED
# define IS_SD_INSERTED (READ(SDCARDDETECT)!=0)
# else
# define IS_SD_INSERTED (READ(SDCARDDETECT)==0)

View File

@ -108,7 +108,7 @@ void cmdqueue_reset()
//commands are removed from command queue after process_command() function is finished
//reseting command queue and enqueing new commands during some (usually long running) command processing would cause that new commands are immediately removed from queue (or damaged)
//this will ensure that all new commands which are enqueued after cmdqueue reset, will be always executed
cmdbuffer_front_already_processed = true;
cmdbuffer_front_already_processed = true;
}
// How long a string could be pushed to the front of the command queue?
@ -354,7 +354,7 @@ void enquecommand_front(const char *cmd, bool from_progmem)
void repeatcommand_front()
{
cmdbuffer_front_already_processed = true;
}
}
void get_command()
{
@ -369,7 +369,7 @@ void get_command()
// start of serial line processing loop
while (((MYSERIAL.available() > 0 && !saved_printing) || (MYSERIAL.available() > 0 && printingIsPaused())) && !cmdqueue_serial_disabled) { //is print is saved (crash detection or filament detection), dont process data from serial line
#ifdef ENABLE_MEATPACK
// MeatPack Changes
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -596,9 +596,9 @@ void get_command()
{
// This is either an empty line, or a line with just a comment.
// Continue to the following line, and continue accumulating the number of bytes
// read from the sdcard into sd_count,
// read from the sdcard into sd_count,
// so that the length of the already read empty lines and comments will be added
// to the following non-empty line.
// to the following non-empty line.
return; // prevent cycling indefinitely - let manage_heaters do their job
}
// The new command buffer could be updated non-atomically, because it is not yet considered
@ -635,7 +635,7 @@ void get_command()
comment_mode = false; //for new command
serial_count = 0; //clear buffer
if(card.eof()) break;
// The following line will reserve buffer space if available.
@ -670,7 +670,9 @@ void get_command()
sprintf_P(time, PSTR("%i hours %i minutes"),hours, minutes);
SERIAL_ECHO_START;
SERIAL_ECHOLN(time);
#ifndef SHOW_FILENAME_AFTER_FINISH
lcd_setstatus(time);
#endif //SHOW_FILENAME_AFTER_FINISH
card.printingHasFinished();
card.checkautostart(true);

View File

@ -4,9 +4,9 @@
#include "Marlin.h"
// String circular buffer. Commands may be pushed to the buffer from both sides:
// Chained commands will be pushed to the front, interactive (from LCD menu)
// Chained commands will be pushed to the front, interactive (from LCD menu)
// and printing commands (from serial line or from SD card) are pushed to the tail.
// First character of each entry indicates the type of the entry:
// First character of each entry indicates the type of the entry:
#define CMDBUFFER_CURRENT_TYPE_UNKNOWN 0
// Command in cmdbuffer was sent over USB.
#define CMDBUFFER_CURRENT_TYPE_USB 1
@ -16,8 +16,8 @@
#define CMDBUFFER_CURRENT_TYPE_UI 3
// Command in cmdbuffer was generated by another G-code.
#define CMDBUFFER_CURRENT_TYPE_CHAINED 4
// Command has been processed and its SD card length has been possibly pushed
// to the planner queue, but not yet removed from the cmdqueue.
// Command has been processed and its SD card length has been possibly pushed
// to the planner queue, but not yet removed from the cmdqueue.
// This is a temporary state to reduce stepper interrupt locking time.
#define CMDBUFFER_CURRENT_TYPE_TO_BE_REMOVED 5
//Command in cmdbuffer was sent over USB and contains line number

View File

@ -65,7 +65,7 @@
#define LANG_SIZE_RESERVED 0x3500 // reserved space for secondary language (13568 bytes).
// 0x3D00 Maximum 15616 bytes as it depends on xflash_layout.h
// 16 Languages max. per group including stock
// 16 Languages max. per group including stock
#if (LANG_SIZE_RESERVED % 256)
#error "LANG_SIZE_RESERVED should be a multiple of a page size"

View File

@ -32,7 +32,7 @@ void eeprom_init()
int last_babystep = eeprom_read_word((uint16_t *)EEPROM_BABYSTEP_Z);
eeprom_update_word(reinterpret_cast<uint16_t *>(&(EEPROM_Sheets_base->s[0].z_offset)), last_babystep);
}
// initialize the sheet names in eeprom
for (uint_least8_t i = 0; i < (sizeof(Sheets::s)/sizeof(Sheets::s[0])); i++) {
SheetName sheetName;

View File

@ -12,6 +12,7 @@
#define EEPROM_H
#include <stdint.h>
#include <stddef.h>
#include "Configuration_var.h"
// Custom Mendel Name
@ -83,7 +84,7 @@ static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEP
To convert hex to dec https://www.rapidtables.com/convert/number/hex-to-decimal.html
Version: 3.14.0
Version: 3.14.1
---------------------------------------------------------------------------------
@ -106,8 +107,8 @@ static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEP
| ^ | ^ | ^ | f0h 240 | ^ __P__ | needs Z calibration | ^ | ^
| ^ | ^ | ^ | fah 250 | ^ | needs XYZ calibration | ^ | ^
| ^ | ^ | ^ | 00h 0 | ^ | Unknown (legacy) | ^ | ^
| 0x0FF5 4085 | uint16 | EEPROM_BABYSTEP_Z0 | ??? | ff ffh 65535 | Babystep for Z ??? | ??? | D3 Ax0ff5 C2
| 0x0FF1 4081 | uint32 | EEPROM_FILAMENTUSED | ??? | 00 00 00 00h 0 __S/P__| Filament used in meters | ??? | D3 Ax0ff1 C4
| 0x0FF5 4085 | uint16 | _EEPROM_FREE_NR12_ | ??? | ff ffh 65535 | _Free EEPROM space_ | _free space_ | D3 Ax0ff5 C2
| 0x0FF1 4081 | uint32 | EEPROM_FILAMENTUSED | ??? | 00 00 00 00h 0 __S/P__| Filament used in centimeters | ??? | D3 Ax0ff1 C4
| 0x0FED 4077 | uint32 | EEPROM_TOTALTIME | ??? | 00 00 00 00h 0 __S/P__| Total print time in minutes | ??? | D3 Ax0fed C4
| 0x0FE5 4069 | float | EEPROM_BED_CALIBRATION_CENTER | ??? | ff ff ff ffh | ??? | ??? | D3 Ax0fe5 C8
| 0x0FDD 4061 | float | EEPROM_BED_CALIBRATION_VEC_X | ??? | ff ff ff ffh | ??? | ??? | D3 Ax0fdd C8
@ -384,6 +385,39 @@ static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEP
| 0x0C80 3200 | char[17]| EEPROM_CUSTOM_MENDEL_NAME | Prusa i3 MK3S| ffffffffffffffffff... | Custom Printer Name | | D3 Ax0c80 C17
| 0x0C7F 3199 | bool | EEPROM_UVLO_Z_LIFTED | 00h 0 | 00h | Power Panic Z axis NOT lifted | Power Panic | D3 Ax0c7f C1
| ^ | ^ | ^ | 01h 1 | 01h | Power Panic Z axis lifted | ^ | ^
| 0x0C7d 3197 | uint16 | EEPROM_UVLO_EXTRUDE_MINTEMP | 0-305 | afh 175 | Power Panic Extrude mintemp | Power Panic | D3 Ax0c7d C2
| 0x0C6D 3181 | uint32 | EEPROM_UVLO_ACCELL_MM_S2_NORMAL | ??? | ff ff ff ffh | Power Panic acceleration mm per s2 normal | Power Panic | D3 Ax0c6d C16
| ^ | ^ | ^ | ??? | ^ | E-axis | ^ | D3 Ax0c79 C4
| ^ | ^ | ^ | ??? | ^ | Z-axis | ^ | D3 Ax0c75 C4
| ^ | ^ | ^ | ??? | ^ | Y-axis | ^ | D3 Ax0c71 C4
| ^ | ^ | ^ | ??? | ^ | X-axis | ^ | D3 Ax0c6d C4
| 0x0C5D 3165 | uint32 | EEPROM_UVLO_ACCELL_MM_S2_SILENT | ??? | ff ff ff ffh | Power Panic acceleration mm per s2 silent | Power Panic | D3 Ax0c5d C16
| ^ | ^ | ^ | ??? | ^ | E-axis | ^ | D3 Ax0c69 C4
| ^ | ^ | ^ | ??? | ^ | Z-axis | ^ | D3 Ax0c65 C4
| ^ | ^ | ^ | ??? | ^ | Y-axis | ^ | D3 Ax0c61 C4
| ^ | ^ | ^ | ??? | ^ | X-axis | ^ | D3 Ax0c5d C4
| 0x0C4D 3149 | float | EEPROM_UVLO_MAX_FEEDRATE_NORMAL | ??? | ff ff ff ffh | Power Panic max feedrate normal | Power Panic | D3 Ax0c4d C16
| ^ | ^ | ^ | ??? | ^ | E-axis | ^ | D3 Ax0d59 C4
| ^ | ^ | ^ | ??? | ^ | Z-axis | ^ | D3 Ax0d55 C4
| ^ | ^ | ^ | ??? | ^ | Y-axis | ^ | D3 Ax0d51 C4
| ^ | ^ | ^ | ??? | ^ | X-axis | ^ | D3 Ax0c4d C4
| 0x0C3D 3133 | float | EEPROM_UVLO_MAX_FEEDRATE_SILENT | ??? | ff ff ff ffh | Power Panic max feedrate silent | Power Panic | D3 Ax0c3d C16
| ^ | ^ | ^ | ??? | ^ | E-axis | ^ | D3 Ax0d49 C4
| ^ | ^ | ^ | ??? | ^ | Z-axis | ^ | D3 Ax0d45 C4
| ^ | ^ | ^ | ??? | ^ | Y-axis | ^ | D3 Ax0d41 C4
| ^ | ^ | ^ | ??? | ^ | X-axis | ^ | D3 Ax0c3d C4
| 0x0C39 3129 | float | EEPROM_UVLO_MIN_FEEDRATE | ??? | ff ff ff ffh | Power Panic min feedrate | Power Panic | D3 Ax0c39 C4
| 0x0C35 3125 | float | EEPROM_UVLO_MIN_TRAVEL_FEEDRATE | ??? | ff ff ff ffh | Power Panic min travel feedrate | Power Panic | D3 Ax0c35 C4
| 0x0C31 3121 | uint32 | EEPROM_UVLO_MIN_SEGMENT_TIME_US | ??? | ff ff ff ffh | Power Panic min segment time us | Power Panic | D3 Ax0c31 C4
| 0x0C21 3105 | float | EEPROM_UVLO_MAX_JERK | ??? | ff ff ff ffh | Power Panic max jerk | Power Panic | D3 Ax0c21 C16
| ^ | ^ | ^ | ??? | ^ | E-axis | ^ | D3 Ax0d2d C4
| ^ | ^ | ^ | ??? | ^ | Z-axis | ^ | D3 Ax0d29 C4
| ^ | ^ | ^ | ??? | ^ | Y-axis | ^ | D3 Ax0d25 C4
| ^ | ^ | ^ | ??? | ^ | X-axis | ^ | D3 Ax0c21 C4
| 0x0C11 3089 | uint8 | EEPROM_CHECK_FILAMENT | 01h 1 | ffh 255 | Check mode for filament is: __warn__ | LCD menu | D3 Ax0c11 C1
| ^ | ^ | ^ | 02h 2 | ^ | Check mode for filament is: __strict__ | ^ | ^
| ^ | ^ | ^ | 00h 0 | ^ | Check mode for filament is: __none__ | ^ | ^
|Address begin|Bit/Type | Name | Valid values | Default/FactoryReset | Description |Gcode/Function| Debug code
| :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--:
@ -407,7 +441,7 @@ static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEP
#define _EEPROM_FREE_NR11_ 4090 // uint16_t
#define EEPROM_BABYSTEP_Z 4088 //legacy, multiple values stored now in EEPROM_Sheets_base
#define EEPROM_CALIBRATION_STATUS_V1 4087 // legacy, used up to v3.11
#define EEPROM_BABYSTEP_Z0 4085
#define _EEPROM_FREE_NR12_ (EEPROM_CALIBRATION_STATUS_V1 - 2) // uint16_t
#define EEPROM_FILAMENTUSED 4081
// uint32_t
#define EEPROM_TOTALTIME 4077
@ -624,9 +658,18 @@ static Sheets * const EEPROM_Sheets_base = (Sheets*)(EEPROM_SHEETS_BASE);
#define EEPROM_FILENAME_EXTENSION (EEPROM_KILL_PENDING_FLAG - 3) // 3 x char
#define EEPROM_CUSTOM_MENDEL_NAME (EEPROM_FILENAME_EXTENSION-17) //char[17]
#define EEPROM_UVLO_Z_LIFTED (EEPROM_CUSTOM_MENDEL_NAME-1) //bool
#define EEPROM_UVLO_EXTRUDE_MINTEMP (EEPROM_UVLO_Z_LIFTED-2) //uint16_t
#define EEPROM_UVLO_ACCELL_MM_S2_NORMAL (EEPROM_UVLO_EXTRUDE_MINTEMP-4*4) // 4 x float
#define EEPROM_UVLO_ACCELL_MM_S2_SILENT (EEPROM_UVLO_ACCELL_MM_S2_NORMAL-4*4) // 4 x uint32_t
#define EEPROM_UVLO_MAX_FEEDRATE_NORMAL (EEPROM_UVLO_ACCELL_MM_S2_SILENT-4*4) // 4 x uint32_t
#define EEPROM_UVLO_MAX_FEEDRATE_SILENT (EEPROM_UVLO_MAX_FEEDRATE_NORMAL-4*4) // 4 x float
#define EEPROM_UVLO_MIN_FEEDRATE (EEPROM_UVLO_MAX_FEEDRATE_SILENT-4) //float
#define EEPROM_UVLO_MIN_TRAVEL_FEEDRATE (EEPROM_UVLO_MIN_FEEDRATE-4) //float
#define EEPROM_UVLO_MIN_SEGMENT_TIME_US (EEPROM_UVLO_MIN_TRAVEL_FEEDRATE-4) //uint32_t
#define EEPROM_UVLO_MAX_JERK (EEPROM_UVLO_MIN_SEGMENT_TIME_US-4*4) // 4 x float
#define EEPROM_CHECK_FILAMENT (EEPROM_UVLO_MAX_JERK-1) // uint8_t
//This is supposed to point to last item to allow EEPROM overrun check. Please update when adding new items.
#define EEPROM_LAST_ITEM EEPROM_UVLO_Z_LIFTED
#define EEPROM_LAST_ITEM EEPROM_CHECK_FILAMENT
// !!!!!
// !!!!! this is end of EEPROM section ... all updates MUST BE inserted before this mark !!!!!
// !!!!!

View File

@ -149,7 +149,7 @@ void checkFanSpeed()
lcd_reset_alert_level(); //for another fan speed error
lcd_setstatuspgm(MSG_WELCOME); // Reset the status line message to visually show the error is gone
}
if (fans_check_enabled && (fan_check_error == EFCE_OK))
if (fans_check_enabled && (fan_check_error != EFCE_REPORTED))
{
for (uint8_t fan = 0; fan < 2; fan++)
{
@ -194,7 +194,7 @@ ISR(INT7_vect) {
if ((millis_nc() - t_fan_rising_edge) >= FAN_PULSE_WIDTH_LIMIT) {//this pulse was from sensor and not from pwm
fan_edge_counter[1] += 2; //we are currently counting all edges so lets count two edges for one pulse
}
}
}
EICRB ^= (1 << 6); //change edge
}
#endif //(defined(FANCHECK) && defined(TACH_1) && (TACH_1 >-1))

View File

@ -62,7 +62,7 @@
/// Write to a pin wrapper, non critical.
/// This macro is cheaper than WRITE(IO,v) on ports H,I,J,K,L, as _WRITE_C disables / enables interrupts
/// and stores the old CPU flags on the stack.
/// This macro should only be called, where it cannot be interrupted.
/// This macro should only be called, where it cannot be interrupted.
#define WRITE_NC(IO, v) _WRITE_NC(IO, v)
/// toggle a pin wrapper
@ -2067,7 +2067,7 @@ pins
pins
*/
//#define AT90USBxx_TEENSYPP_ASSIGNMENTS // Use Teensy++ 2.0 assignments
//#define AT90USBxx_TEENSYPP_ASSIGNMENTS // Use Teensy++ 2.0 assignments
#ifndef AT90USBxx_TEENSYPP_ASSIGNMENTS // Use traditional Marlin pin assignments
#define DIO0_PIN PINA0
@ -2707,8 +2707,8 @@ pins
/*
AT90USB 51 50 49 48 47 46 45 44 10 11 12 13 14 15 16 17 35 36 37 38 39 40 41 42 25 26 27 28 29 30 31 32 33 34 43 09 18 19 01 02 61 60 59 58 57 56 55 54
Port A0 A1 A2 A3 A4 A5 A6 A7 B0 B1 B2 B3 B4 B5 B6 B7 C0 C1 C2 C3 C4 C5 C6 C7 D0 D1 D2 D3 D4 D5 D6 D7 E0 E1 E2 E3 E4 E5 E6 E7 F0 F1 F2 F3 F4 F5 F6 F7
AT90USB 51 50 49 48 47 46 45 44 10 11 12 13 14 15 16 17 35 36 37 38 39 40 41 42 25 26 27 28 29 30 31 32 33 34 43 09 18 19 01 02 61 60 59 58 57 56 55 54
Port A0 A1 A2 A3 A4 A5 A6 A7 B0 B1 B2 B3 B4 B5 B6 B7 C0 C1 C2 C3 C4 C5 C6 C7 D0 D1 D2 D3 D4 D5 D6 D7 E0 E1 E2 E3 E4 E5 E6 E7 F0 F1 F2 F3 F4 F5 F6 F7
Marlin 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
Teensy 28 29 30 31 32 33 34 35 20 21 22 23 24 25 26 27 10 11 12 13 14 15 16 17 00 01 02 03 04 05 06 07 08 09(46*47)36 37 18 19 38 39 40 41 42 43 44 45
The pins 46 and 47 are not supported by Teensyduino, but are supported below.

View File

@ -37,12 +37,31 @@ static constexpr float spacing(float layer_height, float extrusion_width, float
static void lay1cal_common_enqueue_loop(const char * const * cmd_sequence, const uint8_t steps) {
for (uint8_t i = 0; i < steps; ++i)
{
enquecommand_P(static_cast<char*>(pgm_read_ptr(cmd_sequence + i)));
void * const pgm_ptr = pgm_read_ptr(cmd_sequence + i);
// M702 is currently only used with MMU enabled
if (pgm_ptr == MSG_M702 && !MMU2::mmu2.Enabled()) {
continue;
}
enquecommand_P(static_cast<char*>(pgm_ptr));
}
}
static const char extrude_fmt[] PROGMEM = "G1 X%d Y%d E%-.5f";
static const char zero_extrusion[] PROGMEM = "G92 E0";
static const char extrude_fmt_X[] PROGMEM = "G1X%.4fE%.4f";
static const char extrude_fmt_Y[] PROGMEM = "G1Y%.4fE%.4f";
static const char zero_extrusion[] PROGMEM = "G92E0";
static const char feedrate_F1080[] PROGMEM = "G1F1080";
#ifndef NEW_FIRST_LAYER_CAL
static constexpr int8_t invert = 1;
static constexpr float short_length = 20;
static constexpr float square_width = short_length;
#else
static constexpr int8_t invert = -1;
static constexpr float short_length = 13.2812; //max_pos[1]/2 / meander * 2
static constexpr float square_width = short_length*2;
#endif //NEW_FIRST_LAYER_CAL
static constexpr float long_length = 150;
//! @brief Wait for preheat
void lay1cal_wait_preheat()
@ -72,8 +91,8 @@ bool lay1cal_load_filament(uint8_t filament)
if (MMU2::mmu2.Enabled())
{
enquecommand_P(MSG_M83);
enquecommand_P(PSTR("G1 Y-3 F1000"));
enquecommand_P(PSTR("G1 Z0.4 F1000"));
enquecommand_P(PSTR("G1Y-3F1000"));
enquecommand_P(PSTR("G1Z0.4"));
uint8_t currentTool = MMU2::mmu2.get_current_tool();
if(currentTool == filament ){
@ -93,25 +112,22 @@ bool lay1cal_load_filament(uint8_t filament)
//! @brief Print intro line
//! @param extraPurgeNeeded false if the first MMU-related "G1 E29" have to be skipped because the nozzle is already full of filament
//! @param layer_height the height of the calibration layer
//! @param extrusion_width the width of the extrusion layer
//! @param extrusion_width the width of the extrusion layer
void lay1cal_intro_line(bool extraPurgeNeeded, float layer_height, float extrusion_width)
{
static const char cmd_intro_mmu_3[] PROGMEM = "G1 X55 E29 F1073";
static const char cmd_intro_mmu_4[] PROGMEM = "G1 X5 E29 F1800";
static const char cmd_intro_mmu_5[] PROGMEM = "G1 X55 E8 F2000";
static const char cmd_intro_mmu_6[] PROGMEM = "G1 Z0.3 F1000";
static const char cmd_intro_mmu_8[] PROGMEM = "G1 X240 E25 F2200";
static const char cmd_intro_mmu_9[] PROGMEM = "G1 Y-2 F1000";
static const char cmd_intro_mmu_10[] PROGMEM = "G1 X55 E25 F1400";
static const char cmd_intro_mmu_11[] PROGMEM = "G1 Z0.2 F1000";
static const char cmd_intro_mmu_12[] PROGMEM = "G1 X5 E4 F1000";
static const char * const intro_mmu_cmd[] PROGMEM =
static const char cmd_intro_mmu_3[] PROGMEM = "G1X55E29F1073";
static const char cmd_intro_mmu_4[] PROGMEM = "G1X5E29F1800";
static const char cmd_intro_mmu_5[] PROGMEM = "G1X55E8F2000";
static const char cmd_intro_mmu_6[] PROGMEM = "G1Z0.3F1000";
static const char cmd_intro_mmu_8[] PROGMEM = "G1X240E25F2200";
static const char cmd_intro_mmu_9[] PROGMEM = "G1Y-2F1000";
static const char cmd_intro_mmu_10[] PROGMEM = "G1X202.5E8F1400";
static const char cmd_intro_mmu_11[] PROGMEM = "G1Z0.2";
static const char * const cmd_intro_mmu[] PROGMEM =
{
// first 2 items are only relevant if filament was not loaded - i.e. extraPurgeNeeded == true
cmd_intro_mmu_3,
cmd_intro_mmu_4,
cmd_intro_mmu_5,
cmd_intro_mmu_6,
zero_extrusion,
@ -119,42 +135,42 @@ void lay1cal_intro_line(bool extraPurgeNeeded, float layer_height, float extrusi
cmd_intro_mmu_9,
cmd_intro_mmu_10,
cmd_intro_mmu_11,
cmd_intro_mmu_12,
};
if (MMU2::mmu2.Enabled())
{
for (uint8_t i = (extraPurgeNeeded ? 0 : 2); i < (sizeof(intro_mmu_cmd)/sizeof(intro_mmu_cmd[0])); ++i)
for (uint8_t i = (extraPurgeNeeded ? 0 : 2); i < (sizeof(cmd_intro_mmu)/sizeof(cmd_intro_mmu[0])); ++i)
{
enquecommand_P(static_cast<char*>(pgm_read_ptr(&intro_mmu_cmd[i])));
enquecommand_P(static_cast<char*>(pgm_read_ptr(&cmd_intro_mmu[i])));
}
}
else
{
static const char fmt1[] PROGMEM = "G1 X%d E%-.3f F1000";
enquecommandf_P(fmt1, 60, count_e(layer_height, extrusion_width * 4.f, 60));
enquecommandf_P(fmt1, 100, count_e(layer_height, extrusion_width * 8.f, 40));
enquecommand_P(feedrate_F1080); //fixed velocity for the intro line
enquecommandf_P(extrude_fmt_X, 60.f, count_e(layer_height, extrusion_width * 4.f, 60));
enquecommandf_P(extrude_fmt_X, 202.5f, count_e(layer_height, extrusion_width * 8.f, 142.5));
}
}
//! @brief Setup for printing meander
void lay1cal_before_meander()
{
static const char cmd_pre_meander_2[] PROGMEM = "G90"; //use absolute coordinates
static const char cmd_pre_meander_4[] PROGMEM = "G1 E-1.5 F2100";
static const char cmd_pre_meander_5[] PROGMEM = "G1 Z5 F7200";
static const char cmd_pre_meander_6[] PROGMEM = "M204 S1000"; //set acceleration
static const char cmd_pre_meander_7[] PROGMEM = "G1 F4000";
#ifndef NEW_FIRST_LAYER_CAL
static const char cmd_pre_meander_4[] PROGMEM = "G1E-1.5F2100";
static const char cmd_pre_meander_5[] PROGMEM = "G1Z5F7200";
#endif //NEW_FIRST_LAYER_CAL
static const char cmd_pre_meander_6[] PROGMEM = "M204S1000"; //set acceleration
static const char * const cmd_pre_meander[] PROGMEM =
{
zero_extrusion,
cmd_pre_meander_2,
MSG_G90,
MSG_M83, // use relative distances for extrusion
#ifndef NEW_FIRST_LAYER_CAL
cmd_pre_meander_4,
cmd_pre_meander_5,
#endif //NEW_FIRST_LAYER_CAL
cmd_pre_meander_6,
cmd_pre_meander_7,
};
lay1cal_common_enqueue_loop(cmd_pre_meander, (sizeof(cmd_pre_meander)/sizeof(cmd_pre_meander[0])));
@ -163,88 +179,86 @@ void lay1cal_before_meander()
//! @brief Print meander start
void lay1cal_meander_start(float layer_height, float extrusion_width)
{
enquecommand_P(PSTR("G1 X50 Y155"));
static const char fmt1[] PROGMEM = "G1 Z%-.3f F7200";
#ifndef NEW_FIRST_LAYER_CAL
enquecommand_P(PSTR("G1X50Y155"));
#endif //_NEW_FIRST_LAYER_CAL
static const char fmt1[] PROGMEM = "G1Z%.2f";
enquecommandf_P(fmt1, layer_height);
enquecommand_P(PSTR("G1 F1080"));
enquecommandf_P(extrude_fmt, 75, 155, count_e(layer_height, extrusion_width * 4.f, 25));
enquecommandf_P(extrude_fmt, 100, 155, count_e(layer_height, extrusion_width * 2.f, 25));
enquecommandf_P(extrude_fmt, 200, 155, count_e(layer_height, extrusion_width, 100));
enquecommandf_P(extrude_fmt, 200, 135, count_e(layer_height, extrusion_width, 20));
enquecommand_P(feedrate_F1080);
enquecommand_P(MSG_G91); //enable relative XYZ
#ifdef NEW_FIRST_LAYER_CAL
enquecommandf_P(extrude_fmt_Y, short_length, count_e(layer_height, extrusion_width, short_length));
enquecommandf_P(extrude_fmt_X, long_length*invert, count_e(layer_height, extrusion_width, long_length));
enquecommandf_P(extrude_fmt_Y, -short_length*invert, count_e(layer_height, extrusion_width, short_length));
#else
enquecommandf_P(extrude_fmt_X, 25.f*invert, count_e(layer_height, extrusion_width * 4.f, 25));
enquecommandf_P(extrude_fmt_X, 25.f*invert, count_e(layer_height, extrusion_width * 2.f, 25));
enquecommandf_P(extrude_fmt_X, 100.f*invert, count_e(layer_height, extrusion_width, 100));
enquecommandf_P(extrude_fmt_Y, -20.f*invert, count_e(layer_height, extrusion_width, 20));
#endif //_NEW_FIRST_LAYER_CAL
}
//! @brief Print meander
//! @param cmd_buffer character buffer needed to format gcodes
void lay1cal_meander(float layer_height, float extrusion_width)
{
const float short_length = 20;
float long_length = 150;
const float long_extrusion = count_e(layer_height, extrusion_width, long_length);
const float short_extrusion = count_e(layer_height, extrusion_width, short_length);
uint8_t y_pos = 135;
uint8_t x_pos = 50;
for(uint8_t i = 0; i <= 4; ++i)
for(int8_t i = 0, xdir = -invert; i <= 4; i++, xdir = -xdir)
{
enquecommandf_P(extrude_fmt, x_pos, y_pos, long_extrusion);
y_pos -= short_length;
enquecommandf_P(extrude_fmt, x_pos, y_pos, short_extrusion);
x_pos += long_length;
long_length = -long_length;
enquecommandf_P(extrude_fmt_X, xdir * long_length, long_extrusion);
enquecommandf_P(extrude_fmt_Y, invert * -short_length, short_extrusion);
}
#ifdef NEW_FIRST_LAYER_CAL
constexpr float mid_length = 0.5f * long_length - 0.5f * square_width;
const float mid_extrusion = count_e(layer_height, extrusion_width, mid_length);
enquecommandf_P(extrude_fmt_X, -mid_length, mid_extrusion); //~Middle of bed X125
enquecommandf_P(extrude_fmt_Y, short_length, short_extrusion); //~Middle of bed Y105
#endif //NEW_FIRST_LAYER_CAL
}
//! @brief Print square
//!
//! This function needs to be called 4 times with step of 0,4,8,12
//! This function enqueues 4 lines of the square, so it needs to be called multiple times
//!
//! @param cmd_buffer character buffer needed to format gcodes
//! @param i iteration
void lay1cal_square(uint8_t step, float layer_height, float extrusion_width)
void lay1cal_square(float layer_height, float extrusion_width)
{
const float long_length = 20;
const float short_length = spacing(layer_height, extrusion_width);
const float long_extrusion = count_e(layer_height, extrusion_width, long_length);
const float short_extrusion = count_e(layer_height, extrusion_width, short_length);
static const char fmt1[] PROGMEM = "G1 X%d Y%-.2f E%-.3f";
const float Y_spacing = spacing(layer_height, extrusion_width);
const float long_extrusion = count_e(layer_height, extrusion_width, square_width);
const float short_extrusion = count_e(layer_height, extrusion_width, Y_spacing);
for (uint8_t i = step; i < step+4; ++i)
for (uint8_t i = 0; i < 4; i++)
{
enquecommandf_P(fmt1, 70, (35 - i*short_length * 2), long_extrusion);
enquecommandf_P(fmt1, 70, (35 - (2 * i + 1)*short_length), short_extrusion);
enquecommandf_P(fmt1, 50, (35 - (2 * i + 1)*short_length), long_extrusion);
enquecommandf_P(fmt1, 50, (35 - (i + 1)*short_length * 2), short_extrusion);
enquecommandf_P(extrude_fmt_X, square_width*invert, long_extrusion);
enquecommandf_P(extrude_fmt_Y, -Y_spacing*invert, short_extrusion);
enquecommandf_P(extrude_fmt_X, -square_width*invert, long_extrusion);
enquecommandf_P(extrude_fmt_Y, -Y_spacing*invert, short_extrusion);
}
}
void lay1cal_finish(bool mmu_enabled)
void lay1cal_finish()
{
static const char cmd_cal_finish_1[] PROGMEM = "G1 E-0.075 F2100"; //retract
static const char cmd_cal_finish_2[] PROGMEM = "M104 S0"; // turn off temperature
static const char cmd_cal_finish_3[] PROGMEM = "M140 S0"; // turn off heatbed
static const char cmd_cal_finish_4[] PROGMEM = "G1 Z10 F1300"; //lift Z
static const char cmd_cal_finish_5[] PROGMEM = "G1 X10 Y180 F4000"; //Go to parking position
static const char cmd_cal_finish_3[] PROGMEM = "G1E-0.075F2100"; // Retract
static const char cmd_cal_finish_4[] PROGMEM = "M140S0"; // Turn off bed heater
static const char cmd_cal_finish_5[] PROGMEM = "G1Z10F1300"; // Lift Z
static const char cmd_cal_finish_6[] PROGMEM = "G1X10Y180F4000"; // Go to parking position
static const char cmd_cal_finish_8[] PROGMEM = "M104S0"; // Turn off hotend heater
static const char * const cmd_cal_finish[] PROGMEM =
{
MSG_M107, // turn off printer fan
cmd_cal_finish_1,
cmd_cal_finish_2,
cmd_cal_finish_3,
cmd_cal_finish_4,
cmd_cal_finish_5
MSG_G90, // Set to Absolute Positioning
MSG_M107, // Turn off printer fan
cmd_cal_finish_3, // Retract
cmd_cal_finish_4, // Turn off bed heater
cmd_cal_finish_5, // Lift Z
cmd_cal_finish_6, // Go to parking position
MSG_M702, // Unload filament (MMU only)
cmd_cal_finish_8, // Turn off hotend heater
MSG_M84 // Disable stepper motors
};
lay1cal_common_enqueue_loop(cmd_cal_finish, (sizeof(cmd_cal_finish)/sizeof(cmd_cal_finish[0])));
if (mmu_enabled) enquecommand_P(MSG_M702); //unload from nozzle
enquecommand_P(MSG_M84);// disable motors
}

View File

@ -12,7 +12,7 @@ void lay1cal_intro_line(bool skipExtraPurge, float layer_height, float extrusion
void lay1cal_before_meander();
void lay1cal_meander_start(float layer_height, float extrusion_width);
void lay1cal_meander(float layer_height, float extrusion_width);
void lay1cal_square(uint8_t step, float layer_height, float extrusion_width);
void lay1cal_finish(bool mmu_enabled);
void lay1cal_square(float layer_height, float extrusion_width);
void lay1cal_finish();
#endif /* FIRMWARE_FIRST_LAY_CAL_H_ */

View File

@ -11,7 +11,7 @@
// Doing this at higher frequency than the bed "loudspeaker" can handle makes the click barely audible.
// Technically:
// timer0 is set to fast PWM mode at 62.5kHz (timer0 is linked to the bed heating pin) (zero prescaler)
// To keep the bed switching at 30Hz - we don't want the PWM running at 62kHz all the time
// To keep the bed switching at 30Hz - we don't want the PWM running at 62kHz all the time
// since it would burn the heatbed's MOSFET:
// 16MHz/256 levels of PWM duty gives us 62.5kHz
// 62.5kHz/256 gives ~244Hz, that is still too fast - 244/8 gives ~30Hz, that's what we need
@ -19,9 +19,9 @@
// The finite automaton is running in the ISR(TIMER0_OVF_vect)
// 2019-08-14 update: the original algorithm worked very well, however there were 2 regressions:
// 1. 62kHz ISR requires considerable amount of processing power,
// 1. 62kHz ISR requires considerable amount of processing power,
// USB transfer speed dropped by 20%, which was most notable when doing short G-code segments.
// 2. Some users reported TLed PSU started clicking when running at 120V/60Hz.
// 2. Some users reported TLed PSU started clicking when running at 120V/60Hz.
// This looks like the original algorithm didn't maintain base PWM 30Hz, but only 15Hz
// To address both issues, there is an improved approach based on the idea of leveraging
// different CLK prescalers in some automaton states - i.e. when holding LOW or HIGH on the output pin,
@ -40,7 +40,7 @@
// - it can toggle unnoticed, which will result in bed clicking again.
// That's why there are special transition states ZERO_TO_RISE and ONE_TO_FALL, which enable the
// counter change its operation atomically and without artefacts on the output pin.
// The resulting signal on the output pin was checked with an osciloscope.
// The resulting signal on the output pin was checked with an osciloscope.
// If there are any change requirements in the future, the signal must be checked with an osciloscope again,
// ad-hoc changes may completely screw things up!
@ -57,7 +57,7 @@ enum class States : uint8_t {
ZERO_TO_RISE, ///< metastate allowing the timer change its state atomically without artefacts on the output pin
RISE, ///< 16 fast PWM cycles with increasing duty up to steady ON
RISE_TO_ONE, ///< metastate allowing the timer change its state atomically without artefacts on the output pin
ONE, ///< steady 1 (ON), no change for the whole period
ONE, ///< steady 1 (ON), no change for the whole period
FALL, ///< 16 fast PWM cycles with decreasing duty down to steady OFF
FALL_TO_ZERO ///< metastate allowing the timer change its state atomically without artefacts on the output pin
};
@ -92,7 +92,7 @@ static const uint8_t fastShift = 4;
/// increment slowCounter by 1
/// but use less bits of soft PWM - something like soft_pwm_bed >> 2
/// that may further reduce the CPU cycles required by the bed heating automaton
/// Due to the nature of bed heating the reduced PID precision may not be a major issue, however doing 8x less ISR(timer0_ovf) may significantly improve the performance
/// Due to the nature of bed heating the reduced PID precision may not be a major issue, however doing 8x less ISR(timer0_ovf) may significantly improve the performance
static const uint8_t slowInc = 1;
ISR(TIMER0_OVF_vect) // timer compare interrupt service routine
@ -177,6 +177,6 @@ ISR(TIMER0_OVF_vect) // timer compare interrupt service routine
TCNT0 = 128;
OCR0B = 255;
TCCR0B = (1 << CS01); // change prescaler to 8, i.e. 7.8kHz
break;
break;
}
}

View File

@ -248,7 +248,7 @@ const char* lang_get_name_by_code(uint16_t code)
#endif // COMMUNITY_LANG_GROUP1_RO
//Use the 3 lines below as a template and replace 'QR' and 'New language'
//#ifdef COMMUNITY_LANG_GROUP1_QR
//#ifdef COMMUNITY_LANG_GROUP1_QR
// case LANG_CODE_QR: return _n("New language"); //community contribution
//#endif // COMMUNITY_LANG_GROUP1_QR
#endif // COMMUNITY_LANGUAGE_SUPPORT

View File

@ -43,7 +43,7 @@
/** @brief lang_table_header_t structure - (size= 16byte) */
typedef struct
{
uint32_t magic; //+0
uint32_t magic; //+0
uint16_t size; //+4
uint16_t count; //+6
uint16_t checksum; //+8

View File

@ -22,8 +22,6 @@
#define LCD_8BIT
#endif
// #define VT100
// commands
#define LCD_CLEARDISPLAY 0x01
#define LCD_RETURNHOME 0x02
@ -77,10 +75,6 @@ static uint8_t lcd_displaymode = 0;
uint8_t lcd_currline;
static uint8_t lcd_ddram_address; // no need for preventing ddram overflow
#ifdef VT100
uint8_t lcd_escape[8];
#endif
struct CustomCharacter {
uint8_t colByte;
uint8_t rowData[4];
@ -95,30 +89,11 @@ static const CustomCharacter Font[] PROGMEM = {
#define CUSTOM_CHARACTERS_CNT (sizeof(Font) / sizeof(Font[0]))
static void lcd_display(void);
#if 0
static void lcd_no_display(void);
static void lcd_no_cursor(void);
static void lcd_cursor(void);
static void lcd_no_blink(void);
static void lcd_blink(void);
static void lcd_scrollDisplayLeft(void);
static void lcd_scrollDisplayRight(void);
static void lcd_leftToRight(void);
static void lcd_rightToLeft(void);
static void lcd_autoscroll(void);
static void lcd_no_autoscroll(void);
#endif
static void lcd_print_custom(uint8_t c);
static void lcd_invalidate_custom_characters();
#ifdef VT100
void lcd_escape_write(uint8_t chr);
#endif
static void lcd_pulseEnable(void)
{
{
WRITE(LCD_PINS_ENABLE,HIGH);
_delay_us(1); // enable pulse must be >450ns
WRITE(LCD_PINS_ENABLE,LOW);
@ -136,7 +111,7 @@ static void lcd_writebits(uint8_t value)
WRITE(LCD_PINS_D5, value & 0x20);
WRITE(LCD_PINS_D6, value & 0x40);
WRITE(LCD_PINS_D7, value & 0x80);
lcd_pulseEnable();
}
@ -164,16 +139,9 @@ static void lcd_write(uint8_t value)
if (value == '\n') {
if (lcd_currline > 3) lcd_currline = -1;
lcd_set_cursor(0, lcd_currline + 1); // LF
}
else if ((value >= 0x80) && (value < (0x80 + CUSTOM_CHARACTERS_CNT))) {
} else if ((value >= 0x80) && (value < (0x80 + CUSTOM_CHARACTERS_CNT))) {
lcd_print_custom(value);
}
#ifdef VT100
else if (lcd_escape[0] || (value == '\e')) {
lcd_escape_write(value);
}
#endif
else {
} else {
lcd_send(value, HIGH);
lcd_ddram_address++; // no need for preventing ddram overflow
}
@ -199,7 +167,7 @@ static void lcd_begin(uint8_t clear)
// finally, set # lines, font size, etc.0
lcd_command(LCD_FUNCTIONSET | lcd_displayfunction);
// turn the display on with no cursor or blinking default
lcd_displaycontrol = LCD_CURSOROFF | LCD_BLINKOFF;
lcd_displaycontrol = LCD_CURSOROFF | LCD_BLINKOFF;
lcd_display();
// clear it off
if (clear) lcd_clear();
@ -207,10 +175,6 @@ static void lcd_begin(uint8_t clear)
lcd_displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT;
// set the entry mode
lcd_command(LCD_ENTRYMODESET | lcd_displaymode);
#ifdef VT100
lcd_escape[0] = 0;
#endif
}
static int lcd_putchar(char c, FILE *)
@ -235,12 +199,12 @@ void lcd_init(void)
SET_OUTPUT(LCD_PINS_D5);
SET_OUTPUT(LCD_PINS_D6);
SET_OUTPUT(LCD_PINS_D7);
#ifdef LCD_8BIT
lcd_displayfunction |= LCD_8BITMODE;
#endif
lcd_displayfunction |= LCD_2LINE;
_delay_us(50000);
_delay_us(50000);
lcd_begin(1); //first time init
fdev_setup_stream(lcdout, lcd_putchar, NULL, _FDEV_SETUP_WRITE); //setup lcdout stream
}
@ -278,83 +242,6 @@ void lcd_display(void)
lcd_command(LCD_DISPLAYCONTROL | lcd_displaycontrol);
}
#if 0
void lcd_no_display(void)
{
lcd_displaycontrol &= ~LCD_DISPLAYON;
lcd_command(LCD_DISPLAYCONTROL | lcd_displaycontrol);
}
#endif
#ifdef VT100 //required functions for VT100
// Turns the underline cursor on/off
void lcd_no_cursor(void)
{
lcd_displaycontrol &= ~LCD_CURSORON;
lcd_command(LCD_DISPLAYCONTROL | lcd_displaycontrol);
}
void lcd_cursor(void)
{
lcd_displaycontrol |= LCD_CURSORON;
lcd_command(LCD_DISPLAYCONTROL | lcd_displaycontrol);
}
#endif
#if 0
// Turn on and off the blinking cursor
void lcd_no_blink(void)
{
lcd_displaycontrol &= ~LCD_BLINKON;
lcd_command(LCD_DISPLAYCONTROL | lcd_displaycontrol);
}
void lcd_blink(void)
{
lcd_displaycontrol |= LCD_BLINKON;
lcd_command(LCD_DISPLAYCONTROL | lcd_displaycontrol);
}
// These commands scroll the display without changing the RAM
void lcd_scrollDisplayLeft(void)
{
lcd_command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVELEFT);
}
void lcd_scrollDisplayRight(void)
{
lcd_command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVERIGHT);
}
// This is for text that flows Left to Right
void lcd_leftToRight(void)
{
lcd_displaymode |= LCD_ENTRYLEFT;
lcd_command(LCD_ENTRYMODESET | lcd_displaymode);
}
// This is for text that flows Right to Left
void lcd_rightToLeft(void)
{
lcd_displaymode &= ~LCD_ENTRYLEFT;
lcd_command(LCD_ENTRYMODESET | lcd_displaymode);
}
// This will 'right justify' text from the cursor
void lcd_autoscroll(void)
{
lcd_displaymode |= LCD_ENTRYSHIFTINCREMENT;
lcd_command(LCD_ENTRYMODESET | lcd_displaymode);
}
// This will 'left justify' text from the cursor
void lcd_no_autoscroll(void)
{
lcd_displaymode &= ~LCD_ENTRYSHIFTINCREMENT;
lcd_command(LCD_ENTRYMODESET | lcd_displaymode);
}
#endif
/// @brief set the current LCD row
/// @param row LCD row number, ranges from 0 to LCD_HEIGHT - 1
static void FORCE_INLINE lcd_set_current_row(uint8_t row)
@ -394,10 +281,10 @@ void lcd_createChar_P(uint8_t location, const CustomCharacter *char_p)
// The LCD expects the CGRAM data to be sent as pixel data, row by row. Since there are 8 rows per character, 8 bytes need to be sent.
// However, storing the data in the flash as the LCD expects it is wasteful since 3 bits per row are don't care and are not used.
// Therefore, flash can be saved if the character data is packed. For the AVR to unpack efficiently and quickly, the following scheme was used:
//
//
// colbyte data0 data1 data2 data3
// a b c d e
//
//
// ** ** ** b7 b6 b5 b4 a0
// ** ** ** b3 b2 b1 b0 a1
// ** ** ** c7 c6 c5 c4 a2
@ -406,7 +293,7 @@ void lcd_createChar_P(uint8_t location, const CustomCharacter *char_p)
// ** ** ** d3 d2 d1 d0 a5
// ** ** ** e7 e6 e5 e4 a6
// ** ** ** e3 e2 e1 e0 a7
//
//
// The bits marked as ** in the unpacked data are don't care and they will contain garbage.
uint8_t temp;
@ -414,7 +301,7 @@ void lcd_createChar_P(uint8_t location, const CustomCharacter *char_p)
__asm__ __volatile__ (
// load colByte
"lpm %1, Z+" "\n\t"
// begin for loop
"ldi %0, 8" "\n\t"
"mov __zero_reg__, %0" "\n\t" // use zero_reg as loop counter
@ -431,7 +318,7 @@ void lcd_createChar_P(uint8_t location, const CustomCharacter *char_p)
// end for loop
"dec __zero_reg__" "\n\t"
"brne forBegin_%=" "\n\t"
: "=&d" (temp), "=&r" (colByte)
: "z" (char_p), "e" (charmap)
);
@ -443,144 +330,6 @@ void lcd_createChar_P(uint8_t location, const CustomCharacter *char_p)
lcd_command(LCD_SETDDRAMADDR | lcd_ddram_address); // no need for masking the address
}
#ifdef VT100
//Supported VT100 escape codes:
//EraseScreen "\x1b[2J"
//CursorHome "\x1b[%d;%dH"
//CursorShow "\x1b[?25h"
//CursorHide "\x1b[?25l"
void lcd_escape_write(uint8_t chr)
{
#define escape_cnt (lcd_escape[0]) //escape character counter
#define is_num_msk (lcd_escape[1]) //numeric character bit mask
#define chr_is_num (is_num_msk & 0x01) //current character is numeric
#define e_2_is_num (is_num_msk & 0x04) //escape char 2 is numeric
#define e_3_is_num (is_num_msk & 0x08) //...
#define e_4_is_num (is_num_msk & 0x10)
#define e_5_is_num (is_num_msk & 0x20)
#define e_6_is_num (is_num_msk & 0x40)
#define e_7_is_num (is_num_msk & 0x80)
#define e2_num (lcd_escape[2] - '0') //number from character 2
#define e3_num (lcd_escape[3] - '0') //number from character 3
#define e23_num (10*e2_num+e3_num) //number from characters 2 and 3
#define e4_num (lcd_escape[4] - '0') //number from character 4
#define e5_num (lcd_escape[5] - '0') //number from character 5
#define e45_num (10*e4_num+e5_num) //number from characters 4 and 5
#define e6_num (lcd_escape[6] - '0') //number from character 6
#define e56_num (10*e5_num+e6_num) //number from characters 5 and 6
if (escape_cnt > 1) // escape length > 1 = "\x1b["
{
lcd_escape[escape_cnt] = chr; // store current char
if ((chr >= '0') && (chr <= '9')) // char is numeric
is_num_msk |= (1 | (1 << escape_cnt)); //set mask
else
is_num_msk &= ~1; //clear mask
}
switch (escape_cnt++)
{
case 0:
if (chr == 0x1b) return; // escape = "\x1b"
break;
case 1:
is_num_msk = 0x00; // reset 'is number' bit mask
if (chr == '[') return; // escape = "\x1b["
break;
case 2:
switch (chr)
{
case '2': return; // escape = "\x1b[2"
case '?': return; // escape = "\x1b[?"
default:
if (chr_is_num) return; // escape = "\x1b[%1d"
}
break;
case 3:
switch (lcd_escape[2])
{
case '?': // escape = "\x1b[?"
if (chr == '2') return; // escape = "\x1b[?2"
break;
case '2':
if (chr == 'J') // escape = "\x1b[2J"
{ lcd_clear(); break; } // EraseScreen
default:
if (e_2_is_num && // escape = "\x1b[%1d"
((chr == ';') || // escape = "\x1b[%1d;"
chr_is_num)) // escape = "\x1b[%2d"
return;
}
break;
case 4:
switch (lcd_escape[2])
{
case '?': // "\x1b[?"
if ((lcd_escape[3] == '2') && (chr == '5')) return; // escape = "\x1b[?25"
break;
default:
if (e_2_is_num) // escape = "\x1b[%1d"
{
if ((lcd_escape[3] == ';') && chr_is_num) return; // escape = "\x1b[%1d;%1d"
else if (e_3_is_num && (chr == ';')) return; // escape = "\x1b[%2d;"
}
}
break;
case 5:
switch (lcd_escape[2])
{
case '?':
if ((lcd_escape[3] == '2') && (lcd_escape[4] == '5')) // escape = "\x1b[?25"
switch (chr)
{
case 'h': // escape = "\x1b[?25h"
lcd_cursor(); // CursorShow
break;
case 'l': // escape = "\x1b[?25l"
lcd_no_cursor(); // CursorHide
break;
}
break;
default:
if (e_2_is_num) // escape = "\x1b[%1d"
{
if ((lcd_escape[3] == ';') && e_4_is_num) // escape = "\x1b%1d;%1dH"
{
if (chr == 'H') // escape = "\x1b%1d;%1dH"
lcd_set_cursor(e4_num, e2_num); // CursorHome
else if (chr_is_num)
return; // escape = "\x1b%1d;%2d"
}
else if (e_3_is_num && (lcd_escape[4] == ';') && chr_is_num)
return; // escape = "\x1b%2d;%1d"
}
}
break;
case 6:
if (e_2_is_num) // escape = "\x1b[%1d"
{
if ((lcd_escape[3] == ';') && e_4_is_num && e_5_is_num && (chr == 'H')) // escape = "\x1b%1d;%2dH"
lcd_set_cursor(e45_num, e2_num); // CursorHome
else if (e_3_is_num && (lcd_escape[4] == ';') && e_5_is_num) // escape = "\x1b%2d;%1d"
{
if (chr == 'H') // escape = "\x1b%2d;%1dH"
lcd_set_cursor(e5_num, e23_num); // CursorHome
else if (chr_is_num) // "\x1b%2d;%2d"
return;
}
}
break;
case 7:
if (e_2_is_num && e_3_is_num && (lcd_escape[4] == ';')) // "\x1b[%2d;"
if (e_5_is_num && e_6_is_num && (chr == 'H')) // "\x1b[%2d;%2dH"
lcd_set_cursor(e56_num, e23_num); // CursorHome
break;
}
escape_cnt = 0; // reset escape
}
#endif //VT100
int lcd_putc(char c)
{
return fputc(c, lcdout);
@ -690,13 +439,13 @@ void lcd_print(unsigned long n, int base)
void lcd_printNumber(unsigned long n, uint8_t base)
{
unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars.
unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars.
uint8_t i = 0;
if (n == 0)
{
lcd_print('0');
return;
}
}
while (n > 0)
{
buf[i++] = n % base;
@ -869,7 +618,7 @@ void lcd_buttons_update(void)
uint8_t enc_bits = 0;
if (!READ(BTN_EN1)) enc_bits |= _BV(0);
if (!READ(BTN_EN2)) enc_bits |= _BV(1);
if (enc_bits != enc_bits_old)
{
int8_t newDiff = pgm_read_byte(&encrot_table[(enc_bits_old << 2) | enc_bits]);
@ -956,9 +705,9 @@ void lcd_frame_start() {
#endif // DEBUG_CUSTOM_CHARACTERS
lcd_custom_characters[i] = 0x7F;
}
}
#ifdef DEBUG_CUSTOM_CHARACTERS
printf_P(PSTR("frame start:"));
for (uint8_t i = 0; i < 8; i++) {

View File

@ -22,19 +22,6 @@ extern void lcd_clear(void);
extern void lcd_home(void);
/*extern void lcd_no_display(void);
extern void lcd_display(void);
extern void lcd_no_blink(void);
extern void lcd_blink(void);
extern void lcd_no_cursor(void);
extern void lcd_cursor(void);
extern void lcd_scrollDisplayLeft(void);
extern void lcd_scrollDisplayRight(void);
extern void lcd_leftToRight(void);
extern void lcd_rightToLeft(void);
extern void lcd_autoscroll(void);
extern void lcd_no_autoscroll(void);*/
extern void lcd_set_cursor(uint8_t col, uint8_t row);
/// @brief Change the cursor column position while preserving the current row position
@ -70,19 +57,6 @@ extern void lcd_print(unsigned int, int = 10);
extern void lcd_print(long, int = 10);
extern void lcd_print(unsigned long, int = 10);
//! @brief Clear screen
#define ESC_2J "\x1b[2J"
//! @brief Show cursor
#define ESC_25h "\x1b[?25h"
//! @brief Hide cursor
#define ESC_25l "\x1b[?25l"
//! @brief Set cursor to
//! @param c column
//! @param r row
#define ESC_H(c,r) "\x1b["#r";"#c"H"
#define LCD_UPDATE_INTERVAL 100
#define LCD_TIMEOUT_TO_STATUS 30000ul //!< Generic timeout to status screen in ms, when no user action.
#define LCD_TIMEOUT_TO_STATUS_BABYSTEP_Z 90000ul //!< Specific timeout for lcd_babystep_z screen in ms.
@ -137,18 +111,18 @@ extern void lcd_buttons_update(void);
//! When constructed (on stack), original state state of lcd_update_enabled is stored
//! and LCD updates are disabled.
//! When destroyed (gone out of scope), original state of LCD update is restored.
//! It has zero overhead compared to storing bool saved = lcd_update_enabled
//! and calling lcd_update_enable(false) and lcd_update_enable(saved).
//! Do not call lcd_update_enable() to prevent calling lcd_update() in sensitive code.
//! in certain scenarios it will cause recursion e.g. in the menus.
class LcdUpdateDisabler
{
public:
LcdUpdateDisabler(): m_updateEnabled(lcd_update_enabled)
{
lcd_update_enable(false);
lcd_update_enabled = false;
}
~LcdUpdateDisabler()
{
lcd_update_enable(m_updateEnabled);
lcd_update_enabled = m_updateEnabled;
}
private:

View File

@ -326,7 +326,7 @@ void FORCE_INLINE mp_handle_cmd(const MeatPack_Command c) {
break;
}
mp_echo_config_state();
mp_echo_config_state();
}
//==========================================================================

View File

@ -22,7 +22,7 @@
* objects with high curvature, especially at high speeds. There is also the issue of the limited
* baud rate provided by Prusa's Atmega2560-based boards, over the USB serial connection. So soft-
* ware like OctoPrint would also suffer this same micro-stuttering and poor print quality issue.
*
*
*/
#include <stdint.h>
#include "Configuration.h"

View File

@ -110,7 +110,7 @@ void menu_back_no_reset(void)
{
if (menu_depth > 0)
{
menu_depth--;
menu_depth--;
menu_goto(menu_stack[menu_depth].menu, menu_stack[menu_depth].position, false);
}
}
@ -145,7 +145,7 @@ void menu_item_ret(void)
{
lcd_draw_update = 2;
menu_item++;
//prevent the rest of the menu items from rendering or getting clicked
menu_row = LCD_HEIGHT; // early exit from the MENU_BEGIN() for loop at the end of the current cycle
menu_line = 0; // prevent subsequent menu items from rendering at all in the current MENU_BEGIN() for loop cycle
@ -433,24 +433,24 @@ static void menu_draw_P(const char chr, const char* str, const int16_t val)
//! @brief Draw up to 10 chars of text and a float number in format from +0.0 to +12345.0. The increased range is necessary
//! for displaying large values of extruder positions, which caused text overflow in the previous implementation.
//!
//!
//! @param str string label to print
//! @param val value to print aligned to the right side of the display
//!
//! @param val value to print aligned to the right side of the display
//!
//! Implementation comments:
//! The text needs to come with a colon ":", this function does not append it anymore.
//! That resulted in a much shorter implementation (234628B -> 234476B)
//! There are similar functions around which may be shortened in a similar way
void menu_draw_float31(const char* str, float val)
{
lcd_printf_P(menu_fmt_float31, str, val);
lcd_printf_P(menu_fmt_float31, str, val);
}
//! @brief Draw up to 14 chars of text and a float number in format +1.234
//!
//!
//! @param str string label to print
//! @param val value to print aligned to the right side of the display
//!
//! @param val value to print aligned to the right side of the display
//!
//! Implementation comments:
//! This function uses similar optimization principles as menu_draw_float31
//! (i.e. str must include a ':' at its end)
@ -475,10 +475,8 @@ static void _menu_edit_P()
// disable after first use and/or if the initial value is not minEditValue
_md->minJumpValue = 0;
}
_md->currentValue += lcd_encoder;
lcd_encoder = 0; // Consume knob rotation event
// Constrain the value in case it's outside the allowed limits
_md->currentValue = constrain(_md->currentValue, _md->minEditValue, _md->maxEditValue);
lcd_set_cursor(0, 1);
@ -501,7 +499,7 @@ void menu_item_edit_P(const char* str, void* pval, uint8_t pbits, int16_t min_va
{
int16_t cur_val = (pbits == 8 ? *((uint8_t*)pval) : *((int16_t*)pval));
if (lcd_draw_update)
if (lcd_draw_update)
{
lcd_set_cursor(0, menu_row);
menu_draw_P(menu_selection_mark(), str, cur_val);
@ -530,7 +528,7 @@ void menu_progressbar_init(uint16_t total, const char* title)
lcd_clear();
progressbar_block_count = 0;
progressbar_total = total;
lcd_set_cursor(0, 1);
lcd_print_pad_P(title, LCD_WIDTH);
lcd_set_cursor(0, 2);

View File

@ -10,7 +10,7 @@
//Function pointer to menu functions.
typedef void (*menu_func_t)(void);
typedef struct
typedef struct
{
menu_func_t menu;
int8_t position;

View File

@ -2,6 +2,7 @@
#include "ConfigurationStore.h"
#include "util.h"
#include "language.h"
#include "lcd.h"
#include "mesh_bed_calibration.h"
#include "mesh_bed_leveling.h"
#include "stepper.h"
@ -262,26 +263,26 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
for (uint8_t i = 0; i < npts; ++i) {
// First for the residuum in the x axis:
if (r != 1 && c != 1) {
float a =
float a =
(r == 0) ? 1.f :
((r == 2) ? (-s1 * measured_pts[2 * i]) :
(-c2 * measured_pts[2 * i + 1]));
float b =
float b =
(c == 0) ? 1.f :
((c == 2) ? (-s1 * measured_pts[2 * i]) :
(-c2 * measured_pts[2 * i + 1]));
float w = point_weight_x(i, measured_pts[2 * i + 1]);
acc += a * b * w;
}
// Second for the residuum in the y axis.
// Second for the residuum in the y axis.
// The first row of the points have a low weight, because their position may not be known
// with a sufficient accuracy.
if (r != 0 && c != 0) {
float a =
float a =
(r == 1) ? 1.f :
((r == 2) ? ( c1 * measured_pts[2 * i]) :
(-s2 * measured_pts[2 * i + 1]));
float b =
float b =
(c == 1) ? 1.f :
((c == 2) ? ( c1 * measured_pts[2 * i]) :
(-s2 * measured_pts[2 * i + 1]));
@ -295,7 +296,7 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
acc = 0.f;
for (uint8_t i = 0; i < npts; ++i) {
{
float j =
float j =
(r == 0) ? 1.f :
((r == 1) ? 0.f :
((r == 2) ? (-s1 * measured_pts[2 * i]) :
@ -305,7 +306,7 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
acc += j * fx * w;
}
{
float j =
float j =
(r == 0) ? 0.f :
((r == 1) ? 1.f :
((r == 2) ? ( c1 * measured_pts[2 * i]) :
@ -455,7 +456,7 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
if (err > BED_CALIBRATION_POINT_OFFSET_MAX_EUCLIDIAN) {
result = BED_SKEW_OFFSET_DETECTION_FITTING_FAILED;
#ifdef SUPPORT_VERBOSITY
if(verbosity_level >= 20) SERIAL_ECHOPGM(", error > max. error euclidian");
if(verbosity_level >= 20) SERIAL_ECHOPGM(", error > max. error euclidian");
#endif // SUPPORT_VERBOSITY
}
}
@ -499,19 +500,6 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
}
#endif // SUPPORT_VERBOSITY
#if 0
if (result == BED_SKEW_OFFSET_DETECTION_PERFECT && fabs(a1) < bed_skew_angle_mild && fabs(a2) < bed_skew_angle_mild) {
#ifdef SUPPORT_VERBOSITY
if (verbosity_level > 0)
SERIAL_ECHOLNPGM("Very little skew detected. Disabling skew correction.");
#endif // SUPPORT_VERBOSITY
// Just disable the skew correction.
vec_x[0] = MACHINE_AXIS_SCALE_X;
vec_x[1] = 0.f;
vec_y[0] = 0.f;
vec_y[1] = MACHINE_AXIS_SCALE_Y;
}
#else
if (result == BED_SKEW_OFFSET_DETECTION_PERFECT) {
#ifdef SUPPORT_VERBOSITY
if (verbosity_level > 0)
@ -583,7 +571,6 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
}
#endif // SUPPORT_VERBOSITY
}
#endif
// Invert the transformation matrix made of vec_x, vec_y and cntr.
{
@ -684,7 +671,7 @@ void reset_bed_offset_and_skew()
bool is_bed_z_jitter_data_valid()
// offsets of the Z heiths of the calibration points from the first point are saved as 16bit signed int, scaled to tenths of microns
// if at least one 16bit integer has different value then -1 (0x0FFFF), data are considered valid and function returns true, otherwise it returns false
{
{
for (int8_t i = 0; i < 8; ++i) {
if (eeprom_read_word((uint16_t*)(EEPROM_BED_CALIBRATION_Z_JITTER + i * 2)) != 0x0FFFF)
return true;
@ -947,11 +934,11 @@ bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, int
#endif //SUPPORT_VERBOSITY
)
{
bool high_deviation_occured = false;
bool high_deviation_occured = false;
bedPWMDisabled = 1;
#ifdef TMC2130
bool bHighPowerForced = false;
if (tmc2130_mode == TMC2130_MODE_SILENT)
if (tmc2130_mode == TMC2130_MODE_SILENT)
{
FORCE_HIGH_POWER_START;
bHighPowerForced = true;
@ -985,7 +972,7 @@ bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, int
#endif //TMC2130
for (uint8_t i = 0; i < n_iter; ++ i)
{
current_position[Z_AXIS] += high_deviation_occured ? 0.5 : 0.2;
float z_bckp = current_position[Z_AXIS];
go_to_current(homing_feedrate[Z_AXIS]/60);
@ -997,7 +984,7 @@ bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, int
update_current_position_z();
//printf_P(PSTR("Zs: %f, Z: %f, delta Z: %f"), z_bckp, current_position[Z_AXIS], (z_bckp - current_position[Z_AXIS]));
if (fabs(current_position[Z_AXIS] - z_bckp) < 0.025) {
//printf_P(PSTR("PINDA triggered immediately, move Z higher and repeat measurement\n"));
//printf_P(PSTR("PINDA triggered immediately, move Z higher and repeat measurement\n"));
raise_z(0.5);
current_position[Z_AXIS] = minimum_z;
go_to_current(homing_feedrate[Z_AXIS]/(4*60));
@ -1026,12 +1013,12 @@ bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, int
//printf_P(PSTR("Z[%d] = %d, dz=%d\n"), i, (int)(current_position[Z_AXIS] * 1000), (int)(dz * 1000));
//printf_P(PSTR("Z- measurement deviation from avg value %f um\n"), dz);
if (dz > 0.05) { //deviation > 50um
if (high_deviation_occured == false) { //first occurence may be caused in some cases by mechanic resonance probably especially if printer is placed on unstable surface
if (high_deviation_occured == false) { //first occurence may be caused in some cases by mechanic resonance probably especially if printer is placed on unstable surface
//printf_P(PSTR("high dev. first occurence\n"));
delay_keep_alive(500); //damping
//start measurement from the begining, but this time with higher movements in Z axis which should help to reduce mechanical resonance
high_deviation_occured = true;
i = -1;
i = -1;
z = 0;
}
else {
@ -1199,8 +1186,6 @@ BedSkewOffsetDetectionResultType find_bed_induction_sensor_point_xy(int
MYSERIAL.println(current_position[Z_AXIS]);
}
#endif //SUPPORT_VERBOSITY
//lcd_show_fullscreen_message_and_wait_P(PSTR("First hit"));
//lcd_update_enable(true);
float init_x_position = current_position[X_AXIS];
float init_y_position = current_position[Y_AXIS];
@ -1208,7 +1193,7 @@ BedSkewOffsetDetectionResultType find_bed_induction_sensor_point_xy(int
// we have to let the planner know where we are right now as it is not where we said to go.
update_current_position_xyz();
enable_z_endstop(false);
for (int8_t iter = 0; iter < 2; ++iter) {
/*SERIAL_ECHOPGM("iter: ");
MYSERIAL.println(iter);
@ -1227,7 +1212,7 @@ BedSkewOffsetDetectionResultType find_bed_induction_sensor_point_xy(int
invert_z_endstop(true);
for (int iteration = 0; iteration < 8; iteration++) {
found = false;
found = false;
enable_z_endstop(true);
go_xy(init_x_position + 16.0f, current_position[Y_AXIS], feedrate / 5);
update_current_position_xyz();
@ -1253,7 +1238,7 @@ BedSkewOffsetDetectionResultType find_bed_induction_sensor_point_xy(int
current_position[X_AXIS] = 0.5f * (a + b);
go_xy(current_position[X_AXIS], init_y_position, feedrate / 5);
found = true;
// Search in the Y direction along a cross.
found = false;
enable_z_endstop(true);
@ -1329,7 +1314,7 @@ BedSkewOffsetDetectionResultType find_bed_induction_sensor_point_xy(int
break;
}
}
enable_z_endstop(false);
invert_z_endstop(false);
return found;
@ -1817,7 +1802,7 @@ canceled:
#define IMPROVE_BED_INDUCTION_SENSOR_POINT3_SEARCH_RADIUS (8.f)
#define IMPROVE_BED_INDUCTION_SENSOR_POINT3_SEARCH_STEP_FINE_Y (0.1f)
inline bool improve_bed_induction_sensor_point3(int verbosity_level)
{
{
float center_old_x = current_position[X_AXIS];
float center_old_y = current_position[Y_AXIS];
float a, b;
@ -2192,7 +2177,7 @@ float __attribute__((noinline)) BED_Y(const uint8_t row)
}
BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level, uint8_t &too_far_mask)
{
{
// Don't let the manage_inactivity() function remove power from the motors.
refresh_cmd_timeout();
@ -2203,13 +2188,13 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
float *vec_y = vec_x + 2;
float *cntr = vec_y + 2;
memset(pts, 0, sizeof(float) * 7 * 7);
uint8_t iteration = 0;
uint8_t iteration = 0;
BedSkewOffsetDetectionResultType result;
// SERIAL_ECHOLNPGM("find_bed_offset_and_skew verbosity level: ");
// SERIAL_ECHO(int(verbosity_level));
// SERIAL_ECHOPGM("");
#ifdef NEW_XYZCAL
{
#else //NEW_XYZCAL
@ -2221,7 +2206,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
#ifdef SUPPORT_VERBOSITY
if (verbosity_level >= 20) {
SERIAL_ECHOLNPGM("Vectors: ");
SERIAL_ECHOPGM("vec_x[0]:");
MYSERIAL.print(vec_x[0], 5);
SERIAL_ECHOLNPGM("");
@ -2290,7 +2275,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
else {
// if first iteration failed, count corrected point coordinates as initial
// Use the corrected coordinate, which is a result of find_bed_offset_and_skew().
current_position[X_AXIS] = vec_x[0] * pgm_read_float(bed_ref_points_4 + k * 2) + vec_y[0] * pgm_read_float(bed_ref_points_4 + k * 2 + 1) + cntr[0];
current_position[Y_AXIS] = vec_x[1] * pgm_read_float(bed_ref_points_4 + k * 2) + vec_y[1] * pgm_read_float(bed_ref_points_4 + k * 2 + 1) + cntr[1];
@ -2333,7 +2318,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
#ifndef NEW_XYZCAL
#ifndef HEATBED_V2
if (k == 0 || k == 1) {
// Improve the position of the 1st row sensor points by a zig-zag movement.
find_bed_induction_sensor_point_z();
@ -2372,11 +2357,11 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
pt[0] += (current_position[X_AXIS]/(iteration + 1)); //count average
pt[1] = (pt[1] * iteration) / (iteration + 1);
pt[1] += (current_position[Y_AXIS] / (iteration + 1));
//pt[0] += current_position[X_AXIS];
//if(iteration > 0) pt[0] = pt[0] / 2;
//pt[1] += current_position[Y_AXIS];
//if (iteration > 0) pt[1] = pt[1] / 2;
@ -2410,7 +2395,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
}
DBG(_n("All 4 calibration points found.\n"));
delay_keep_alive(0); //manage_heater, reset watchdog, manage inactivity
#ifdef SUPPORT_VERBOSITY
if (verbosity_level >= 20) {
// Test the positions. Are the positions reproducible? Now the calibration is active in the planner.
@ -2437,7 +2422,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
}
result = calculate_machine_skew_and_offset_LS(pts, 4, bed_ref_points_4, vec_x, vec_y, cntr, verbosity_level);
delay_keep_alive(0); //manage_heater, reset watchdog, manage inactivity
if (result >= 0) {
DBG(_n("Calibration success.\n"));
world2machine_update(vec_x, vec_y, cntr);
@ -2500,7 +2485,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
}
iteration++;
}
return result;
return result;
}
#ifndef NEW_XYZCAL
@ -2903,7 +2888,7 @@ bool sample_mesh_and_store_reference()
kill(_T(MSG_BED_LEVELING_FAILED_POINT_LOW));
}
// Get cords of measuring point
mbl.set_z(ix, iy, current_position[Z_AXIS]);
}
{
@ -3060,11 +3045,11 @@ void babystep_load()
if (calibration_status_get(CALIBRATION_STATUS_LIVE_ADJUST))
{
check_babystep(); //checking if babystep is in allowed range, otherwise setting babystep to 0
// End of G80: Apply the baby stepping value.
babystepLoadZ = eeprom_read_word(reinterpret_cast<uint16_t *>(&(EEPROM_Sheets_base->
s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].z_offset)));
#if 0
SERIAL_ECHO("Z baby step: ");
SERIAL_ECHO(babystepLoadZ);
@ -3091,7 +3076,7 @@ void babystep_undo()
void babystep_reset()
{
babystepLoadZ = 0;
babystepLoadZ = 0;
}
void count_xyz_details(float (&distanceMin)[2]) {
@ -3101,11 +3086,7 @@ void count_xyz_details(float (&distanceMin)[2]) {
eeprom_read_block(&cntr[0], (float*)(EEPROM_BED_CALIBRATION_CENTER), 8);
eeprom_read_block(&vec_x[0], (float*)(EEPROM_BED_CALIBRATION_VEC_X), 8);
eeprom_read_block(&vec_y[0], (float*)(EEPROM_BED_CALIBRATION_VEC_Y), 8);
#if 0
a2 = -1 * asin(vec_y[0] / MACHINE_AXIS_SCALE_Y);
a1 = asin(vec_x[1] / MACHINE_AXIS_SCALE_X);
angleDiff = fabs(a2 - a1);
#endif
for (uint8_t mesh_point = 0; mesh_point < 2; ++mesh_point) {
float y = vec_x[1] * pgm_read_float(bed_ref_points_4 + mesh_point * 2) + vec_y[1] * pgm_read_float(bed_ref_points_4 + mesh_point * 2 + 1) + cntr[1];
distanceMin[mesh_point] = (y - Y_MIN_POS_CALIBRATION_POINT_OUT_OF_REACH);
@ -3120,8 +3101,8 @@ void mbl_settings_init() {
eeprom_init_default_byte((uint8_t*)EEPROM_MBL_PROBE_NR, 3);
}
//parameter ix: index of mesh bed leveling point in X-axis (for meas_points == 7 is valid range from 0 to 6; for meas_points == 3 is valid range from 0 to 2 )
//parameter iy: index of mesh bed leveling point in Y-axis (for meas_points == 7 is valid range from 0 to 6; for meas_points == 3 is valid range from 0 to 2 )
//parameter ix: index of mesh bed leveling point in X-axis (for meas_points == 7 is valid range from 0 to 6; for meas_points == 3 is valid range from 0 to 2 )
//parameter iy: index of mesh bed leveling point in Y-axis (for meas_points == 7 is valid range from 0 to 6; for meas_points == 3 is valid range from 0 to 2 )
//function returns true if point is considered valid (typicaly in safe distance from magnet or another object which inflences PINDA measurements)
bool mbl_point_measurement_valid(uint8_t ix, uint8_t iy) {
//"human readable" heatbed plan

View File

@ -1,6 +1,6 @@
#pragma once
#include "Marlin.h"
#include <avr/pgmspace.h>
#define BED_ZERO_REF_X (- 22.f + X_PROBE_OFFSET_FROM_EXTRUDER) // -22 + 23 = 1
#define BED_ZERO_REF_Y (- 0.6f + Y_PROBE_OFFSET_FROM_EXTRUDER + 4.f) // -0.6 + 5 + 4 = 8.4
@ -133,7 +133,7 @@ inline bool world2machine_clamp(float &x, float &y)
tmpx = X_MAX_POS;
clamped = true;
}
if (tmpy < Y_MIN_POS) {
tmpy = Y_MIN_POS;
clamped = true;
@ -163,13 +163,13 @@ float BED_Y(const uint8_t row);
* Negative: failed
*/
enum BedSkewOffsetDetectionResultType {
enum BedSkewOffsetDetectionResultType : int8_t {
// Detection failed, some point was not found.
BED_SKEW_OFFSET_DETECTION_POINT_FOUND = 0, //!< Point found
BED_SKEW_OFFSET_DETECTION_POINT_NOT_FOUND = -1, //!< Point not found.
BED_SKEW_OFFSET_DETECTION_FITTING_FAILED = -2, //!< Fitting failed
BED_SKEW_OFFSET_DETECTION_POINT_SCAN_FAILED = -3, //!< Point scan failed, try again
// Detection finished with success.
BED_SKEW_OFFSET_DETECTION_PERFECT = 0, //!< Perfect.
BED_SKEW_OFFSET_DETECTION_SKEW_MILD = 1, //!< Mildly skewed.
@ -195,7 +195,7 @@ extern bool is_bed_z_jitter_data_valid();
// Useful for visualizing the behavior of the bed induction detector.
extern bool scan_bed_induction_points(int8_t verbosity_level);
// Load Z babystep value from the EEPROM into babystepLoadZ,
// Load Z babystep value from the EEPROM into babystepLoadZ,
// but don't apply it through the planner. This is useful on wake up
// after power panic, when it is expected, that the baby step has been already applied.
extern void babystep_load();

View File

@ -14,7 +14,7 @@ void mesh_bed_leveling::reset() {
float mesh_bed_leveling::get_z(float x, float y) {
int i, j;
float s, t;
i = int(floor((x - (BED_X0 + X_PROBE_OFFSET_FROM_EXTRUDER)) / x_mesh_density));
if (i < 0) {
i = 0;
@ -36,7 +36,7 @@ float mesh_bed_leveling::get_z(float x, float y) {
}
t = (y - get_y(j)) / y_mesh_density;
}
float si = 1.f-s;
float z0 = si * z_values[j ][i] + s * z_values[j ][i+1];
float z1 = si * z_values[j+1][i] + s * z_values[j+1][i+1];
@ -60,7 +60,7 @@ void mesh_bed_leveling::upsample_3x3()
if (!isnan(z_values[j][i]))
continue;
float x = get_x(i);
z_values[j][i] =
z_values[j][i] =
z_values[j][idx0] * (x - x1) * (x - x2) / ((x0 - x1) * (x0 - x2)) +
z_values[j][idx1] * (x - x0) * (x - x2) / ((x1 - x0) * (x1 - x2)) +
z_values[j][idx2] * (x - x0) * (x - x1) / ((x2 - x0) * (x2 - x1));
@ -78,7 +78,7 @@ void mesh_bed_leveling::upsample_3x3()
if (!isnan(z_values[j][i]))
continue;
float y = get_y(j);
z_values[j][i] =
z_values[j][i] =
z_values[idx0][i] * (y - y1) * (y - y2) / ((y0 - y1) * (y0 - y2)) +
z_values[idx1][i] * (y - y0) * (y - y2) / ((y1 - y0) * (y1 - y2)) +
z_values[idx2][i] * (y - y0) * (y - y1) / ((y2 - y0) * (y2 - y1));

View File

@ -7,9 +7,9 @@ class mesh_bed_leveling {
public:
uint8_t active;
float z_values[MESH_NUM_Y_POINTS][MESH_NUM_X_POINTS];
mesh_bed_leveling() { reset(); }
void reset();
static float get_x(int i) { return BED_X(i) + X_PROBE_OFFSET_FROM_EXTRUDER; }

View File

@ -18,7 +18,8 @@ const char MSG_BED_HEATING[] PROGMEM_I1 = ISTR("Bed Heating"); ////MSG_BED_HEATI
const char MSG_BED_LEVELING_FAILED_POINT_LOW[] PROGMEM_I1 = ISTR("Bed leveling failed. Sensor didn't trigger. Debris on nozzle? Waiting for reset."); ////MSG_BED_LEVELING_FAILED_POINT_LOW c=20 r=6
const char MSG_BED_SKEW_OFFSET_DETECTION_FITTING_FAILED[] PROGMEM_I1 = ISTR("XYZ calibration failed. Please consult the manual."); ////MSG_BED_SKEW_OFFSET_DETECTION_FITTING_FAILED c=20 r=8
const char MSG_BELT_STATUS[] PROGMEM_I1 = ISTR("Belt status");////MSG_BELT_STATUS c=18
const char MSG_CANCEL[] PROGMEM_I1 = ISTR(">Cancel");////MSG_CANCEL c=10
const char MSG_EJECT[] PROGMEM_I1 = ISTR("Eject"); ////MSG_EJECT c=9
const char MSG_CANCEL[] PROGMEM_I1 = ISTR("Cancel");////MSG_CANCEL c=9
const char MSG_CALIBRATE_Z_AUTO[] PROGMEM_I1 = ISTR("Calibrating Z"); ////MSG_CALIBRATE_Z_AUTO c=20 r=2
const char MSG_CARD_MENU[] PROGMEM_I1 = ISTR("Print from SD"); ////MSG_CARD_MENU c=18
const char MSG_CHECKING_X[] PROGMEM_I1 = ISTR("Checking X axis"); ////MSG_CHECKING_X c=20
@ -34,7 +35,6 @@ const char MSG_ERROR[] PROGMEM_I1 = ISTR("ERROR:"); ////MSG_ERROR c=10
const char MSG_EXTRUDER[] PROGMEM_I1 = ISTR("Extruder"); ////MSG_EXTRUDER c=17
const char MSG_FANS_CHECK[] PROGMEM_I1 = ISTR("Fans check"); ////MSG_FANS_CHECK c=13
const char MSG_FIL_RUNOUTS[] PROGMEM_I1 = ISTR("Fil. runouts"); ////MSG_FIL_RUNOUTS c=15
const char MSG_FILAMENT[] PROGMEM_I1 = ISTR("Filament"); ////MSG_FILAMENT c=17
const char MSG_FAN_SPEED[] PROGMEM_I1 = ISTR("Fan speed"); ////MSG_FAN_SPEED c=14
const char MSG_HOTEND_FAN_SPEED[] PROGMEM_I1 = ISTR("Hotend fan:");////MSG_HOTEND_FAN_SPEED c=15
const char MSG_PRINT_FAN_SPEED[] PROGMEM_I1 = ISTR("Print fan:"); ////MSG_PRINT_FAN_SPEED c=15
@ -102,8 +102,12 @@ const char MSG_SELFTEST_MOTOR[] PROGMEM_I1 = ISTR("Motor"); ////MSG_SELFTEST_MOT
const char MSG_SELFTEST_FILAMENT_SENSOR[] PROGMEM_I1 = ISTR("Filament sensor"); ////MSG_SELFTEST_FILAMENT_SENSOR c=17
const char MSG_SELFTEST_WIRINGERROR[] PROGMEM_I1 = ISTR("Wiring error"); ////MSG_SELFTEST_WIRINGERROR c=18
const char MSG_SETTINGS[] PROGMEM_I1 = ISTR("Settings"); ////MSG_SETTINGS c=18
#ifndef REPLACE_SETREADY
const char MSG_SET_READY[] PROGMEM_I1 = ISTR("Set Ready"); ////MSG_SET_READY c=18
const char MSG_SET_NOT_READY[] PROGMEM_I1 = ISTR("Set not Ready"); ////MSG_SET_NOT_READY c=18
#else
const char MSG_HOSTPRINT[] PROGMEM_I1 = ISTR("Print from host"); ////MSG_HOSTPRINT c=18
#endif //REPLACE_SETREADY
#ifdef HOST_SHUTDOWN
const char MSG_SHUTDOWN_HOST[] PROGMEM_I1 = ISTR("Shutdown host"); ////MSG_SHUTDOWN_HOST c=18
#endif //HOST_SHUTOWN
@ -121,6 +125,7 @@ const char MSG_SILENT[] PROGMEM_I1 = ISTR("Silent"); ////MSG_SILENT c=7
const char MSG_NORMAL[] PROGMEM_I1 = ISTR("Normal"); ////MSG_NORMAL c=7
const char MSG_STEALTH[] PROGMEM_I1 = ISTR("Stealth"); ////MSG_STEALTH c=7
const char MSG_STEEL_SHEET_CHECK[] PROGMEM_I1 = ISTR("Is steel sheet on heatbed?"); ////MSG_STEEL_SHEET_CHECK c=20 r=3
const char MSG_Z_CALIBRATION_PROMPT[] PROGMEM_I1 = ISTR("Z calibration recommended. Run it now?"); ////MSG_Z_CALIBRATION_PROMPT c=20 r=3
const char MSG_STOP_PRINT[] PROGMEM_I1 = ISTR("Stop print"); ////MSG_STOP_PRINT c=18
const char MSG_STOPPED[] PROGMEM_I1 = ISTR("STOPPED."); ////MSG_STOPPED c=20
const char MSG_PINDA_CALIBRATION[] PROGMEM_I1 = ISTR("PINDA cal."); ////MSG_PINDA_CALIBRATION c=13
@ -144,14 +149,15 @@ const char MSG_NONE[] PROGMEM_I1 = ISTR("None"); ////MSG_NONE c=8
const char MSG_WARN[] PROGMEM_I1 = ISTR("Warn"); ////MSG_WARN c=8
const char MSG_STRICT[] PROGMEM_I1 = ISTR("Strict"); ////MSG_STRICT c=8
const char MSG_MODEL[] PROGMEM_I1 = ISTR("Model"); ////MSG_MODEL c=8
const char MSG_GCODE_DIFF_PRINTER_CONTINUE[] PROGMEM_I1 = ISTR("G-code sliced for a different printer type. Continue?"); ////MSG_GCODE_DIFF_PRINTER_CONTINUE c=20 r=3
const char MSG_GCODE_DIFF_PRINTER_CANCELLED[] PROGMEM_I1 =ISTR("G-code sliced for a different printer type. Please re-slice the model again. Print cancelled."); ////MSG_GCODE_DIFF_PRINTER_CANCELLED c=20 r=8
const char MSG_GCODE_NEWER_FIRMWARE_CONTINUE[] PROGMEM_I1 = ISTR("G-code sliced for a newer firmware. Continue?"); ////MSG_GCODE_NEWER_FIRMWARE_CONTINUE c=20 r=3
const char MSG_GCODE_NEWER_FIRMWARE_CANCELLED[] PROGMEM_I1 = ISTR("G-code sliced for a newer firmware. Please update the firmware. Print cancelled."); ////MSG_GCODE_NEWER_FIRMWARE_CANCELLED c=20 r=8
const char MSG_GCODE_DIFF_CONTINUE[] PROGMEM_I1 = ISTR("G-code sliced for a different level. Continue?"); ////MSG_GCODE_DIFF_CONTINUE c=20 r=3
const char MSG_GCODE_DIFF_CANCELLED[] PROGMEM_I1 = ISTR("G-code sliced for a different level. Please re-slice the model again. Print cancelled."); ////MSG_GCODE_DIFF_CANCELLED c=20 r=8
const char MSG_NOZZLE_DIFFERS_CONTINUE[] PROGMEM_I1 = ISTR("Nozzle diameter differs from the G-code. Continue?"); ////MSG_NOZZLE_DIFFERS_CONTINUE c=20 r=3
const char MSG_NOZZLE_DIFFERS_CANCELLED[] PROGMEM_I1 = ISTR("Nozzle diameter differs from the G-code. Please check the value in settings. Print cancelled."); ////MSG_NOZZLE_DIFFERS_CANCELLED c=20 r=8
const char MSG_GCODE_DIFF_PRINTER_CONTINUE[] PROGMEM_I1 = ISTR("G-code sliced for a different printer type."); ////MSG_GCODE_DIFF_PRINTER_CONTINUE c=20 r=3
const char MSG_GCODE_DIFF_PRINTER_CANCELLED[] PROGMEM_I1 =ISTR("G-code sliced for a different printer type. Please re-slice the model again."); ////MSG_GCODE_DIFF_PRINTER_CANCELLED c=20 r=8
const char MSG_GCODE_NEWER_FIRMWARE_CONTINUE[] PROGMEM_I1 = ISTR("G-code sliced for a newer firmware."); ////MSG_GCODE_NEWER_FIRMWARE_CONTINUE c=20 r=3
const char MSG_GCODE_NEWER_FIRMWARE_CANCELLED[] PROGMEM_I1 = ISTR("G-code sliced for a newer firmware. Please update the firmware."); ////MSG_GCODE_NEWER_FIRMWARE_CANCELLED c=20 r=8
const char MSG_GCODE_DIFF_CONTINUE[] PROGMEM_I1 = ISTR("G-code sliced for a different level."); ////MSG_GCODE_DIFF_CONTINUE c=20 r=3
const char MSG_GCODE_DIFF_CANCELLED[] PROGMEM_I1 = ISTR("G-code sliced for a different level. Please re-slice the model again."); ////MSG_GCODE_DIFF_CANCELLED c=20 r=8
const char MSG_MISSING_FILAMENT[] PROGMEM_I1 = ISTR("There is no filament loaded."); ////MSG_MISSING_FILAMENT c=20 r=3
const char MSG_NOZZLE_DIFFERS_CONTINUE[] PROGMEM_I1 = ISTR("Nozzle diameter differs from the G-code."); ////MSG_NOZZLE_DIFFERS_CONTINUE c=20 r=3
const char MSG_NOZZLE_DIFFERS_CANCELLED[] PROGMEM_I1 = ISTR("Nozzle diameter differs from the G-code. Please check the value in settings."); ////MSG_NOZZLE_DIFFERS_CANCELLED c=20 r=8
const char MSG_NOZZLE_DIAMETER[] PROGMEM_I1 = ISTR("Nozzle d."); ////MSG_NOZZLE_DIAMETER c=10
const char MSG_MMU_MODE[] PROGMEM_I1 = ISTR("MMU Mode"); ////MSG_MMU_MODE c=8
const char MSG_SD_CARD[] PROGMEM_I1 = ISTR("SD card"); ////MSG_SD_CARD c=8
@ -192,7 +198,12 @@ extern const char MSG_TM_ACK_ERROR[] PROGMEM_I1 = ISTR("Clear TM error");////MSG
extern const char MSG_LOAD_ALL[] PROGMEM_I1 = ISTR("Load All"); ////MSG_LOAD_ALL c=18
extern const char MSG_NOZZLE_CNG_MENU [] PROGMEM_I1 = ISTR("Nozzle change");////MSG_NOZZLE_CNG_MENU c=18
extern const char MSG_NOZZLE_CNG_READ_HELP [] PROGMEM_I1 = ISTR("For a Nozzle change please read\nprusa.io/nozzle-mk3s");////MSG_NOZZLE_CNG_READ_HELP c=20 r=4
#ifdef QUICK_NOZZLE_CHANGE
extern const char MSG_NOZZLE_CNG_COOLDOWN [] PROGMEM_I1 = ISTR("Nozzle is hot! Wait for cooldown.");////MSG_NOZZLE_CNG_COOLDOWN c=20 r=3
extern const char MSG_NOZZLE_CNG_CHANGED [] PROGMEM_I1 = ISTR("Nozzle changed?");////MSG_NOZZLE_CNG_CHANGED_QUICK c=20 r=3
#else
extern const char MSG_NOZZLE_CNG_CHANGED [] PROGMEM_I1 = ISTR("Hotend at 280C! Nozzle changed and tightened to specs?");////MSG_NOZZLE_CNG_CHANGED c=20 r=6
#endif //QUICK_NOZZLE_CHANGE
extern const char MSG_REPRINT [] PROGMEM_I1 = ISTR("Reprint"); ////MSG_REPRINT c=18
extern const char MSG_FILE_CNT [] PROGMEM_I1 = ISTR("Some files will not be sorted. Max. No. of files in 1 folder for sorting is 100."); ////MSG_FILE_CNT c=20 r=6
extern const char MSG_CHANGED_MOTHERBOARD [] PROGMEM_I1 = ISTR("Warning: motherboard type changed."); ////MSG_CHANGED_MOTHERBOARD c=20 r=4
@ -200,7 +211,7 @@ extern const char MSG_CHANGED_PRINTER [] PROGMEM_I1 = ISTR("Warning: printer typ
extern const char MSG_CHANGED_BOTH [] PROGMEM_I1 = ISTR("Warning: both printer type and motherboard type changed."); ////MSG_CHANGED_BOTH c=20 r=4
extern const char MSG_DEFAULT_SETTINGS_LOADED [] PROGMEM_I1 = ISTR("Old settings found. Default PID, Esteps etc. will be set."); ////MSG_DEFAULT_SETTINGS_LOADED c=20 r=6
extern const char MSG_FORCE_SELFTEST [] PROGMEM_I1 = ISTR("Selftest will be run to calibrate accurate sensorless rehoming."); ////MSG_FORCE_SELFTEST c=20 r=8
extern const char MSG_MBL_FAILED_Z_CAL [] PROGMEM_I1 = ISTR("Mesh bed leveling failed. Please run Z calibration."); ////MSG_MBL_FAILED_Z_CAL c=20 r=4
extern const char MSG_MBL_FAILED [] PROGMEM_I1 = ISTR("Mesh bed leveling failed. Print canceled."); ////MSG_MBL_FAILED c=20 r=4
extern const char MSG_ZLEVELING_ENFORCED [] PROGMEM_I1 = ISTR("Some problem encountered, Z-leveling enforced ..."); ////MSG_ZLEVELING_ENFORCED c=20 r=4
extern const char MSG_UNLOAD_SUCCESSFUL [] PROGMEM_I1 = ISTR("Was filament unload successful?"); ////MSG_UNLOAD_SUCCESSFUL c=20 r=3
extern const char MSG_CHECK_IDLER [] PROGMEM_I1 = ISTR("Please open idler and remove filament manually."); ////MSG_CHECK_IDLER c=20 r=4
@ -242,7 +253,9 @@ extern const char MSG_LOADING_COLOR [] PROGMEM_I1 = ISTR("Loading color"); ////M
extern const char MSG_CORRECTLY [] PROGMEM_I1 = ISTR("Changed correctly"); ////MSG_CORRECTLY c=19
extern const char MSG_NOT_LOADED [] PROGMEM_I1 = ISTR("Filament not loaded"); ////MSG_NOT_LOADED c=19
extern const char MSG_NOT_COLOR [] PROGMEM_I1 = ISTR("Color not correct"); ////MSG_NOT_COLOR c=19
#ifndef REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
extern const char MSG_AUTOLOADING_ENABLED [] PROGMEM_I1 = ISTR("Autoloading filament is active, just press the knob and insert filament..."); ////MSG_AUTOLOADING_ENABLED c=20 r=4
#endif //REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
extern const char MSG_FILAMENT_USED [] PROGMEM_I1 = ISTR("Filament used"); ////MSG_FILAMENT_USED c=19
extern const char MSG_PRINT_TIME [] PROGMEM_I1 = ISTR("Print time"); ////MSG_PRINT_TIME c=19
extern const char MSG_TOTAL_FILAMENT [] PROGMEM_I1 = ISTR("Total filament"); ////MSG_TOTAL_FILAMENT c=19
@ -283,7 +296,7 @@ extern const char MSG_MODE_CHANGE_IN_PROGRESS [] PROGMEM_I1 = ISTR("Mode change
extern const char MSG_COPY_SEL_LANG [] PROGMEM_I1 = ISTR("Copy selected language?"); ////MSG_COPY_SEL_LANG c=20 r=3
extern const char MSG_SHEET_OFFSET [] PROGMEM_I1 = ISTR("Sheet %.7s\nZ offset: %+1.3fmm\n%cContinue\n%cReset"); ////MSG_SHEET_OFFSET c=20 r=4
extern const char MSG_PLEASE_LOAD_PLA [] PROGMEM_I1 = ISTR("Please load filament first."); ////MSG_PLEASE_LOAD_PLA c=20 r=4
extern const char MSG_WIZARD_RERUN [] PROGMEM_I1 = ISTR("Running Wizard will delete current calibration results and start from the beginning. Continue?"); ////MSG_WIZARD_RERUN c=20 r=7
extern const char MSG_WIZARD_RERUN [] PROGMEM_I1 = ISTR("Running Wizard will delete current calibration results and start from the beginning."); ////MSG_WIZARD_RERUN c=20 r=7
extern const char MSG_MMU_INSERT_FILAMENT_FIRST_TUBE [] PROGMEM_I1 = ISTR("Please insert filament into the first tube of the MMU, then press the knob to load it."); ////MSG_MMU_INSERT_FILAMENT_FIRST_TUBE c=20 r=6
extern const char MSG_WIZARD_LOAD_FILAMENT [] PROGMEM_I1 = ISTR("Please insert filament into the extruder, then press the knob to load it."); ////MSG_WIZARD_LOAD_FILAMENT c=20 r=6
extern const char MSG_WIZARD_V2_CAL [] PROGMEM_I1 = ISTR("Now I will calibrate distance between tip of the nozzle and heatbed surface."); ////MSG_WIZARD_V2_CAL c=20 r=8
@ -360,37 +373,28 @@ extern const char MSG_SELFTEST_CHECK_HOTEND [] PROGMEM_I1 = ISTR("Checking hoten
extern const char MSG_SELFTEST_CHECK_ALLCORRECT [] PROGMEM_I1 = ISTR("All correct"); ////MSG_SELFTEST_CHECK_ALLCORRECT c=20
extern const char MSG_CALIBRATING_HOME [] PROGMEM_I1 = ISTR("Calibrating home"); ////MSG_CALIBRATING_HOME c=20
extern const char MSG_CHECKING_FILE [] PROGMEM_I1 = ISTR("Checking file"); ////MSG_CHECKING_FILE c=17
extern const char MSG_FILE_INCOMPLETE [] PROGMEM_I1 = ISTR("File incomplete. Continue anyway?"); ////MSG_FILE_INCOMPLETE c=20 r=3
extern const char MSG_FILE_INCOMPLETE [] PROGMEM_I1 = ISTR("File incomplete."); ////MSG_FILE_INCOMPLETE c=20 r=3
extern const char MSG_SD_REMOVED [] PROGMEM_I1 = ISTR("Card removed"); ////MSG_SD_REMOVED c=20
extern const char MSG_NEW_FIRMWARE_AVAILABLE [] PROGMEM_I1 = ISTR("New firmware version available:"); ////MSG_NEW_FIRMWARE_AVAILABLE c=20 r=2
extern const char MSG_NEW_FIRMWARE_PLEASE_UPGRADE [] PROGMEM_I1 = ISTR("Please upgrade."); ////MSG_NEW_FIRMWARE_PLEASE_UPGRADE c=20
extern const char MSG_FW_MK3_DETECTED [] PROGMEM_I1 = ISTR(PRINTER_NAME " firmware detected on " PRINTER_NAME_ALTERNATE " printer"); ////MSG_FW_MK3_DETECTED c=20 r=4
//not internationalized messages
#if 0
const char MSG_FW_VERSION_BETA[] PROGMEM_N1 = "You are using a BETA firmware version! It is in a development state! Use this version with CAUTION as it may DAMAGE the printer!"; ////MSG_FW_VERSION_BETA c=20 r=8
#endif
const char MSG_SPOOL_JOIN[] PROGMEM_N1 = "SpoolJoin"; ////MSG_SPOOL_JOIN c=13
const char MSG_FIRMWARE[] PROGMEM_N1 = "Firmware"; ////MSG_FIRMWARE c=8
const char MSG_FILAMENT[] PROGMEM_N1 = "Filament"; ////MSG_FILAMENT c=8
const char MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY[] PROGMEM_N1 = "FlashAir"; ////MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY c=8
const char MSG_PINDA[] PROGMEM_N1 = "PINDA"; ////MSG_PINDA c=5
const char MSG_WELCOME[] PROGMEM_N1 = WELCOME_MSG;
const char MSG_SD_WORKDIR_FAIL[] PROGMEM_N1 = "workDir open failed"; ////
const char MSG_BROWNOUT_RESET[] PROGMEM_N1 = " Brown out Reset"; ////
const char MSG_EXTERNAL_RESET[] PROGMEM_N1 = " External Reset"; ////
const char MSG_FILE_SAVED[] PROGMEM_N1 = "Done saving file."; ////
const char MSG_POSITION_UNKNOWN[] PROGMEM_N1 = "Home X/Y before Z"; ////
const char MSG_SOFTWARE_RESET[] PROGMEM_N1 = " Software Reset"; ////
const char MSG_UNKNOWN_COMMAND[] PROGMEM_N1 = "Unknown command: \""; ////
const char MSG_WATCHDOG_RESET[] PROGMEM_N1 = " Watchdog Reset"; ////
const char MSG_Z_MAX[] PROGMEM_N1 = "z_max: "; ////
const char MSG_Z_MIN[] PROGMEM_N1 = "z_min: "; ////
const char MSG_ZPROBE_OUT[] PROGMEM_N1 = "Z probe out. bed"; ////
#ifdef ENABLE_AUTO_BED_LEVELING
const char MSG_ZPROBE_ZOFFSET[] PROGMEM_N1 = "Z Offset"; ////
#endif
const char MSG_TMC_OVERTEMP[] PROGMEM_N1 = "TMC DRIVER OVERTEMP"; ////
const char MSG_Enqueing[] PROGMEM_N1 = "enqueing \""; ////
const char MSG_ENDSTOPS_HIT[] PROGMEM_N1 = "endstops hit: "; ////
const char MSG_SD_ERR_WRITE_TO_FILE[] PROGMEM_N1 = "error writing to file"; ////
const char MSG_OK[] PROGMEM_N1 = "ok"; ////
const char MSG_OK_CAPS[] PROGMEM_N1 = "OK"; ////
@ -409,6 +413,7 @@ const char MSG_HOST_ACTION_NOT_READY[] PROGMEM_N1 = "//action:not_ready"; ////
const char MSG_HOST_ACTION_START[] PROGMEM_N1 = "//action:start"; ////
const char MSG_HOST_ACTION_UVLO_RECOVERY_READY[] PROGMEM_N1 = "//action:uvlo_recovery_ready"; ////
const char MSG_HOST_ACTION_UVLO_AUTO_RECOVERY_READY[] PROGMEM_N1 = "//action:uvlo_auto_recovery_ready"; ////
const char MSG_HOST_ACTION_NOTIFICATION[] PROGMEM_N1 = "//action:notification %S\n"; ////
#ifdef HOST_SHUTDOWN
const char MSG_HOST_ACTION_SHUTDOWN[] PROGMEM_N1 = "//action:shutdown"; ////
#endif //HOST_SHUTOWN
@ -419,10 +424,13 @@ const char MSG_ADVANCE_K[] PROGMEM_N1 = "Advance K:"; ////c=13
const char MSG_POWERPANIC_DETECTED[] PROGMEM_N1 = "POWER PANIC DETECTED"; ////c=20
const char MSG_LCD_STATUS_CHANGED[] PROGMEM_N1 = "LCD status changed";
const char MSG_UNKNOWN_CODE[] PROGMEM_N1 = "Unknown %c code: %s\n";
const char MSG_FILAMENT_RUNOUT_DETECTED[] PROGMEM_N1 = "Filament runout detected!"; ////c=20 r=2
// Common G-gcodes
const char G1_E_F2700[] PROGMEM_N1 = "G1 E%-.3f F2700";
const char G28W[] PROGMEM_N1 = "G28 W";
const char MSG_G90[] PROGMEM_N1 = "G90";
const char MSG_G91[] PROGMEM_N1 = "G91";
const char MSG_M23[] PROGMEM_N1 = "M23 %s";
const char MSG_M24[] PROGMEM_N1 = "M24";
const char MSG_M83[] PROGMEM_N1 = "M83";

View File

@ -21,6 +21,7 @@ extern const char MSG_BED_HEATING[];
extern const char MSG_BED_LEVELING_FAILED_POINT_LOW[];
extern const char MSG_BED_SKEW_OFFSET_DETECTION_FITTING_FAILED[];
extern const char MSG_BELT_STATUS[];
extern const char MSG_EJECT[];
extern const char MSG_CANCEL[];
extern const char MSG_CALIBRATE_Z_AUTO[];
extern const char MSG_CARD_MENU[];
@ -37,7 +38,6 @@ extern const char MSG_ERROR[];
extern const char MSG_EXTRUDER[];
extern const char MSG_FANS_CHECK[];
extern const char MSG_FIL_RUNOUTS[];
extern const char MSG_FILAMENT[];
extern const char MSG_FAN_SPEED[];
extern const char MSG_HOTEND_FAN_SPEED[];
extern const char MSG_PRINT_FAN_SPEED[];
@ -104,8 +104,12 @@ extern const char MSG_SELFTEST_MOTOR[];
extern const char MSG_SELFTEST_FILAMENT_SENSOR[];
extern const char MSG_SELFTEST_WIRINGERROR[];
extern const char MSG_SETTINGS[];
#ifndef REPLACE_SETREADY
extern const char MSG_SET_READY[];
extern const char MSG_SET_NOT_READY[];
#else
extern const char MSG_HOSTPRINT[];
#endif
#ifdef HOST_SHUTDOWN
extern const char MSG_SHUTDOWN_HOST[];
#endif //HOST_SHUTOWN
@ -123,6 +127,7 @@ extern const char MSG_SILENT[];
extern const char MSG_NORMAL[];
extern const char MSG_STEALTH[];
extern const char MSG_STEEL_SHEET_CHECK[];
extern const char MSG_Z_CALIBRATION_PROMPT[];
extern const char MSG_STOP_PRINT[];
extern const char MSG_STOPPED[];
extern const char MSG_PINDA_CALIBRATION[];
@ -152,6 +157,7 @@ extern const char MSG_GCODE_NEWER_FIRMWARE_CONTINUE[];
extern const char MSG_GCODE_NEWER_FIRMWARE_CANCELLED[];
extern const char MSG_GCODE_DIFF_CONTINUE[];
extern const char MSG_GCODE_DIFF_CANCELLED[];
extern const char MSG_MISSING_FILAMENT[];
extern const char MSG_NOZZLE_DIFFERS_CONTINUE[];
extern const char MSG_NOZZLE_DIFFERS_CANCELLED[];
extern const char MSG_NOZZLE_DIAMETER[];
@ -194,6 +200,9 @@ extern const char MSG_LOAD_ALL[];
extern const char MSG_NOZZLE_CNG_MENU [];
extern const char MSG_NOZZLE_CNG_READ_HELP [];
extern const char MSG_NOZZLE_CNG_CHANGED [];
#ifdef QUICK_NOZZLE_CHANGE
extern const char MSG_NOZZLE_CNG_COOLDOWN [];
#endif //QUICK_NOZZLE_CHANGE
extern const char MSG_REPRINT [];
extern const char MSG_FILE_CNT [];
extern const char MSG_CHANGED_MOTHERBOARD [];
@ -201,7 +210,7 @@ extern const char MSG_CHANGED_PRINTER [];
extern const char MSG_CHANGED_BOTH [];
extern const char MSG_DEFAULT_SETTINGS_LOADED [];
extern const char MSG_FORCE_SELFTEST [];
extern const char MSG_MBL_FAILED_Z_CAL [];
extern const char MSG_MBL_FAILED [];
extern const char MSG_ZLEVELING_ENFORCED [];
extern const char MSG_UNLOAD_SUCCESSFUL [];
extern const char MSG_CHECK_IDLER [];
@ -243,7 +252,9 @@ extern const char MSG_LOADING_COLOR [];
extern const char MSG_CORRECTLY [];
extern const char MSG_NOT_LOADED [];
extern const char MSG_NOT_COLOR [];
#ifndef REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
extern const char MSG_AUTOLOADING_ENABLED [];
#endif //REMOVE_AUTOLOAD_FILAMENT_MENU_ENTRY
extern const char MSG_FILAMENT_USED [];
extern const char MSG_PRINT_TIME [];
extern const char MSG_TOTAL_FILAMENT [];
@ -368,31 +379,22 @@ extern const char MSG_NEW_FIRMWARE_PLEASE_UPGRADE [];
extern const char MSG_FW_MK3_DETECTED [];
//not internationalized messages
#if 0
extern const char MSG_FW_VERSION_BETA[];
#endif
extern const char MSG_SPOOL_JOIN[];
extern const char MSG_FIRMWARE[];
extern const char MSG_FILAMENT[];
extern const char MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY[];
extern const char MSG_PINDA[];
extern const char MSG_WELCOME[];
extern const char MSG_SD_WORKDIR_FAIL[];
extern const char MSG_BROWNOUT_RESET[];
extern const char MSG_EXTERNAL_RESET[];
extern const char MSG_FILE_SAVED[];
extern const char MSG_POSITION_UNKNOWN[];
extern const char MSG_SOFTWARE_RESET[];
extern const char MSG_UNKNOWN_COMMAND[];
extern const char MSG_WATCHDOG_RESET[];
extern const char MSG_Z_MAX[];
extern const char MSG_Z_MIN[];
extern const char MSG_ZPROBE_OUT[];
#ifdef ENABLE_AUTO_BED_LEVELING
extern const char MSG_ZPROBE_ZOFFSET[];
#endif
extern const char MSG_TMC_OVERTEMP[];
extern const char MSG_Enqueing[];
extern const char MSG_ENDSTOPS_HIT[];
extern const char MSG_SD_ERR_WRITE_TO_FILE[];
extern const char MSG_OK[];
extern const char MSG_OK_CAPS[];
@ -413,6 +415,7 @@ extern const char MSG_HOST_ACTION_NOT_READY[];
extern const char MSG_HOST_ACTION_START[];
extern const char MSG_HOST_ACTION_UVLO_RECOVERY_READY[];
extern const char MSG_HOST_ACTION_UVLO_AUTO_RECOVERY_READY[];
extern const char MSG_HOST_ACTION_NOTIFICATION[];
#ifdef HOST_SHUTDOWN
extern const char MSG_HOST_ACTION_SHUTDOWN[];
#endif //HOST_SHUTOWN
@ -423,10 +426,13 @@ extern const char MSG_ADVANCE_K[];
extern const char MSG_POWERPANIC_DETECTED[];
extern const char MSG_LCD_STATUS_CHANGED[];
extern const char MSG_UNKNOWN_CODE[];
extern const char MSG_FILAMENT_RUNOUT_DETECTED[];
// Common G-gcodes
extern const char G1_E_F2700[];
extern const char G28W[];
extern const char MSG_G90[];
extern const char MSG_G91[];
extern const char MSG_M23[];
extern const char MSG_M24[];
extern const char MSG_M83[];

View File

@ -34,7 +34,7 @@ void waitForHotendTargetTemp(uint16_t delay, F f) {
}
void WaitForHotendTargetTempBeep() {
waitForHotendTargetTemp(3000, []{ });
waitForHotendTargetTemp(200, [] {});
MakeSound(Prompt);
}
@ -73,14 +73,17 @@ void MMU2::Start() {
mmu2Serial.flush(); // make sure the UART buffer is clear before starting communication
SetCurrentTool(MMU2_NO_TOOL);
state = xState::Connecting;
// start the communication
logic.Start();
logic.ResetRetryAttempts();
logic.ResetCommunicationTimeoutAttempts();
state = xState::Connecting;
logic.Start();
}
MMU2::~MMU2() {}
void MMU2::Stop() {
StopKeepPowered();
PowerOff();
@ -153,8 +156,9 @@ void MMU2::PowerOn() {
}
bool MMU2::ReadRegister(uint8_t address) {
if (!WaitForMMUReady())
if (!WaitForMMUReady()) {
return false;
}
do {
logic.ReadRegister(address); // we may signal the accepted/rejected status of the response as return value of this function
} while (!manage_response(false, false));
@ -165,8 +169,9 @@ bool MMU2::ReadRegister(uint8_t address) {
}
bool __attribute__((noinline)) MMU2::WriteRegister(uint8_t address, uint16_t data) {
if (!WaitForMMUReady())
if (!WaitForMMUReady()) {
return false;
}
// special cases - intercept requests of registers which influence the printer's behaviour too + perform the change even on the printer's side
switch (address) {
@ -192,12 +197,11 @@ void MMU2::mmu_loop() {
// Atomic compare_exchange would have been the most appropriate solution here, but this gets called only in Marlin's task,
// so thread safety should be kept
static bool avoidRecursion = false;
if (avoidRecursion)
if (avoidRecursion) {
return;
}
avoidRecursion = true;
mmu_loop_inner(true);
avoidRecursion = false;
}
@ -208,7 +212,7 @@ void __attribute__((noinline)) MMU2::mmu_loop_inner(bool reportErrors) {
void MMU2::CheckFINDARunout() {
// Check for FINDA filament runout
if (!FindaDetectsFilament() && check_fsensor()) {
if (!FindaDetectsFilament() && check_fsensor()) { // Check if we have filament runout detected from sensors
SERIAL_ECHOLNPGM("FINDA filament runout!");
marlin_stop_and_save_print_to_ram();
restore_print_from_ram_and_continue(0);
@ -301,8 +305,12 @@ bool MMU2::VerifyFilamentEnteredPTFE() {
filament_inserted = filament_inserted && (WhereIsFilament() == FilamentState::AT_FSENSOR);
tlur.Progress(filament_inserted);
safe_delay_keep_alive(0);
if (planner_draining()) {
return false; // power panic or a similar issue happened, bail out fast
}
}
}
Disable_E0();
if (!filament_inserted) {
IncrementLoadFails();
@ -318,8 +326,9 @@ bool MMU2::ToolChangeCommonOnce(uint8_t slot) {
Disable_E0(); // it may seem counterintuitive to disable the E-motor, but it gets enabled in the planner whenever the E-motor is to move
tool_change_extruder = slot;
logic.ToolChange(slot); // let the MMU pull the filament out and push a new one in
if (manage_response(true, true))
if (manage_response(true, true)) {
break;
}
// otherwise: failed to perform the command - unload first and then let it run again
IncrementMMUFails();
@ -335,7 +344,7 @@ bool MMU2::ToolChangeCommonOnce(uint8_t slot) {
}
if (VerifyFilamentEnteredPTFE()) {
return true; // success
} else { // Prepare a retry attempt
} else { // Prepare a retry attempt
UnloadInner();
if (retries == 2 && cutter_enabled()) {
CutFilamentInner(slot); // try cutting filament tip at the last attempt
@ -347,6 +356,9 @@ bool MMU2::ToolChangeCommonOnce(uint8_t slot) {
void MMU2::ToolChangeCommon(uint8_t slot) {
while (!ToolChangeCommonOnce(slot)) { // while not successfully fed into extruder's PTFE tube
if (planner_draining()) {
return; // power panic happening, pretend the G-code finished ok
}
// failed autoretry, report an error by forcing a "printer" error into the MMU infrastructure - it is a hack to leverage existing code
// @@TODO theoretically logic layer may not need to be spoiled with the printer error - may be just the manage_response needs it...
logic.SetPrinterError(ErrorCode::LOAD_TO_EXTRUDER_FAILED);
@ -357,15 +369,16 @@ void MMU2::ToolChangeCommon(uint8_t slot) {
static_cast<void>(manage_response(true, true)); // yes, I'd like to silence [[nodiscard]] warning at this spot by casting to void
}
SetCurrentTool(slot); //filament change is finished
SetCurrentTool(slot); // filament change is finished
SpoolJoin::spooljoin.setSlot(slot);
++toolchange_counter;
}
bool MMU2::tool_change(uint8_t slot) {
if (!WaitForMMUReady())
if (!WaitForMMUReady()) {
return false;
}
if (slot != extruder) {
if (/*FindaDetectsFilament()*/
@ -390,8 +403,9 @@ bool MMU2::tool_change(uint8_t slot) {
///- Tx Same as T?, except nozzle doesn't have to be preheated. Tc must be placed after extruder nozzle is preheated to finish filament load.
///- Tc Load to nozzle after filament was prepared by Tx and extruder nozzle is already heated.
bool MMU2::tool_change(char code, uint8_t slot) {
if (!WaitForMMUReady())
if (!WaitForMMUReady()) {
return false;
}
FSensorBlockRunout blockRunout;
@ -435,8 +449,9 @@ void MMU2::SetCurrentTool(uint8_t ex){
}
bool MMU2::set_filament_type(uint8_t /*slot*/, uint8_t /*type*/) {
if (!WaitForMMUReady())
if (!WaitForMMUReady()) {
return false;
}
// @@TODO - this is not supported in the new MMU yet
// slot = slot; // @@TODO
@ -461,8 +476,9 @@ void MMU2::UnloadInner() {
for (;;) {
Disable_E0();
logic.UnloadFilament();
if (manage_response(false, true))
if (manage_response(false, true)) {
break;
}
IncrementMMUFails();
}
MakeSound(Confirm);
@ -473,8 +489,9 @@ void MMU2::UnloadInner() {
}
bool MMU2::unload() {
if (!WaitForMMUReady())
if (!WaitForMMUReady()) {
return false;
}
WaitForHotendTargetTempBeep();
@ -482,6 +499,7 @@ bool MMU2::unload() {
ReportingRAII rep(CommandInProgress::UnloadFilament);
UnloadInner();
}
ScreenUpdateEnable();
return true;
}
@ -490,15 +508,17 @@ void MMU2::CutFilamentInner(uint8_t slot) {
for (;;) {
Disable_E0();
logic.CutFilament(slot);
if (manage_response(false, true))
if (manage_response(false, true)) {
break;
}
IncrementMMUFails();
}
}
bool MMU2::cut_filament(uint8_t slot, bool enableFullScreenMsg /*= true*/) {
if (!WaitForMMUReady())
if (!WaitForMMUReady()) {
return false;
}
if (enableFullScreenMsg) {
FullScreenMsgCut(slot);
@ -528,8 +548,9 @@ bool MMU2::loading_test(uint8_t slot) {
}
bool MMU2::load_filament(uint8_t slot) {
if (!WaitForMMUReady())
if (!WaitForMMUReady()) {
return false;
}
FullScreenMsgLoad(slot);
{
@ -537,8 +558,9 @@ bool MMU2::load_filament(uint8_t slot) {
for (;;) {
Disable_E0();
logic.LoadFilament(slot);
if (manage_response(false, false))
if (manage_response(false, false)) {
break;
}
IncrementMMUFails();
}
MakeSound(SoundType::Confirm);
@ -548,8 +570,9 @@ bool MMU2::load_filament(uint8_t slot) {
}
bool MMU2::load_filament_to_nozzle(uint8_t slot) {
if (!WaitForMMUReady())
if (!WaitForMMUReady()) {
return false;
}
WaitForHotendTargetTempBeep();
@ -574,8 +597,9 @@ bool MMU2::load_filament_to_nozzle(uint8_t slot) {
}
bool MMU2::eject_filament(uint8_t slot, bool enableFullScreenMsg /* = true */) {
if (!WaitForMMUReady())
if (!WaitForMMUReady()) {
return false;
}
if (enableFullScreenMsg) {
FullScreenMsgEject(slot);
@ -589,8 +613,9 @@ bool MMU2::eject_filament(uint8_t slot, bool enableFullScreenMsg /* = true */) {
for (;;) {
Disable_E0();
logic.EjectFilament(slot);
if (manage_response(false, true))
if (manage_response(false, true)) {
break;
}
IncrementMMUFails();
}
SetCurrentTool(MMU2_NO_TOOL);
@ -611,8 +636,9 @@ void MMU2::Home(uint8_t mode) {
}
void MMU2::SaveHotendTemp(bool turn_off_nozzle) {
if (mmu_print_saved & SavedState::Cooldown)
if (mmu_print_saved & SavedState::Cooldown) {
return;
}
if (turn_off_nozzle && !(mmu_print_saved & SavedState::CooldownPending)) {
Disable_E0();
@ -701,8 +727,7 @@ void MMU2::CheckUserInput() {
lastButton = Buttons::NoButton; // Clear it.
}
if (mmu2.MMULastErrorSource() == MMU2::ErrorSourcePrinter && btn != Buttons::NoButton)
{
if (mmu2.MMULastErrorSource() == ErrorSourcePrinter && btn != Buttons::NoButton) {
// When the printer has raised an error screen, and a button was selected
// the error screen should always be dismissed.
ClearPrinterError();
@ -720,7 +745,7 @@ void MMU2::CheckUserInput() {
SERIAL_ECHOLN((int)buttons_to_uint8t(btn));
ResumeHotendTemp(); // Recover the hotend temp before we attempt to do anything else...
if (mmu2.MMULastErrorSource() == MMU2::ErrorSourceMMU) {
if (mmu2.MMULastErrorSource() == ErrorSourceMMU) {
// Do not send a button to the MMU unless the MMU is in error state
Button(buttons_to_uint8t(btn));
}
@ -782,6 +807,7 @@ bool MMU2::manage_response(const bool move_axes, const bool turn_off_nozzle) {
// - failed -> then do the safety moves on the printer like before
// - finished ok -> proceed with reading other commands
safe_delay_keep_alive(0); // calls LogicStep() and remembers its return status
// also disables stepper motor unlocking
if (mmu_print_saved & SavedState::CooldownPending) {
if (!nozzleTimeout.running()) {
@ -803,9 +829,8 @@ bool MMU2::manage_response(const bool move_axes, const bool turn_off_nozzle) {
// command/operation completed, let Marlin continue its work
// the E may have some more moves to finish - wait for them
ResumeHotendTemp();
ResumeUnpark(); // We can now travel back to the tower or wherever we were when we saved.
if (!TuneMenuEntered())
{
ResumeUnpark(); // We can now travel back to the tower or wherever we were when we saved.
if (!TuneMenuEntered()) {
// If the error screen is sleeping (running 'Tune' menu)
// then don't reset retry attempts because we this will trigger
// an automatic retry attempt when 'Tune' button is selected. We want the
@ -920,15 +945,19 @@ void MMU2::filament_ramming() {
execute_extruder_sequence(ramming_sequence, sizeof(ramming_sequence) / sizeof(E_Step));
}
void MMU2::execute_extruder_sequence(const E_Step *sequence, uint8_t steps) {
void MMU2::execute_extruder_sequence(const E_Step *sequence, uint8_t stepCount) {
planner_synchronize();
// Plan the moves
const E_Step *step = sequence;
for (uint8_t i = steps; i > 0; --i) {
for (uint8_t i = stepCount; i > 0; --i) {
extruder_move(pgm_read_float(&(step->extrude)), pgm_read_float(&(step->feedRate)));
step++;
}
planner_synchronize(); // it looks like it's better to sync the moves at the end - smoother move (if the sequence is not too long).
// Wait for the moves to finish
// it looks like it's better to sync the moves at the end - smoother move (if the sequence is not too long).
planner_synchronize();
Disable_E0();
}
@ -1031,7 +1060,7 @@ void MMU2::OnMMUProgressMsgChanged(ProgressCode pc) {
switch (pc) {
case ProgressCode::UnloadingToFinda:
if ((CommandInProgress)logic.CommandInProgress() == CommandInProgress::UnloadFilament
|| ((CommandInProgress)logic.CommandInProgress() == CommandInProgress::ToolChange)) {
|| ((CommandInProgress)logic.CommandInProgress() == CommandInProgress::ToolChange)) {
// If MK3S sent U0 command, ramming sequence takes care of releasing the filament.
// If Toolchange is done while printing, PrusaSlicer takes care of releasing the filament
// If printing is not in progress, ToolChange will issue a U0 command.
@ -1079,14 +1108,10 @@ void MMU2::OnMMUProgressMsgSame(ProgressCode pc) {
case FilamentState::AT_FSENSOR:
// fsensor triggered, finish FeedingToExtruder state
loadFilamentStarted = false;
// Abort any excess E-move from the planner queue
planner_abort_queued_moves();
// After the MMU knows the FSENSOR is triggered it will:
// 1. Push the filament by additional 30mm (see fsensorToNozzle)
// 2. Disengage the idler and push another 2mm.
extruder_move(logic.ExtraLoadDistance() + 2, logic.PulleySlowFeedRate());
{
extruder_move(logic.ExtraLoadDistance() + 2, logic.PulleySlowFeedRate());
}
break;
case FilamentState::NOT_PRESENT:
// fsensor not triggered, continue moving extruder

View File

@ -11,6 +11,7 @@ typedef float feedRate_t;
#else
#include "protocol_logic.h"
#include <atomic>
#include <memory>
#endif
struct E_Step;
@ -32,6 +33,7 @@ struct Version {
class MMU2 {
public:
MMU2();
~MMU2();
/// Powers ON the MMU, then initializes the UART and protocol logic
void Start();
@ -48,17 +50,17 @@ public:
/// Different levels of resetting the MMU
enum ResetForm : uint8_t {
Software = 0, ///< sends a X0 command into the MMU, the MMU will watchdog-reset itself
ResetPin = 1, ///< trigger the reset pin of the MMU
CutThePower = 2, ///< power off and power on (that includes +5V and +24V power lines)
Software = 0, ///< sends a X0 command into the MMU, the MMU will watchdog-reset itself
ResetPin = 1, ///< trigger the reset pin of the MMU
CutThePower = 2, ///< power off and power on (that includes +5V and +24V power lines)
EraseEEPROM = 42, ///< erase MMU EEPROM and then perform a software reset
};
/// Saved print state on error.
enum SavedState : uint8_t {
None = 0, // No state saved.
None = 0, // No state saved.
ParkExtruder = 1, // The extruder was parked.
Cooldown = 2, // The extruder was allowed to cool.
Cooldown = 2, // The extruder was allowed to cool.
CooldownPending = 4,
};
@ -207,9 +209,9 @@ public:
};
inline void InvokeErrorScreen(ErrorCode ec) {
// The printer may not raise an error when the MMU is busy
if (!logic.CommandInProgress() // MMU must not be busy
if (!logic.CommandInProgress() // MMU must not be busy
&& MMUCurrentErrorCode() == ErrorCode::OK // The protocol must not be in error state
&& lastErrorCode != ec) // The error code is not a duplicate
&& lastErrorCode != ec) // The error code is not a duplicate
{
ReportError(ec, ErrorSource::ErrorSourcePrinter);
}
@ -273,7 +275,9 @@ private:
StepStatus LogicStep(bool reportErrors);
void filament_ramming();
void execute_extruder_sequence(const E_Step *sequence, uint8_t steps);
void execute_extruder_sequence(const E_Step *sequence, uint8_t stepCount);
void execute_load_to_nozzle_sequence();
/// Reports an error into attached ExtUIs
@ -342,8 +346,9 @@ private:
void SetCurrentTool(uint8_t ex);
ProtocolLogic logic; ///< implementation of the protocol logic layer
uint8_t extruder; ///< currently active slot in the MMU ... somewhat... not sure where to get it from yet
ProtocolLogic logic; ///< implementation of the protocol logic layer
uint8_t extruder; ///< currently active slot in the MMU ... somewhat... not sure where to get it from yet
uint8_t tool_change_extruder; ///< only used for UI purposes
pos3d resume_position;

View File

@ -1,6 +1,6 @@
#!/bin/bash
# download Prusa Error Codes for MMU
# download Prusa Error Codes for MMU
#wget https://raw.githubusercontent.com/3d-gussner/Prusa-Error-Codes/master/04_MMU/error-codes.yaml --output-document=error-codes.yaml
wget https://raw.githubusercontent.com/prusa3d/Prusa-Error-Codes/master/04_MMU/error-codes.yaml --output-document=error-codes.yaml

View File

@ -124,10 +124,10 @@ static const constexpr uint16_t errorCodes[] PROGMEM = {
ERR_ELECTRICAL_MMU_MCU_ERROR,
ERR_CONNECT_MMU_NOT_RESPONDING,
ERR_CONNECT_COMMUNICATION_ERROR,
ERR_SYSTEM_FILAMENT_ALREADY_LOADED,
ERR_SYSTEM_INVALID_TOOL,
ERR_SYSTEM_QUEUE_FULL,
ERR_SYSTEM_FW_UPDATE_NEEDED,
ERR_SYSTEM_FILAMENT_ALREADY_LOADED,
ERR_SYSTEM_INVALID_TOOL,
ERR_SYSTEM_QUEUE_FULL,
ERR_SYSTEM_FW_UPDATE_NEEDED,
ERR_SYSTEM_FW_RUNTIME_ERROR,
ERR_SYSTEM_UNLOAD_MANUALLY,
ERR_SYSTEM_FILAMENT_EJECTED,
@ -287,7 +287,7 @@ static const char MSG_DESC_FILAMENT_CHANGE[] PROGMEM_I1 = ISTR("M600 Filament Ch
static const char MSG_DESC_UNKNOWN_ERROR[] PROGMEM_I1 = ISTR("Unexpected error occurred."); ////MSG_DESC_UNKNOWN_ERROR c=20 r=8
// Read explanation in mmu2_protocol_logic.cpp -> supportedMmuFWVersion
static constexpr char MSG_DESC_FW_UPDATE_NEEDED[] PROGMEM_I1 = ISTR("MMU FW version is incompatible with printer FW.Update to version 3.0.2."); ////MSG_DESC_FW_UPDATE_NEEDED c=20 r=8
static constexpr char MSG_DESC_FW_UPDATE_NEEDED[] PROGMEM_I1 = ISTR("MMU FW version is incompatible with printer FW.Update to version 3.0.3."); ////MSG_DESC_FW_UPDATE_NEEDED c=20 r=8
static constexpr uint8_t szFWUN = sizeof(MSG_DESC_FW_UPDATE_NEEDED);
// at least check the individual version characters in MSG_DESC_FW_UPDATE_NEEDED
static_assert(MSG_DESC_FW_UPDATE_NEEDED[szFWUN - 7] == ('0' + mmuVersionMajor));
@ -355,7 +355,7 @@ static const char MSG_BTN_RETRY[] PROGMEM_I1 = ISTR("Retry"); ////MSG_BTN_RETRY
static const char MSG_BTN_RESET_MMU[] PROGMEM_I1 = ISTR("ResetMMU"); ////MSG_BTN_RESET_MMU c=8
static const char MSG_BTN_UNLOAD[] PROGMEM_I1 = ISTR("Unload"); ////MSG_BTN_UNLOAD c=8
static const char MSG_BTN_LOAD[] PROGMEM_I1 = ISTR("Load"); ////MSG_BTN_LOAD c=8
static const char MSG_BTN_EJECT[] PROGMEM_I1 = ISTR("Eject"); ////MSG_BTN_EJECT c=8
//static const char MSG_BTN_EJECT[] PROGMEM_I1 = ISTR("Eject"); //Reuse MSG_EJECT c=9
//static const char MSG_BTN_TUNE_MMU[] PROGMEM_I1 = ISTR("Tune"); //Reuse MSG_TUNE c=8
static const char MSG_BTN_STOP[] PROGMEM_I1 = ISTR("Stop"); ////MSG_BTN_STOP c=8
static const char MSG_BTN_DISABLE_MMU[] PROGMEM_I1 = ISTR("Disable"); ////MSG_BTN_DISABLE_MMU c=8
@ -368,7 +368,7 @@ static const char * const btnOperation[] PROGMEM = {
_R(MSG_BTN_RESET_MMU),
_R(MSG_BTN_UNLOAD),
_R(MSG_BTN_LOAD),
_R(MSG_BTN_EJECT),
_R(MSG_EJECT),
_R(MSG_TUNE),
_R(MSG_BTN_STOP),
_R(MSG_BTN_DISABLE_MMU),

View File

@ -29,17 +29,17 @@ static constexpr uint8_t FindErrorIndex(uint16_t pec) {
return (i != errorCodesEnd) ? (i-errorCodes) : (errorCodesSize - 1);
}
// check that the searching algoritm works
static_assert( FindErrorIndex(ERR_MECHANICAL_FINDA_DIDNT_TRIGGER) == 0);
static_assert( FindErrorIndex(ERR_MECHANICAL_FINDA_FILAMENT_STUCK) == 1);
static_assert( FindErrorIndex(ERR_MECHANICAL_FSENSOR_DIDNT_TRIGGER) == 2);
static_assert( FindErrorIndex(ERR_MECHANICAL_FSENSOR_FILAMENT_STUCK) == 3);
// check that the searching algorithm works
static_assert(FindErrorIndex(ERR_MECHANICAL_FINDA_DIDNT_TRIGGER) == 0);
static_assert(FindErrorIndex(ERR_MECHANICAL_FINDA_FILAMENT_STUCK) == 1);
static_assert(FindErrorIndex(ERR_MECHANICAL_FSENSOR_DIDNT_TRIGGER) == 2);
static_assert(FindErrorIndex(ERR_MECHANICAL_FSENSOR_FILAMENT_STUCK) == 3);
constexpr ErrorCode operator&(ErrorCode a, ErrorCode b){
constexpr ErrorCode operator&(ErrorCode a, ErrorCode b) {
return (ErrorCode)((uint16_t)a & (uint16_t)b);
}
constexpr bool ContainsBit(ErrorCode ec, ErrorCode mask){
constexpr bool ContainsBit(ErrorCode ec, ErrorCode mask) {
return (uint16_t)ec & (uint16_t)mask;
}
@ -67,17 +67,17 @@ uint8_t PrusaErrorCodeIndex(ErrorCode ec) {
case ErrorCode::STALLED_PULLEY:
case ErrorCode::MOVE_PULLEY_FAILED:
return FindErrorIndex(ERR_MECHANICAL_PULLEY_CANNOT_MOVE);
case ErrorCode::HOMING_SELECTOR_FAILED:
return FindErrorIndex(ERR_MECHANICAL_SELECTOR_CANNOT_HOME);
case ErrorCode::MOVE_SELECTOR_FAILED:
return FindErrorIndex(ERR_MECHANICAL_SELECTOR_CANNOT_MOVE);
case ErrorCode::HOMING_IDLER_FAILED:
return FindErrorIndex(ERR_MECHANICAL_IDLER_CANNOT_HOME);
case ErrorCode::MOVE_IDLER_FAILED:
return FindErrorIndex(ERR_MECHANICAL_IDLER_CANNOT_MOVE);
case ErrorCode::MMU_NOT_RESPONDING:
return FindErrorIndex(ERR_CONNECT_MMU_NOT_RESPONDING);
case ErrorCode::PROTOCOL_ERROR:
@ -96,93 +96,115 @@ uint8_t PrusaErrorCodeIndex(ErrorCode ec) {
return FindErrorIndex(ERR_SYSTEM_UNLOAD_MANUALLY);
case ErrorCode::MCU_UNDERVOLTAGE_VCC:
return FindErrorIndex(ERR_ELECTRICAL_MMU_MCU_ERROR);
default: break;
default:
break;
}
// Electrical issues which can be detected somehow.
// Need to be placed before TMC-related errors in order to process couples of error bits between single ones
// and to keep the code size down.
if (ContainsBit(ec, ErrorCode::TMC_PULLEY_BIT)) {
if ((ec & ErrorCode::MMU_SOLDERING_NEEDS_ATTENTION) == ErrorCode::MMU_SOLDERING_NEEDS_ATTENTION)
if ((ec & ErrorCode::MMU_SOLDERING_NEEDS_ATTENTION) == ErrorCode::MMU_SOLDERING_NEEDS_ATTENTION) {
return FindErrorIndex(ERR_ELECTRICAL_MMU_PULLEY_SELFTEST_FAILED);
}
} else if (ContainsBit(ec, ErrorCode::TMC_SELECTOR_BIT)) {
if ((ec & ErrorCode::MMU_SOLDERING_NEEDS_ATTENTION) == ErrorCode::MMU_SOLDERING_NEEDS_ATTENTION)
if ((ec & ErrorCode::MMU_SOLDERING_NEEDS_ATTENTION) == ErrorCode::MMU_SOLDERING_NEEDS_ATTENTION) {
return FindErrorIndex(ERR_ELECTRICAL_MMU_SELECTOR_SELFTEST_FAILED);
}
} else if (ContainsBit(ec, ErrorCode::TMC_IDLER_BIT)) {
if ((ec & ErrorCode::MMU_SOLDERING_NEEDS_ATTENTION) == ErrorCode::MMU_SOLDERING_NEEDS_ATTENTION)
if ((ec & ErrorCode::MMU_SOLDERING_NEEDS_ATTENTION) == ErrorCode::MMU_SOLDERING_NEEDS_ATTENTION) {
return FindErrorIndex(ERR_ELECTRICAL_MMU_IDLER_SELFTEST_FAILED);
}
}
// TMC-related errors - multiple of these can occur at once
// - in such a case we report the first which gets found/converted into Prusa-Error-Codes (usually the fact, that one TMC has an issue is serious enough)
// By carefully ordering the checks here we can prioritize the errors being reported to the user.
if (ContainsBit(ec, ErrorCode::TMC_PULLEY_BIT)) {
if (ContainsBit(ec, ErrorCode::TMC_IOIN_MISMATCH))
if (ContainsBit(ec, ErrorCode::TMC_IOIN_MISMATCH)) {
return FindErrorIndex(ERR_ELECTRICAL_TMC_PULLEY_DRIVER_ERROR);
if (ContainsBit(ec, ErrorCode::TMC_RESET))
}
if (ContainsBit(ec, ErrorCode::TMC_RESET)) {
return FindErrorIndex(ERR_ELECTRICAL_TMC_PULLEY_DRIVER_RESET);
if (ContainsBit(ec, ErrorCode::TMC_UNDERVOLTAGE_ON_CHARGE_PUMP))
}
if (ContainsBit(ec, ErrorCode::TMC_UNDERVOLTAGE_ON_CHARGE_PUMP)) {
return FindErrorIndex(ERR_ELECTRICAL_TMC_PULLEY_UNDERVOLTAGE_ERROR);
if (ContainsBit(ec, ErrorCode::TMC_SHORT_TO_GROUND))
}
if (ContainsBit(ec, ErrorCode::TMC_SHORT_TO_GROUND)) {
return FindErrorIndex(ERR_ELECTRICAL_TMC_PULLEY_DRIVER_SHORTED);
if (ContainsBit(ec, ErrorCode::TMC_OVER_TEMPERATURE_WARN))
}
if (ContainsBit(ec, ErrorCode::TMC_OVER_TEMPERATURE_WARN)) {
return FindErrorIndex(ERR_TEMPERATURE_WARNING_TMC_PULLEY_TOO_HOT);
if (ContainsBit(ec, ErrorCode::TMC_OVER_TEMPERATURE_ERROR))
}
if (ContainsBit(ec, ErrorCode::TMC_OVER_TEMPERATURE_ERROR)) {
return FindErrorIndex(ERR_TEMPERATURE_TMC_PULLEY_OVERHEAT_ERROR);
}
} else if (ContainsBit(ec, ErrorCode::TMC_SELECTOR_BIT)) {
if (ContainsBit(ec, ErrorCode::TMC_IOIN_MISMATCH))
if (ContainsBit(ec, ErrorCode::TMC_IOIN_MISMATCH)) {
return FindErrorIndex(ERR_ELECTRICAL_TMC_SELECTOR_DRIVER_ERROR);
if (ContainsBit(ec, ErrorCode::TMC_RESET))
}
if (ContainsBit(ec, ErrorCode::TMC_RESET)) {
return FindErrorIndex(ERR_ELECTRICAL_TMC_SELECTOR_DRIVER_RESET);
if (ContainsBit(ec, ErrorCode::TMC_UNDERVOLTAGE_ON_CHARGE_PUMP))
}
if (ContainsBit(ec, ErrorCode::TMC_UNDERVOLTAGE_ON_CHARGE_PUMP)) {
return FindErrorIndex(ERR_ELECTRICAL_TMC_SELECTOR_UNDERVOLTAGE_ERROR);
if (ContainsBit(ec, ErrorCode::TMC_SHORT_TO_GROUND))
}
if (ContainsBit(ec, ErrorCode::TMC_SHORT_TO_GROUND)) {
return FindErrorIndex(ERR_ELECTRICAL_TMC_SELECTOR_DRIVER_SHORTED);
if (ContainsBit(ec, ErrorCode::TMC_OVER_TEMPERATURE_WARN))
}
if (ContainsBit(ec, ErrorCode::TMC_OVER_TEMPERATURE_WARN)) {
return FindErrorIndex(ERR_TEMPERATURE_WARNING_TMC_SELECTOR_TOO_HOT);
if (ContainsBit(ec, ErrorCode::TMC_OVER_TEMPERATURE_ERROR))
}
if (ContainsBit(ec, ErrorCode::TMC_OVER_TEMPERATURE_ERROR)) {
return FindErrorIndex(ERR_TEMPERATURE_TMC_SELECTOR_OVERHEAT_ERROR);
}
} else if (ContainsBit(ec, ErrorCode::TMC_IDLER_BIT)) {
if (ContainsBit(ec, ErrorCode::TMC_IOIN_MISMATCH))
if (ContainsBit(ec, ErrorCode::TMC_IOIN_MISMATCH)) {
return FindErrorIndex(ERR_ELECTRICAL_TMC_IDLER_DRIVER_ERROR);
if (ContainsBit(ec, ErrorCode::TMC_RESET))
}
if (ContainsBit(ec, ErrorCode::TMC_RESET)) {
return FindErrorIndex(ERR_ELECTRICAL_TMC_IDLER_DRIVER_RESET);
if (ContainsBit(ec, ErrorCode::TMC_UNDERVOLTAGE_ON_CHARGE_PUMP))
}
if (ContainsBit(ec, ErrorCode::TMC_UNDERVOLTAGE_ON_CHARGE_PUMP)) {
return FindErrorIndex(ERR_ELECTRICAL_TMC_IDLER_UNDERVOLTAGE_ERROR);
if (ContainsBit(ec, ErrorCode::TMC_SHORT_TO_GROUND))
}
if (ContainsBit(ec, ErrorCode::TMC_SHORT_TO_GROUND)) {
return FindErrorIndex(ERR_ELECTRICAL_TMC_IDLER_DRIVER_SHORTED);
if (ContainsBit(ec, ErrorCode::TMC_OVER_TEMPERATURE_WARN))
}
if (ContainsBit(ec, ErrorCode::TMC_OVER_TEMPERATURE_WARN)) {
return FindErrorIndex(ERR_TEMPERATURE_WARNING_TMC_IDLER_TOO_HOT);
if (ContainsBit(ec, ErrorCode::TMC_OVER_TEMPERATURE_ERROR))
}
if (ContainsBit(ec, ErrorCode::TMC_OVER_TEMPERATURE_ERROR)) {
return FindErrorIndex(ERR_TEMPERATURE_TMC_IDLER_OVERHEAT_ERROR);
}
}
// if nothing got caught, return a generic runtime error
// if nothing got caught, return a generic error
return FindErrorIndex(ERR_OTHER_UNKNOWN_ERROR);
}
uint16_t PrusaErrorCode(uint8_t i){
uint16_t PrusaErrorCode(uint8_t i) {
return pgm_read_word(errorCodes + i);
}
const char * PrusaErrorTitle(uint8_t i){
const char *PrusaErrorTitle(uint8_t i) {
return (const char *)pgm_read_ptr(errorTitles + i);
}
const char * PrusaErrorDesc(uint8_t i){
const char *PrusaErrorDesc(uint8_t i) {
return (const char *)pgm_read_ptr(errorDescs + i);
}
uint8_t PrusaErrorButtons(uint8_t i){
uint8_t PrusaErrorButtons(uint8_t i) {
return pgm_read_byte(errorButtons + i);
}
const char * PrusaErrorButtonTitle(uint8_t bi){
const char *PrusaErrorButtonTitle(uint8_t bi) {
// -1 represents the hidden NoOperation button which is not drawn in any way
return (const char *)pgm_read_ptr(btnOperation + bi - 1);
}
const char * PrusaErrorButtonMore(){
const char *PrusaErrorButtonMore() {
return MSG_BTN_MORE;
}
@ -193,13 +215,12 @@ Buttons ButtonPressed(ErrorCode ec) {
const auto result = ButtonAvailable(ec);
buttonSelectedOperation = ButtonOperations::NoOperation; // Reset operation
return result;
}
Buttons ButtonAvailable(ErrorCode ec) {
uint8_t ei = PrusaErrorCodeIndex(ec);
// The list of responses which occur in mmu error dialogs
// Return button index or perform some action on the MK3 by itself (like Reset MMU)
// Based on Prusa-Error-Codes errors_list.h
@ -266,23 +287,23 @@ Buttons ButtonAvailable(ErrorCode ec) {
break;
}
break;
case ERR_TEMPERATURE_TMC_PULLEY_OVERHEAT_ERROR:
case ERR_TEMPERATURE_TMC_SELECTOR_OVERHEAT_ERROR:
case ERR_TEMPERATURE_TMC_IDLER_OVERHEAT_ERROR:
case ERR_ELECTRICAL_TMC_PULLEY_DRIVER_ERROR:
case ERR_ELECTRICAL_TMC_SELECTOR_DRIVER_ERROR:
case ERR_ELECTRICAL_TMC_IDLER_DRIVER_ERROR:
case ERR_ELECTRICAL_TMC_PULLEY_DRIVER_RESET:
case ERR_ELECTRICAL_TMC_SELECTOR_DRIVER_RESET:
case ERR_ELECTRICAL_TMC_IDLER_DRIVER_RESET:
case ERR_ELECTRICAL_TMC_PULLEY_UNDERVOLTAGE_ERROR:
case ERR_ELECTRICAL_TMC_SELECTOR_UNDERVOLTAGE_ERROR:
case ERR_ELECTRICAL_TMC_IDLER_UNDERVOLTAGE_ERROR:
case ERR_ELECTRICAL_TMC_PULLEY_DRIVER_SHORTED:
case ERR_ELECTRICAL_TMC_SELECTOR_DRIVER_SHORTED:
case ERR_ELECTRICAL_TMC_IDLER_DRIVER_SHORTED:
@ -323,7 +344,7 @@ Buttons ButtonAvailable(ErrorCode ec) {
break;
}
break;
case ERR_SYSTEM_INVALID_TOOL:
switch (buttonSelectedOperation) {
case ButtonOperations::StopPrint: // "Stop print"
@ -338,11 +359,11 @@ Buttons ButtonAvailable(ErrorCode ec) {
default:
break;
}
return Buttons::NoButton;
}
void SetButtonResponse(ButtonOperations rsp){
void SetButtonResponse(ButtonOperations rsp) {
buttonSelectedOperation = rsp;
}

View File

@ -6,7 +6,7 @@
#include "mmu2/error_codes.h"
#else
#include "buttons.h"
#include "../../../../../../Prusa-Error-Codes/04_MMU/button_operations.h"
#include "../../../../../../Prusa-Error-Codes/include/button_operations.h"
#include "../../../../../../Prusa-Firmware-MMU/src/logic/error_codes.h"
#endif

View File

@ -55,7 +55,7 @@ void LogEchoEvent_P(const char *msg_P);
} while (0)
#define MMU2_ERROR_MSG(S) MMU2_ECHO_MSG(S) //!@todo Decide MMU errors on serial line
#else // #ifndef UNITTEST
#else // #ifndef UNITTEST
#include "stubs/stub_interfaces.h"
#define MMU2_ECHO_MSGLN(S) marlinLogSim.AppendLine(S)
#define MMU2_ERROR_MSGLN(S) marlinLogSim.AppendLine(S)
@ -65,4 +65,4 @@ void LogEchoEvent_P(const char *msg_P);
#define SERIAL_ECHOPGM(S) /* */
#define SERIAL_ECHOLN(S) /*marlinLogSim.AppendLine(S)*/
#endif // #ifndef UNITTEST
#endif // #ifndef UNITTEST

View File

@ -28,6 +28,7 @@ void extruder_schedule_turning(float feed_rate);
float move_raise_z(float delta);
void planner_abort_queued_moves();
bool planner_draining();
void planner_synchronize();
bool planner_any_moves();
float stepper_get_machine_position_E_mm();
@ -42,8 +43,8 @@ void nozzle_park();
bool marlin_printingIsActive();
void marlin_manage_heater();
void marlin_manage_inactivity(bool b);
void marlin_idle(bool b);
void marlin_manage_inactivity(bool ignore_stepper_queue);
void marlin_idle(bool ignore_stepper_queue);
void marlin_refresh_print_state_in_ram();
void marlin_clear_print_state_in_ram();
void marlin_stop_and_save_print_to_ram();

View File

@ -38,6 +38,10 @@ void planner_abort_queued_moves() {
planner_aborted = false;
}
bool planner_draining() {
return planner_aborted;
}
void planner_synchronize() {
st_synchronize();
}
@ -46,33 +50,33 @@ bool planner_any_moves() {
return blocks_queued();
}
float planner_get_machine_position_E_mm(){
float planner_get_machine_position_E_mm() {
return current_position[E_AXIS];
}
float stepper_get_machine_position_E_mm(){
float stepper_get_machine_position_E_mm() {
return st_get_position_mm(E_AXIS);
}
float planner_get_current_position_E(){
float planner_get_current_position_E() {
return current_position[E_AXIS];
}
void planner_set_current_position_E(float e){
void planner_set_current_position_E(float e) {
current_position[E_AXIS] = e;
}
pos3d planner_current_position(){
pos3d planner_current_position() {
return pos3d(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS]);
}
void motion_do_blocking_move_to_xy(float rx, float ry, float feedRate_mm_s){
void motion_do_blocking_move_to_xy(float rx, float ry, float feedRate_mm_s) {
current_position[X_AXIS] = rx;
current_position[Y_AXIS] = ry;
planner_line_to_current_position_sync(feedRate_mm_s);
}
void motion_do_blocking_move_to_z(float z, float feedRate_mm_s){
void motion_do_blocking_move_to_z(float z, float feedRate_mm_s) {
current_position[Z_AXIS] = z;
planner_line_to_current_position_sync(feedRate_mm_s);
}
@ -84,32 +88,31 @@ void nozzle_park() {
}
bool marlin_printingIsActive() {
// return IS_SD_PRINTING || usb_timer_running();
return printer_active();
}
void marlin_manage_heater(){
void marlin_manage_heater() {
manage_heater();
}
void marlin_manage_inactivity(bool b){
manage_inactivity(b);
void marlin_manage_inactivity(bool ignore_stepper_queue) {
manage_inactivity(ignore_stepper_queue);
}
void marlin_idle(bool b){
void marlin_idle(bool ignore_stepper_queue) {
manage_heater();
manage_inactivity(b);
manage_inactivity(ignore_stepper_queue);
}
void marlin_refresh_print_state_in_ram(){
void marlin_refresh_print_state_in_ram() {
refresh_print_state_in_ram();
}
void marlin_clear_print_state_in_ram(){
void marlin_clear_print_state_in_ram() {
clear_print_state_in_ram();
}
void marlin_stop_and_save_print_to_ram(){
void marlin_stop_and_save_print_to_ram() {
stop_and_save_print_to_ram(0,0);
}
@ -133,10 +136,15 @@ void safe_delay_keep_alive(uint16_t t) {
delay_keep_alive(t);
}
void Enable_E0(){ enable_e0(); }
void Disable_E0(){ disable_e0(); }
void Enable_E0() {
enable_e0();
}
bool all_axes_homed(){
void Disable_E0() {
disable_e0();
}
bool all_axes_homed() {
return axis_known_position[X_AXIS] && axis_known_position[Y_AXIS];
}

View File

@ -30,7 +30,7 @@ static const char MSG_PROGRESS_HOMING[] PROGMEM_I1 = ISTR("Homing"); /
static const char MSG_PROGRESS_MOVING_SELECTOR[] PROGMEM_I1 = ISTR("Moving selector"); ////MSG_PROGRESS_MOVING_SELECTOR c=20
static const char MSG_PROGRESS_FEED_FSENSOR[] PROGMEM_I1 = ISTR("Feeding to FSensor"); ////MSG_PROGRESS_FEED_FSENSOR c=20
static const char * const progressTexts[] PROGMEM = {
static const char *const progressTexts[] PROGMEM = {
_R(MSG_PROGRESS_OK),
_R(MSG_PROGRESS_ENGAGE_IDLER),
_R(MSG_PROGRESS_DISENGAGE_IDLER),
@ -62,11 +62,11 @@ static const char * const progressTexts[] PROGMEM = {
_R(MSG_PROGRESS_FEED_FSENSOR)
};
const char * ProgressCodeToText(ProgressCode pc){
const char *ProgressCodeToText(ProgressCode pc) {
// @@TODO ?? a better fallback option?
return ( (uint16_t)pc <= (sizeof(progressTexts) / sizeof(progressTexts[0])) )
? static_cast<const char *>(pgm_read_ptr(&progressTexts[(uint16_t)pc]))
: static_cast<const char *>(pgm_read_ptr(&progressTexts[0]));
return ((uint16_t)pc <= (sizeof(progressTexts) / sizeof(progressTexts[0])))
? static_cast<const char *>(pgm_read_ptr(&progressTexts[(uint16_t)pc]))
: static_cast<const char *>(pgm_read_ptr(&progressTexts[0]));
}
} // namespace MMU2

View File

@ -1,4 +1,4 @@
/// @file
/// @file mmu2_protocol.cpp
#include "mmu2_protocol.h"
// protocol definition
@ -112,11 +112,8 @@ DecodeStatus Protocol::DecodeRequest(uint8_t c) {
rqState = RequestStates::Code;
return DecodeStatus::MessageCompleted;
}
} else {
requestMsg.code = RequestMsgCodes::unknown;
rqState = RequestStates::Error;
return DecodeStatus::Error;
}
[[fallthrough]];
default: //case error:
if (IsNewLine(c)) {
rqState = RequestStates::Code;

View File

@ -1,4 +1,4 @@
/// @file protocol.h
/// @file mmu2_protocol.h
#pragma once
#include <stdint.h>
#include "mmu2_crc.h"
@ -8,6 +8,7 @@ namespace modules {
/// @brief The MMU communication protocol implementation and related stuff.
///
/// See description of the new protocol in the MMU 2021 doc
namespace protocol {
/// Definition of request message codes
@ -179,17 +180,9 @@ public:
/// @returns number of bytes written into txbuff
static uint8_t EncodeResponseReadFINDA(const RequestMsg &msg, uint8_t findaValue, uint8_t *txbuff);
/// Encode response to Query operation status
/// @param msg source request message for this response
/// @param code status of operation (Processing, Error, Finished)
/// @param value related to status of operation(e.g. error code or progress)
/// @param rcs status of operation (Processing, Error, Finished)
/// @param txbuff where to format the message
/// @returns number of bytes written into txbuff
static uint8_t EncodeResponseQueryOperation(const RequestMsg &msg, ResponseCommandStatus rcs, uint8_t *txbuff);

View File

@ -6,7 +6,7 @@
// on MK3/S/+ we shuffle the timers a bit, thus "_millis" may not equal "millis"
#include "system_timer.h"
#else
// irrelevant on Buddy FW, just keep "_millis" as "millis"
// irrelevant on Buddy FW, just keep "_millis" as "millis"
#include <wiring_time.h>
#define _millis millis
#ifdef UNITTEST
@ -32,18 +32,18 @@ namespace MMU2 {
static constexpr uint8_t supportedMmuFWVersion[3] PROGMEM = { mmuVersionMajor, mmuVersionMinor, mmuVersionPatch };
const Register ProtocolLogic::regs8Addrs[ProtocolLogic::regs8Count] PROGMEM = {
Register::FINDA_State, // FINDA state
Register::FINDA_State, // FINDA state
Register::Set_Get_Selector_Slot, // Selector slot
Register::Set_Get_Idler_Slot, // Idler slot
Register::Set_Get_Idler_Slot, // Idler slot
};
const Register ProtocolLogic::regs16Addrs[ProtocolLogic::regs16Count] PROGMEM = {
Register::MMU_Errors, // MMU errors - aka statistics
Register::MMU_Errors, // MMU errors - aka statistics
Register::Get_Pulley_Position, // Pulley position [mm]
};
const Register ProtocolLogic::initRegs8Addrs[ProtocolLogic::initRegs8Count] PROGMEM = {
Register::Extra_Load_Distance, // extra load distance [mm]
Register::Extra_Load_Distance, // extra load distance [mm]
Register::Pulley_Slow_Feedrate, // pulley slow feedrate [mm/s]
};
@ -186,7 +186,7 @@ StepStatus ProtocolLogic::ExpectingMessage() {
break;
}
}
[[fallthrough]]; // otherwise
[[fallthrough]]; // otherwise
default:
RecordUARTActivity(); // something has happened on the UART, update the timeout record
return ProtocolError;
@ -194,7 +194,7 @@ StepStatus ProtocolLogic::ExpectingMessage() {
}
if (bytesConsumed != 0) {
RecordUARTActivity(); // something has happened on the UART, update the timeout record
return Processing; // consumed some bytes, but message still not ready
return Processing; // consumed some bytes, but message still not ready
} else if (Elapsed(linkLayerTimeout) && currentScope != Scope::Stopped) {
return CommunicationTimeout;
}
@ -267,6 +267,8 @@ StepStatus ProtocolLogic::ScopeStep() {
if (!ExpectsResponse()) {
// we are waiting for something
switch (currentScope) {
case Scope::StartSeq:
return Processing;
case Scope::DelayedRestart:
return DelayedRestartWait();
case Scope::Idle:
@ -280,17 +282,18 @@ StepStatus ProtocolLogic::ScopeStep() {
}
} else {
// we are expecting a message
if (auto expmsg = ExpectingMessage(); expmsg != MessageReady) // this whole statement takes 12B
if (auto expmsg = ExpectingMessage(); expmsg != MessageReady) { // this whole statement takes 12B
return expmsg;
}
// process message
switch (currentScope) {
case Scope::StartSeq:
return StartSeqStep(); // ~270B
case Scope::Idle:
return IdleStep(); // ~300B
return IdleStep(); // ~300B
case Scope::Command:
return CommandStep(); // ~430B
return CommandStep(); // ~430B
case Scope::Stopped:
return StoppedStep();
default:
@ -335,7 +338,7 @@ StepStatus ProtocolLogic::StartSeqStep() {
StepStatus ProtocolLogic::DelayedRestartWait() {
if (Elapsed(heartBeatPeriod)) { // this basically means, that we are waiting until there is some traffic on
while (uart->read() != -1)
; // clear the input buffer
; // clear the input buffer
// switch to StartSeq
Start();
}
@ -723,12 +726,13 @@ void ProtocolLogic::FormatLastResponseMsgAndClearLRB(char *dst) {
for (uint8_t i = 0; i < lrb; ++i) {
uint8_t b = lastReceivedBytes[i];
// Check for printable character, including space
if (b < 32 || b > 127)
if (b < 32 || b > 127) {
b = '.';
}
*dst++ = b;
}
*dst = 0; // terminate properly
lrb = 0; // reset the input buffer index in case of a clean message
lrb = 0; // reset the input buffer index in case of a clean message
}
void ProtocolLogic::LogRequestMsg(const uint8_t *txbuff, uint8_t size) {
@ -738,8 +742,9 @@ void ProtocolLogic::LogRequestMsg(const uint8_t *txbuff, uint8_t size) {
for (uint8_t i = 0; i < size; ++i) {
uint8_t b = txbuff[i];
// Check for printable character, including space
if (b < 32 || b > 127)
if (b < 32 || b > 127) {
b = '.';
}
tmp[i + 1] = b;
}
tmp[size + 1] = 0;
@ -809,7 +814,7 @@ StepStatus ProtocolLogic::Step() {
// We are ok, switching to Idle if there is no potential next request planned.
// But the trouble is we must report a finished command if the previous command has just been finished
// i.e. only try to find some planned command if we just finished the Idle cycle
if (!ActivatePlannedRequest()) { // if nothing is planned, switch to Idle
if (!ActivatePlannedRequest()) { // if nothing is planned, switch to Idle
SwitchToIdle();
} else if (ExpectsResponse()) {
// if the previous cycle was Idle and now we have planned a new command -> avoid returning Finished
@ -845,8 +850,9 @@ StepStatus ProtocolLogic::Step() {
}
uint8_t ProtocolLogic::CommandInProgress() const {
if (currentScope != Scope::Command)
if (currentScope != Scope::Command) {
return 0;
}
return (uint8_t)ReqMsg().code;
}
@ -862,7 +868,7 @@ void ProtocolLogic::ResetRetryAttempts() {
retryAttempts = MAX_RETRIES;
}
void __attribute__((noinline)) ProtocolLogic::ResetCommunicationTimeoutAttempts() {
void ProtocolLogic::ResetCommunicationTimeoutAttempts() {
SERIAL_ECHOLNPGM("RSTCommTimeout");
dataTO.Reset();
}

View File

@ -52,22 +52,22 @@ class ProtocolLogic;
/// ProtocolLogic stepping statuses
enum StepStatus : uint_fast8_t {
Processing = 0,
MessageReady, ///< a message has been successfully decoded from the received bytes
Finished, ///< Scope finished successfully
Interrupted, ///< received "Finished" message related to a different command than originally issued (most likely the MMU restarted while doing something)
MessageReady, ///< a message has been successfully decoded from the received bytes
Finished, ///< Scope finished successfully
Interrupted, ///< received "Finished" message related to a different command than originally issued (most likely the MMU restarted while doing something)
CommunicationTimeout, ///< the MMU failed to respond to a request within a specified time frame
ProtocolError, ///< bytes read from the MMU didn't form a valid response
CommandRejected, ///< the MMU rejected the command due to some other command in progress, may be the user is operating the MMU locally (button commands)
CommandError, ///< the command in progress stopped due to unrecoverable error, user interaction required
VersionMismatch, ///< the MMU reports its firmware version incompatible with our implementation
PrinterError, ///< printer's explicit error - MMU is fine, but the printer was unable to complete the requested operation
ProtocolError, ///< bytes read from the MMU didn't form a valid response
CommandRejected, ///< the MMU rejected the command due to some other command in progress, may be the user is operating the MMU locally (button commands)
CommandError, ///< the command in progress stopped due to unrecoverable error, user interaction required
VersionMismatch, ///< the MMU reports its firmware version incompatible with our implementation
PrinterError, ///< printer's explicit error - MMU is fine, but the printer was unable to complete the requested operation
CommunicationRecovered,
ButtonPushed, ///< The MMU reported the user pushed one of its three buttons.
ButtonPushed, ///< The MMU reported the user pushed one of its three buttons.
};
inline constexpr uint32_t linkLayerTimeout = 2000; ///< default link layer communication timeout
inline constexpr uint32_t linkLayerTimeout = 2000; ///< default link layer communication timeout
inline constexpr uint32_t dataLayerTimeout = linkLayerTimeout * 3; ///< data layer communication timeout
inline constexpr uint32_t heartBeatPeriod = linkLayerTimeout / 2; ///< period of heart beat messages (Q0)
inline constexpr uint32_t heartBeatPeriod = linkLayerTimeout / 2; ///< period of heart beat messages (Q0)
static_assert(heartBeatPeriod < linkLayerTimeout && linkLayerTimeout < dataLayerTimeout, "Incorrect ordering of timeouts");
@ -229,9 +229,9 @@ private:
ErrorCode explicitPrinterError;
enum class State : uint_fast8_t {
Stopped, ///< stopped for whatever reason
Stopped, ///< stopped for whatever reason
InitSequence, ///< initial sequence running
Running ///< normal operation - Idle + Command processing
Running ///< normal operation - Idle + Command processing
};
enum class Scope : uint_fast8_t {
@ -347,25 +347,25 @@ private:
/// Activate the planned state once the immediate response to a sent request arrived
bool ActivatePlannedRequest();
uint32_t lastUARTActivityMs; ///< timestamp - last ms when something occurred on the UART
DropOutFilter dataTO; ///< Filter of short consecutive drop outs which are recovered instantly
uint32_t lastUARTActivityMs; ///< timestamp - last ms when something occurred on the UART
DropOutFilter dataTO; ///< Filter of short consecutive drop outs which are recovered instantly
ResponseMsg rsp; ///< decoded response message from the MMU protocol
ResponseMsg rsp; ///< decoded response message from the MMU protocol
State state; ///< internal state of ProtocolLogic
State state; ///< internal state of ProtocolLogic
Protocol protocol; ///< protocol codec
Protocol protocol; ///< protocol codec
std::array<uint8_t, 16> lastReceivedBytes; ///< remembers the last few bytes of incoming communication for diagnostic purposes
uint8_t lrb;
MMU2Serial *uart; ///< UART interface
MMU2Serial *uart; ///< UART interface
ErrorCode errorCode; ///< last received error code from the MMU
ErrorCode errorCode; ///< last received error code from the MMU
ProgressCode progressCode; ///< last received progress code from the MMU
Buttons buttonCode; ///< Last received button from the MMU.
Buttons buttonCode; ///< Last received button from the MMU.
uint8_t lastFSensor; ///< last state of filament sensor
uint8_t lastFSensor; ///< last state of filament sensor
#ifndef __AVR__
uint8_t txbuff[Protocol::MaxRequestSize()]; ///< In Buddy FW - a static transmit buffer needs to exist as DMA cannot be used from CCMRAM.

View File

@ -11,6 +11,7 @@
#include "ultralcd.h"
#include "Filament_sensor.h"
#include "language.h"
#include "lcd.h"
#include "temperature.h"
#include "sound.h"
@ -157,7 +158,7 @@ static uint8_t ReportErrorHookMonitor(uint8_t ei) {
//! | |
//! |>(left) |
//! ----------------------
//! Three choices
//! Three choices
//! |>(left)>(mid)>(righ)|
//! ----------------------
//! Two choices
@ -236,7 +237,7 @@ bool TuneMenuEntered() {
void ReportErrorHook(CommandInProgress /*cip*/, ErrorCode ec, uint8_t /*es*/) {
if (putErrorScreenToSleep) return;
if (mmu2.MMUCurrentErrorCode() == ErrorCode::OK && mmu2.MMULastErrorSource() == MMU2::ErrorSourceMMU) {
// If the error code suddenly changes to OK, that means
// a button was pushed on the MMU and the LCD should
@ -464,6 +465,15 @@ void tuneIdlerStallguardThresholdMenu() {
}
void tuneIdlerStallguardThreshold() {
if ((CommandInProgress)mmu2.GetCommandInProgress() != NoCommand)
{
// Workaround to mitigate an issue where the Tune menu doesn't
// work if the MMU is running a command. For example the Idler
// homing fails during toolchange.
// To save the print, make the Tune button unresponsive for now.
return;
}
putErrorScreenToSleep = true;
menu_submenu(tuneIdlerStallguardThresholdMenu);
}

View File

@ -13,9 +13,12 @@ namespace MMU2 {
/// When the printer's FW starts, the MMU mode is either Stopped or NotResponding (based on user's preference).
/// When the MMU successfully establishes communication, the state changes to Active.
enum class xState : uint_fast8_t {
Active, ///< MMU has been detected, connected, communicates and is ready to be worked with.
/// The user doesn't want the printer to work with the MMU. The MMU itself is not powered and does not work at all.
/// !!! Must be 0 !!! marlin_vars.mmu2_state is set to 0 if not active
Stopped,
Active, ///< MMU has been detected, connected, communicates and is ready to be worked with.
Connecting, ///< MMU is connected but it doesn't communicate (yet). The user wants the MMU, but it is not ready to be worked with.
Stopped ///< The user doesn't want the printer to work with the MMU. The MMU itself is not powered and does not work at all.
};
} // namespace MMU2

View File

@ -5,6 +5,6 @@ namespace MMU2 {
static constexpr uint8_t mmuVersionMajor = 3;
static constexpr uint8_t mmuVersionMinor = 0;
static constexpr uint8_t mmuVersionPatch = 2;
static constexpr uint8_t mmuVersionPatch = 3;
} // namespace MMU2

View File

@ -24,13 +24,13 @@
#include "stepper.h"
#include "planner.h"
// The arc is approximated by generating a huge number of tiny, linear segments. The length of each
// segment is configured in settings.mm_per_arc_segment.
// The arc is approximated by generating a huge number of tiny, linear segments. The length of each
// segment is configured in settings.mm_per_arc_segment.
void mc_arc(const float* position, float* target, const float* offset, float feed_rate, float radius, bool isclockwise, uint16_t start_segment_idx)
{
float start_position[4];
memcpy(start_position, position, sizeof(start_position));
float r_axis_x = -offset[X_AXIS]; // Radius vector from center to current location
float r_axis_y = -offset[Y_AXIS];
float center_axis_x = start_position[X_AXIS] - r_axis_x;
@ -56,7 +56,7 @@ void mc_arc(const float* position, float* target, const float* offset, float fee
if (cs.arc_segments_per_sec > 0)
{
// 20200417 - FormerLurker - Implement MIN_ARC_SEGMENTS if it is defined - from Marlin 2.0 implementation
float mm_per_arc_segment_sec = (feed_rate / 60.0f) * (1.0f / cs.arc_segments_per_sec);
float mm_per_arc_segment_sec = feed_rate / (60.f * float(cs.arc_segments_per_sec));
if (mm_per_arc_segment_sec < mm_per_arc_segment)
mm_per_arc_segment = mm_per_arc_segment_sec;
}
@ -89,7 +89,7 @@ void mc_arc(const float* position, float* target, const float* offset, float fee
// calculating here
const float millimeters_of_travel_arc = hypot(angular_travel_total * radius, fabs(travel_z));
if (millimeters_of_travel_arc < 0.001) { return; }
// Calculate the number of arc segments
unsigned short segments = static_cast<unsigned short>(ceil(millimeters_of_travel_arc / mm_per_arc_segment));

View File

@ -4,7 +4,7 @@
Copyright (c) 2009-2011 Simen Svale Skogsrud
Copyright (c) 2011 Sungeun K. Jeon
Grbl is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
@ -22,7 +22,7 @@
#ifndef motion_control_h
#define motion_control_h
// Execute an arc in offset mode format. position == current xyz, target == target xyz,
// Execute an arc in offset mode format. position == current xyz, target == target xyz,
// offset == offset from current xyz, axis_XXX defines circle plane in tool space, axis_linear is
// the direction of helical travel, radius == circle radius, isclockwise boolean. Used
// for vector transformation direction.

View File

@ -13,7 +13,7 @@
#define OPTIBOOT_MAJVER 6
#define OPTIBOOT_CUSTOMVER 0
#define OPTIBOOT_MINVER 2
static unsigned const int __attribute__((section(".version")))
static unsigned const int __attribute__((section(".version")))
optiboot_version = 256*(OPTIBOOT_MAJVER + OPTIBOOT_CUSTOMVER) + OPTIBOOT_MINVER;
#if 0

View File

@ -54,7 +54,7 @@ const PROGMEM uint8_t pat9125_init_bank0[] = {
PAT9125_RES_Y, PAT9125_YRES,
// Set data format and sensor orientation.
PAT9125_ORIENTATION, ((PAT9125_12B_RES?0x04:0) | (PAT9125_INVERT_X?0x08:0) | (PAT9125_INVERT_Y?0x10:0) | (PAT9125_SWAP_XY?0x20:0)),
// Now continues the magic sequence from the PAT912EL Application Note: Firmware Guides for Tracking Optimization.
0x5e, 0x08,
0x20, 0x64,
@ -136,22 +136,22 @@ uint8_t pat9125_init(void)
pat9125_wr_reg(PAT9125_CONFIG, 0x97);
// Wait until the sensor reboots.
_delay_ms(1);
//Write init sequence in bank0. MUST ALREADY BE IN bank0.
if (!pat9125_wr_seq(pat9125_init_bank0))
return 0;
_delay_ms(10); // not sure why this is here. But I'll allow it.
// Switch to bank1, not allowed to perform pat9125_wr_reg_verify on this register.
pat9125_wr_reg(PAT9125_BANK_SELECTION, 0x01);
//Write init sequence in bank1. MUST ALREADY BE IN bank1.
if (!pat9125_wr_seq(pat9125_init_bank1))
return 0;
// Switch to bank0, not allowed to perform pat9125_wr_reg_verify on this register.
pat9125_wr_reg(PAT9125_BANK_SELECTION, 0x00);
// Enable write protect.
pat9125_wr_reg(PAT9125_WP, 0x00); //prevents writing to registers over 0x09
@ -161,14 +161,14 @@ uint8_t pat9125_init(void)
#else //PAT9125_NEW_INIT
// Disable write protect.
pat9125_wr_reg(PAT9125_WP, 0x5a); //allows writing to all registers
pat9125_wr_reg(PAT9125_RES_X, PAT9125_XRES);
pat9125_wr_reg(PAT9125_RES_Y, PAT9125_YRES);
printf_P(PSTR("PAT9125_RES_X=%u\n"), pat9125_rd_reg(PAT9125_RES_X));
printf_P(PSTR("PAT9125_RES_Y=%u\n"), pat9125_rd_reg(PAT9125_RES_Y));
pat9125_wr_reg(PAT9125_ORIENTATION, ((PAT9125_12B_RES?0x04:0) | (PAT9125_INVERT_X?0x08:0) | (PAT9125_INVERT_Y?0x10:0) | (PAT9125_SWAP_XY?0x20:0)));
// Enable write protect.
pat9125_wr_reg(PAT9125_WP, 0x00); //prevents writing to registers over 0x09
#endif //PAT9125_NEW_INIT

View File

@ -3,8 +3,6 @@
#include "boards.h"
#define LARGE_FLASH true
/*****************************************************************
* Rambo Pin Assignments 1.3
******************************************************************/

View File

@ -119,7 +119,7 @@
#define SDCARDDETECT 15
#define TACH_0 79 // !!! changed from 81 (EINY03)
#define TACH_1 80
#define TACH_1 80
#define IR_SENSOR_PIN 62 //idler sensor @PK0 (digital pin 62/A8)

View File

@ -101,7 +101,7 @@
#define SDCARDDETECT 72
#define IR_SENSOR_PIN 20 //idler sensor
#define IR_SENSOR_PIN 20 //idler sensor
// Support for an 8 bit logic analyzer, for example the Saleae.
// Channels 0-2 are fast, they could generate 2.667Mhz waveform with a software loop.

View File

@ -1,53 +1,53 @@
/*
planner.c - buffers movement commands and manages the acceleration profile plan
Part of Grbl
Copyright (c) 2009-2011 Simen Svale Skogsrud
Grbl is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Grbl is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
*/
/* The ring buffer implementation gleaned from the wiring_serial library by David A. Mellis. */
/*
/*
Reasoning behind the mathematics in this module (in the key of 'Mathematica'):
s == speed, a == acceleration, t == time, d == distance
Basic definitions:
Speed[s_, a_, t_] := s + (a*t)
Speed[s_, a_, t_] := s + (a*t)
Travel[s_, a_, t_] := Integrate[Speed[s, a, t], t]
Distance to reach a specific speed with a constant acceleration:
Solve[{Speed[s, a, t] == m, Travel[s, a, t] == d}, d, t]
d -> (m^2 - s^2)/(2 a) --> estimate_acceleration_distance()
Speed after a given distance of travel with constant acceleration:
Solve[{Speed[s, a, t] == m, Travel[s, a, t] == d}, m, t]
m -> Sqrt[2 a d + s^2]
m -> Sqrt[2 a d + s^2]
DestinationSpeed[s_, a_, d_] := Sqrt[2 a d + s^2]
When to start braking (di) to reach a specified destionation speed (s2) after accelerating
from initial speed s1 without ever stopping at a plateau:
Solve[{DestinationSpeed[s1, a, di] == DestinationSpeed[s2, a, d - di]}, di]
di -> (2 a d - s1^2 + s2^2)/(4 a) --> intersection_distance()
IntersectionDistance[s1_, s2_, a_, d_] := (2 a d - s1^2 + s2^2)/(4 a)
*/
@ -57,6 +57,7 @@
#include "temperature.h"
#include "fancheck.h"
#include "ultralcd.h"
#include "lcd.h"
#include "language.h"
#include "ConfigurationStore.h"
@ -84,15 +85,6 @@ float* max_feedrate = cs.max_feedrate_normal;
uint32_t* max_acceleration_mm_per_s2 = cs.max_acceleration_mm_per_s2_normal;
uint32_t max_acceleration_steps_per_s2[NUM_AXIS];
#ifdef ENABLE_AUTO_BED_LEVELING
// this holds the required transform to compensate for bed level
matrix_3x3 plan_bed_level_matrix = {
1.0, 0.0, 0.0,
0.0, 1.0, 0.0,
0.0, 0.0, 1.0,
};
#endif // #ifdef ENABLE_AUTO_BED_LEVELING
// The current position of the tool in absolute steps
long position[NUM_AXIS]; //rescaled from extern when axis_steps_per_mm are changed by gcode
static float previous_speed[NUM_AXIS]; // Speed of previous path line segment
@ -114,7 +106,7 @@ volatile uint8_t block_buffer_head; // Index of the next block to be pus
volatile uint8_t block_buffer_tail; // Index of the block to process now
#ifdef PLANNER_DIAGNOSTICS
// Diagnostic function: Minimum number of planned moves since the last
// Diagnostic function: Minimum number of planned moves since the last
static uint8_t g_cntr_planner_queue_min = 0;
#endif /* PLANNER_DIAGNOSTICS */
@ -123,7 +115,7 @@ static uint8_t g_cntr_planner_queue_min = 0;
//===========================================================================
#ifdef PREVENT_DANGEROUS_EXTRUDE
int extrude_min_temp = EXTRUDE_MINTEMP;
#endif
#endif //PREVENT_DANGEROUS_EXTRUDE
#ifdef LIN_ADVANCE
float extruder_advance_K = LA_K_DEF;
@ -155,7 +147,7 @@ static inline uint8_t prev_block_index(uint8_t block_index) {
//=============================functions ============================
//===========================================================================
// Calculates the distance (not time) it takes to accelerate from initial_rate to target_rate using the
// Calculates the distance (not time) it takes to accelerate from initial_rate to target_rate using the
// given acceleration:
FORCE_INLINE float estimate_acceleration_distance(float initial_rate, float target_rate, float acceleration)
{
@ -168,12 +160,12 @@ FORCE_INLINE float estimate_acceleration_distance(float initial_rate, float targ
}
}
// This function gives you the point at which you must start braking (at the rate of -acceleration) if
// This function gives you the point at which you must start braking (at the rate of -acceleration) if
// you started at speed initial_rate and accelerated until this point and want to end at the final_rate after
// a total travel of distance. This can be used to compute the intersection point between acceleration and
// deceleration in the cases where the trapezoid has no plateau (i.e. never reaches maximum speed)
FORCE_INLINE float intersection_distance(float initial_rate, float final_rate, float acceleration, float distance)
FORCE_INLINE float intersection_distance(float initial_rate, float final_rate, float acceleration, float distance)
{
if (acceleration!=0) {
return((2.0*acceleration*distance-initial_rate*initial_rate+final_rate*final_rate)/
@ -188,7 +180,7 @@ FORCE_INLINE float intersection_distance(float initial_rate, float final_rate, f
#define MINIMAL_STEP_RATE 120
// Calculates trapezoid parameters so that the entry- and exit-speed is compensated by the provided factors.
void calculate_trapezoid_for_block(block_t *block, float entry_speed, float exit_speed)
void calculate_trapezoid_for_block(block_t *block, float entry_speed, float exit_speed)
{
// These two lines are the only floating point calculations performed in this routine.
// initial_rate, final_rate in Hz.
@ -248,7 +240,7 @@ void calculate_trapezoid_for_block(block_t *block, float entry_speed, float exit
// Avoid negative numbers
if (final_rate_sqr >= initial_rate_sqr) {
// accelerate_steps = ceil(intersection_distance(initial_rate, final_rate, acceleration, block->step_event_count));
// intersection_distance(float initial_rate, float final_rate, float acceleration, float distance)
// intersection_distance(float initial_rate, float final_rate, float acceleration, float distance)
// (2.0*acceleration*distance-initial_rate*initial_rate+final_rate*final_rate)/(4.0*acceleration);
#if 0
accelerate_steps = (block->step_event_count >> 1) + (final_rate_sqr - initial_rate_sqr + acceleration_x4 - 1 + (block->step_event_count & 1) * acceleration_x2) / acceleration_x4;
@ -308,9 +300,9 @@ void calculate_trapezoid_for_block(block_t *block, float entry_speed, float exit
CRITICAL_SECTION_END;
}
// Calculates the maximum allowable entry speed, when you must be able to reach target_velocity using the
// Calculates the maximum allowable entry speed, when you must be able to reach target_velocity using the
// decceleration within the allotted distance.
FORCE_INLINE float max_allowable_entry_speed(float decceleration, float target_velocity, float distance)
FORCE_INLINE float max_allowable_entry_speed(float decceleration, float target_velocity, float distance)
{
// assert(decceleration < 0);
return sqrt(target_velocity*target_velocity-2*decceleration*distance);
@ -318,17 +310,17 @@ FORCE_INLINE float max_allowable_entry_speed(float decceleration, float target_v
// Recalculates the motion plan according to the following algorithm:
//
// 1. Go over every block in reverse order and calculate a junction speed reduction (i.e. block_t.entry_factor)
// 1. Go over every block in reverse order and calculate a junction speed reduction (i.e. block_t.entry_factor)
// so that:
// a. The junction jerk is within the set limit
// b. No speed reduction within one block requires faster deceleration than the one, true constant
// b. No speed reduction within one block requires faster deceleration than the one, true constant
// acceleration.
// 2. Go over every block in chronological order and dial down junction speed reduction values if
// a. The speed increase within one block would require faster accelleration than the one, true
// 2. Go over every block in chronological order and dial down junction speed reduction values if
// a. The speed increase within one block would require faster accelleration than the one, true
// constant acceleration.
//
// When these stages are complete all blocks have an entry_factor that will allow all speed changes to
// be performed using only the one, true constant acceleration, and where no junction jerk is jerkier than
// When these stages are complete all blocks have an entry_factor that will allow all speed changes to
// be performed using only the one, true constant acceleration, and where no junction jerk is jerkier than
// the set limit. Finally it will:
//
// 3. Recalculate trapezoids for all blocks.
@ -340,20 +332,20 @@ FORCE_INLINE float max_allowable_entry_speed(float decceleration, float target_v
// Following sources may be used to optimize the 8-bit AVR code:
// http://www.mikrocontroller.net/articles/AVR_Arithmetik
// http://darcy.rsgc.on.ca/ACES/ICE4M/FixedPoint/avrfix.pdf
//
//
// https://github.com/gcc-mirror/gcc/blob/master/libgcc/config/avr/lib1funcs-fixed.S
// https://gcc.gnu.org/onlinedocs/gcc/Fixed-Point.html
// https://gcc.gnu.org/onlinedocs/gccint/Fixed-point-fractional-library-routines.html
//
//
// https://ucexperiment.wordpress.com/2015/04/04/arduino-s15-16-fixed-point-math-routines/
// https://mekonik.wordpress.com/2009/03/18/arduino-avr-gcc-multiplication/
// https://github.com/rekka/avrmultiplication
//
//
// https://people.ece.cornell.edu/land/courses/ece4760/Math/Floating_point/
// https://courses.cit.cornell.edu/ee476/Math/
// https://courses.cit.cornell.edu/ee476/Math/GCC644/fixedPt/multASM.S
//
void planner_recalculate(const float &safe_final_speed)
void planner_recalculate(const float &safe_final_speed)
{
// Reverse pass
// Make a local copy of block_buffer_tail, because the interrupt can alter it
@ -531,7 +523,7 @@ bool e_active()
void check_axes_activity()
{
uint8_t x_active = 0;
uint8_t y_active = 0;
uint8_t y_active = 0;
uint8_t z_active = 0;
uint8_t e_active = 0;
uint8_t tail_fan_speed = fanSpeed;
@ -627,7 +619,7 @@ void planner_reset_position()
current_position[Z_AXIS] -= mbl.get_z(current_position[X_AXIS], current_position[Y_AXIS]);
else {
float t = float(step_events_completed) / float(current_block->step_event_count);
float vec[3] = {
float vec[3] = {
current_block->steps_x / cs.axis_steps_per_mm[X_AXIS],
current_block->steps_y / cs.axis_steps_per_mm[Y_AXIS],
current_block->steps_z / cs.axis_steps_per_mm[Z_AXIS]
@ -690,7 +682,7 @@ void plan_set_position_curposXYZE(){
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
}
// Add a new linear movement to the buffer. steps_x, _y and _z is the absolute position in
// Add a new linear movement to the buffer. steps_x, _y and _z is the absolute position in
// mm. Microseconds specify how many microseconds the move should take to perform. To aid acceleration
// calculation the caller must also provide the physical length of the line in millimeters.
void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate, const float* gcode_start_position, uint16_t segment_idx)
@ -706,9 +698,9 @@ void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate
// Rest here until there is room in the buffer.
if (block_buffer_tail == next_buffer_head) {
do {
manage_heater();
manage_heater();
// Vojtech: Don't disable motors inside the planner!
manage_inactivity(false);
manage_inactivity(false);
lcd_update(0);
} while (block_buffer_tail == next_buffer_head);
}
@ -736,7 +728,7 @@ void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate
memcpy(block->gcode_start_position, gcode_start_position, sizeof(block_t::gcode_start_position));
else
memcpy(block->gcode_start_position, current_position, sizeof(block_t::gcode_start_position));
// Save the index of this segment (when a single G0/1/2/3 command plans multiple segments)
block->segment_idx = segment_idx;
@ -757,53 +749,8 @@ void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate
plan_reset_next_e_sched = true;
}
#ifdef ENABLE_AUTO_BED_LEVELING
apply_rotation_xyz(plan_bed_level_matrix, x, y, z);
#endif // ENABLE_AUTO_BED_LEVELING
// Apply the machine correction matrix.
{
#if 0
SERIAL_ECHOPGM("Planner, current position - servos: ");
MYSERIAL.print(st_get_position_mm(X_AXIS), 5);
SERIAL_ECHOPGM(", ");
MYSERIAL.print(st_get_position_mm(Y_AXIS), 5);
SERIAL_ECHOPGM(", ");
MYSERIAL.print(st_get_position_mm(Z_AXIS), 5);
SERIAL_ECHOLNPGM("");
SERIAL_ECHOPGM("Planner, target position, initial: ");
MYSERIAL.print(x, 5);
SERIAL_ECHOPGM(", ");
MYSERIAL.print(y, 5);
SERIAL_ECHOLNPGM("");
SERIAL_ECHOPGM("Planner, world2machine: ");
MYSERIAL.print(world2machine_rotation_and_skew[0][0], 5);
SERIAL_ECHOPGM(", ");
MYSERIAL.print(world2machine_rotation_and_skew[0][1], 5);
SERIAL_ECHOPGM(", ");
MYSERIAL.print(world2machine_rotation_and_skew[1][0], 5);
SERIAL_ECHOPGM(", ");
MYSERIAL.print(world2machine_rotation_and_skew[1][1], 5);
SERIAL_ECHOLNPGM("");
SERIAL_ECHOPGM("Planner, offset: ");
MYSERIAL.print(world2machine_shift[0], 5);
SERIAL_ECHOPGM(", ");
MYSERIAL.print(world2machine_shift[1], 5);
SERIAL_ECHOLNPGM("");
#endif
world2machine(x, y);
#if 0
SERIAL_ECHOPGM("Planner, target position, corrected: ");
MYSERIAL.print(x, 5);
SERIAL_ECHOPGM(", ");
MYSERIAL.print(y, 5);
SERIAL_ECHOLNPGM("");
#endif
}
// Apply the machine correction matrix.
world2machine(x, y);
// The target position of the tool in absolute steps
// Calculate target position in absolute steps
@ -828,7 +775,7 @@ void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate
int32_t dx = target[X_AXIS] - position[X_AXIS];
int32_t dy = target[Y_AXIS] - position[Y_AXIS];
int32_t dz = target[Z_AXIS] - position[Z_AXIS];
#ifdef PREVENT_DANGEROUS_EXTRUDE
if(de)
{
@ -842,7 +789,7 @@ void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate
SERIAL_ECHO_START;
SERIAL_ECHOLNRPGM(_n(" cold extrusion prevented"));////MSG_ERR_COLD_EXTRUDE_STOP
}
#ifdef PREVENT_LENGTHY_EXTRUDE
if(labs(de) > cs.axis_steps_per_mm[E_AXIS]*EXTRUDE_MAXLENGTH)
{
@ -856,7 +803,7 @@ void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate
}
#endif
}
#endif
#endif //PREVENT_DANGEROUS_EXTRUDE
// Number of steps for each axis
#ifndef COREXY
@ -875,11 +822,11 @@ block->steps[Y_AXIS].wide = labs(dx - dy);
// Bail if this is a zero-length block
if (block->step_event_count.wide <= dropsegments)
{
{
#ifdef PLANNER_DIAGNOSTICS
planner_update_queue_min_counter();
#endif /* PLANNER_DIAGNOSTICS */
return;
return;
}
block->fan_speed = fanSpeed;
@ -917,15 +864,15 @@ block->steps[Y_AXIS].wide = labs(dx - dy);
else
{
if(feed_rate<cs.minimumfeedrate) feed_rate=cs.minimumfeedrate;
}
}
/* This part of the code calculates the total length of the movement.
/* This part of the code calculates the total length of the movement.
For cartesian bots, the X_AXIS is the real X movement and same for Y_AXIS.
But for corexy bots, that is not true. The "X_AXIS" and "Y_AXIS" motors (that should be named to A_AXIS
and B_AXIS) cannot be used for X and Y length, because A=X+Y and B=X-Y.
So we need to create other 2 "AXIS", named X_HEAD and Y_HEAD, meaning the real displacement of the Head.
So we need to create other 2 "AXIS", named X_HEAD and Y_HEAD, meaning the real displacement of the Head.
Having the real displacement of the head, we can calculate the total movement length and apply the desired speed.
*/
*/
#ifndef COREXY
float delta_mm[4];
delta_mm[X_AXIS] = dx / cs.axis_steps_per_mm[X_AXIS];
@ -942,16 +889,16 @@ Having the real displacement of the head, we can calculate the total movement le
if ( block->steps[X_AXIS].wide <=dropsegments && block->steps[Y_AXIS].wide <=dropsegments && block->steps[Z_AXIS].wide <=dropsegments )
{
block->millimeters = fabs(delta_mm[E_AXIS]);
}
}
else
{
#ifndef COREXY
block->millimeters = sqrt(square(delta_mm[X_AXIS]) + square(delta_mm[Y_AXIS]) + square(delta_mm[Z_AXIS]));
#else
block->millimeters = sqrt(square(delta_mm[X_HEAD]) + square(delta_mm[Y_HEAD]) + square(delta_mm[Z_AXIS]));
#endif
#endif
}
float inverse_millimeters = 1.0/block->millimeters; // Inverse millimeters to remove multiple divides
float inverse_millimeters = 1.0/block->millimeters; // Inverse millimeters to remove multiple divides
// Calculate speed in mm/second for each axis. No divide by zero due to previous checks.
float inverse_second = feed_rate * inverse_millimeters;
@ -986,7 +933,7 @@ Having the real displacement of the head, we can calculate the total movement le
}
}
// Correct the speed
// Correct the speed
if( speed_factor < 1.0)
{
for(unsigned char i=0; i < 4; i++)
@ -1000,7 +947,7 @@ Having the real displacement of the head, we can calculate the total movement le
#ifdef LIN_ADVANCE
float e_D_ratio = 0;
#endif
// Compute and limit the acceleration rate for the trapezoid generator.
// Compute and limit the acceleration rate for the trapezoid generator.
// block->step_event_count ... event count of the fastest axis
// block->millimeters ... Euclidian length of the XYZ movement or the E length, if no XYZ movement.
float steps_per_mm = block->step_event_count.wide/block->millimeters;
@ -1142,11 +1089,11 @@ Having the real displacement of the head, we can calculate the total movement le
v_entry *= v_factor;
}
// Calculate the jerk depending on whether the axis is coasting in the same direction or reversing a direction.
float jerk =
float jerk =
(v_exit > v_entry) ?
((v_entry > 0.f || v_exit < 0.f) ?
// coasting
(v_exit - v_entry) :
(v_exit - v_entry) :
// axis reversal
max(v_exit, - v_entry)) :
// v_exit <= v_entry
@ -1269,7 +1216,7 @@ Having the real displacement of the head, we can calculate the total movement le
position_float[Z_AXIS] = z;
position_float[E_AXIS] = e;
#endif
// Recalculate the trapezoids to maximize speed at the segment transitions while respecting
// the machine limits (maximum acceleration and maximum jerk).
// This runs asynchronously with the stepper interrupt controller, which may
@ -1291,33 +1238,14 @@ Having the real displacement of the head, we can calculate the total movement le
ENABLE_STEPPER_DRIVER_INTERRUPT();
}
#ifdef ENABLE_AUTO_BED_LEVELING
vector_3 plan_get_position() {
vector_3 position = vector_3(st_get_position_mm(X_AXIS), st_get_position_mm(Y_AXIS), st_get_position_mm(Z_AXIS));
//position.debug("in plan_get position");
//plan_bed_level_matrix.debug("in plan_get bed_level");
matrix_3x3 inverse = matrix_3x3::transpose(plan_bed_level_matrix);
//inverse.debug("in plan_get inverse");
position.apply_rotation(inverse);
//position.debug("after rotation");
return position;
}
#endif // ENABLE_AUTO_BED_LEVELING
void plan_set_position(float x, float y, float z, const float &e)
{
#ifdef ENABLE_AUTO_BED_LEVELING
apply_rotation_xyz(plan_bed_level_matrix, x, y, z);
#endif // ENABLE_AUTO_BED_LEVELING
world2machine(x, y);
position[X_AXIS] = lround(x*cs.axis_steps_per_mm[X_AXIS]);
position[Y_AXIS] = lround(y*cs.axis_steps_per_mm[Y_AXIS]);
#ifdef MESH_BED_LEVELING
position[Z_AXIS] = mbl.active ?
position[Z_AXIS] = mbl.active ?
lround((z+mbl.get_z(x, y))*cs.axis_steps_per_mm[Z_AXIS]) :
lround(z*cs.axis_steps_per_mm[Z_AXIS]);
#else
@ -1350,7 +1278,7 @@ void plan_set_e_position(const float &e)
#ifdef LIN_ADVANCE
position_float[E_AXIS] = e;
#endif
position[E_AXIS] = lround(e*cs.axis_steps_per_mm[E_AXIS]);
position[E_AXIS] = lround(e*cs.axis_steps_per_mm[E_AXIS]);
st_set_e_position(position[E_AXIS]);
}
@ -1364,7 +1292,7 @@ void set_extrude_min_temp(int temp)
{
extrude_min_temp = temp;
}
#endif
#endif //PREVENT_DANGEROUS_EXTRUDE
// Calculate the steps/s^2 acceleration rates, based on the mm/s^s
void reset_acceleration_rates()
@ -1422,7 +1350,7 @@ uint16_t planner_calc_sd_length()
while (_block_buffer_head != _block_buffer_tail)
{
sdlen += block_buffer[_block_buffer_tail].sdlen;
_block_buffer_tail = (_block_buffer_tail + 1) & (BLOCK_BUFFER_SIZE - 1);
_block_buffer_tail = (_block_buffer_tail + 1) & (BLOCK_BUFFER_SIZE - 1);
}
return sdlen;
}

View File

@ -18,7 +18,7 @@
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
*/
// This module is to be considered a sub-module of stepper.c. Please don't include
// This module is to be considered a sub-module of stepper.c. Please don't include
// this file from any other module.
#ifndef planner_h
@ -26,10 +26,6 @@
#include "Marlin.h"
#ifdef ENABLE_AUTO_BED_LEVELING
#include "vector_3.h"
#endif // ENABLE_AUTO_BED_LEVELING
enum BlockFlag {
// Planner flag to recalculate trapezoids on entry junction.
// This flag has an optimization purpose only.
@ -66,7 +62,7 @@ union dda_usteps_t
};
};
// This struct is used when buffering the setup for each linear movement "nominal" values are as specified in
// This struct is used when buffering the setup for each linear movement "nominal" values are as specified in
// the source g-code and may never actually be reached if acceleration management is active.
typedef struct {
// Fields used by the bresenham algorithm for tracing the line
@ -99,8 +95,8 @@ typedef struct {
// Settings for the trapezoid generator (runs inside an interrupt handler).
// Changing the following values in the planner needs to be synchronized with the interrupt handler by disabling the interrupts.
uint32_t nominal_rate; // The nominal step rate for this block in step_events/sec
uint32_t initial_rate; // The jerk-adjusted step rate at start of block
uint32_t nominal_rate; // The nominal step rate for this block in step_events/sec
uint32_t initial_rate; // The jerk-adjusted step rate at start of block
uint32_t final_rate; // The minimal rate at exit
uint32_t acceleration_steps_per_s2; // acceleration steps/sec^2
uint8_t fan_speed; // Print fan speed, ranges from 0 to 255
@ -130,25 +126,10 @@ typedef struct {
extern float extruder_advance_K; // Linear-advance K factor
#endif
#ifdef ENABLE_AUTO_BED_LEVELING
// this holds the required transform to compensate for bed level
extern matrix_3x3 plan_bed_level_matrix;
#endif // #ifdef ENABLE_AUTO_BED_LEVELING
// Initialize the motion plan subsystem
// Initialize the motion plan subsystem
void plan_init();
// Add a new linear movement to the buffer. x, y and z is the signed, absolute target position in
// millimaters. Feed rate specifies the speed of the motion.
#ifdef ENABLE_AUTO_BED_LEVELING
void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate);
// Get the position applying the bed level matrix if enabled
vector_3 plan_get_position();
#else
/// Extracting common call of
/// Extracting common call of
/// plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], ...
/// saves almost 5KB.
/// The performance penalty is negligible, since these planned lines are usually maintenance moves with the extruder.
@ -159,15 +140,9 @@ void plan_buffer_line_destinationXYZE(float feed_rate);
void plan_set_position_curposXYZE();
void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate, const float* gcode_start_position = NULL, uint16_t segment_idx = 0);
//void plan_buffer_line(const float &x, const float &y, const float &z, const float &e, float feed_rate, const uint8_t &extruder);
#endif // ENABLE_AUTO_BED_LEVELING
// Set position. Used for G92 instructions.
//#ifdef ENABLE_AUTO_BED_LEVELING
void plan_set_position(float x, float y, float z, const float &e);
//#else
//void plan_set_position(const float &x, const float &y, const float &z, const float &e);
//#endif // ENABLE_AUTO_BED_LEVELING
void plan_set_z_position(const float &z);
void plan_set_e_position(const float &e);
@ -187,7 +162,7 @@ extern float* max_feedrate;
// Use M201 to override by software
extern uint32_t* max_acceleration_mm_per_s2;
extern uint32_t* max_acceleration_mm_per_s2;
extern uint32_t max_acceleration_steps_per_s2[NUM_AXIS];
extern long position[NUM_AXIS];
@ -211,15 +186,15 @@ extern block_t block_buffer[BLOCK_BUFFER_SIZE]; // A ring buffer for
// Index of the next block to be pushed into the planner queue.
extern volatile uint8_t block_buffer_head;
// Index of the first block in the planner queue.
// This is the block, which is being currently processed by the stepper routine,
// This is the block, which is being currently processed by the stepper routine,
// or which is first to be processed by the stepper routine.
extern volatile uint8_t block_buffer_tail;
// Called when the current block is no longer needed. Discards the block and makes the memory
// available for new blocks.
FORCE_INLINE void plan_discard_current_block()
// available for new blocks.
FORCE_INLINE void plan_discard_current_block()
{
if (block_buffer_head != block_buffer_tail) {
block_buffer_tail = (block_buffer_tail + 1) & (BLOCK_BUFFER_SIZE - 1);
block_buffer_tail = (block_buffer_tail + 1) & (BLOCK_BUFFER_SIZE - 1);
}
}
@ -227,10 +202,10 @@ FORCE_INLINE void plan_discard_current_block()
// Mark this block as busy, so its velocities and acceperations will be no more recalculated
// by the planner routine.
// Returns NULL if buffer empty
FORCE_INLINE block_t *plan_get_current_block()
FORCE_INLINE block_t *plan_get_current_block()
{
if (block_buffer_head == block_buffer_tail) {
return(NULL);
if (block_buffer_head == block_buffer_tail) {
return(NULL);
}
block_t *block = &block_buffer[block_buffer_tail];
block->busy = true;
@ -238,8 +213,8 @@ FORCE_INLINE block_t *plan_get_current_block()
}
// Returns true if the buffer has a queued block, false otherwise
FORCE_INLINE bool blocks_queued() {
return (block_buffer_head != block_buffer_tail);
FORCE_INLINE bool blocks_queued() {
return (block_buffer_head != block_buffer_tail);
}
//return the nr of buffered moves
@ -250,7 +225,7 @@ FORCE_INLINE uint8_t moves_planned() {
FORCE_INLINE bool planner_queue_full() {
uint8_t next_block_index = block_buffer_head;
if (++ next_block_index == BLOCK_BUFFER_SIZE)
next_block_index = 0;
next_block_index = 0;
return block_buffer_tail == next_block_index;
}
@ -266,7 +241,7 @@ extern bool planner_aborted;
#ifdef PREVENT_DANGEROUS_EXTRUDE
extern int extrude_min_temp;
void set_extrude_min_temp(int temp);
#endif
#endif //PREVENT_DANGEROUS_EXTRUDE
void reset_acceleration_rates();
#endif

View File

@ -191,10 +191,22 @@ void uvlo_() {
eeprom_update_float_notify((float*)(EEPROM_UVLO_LA_K), extruder_advance_K);
#endif
#ifdef PREVENT_DANGEROUS_EXTRUDE
eeprom_update_word_notify((uint16_t*)EEPROM_UVLO_EXTRUDE_MINTEMP, extrude_min_temp);
#endif //PREVENT_DANGEROUS_EXTRUDE
eeprom_update_block_notify(cs.max_acceleration_mm_per_s2_normal, (uint32_t *)EEPROM_UVLO_ACCELL_MM_S2_NORMAL, sizeof(cs.max_acceleration_mm_per_s2_normal));
eeprom_update_block_notify(cs.max_acceleration_mm_per_s2_silent, (uint32_t *)EEPROM_UVLO_ACCELL_MM_S2_SILENT, sizeof(cs.max_acceleration_mm_per_s2_silent));
eeprom_update_block_notify(cs.max_feedrate_normal, (float *)EEPROM_UVLO_MAX_FEEDRATE_NORMAL, sizeof(cs.max_feedrate_normal));
eeprom_update_block_notify(cs.max_feedrate_silent, (float *)EEPROM_UVLO_MAX_FEEDRATE_SILENT, sizeof(cs.max_feedrate_silent));
eeprom_update_float_notify((float *)(EEPROM_UVLO_MIN_FEEDRATE), cs.minimumfeedrate);
eeprom_update_float_notify((float *)(EEPROM_UVLO_MIN_TRAVEL_FEEDRATE), cs.mintravelfeedrate);
eeprom_update_dword_notify((uint32_t *)(EEPROM_UVLO_MIN_SEGMENT_TIME_US), cs.min_segment_time_us);
eeprom_update_block_notify(cs.max_jerk, (float *)EEPROM_UVLO_MAX_JERK, sizeof(cs.max_jerk));
// Finally store the "power outage" flag.
if (did_pause_print) {
eeprom_update_byte_notify((uint8_t*)EEPROM_UVLO_Z_LIFTED, 1);
}
eeprom_update_byte_notify((uint8_t*)EEPROM_UVLO, PowerPanic::PENDING_RECOVERY);
// Increment power failure counter
@ -422,6 +434,17 @@ bool recover_machine_state_after_power_panic() {
extruder_advance_K = eeprom_read_float((float*)EEPROM_UVLO_LA_K);
#endif
#ifdef PREVENT_DANGEROUS_EXTRUDE
extrude_min_temp = eeprom_read_word((uint16_t*)EEPROM_UVLO_EXTRUDE_MINTEMP);
#endif //PREVENT_DANGEROUS_EXTRUDE
eeprom_read_block(cs.max_acceleration_mm_per_s2_normal, (uint32_t *)EEPROM_UVLO_ACCELL_MM_S2_NORMAL, sizeof(cs.max_acceleration_mm_per_s2_normal));
eeprom_read_block(cs.max_acceleration_mm_per_s2_silent, (uint32_t *)EEPROM_UVLO_ACCELL_MM_S2_SILENT, sizeof(cs.max_acceleration_mm_per_s2_silent));
eeprom_read_block(cs.max_feedrate_normal, (float *)EEPROM_UVLO_MAX_FEEDRATE_NORMAL, sizeof(cs.max_feedrate_normal));
eeprom_read_block(cs.max_feedrate_silent, (float *)EEPROM_UVLO_MAX_FEEDRATE_SILENT, sizeof(cs.max_feedrate_silent));
cs.minimumfeedrate = eeprom_read_float((float *)EEPROM_UVLO_MIN_FEEDRATE);
cs.mintravelfeedrate = eeprom_read_float((float *)EEPROM_UVLO_MIN_TRAVEL_FEEDRATE);
cs.min_segment_time_us = eeprom_read_dword((uint32_t *)EEPROM_UVLO_MIN_SEGMENT_TIME_US);
eeprom_read_block(cs.max_jerk, (float *)EEPROM_UVLO_MAX_JERK, sizeof(cs.max_jerk));
return mbl_was_active;
}

View File

@ -16,5 +16,5 @@ enum PrintType : uint8_t {
} // namespace PowerPanic
void uvlo_();
void recover_print(uint8_t automatic);
void recover_print(uint8_t automatic);
void setup_uvlo_interrupt();

File diff suppressed because it is too large Load Diff

View File

@ -1,22 +0,0 @@
#include "Configuration.h"
#ifdef AUTO_BED_LEVELING_GRID
void daxpy ( int n, double da, double dx[], int incx, double dy[], int incy );
double ddot ( int n, double dx[], int incx, double dy[], int incy );
double dnrm2 ( int n, double x[], int incx );
void dqrank ( double a[], int lda, int m, int n, double tol, int *kr,
int jpvt[], double qraux[] );
void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[],
double work[], int job );
int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[],
double x[], double rsd[], int jpvt[], double qraux[], int itask );
void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[],
double rsd[], int jpvt[], double qraux[] );
int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[],
double qy[], double qty[], double b[], double rsd[], double ab[], int job );
void dscal ( int n, double sa, double x[], int incx );
void dswap ( int n, double x[], int incx, double y[], int incy );
double *qr_solve ( int m, int n, double a[], double b[] );
#endif

View File

@ -1,5 +1,4 @@
//sm4.c - simple 4-axis stepper control
//sm4.cpp - simple 4-axis stepper control
#include "sm4.h"
#include <avr/io.h>
#include <avr/pgmspace.h>
@ -49,28 +48,6 @@ sm4_update_pos_cb_t sm4_update_pos_cb = 0;
sm4_calc_delay_cb_t sm4_calc_delay_cb = 0;
uint16_t sm4_cpu_time = 0;
uint8_t sm4_get_dir(uint8_t axis)
{
switch (axis)
{
#if ((MOTHERBOARD == BOARD_RAMBO_MINI_1_0) || (MOTHERBOARD == BOARD_RAMBO_MINI_1_3))
case 0: return (PORTL & 2)?XDIR;
case 1: return (PORTL & 1)?YDIR;
case 2: return (PORTL & 4)?ZDIR;
case 3: return (PORTL & 64)?EDIR;
#elif ((MOTHERBOARD == BOARD_EINSY_1_0a))
case 0: return (PORTL & 1)?XDIR;
case 1: return (PORTL & 2)?YDIR;
case 2: return (PORTL & 4)?ZDIR;
case 3: return (PORTL & 64)?EDIR;
#endif
}
return 0;
}
void sm4_set_dir(uint8_t axis, uint8_t dir)
{
switch (axis)
@ -90,30 +67,9 @@ void sm4_set_dir(uint8_t axis, uint8_t dir)
asm("nop");
}
uint8_t sm4_get_dir_bits(void)
{
register uint8_t dir_bits = 0;
register uint8_t portL = PORTL;
//TODO -optimize in asm
#if ((MOTHERBOARD == BOARD_RAMBO_MINI_1_0) || (MOTHERBOARD == BOARD_RAMBO_MINI_1_3))
if (portL & 2) dir_bits |= 1;
if (portL & 1) dir_bits |= 2;
if (portL & 4) dir_bits |= 4;
if (portL & 64) dir_bits |= 8;
dir_bits ^= dir_mask;
#elif ((MOTHERBOARD == BOARD_EINSY_1_0a))
if (portL & 1) dir_bits |= 1;
if (portL & 2) dir_bits |= 2;
if (portL & 4) dir_bits |= 4;
if (portL & 64) dir_bits |= 8;
dir_bits ^= dir_mask;
#endif
return dir_bits;
}
void sm4_set_dir_bits(uint8_t dir_bits)
{
register uint8_t portL = PORTL;
uint8_t portL = PORTL;
portL &= 0xb8; //set direction bits to zero
//TODO -optimize in asm
#if ((MOTHERBOARD == BOARD_RAMBO_MINI_1_0) || (MOTHERBOARD == BOARD_RAMBO_MINI_1_3))
@ -123,7 +79,7 @@ void sm4_set_dir_bits(uint8_t dir_bits)
if (dir_bits & 4) portL |= 4; //set Z direction bit
if (dir_bits & 8) portL |= 64; //set E direction bit
#elif ((MOTHERBOARD == BOARD_EINSY_1_0a))
dir_bits ^= dir_mask;
dir_bits ^= dir_mask;
if (dir_bits & 1) portL |= 1; //set X direction bit
if (dir_bits & 2) portL |= 2; //set Y direction bit
if (dir_bits & 4) portL |= 4; //set Z direction bit
@ -139,7 +95,7 @@ void sm4_do_step(uint8_t axes_mask)
#ifdef TMC2130_DEDGE_STEPPING
PINC = (axes_mask & 0x0f); // toggle step signals by mask
#else
register uint8_t portC = PORTC & 0xf0;
uint8_t portC = PORTC & 0xf0;
PORTC = portC | (axes_mask & 0x0f); //set step signals by mask
asm("nop");
PORTC = portC; //set step signals to zero
@ -148,60 +104,6 @@ void sm4_do_step(uint8_t axes_mask)
#endif //((MOTHERBOARD == BOARD_RAMBO_MINI_1_0) || (MOTHERBOARD == BOARD_RAMBO_MINI_1_3) || (MOTHERBOARD == BOARD_EINSY_1_0a))
}
uint16_t sm4_line_xyze_ui(uint16_t dx, uint16_t dy, uint16_t dz, uint16_t de)
{
uint16_t dd = (uint16_t)(sqrt((float)(((uint32_t)dx)*dx + ((uint32_t)dy*dy) + ((uint32_t)dz*dz) + ((uint32_t)de*de))) + 0.5);
uint16_t nd = dd;
uint16_t cx = dd;
uint16_t cy = dd;
uint16_t cz = dd;
uint16_t ce = dd;
uint16_t x = 0;
uint16_t y = 0;
uint16_t z = 0;
uint16_t e = 0;
while (nd)
{
if (sm4_stop_cb && (*sm4_stop_cb)()) break;
uint8_t sm = 0; //step mask
if (cx <= dx)
{
sm |= 1;
cx += dd;
x++;
}
if (cy <= dy)
{
sm |= 2;
cy += dd;
y++;
}
if (cz <= dz)
{
sm |= 4;
cz += dd;
z++;
}
if (ce <= de)
{
sm |= 8;
ce += dd;
e++;
}
cx -= dx;
cy -= dy;
cz -= dz;
ce -= de;
sm4_do_step(sm);
uint16_t delay = SM4_DEFDELAY;
if (sm4_calc_delay_cb) delay = (*sm4_calc_delay_cb)(nd, dd);
if (delay) delayMicroseconds(delay);
nd--;
}
if (sm4_update_pos_cb) (*sm4_update_pos_cb)(x, y, z, e);
return nd;
}
uint16_t sm4_line_xyz_ui(uint16_t dx, uint16_t dy, uint16_t dz){
uint16_t dd = (uint16_t)(sqrt((float)(((uint32_t)dx)*dx + ((uint32_t)dy*dy) + ((uint32_t)dz*dz))) + 0.5);
uint16_t nd = dd;

Some files were not shown because too many files have changed in this diff Show More