diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 8e5358f1cb..6abe5e4e35 100755 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 5.4.2-stable+2022-08-03 +current_version = 5.5.0-stable+2022-11-02 commit = False tag = False parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\-(?P[a-z]+))?\+(?P\d{4}\-\d{2}\-\d{2}) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d3f7f07f5..6ab9beb1f3 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,23 @@ # ADVi3++ Changelog +## 5.5.0 (2022-11-02) + +* **#318** - [Thermal runaway error is not always displayed on the LCD screen](https://github.com/andrivet/ADVi3pp/issues/318) +* **#317** - [G-Code M114 response breaks Octolapse](https://github.com/andrivet/ADVi3pp/issues/317) +* **#313** - [Cancel automatic leveling](https://github.com/andrivet/ADVi3pp/issues/313) +* **#312** - [Detect and prevent bounces](https://github.com/andrivet/ADVi3pp/issues/312) +* **#311** - [Restore Z-offset in Sensor Settings](https://github.com/andrivet/ADVi3pp/issues/311) +* **#310** - [Add steps in BLTouch Tuning for cases when the BLTouch is blinking red](https://github.com/andrivet/ADVi3pp/issues/310) +* **#308** - [Update description of Print Settings pane](https://github.com/andrivet/ADVi3pp/issues/308) +* **#307** - [Versions over 5.0.3 having issues accessing SD card files](https://github.com/andrivet/ADVi3pp/issues/307) +* **#306** - [Fast probing with BLTouch](https://github.com/andrivet/ADVi3pp/issues/306) +* **#293** - [BLTouch - warning on transposed black and white wires](https://github.com/andrivet/ADVi3pp/issues/293) +* **#296** - [Manual jog controls disturb homing function, triggering "Homing failed" hardware error](https://github.com/andrivet/ADVi3pp/issues/296) +* **#294** - [If print menu is accessed while printer is moving, it shows as if it's printing](https://github.com/andrivet/ADVi3pp/issues/294) +* **#267** - [Live Flow Tuning](https://github.com/andrivet/ADVi3pp/issues/267) +* **#238** - [M851 should accept all offset arguments, not just Z offset](https://github.com/andrivet/ADVi3pp/issues/238) +* **#153** - [Graph as default view or GCode to show the graph view](https://github.com/andrivet/ADVi3pp/issues/153) + ## 5.4.2 (2022-08-03) * **#298** - [The computation of the Extruder Tuning is wrong](https://github.com/andrivet/ADVi3pp/issues/298) diff --git a/LCD-Panel/DGUS-root/DWIN_SET/13Touch_Control_Config.bin b/LCD-Panel/DGUS-root/DWIN_SET/13Touch_Control_Config.bin index baef92b116..0f4d75c730 100755 Binary files a/LCD-Panel/DGUS-root/DWIN_SET/13Touch_Control_Config.bin and b/LCD-Panel/DGUS-root/DWIN_SET/13Touch_Control_Config.bin differ diff --git a/LCD-Panel/DGUS-root/DWIN_SET/14Variable_Config.bin b/LCD-Panel/DGUS-root/DWIN_SET/14Variable_Config.bin index 5506999fc0..fb087c6cda 100755 Binary files a/LCD-Panel/DGUS-root/DWIN_SET/14Variable_Config.bin and b/LCD-Panel/DGUS-root/DWIN_SET/14Variable_Config.bin differ diff --git a/LCD-Panel/DGUS-root/DWIN_SET/22_Config.bin b/LCD-Panel/DGUS-root/DWIN_SET/22_Config.bin index 80cd8c6485..b98e7e86db 100755 Binary files a/LCD-Panel/DGUS-root/DWIN_SET/22_Config.bin and b/LCD-Panel/DGUS-root/DWIN_SET/22_Config.bin differ diff --git a/LCD-Panel/DGUS-root/DWIN_SET/25_Controls.ICO b/LCD-Panel/DGUS-root/DWIN_SET/25_Controls.ICO index 762d5288d8..c615e6e0e6 100755 Binary files a/LCD-Panel/DGUS-root/DWIN_SET/25_Controls.ICO and b/LCD-Panel/DGUS-root/DWIN_SET/25_Controls.ICO differ diff --git a/LCD-Panel/DGUS-root/DWprj.hmi b/LCD-Panel/DGUS-root/DWprj.hmi index d9e3033f7c..d5c1ffdeb1 100755 --- a/LCD-Panel/DGUS-root/DWprj.hmi +++ b/LCD-Panel/DGUS-root/DWprj.hmi @@ -27,8 +27,8 @@ SPADDRESS=5000 041=041_sd_card_p.bmp 042=042_print.bmp 043=043_print_p.bmp -044=044_sponsors.bmp -045=045_sponsors_p.bmp +044=044_baby_steps.bmp +045=045_baby_steps_p.bmp 046=046_waiting.bmp 048=048_manual_leveling.bmp 049=049_manual_leveling_p.bmp @@ -93,8 +93,8 @@ SPADDRESS=5000 111=111_linear_advance_settings_p.bmp 112=112_diagnosis.bmp 113=113_diagnosis_p.bmp -114=114_bltouch_testing_1.bmp -115=115_bltouch_testing_1_p.bmp +114=114_bltouch_testing_1a.bmp +115=115_bltouch_testing_1a_p.bmp 116=116_bltouch_testing_2.bmp 117=117_bltouch_testing_2_p.bmp 118=118_bltouch_testing_3.bmp @@ -119,6 +119,10 @@ SPADDRESS=5000 141=141_skew3_p.bmp 142=142_beeper.bmp 143=143_beeper_p.bmp +144=144_automatic_leveling.bmp +145=145_automatic_leveling_p.bmp +146=146_bltouch_testing_1b.bmp +147=147_bltouch_testing_1b_p.bmp 200=200_boot.bmp 201=201_boot.bmp 202=202_boot.bmp diff --git a/LCD-Panel/DGUS-root/TFT/022_main.bmp.tft b/LCD-Panel/DGUS-root/TFT/022_main.bmp.tft index 0c21db5219..19a119575d 100755 Binary files a/LCD-Panel/DGUS-root/TFT/022_main.bmp.tft and b/LCD-Panel/DGUS-root/TFT/022_main.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/024_controls.bmp.tft b/LCD-Panel/DGUS-root/TFT/024_controls.bmp.tft index 0818bc7353..f5e1419971 100755 Binary files a/LCD-Panel/DGUS-root/TFT/024_controls.bmp.tft and b/LCD-Panel/DGUS-root/TFT/024_controls.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/026_tuning.bmp.tft b/LCD-Panel/DGUS-root/TFT/026_tuning.bmp.tft index 8c0a433922..e17024e782 100755 Binary files a/LCD-Panel/DGUS-root/TFT/026_tuning.bmp.tft and b/LCD-Panel/DGUS-root/TFT/026_tuning.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/028_settings.bmp.tft b/LCD-Panel/DGUS-root/TFT/028_settings.bmp.tft index e26133ae19..2ed35560af 100755 Binary files a/LCD-Panel/DGUS-root/TFT/028_settings.bmp.tft and b/LCD-Panel/DGUS-root/TFT/028_settings.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/030_load_unload.bmp.tft b/LCD-Panel/DGUS-root/TFT/030_load_unload.bmp.tft index 5d85b2fce0..e05d875a25 100755 Binary files a/LCD-Panel/DGUS-root/TFT/030_load_unload.bmp.tft and b/LCD-Panel/DGUS-root/TFT/030_load_unload.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/032_wait_back.bmp.tft b/LCD-Panel/DGUS-root/TFT/032_wait_back.bmp.tft index f7e2ba286c..8ccd177513 100755 Binary files a/LCD-Panel/DGUS-root/TFT/032_wait_back.bmp.tft and b/LCD-Panel/DGUS-root/TFT/032_wait_back.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/034_wait_back_continue.bmp.tft b/LCD-Panel/DGUS-root/TFT/034_wait_back_continue.bmp.tft index 536896b9cf..ebe22ef74a 100755 Binary files a/LCD-Panel/DGUS-root/TFT/034_wait_back_continue.bmp.tft and b/LCD-Panel/DGUS-root/TFT/034_wait_back_continue.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/036_preheat.bmp.tft b/LCD-Panel/DGUS-root/TFT/036_preheat.bmp.tft index efccaa1cb3..08979bbace 100755 Binary files a/LCD-Panel/DGUS-root/TFT/036_preheat.bmp.tft and b/LCD-Panel/DGUS-root/TFT/036_preheat.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/038_move.bmp.tft b/LCD-Panel/DGUS-root/TFT/038_move.bmp.tft index b5d6dfd0fc..e2d8f8d79c 100755 Binary files a/LCD-Panel/DGUS-root/TFT/038_move.bmp.tft and b/LCD-Panel/DGUS-root/TFT/038_move.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/040_sd_card.bmp.tft b/LCD-Panel/DGUS-root/TFT/040_sd_card.bmp.tft index 0082de10f9..9908548418 100755 Binary files a/LCD-Panel/DGUS-root/TFT/040_sd_card.bmp.tft and b/LCD-Panel/DGUS-root/TFT/040_sd_card.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/041_sd_card_p.bmp.tft b/LCD-Panel/DGUS-root/TFT/041_sd_card_p.bmp.tft index afabdb3764..0d76dc7c22 100755 Binary files a/LCD-Panel/DGUS-root/TFT/041_sd_card_p.bmp.tft and b/LCD-Panel/DGUS-root/TFT/041_sd_card_p.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/042_print.bmp.tft b/LCD-Panel/DGUS-root/TFT/042_print.bmp.tft index 91a08d740f..f972f74504 100755 Binary files a/LCD-Panel/DGUS-root/TFT/042_print.bmp.tft and b/LCD-Panel/DGUS-root/TFT/042_print.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/044_baby_steps.bmp.tft b/LCD-Panel/DGUS-root/TFT/044_baby_steps.bmp.tft new file mode 100755 index 0000000000..59db8d86f4 Binary files /dev/null and b/LCD-Panel/DGUS-root/TFT/044_baby_steps.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/045_baby_steps_p.bmp.tft b/LCD-Panel/DGUS-root/TFT/045_baby_steps_p.bmp.tft new file mode 100755 index 0000000000..885254e564 Binary files /dev/null and b/LCD-Panel/DGUS-root/TFT/045_baby_steps_p.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/046_waiting.bmp.tft b/LCD-Panel/DGUS-root/TFT/046_waiting.bmp.tft index 5ef86b0f2a..7415e451e5 100755 Binary files a/LCD-Panel/DGUS-root/TFT/046_waiting.bmp.tft and b/LCD-Panel/DGUS-root/TFT/046_waiting.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/048_manual_leveling.bmp.tft b/LCD-Panel/DGUS-root/TFT/048_manual_leveling.bmp.tft index 3b083ae6f2..8e9b0750b0 100755 Binary files a/LCD-Panel/DGUS-root/TFT/048_manual_leveling.bmp.tft and b/LCD-Panel/DGUS-root/TFT/048_manual_leveling.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/050_extruder_tuning_temp.bmp.tft b/LCD-Panel/DGUS-root/TFT/050_extruder_tuning_temp.bmp.tft index 9847a4fbb7..5fa4893f71 100755 Binary files a/LCD-Panel/DGUS-root/TFT/050_extruder_tuning_temp.bmp.tft and b/LCD-Panel/DGUS-root/TFT/050_extruder_tuning_temp.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/052_wait_continue.bmp.tft b/LCD-Panel/DGUS-root/TFT/052_wait_continue.bmp.tft index d2e36f5613..5807199ace 100755 Binary files a/LCD-Panel/DGUS-root/TFT/052_wait_continue.bmp.tft and b/LCD-Panel/DGUS-root/TFT/052_wait_continue.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/054_extruder_measure.bmp.tft b/LCD-Panel/DGUS-root/TFT/054_extruder_measure.bmp.tft index 5b30bfdcc2..dcdd1cb92b 100755 Binary files a/LCD-Panel/DGUS-root/TFT/054_extruder_measure.bmp.tft and b/LCD-Panel/DGUS-root/TFT/054_extruder_measure.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/056_leveling.bmp.tft b/LCD-Panel/DGUS-root/TFT/056_leveling.bmp.tft index 72c4fd5c04..ba562abab8 100755 Binary files a/LCD-Panel/DGUS-root/TFT/056_leveling.bmp.tft and b/LCD-Panel/DGUS-root/TFT/056_leveling.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/058_pid_tuning_1.bmp.tft b/LCD-Panel/DGUS-root/TFT/058_pid_tuning_1.bmp.tft index a79f9b87de..2dbf1a062e 100755 Binary files a/LCD-Panel/DGUS-root/TFT/058_pid_tuning_1.bmp.tft and b/LCD-Panel/DGUS-root/TFT/058_pid_tuning_1.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/060_killed.bmp.tft b/LCD-Panel/DGUS-root/TFT/060_killed.bmp.tft index cddedb3335..540876a135 100755 Binary files a/LCD-Panel/DGUS-root/TFT/060_killed.bmp.tft and b/LCD-Panel/DGUS-root/TFT/060_killed.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/062_motors_settings.bmp.tft b/LCD-Panel/DGUS-root/TFT/062_motors_settings.bmp.tft index 5dea8ae682..a06efe0843 100755 Binary files a/LCD-Panel/DGUS-root/TFT/062_motors_settings.bmp.tft and b/LCD-Panel/DGUS-root/TFT/062_motors_settings.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/064_pid_settings.bmp.tft b/LCD-Panel/DGUS-root/TFT/064_pid_settings.bmp.tft index 369b58c3dc..635d4c6f52 100755 Binary files a/LCD-Panel/DGUS-root/TFT/064_pid_settings.bmp.tft and b/LCD-Panel/DGUS-root/TFT/064_pid_settings.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/066_factory_reset.bmp.tft b/LCD-Panel/DGUS-root/TFT/066_factory_reset.bmp.tft index 131785529c..04262c060b 100755 Binary files a/LCD-Panel/DGUS-root/TFT/066_factory_reset.bmp.tft and b/LCD-Panel/DGUS-root/TFT/066_factory_reset.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/068_statistics.bmp.tft b/LCD-Panel/DGUS-root/TFT/068_statistics.bmp.tft index 25e90b5d91..8be11b6b83 100755 Binary files a/LCD-Panel/DGUS-root/TFT/068_statistics.bmp.tft and b/LCD-Panel/DGUS-root/TFT/068_statistics.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/070_versions.bmp.tft b/LCD-Panel/DGUS-root/TFT/070_versions.bmp.tft index e907e31355..bb226e7360 100755 Binary files a/LCD-Panel/DGUS-root/TFT/070_versions.bmp.tft and b/LCD-Panel/DGUS-root/TFT/070_versions.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/072_steps_settings.bmp.tft b/LCD-Panel/DGUS-root/TFT/072_steps_settings.bmp.tft index 9e975eeff3..894c58dc6c 100755 Binary files a/LCD-Panel/DGUS-root/TFT/072_steps_settings.bmp.tft and b/LCD-Panel/DGUS-root/TFT/072_steps_settings.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/074_feedrate_settings.bmp.tft b/LCD-Panel/DGUS-root/TFT/074_feedrate_settings.bmp.tft index 2d8c3b80f6..b4bb2eb482 100755 Binary files a/LCD-Panel/DGUS-root/TFT/074_feedrate_settings.bmp.tft and b/LCD-Panel/DGUS-root/TFT/074_feedrate_settings.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/076_acceleration_settings.bmp.tft b/LCD-Panel/DGUS-root/TFT/076_acceleration_settings.bmp.tft index 8213d25707..5ee9c30eb7 100755 Binary files a/LCD-Panel/DGUS-root/TFT/076_acceleration_settings.bmp.tft and b/LCD-Panel/DGUS-root/TFT/076_acceleration_settings.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/078_pause_options.bmp.tft b/LCD-Panel/DGUS-root/TFT/078_pause_options.bmp.tft index 0e3d9b5f4a..c126b20694 100755 Binary files a/LCD-Panel/DGUS-root/TFT/078_pause_options.bmp.tft and b/LCD-Panel/DGUS-root/TFT/078_pause_options.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/080_print_settings.bmp.tft b/LCD-Panel/DGUS-root/TFT/080_print_settings.bmp.tft index 2dd855fb5b..d6b06a2d85 100755 Binary files a/LCD-Panel/DGUS-root/TFT/080_print_settings.bmp.tft and b/LCD-Panel/DGUS-root/TFT/080_print_settings.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/082_setup.bmp.tft b/LCD-Panel/DGUS-root/TFT/082_setup.bmp.tft index 28f3ca155e..861ab425b3 100755 Binary files a/LCD-Panel/DGUS-root/TFT/082_setup.bmp.tft and b/LCD-Panel/DGUS-root/TFT/082_setup.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/084_setup_no_sensor.bmp.tft b/LCD-Panel/DGUS-root/TFT/084_setup_no_sensor.bmp.tft index d0b71ed27d..185c2d4ef2 100755 Binary files a/LCD-Panel/DGUS-root/TFT/084_setup_no_sensor.bmp.tft and b/LCD-Panel/DGUS-root/TFT/084_setup_no_sensor.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/086_temperature.bmp.tft b/LCD-Panel/DGUS-root/TFT/086_temperature.bmp.tft index 15ee01e960..befcb4f627 100755 Binary files a/LCD-Panel/DGUS-root/TFT/086_temperature.bmp.tft and b/LCD-Panel/DGUS-root/TFT/086_temperature.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/088_info.bmp.tft b/LCD-Panel/DGUS-root/TFT/088_info.bmp.tft index 5357416a17..80e90d16a3 100755 Binary files a/LCD-Panel/DGUS-root/TFT/088_info.bmp.tft and b/LCD-Panel/DGUS-root/TFT/088_info.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/090_vibrations_tuning.bmp.tft b/LCD-Panel/DGUS-root/TFT/090_vibrations_tuning.bmp.tft index 5cdfc91952..ab1b93b54f 100755 Binary files a/LCD-Panel/DGUS-root/TFT/090_vibrations_tuning.bmp.tft and b/LCD-Panel/DGUS-root/TFT/090_vibrations_tuning.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/092_no_sensor.bmp.tft b/LCD-Panel/DGUS-root/TFT/092_no_sensor.bmp.tft index 511a2b2300..47f23bc4aa 100755 Binary files a/LCD-Panel/DGUS-root/TFT/092_no_sensor.bmp.tft and b/LCD-Panel/DGUS-root/TFT/092_no_sensor.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/094_sensor_settings.bmp.tft b/LCD-Panel/DGUS-root/TFT/094_sensor_settings.bmp.tft index d6ce0d6b3f..40957bc6a6 100755 Binary files a/LCD-Panel/DGUS-root/TFT/094_sensor_settings.bmp.tft and b/LCD-Panel/DGUS-root/TFT/094_sensor_settings.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/096_LCD.bmp.tft b/LCD-Panel/DGUS-root/TFT/096_LCD.bmp.tft index 8b76984e47..451e747e7d 100755 Binary files a/LCD-Panel/DGUS-root/TFT/096_LCD.bmp.tft and b/LCD-Panel/DGUS-root/TFT/096_LCD.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/098_copyrights.bmp.tft b/LCD-Panel/DGUS-root/TFT/098_copyrights.bmp.tft index 87d469c66d..7bd57a3850 100755 Binary files a/LCD-Panel/DGUS-root/TFT/098_copyrights.bmp.tft and b/LCD-Panel/DGUS-root/TFT/098_copyrights.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/102_sensor_grid.bmp.tft b/LCD-Panel/DGUS-root/TFT/102_sensor_grid.bmp.tft index bc7ac5fe6e..be88dd4d32 100755 Binary files a/LCD-Panel/DGUS-root/TFT/102_sensor_grid.bmp.tft and b/LCD-Panel/DGUS-root/TFT/102_sensor_grid.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/104_eeprom_mismatch.bmp.tft b/LCD-Panel/DGUS-root/TFT/104_eeprom_mismatch.bmp.tft index 4793630d2e..a82c508d24 100755 Binary files a/LCD-Panel/DGUS-root/TFT/104_eeprom_mismatch.bmp.tft and b/LCD-Panel/DGUS-root/TFT/104_eeprom_mismatch.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/106_z_height.bmp.tft b/LCD-Panel/DGUS-root/TFT/106_z_height.bmp.tft index a0d56675ef..3403c2ae3e 100755 Binary files a/LCD-Panel/DGUS-root/TFT/106_z_height.bmp.tft and b/LCD-Panel/DGUS-root/TFT/106_z_height.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/110_linear_advance_settings.bmp.tft b/LCD-Panel/DGUS-root/TFT/110_linear_advance_settings.bmp.tft index d9b2ff3702..fcefbdaa80 100755 Binary files a/LCD-Panel/DGUS-root/TFT/110_linear_advance_settings.bmp.tft and b/LCD-Panel/DGUS-root/TFT/110_linear_advance_settings.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/112_diagnosis.bmp.tft b/LCD-Panel/DGUS-root/TFT/112_diagnosis.bmp.tft index d1f95cee66..0bdec4bd20 100755 Binary files a/LCD-Panel/DGUS-root/TFT/112_diagnosis.bmp.tft and b/LCD-Panel/DGUS-root/TFT/112_diagnosis.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/114_bltouch_testing_1.bmp.tft b/LCD-Panel/DGUS-root/TFT/114_bltouch_testing_1.bmp.tft index 126ea21d34..f2c2f4048f 100755 Binary files a/LCD-Panel/DGUS-root/TFT/114_bltouch_testing_1.bmp.tft and b/LCD-Panel/DGUS-root/TFT/114_bltouch_testing_1.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/114_bltouch_testing_1a.bmp.tft b/LCD-Panel/DGUS-root/TFT/114_bltouch_testing_1a.bmp.tft new file mode 100755 index 0000000000..049bcaa12f Binary files /dev/null and b/LCD-Panel/DGUS-root/TFT/114_bltouch_testing_1a.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/115_bltouch_testing_1a_p.bmp.tft b/LCD-Panel/DGUS-root/TFT/115_bltouch_testing_1a_p.bmp.tft new file mode 100755 index 0000000000..b361058959 Binary files /dev/null and b/LCD-Panel/DGUS-root/TFT/115_bltouch_testing_1a_p.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/116_bltouch_testing_2.bmp.tft b/LCD-Panel/DGUS-root/TFT/116_bltouch_testing_2.bmp.tft index c6e95814bf..e5231e13fc 100755 Binary files a/LCD-Panel/DGUS-root/TFT/116_bltouch_testing_2.bmp.tft and b/LCD-Panel/DGUS-root/TFT/116_bltouch_testing_2.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/118_bltouch_testing_3.bmp.tft b/LCD-Panel/DGUS-root/TFT/118_bltouch_testing_3.bmp.tft index b2c03cf6b2..f9ca21cacb 100755 Binary files a/LCD-Panel/DGUS-root/TFT/118_bltouch_testing_3.bmp.tft and b/LCD-Panel/DGUS-root/TFT/118_bltouch_testing_3.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/120_bltouch_testing_4.bmp.tft b/LCD-Panel/DGUS-root/TFT/120_bltouch_testing_4.bmp.tft index 0d5ff7f5d2..62e3b946af 100755 Binary files a/LCD-Panel/DGUS-root/TFT/120_bltouch_testing_4.bmp.tft and b/LCD-Panel/DGUS-root/TFT/120_bltouch_testing_4.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/127_signed_keyboard_decimal_p.bmp.tft b/LCD-Panel/DGUS-root/TFT/127_signed_keyboard_decimal_p.bmp.tft index 2a2bb3c9a6..939de28844 100755 Binary files a/LCD-Panel/DGUS-root/TFT/127_signed_keyboard_decimal_p.bmp.tft and b/LCD-Panel/DGUS-root/TFT/127_signed_keyboard_decimal_p.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/132_x_twist.bmp.tft b/LCD-Panel/DGUS-root/TFT/132_x_twist.bmp.tft index 1848fa5dc4..8f396cceeb 100755 Binary files a/LCD-Panel/DGUS-root/TFT/132_x_twist.bmp.tft and b/LCD-Panel/DGUS-root/TFT/132_x_twist.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/134_runout.bmp.tft b/LCD-Panel/DGUS-root/TFT/134_runout.bmp.tft index cbdbf6f51b..456b2559cf 100755 Binary files a/LCD-Panel/DGUS-root/TFT/134_runout.bmp.tft and b/LCD-Panel/DGUS-root/TFT/134_runout.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/136_skew1.bmp.tft b/LCD-Panel/DGUS-root/TFT/136_skew1.bmp.tft index cd2559a6bb..e8bb8ed6ae 100755 Binary files a/LCD-Panel/DGUS-root/TFT/136_skew1.bmp.tft and b/LCD-Panel/DGUS-root/TFT/136_skew1.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/138_skew2.bmp.tft b/LCD-Panel/DGUS-root/TFT/138_skew2.bmp.tft index b70c3540a3..b973a5e7ca 100755 Binary files a/LCD-Panel/DGUS-root/TFT/138_skew2.bmp.tft and b/LCD-Panel/DGUS-root/TFT/138_skew2.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/140_skew3.bmp.tft b/LCD-Panel/DGUS-root/TFT/140_skew3.bmp.tft index 830b651ca5..0b916f82c6 100755 Binary files a/LCD-Panel/DGUS-root/TFT/140_skew3.bmp.tft and b/LCD-Panel/DGUS-root/TFT/140_skew3.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/142_beeper.bmp.tft b/LCD-Panel/DGUS-root/TFT/142_beeper.bmp.tft index e6c40f05b2..c9e11d5cba 100755 Binary files a/LCD-Panel/DGUS-root/TFT/142_beeper.bmp.tft and b/LCD-Panel/DGUS-root/TFT/142_beeper.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/144_automatic_leveling.bmp.tft b/LCD-Panel/DGUS-root/TFT/144_automatic_leveling.bmp.tft new file mode 100755 index 0000000000..336819d1c5 Binary files /dev/null and b/LCD-Panel/DGUS-root/TFT/144_automatic_leveling.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/145_automatic_leveling_p.bmp.tft b/LCD-Panel/DGUS-root/TFT/145_automatic_leveling_p.bmp.tft new file mode 100755 index 0000000000..792d8c786f Binary files /dev/null and b/LCD-Panel/DGUS-root/TFT/145_automatic_leveling_p.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/146_bltouch_testing_1b.bmp.tft b/LCD-Panel/DGUS-root/TFT/146_bltouch_testing_1b.bmp.tft new file mode 100755 index 0000000000..f81a912488 Binary files /dev/null and b/LCD-Panel/DGUS-root/TFT/146_bltouch_testing_1b.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/147_bltouch_testing_1b_p.bmp.tft b/LCD-Panel/DGUS-root/TFT/147_bltouch_testing_1b_p.bmp.tft new file mode 100755 index 0000000000..34551fbe69 Binary files /dev/null and b/LCD-Panel/DGUS-root/TFT/147_bltouch_testing_1b_p.bmp.tft differ diff --git a/LCD-Panel/DGUS-root/TFT/206_boot.bmp.tft b/LCD-Panel/DGUS-root/TFT/206_boot.bmp.tft index e50d73385d..37b0aee880 100755 Binary files a/LCD-Panel/DGUS-root/TFT/206_boot.bmp.tft and b/LCD-Panel/DGUS-root/TFT/206_boot.bmp.tft differ diff --git a/LCD-Panel/Masters/ADVi3++5 LCD-Panel.sketch b/LCD-Panel/Masters/ADVi3++5 LCD-Panel.sketch index c10e6f5faa..56a50f44d3 100755 Binary files a/LCD-Panel/Masters/ADVi3++5 LCD-Panel.sketch and b/LCD-Panel/Masters/ADVi3++5 LCD-Panel.sketch differ diff --git a/LCD-Panel/Masters/Boot.afdesign b/LCD-Panel/Masters/Boot.afdesign index a25ca2be23..e3bf8bbd2f 100644 Binary files a/LCD-Panel/Masters/Boot.afdesign and b/LCD-Panel/Masters/Boot.afdesign differ diff --git a/LCD-Panel/Masters/Boot.png b/LCD-Panel/Masters/Boot.png index f62917969f..3565f00213 100644 Binary files a/LCD-Panel/Masters/Boot.png and b/LCD-Panel/Masters/Boot.png differ diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index a8bf7eeae1..b1b14643ee 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -38,7 +38,7 @@ * * Advanced settings can be found in Configuration_adv.h */ -#define CONFIGURATION_H_VERSION 02010000 +#define CONFIGURATION_H_VERSION 02010100 //=========================================================================== //============================= Getting Started ============================= @@ -60,15 +60,6 @@ * https://www.thingiverse.com/thing:1278865 */ -//=========================================================================== -//========================== DELTA / SCARA / TPARA ========================== -//=========================================================================== -// -// Download configurations from the link above and customize for your machine. -// Examples are located in config/examples/delta, .../SCARA, and .../TPARA. -// -//=========================================================================== - // @section info // Author info of this build printed to the host during boot and M115 @@ -140,7 +131,7 @@ * :[-2, -1, 0, 1, 2, 3, 4, 5, 6, 7] */ //#define SERIAL_PORT_2 -1 -//#define BAUDRATE_2 250000 // Enable to override BAUDRATE +//#define BAUDRATE_2 250000 // :[2400, 9600, 19200, 38400, 57600, 115200, 250000, 500000, 1000000] Enable to override BAUDRATE /** * Select a third serial port on the board to use for communication with the host. @@ -148,7 +139,7 @@ * :[-1, 0, 1, 2, 3, 4, 5, 6, 7] */ //#define SERIAL_PORT_3 1 -//#define BAUDRATE_3 250000 // Enable to override BAUDRATE +//#define BAUDRATE_3 250000 // :[2400, 9600, 19200, 38400, 57600, 115200, 250000, 500000, 1000000] Enable to override BAUDRATE // Enable the Bluetooth serial interface on AT90USB devices //#define BLUETOOTH @@ -168,13 +159,12 @@ * * Use TMC2208/TMC2208_STANDALONE for TMC2225 drivers and TMC2209/TMC2209_STANDALONE for TMC2226 drivers. * - * Options: A4988, A5984, DRV8825, LV8729, L6470, L6474, POWERSTEP01, - * TB6560, TB6600, TMC2100, + * Options: A4988, A5984, DRV8825, LV8729, TB6560, TB6600, TMC2100, * TMC2130, TMC2130_STANDALONE, TMC2160, TMC2160_STANDALONE, * TMC2208, TMC2208_STANDALONE, TMC2209, TMC2209_STANDALONE, * TMC26X, TMC26X_STANDALONE, TMC2660, TMC2660_STANDALONE, * TMC5130, TMC5130_STANDALONE, TMC5160, TMC5160_STANDALONE - * :['A4988', 'A5984', 'DRV8825', 'LV8729', 'L6470', 'L6474', 'POWERSTEP01', 'TB6560', 'TB6600', 'TMC2100', 'TMC2130', 'TMC2130_STANDALONE', 'TMC2160', 'TMC2160_STANDALONE', 'TMC2208', 'TMC2208_STANDALONE', 'TMC2209', 'TMC2209_STANDALONE', 'TMC26X', 'TMC26X_STANDALONE', 'TMC2660', 'TMC2660_STANDALONE', 'TMC5130', 'TMC5130_STANDALONE', 'TMC5160', 'TMC5160_STANDALONE'] + * :['A4988', 'A5984', 'DRV8825', 'LV8729', 'TB6560', 'TB6600', 'TMC2100', 'TMC2130', 'TMC2130_STANDALONE', 'TMC2160', 'TMC2160_STANDALONE', 'TMC2208', 'TMC2208_STANDALONE', 'TMC2209', 'TMC2209_STANDALONE', 'TMC26X', 'TMC26X_STANDALONE', 'TMC2660', 'TMC2660_STANDALONE', 'TMC5130', 'TMC5130_STANDALONE', 'TMC5160', 'TMC5160_STANDALONE'] */ #define X_DRIVER_TYPE A4988 #define Y_DRIVER_TYPE A4988 @@ -292,6 +282,7 @@ #define SWITCHING_NOZZLE_SERVO_NR 0 //#define SWITCHING_NOZZLE_E1_SERVO_NR 1 // If two servos are used, the index of the second #define SWITCHING_NOZZLE_SERVO_ANGLES { 0, 90 } // Angles for E0, E1 (single servo) or lowered/raised (dual servo) + #define SWITCHING_NOZZLE_SERVO_DWELL 2500 // Dwell time to wait for servo to make physical move #endif /** @@ -408,7 +399,7 @@ //#define HOTEND_OFFSET_Y { 0.0, 5.00 } // (mm) relative Y-offset for each nozzle //#define HOTEND_OFFSET_Z { 0.0, 0.00 } // (mm) relative Z-offset for each nozzle -// @section machine +// @section psu control /** * Power Supply Control @@ -570,22 +561,32 @@ #define DUMMY_THERMISTOR_999_VALUE 100 // Resistor values when using MAX31865 sensors (-5) on TEMP_SENSOR_0 / 1 -//#define MAX31865_SENSOR_OHMS_0 100 // (Ω) Typically 100 or 1000 (PT100 or PT1000) -//#define MAX31865_CALIBRATION_OHMS_0 430 // (Ω) Typically 430 for Adafruit PT100; 4300 for Adafruit PT1000 -//#define MAX31865_SENSOR_OHMS_1 100 -//#define MAX31865_CALIBRATION_OHMS_1 430 +#if TEMP_SENSOR_IS_MAX_TC(0) + #define MAX31865_SENSOR_OHMS_0 100 // (Ω) Typically 100 or 1000 (PT100 or PT1000) + #define MAX31865_CALIBRATION_OHMS_0 430 // (Ω) Typically 430 for Adafruit PT100; 4300 for Adafruit PT1000 +#endif +#if TEMP_SENSOR_IS_MAX_TC(1) + #define MAX31865_SENSOR_OHMS_1 100 + #define MAX31865_CALIBRATION_OHMS_1 430 +#endif -#define TEMP_RESIDENCY_TIME 10 // (seconds) Time to wait for hotend to "settle" in M109 -#define TEMP_WINDOW 1 // (°C) Temperature proximity for the "temperature reached" timer -#define TEMP_HYSTERESIS 3 // (°C) Temperature proximity considered "close enough" to the target +#if HAS_E_TEMP_SENSOR + #define TEMP_RESIDENCY_TIME 10 // (seconds) Time to wait for hotend to "settle" in M109 + #define TEMP_WINDOW 1 // (°C) Temperature proximity for the "temperature reached" timer + #define TEMP_HYSTERESIS 3 // (°C) Temperature proximity considered "close enough" to the target +#endif -#define TEMP_BED_RESIDENCY_TIME 10 // (seconds) Time to wait for bed to "settle" in M190 -#define TEMP_BED_WINDOW 1 // (°C) Temperature proximity for the "temperature reached" timer -#define TEMP_BED_HYSTERESIS 3 // (°C) Temperature proximity considered "close enough" to the target +#if TEMP_SENSOR_BED + #define TEMP_BED_RESIDENCY_TIME 10 // (seconds) Time to wait for bed to "settle" in M190 + #define TEMP_BED_WINDOW 1 // (°C) Temperature proximity for the "temperature reached" timer + #define TEMP_BED_HYSTERESIS 3 // (°C) Temperature proximity considered "close enough" to the target +#endif -#define TEMP_CHAMBER_RESIDENCY_TIME 10 // (seconds) Time to wait for chamber to "settle" in M191 -#define TEMP_CHAMBER_WINDOW 1 // (°C) Temperature proximity for the "temperature reached" timer -#define TEMP_CHAMBER_HYSTERESIS 3 // (°C) Temperature proximity considered "close enough" to the target +#if TEMP_SENSOR_CHAMBER + #define TEMP_CHAMBER_RESIDENCY_TIME 10 // (seconds) Time to wait for chamber to "settle" in M191 + #define TEMP_CHAMBER_WINDOW 1 // (°C) Temperature proximity for the "temperature reached" timer + #define TEMP_CHAMBER_HYSTERESIS 3 // (°C) Temperature proximity considered "close enough" to the target +#endif /** * Redundant Temperature Sensor (TEMP_SENSOR_REDUNDANT) @@ -644,6 +645,8 @@ //============================= PID Settings ================================ //=========================================================================== +// @section hotend temp + // Enable PIDTEMP for PID control or MPCTEMP for Predictive Model. // temperature control. Disable both for bang-bang heating. #define PIDTEMP // See the PID Tuning Guide at https://reprap.org/wiki/PID_Tuning @@ -654,7 +657,8 @@ #define PID_K1 0.95 // Smoothing factor within any PID loop #if ENABLED(PIDTEMP) - //#define PID_PARAMS_PER_HOTEND // Uses separate PID parameters for each extruder (useful for mismatched extruders) + //#define PID_DEBUG // Print PID debug data to the serial port. Use 'M303 D' to toggle activation. + //#define PID_PARAMS_PER_HOTEND // Use separate PID parameters for each extruder (useful for mismatched extruders) // Set/get with G-code: M301 E[extruder number, 0-2] #if ENABLED(PID_PARAMS_PER_HOTEND) @@ -676,7 +680,8 @@ * * Use a physical model of the hotend to control temperature. When configured correctly * this gives better responsiveness and stability than PID and it also removes the need - * for PID_EXTRUSION_SCALING and PID_FAN_SCALING. Use M306 to autotune the model. + * for PID_EXTRUSION_SCALING and PID_FAN_SCALING. Use M306 T to autotune the model. + * @section mpctemp */ #if ENABLED(MPCTEMP) //#define MPC_EDIT_MENU // Add MPC editing to the "Advanced Settings" menu. (~1300 bytes of flash) @@ -729,6 +734,7 @@ * impact FET heating. This also works fine on a Fotek SSR-10DA Solid State Relay into a 250W * heater. If your configuration is significantly different than this and you don't understand * the issues involved, don't use bed PID until someone else verifies that your hardware works. + * @section bed temp */ // @advi3++: Enable Bed PID #define PIDTEMPBED @@ -745,7 +751,7 @@ #if ENABLED(PIDTEMPBED) //#define MIN_BED_POWER 0 - //#define PID_BED_DEBUG // Sends debug data to the serial port. + //#define PID_BED_DEBUG // Print Bed PID debug data to the serial port. // @advi3++: Wanhao Duplicator i3 Plus #define DEFAULT_bedKp 333.66 @@ -778,6 +784,7 @@ * impact FET heating. This also works fine on a Fotek SSR-10DA Solid State Relay into a 200W * heater. If your configuration is significantly different than this and you don't understand * the issues involved, don't use chamber PID until someone else verifies that your hardware works. + * @section chamber temp */ //#define PIDTEMPCHAMBER //#define CHAMBER_LIMIT_SWITCHING @@ -792,7 +799,7 @@ #if ENABLED(PIDTEMPCHAMBER) #define MIN_CHAMBER_POWER 0 - //#define PID_CHAMBER_DEBUG // Sends debug data to the serial port. + //#define PID_CHAMBER_DEBUG // Print Chamber PID debug data to the serial port. // Lasko "MyHeat Personal Heater" (200w) modified with a Fotek SSR-10DA to control only the heating element // and placed inside the small Creality printer enclosure tent. @@ -806,7 +813,6 @@ #endif // PIDTEMPCHAMBER #if ANY(PIDTEMP, PIDTEMPBED, PIDTEMPCHAMBER) - //#define PID_DEBUG // Sends debug data to the serial port. Use 'M303 D' to toggle activation. //#define PID_OPENLOOP // Puts PID in open loop. M104/M140 sets the output power from 0 to PID_MAX //#define SLOW_PWM_HEATERS // PWM with very low frequency (roughly 0.125Hz=8s) and minimum state time of approximately 1s useful for heaters driven by a relay #define PID_FUNCTIONAL_RANGE 10 // If the temperature difference between the target temperature and the actual temperature @@ -816,7 +822,7 @@ //#define PID_AUTOTUNE_MENU // Add PID auto-tuning to the "Advanced Settings" menu. (~250 bytes of flash) #endif -// @section extruder +// @section safety /** * Prevent extrusion if the temperature is below EXTRUDE_MINTEMP. @@ -884,7 +890,143 @@ #define POLAR_SEGMENTS_PER_SECOND 5 #endif -// Enable for an articulated robot (robot arm). Joints are directly mapped to axes (no kinematics). +// @section delta + +// Enable for DELTA kinematics and configure below +//#define DELTA +#if ENABLED(DELTA) + + // Make delta curves from many straight lines (linear interpolation). + // This is a trade-off between visible corners (not enough segments) + // and processor overload (too many expensive sqrt calls). + #define DELTA_SEGMENTS_PER_SECOND 200 + + // After homing move down to a height where XY movement is unconstrained + //#define DELTA_HOME_TO_SAFE_ZONE + + // Delta calibration menu + // uncomment to add three points calibration menu option. + // See http://minow.blogspot.com/index.html#4918805519571907051 + //#define DELTA_CALIBRATION_MENU + + // uncomment to add G33 Delta Auto-Calibration (Enable EEPROM_SETTINGS to store results) + //#define DELTA_AUTO_CALIBRATION + + // NOTE NB all values for DELTA_* values MUST be floating point, so always have a decimal point in them + + #if ENABLED(DELTA_AUTO_CALIBRATION) + // set the default number of probe points : n*n (1 -> 7) + #define DELTA_CALIBRATION_DEFAULT_POINTS 4 + #endif + + #if EITHER(DELTA_AUTO_CALIBRATION, DELTA_CALIBRATION_MENU) + // Set the steprate for papertest probing + #define PROBE_MANUALLY_STEP 0.05 // (mm) + #endif + + // Print surface diameter/2 minus unreachable space (avoid collisions with vertical towers). + #define DELTA_PRINTABLE_RADIUS 140.0 // (mm) + + // Maximum reachable area + #define DELTA_MAX_RADIUS 140.0 // (mm) + + // Center-to-center distance of the holes in the diagonal push rods. + #define DELTA_DIAGONAL_ROD 250.0 // (mm) + + // Distance between bed and nozzle Z home position + #define DELTA_HEIGHT 250.00 // (mm) Get this value from G33 auto calibrate + + #define DELTA_ENDSTOP_ADJ { 0.0, 0.0, 0.0 } // Get these values from G33 auto calibrate + + // Horizontal distance bridged by diagonal push rods when effector is centered. + #define DELTA_RADIUS 124.0 // (mm) Get this value from G33 auto calibrate + + // Trim adjustments for individual towers + // tower angle corrections for X and Y tower / rotate XYZ so Z tower angle = 0 + // measured in degrees anticlockwise looking from above the printer + #define DELTA_TOWER_ANGLE_TRIM { 0.0, 0.0, 0.0 } // Get these values from G33 auto calibrate + + // Delta radius and diagonal rod adjustments (mm) + //#define DELTA_RADIUS_TRIM_TOWER { 0.0, 0.0, 0.0 } + //#define DELTA_DIAGONAL_ROD_TRIM_TOWER { 0.0, 0.0, 0.0 } +#endif + +// @section scara + +/** + * MORGAN_SCARA was developed by QHARLEY in South Africa in 2012-2013. + * Implemented and slightly reworked by JCERNY in June, 2014. + * + * Mostly Printed SCARA is an open source design by Tyler Williams. See: + * https://www.thingiverse.com/thing:2487048 + * https://www.thingiverse.com/thing:1241491 + */ +//#define MORGAN_SCARA +//#define MP_SCARA +#if EITHER(MORGAN_SCARA, MP_SCARA) + // If movement is choppy try lowering this value + #define SCARA_SEGMENTS_PER_SECOND 200 + + // Length of inner and outer support arms. Measure arm lengths precisely. + #define SCARA_LINKAGE_1 150 // (mm) + #define SCARA_LINKAGE_2 150 // (mm) + + // SCARA tower offset (position of Tower relative to bed zero position) + // This needs to be reasonably accurate as it defines the printbed position in the SCARA space. + #define SCARA_OFFSET_X 100 // (mm) + #define SCARA_OFFSET_Y -56 // (mm) + + #if ENABLED(MORGAN_SCARA) + + //#define DEBUG_SCARA_KINEMATICS + #define SCARA_FEEDRATE_SCALING // Convert XY feedrate from mm/s to degrees/s on the fly + + // Radius around the center where the arm cannot reach + #define MIDDLE_DEAD_ZONE_R 0 // (mm) + + #define THETA_HOMING_OFFSET 0 // Calculated from Calibration Guide and M360 / M114. See http://reprap.harleystudio.co.za/?page_id=1073 + #define PSI_HOMING_OFFSET 0 // Calculated from Calibration Guide and M364 / M114. See http://reprap.harleystudio.co.za/?page_id=1073 + + #elif ENABLED(MP_SCARA) + + #define SCARA_OFFSET_THETA1 12 // degrees + #define SCARA_OFFSET_THETA2 131 // degrees + + #endif + +#endif + +// @section tpara + +// Enable for TPARA kinematics and configure below +//#define AXEL_TPARA +#if ENABLED(AXEL_TPARA) + #define DEBUG_ROBOT_KINEMATICS + #define ROBOT_SEGMENTS_PER_SECOND 200 + + // Length of inner and outer support arms. Measure arm lengths precisely. + #define ROBOT_LINKAGE_1 120 // (mm) + #define ROBOT_LINKAGE_2 120 // (mm) + + // SCARA tower offset (position of Tower relative to bed zero position) + // This needs to be reasonably accurate as it defines the printbed position in the SCARA space. + #define ROBOT_OFFSET_X 0 // (mm) + #define ROBOT_OFFSET_Y 0 // (mm) + #define ROBOT_OFFSET_Z 0 // (mm) + + #define SCARA_FEEDRATE_SCALING // Convert XY feedrate from mm/s to degrees/s on the fly + + // Radius around the center where the arm cannot reach + #define MIDDLE_DEAD_ZONE_R 0 // (mm) + + // Calculated from Calibration Guide and M360 / M114. See http://reprap.harleystudio.co.za/?page_id=1073 + #define THETA_HOMING_OFFSET 0 + #define PSI_HOMING_OFFSET 0 +#endif + +// @section machine + +// Articulated robot (arm). Joints are directly mapped to axes with no kinematics. //#define ARTICULATED_ROBOT_ARM // For a hot wire cutter with parallel horizontal axes (X, I) where the heights of the two wire @@ -895,7 +1037,7 @@ //============================== Endstop Settings =========================== //=========================================================================== -// @section homing +// @section endstops // Specify here all the endstop connectors that are connected to any endstop or probe. // Almost all printers will be using one per axis. Probes will use one or more of the @@ -1055,7 +1197,7 @@ * X, Y, Z [, I [, J [, K...]]], E0 [, E1[, E2...]] */ // @advi3++: Set reasonable default values for Wanhao i3 Plus -#define DEFAULT_MAX_FEEDRATE { 450, 450, 5, 25 } +#define DEFAULT_MAX_FEEDRATE { 450, 450, 10, 25 } //#define LIMITED_MAX_FR_EDITING // Limit edit via M203 or LCD to DEFAULT_MAX_FEEDRATE * 2 #if ENABLED(LIMITED_MAX_FR_EDITING) @@ -1264,6 +1406,27 @@ #define Z_PROBE_RETRACT_X X_MAX_POS #endif +/** + * Magnetically Mounted Probe + * For probes such as Euclid, Klicky, Klackender, etc. + */ +//#define MAG_MOUNTED_PROBE +#if ENABLED(MAG_MOUNTED_PROBE) + #define PROBE_DEPLOY_FEEDRATE (133*60) // (mm/min) Probe deploy speed + #define PROBE_STOW_FEEDRATE (133*60) // (mm/min) Probe stow speed + + #define MAG_MOUNTED_DEPLOY_1 { PROBE_DEPLOY_FEEDRATE, { 245, 114, 30 } } // Move to side Dock & Attach probe + #define MAG_MOUNTED_DEPLOY_2 { PROBE_DEPLOY_FEEDRATE, { 210, 114, 30 } } // Move probe off dock + #define MAG_MOUNTED_DEPLOY_3 { PROBE_DEPLOY_FEEDRATE, { 0, 0, 0 } } // Extra move if needed + #define MAG_MOUNTED_DEPLOY_4 { PROBE_DEPLOY_FEEDRATE, { 0, 0, 0 } } // Extra move if needed + #define MAG_MOUNTED_DEPLOY_5 { PROBE_DEPLOY_FEEDRATE, { 0, 0, 0 } } // Extra move if needed + #define MAG_MOUNTED_STOW_1 { PROBE_STOW_FEEDRATE, { 245, 114, 20 } } // Move to dock + #define MAG_MOUNTED_STOW_2 { PROBE_STOW_FEEDRATE, { 245, 114, 0 } } // Place probe beside remover + #define MAG_MOUNTED_STOW_3 { PROBE_STOW_FEEDRATE, { 230, 114, 0 } } // Side move to remove probe + #define MAG_MOUNTED_STOW_4 { PROBE_STOW_FEEDRATE, { 210, 114, 20 } } // Side move to remove probe + #define MAG_MOUNTED_STOW_5 { PROBE_STOW_FEEDRATE, { 0, 0, 0 } } // Extra move if needed +#endif + // Duet Smart Effector (for delta printers) - https://bit.ly/2ul5U7J // When the pin is defined you can use M672 to set/reset the probe sensitivity. //#define DUET_SMART_EFFECTOR @@ -1279,9 +1442,37 @@ */ //#define SENSORLESS_PROBING -// -// For Z_PROBE_ALLEN_KEY see the Delta example configurations. -// +/** + * Allen key retractable z-probe as seen on many Kossel delta printers - https://reprap.org/wiki/Kossel#Automatic_bed_leveling_probe + * Deploys by touching z-axis belt. Retracts by pushing the probe down. + */ +//#define Z_PROBE_ALLEN_KEY +#if ENABLED(Z_PROBE_ALLEN_KEY) + // 2 or 3 sets of coordinates for deploying and retracting the spring loaded touch probe on G29, + // if servo actuated touch probe is not defined. Uncomment as appropriate for your printer/probe. + + #define Z_PROBE_ALLEN_KEY_DEPLOY_1 { 30.0, DELTA_PRINTABLE_RADIUS, 100.0 } + #define Z_PROBE_ALLEN_KEY_DEPLOY_1_FEEDRATE XY_PROBE_FEEDRATE + + #define Z_PROBE_ALLEN_KEY_DEPLOY_2 { 0.0, DELTA_PRINTABLE_RADIUS, 100.0 } + #define Z_PROBE_ALLEN_KEY_DEPLOY_2_FEEDRATE (XY_PROBE_FEEDRATE)/10 + + #define Z_PROBE_ALLEN_KEY_DEPLOY_3 { 0.0, (DELTA_PRINTABLE_RADIUS) * 0.75, 100.0 } + #define Z_PROBE_ALLEN_KEY_DEPLOY_3_FEEDRATE XY_PROBE_FEEDRATE + + #define Z_PROBE_ALLEN_KEY_STOW_1 { -64.0, 56.0, 23.0 } // Move the probe into position + #define Z_PROBE_ALLEN_KEY_STOW_1_FEEDRATE XY_PROBE_FEEDRATE + + #define Z_PROBE_ALLEN_KEY_STOW_2 { -64.0, 56.0, 3.0 } // Push it down + #define Z_PROBE_ALLEN_KEY_STOW_2_FEEDRATE (XY_PROBE_FEEDRATE)/10 + + #define Z_PROBE_ALLEN_KEY_STOW_3 { -64.0, 56.0, 50.0 } // Move it up to clear + #define Z_PROBE_ALLEN_KEY_STOW_3_FEEDRATE XY_PROBE_FEEDRATE + + #define Z_PROBE_ALLEN_KEY_STOW_4 { 0.0, 0.0, 50.0 } + #define Z_PROBE_ALLEN_KEY_STOW_4_FEEDRATE XY_PROBE_FEEDRATE + +#endif // Z_PROBE_ALLEN_KEY /** * Nozzle-to-Probe offsets { X, Y, Z } @@ -1331,10 +1522,10 @@ #define PROBING_MARGIN 10 // X and Y axis travel speed (mm/min) between probes -#define XY_PROBE_FEEDRATE (100*60) // @advi3++ +#define XY_PROBE_FEEDRATE (150*60) // @advi3++ // Feedrate (mm/min) for the first approach when double-probing (MULTIPLE_PROBING == 2) -#define Z_PROBE_FEEDRATE_FAST (20*60) // @advi3++ +#define Z_PROBE_FEEDRATE_FAST (10*60) // @advi3++ // Feedrate (mm/min) for the "accurate" probe of each point #define Z_PROBE_FEEDRATE_SLOW (Z_PROBE_FEEDRATE_FAST / 2) @@ -1541,7 +1732,7 @@ //#define V_HOME_DIR -1 //#define W_HOME_DIR -1 -// @section machine +// @section geometry // The size of the printable area #define X_BED_SIZE 200 @@ -1757,6 +1948,15 @@ #define LEVELING_BED_TEMP 50 #endif +/** + * Bed Distance Sensor + * + * Measures the distance from bed to nozzle with accuracy of 0.01mm. + * For information about this sensor https://github.com/markniu/Bed_Distance_sensor + * Uses I2C port, so it requires I2C library markyue/Panda_SoftMasterI2C. + */ +//#define BD_SENSOR + /** * Enable detailed logging of G28, G29, M48, etc. * Turn on with the command 'M111 S32'. @@ -1880,7 +2080,7 @@ //#define LCD_BED_TRAMMING #if ENABLED(LCD_BED_TRAMMING) - #define BED_TRAMMING_INSET_LFRB { 30, 30, 30, 30 } // (mm) Left, Front, Right, Back insets + #define BED_TRAMMING_INSET_LFRB { 30, 30, 30, 30 } // (mm) Left, Front, Right, Back insets #define BED_TRAMMING_HEIGHT 0.0 // (mm) Z height of nozzle at leveling points #define BED_TRAMMING_Z_HOP 4.0 // (mm) Z height of nozzle between leveling points //#define BED_TRAMMING_INCLUDE_CENTER // Move to the center after the last corner @@ -1953,7 +2153,7 @@ // Homing speeds (linear=mm/min, rotational=°/min) // @advi3++ -#define HOMING_FEEDRATE_MM_M { (100*60), (100*60), (20*60) } +#define HOMING_FEEDRATE_MM_M { (100*60), (100*60), (10*60) } // Validate that endstops are triggered on homing moves // @advi3++: Do not validate when using the Simulator @@ -2022,7 +2222,7 @@ //============================= Additional Features =========================== //============================================================================= -// @section extras +// @section eeprom /** * EEPROM @@ -2035,7 +2235,7 @@ */ // @advi3++: Wanhao i3 Plus has EEPROM so enable it to store values #define EEPROM_SETTINGS // Persistent storage with M500 and M501 -//#define DISABLE_M503 // Saves ~2700 bytes of PROGMEM. Disable for release! +//#define DISABLE_M503 // Saves ~2700 bytes of flash. Disable for release! #define EEPROM_CHITCHAT // Give feedback on EEPROM commands. Disable to save PROGMEM. #define EEPROM_BOOT_SILENT // Keep M503 quiet and only give errors during first load #if ENABLED(EEPROM_SETTINGS) @@ -2044,6 +2244,8 @@ //#define EEPROM_INIT_NOW // Init EEPROM on first boot after a new build. #endif +// @section host + // // Host Keepalive // @@ -2054,6 +2256,8 @@ #define DEFAULT_KEEPALIVE_INTERVAL 2 // Number of seconds between "busy" messages. Set with M113. #define BUSY_WHILE_HEATING // Some hosts require "busy" messages even during heating +// @section units + // // G20/G21 Inch mode support // @@ -2097,6 +2301,8 @@ #define PREHEAT_5_TEMP_BED 0 #define PREHEAT_5_FAN_SPEED 0 // Value from 0 to 255 +// @section motion + /** * Nozzle Park * @@ -2110,6 +2316,8 @@ */ // @advi3++: Enable nozzle parking #define NOZZLE_PARK_FEATURE +// @advi3++: Do not park in case of hardware error +//#define NOZZLE_PARK_ON_ERROR #if ENABLED(NOZZLE_PARK_FEATURE) // Specify a park position as { X, Y, Z_raise } @@ -2196,6 +2404,8 @@ #endif +// @section host + /** * Print Job Timer * @@ -2222,6 +2432,8 @@ */ #define PRINTJOB_TIMER_AUTOSTART +// @section stats + /** * Print Counter * @@ -2240,6 +2452,8 @@ #define PRINTCOUNTER_SAVE_INTERVAL 60 // (minutes) EEPROM save interval during print #endif +// @section security + /** * Password * @@ -2275,7 +2489,7 @@ //============================= LCD and SD support ============================ //============================================================================= -// @section lcd +// @section interface /** * LCD LANGUAGE @@ -2392,6 +2606,16 @@ // //#define REVERSE_SELECT_DIRECTION +// +// Encoder EMI Noise Filter +// +// This option increases encoder samples to filter out phantom encoder clicks caused by EMI noise. +// +//#define ENCODER_NOISE_FILTER +#if ENABLED(ENCODER_NOISE_FILTER) + #define ENCODER_SAMPLES 10 +#endif + // // Individual Axis Homing // @@ -2422,6 +2646,7 @@ //======================== LCD / Controller Selection ========================= //======================== (Character-based LCDs) ========================= //============================================================================= +// @section lcd // // RepRapDiscount Smart Controller. @@ -2723,6 +2948,12 @@ // //#define SILVER_GATE_GLCD_CONTROLLER +// +// eMotion Tech LCD with SD +// https://www.reprap-france.com/produit/1234568748-ecran-graphique-128-x-64-points-2-1 +// +//#define EMOTION_TECH_LCD + //============================================================================= //============================== OLED Displays ============================== //============================================================================= @@ -2860,12 +3091,10 @@ // Mini DGUS Touch Display (without DWIN OS) #define EXTENSIBLE_UI #define ADVi3PP_UI -#define HAS_BUZZER 1 // DGUS panel has a buzzer #define HAS_LCD_BRIGHTNESS 1 #define LCD_BRIGHTNESS_MIN 0x01 #define LCD_BRIGHTNESS_MAX 0x40 #define LCD_BRIGHTNESS_DEFAULT LCD_BRIGHTNESS_MAX -//#define PROGRESS_SCALE 1U #if ENABLED(EXTENSIBLE_UI) //#define EXTUI_LOCAL_BEEPER // Enables use of local Beeper pin with external display @@ -3059,7 +3288,7 @@ //=============================== Extra Features ============================== //============================================================================= -// @section extras +// @section fans // Set number of user-controlled fans. Disable to use all board-defined fans. // :[1,2,3,4,5,6,7,8] @@ -3084,14 +3313,18 @@ // duty cycle is attained. //#define SOFT_PWM_DITHER +// @section extras + +// Support for the BariCUDA Paste Extruder +//#define BARICUDA + +// @section lights + // Temperature status LEDs that display the hotend and bed temperature. // If all hotends, bed temperature, and target temperature are under 54C // then the BLUE led is on. Otherwise the RED led is on. (1C hysteresis) //#define TEMP_STAT_LEDS -// Support for the BariCUDA Paste Extruder -//#define BARICUDA - // Support for BlinkM/CyzRgb //#define BLINKM @@ -3177,6 +3410,8 @@ #define PRINTER_EVENT_LEDS #endif +// @section servos + /** * Number of servos * diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 0cef51f81c..c60768c016 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -30,7 +30,25 @@ * * Basic settings can be found in Configuration.h */ -#define CONFIGURATION_ADV_H_VERSION 02010000 +#define CONFIGURATION_ADV_H_VERSION 02010100 + +// @section develop + +/** + * Configuration Export + * + * Export the configuration as part of the build. (See signature.py) + * Output files are saved with the build (e.g., .pio/build/mega2560). + * + * See `build_all_examples --ini` as an example of config.ini archiving. + * + * 1 = marlin_config.json - Dictionary containing the configuration. + * This file is also generated for CONFIGURATION_EMBEDDING. + * 2 = config.ini - File format for PlatformIO preprocessing. + * 3 = schema.json - The entire configuration schema. (13 = pattern groups) + * 4 = schema.yml - The entire configuration schema. + */ +//#define CONFIG_EXPORT // :[1:'JSON', 2:'config.ini', 3:'schema.json', 4:'schema.yml'] //=========================================================================== //============================= Thermal Settings ============================ @@ -54,87 +72,101 @@ // Custom Thermistor 1000 parameters // #if TEMP_SENSOR_0 == 1000 - #define HOTEND0_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor - #define HOTEND0_RESISTANCE_25C_OHMS 100000 // Resistance at 25C - #define HOTEND0_BETA 3950 // Beta value + #define HOTEND0_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor + #define HOTEND0_RESISTANCE_25C_OHMS 100000 // Resistance at 25C + #define HOTEND0_BETA 3950 // Beta value + #define HOTEND0_SH_C_COEFF 0 // Steinhart-Hart C coefficient #endif #if TEMP_SENSOR_1 == 1000 - #define HOTEND1_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor - #define HOTEND1_RESISTANCE_25C_OHMS 100000 // Resistance at 25C - #define HOTEND1_BETA 3950 // Beta value + #define HOTEND1_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor + #define HOTEND1_RESISTANCE_25C_OHMS 100000 // Resistance at 25C + #define HOTEND1_BETA 3950 // Beta value + #define HOTEND1_SH_C_COEFF 0 // Steinhart-Hart C coefficient #endif #if TEMP_SENSOR_2 == 1000 - #define HOTEND2_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor - #define HOTEND2_RESISTANCE_25C_OHMS 100000 // Resistance at 25C - #define HOTEND2_BETA 3950 // Beta value + #define HOTEND2_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor + #define HOTEND2_RESISTANCE_25C_OHMS 100000 // Resistance at 25C + #define HOTEND2_BETA 3950 // Beta value + #define HOTEND2_SH_C_COEFF 0 // Steinhart-Hart C coefficient #endif #if TEMP_SENSOR_3 == 1000 - #define HOTEND3_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor - #define HOTEND3_RESISTANCE_25C_OHMS 100000 // Resistance at 25C - #define HOTEND3_BETA 3950 // Beta value + #define HOTEND3_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor + #define HOTEND3_RESISTANCE_25C_OHMS 100000 // Resistance at 25C + #define HOTEND3_BETA 3950 // Beta value + #define HOTEND3_SH_C_COEFF 0 // Steinhart-Hart C coefficient #endif #if TEMP_SENSOR_4 == 1000 - #define HOTEND4_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor - #define HOTEND4_RESISTANCE_25C_OHMS 100000 // Resistance at 25C - #define HOTEND4_BETA 3950 // Beta value + #define HOTEND4_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor + #define HOTEND4_RESISTANCE_25C_OHMS 100000 // Resistance at 25C + #define HOTEND4_BETA 3950 // Beta value + #define HOTEND4_SH_C_COEFF 0 // Steinhart-Hart C coefficient #endif #if TEMP_SENSOR_5 == 1000 - #define HOTEND5_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor - #define HOTEND5_RESISTANCE_25C_OHMS 100000 // Resistance at 25C - #define HOTEND5_BETA 3950 // Beta value + #define HOTEND5_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor + #define HOTEND5_RESISTANCE_25C_OHMS 100000 // Resistance at 25C + #define HOTEND5_BETA 3950 // Beta value + #define HOTEND5_SH_C_COEFF 0 // Steinhart-Hart C coefficient #endif #if TEMP_SENSOR_6 == 1000 - #define HOTEND6_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor - #define HOTEND6_RESISTANCE_25C_OHMS 100000 // Resistance at 25C - #define HOTEND6_BETA 3950 // Beta value + #define HOTEND6_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor + #define HOTEND6_RESISTANCE_25C_OHMS 100000 // Resistance at 25C + #define HOTEND6_BETA 3950 // Beta value + #define HOTEND6_SH_C_COEFF 0 // Steinhart-Hart C coefficient #endif #if TEMP_SENSOR_7 == 1000 - #define HOTEND7_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor - #define HOTEND7_RESISTANCE_25C_OHMS 100000 // Resistance at 25C - #define HOTEND7_BETA 3950 // Beta value + #define HOTEND7_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor + #define HOTEND7_RESISTANCE_25C_OHMS 100000 // Resistance at 25C + #define HOTEND7_BETA 3950 // Beta value + #define HOTEND7_SH_C_COEFF 0 // Steinhart-Hart C coefficient #endif #if TEMP_SENSOR_BED == 1000 - #define BED_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor - #define BED_RESISTANCE_25C_OHMS 100000 // Resistance at 25C - #define BED_BETA 3950 // Beta value + #define BED_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor + #define BED_RESISTANCE_25C_OHMS 100000 // Resistance at 25C + #define BED_BETA 3950 // Beta value + #define BED_SH_C_COEFF 0 // Steinhart-Hart C coefficient #endif #if TEMP_SENSOR_CHAMBER == 1000 - #define CHAMBER_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor - #define CHAMBER_RESISTANCE_25C_OHMS 100000 // Resistance at 25C - #define CHAMBER_BETA 3950 // Beta value + #define CHAMBER_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor + #define CHAMBER_RESISTANCE_25C_OHMS 100000 // Resistance at 25C + #define CHAMBER_BETA 3950 // Beta value + #define CHAMBER_SH_C_COEFF 0 // Steinhart-Hart C coefficient #endif #if TEMP_SENSOR_COOLER == 1000 - #define COOLER_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor - #define COOLER_RESISTANCE_25C_OHMS 100000 // Resistance at 25C - #define COOLER_BETA 3950 // Beta value + #define COOLER_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor + #define COOLER_RESISTANCE_25C_OHMS 100000 // Resistance at 25C + #define COOLER_BETA 3950 // Beta value + #define COOLER_SH_C_COEFF 0 // Steinhart-Hart C coefficient #endif #if TEMP_SENSOR_PROBE == 1000 - #define PROBE_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor - #define PROBE_RESISTANCE_25C_OHMS 100000 // Resistance at 25C - #define PROBE_BETA 3950 // Beta value + #define PROBE_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor + #define PROBE_RESISTANCE_25C_OHMS 100000 // Resistance at 25C + #define PROBE_BETA 3950 // Beta value + #define PROBE_SH_C_COEFF 0 // Steinhart-Hart C coefficient #endif #if TEMP_SENSOR_BOARD == 1000 - #define BOARD_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor - #define BOARD_RESISTANCE_25C_OHMS 100000 // Resistance at 25C - #define BOARD_BETA 3950 // Beta value + #define BOARD_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor + #define BOARD_RESISTANCE_25C_OHMS 100000 // Resistance at 25C + #define BOARD_BETA 3950 // Beta value + #define BOARD_SH_C_COEFF 0 // Steinhart-Hart C coefficient #endif #if TEMP_SENSOR_REDUNDANT == 1000 - #define REDUNDANT_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor - #define REDUNDANT_RESISTANCE_25C_OHMS 100000 // Resistance at 25C - #define REDUNDANT_BETA 3950 // Beta value + #define REDUNDANT_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor + #define REDUNDANT_RESISTANCE_25C_OHMS 100000 // Resistance at 25C + #define REDUNDANT_BETA 3950 // Beta value + #define REDUNDANT_SH_C_COEFF 0 // Steinhart-Hart C coefficient #endif /** @@ -912,7 +944,7 @@ * * Set the default state here, change with 'M401 S' or UI, use M500 to save, M502 to reset. */ - //#define BLTOUCH_HS_MODE true + #define BLTOUCH_HS_MODE false // @advi3++. Enable but not active by default // Safety: Enable voltage mode settings in the LCD menu. //#define BLTOUCH_LCD_VOLTAGE_MENU @@ -927,9 +959,12 @@ */ //#define Z_STEPPER_AUTO_ALIGN #if ENABLED(Z_STEPPER_AUTO_ALIGN) - // Define probe X and Y positions for Z1, Z2 [, Z3 [, Z4]] - // If not defined, probe limits will be used. - // Override with 'M422 S X Y' + /** + * Define probe X and Y positions for Z1, Z2 [, Z3 [, Z4]] + * These positions are machine-relative and do not shift with the M206 home offset! + * If not defined, probe limits will be used. + * Override with 'M422 S X Y'. + */ //#define Z_STEPPER_ALIGN_XY { { 10, 190 }, { 100, 10 }, { 190, 190 } } /** @@ -1335,6 +1370,9 @@ #define XATC_Y_POSITION Y_CENTER // (mm) Y position to probe #define XATC_Z_OFFSETS { 0, 0, 0 } // Z offsets for X axis sample points #endif + + // Show Deploy / Stow Probe options in the Motion menu. + #define PROBE_DEPLOY_STOW_MENU #endif // Include a page of printer information in the LCD Main Menu @@ -1413,7 +1451,7 @@ // LCD Print Progress options #if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) #if CAN_SHOW_REMAINING_TIME - #define SHOW_REMAINING_TIME // Display estimated time to completion advi3++ + #define SHOW_REMAINING_TIME // Display estimated time to completion @advi3++ #if ENABLED(SHOW_REMAINING_TIME) //#define USE_M73_REMAINING_TIME // Use remaining time from M73 command instead of estimation //#define ROTATE_PROGRESS_DISPLAY // Display (P)rogress, (E)lapsed, and (R)emaining time @@ -1450,7 +1488,9 @@ // The standard SD detect circuit reads LOW when media is inserted and HIGH when empty. // Enable this option and set to HIGH if your SD cards are incorrectly detected. - //#define SD_DETECT_STATE HIGH +#ifdef ADVi3PP_HARDWARE_SIMULATOR // @advi3++ + #define SD_DETECT_STATE HIGH +#endif //#define SD_IGNORE_AT_STARTUP // Don't mount the SD card when starting up //#define SDCARD_READONLY // Read-only SD card (to save over 2K of flash) @@ -1588,6 +1628,9 @@ * Endstops must be activated for this option to work. */ //#define SD_ABORT_ON_ENDSTOP_HIT + #if ENABLED(SD_ABORT_ON_ENDSTOP_HIT) + //#define SD_ABORT_ON_ENDSTOP_HIT_GCODE "G28XY" // G-code to run on endstop hit (e.g., "G28XY" or "G27") + #endif //#define SD_REPRINT_LAST_SELECTED_FILE // On print completion open the LCD Menu and select the same file @@ -1622,6 +1665,8 @@ //#define USE_UHS2_USB //#define USE_UHS3_USB + #define DISABLE_DUE_SD_MMC // Disable USB Host access to USB Drive to prevent hangs on block access for DUE platform + /** * Native USB Host supported by some boards (USB OTG) */ @@ -2027,9 +2072,11 @@ #endif #endif - //#define BABYSTEP_DISPLAY_TOTAL // Display total babysteps since last G28 - - #ifdef ADVi3PP_PROBE // @advi3++: Sensor only + // @advi3++ If no sensor, use BABYSTEP_DISPLAY_TOTAL, else BABYSTEP_ZPROBE_OFFSET + // from what I understand from the code (ExtUI::getZOffset_mm), using both gives wrong results + #ifndef ADVi3PP_PROBE + #define BABYSTEP_DISPLAY_TOTAL // Display total babysteps since last G28 + #else #define BABYSTEP_ZPROBE_OFFSET // Combine M851 Z and Babystepping #endif #if ENABLED(BABYSTEP_ZPROBE_OFFSET) @@ -2566,6 +2613,8 @@ #endif #endif // HAS_MULTI_EXTRUDER +// @section advanced pause + /** * Advanced Pause for Filament Change * - Adds the G-code M600 Filament Change to initiate a filament change. @@ -2626,13 +2675,12 @@ //#define FILAMENT_UNLOAD_ALL_EXTRUDERS // Allow M702 to unload all extruders above a minimum target temp (as set by M302) #endif -// @section tmc - /** * TMC26X Stepper Driver options * * The TMC26XStepper library is required for this stepper driver. * https://github.com/trinamic/TMC26XStepper + * @section tmc/tmc26x */ #if HAS_DRIVER(TMC26X) @@ -2770,8 +2818,6 @@ #endif // TMC26X -// @section tmc_smart - /** * To use TMC2130, TMC2160, TMC2660, TMC5130, TMC5160 stepper drivers in SPI mode * connect your SPI pins to the hardware SPI interface on your board and define @@ -2787,6 +2833,7 @@ * * TMCStepper library is required to use TMC stepper drivers. * https://github.com/teemuatlut/TMCStepper + * @section tmc/config */ #if HAS_TRINAMIC_CONFIG @@ -3010,6 +3057,8 @@ //#define E7_HOLD_MULTIPLIER 0.5 #endif + // @section tmc/spi + /** * Override default SPI pins for TMC2130, TMC2160, TMC2660, TMC5130 and TMC5160 drivers here. * The default pins can be found in your board's pins file. @@ -3047,6 +3096,8 @@ //#define TMC_SW_MISO -1 //#define TMC_SW_SCK -1 + // @section tmc/serial + /** * Four TMC2209 drivers can use the same HW/SW serial port with hardware configured addresses. * Set the address using jumpers on pins MS1 and MS2. @@ -3082,6 +3133,8 @@ //#define E6_SLAVE_ADDRESS 0 //#define E7_SLAVE_ADDRESS 0 + // @section tmc/smart + /** * Software enable * @@ -3090,6 +3143,8 @@ */ //#define SOFTWARE_DRIVER_ENABLE + // @section tmc/stealthchop + /** * TMC2130, TMC2160, TMC2208, TMC2209, TMC5130 and TMC5160 only * Use Trinamic's ultra quiet stepping mode. @@ -3144,6 +3199,8 @@ //#define CHOPPER_TIMING_E6 CHOPPER_TIMING_E //#define CHOPPER_TIMING_E7 CHOPPER_TIMING_E + // @section tmc/status + /** * Monitor Trinamic drivers * for error conditions like overtemperature and short to ground. @@ -3163,6 +3220,8 @@ #define STOP_ON_ERROR #endif + // @section tmc/hybrid + /** * TMC2130, TMC2160, TMC2208, TMC2209, TMC5130 and TMC5160 only * The driver will switch to spreadCycle when stepper speed is over HYBRID_THRESHOLD. @@ -3219,6 +3278,7 @@ * homing and adds a guard period for endstop triggering. * * Comment *_STALL_SENSITIVITY to disable sensorless homing for that axis. + * @section tmc/stallguard */ //#define SENSORLESS_HOMING // StallGuard capable drivers only @@ -3242,6 +3302,8 @@ //#define IMPROVE_HOMING_RELIABILITY #endif + // @section tmc/config + /** * TMC Homing stepper phase. * @@ -3281,254 +3343,6 @@ #endif // HAS_TRINAMIC_CONFIG -// @section L64XX - -/** - * L64XX Stepper Driver options - * - * Arduino-L6470 library (0.8.0 or higher) is required. - * https://github.com/ameyer/Arduino-L6470 - * - * Requires the following to be defined in your pins_YOUR_BOARD file - * L6470_CHAIN_SCK_PIN - * L6470_CHAIN_MISO_PIN - * L6470_CHAIN_MOSI_PIN - * L6470_CHAIN_SS_PIN - * ENABLE_RESET_L64XX_CHIPS(Q) where Q is 1 to enable and 0 to reset - */ - -#if HAS_L64XX - - //#define L6470_CHITCHAT // Display additional status info - - #if AXIS_IS_L64XX(X) - #define X_MICROSTEPS 128 // Number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128) - L6474 max is 16 - #define X_OVERCURRENT 2000 // (mA) Current where the driver detects an over current - // L6470 & L6474 - VALID: 375 x (1 - 16) - 6A max - rounds down - // POWERSTEP01: VALID: 1000 x (1 - 32) - 32A max - rounds down - #define X_STALLCURRENT 1500 // (mA) Current where the driver detects a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) - // L6470 & L6474 - VALID: 31.25 * (1-128) - 4A max - rounds down - // POWERSTEP01: VALID: 200 x (1 - 32) - 6.4A max - rounds down - // L6474 - STALLCURRENT setting is used to set the nominal (TVAL) current - #define X_MAX_VOLTAGE 127 // 0-255, Maximum effective voltage seen by stepper - not used by L6474 - #define X_CHAIN_POS -1 // Position in SPI chain, 0=Not in chain, 1=Nearest MOSI - #define X_SLEW_RATE 1 // 0-3, Slew 0 is slowest, 3 is fastest - #endif - - #if AXIS_IS_L64XX(X2) - #define X2_MICROSTEPS X_MICROSTEPS - #define X2_OVERCURRENT 2000 - #define X2_STALLCURRENT 1500 - #define X2_MAX_VOLTAGE 127 - #define X2_CHAIN_POS -1 - #define X2_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(Y) - #define Y_MICROSTEPS 128 - #define Y_OVERCURRENT 2000 - #define Y_STALLCURRENT 1500 - #define Y_MAX_VOLTAGE 127 - #define Y_CHAIN_POS -1 - #define Y_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(Y2) - #define Y2_MICROSTEPS Y_MICROSTEPS - #define Y2_OVERCURRENT 2000 - #define Y2_STALLCURRENT 1500 - #define Y2_MAX_VOLTAGE 127 - #define Y2_CHAIN_POS -1 - #define Y2_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(Z) - #define Z_MICROSTEPS 128 - #define Z_OVERCURRENT 2000 - #define Z_STALLCURRENT 1500 - #define Z_MAX_VOLTAGE 127 - #define Z_CHAIN_POS -1 - #define Z_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(Z2) - #define Z2_MICROSTEPS Z_MICROSTEPS - #define Z2_OVERCURRENT 2000 - #define Z2_STALLCURRENT 1500 - #define Z2_MAX_VOLTAGE 127 - #define Z2_CHAIN_POS -1 - #define Z2_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(Z3) - #define Z3_MICROSTEPS Z_MICROSTEPS - #define Z3_OVERCURRENT 2000 - #define Z3_STALLCURRENT 1500 - #define Z3_MAX_VOLTAGE 127 - #define Z3_CHAIN_POS -1 - #define Z3_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(Z4) - #define Z4_MICROSTEPS Z_MICROSTEPS - #define Z4_OVERCURRENT 2000 - #define Z4_STALLCURRENT 1500 - #define Z4_MAX_VOLTAGE 127 - #define Z4_CHAIN_POS -1 - #define Z4_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(I) - #define I_MICROSTEPS 128 - #define I_OVERCURRENT 2000 - #define I_STALLCURRENT 1500 - #define I_MAX_VOLTAGE 127 - #define I_CHAIN_POS -1 - #define I_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(J) - #define J_MICROSTEPS 128 - #define J_OVERCURRENT 2000 - #define J_STALLCURRENT 1500 - #define J_MAX_VOLTAGE 127 - #define J_CHAIN_POS -1 - #define J_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(K) - #define K_MICROSTEPS 128 - #define K_OVERCURRENT 2000 - #define K_STALLCURRENT 1500 - #define K_MAX_VOLTAGE 127 - #define K_CHAIN_POS -1 - #define K_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(U) - #define U_MICROSTEPS 128 - #define U_OVERCURRENT 2000 - #define U_STALLCURRENT 1500 - #define U_MAX_VOLTAGE 127 - #define U_CHAIN_POS -1 - #define U_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(V) - #define V_MICROSTEPS 128 - #define V_OVERCURRENT 2000 - #define V_STALLCURRENT 1500 - #define V_MAX_VOLTAGE 127 - #define V_CHAIN_POS -1 - #define V_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(W) - #define W_MICROSTEPS 128 - #define W_OVERCURRENT 2000 - #define W_STALLCURRENT 1500 - #define W_MAX_VOLTAGE 127 - #define W_CHAIN_POS -1 - #define W_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(E0) - #define E0_MICROSTEPS 128 - #define E0_OVERCURRENT 2000 - #define E0_STALLCURRENT 1500 - #define E0_MAX_VOLTAGE 127 - #define E0_CHAIN_POS -1 - #define E0_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(E1) - #define E1_MICROSTEPS E0_MICROSTEPS - #define E1_OVERCURRENT 2000 - #define E1_STALLCURRENT 1500 - #define E1_MAX_VOLTAGE 127 - #define E1_CHAIN_POS -1 - #define E1_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(E2) - #define E2_MICROSTEPS E0_MICROSTEPS - #define E2_OVERCURRENT 2000 - #define E2_STALLCURRENT 1500 - #define E2_MAX_VOLTAGE 127 - #define E2_CHAIN_POS -1 - #define E2_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(E3) - #define E3_MICROSTEPS E0_MICROSTEPS - #define E3_OVERCURRENT 2000 - #define E3_STALLCURRENT 1500 - #define E3_MAX_VOLTAGE 127 - #define E3_CHAIN_POS -1 - #define E3_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(E4) - #define E4_MICROSTEPS E0_MICROSTEPS - #define E4_OVERCURRENT 2000 - #define E4_STALLCURRENT 1500 - #define E4_MAX_VOLTAGE 127 - #define E4_CHAIN_POS -1 - #define E4_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(E5) - #define E5_MICROSTEPS E0_MICROSTEPS - #define E5_OVERCURRENT 2000 - #define E5_STALLCURRENT 1500 - #define E5_MAX_VOLTAGE 127 - #define E5_CHAIN_POS -1 - #define E5_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(E6) - #define E6_MICROSTEPS E0_MICROSTEPS - #define E6_OVERCURRENT 2000 - #define E6_STALLCURRENT 1500 - #define E6_MAX_VOLTAGE 127 - #define E6_CHAIN_POS -1 - #define E6_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(E7) - #define E7_MICROSTEPS E0_MICROSTEPS - #define E7_OVERCURRENT 2000 - #define E7_STALLCURRENT 1500 - #define E7_MAX_VOLTAGE 127 - #define E7_CHAIN_POS -1 - #define E7_SLEW_RATE 1 - #endif - - /** - * Monitor L6470 drivers for error conditions like over temperature and over current. - * In the case of over temperature Marlin can decrease the drive until the error condition clears. - * Other detected conditions can be used to stop the current print. - * Relevant G-codes: - * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. - * I not present or I0 or I1 - X, Y, Z or E0 - * I2 - X2, Y2, Z2 or E1 - * I3 - Z3 or E3 - * I4 - Z4 or E4 - * I5 - E5 - * M916 - Increase drive level until get thermal warning - * M917 - Find minimum current thresholds - * M918 - Increase speed until max or error - * M122 S0/1 - Report driver parameters - */ - //#define MONITOR_L6470_DRIVER_STATUS - - #if ENABLED(MONITOR_L6470_DRIVER_STATUS) - #define KVAL_HOLD_STEP_DOWN 1 - //#define L6470_STOP_ON_ERROR - #endif - -#endif // HAS_L64XX - // @section i2cbus // @@ -3570,7 +3384,7 @@ #define I2C_SLAVE_ADDRESS 0 // Set a value from 8 to 127 to act as a slave #endif -// @section extras +// @section photo /** * Photo G-code @@ -3613,6 +3427,8 @@ #endif #endif +// @section cnc + /** * Spindle & Laser control * @@ -3713,8 +3529,11 @@ #endif // Define the minimum and maximum test pulse time values for a laser test fire function - #define LASER_TEST_PULSE_MIN 1 // Used with Laser Control Menu - #define LASER_TEST_PULSE_MAX 999 // Caution: Menu may not show more than 3 characters + #define LASER_TEST_PULSE_MIN 1 // (ms) Used with Laser Control Menu + #define LASER_TEST_PULSE_MAX 999 // (ms) Caution: Menu may not show more than 3 characters + + #define SPINDLE_LASER_POWERUP_DELAY 50 // (ms) Delay to allow the spindle/laser to come up to speed/power + #define SPINDLE_LASER_POWERDOWN_DELAY 50 // (ms) Delay to allow the spindle to stop /** * Laser Safety Timeout @@ -3727,79 +3546,38 @@ #define LASER_SAFETY_TIMEOUT_MS 1000 // (ms) /** - * Enable inline laser power to be handled in the planner / stepper routines. - * Inline power is specified by the I (inline) flag in an M3 command (e.g., M3 S20 I) - * or by the 'S' parameter in G0/G1/G2/G3 moves (see LASER_MOVE_POWER). + * Any M3 or G1/2/3/5 command with the 'I' parameter enables continuous inline power mode. * - * This allows the laser to keep in perfect sync with the planner and removes - * the powerup/down delay since lasers require negligible time. + * e.g., 'M3 I' enables continuous inline power which is processed by the planner. + * Power is stored in move blocks and applied when blocks are processed by the Stepper ISR. + * + * 'M4 I' sets dynamic mode which uses the current feedrate to calculate a laser power OCR value. + * + * Any move in dynamic mode will use the current feedrate to calculate the laser power. + * Feed rates are set by the F parameter of a move command e.g. G1 X0 Y10 F6000 + * Laser power would be calculated by bit shifting off 8 LSB's. In binary this is div 256. + * The calculation gives us ocr values from 0 to 255, values over F65535 will be set as 255 . + * More refined power control such as compesation for accell/decell will be addressed in future releases. + * + * M5 I clears inline mode and set power to 0, M5 sets the power output to 0 but leaves inline mode on. */ - //#define LASER_POWER_INLINE - - #if ENABLED(LASER_POWER_INLINE) - /** - * Scale the laser's power in proportion to the movement rate. - * - * - Sets the entry power proportional to the entry speed over the nominal speed. - * - Ramps the power up every N steps to approximate the speed trapezoid. - * - Due to the limited power resolution this is only approximate. - */ - #define LASER_POWER_INLINE_TRAPEZOID - /** - * Continuously calculate the current power (nominal_power * current_rate / nominal_rate). - * Required for accurate power with non-trapezoidal acceleration (e.g., S_CURVE_ACCELERATION). - * This is a costly calculation so this option is discouraged on 8-bit AVR boards. - * - * LASER_POWER_INLINE_TRAPEZOID_CONT_PER defines how many step cycles there are between power updates. If your - * board isn't able to generate steps fast enough (and you are using LASER_POWER_INLINE_TRAPEZOID_CONT), increase this. - * Note that when this is zero it means it occurs every cycle; 1 means a delay wait one cycle then run, etc. - */ - //#define LASER_POWER_INLINE_TRAPEZOID_CONT - - /** - * Stepper iterations between power updates. Increase this value if the board - * can't keep up with the processing demands of LASER_POWER_INLINE_TRAPEZOID_CONT. - * Disable (or set to 0) to recalculate power on every stepper iteration. - */ - //#define LASER_POWER_INLINE_TRAPEZOID_CONT_PER 10 - - /** - * Include laser power in G0/G1/G2/G3/G5 commands with the 'S' parameter - */ - //#define LASER_MOVE_POWER - - #if ENABLED(LASER_MOVE_POWER) - // Turn off the laser on G0 moves with no power parameter. - // If a power parameter is provided, use that instead. - //#define LASER_MOVE_G0_OFF - - // Turn off the laser on G28 homing. - //#define LASER_MOVE_G28_OFF - #endif - - /** - * Inline flag inverted - * - * WARNING: M5 will NOT turn off the laser unless another move - * is done (so G-code files must end with 'M5 I'). - */ - //#define LASER_POWER_INLINE_INVERT - - /** - * Continuously apply inline power. ('M3 S3' == 'G1 S3' == 'M3 S3 I') - * - * The laser might do some weird things, so only enable this - * feature if you understand the implications. - */ - //#define LASER_POWER_INLINE_CONTINUOUS - - #else - - #define SPINDLE_LASER_POWERUP_DELAY 50 // (ms) Delay to allow the spindle/laser to come up to speed/power - #define SPINDLE_LASER_POWERDOWN_DELAY 50 // (ms) Delay to allow the spindle to stop + /** + * Enable M3 commands for laser mode inline power planner syncing. + * This feature enables any M3 S-value to be injected into the block buffers while in + * CUTTER_MODE_CONTINUOUS. The option allows M3 laser power to be commited without waiting + * for a planner syncronization + */ + //#define LASER_POWER_SYNC - #endif + /** + * Scale the laser's power in proportion to the movement rate. + * + * - Sets the entry power proportional to the entry speed over the nominal speed. + * - Ramps the power up every N steps to approximate the speed trapezoid. + * - Due to the limited power resolution this is only approximate. + */ + //#define LASER_POWER_TRAP // // Laser I2C Ammeter (High precision INA226 low/high side module) @@ -3854,6 +3632,8 @@ #define COOLANT_FLOOD_INVERT false // Set "true" if the on/off function is reversed #endif +// @section filament width + /** * Filament Width Sensor * @@ -3887,6 +3667,8 @@ //#define FILAMENT_LCD_DISPLAY #endif +// @section power + /** * Power Monitor * Monitor voltage (V) and/or current (A), and -when possible- power (W) @@ -3910,6 +3692,8 @@ #define POWER_MONITOR_VOLTAGE_OFFSET 0 // Offset (in volts) applied to the calculated voltage #endif +// @section safety + /** * Stepper Driver Anti-SNAFU Protection * @@ -3919,6 +3703,8 @@ */ //#define DISABLE_DRIVER_SAFE_POWER_PROTECT +// @section cnc + /** * CNC Coordinate Systems * @@ -3927,6 +3713,8 @@ */ //#define CNC_COORDINATE_SYSTEMS +// @section reporting + /** * Auto-report fan speed with M123 S * Requires fans with tachometer pins @@ -3954,6 +3742,8 @@ //#define M115_GEOMETRY_REPORT #endif +// @section security + /** * Expected Printer Check * Add the M16 G-code to compare a string to the MACHINE_NAME. @@ -3961,6 +3751,8 @@ */ //#define EXPECTED_PRINTER_CHECK +// @section volumetrics + /** * Disable all Volumetric extrusion options */ @@ -3989,14 +3781,7 @@ #endif #endif -/** - * Enable this option for a leaner build of Marlin that removes all - * workspace offsets, simplifying coordinate transformations, leveling, etc. - * - * - M206 and M428 are disabled. - * - G92 will revert to its behavior from Marlin 1.0. - */ -//#define NO_WORKSPACE_OFFSETS +// @section reporting // Extra options for the M114 "Current Position" report //#define M114_DETAIL // Use 'M114` for details to check planner calculations @@ -4005,6 +3790,8 @@ //#define REPORT_FAN_CHANGE // Report the new fan speed when changed by M106 (and others) +// @section gcode + /** * Spend 28 bytes of SRAM to optimize the G-code parser */ @@ -4022,6 +3809,15 @@ //#define REPETIER_GCODE_M360 // Add commands originally from Repetier FW +/** + * Enable this option for a leaner build of Marlin that removes all + * workspace offsets, simplifying coordinate transformations, leveling, etc. + * + * - M206 and M428 are disabled. + * - G92 will revert to its behavior from Marlin 1.0. + */ +//#define NO_WORKSPACE_OFFSETS + /** * CNC G-code options * Support CNC-style G-code dialects used by laser cutters, drawing machine cams, etc. @@ -4037,6 +3833,8 @@ //#define VARIABLE_G0_FEEDRATE // The G0 feedrate is set by F in G0 motion mode #endif +// @section gcode + /** * Startup commands * @@ -4061,6 +3859,8 @@ * Up to 25 may be defined, but the actual number is LCD-dependent. */ +// @section custom main menu + // Custom Menu: Main Menu //#define CUSTOM_MENU_MAIN #if ENABLED(CUSTOM_MENU_MAIN) @@ -4091,6 +3891,8 @@ //#define MAIN_MENU_ITEM_5_CONFIRM #endif +// @section custom config menu + // Custom Menu: Configuration Menu //#define CUSTOM_MENU_CONFIG #if ENABLED(CUSTOM_MENU_CONFIG) @@ -4121,6 +3923,8 @@ //#define CONFIG_MENU_ITEM_5_CONFIRM #endif +// @section custom buttons + /** * User-defined buttons to run custom G-code. * Up to 25 may be defined. @@ -4152,6 +3956,8 @@ #endif #endif +// @section host + /** * Host Action Commands * @@ -4178,6 +3984,8 @@ //#define HOST_SHUTDOWN_MENU_ITEM // Add a menu item that tells the host to shut down #endif +// @section extras + /** * Cancel Objects * @@ -4199,6 +4007,7 @@ * Alternative Supplier: https://reliabuild3d.com/ * * Reliabuild encoders have been modified to improve reliability. + * @section i2c encoders */ //#define I2C_POSITION_ENCODERS @@ -4270,6 +4079,7 @@ /** * Analog Joystick(s) + * @section joystick */ //#define JOYSTICK #if ENABLED(JOYSTICK) @@ -4294,6 +4104,7 @@ * Modern replacement for the Prusa TMC_Z_CALIBRATION. * Adds capability to work with any adjustable current drivers. * Implemented as G34 because M915 is deprecated. + * @section calibrate */ //#define MECHANICAL_GANTRY_CALIBRATION #if ENABLED(MECHANICAL_GANTRY_CALIBRATION) @@ -4311,6 +4122,7 @@ /** * Instant freeze / unfreeze functionality * Potentially useful for emergency stop that allows being resumed. + * @section interface */ //#define FREEZE_FEATURE #if ENABLED(FREEZE_FEATURE) @@ -4323,6 +4135,7 @@ * * Add support for a low-cost 8x8 LED Matrix based on the Max7219 chip as a realtime status display. * Requires 3 signal wires. Some useful debug options are included to demonstrate its usage. + * @section debug matrix */ //#define MAX7219_DEBUG #if ENABLED(MAX7219_DEBUG) @@ -4361,6 +4174,7 @@ * Support for Synchronized Z moves when used with NanoDLP. G0/G1 axis moves will * output a "Z_move_comp" string to enable synchronization with DLP projector exposure. * This feature allows you to use [[WaitForDoneMessage]] instead of M400 commands. + * @section nanodlp */ //#define NANODLP_Z_SYNC #if ENABLED(NANODLP_Z_SYNC) @@ -4369,6 +4183,7 @@ /** * Ethernet. Use M552 to enable and set the IP address. + * @section network */ #if HAS_ETHERNET #define MAC_ADDRESS { 0xDE, 0xAD, 0xBE, 0xEF, 0xF0, 0x0D } // A MAC address unique to your network @@ -4396,6 +4211,8 @@ //#include "Configuration_Secure.h" // External file with WiFi SSID / Password #endif +// @section multi-material + /** * Průša Multi-Material Unit (MMU) * Enable in Configuration.h @@ -4501,6 +4318,7 @@ /** * Advanced Print Counter settings + * @section stats */ #if ENABLED(PRINTCOUNTER) #define SERVICE_WARNING_BUZZES 3 @@ -4536,6 +4354,9 @@ #define PINS_DEBUGGING #endif +// Enable Tests that will run at startup and produce a report +//#define MARLIN_TEST_BUILD + // Enable Marlin dev mode which adds some special commands //#define MARLIN_DEV_MODE diff --git a/Marlin/Makefile b/Marlin/Makefile index 563354fdbe..c72c1d5896 100644 --- a/Marlin/Makefile +++ b/Marlin/Makefile @@ -317,123 +317,10 @@ else ifeq ($(HARDWARE_MOTHERBOARD),1159) else ifeq ($(HARDWARE_MOTHERBOARD),1160) # Longer LKx PRO / Alfawise Uxx Pro (PRO version) else ifeq ($(HARDWARE_MOTHERBOARD),1161) - - -# 3Drag Controller -else ifeq ($(HARDWARE_MOTHERBOARD),1100) -# Velleman K8200 Controller (derived from 3Drag Controller) -else ifeq ($(HARDWARE_MOTHERBOARD),1101) -# Velleman K8400 Controller (derived from 3Drag Controller) -else ifeq ($(HARDWARE_MOTHERBOARD),1102) -# Velleman K8600 Controller (Vertex Nano) -else ifeq ($(HARDWARE_MOTHERBOARD),1103) -# Velleman K8800 Controller (Vertex Delta) -else ifeq ($(HARDWARE_MOTHERBOARD),1104) -# 2PrintBeta BAM&DICE with STK drivers -else ifeq ($(HARDWARE_MOTHERBOARD),1105) -# 2PrintBeta BAM&DICE Due with STK drivers -else ifeq ($(HARDWARE_MOTHERBOARD),1106) -# MKS BASE v1.0 -else ifeq ($(HARDWARE_MOTHERBOARD),1107) -# MKS v1.4 with A4982 stepper drivers -else ifeq ($(HARDWARE_MOTHERBOARD),1108) -# MKS v1.5 with Allegro A4982 stepper drivers -else ifeq ($(HARDWARE_MOTHERBOARD),1109) -# MKS v1.6 with Allegro A4982 stepper drivers -else ifeq ($(HARDWARE_MOTHERBOARD),1110) -# MKS BASE 1.0 with Heroic HR4982 stepper drivers -else ifeq ($(HARDWARE_MOTHERBOARD),1111) -# MKS GEN v1.3 or 1.4 -else ifeq ($(HARDWARE_MOTHERBOARD),1112) -# MKS GEN L -else ifeq ($(HARDWARE_MOTHERBOARD),1113) -# zrib V2.0 control board (Chinese RAMPS replica) -else ifeq ($(HARDWARE_MOTHERBOARD),1114) -# BigTreeTech or BIQU KFB2.0 -else ifeq ($(HARDWARE_MOTHERBOARD),1115) -# Felix 2.0+ Electronics Board (RAMPS like) -else ifeq ($(HARDWARE_MOTHERBOARD),1116) -# Invent-A-Part RigidBoard -else ifeq ($(HARDWARE_MOTHERBOARD),1117) -# Invent-A-Part RigidBoard V2 -else ifeq ($(HARDWARE_MOTHERBOARD),1118) -# Sainsmart 2-in-1 board -else ifeq ($(HARDWARE_MOTHERBOARD),1119) -# Ultimaker -else ifeq ($(HARDWARE_MOTHERBOARD),1120) -# Ultimaker (Older electronics. Pre 1.5.4. This is rare) -else ifeq ($(HARDWARE_MOTHERBOARD),1121) - MCU ?= atmega1280 - PROG_MCU ?= m1280 - -# Azteeg X3 -else ifeq ($(HARDWARE_MOTHERBOARD),1122) -# Azteeg X3 Pro -else ifeq ($(HARDWARE_MOTHERBOARD),1123) -# Ultimainboard 2.x (Uses TEMP_SENSOR 20) -else ifeq ($(HARDWARE_MOTHERBOARD),1124) -# Rumba -else ifeq ($(HARDWARE_MOTHERBOARD),1125) -# Raise3D Rumba -else ifeq ($(HARDWARE_MOTHERBOARD),1126) -# Rapide Lite RL200 Rumba -else ifeq ($(HARDWARE_MOTHERBOARD),1127) -# Formbot T-Rex 2 Plus -else ifeq ($(HARDWARE_MOTHERBOARD),1128) -# Formbot T-Rex 3 -else ifeq ($(HARDWARE_MOTHERBOARD),1129) -# Formbot Raptor -else ifeq ($(HARDWARE_MOTHERBOARD),1130) -# Formbot Raptor 2 -else ifeq ($(HARDWARE_MOTHERBOARD),1131) -# bq ZUM Mega 3D -else ifeq ($(HARDWARE_MOTHERBOARD),1132) -# MakeBoard Mini v2.1.2 is a control board sold by MicroMake -else ifeq ($(HARDWARE_MOTHERBOARD),1133) -# TriGorilla Anycubic version 1.3 based on RAMPS EFB -else ifeq ($(HARDWARE_MOTHERBOARD),1134) -# TriGorilla Anycubic version 1.4 based on RAMPS EFB -else ifeq ($(HARDWARE_MOTHERBOARD),1135) -# TriGorilla Anycubic version 1.4 Rev 1.1 -else ifeq ($(HARDWARE_MOTHERBOARD),1136) -# Creality: Ender-4, CR-8 -else ifeq ($(HARDWARE_MOTHERBOARD),1137) -# Creality: CR10S, CR20, CR-X -else ifeq ($(HARDWARE_MOTHERBOARD),1138) -# Dagoma F5 -else ifeq ($(HARDWARE_MOTHERBOARD),1139) -# FYSETC F6 1.3 -else ifeq ($(HARDWARE_MOTHERBOARD),1140) -# FYSETC F6 1.5 -else ifeq ($(HARDWARE_MOTHERBOARD),1141) -# Duplicator i3 Plus -else ifeq ($(HARDWARE_MOTHERBOARD),1142) -# VORON -else ifeq ($(HARDWARE_MOTHERBOARD),1143) -# TRONXY V3 1.0 -else ifeq ($(HARDWARE_MOTHERBOARD),1144) -# Z-Bolt X Series -else ifeq ($(HARDWARE_MOTHERBOARD),1145) -# TT OSCAR -else ifeq ($(HARDWARE_MOTHERBOARD),1146) -# Overlord/Overlord Pro -else ifeq ($(HARDWARE_MOTHERBOARD),1147) -# ADIMLab Gantry v1 -else ifeq ($(HARDWARE_MOTHERBOARD),1148) -# ADIMLab Gantry v2 -else ifeq ($(HARDWARE_MOTHERBOARD),1149) -# BIQU Tango V1 -else ifeq ($(HARDWARE_MOTHERBOARD),1150) -# MKS GEN L V2 -else ifeq ($(HARDWARE_MOTHERBOARD),1151) -# MKS GEN L V2.1 -else ifeq ($(HARDWARE_MOTHERBOARD),1152) -# Copymaster 3D -else ifeq ($(HARDWARE_MOTHERBOARD),1153) -# Ortur 4 -else ifeq ($(HARDWARE_MOTHERBOARD),1154) -# Tenlog D3 Hero -else ifeq ($(HARDWARE_MOTHERBOARD),1155) +# Zonestar zrib V5.3 (Chinese RAMPS replica) +else ifeq ($(HARDWARE_MOTHERBOARD),1162) +# Pxmalion Core I3 +else ifeq ($(HARDWARE_MOTHERBOARD),1163) # # RAMBo and derivatives diff --git a/Marlin/Version.h b/Marlin/Version.h index f6e4635c8f..d9ec298ede 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -28,7 +28,7 @@ /** * Marlin release version identifier */ -//#define SHORT_BUILD_VERSION "2.1" +//#define SHORT_BUILD_VERSION "2.1.1" /** * Verbose version identifier which should contain a reference to the location @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -//#define STRING_DISTRIBUTION_DATE "2022-06-04" +//#define STRING_DISTRIBUTION_DATE "2022-08-06" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/config.ini b/Marlin/config.ini new file mode 100644 index 0000000000..0fb9fb0c93 --- /dev/null +++ b/Marlin/config.ini @@ -0,0 +1,211 @@ +# +# Marlin Firmware +# config.ini - Options to apply before the build +# +[config:base] +ini_use_config = none + +# Load all config: sections in this file +;ini_use_config = all +# Load config file relative to Marlin/ +;ini_use_config = another.ini +# Download configurations from GitHub +;ini_use_config = example/Creality/Ender-5 Plus @ bugfix-2.1.x +# Download configurations from your server +;ini_use_config = https://me.myserver.com/path/to/configs +# Evaluate config:base and do a config dump +;ini_use_config = base +;config_export = 2 + +[config:minimal] +motherboard = BOARD_RAMPS_14_EFB +serial_port = 0 +baudrate = 250000 + +use_watchdog = on +thermal_protection_hotends = on +thermal_protection_hysteresis = 4 +thermal_protection_period = 40 + +bufsize = 4 +block_buffer_size = 16 +max_cmd_size = 96 + +extruders = 1 +temp_sensor_0 = 1 + +temp_hysteresis = 3 +heater_0_mintemp = 5 +heater_0_maxtemp = 275 +preheat_1_temp_hotend = 180 + +bang_max = 255 +pidtemp = on +pid_k1 = 0.95 +pid_max = BANG_MAX +pid_functional_range = 10 + +default_kp = 22.20 +default_ki = 1.08 +default_kd = 114.00 + +x_driver_type = A4988 +y_driver_type = A4988 +z_driver_type = A4988 +e0_driver_type = A4988 + +x_bed_size = 200 +x_min_pos = 0 +x_max_pos = X_BED_SIZE + +y_bed_size = 200 +y_min_pos = 0 +y_max_pos = Y_BED_SIZE + +z_min_pos = 0 +z_max_pos = 200 + +x_home_dir = -1 +y_home_dir = -1 +z_home_dir = -1 + +use_xmin_plug = on +use_ymin_plug = on +use_zmin_plug = on + +x_min_endstop_inverting = false +y_min_endstop_inverting = false +z_min_endstop_inverting = false + +default_axis_steps_per_unit = { 80, 80, 400, 500 } +axis_relative_modes = { false, false, false, false } +default_max_feedrate = { 300, 300, 5, 25 } +default_max_acceleration = { 3000, 3000, 100, 10000 } + +homing_feedrate_mm_m = { (50*60), (50*60), (4*60) } +homing_bump_divisor = { 2, 2, 4 } + +x_enable_on = 0 +y_enable_on = 0 +z_enable_on = 0 +e_enable_on = 0 + +invert_x_dir = false +invert_y_dir = true +invert_z_dir = false +invert_e0_dir = false + +invert_e_step_pin = false +invert_x_step_pin = false +invert_y_step_pin = false +invert_z_step_pin = false + +disable_x = false +disable_y = false +disable_z = false +disable_e = false + +proportional_font_ratio = 1.0 +default_nominal_filament_dia = 1.75 + +junction_deviation_mm = 0.013 + +default_acceleration = 3000 +default_travel_acceleration = 3000 +default_retract_acceleration = 3000 + +default_minimumfeedrate = 0.0 +default_mintravelfeedrate = 0.0 + +minimum_planner_speed = 0.05 +min_steps_per_segment = 6 +default_minsegmenttime = 20000 + +[config:basic] +bed_overshoot = 10 +busy_while_heating = on +default_ejerk = 5.0 +default_keepalive_interval = 2 +default_leveling_fade_height = 0.0 +disable_inactive_extruder = on +display_charset_hd44780 = JAPANESE +eeprom_boot_silent = on +eeprom_chitchat = on +endstoppullups = on +extrude_maxlength = 200 +extrude_mintemp = 170 +host_keepalive_feature = on +hotend_overshoot = 15 +jd_handle_small_segments = on +lcd_info_screen_style = 0 +lcd_language = en +max_bed_power = 255 +mesh_inset = 0 +min_software_endstops = on +max_software_endstops = on +min_software_endstop_x = on +min_software_endstop_y = on +min_software_endstop_z = on +max_software_endstop_x = on +max_software_endstop_y = on +max_software_endstop_z = on +preheat_1_fan_speed = 0 +preheat_1_label = "PLA" +preheat_1_temp_bed = 70 +prevent_cold_extrusion = on +prevent_lengthy_extrude = on +printjob_timer_autostart = on +probing_margin = 10 +show_bootscreen = on +soft_pwm_scale = 0 +string_config_h_author = "(none, default config)" +temp_bed_hysteresis = 3 +temp_bed_residency_time = 10 +temp_bed_window = 1 +temp_residency_time = 10 +temp_window = 1 +validate_homing_endstops = on +xy_probe_feedrate = (133*60) +z_clearance_between_probes = 5 +z_clearance_deploy_probe = 10 +z_clearance_multi_probe = 5 + +[config:advanced] +arc_support = on +auto_report_temperatures = on +autotemp = on +autotemp_oldweight = 0.98 +bed_check_interval = 5000 +default_stepper_deactive_time = 120 +default_volumetric_extruder_limit = 0.00 +disable_inactive_e = true +disable_inactive_x = true +disable_inactive_y = true +disable_inactive_z = true +e0_auto_fan_pin = -1 +encoder_100x_steps_per_sec = 80 +encoder_10x_steps_per_sec = 30 +encoder_rate_multiplier = on +extended_capabilities_report = on +extruder_auto_fan_speed = 255 +extruder_auto_fan_temperature = 50 +fanmux0_pin = -1 +fanmux1_pin = -1 +fanmux2_pin = -1 +faster_gcode_parser = on +homing_bump_mm = { 5, 5, 2 } +max_arc_segment_mm = 1.0 +min_arc_segment_mm = 0.1 +min_circle_segments = 72 +n_arc_correction = 25 +serial_overrun_protection = on +slowdown = on +slowdown_divisor = 2 +temp_sensor_bed = 0 +thermal_protection_bed_hysteresis = 2 +thermocouple_max_errors = 15 +tx_buffer_size = 0 +watch_bed_temp_increase = 2 +watch_bed_temp_period = 60 +watch_temp_increase = 2 +watch_temp_period = 20 diff --git a/Marlin/src/HAL/AVR/inc/SanityCheck.h b/Marlin/src/HAL/AVR/inc/SanityCheck.h index 1c1d8d4413..89425ca853 100644 --- a/Marlin/src/HAL/AVR/inc/SanityCheck.h +++ b/Marlin/src/HAL/AVR/inc/SanityCheck.h @@ -35,11 +35,19 @@ || X_STEP_PIN == N || Y_STEP_PIN == N || Z_STEP_PIN == N \ || X_DIR_PIN == N || Y_DIR_PIN == N || Z_DIR_PIN == N \ || X_ENA_PIN == N || Y_ENA_PIN == N || Z_ENA_PIN == N \ + || BTN_EN1 == N || BTN_EN2 == N \ ) -#if CONF_SERIAL_IS(0) // D0-D1. No known conflicts. +#if CONF_SERIAL_IS(0) + // D0-D1. No known conflicts. #endif -#if CONF_SERIAL_IS(1) && (CHECK_SERIAL_PIN(18) || CHECK_SERIAL_PIN(19)) - #error "Serial Port 1 pin D18 and/or D19 conflicts with another pin on the board." +#if NOT_TARGET(__AVR_ATmega644P__, __AVR_ATmega1284P__) + #if CONF_SERIAL_IS(1) && (CHECK_SERIAL_PIN(18) || CHECK_SERIAL_PIN(19)) + #error "Serial Port 1 pin D18 and/or D19 conflicts with another pin on the board." + #endif +#else + #if CONF_SERIAL_IS(1) && (CHECK_SERIAL_PIN(10) || CHECK_SERIAL_PIN(11)) + #error "Serial Port 1 pin D10 and/or D11 conflicts with another pin on the board." + #endif #endif #if CONF_SERIAL_IS(2) && (CHECK_SERIAL_PIN(16) || CHECK_SERIAL_PIN(17)) #error "Serial Port 2 pin D16 and/or D17 conflicts with another pin on the board." diff --git a/Marlin/src/HAL/ESP32/HAL.h b/Marlin/src/HAL/ESP32/HAL.h index 600ca8f5ee..ddfedf92ee 100644 --- a/Marlin/src/HAL/ESP32/HAL.h +++ b/Marlin/src/HAL/ESP32/HAL.h @@ -60,8 +60,8 @@ #endif #endif -#define CRITICAL_SECTION_START() portENTER_CRITICAL(&spinlock) -#define CRITICAL_SECTION_END() portEXIT_CRITICAL(&spinlock) +#define CRITICAL_SECTION_START() portENTER_CRITICAL(&hal.spinlock) +#define CRITICAL_SECTION_END() portEXIT_CRITICAL(&hal.spinlock) #define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment #define PWM_FREQUENCY 1000u // Default PWM frequency when set_pwm_duty() is called without set_pwm_frequency() diff --git a/Marlin/src/HAL/LPC1768/upload_extra_script.py b/Marlin/src/HAL/LPC1768/upload_extra_script.py index 7975f151f7..3e23c63ca1 100755 --- a/Marlin/src/HAL/LPC1768/upload_extra_script.py +++ b/Marlin/src/HAL/LPC1768/upload_extra_script.py @@ -12,7 +12,7 @@ target_filename = "FIRMWARE.CUR" target_drive = "REARM" - import os,getpass,platform + import platform current_OS = platform.system() Import("env") @@ -26,7 +26,8 @@ def print_error(e): def before_upload(source, target, env): try: - # + from pathlib import Path + # # Find a disk for upload # upload_disk = 'Disk not found' @@ -38,6 +39,7 @@ def before_upload(source, target, env): # Windows - doesn't care about the disk's name, only cares about the drive letter import subprocess,string from ctypes import windll + from pathlib import PureWindowsPath # getting list of drives # https://stackoverflow.com/questions/827371/is-there-a-way-to-list-all-the-available-drive-letters-in-python @@ -49,7 +51,7 @@ def before_upload(source, target, env): bitmask >>= 1 for drive in drives: - final_drive_name = drive + ':\\' + final_drive_name = drive + ':' # print ('disc check: {}'.format(final_drive_name)) try: volume_info = str(subprocess.check_output('cmd /C dir ' + final_drive_name, stderr=subprocess.STDOUT)) @@ -59,29 +61,33 @@ def before_upload(source, target, env): else: if target_drive in volume_info and not target_file_found: # set upload if not found target file yet target_drive_found = True - upload_disk = final_drive_name + upload_disk = PureWindowsPath(final_drive_name) if target_filename in volume_info: if not target_file_found: - upload_disk = final_drive_name + upload_disk = PureWindowsPath(final_drive_name) target_file_found = True elif current_OS == 'Linux': # # platformio.ini will accept this for a Linux upload port designation: 'upload_port = /media/media_name/drive' # - drives = os.listdir(os.path.join(os.sep, 'media', getpass.getuser())) + import getpass + user = getpass.getuser() + mpath = Path('media', user) + drives = [ x for x in mpath.iterdir() if x.is_dir() ] if target_drive in drives: # If target drive is found, use it. target_drive_found = True - upload_disk = os.path.join(os.sep, 'media', getpass.getuser(), target_drive) + os.sep + upload_disk = mpath / target_drive else: for drive in drives: try: - files = os.listdir(os.path.join(os.sep, 'media', getpass.getuser(), drive)) + fpath = mpath / drive + files = [ x for x in fpath.iterdir() if x.is_file() ] except: continue else: if target_filename in files: - upload_disk = os.path.join(os.sep, 'media', getpass.getuser(), drive) + os.sep + upload_disk = mpath / drive target_file_found = True break # @@ -97,26 +103,28 @@ def before_upload(source, target, env): # # platformio.ini will accept this for a OSX upload port designation: 'upload_port = /media/media_name/drive' # - drives = os.listdir('/Volumes') # human readable names + dpath = Path('/Volumes') # human readable names + drives = [ x for x in dpath.iterdir() ] if target_drive in drives and not target_file_found: # set upload if not found target file yet target_drive_found = True - upload_disk = '/Volumes/' + target_drive + '/' + upload_disk = dpath / target_drive for drive in drives: try: - filenames = os.listdir('/Volumes/' + drive + '/') # will get an error if the drive is protected + fpath = dpath / drive # will get an error if the drive is protected + files = [ x for x in fpath.iterdir() ] except: continue else: - if target_filename in filenames: + if target_filename in files: if not target_file_found: - upload_disk = '/Volumes/' + drive + '/' + upload_disk = dpath / drive target_file_found = True # # Set upload_port to drive if found # if target_file_found or target_drive_found: - env.Replace(UPLOAD_PORT=upload_disk) + env.Replace(UPLOAD_PORT=str(upload_disk)) print('\nUpload disk: ', upload_disk, '\n') else: print_error('Autodetect Error') diff --git a/Marlin/src/HAL/STM32/sdio.cpp b/Marlin/src/HAL/STM32/sdio.cpp index e958d8c3bc..41fe90b825 100644 --- a/Marlin/src/HAL/STM32/sdio.cpp +++ b/Marlin/src/HAL/STM32/sdio.cpp @@ -33,227 +33,410 @@ #include #include -// use local drivers #if defined(STM32F103xE) || defined(STM32F103xG) - #include + #include + #include #elif defined(STM32F4xx) - #include + #include + #include + #include + #include #elif defined(STM32F7xx) - #include + #include + #include + #include + #include #elif defined(STM32H7xx) - #include + #define SDIO_FOR_STM32H7 + #include + #include + #include + #include #else - #error "SDIO only supported with STM32F103xE, STM32F103xG, STM32F4xx, STM32F7xx, or STM32H7xx." + #error "SDIO is only supported with STM32F103xE, STM32F103xG, STM32F4xx, STM32F7xx, and STM32H7xx." #endif +// SDIO Max Clock (naming from STM Manual, don't change) +#define SDIOCLK 48000000 + // Target Clock, configurable. Default is 18MHz, from STM32F1 #ifndef SDIO_CLOCK #define SDIO_CLOCK 18000000 // 18 MHz #endif -#define SD_TIMEOUT 1000 // ms +SD_HandleTypeDef hsd; // SDIO structure -// SDIO Max Clock (naming from STM Manual, don't change) -#define SDIOCLK 48000000 +static uint32_t clock_to_divider(uint32_t clk) { + #ifdef SDIO_FOR_STM32H7 + // SDMMC_CK frequency = sdmmc_ker_ck / [2 * CLKDIV]. + uint32_t sdmmc_clk = HAL_RCCEx_GetPeriphCLKFreq(RCC_PERIPHCLK_SDMMC); + return sdmmc_clk / (2U * SDIO_CLOCK) + (sdmmc_clk % (2U * SDIO_CLOCK) != 0); + #else + // limit the SDIO master clock to 8/3 of PCLK2. See STM32 Manuals + // Also limited to no more than 48Mhz (SDIOCLK). + const uint32_t pclk2 = HAL_RCC_GetPCLK2Freq(); + clk = min(clk, (uint32_t)(pclk2 * 8 / 3)); + clk = min(clk, (uint32_t)SDIOCLK); + // Round up divider, so we don't run the card over the speed supported, + // and subtract by 2, because STM32 will add 2, as written in the manual: + // SDIO_CK frequency = SDIOCLK / [CLKDIV + 2] + return pclk2 / clk + (pclk2 % clk != 0) - 2; + #endif +} -#if defined(STM32F1xx) - DMA_HandleTypeDef hdma_sdio; - extern "C" void DMA2_Channel4_5_IRQHandler(void) { - HAL_DMA_IRQHandler(&hdma_sdio); - } -#elif defined(STM32F4xx) - DMA_HandleTypeDef hdma_sdio_rx; - DMA_HandleTypeDef hdma_sdio_tx; - extern "C" void DMA2_Stream3_IRQHandler(void) { - HAL_DMA_IRQHandler(&hdma_sdio_rx); +// Start the SDIO clock +void HAL_SD_MspInit(SD_HandleTypeDef *hsd) { + UNUSED(hsd); + #ifdef SDIO_FOR_STM32H7 + pinmap_pinout(PC_12, PinMap_SD); + pinmap_pinout(PD_2, PinMap_SD); + pinmap_pinout(PC_8, PinMap_SD); + #if PINS_EXIST(SDIO_D1, SDIO_D2, SDIO_D3) // Define D1-D3 only for 4-bit wide SDIO bus + pinmap_pinout(PC_9, PinMap_SD); + pinmap_pinout(PC_10, PinMap_SD); + pinmap_pinout(PC_11, PinMap_SD); + #endif + __HAL_RCC_SDMMC1_CLK_ENABLE(); + HAL_NVIC_EnableIRQ(SDMMC1_IRQn); + #else + __HAL_RCC_SDIO_CLK_ENABLE(); + #endif +} + +#ifdef SDIO_FOR_STM32H7 + + #define SD_TIMEOUT 1000 // ms + + extern "C" void SDMMC1_IRQHandler(void) { HAL_SD_IRQHandler(&hsd); } + + uint8_t waitingRxCplt = 0, waitingTxCplt = 0; + void HAL_SD_TxCpltCallback(SD_HandleTypeDef *hsdio) { waitingTxCplt = 0; } + void HAL_SD_RxCpltCallback(SD_HandleTypeDef *hsdio) { waitingRxCplt = 0; } + + void HAL_SD_MspDeInit(SD_HandleTypeDef *hsd) { + __HAL_RCC_SDMMC1_FORCE_RESET(); delay(10); + __HAL_RCC_SDMMC1_RELEASE_RESET(); delay(10); } - extern "C" void DMA2_Stream6_IRQHandler(void) { - HAL_DMA_IRQHandler(&hdma_sdio_tx); + bool SDIO_Init() { + HAL_StatusTypeDef sd_state = HAL_OK; + if (hsd.Instance == SDMMC1) HAL_SD_DeInit(&hsd); + + // HAL SD initialization + hsd.Instance = SDMMC1; + hsd.Init.ClockEdge = SDMMC_CLOCK_EDGE_RISING; + hsd.Init.ClockPowerSave = SDMMC_CLOCK_POWER_SAVE_DISABLE; + hsd.Init.BusWide = SDMMC_BUS_WIDE_1B; + hsd.Init.HardwareFlowControl = SDMMC_HARDWARE_FLOW_CONTROL_DISABLE; + hsd.Init.ClockDiv = clock_to_divider(SDIO_CLOCK); + sd_state = HAL_SD_Init(&hsd); + + #if PINS_EXIST(SDIO_D1, SDIO_D2, SDIO_D3) + if (sd_state == HAL_OK) + sd_state = HAL_SD_ConfigWideBusOperation(&hsd, SDMMC_BUS_WIDE_4B); + #endif + + return (sd_state == HAL_OK); } -#elif defined(STM32H7xx) - #define __HAL_RCC_SDIO_FORCE_RESET __HAL_RCC_SDMMC1_FORCE_RESET - #define __HAL_RCC_SDIO_RELEASE_RESET __HAL_RCC_SDMMC1_RELEASE_RESET - #define __HAL_RCC_SDIO_CLK_ENABLE __HAL_RCC_SDMMC1_CLK_ENABLE - #define SDIO SDMMC1 - #define SDIO_IRQn SDMMC1_IRQn - #define SDIO_IRQHandler SDMMC1_IRQHandler - #define SDIO_CLOCK_EDGE_RISING SDMMC_CLOCK_EDGE_RISING - #define SDIO_CLOCK_POWER_SAVE_DISABLE SDMMC_CLOCK_POWER_SAVE_DISABLE - #define SDIO_BUS_WIDE_1B SDMMC_BUS_WIDE_1B - #define SDIO_BUS_WIDE_4B SDMMC_BUS_WIDE_4B - #define SDIO_HARDWARE_FLOW_CONTROL_DISABLE SDMMC_HARDWARE_FLOW_CONTROL_DISABLE -#endif -uint8_t waitingRxCplt = 0; -uint8_t waitingTxCplt = 0; -SD_HandleTypeDef hsd; +#else // !SDIO_FOR_STM32H7 -extern "C" void SDIO_IRQHandler(void) { - HAL_SD_IRQHandler(&hsd); -} + #define SD_TIMEOUT 500 // ms -void HAL_SD_TxCpltCallback(SD_HandleTypeDef *hsdio) { - waitingTxCplt = 0; -} + // SDIO retries, configurable. Default is 3, from STM32F1 + #ifndef SDIO_READ_RETRIES + #define SDIO_READ_RETRIES 3 + #endif -void HAL_SD_RxCpltCallback(SD_HandleTypeDef *hsdio) { - waitingRxCplt = 0; -} + // F4 supports one DMA for RX and another for TX, but Marlin will never + // do read and write at same time, so we use the same DMA for both. + DMA_HandleTypeDef hdma_sdio; -void HAL_SD_MspInit(SD_HandleTypeDef *hsd) { - pinmap_pinout(PC_12, PinMap_SD); - pinmap_pinout(PD_2, PinMap_SD); - pinmap_pinout(PC_8, PinMap_SD); - #if PINS_EXIST(SDIO_D1, SDIO_D2, SDIO_D3) // define D1-D3 only if have a four bit wide SDIO bus - // D1-D3 - pinmap_pinout(PC_9, PinMap_SD); - pinmap_pinout(PC_10, PinMap_SD); - pinmap_pinout(PC_11, PinMap_SD); + #ifdef STM32F1xx + #define DMA_IRQ_HANDLER DMA2_Channel4_5_IRQHandler + #elif defined(STM32F4xx) + #define DMA_IRQ_HANDLER DMA2_Stream3_IRQHandler + #else + #error "Unknown STM32 architecture." #endif - __HAL_RCC_SDIO_CLK_ENABLE(); - HAL_NVIC_EnableIRQ(SDIO_IRQn); + extern "C" void SDIO_IRQHandler(void) { HAL_SD_IRQHandler(&hsd); } + extern "C" void DMA_IRQ_HANDLER(void) { HAL_DMA_IRQHandler(&hdma_sdio); } + + /* + SDIO_INIT_CLK_DIV is 118 + SDIO clock frequency is 48MHz / (TRANSFER_CLOCK_DIV + 2) + SDIO init clock frequency should not exceed 400kHz = 48MHz / (118 + 2) + + Default TRANSFER_CLOCK_DIV is 2 (118 / 40) + Default SDIO clock frequency is 48MHz / (2 + 2) = 12 MHz + This might be too fast for stable SDIO operations + + MKS Robin SDIO seems stable with BusWide 1bit and ClockDiv 8 (i.e., 4.8MHz SDIO clock frequency) + More testing is required as there are clearly some 4bit init problems. + */ + + void go_to_transfer_speed() { + /* Default SDIO peripheral configuration for SD card initialization */ + hsd.Init.ClockEdge = hsd.Init.ClockEdge; + hsd.Init.ClockBypass = hsd.Init.ClockBypass; + hsd.Init.ClockPowerSave = hsd.Init.ClockPowerSave; + hsd.Init.BusWide = hsd.Init.BusWide; + hsd.Init.HardwareFlowControl = hsd.Init.HardwareFlowControl; + hsd.Init.ClockDiv = clock_to_divider(SDIO_CLOCK); + + /* Initialize SDIO peripheral interface with default configuration */ + SDIO_Init(hsd.Instance, hsd.Init); + } - // DMA Config - #if defined(STM32F1xx) - __HAL_RCC_DMA2_CLK_ENABLE(); - HAL_NVIC_EnableIRQ(DMA2_Channel4_5_IRQn); - hdma_sdio.Instance = DMA2_Channel4; - hdma_sdio.Init.Direction = DMA_PERIPH_TO_MEMORY; + void SD_LowLevel_Init() { + uint32_t tempreg; + + // Enable GPIO clocks + __HAL_RCC_GPIOC_CLK_ENABLE(); + __HAL_RCC_GPIOD_CLK_ENABLE(); + + GPIO_InitTypeDef GPIO_InitStruct; + + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = 1; // GPIO_NOPULL + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; + + #if DISABLED(STM32F1xx) + GPIO_InitStruct.Alternate = GPIO_AF12_SDIO; + #endif + + GPIO_InitStruct.Pin = GPIO_PIN_8 | GPIO_PIN_12; // D0 & SCK + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + #if PINS_EXIST(SDIO_D1, SDIO_D2, SDIO_D3) // define D1-D3 only if have a four bit wide SDIO bus + GPIO_InitStruct.Pin = GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11; // D1-D3 + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + #endif + + // Configure PD.02 CMD line + GPIO_InitStruct.Pin = GPIO_PIN_2; + HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); + + // Setup DMA + #ifdef STM32F1xx + hdma_sdio.Init.Mode = DMA_NORMAL; + hdma_sdio.Instance = DMA2_Channel4; + HAL_NVIC_EnableIRQ(DMA2_Channel4_5_IRQn); + #elif defined(STM32F4xx) + hdma_sdio.Init.Mode = DMA_PFCTRL; + hdma_sdio.Instance = DMA2_Stream3; + hdma_sdio.Init.Channel = DMA_CHANNEL_4; + hdma_sdio.Init.FIFOMode = DMA_FIFOMODE_ENABLE; + hdma_sdio.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; + hdma_sdio.Init.MemBurst = DMA_MBURST_INC4; + hdma_sdio.Init.PeriphBurst = DMA_PBURST_INC4; + HAL_NVIC_EnableIRQ(DMA2_Stream3_IRQn); + #endif + HAL_NVIC_EnableIRQ(SDIO_IRQn); hdma_sdio.Init.PeriphInc = DMA_PINC_DISABLE; hdma_sdio.Init.MemInc = DMA_MINC_ENABLE; hdma_sdio.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; hdma_sdio.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; - hdma_sdio.Init.Mode = DMA_NORMAL; hdma_sdio.Init.Priority = DMA_PRIORITY_LOW; - HAL_DMA_Init(&hdma_sdio); + __HAL_LINKDMA(&hsd, hdmarx, hdma_sdio); + __HAL_LINKDMA(&hsd, hdmatx, hdma_sdio); + + #ifdef STM32F1xx + __HAL_RCC_SDIO_CLK_ENABLE(); + __HAL_RCC_DMA2_CLK_ENABLE(); + #else + __HAL_RCC_SDIO_FORCE_RESET(); delay(2); + __HAL_RCC_SDIO_RELEASE_RESET(); delay(2); + __HAL_RCC_SDIO_CLK_ENABLE(); + + __HAL_RCC_DMA2_FORCE_RESET(); delay(2); + __HAL_RCC_DMA2_RELEASE_RESET(); delay(2); + __HAL_RCC_DMA2_CLK_ENABLE(); + #endif + + // Initialize the SDIO (with initial <400Khz Clock) + tempreg = 0 // Reset value + | SDIO_CLKCR_CLKEN // Clock enabled + | SDIO_INIT_CLK_DIV; // Clock Divider. Clock = 48000 / (118 + 2) = 400Khz + // Keep the rest at 0 => HW_Flow Disabled, Rising Clock Edge, Disable CLK ByPass, Bus Width = 0, Power save Disable + SDIO->CLKCR = tempreg; + + // Power up the SDIO + SDIO_PowerState_ON(SDIO); + hsd.Instance = SDIO; + } - __HAL_LINKDMA(hsd, hdmarx ,hdma_sdio); - __HAL_LINKDMA(hsd, hdmatx, hdma_sdio); - #elif defined(STM32F4xx) - __HAL_RCC_DMA2_CLK_ENABLE(); - HAL_NVIC_EnableIRQ(DMA2_Stream3_IRQn); - HAL_NVIC_EnableIRQ(DMA2_Stream6_IRQn); - hdma_sdio_rx.Instance = DMA2_Stream3; - hdma_sdio_rx.Init.Channel = DMA_CHANNEL_4; - hdma_sdio_rx.Init.Direction = DMA_PERIPH_TO_MEMORY; - hdma_sdio_rx.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_sdio_rx.Init.MemInc = DMA_MINC_ENABLE; - hdma_sdio_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; - hdma_sdio_rx.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; - hdma_sdio_rx.Init.Mode = DMA_PFCTRL; - hdma_sdio_rx.Init.Priority = DMA_PRIORITY_LOW; - hdma_sdio_rx.Init.FIFOMode = DMA_FIFOMODE_ENABLE; - hdma_sdio_rx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - hdma_sdio_rx.Init.MemBurst = DMA_MBURST_INC4; - hdma_sdio_rx.Init.PeriphBurst = DMA_PBURST_INC4; - HAL_DMA_Init(&hdma_sdio_rx); - - __HAL_LINKDMA(hsd,hdmarx,hdma_sdio_rx); - - hdma_sdio_tx.Instance = DMA2_Stream6; - hdma_sdio_tx.Init.Channel = DMA_CHANNEL_4; - hdma_sdio_tx.Init.Direction = DMA_MEMORY_TO_PERIPH; - hdma_sdio_tx.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_sdio_tx.Init.MemInc = DMA_MINC_ENABLE; - hdma_sdio_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; - hdma_sdio_tx.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; - hdma_sdio_tx.Init.Mode = DMA_PFCTRL; - hdma_sdio_tx.Init.Priority = DMA_PRIORITY_LOW; - hdma_sdio_tx.Init.FIFOMode = DMA_FIFOMODE_ENABLE; - hdma_sdio_tx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - hdma_sdio_tx.Init.MemBurst = DMA_MBURST_INC4; - hdma_sdio_tx.Init.PeriphBurst = DMA_PBURST_INC4; - HAL_DMA_Init(&hdma_sdio_tx); - - __HAL_LINKDMA(hsd,hdmatx,hdma_sdio_tx); - #endif -} + bool SDIO_Init() { + uint8_t retryCnt = SDIO_READ_RETRIES; -void HAL_SD_MspDeInit(SD_HandleTypeDef *hsd) { - #if !defined(STM32F1xx) - __HAL_RCC_SDIO_FORCE_RESET(); - delay(10); - __HAL_RCC_SDIO_RELEASE_RESET(); - delay(10); - #endif -} + bool status; + hsd.Instance = SDIO; + hsd.State = HAL_SD_STATE_RESET; -static uint32_t clock_to_divider(uint32_t clk) { - #if defined(STM32H7xx) - // SDMMC_CK frequency = sdmmc_ker_ck / [2 * CLKDIV]. - uint32_t sdmmc_clk = HAL_RCCEx_GetPeriphCLKFreq(RCC_PERIPHCLK_SDMMC); - return sdmmc_clk / (2U * SDIO_CLOCK) + (sdmmc_clk % (2U * SDIO_CLOCK) != 0); - #else - // limit the SDIO master clock to 8/3 of PCLK2. See STM32 Manuals - // Also limited to no more than 48Mhz (SDIOCLK). - const uint32_t pclk2 = HAL_RCC_GetPCLK2Freq(); - clk = min(clk, (uint32_t)(pclk2 * 8 / 3)); - clk = min(clk, (uint32_t)SDIOCLK); - // Round up divider, so we don't run the card over the speed supported, - // and subtract by 2, because STM32 will add 2, as written in the manual: - // SDIO_CK frequency = SDIOCLK / [CLKDIV + 2] - return pclk2 / clk + (pclk2 % clk != 0) - 2; - #endif -} + SD_LowLevel_Init(); -bool SDIO_Init() { - HAL_StatusTypeDef sd_state = HAL_OK; - if (hsd.Instance == SDIO) - HAL_SD_DeInit(&hsd); - - /* HAL SD initialization */ - hsd.Instance = SDIO; - hsd.Init.ClockEdge = SDIO_CLOCK_EDGE_RISING; - hsd.Init.ClockPowerSave = SDIO_CLOCK_POWER_SAVE_DISABLE; - hsd.Init.BusWide = SDIO_BUS_WIDE_1B; - hsd.Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_DISABLE; - hsd.Init.ClockDiv = clock_to_divider(SDIO_CLOCK); - sd_state = HAL_SD_Init(&hsd); - - #if PINS_EXIST(SDIO_D1, SDIO_D2, SDIO_D3) - if (sd_state == HAL_OK) { - sd_state = HAL_SD_ConfigWideBusOperation(&hsd, SDIO_BUS_WIDE_4B); + uint8_t retry_Cnt = retryCnt; + for (;;) { + hal.watchdog_refresh(); + status = (bool) HAL_SD_Init(&hsd); + if (!status) break; + if (!--retry_Cnt) return false; // return failing status if retries are exhausted } - #endif - return (sd_state == HAL_OK) ? true : false; -} + go_to_transfer_speed(); + + #if PINS_EXIST(SDIO_D1, SDIO_D2, SDIO_D3) // go to 4 bit wide mode if pins are defined + retry_Cnt = retryCnt; + for (;;) { + hal.watchdog_refresh(); + if (!HAL_SD_ConfigWideBusOperation(&hsd, SDIO_BUS_WIDE_4B)) break; // some cards are only 1 bit wide so a pass here is not required + if (!--retry_Cnt) break; + } + if (!retry_Cnt) { // wide bus failed, go back to one bit wide mode + hsd.State = (HAL_SD_StateTypeDef) 0; // HAL_SD_STATE_RESET + SD_LowLevel_Init(); + retry_Cnt = retryCnt; + for (;;) { + hal.watchdog_refresh(); + status = (bool) HAL_SD_Init(&hsd); + if (!status) break; + if (!--retry_Cnt) return false; // return failing status if retries are exhausted + } + go_to_transfer_speed(); + } + #endif + + return true; + } -bool SDIO_ReadBlock(uint32_t block, uint8_t *dst) { - uint32_t timeout = HAL_GetTick() + SD_TIMEOUT; + /** + * @brief Read or Write a block + * @details Read or Write a block with SDIO + * + * @param block The block index + * @param src The data buffer source for a write + * @param dst The data buffer destination for a read + * + * @return true on success + */ + static bool SDIO_ReadWriteBlock_DMA(uint32_t block, const uint8_t *src, uint8_t *dst) { + if (HAL_SD_GetCardState(&hsd) != HAL_SD_CARD_TRANSFER) return false; + + hal.watchdog_refresh(); + + HAL_StatusTypeDef ret; + if (src) { + hdma_sdio.Init.Direction = DMA_MEMORY_TO_PERIPH; + HAL_DMA_Init(&hdma_sdio); + ret = HAL_SD_WriteBlocks_DMA(&hsd, (uint8_t*)src, block, 1); + } + else { + hdma_sdio.Init.Direction = DMA_PERIPH_TO_MEMORY; + HAL_DMA_Init(&hdma_sdio); + ret = HAL_SD_ReadBlocks_DMA(&hsd, (uint8_t*)dst, block, 1); + } - while (HAL_SD_GetCardState(&hsd) != HAL_SD_CARD_TRANSFER) { - if (HAL_GetTick() >= timeout) return false; + if (ret != HAL_OK) { + HAL_DMA_Abort_IT(&hdma_sdio); + HAL_DMA_DeInit(&hdma_sdio); + return false; + } + + millis_t timeout = millis() + SD_TIMEOUT; + // Wait the transfer + while (hsd.State != HAL_SD_STATE_READY) { + if (ELAPSED(millis(), timeout)) { + HAL_DMA_Abort_IT(&hdma_sdio); + HAL_DMA_DeInit(&hdma_sdio); + return false; + } + } + + while (__HAL_DMA_GET_FLAG(&hdma_sdio, __HAL_DMA_GET_TC_FLAG_INDEX(&hdma_sdio)) != 0 + || __HAL_DMA_GET_FLAG(&hdma_sdio, __HAL_DMA_GET_TE_FLAG_INDEX(&hdma_sdio)) != 0) { /* nada */ } + + HAL_DMA_Abort_IT(&hdma_sdio); + HAL_DMA_DeInit(&hdma_sdio); + + timeout = millis() + SD_TIMEOUT; + while (HAL_SD_GetCardState(&hsd) != HAL_SD_CARD_TRANSFER) if (ELAPSED(millis(), timeout)) return false; + + return true; } - waitingRxCplt = 1; - if (HAL_SD_ReadBlocks_DMA(&hsd, (uint8_t *)dst, block, 1) != HAL_OK) - return false; +#endif // !SDIO_FOR_STM32H7 + +/** + * @brief Read a block + * @details Read a block from media with SDIO + * + * @param block The block index + * @param src The block buffer + * + * @return true on success + */ +bool SDIO_ReadBlock(uint32_t block, uint8_t *dst) { + #ifdef SDIO_FOR_STM32H7 + + uint32_t timeout = HAL_GetTick() + SD_TIMEOUT; + + while (HAL_SD_GetCardState(&hsd) != HAL_SD_CARD_TRANSFER) + if (HAL_GetTick() >= timeout) return false; - timeout = HAL_GetTick() + SD_TIMEOUT; - while (waitingRxCplt) - if (HAL_GetTick() >= timeout) return false; + waitingRxCplt = 1; + if (HAL_SD_ReadBlocks_DMA(&hsd, (uint8_t*)dst, block, 1) != HAL_OK) + return false; + + timeout = HAL_GetTick() + SD_TIMEOUT; + while (waitingRxCplt) + if (HAL_GetTick() >= timeout) return false; + + return true; + + #else + + uint8_t retries = SDIO_READ_RETRIES; + while (retries--) if (SDIO_ReadWriteBlock_DMA(block, nullptr, dst)) return true; + return false; - return true; + #endif } +/** + * @brief Write a block + * @details Write a block to media with SDIO + * + * @param block The block index + * @param src The block data + * + * @return true on success + */ bool SDIO_WriteBlock(uint32_t block, const uint8_t *src) { - uint32_t timeout = HAL_GetTick() + SD_TIMEOUT; + #ifdef SDIO_FOR_STM32H7 - while (HAL_SD_GetCardState(&hsd) != HAL_SD_CARD_TRANSFER) - if (HAL_GetTick() >= timeout) return false; + uint32_t timeout = HAL_GetTick() + SD_TIMEOUT; - waitingTxCplt = 1; - if (HAL_SD_WriteBlocks_DMA(&hsd, (uint8_t *)src, block, 1) != HAL_OK) - return false; + while (HAL_SD_GetCardState(&hsd) != HAL_SD_CARD_TRANSFER) + if (HAL_GetTick() >= timeout) return false; + + waitingTxCplt = 1; + if (HAL_SD_WriteBlocks_DMA(&hsd, (uint8_t*)src, block, 1) != HAL_OK) + return false; - timeout = HAL_GetTick() + SD_TIMEOUT; - while (waitingTxCplt) - if (HAL_GetTick() >= timeout) return false; + timeout = HAL_GetTick() + SD_TIMEOUT; + while (waitingTxCplt) + if (HAL_GetTick() >= timeout) return false; - return true; + return true; + + #else + + uint8_t retries = SDIO_READ_RETRIES; + while (retries--) if (SDIO_ReadWriteBlock_DMA(block, src, nullptr)) return true; + return false; + + #endif } bool SDIO_IsReady() { diff --git a/Marlin/src/HAL/STM32/tft/tft_ltdc.cpp b/Marlin/src/HAL/STM32/tft/tft_ltdc.cpp index 66cfd65995..95871bf41f 100644 --- a/Marlin/src/HAL/STM32/tft/tft_ltdc.cpp +++ b/Marlin/src/HAL/STM32/tft/tft_ltdc.cpp @@ -372,9 +372,9 @@ void TFT_LTDC::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Cou if (MemoryIncrease == DMA_PINC_ENABLE) { DrawImage(x_min, y_cur, x_min + width, y_cur + height, Data); Data += width * height; - } else { - DrawRect(x_min, y_cur, x_min + width, y_cur + height, *Data); } + else + DrawRect(x_min, y_cur, x_min + width, y_cur + height, *Data); y_cur += height; } diff --git a/Marlin/src/HAL/shared/HAL_spi_L6470.cpp b/Marlin/src/HAL/shared/HAL_spi_L6470.cpp deleted file mode 100644 index 5d4ce89b27..0000000000 --- a/Marlin/src/HAL/shared/HAL_spi_L6470.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * - * Based on Sprinter and grbl. - * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm - * - * This program 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. - * - * This program 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 this program. If not, see . - * - */ - -/** - * Software L6470 SPI functions originally from Arduino Sd2Card Library - * Copyright (c) 2009 by William Greiman - */ - -#include "../../inc/MarlinConfig.h" - -#if HAS_L64XX - -#include "Delay.h" - -#include "../../core/serial.h" -#include "../../libs/L64XX/L64XX_Marlin.h" - -// Make sure GCC optimizes this file. -// Note that this line triggers a bug in GCC which is fixed by casting. -// See the note below. -#pragma GCC optimize (3) - -// run at ~4Mhz -inline uint8_t L6470_SpiTransfer_Mode_0(uint8_t b) { // using Mode 0 - for (uint8_t bits = 8; bits--;) { - WRITE(L6470_CHAIN_MOSI_PIN, b & 0x80); - b <<= 1; // little setup time - - WRITE(L6470_CHAIN_SCK_PIN, HIGH); - DELAY_NS(125); // 10 cycles @ 84mhz - - b |= (READ(L6470_CHAIN_MISO_PIN) != 0); - - WRITE(L6470_CHAIN_SCK_PIN, LOW); - DELAY_NS(125); // 10 cycles @ 84mhz - } - return b; -} - -inline uint8_t L6470_SpiTransfer_Mode_3(uint8_t b) { // using Mode 3 - for (uint8_t bits = 8; bits--;) { - WRITE(L6470_CHAIN_SCK_PIN, LOW); - WRITE(L6470_CHAIN_MOSI_PIN, b & 0x80); - - DELAY_NS(125); // 10 cycles @ 84mhz - WRITE(L6470_CHAIN_SCK_PIN, HIGH); - DELAY_NS(125); // Need more delay for fast CPUs - - b <<= 1; // little setup time - b |= (READ(L6470_CHAIN_MISO_PIN) != 0); - } - DELAY_NS(125); // 10 cycles @ 84mhz - return b; -} - -/** - * L64XX methods for SPI init and transfer - */ -void L64XX_Marlin::spi_init() { - OUT_WRITE(L6470_CHAIN_SS_PIN, HIGH); - OUT_WRITE(L6470_CHAIN_SCK_PIN, HIGH); - OUT_WRITE(L6470_CHAIN_MOSI_PIN, HIGH); - SET_INPUT(L6470_CHAIN_MISO_PIN); - - #if PIN_EXISTS(L6470_BUSY) - SET_INPUT(L6470_BUSY_PIN); - #endif - - OUT_WRITE(L6470_CHAIN_MOSI_PIN, HIGH); -} - -uint8_t L64XX_Marlin::transfer_single(uint8_t data, int16_t ss_pin) { - // First device in chain has data sent last - extDigitalWrite(ss_pin, LOW); - - hal.isr_off(); // Disable interrupts during SPI transfer (can't allow partial command to chips) - const uint8_t data_out = L6470_SpiTransfer_Mode_3(data); - hal.isr_on(); // Enable interrupts - - extDigitalWrite(ss_pin, HIGH); - return data_out; -} - -uint8_t L64XX_Marlin::transfer_chain(uint8_t data, int16_t ss_pin, uint8_t chain_position) { - uint8_t data_out = 0; - - // first device in chain has data sent last - extDigitalWrite(ss_pin, LOW); - - for (uint8_t i = L64XX::chain[0]; !L64xxManager.spi_abort && i >= 1; i--) { // Send data unless aborted - hal.isr_off(); // Disable interrupts during SPI transfer (can't allow partial command to chips) - const uint8_t temp = L6470_SpiTransfer_Mode_3(uint8_t(i == chain_position ? data : dSPIN_NOP)); - hal.isr_on(); // Enable interrupts - if (i == chain_position) data_out = temp; - } - - extDigitalWrite(ss_pin, HIGH); - return data_out; -} - -/** - * Platform-supplied L6470 buffer transfer method - */ -void L64XX_Marlin::transfer(uint8_t L6470_buf[], const uint8_t length) { - // First device in chain has its data sent last - - if (spi_active) { // Interrupted SPI transfer so need to - WRITE(L6470_CHAIN_SS_PIN, HIGH); // guarantee min high of 650ns - DELAY_US(1); - } - - WRITE(L6470_CHAIN_SS_PIN, LOW); - for (uint8_t i = length; i >= 1; i--) - L6470_SpiTransfer_Mode_3(uint8_t(L6470_buf[i])); - WRITE(L6470_CHAIN_SS_PIN, HIGH); -} - -#pragma GCC reset_options - -#endif // HAS_L64XX diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index db09920b1b..d38eab2634 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -39,17 +39,13 @@ #endif #include -#include "core/utility.h" - +#include "module/endstops.h" #include "module/motion.h" #include "module/planner.h" -#include "module/endstops.h" -#include "module/temperature.h" -#include "module/settings.h" #include "module/printcounter.h" // PrintCounter or Stopwatch - +#include "module/settings.h" #include "module/stepper.h" -#include "module/stepper/indirection.h" +#include "module/temperature.h" #include "gcode/gcode.h" #include "gcode/parser.h" @@ -125,6 +121,10 @@ #include "feature/bltouch.h" #endif +#if ENABLED(BD_SENSOR) + #include "feature/bedlevel/bdl/bdl.h" +#endif + #if ENABLED(POLL_JOG) #include "feature/joystick.h" #endif @@ -228,10 +228,6 @@ #include "feature/mmu/mmu2.h" #endif -#if HAS_L64XX - #include "libs/L64XX/L64XX_Marlin.h" -#endif - #if ENABLED(PASSWORD_FEATURE) #include "feature/password/password.h" #endif @@ -252,6 +248,10 @@ #include "feature/easythreed_ui.h" #endif +#if ENABLED(MARLIN_TEST_BUILD) + #include "tests/marlin_tests.h" +#endif + PGMSTR(M112_KILL_STR, "M112 Shutdown"); MarlinState marlin_state = MF_INITIALIZING; @@ -420,7 +420,7 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) { SERIAL_ERROR_START(); SERIAL_ECHOPGM(STR_KILL_PRE); SERIAL_ECHOLNPGM(STR_KILL_INACTIVE_TIME, parser.command_ptr); - kill(F("Printer not able to process GCodes")); + kill(F("Printer not able to process GCodes")); // @advi3++ } const bool has_blocks = planner.has_blocks_queued(); // Any moves in the planner? @@ -434,7 +434,7 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) { if (!has_blocks && !do_reset_timeout && gcode.stepper_inactive_timeout()) { if (!already_shutdown_steppers) { - already_shutdown_steppers = true; // L6470 SPI will consume 99% of free time without this + already_shutdown_steppers = true; // Individual axes will be disabled if configured TERN_(DISABLE_INACTIVE_X, stepper.disable_axis(X_AXIS)); @@ -733,8 +733,6 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) { TERN_(MONITOR_DRIVER_STATUS, monitor_tmc_drivers()); - TERN_(MONITOR_L6470_DRIVER_STATUS, L64xxManager.monitor_driver()); - // Limit check_axes_activity frequency to 10Hz static millis_t next_check_axes_ms = 0; if (ELAPSED(ms, next_check_axes_ms)) { @@ -785,11 +783,14 @@ void idle(bool no_stepper_sleep/*=false*/) { if (++idle_depth > 5) SERIAL_ECHOLNPGM("idle() call depth: ", idle_depth); #endif + // Bed Distance Sensor task + TERN_(BD_SENSOR, bdl.process()); + // Core Marlin activities manage_inactivity(no_stepper_sleep); // Manage Heaters (and Watchdog) - thermalManager.manage_heater(); + thermalManager.task(); // Max7219 heartbeat, animation, etc TERN_(MAX7219_DEBUG, max7219.idle_tasks()); @@ -883,7 +884,7 @@ void idle(bool no_stepper_sleep/*=false*/) { return; } - +// @advi3++ void kill(FSTR_P const lcd_error/*=nullptr*/, FSTR_P const lcd_component/*=nullptr*/, const bool steppers_off/*=false*/) { // @advi3++ kill(NAN, lcd_error, lcd_component, steppers_off); } @@ -899,10 +900,10 @@ void kill(float temp, FSTR_P const lcd_error/*=nullptr*/, FSTR_P const lcd_compo // Echo the LCD message to serial for extra context if (lcd_error) { SERIAL_ECHO_START(); SERIAL_ECHOLNF(lcd_error); } - if(!isnan(temp)) { SERIAL_ECHO_START(); SERIAL_ECHOLNPAIR_F("Temp:", temp); } + if(!isnan(temp)) { SERIAL_ECHO_START(); SERIAL_ECHOLNPAIR_F("Temp:", temp); } // @advi3++ #if HAS_DISPLAY - ui.kill_screen(temp, lcd_error ?: GET_TEXT_F(MSG_KILLED), lcd_component ?: FPSTR(NUL_STR)); + ui.kill_screen(temp, lcd_error ?: GET_TEXT_F(MSG_KILLED), lcd_component ?: FPSTR(NUL_STR)); // @advi3++ #else UNUSED(lcd_error); UNUSED(lcd_component); #endif @@ -1070,7 +1071,6 @@ inline void tmc_standby_setup() { * • TMC220x Stepper Drivers (Serial) * • PSU control * • Power-loss Recovery - * • L64XX Stepper Drivers (SPI) * • Stepper Driver Reset: DISABLE * • TMC Stepper Drivers (SPI) * • Run hal.init_board() for additional pins setup @@ -1233,10 +1233,10 @@ void setup() { SETUP_RUN(hal.init()); // Init and disable SPI thermocouples; this is still needed - #if TEMP_SENSOR_0_IS_MAX_TC || (TEMP_SENSOR_REDUNDANT_IS_MAX_TC && REDUNDANT_TEMP_MATCH(SOURCE, E0)) + #if TEMP_SENSOR_IS_MAX_TC(0) || (TEMP_SENSOR_IS_MAX_TC(REDUNDANT) && REDUNDANT_TEMP_MATCH(SOURCE, E0)) OUT_WRITE(TEMP_0_CS_PIN, HIGH); // Disable #endif - #if TEMP_SENSOR_1_IS_MAX_TC || (TEMP_SENSOR_REDUNDANT_IS_MAX_TC && REDUNDANT_TEMP_MATCH(SOURCE, E1)) + #if TEMP_SENSOR_IS_MAX_TC(1) || (TEMP_SENSOR_IS_MAX_TC(REDUNDANT) && REDUNDANT_TEMP_MATCH(SOURCE, E1)) OUT_WRITE(TEMP_1_CS_PIN, HIGH); #endif @@ -1259,10 +1259,6 @@ void setup() { SETUP_RUN(tmc_init_cs_pins()); #endif - #if HAS_L64XX - SETUP_RUN(L64xxManager.init()); // Set up SPI, init drivers - #endif - #if ENABLED(PSU_CONTROL) SETUP_LOG("PSU_CONTROL"); powerManager.init(); @@ -1324,7 +1320,7 @@ void setup() { // UI must be initialized before EEPROM // (because EEPROM code calls the UI). - SETUP_RUN(ui.init_lcd()); + SETUP_RUN(ui.init()); #if PIN_EXISTS(SAFE_POWER) #if HAS_DRIVER_SAFE_POWER_PROTECT @@ -1649,9 +1645,15 @@ void setup() { SETUP_RUN(test_tmc_connection()); #endif + #if ENABLED(BD_SENSOR) + SETUP_RUN(bdl.init(I2C_BD_SDA_PIN, I2C_BD_SCL_PIN, I2C_BD_DELAY)); + #endif + marlin_state = MF_RUNNING; SETUP_LOG("setup() completed."); + + TERN_(MARLIN_TEST_BUILD, runStartupTests()); } /** @@ -1686,5 +1688,7 @@ void loop() { TERN_(HAS_TFT_LVGL_UI, printer_state_polling()); + TERN_(MARLIN_TEST_BUILD, runPeriodicTests()); + } while (ENABLED(__AVR__)); // Loop forever on slower (AVR) boards } diff --git a/Marlin/src/advi3pp/core/buzzer.cpp b/Marlin/src/advi3pp/core/buzzer.cpp index 6545065ba3..3ed79b9016 100644 --- a/Marlin/src/advi3pp/core/buzzer.cpp +++ b/Marlin/src/advi3pp/core/buzzer.cpp @@ -81,15 +81,13 @@ uint16_t Buzzer::do_size_of() const { //! Send the buzz command to the LCD panel //! @param duration Duration of the sound -void Buzzer::send_buzz_command_to_lcd() -{ +void Buzzer::send_buzz_command_to_lcd() { send_buzz_command_to_lcd(get_buzz_duration()); } //! Send the buzz command to the LCD panel //! @param duration Duration of the sound -void Buzzer::send_buzz_command_to_lcd(uint8_t duration) -{ +void Buzzer::send_buzz_command_to_lcd(uint8_t duration) { if(duration <= 0) duration = 1; WriteRegisterRequest{Register::BuzzerBeepingTime}.write_byte(duration); @@ -97,8 +95,7 @@ void Buzzer::send_buzz_command_to_lcd(uint8_t duration) //! Activate the LCD internal buzzer for the given duration. //! Note: If the buzzer is disabled, does nothing. -void Buzzer::buzz_on_action() -{ +void Buzzer::buzz_on_action() { ui.refresh_screen_timeout(); if(!is_buzz_on_action_enabled()) return; @@ -108,8 +105,7 @@ void Buzzer::buzz_on_action() //! Activate the LCD internal buzzer for the given duration. //! Note: If the buzzer is disabled, does nothing. -void Buzzer::buzz_on_action(uint8_t duration) -{ +void Buzzer::buzz_on_action(uint8_t duration) { ui.refresh_screen_timeout(); if(!is_buzz_on_action_enabled()) return; @@ -119,11 +115,10 @@ void Buzzer::buzz_on_action(uint8_t duration) //! Buzz briefly when the LCD panel is pressed. //! Note: If buzz on press is disabled, does nothing -void Buzzer::buzz_on_press() -{ - if(!is_buzz_on_press_enabled()) - return; - send_buzz_command_to_lcd(); +void Buzzer::buzz_on_press() { + if(!is_buzz_on_press_enabled()) + return; + send_buzz_command_to_lcd(); } } \ No newline at end of file diff --git a/Marlin/src/advi3pp/core/core.cpp b/Marlin/src/advi3pp/core/core.cpp index 9b70cc47d7..930787c040 100755 --- a/Marlin/src/advi3pp/core/core.cpp +++ b/Marlin/src/advi3pp/core/core.cpp @@ -29,9 +29,9 @@ #include "dgus.h" #include "buzzer.h" #include "reentrant.h" -#include "../screens/core/no_sensor.h" +#include "wait.h" +#include "../screens/leveling/no_sensor.h" #include "../screens/controls/controls.h" -#include "../screens/core/wait.h" #include "../screens/controls/load_unload.h" #include "../screens/controls/preheat.h" #include "../screens/controls/move.h" @@ -41,14 +41,12 @@ #include "../screens/print/print.h" #include "../screens/print/pause_options.h" #include "../screens/print/sd_card.h" -#include "../screens/print/change_filament.h" #include "../screens/print/temperatures.h" #include "../screens/tuning/extruder_tuning.h" #include "../screens/tuning/pid_tuning.h" #include "../screens/tuning/bltouch_testing.h" #include "../screens/leveling/z_height.h" #include "../screens/tuning/io.h" -#include "../screens/tuning/usb_to_lcd.h" #include "../screens/tuning/setup.h" #include "../screens/leveling/xtwist.h" #include "../screens/tuning/vibrations.h" @@ -57,7 +55,8 @@ #include "../screens/settings/sensor_settings.h" #include "../screens/settings/lcd_settings.h" #include "../screens/settings/beeper_settings.h" -#include "../screens/settings/print_settings.h" +#include "../screens/print/print_settings.h" +#include "../screens/print/baby_steps.h" #include "../screens/settings/pid_settings.h" #include "../screens/settings/step_settings.h" #include "../screens/settings/feedrate_settings.h" @@ -68,7 +67,6 @@ #include "../screens/info/versions.h" #include "../screens/info/statistics.h" #include "../screens/info/copyrights.h" -#include "../screens/info/sponsors.h" #include "../screens/info/killed.h" namespace ADVi3pp { @@ -76,6 +74,7 @@ namespace ADVi3pp { static constexpr unsigned int FROM_LCD_DELAY = 0; // ms static constexpr unsigned int TO_LCD_DELAY = 250; // ms static constexpr float Z_ROOM = 20; // mm +static constexpr unsigned int ANTI_BOUNCE_DELAY = 20; // ms Core core; @@ -86,74 +85,69 @@ Task to_lcd_task; // ---------------------------------------------------------------------------- Once::operator bool() { - if(!once_) - return false; - once_ = false; - return true; + if(!once_) + return false; + once_ = false; + return true; } // ---------------------------------------------------------------------------- -void Core::startup() -{ +void Core::startup() { #ifdef ADVi3PP_DEBUG - pinMode(LED_PIN, OUTPUT); // To help debugging when serial is not available + pinMode(LED_PIN, OUTPUT); // To help debugging when serial is not available #endif - dgus.open(); + dgus.open(); } -bool Core::init() -{ - if(!once_) - return false; +bool Core::init() { + if(!once_) + return false; - dgus.setup(); - status.set(GET_TEXT_F(WELCOME_MSG)); // This welcome message is not displayed on power-on - send_gplv3_7b_notice(); // You are not authorized to remove or alter this notice - send_sponsors(); - graphs.clear(); - versions.send_versions(); + dgus.setup(); + status.set(GET_TEXT_F(WELCOME_MSG)); // This welcome message is not displayed on power-on + send_gplv3_7b_notice(); // You are not authorized to remove or alter this notice + graphs.clear(); + versions.send_versions(); #if HAS_LEVELING - ExtUI::setLevelingActive(true); + ExtUI::setLevelingActive(true); #endif - from_lcd_task.set(Callback{this, &Core::from_lcd}, FROM_LCD_DELAY); - to_lcd_task.set(Callback{this, &Core::to_lcd}, TO_LCD_DELAY); + from_lcd_task.set(Callback{this, &Core::from_lcd}, FROM_LCD_DELAY); + to_lcd_task.set(Callback{this, &Core::to_lcd}, TO_LCD_DELAY); - if(settings.does_eeprom_mismatch()) - eeprom_mismatch.show(); - else - pages.show(Page::Boot); + if(settings.does_eeprom_mismatch()) + eeprom_mismatch.show(); + else + pages.show(Page::Boot, Action::None); - return true; + return true; } -void Core::idle() -{ - static Reentrant reentrant; - ReentrantScope scope{reentrant}; +void Core::idle() { + static Reentrant reentrant; + ReentrantScope scope{reentrant}; - if(!scope.reentrant()) { - init(); - from_lcd_task.execute(); - } + if(!scope.reentrant()) { + init(); + from_lcd_task.execute(); + } - to_lcd_task.execute(); + to_lcd_task.execute(); - if(!scope.reentrant()) - background_task.execute(); + if(!scope.reentrant()) + background_task.execute(); } void Core::to_lcd() { - update_progress(); - send_lcd_data(); - graphs.update(); - send_lcd_touch_request(); + update_progress(); + send_lcd_data(); + graphs.update(); + send_lcd_touch_request(); } -void Core::killed(float temp, const FlashChar* error, const FlashChar* component) -{ +void Core::killed(float temp, const FlashChar* error, const FlashChar* component) { status.set(error); send_lcd_data(); dimming.sleep_off(); @@ -162,115 +156,124 @@ void Core::killed(float temp, const FlashChar* error, const FlashChar* component //! Note to forks author: //! Under GPLv3 provision 7(b), you are not authorized to remove or alter this notice. -void Core::send_gplv3_7b_notice() -{ +void Core::send_gplv3_7b_notice() { SERIAL_ECHO_START(); SERIAL_ECHOLNPGM("Based on ADVi3++, Copyright (C) 2017-2022 Sebastien Andrivet"); } -void Core::send_sponsors() -{ - SERIAL_ECHO_START(); - SERIAL_ECHOLNPGM("Premium Sponsors: Alexander Cherenegar, Mauro Gil"); -} - //! Update the progress bar if the printer is printing for the SD card -void Core::update_progress() -{ +void Core::update_progress() { // TODO Not sure it is necessary } //! Read a frame from the LCD and act accordingly. -void Core::from_lcd() -{ - if(dimming.receive()) - return; - - ReadAction frame{}; - if(!frame.receive()) - return; - - buzzer.buzz_on_press(); - ui.refresh_screen_timeout(); - - Action action = frame.get_parameter(); - auto key_code = frame.read_key_value(); - uint16_t raw_value = static_cast(key_code); - - Log::frame(LogState::Start) << F("=R==> Action =") << static_cast(action) - << F("KeyValue =") << static_cast(key_code) << Log::endl(); - - switch(action) - { - case Action::Controls: controls.handle(key_code); break; - case Action::PrintCommand: print.handle(key_code); break; - case Action::Wait: wait.handle(key_code); break; - case Action::LoadUnload: load_unload.handle(key_code); break; - case Action::Preheat: preheat.handle(key_code); break; - case Action::Move: move.handle(key_code); break; - case Action::SdCard: sd_card.handle(key_code); break; - case Action::Sponsors: sponsors.handle(key_code); break; - case Action::FactoryReset: factory_reset.handle(key_code); break; - case Action::ManualLeveling: manual_leveling.handle(key_code); break; - case Action::ExtruderTuning: extruder_tuning.handle(key_code); break; - case Action::PidTuning: pid_tuning.handle(key_code); break; - case Action::SensorSettings: sensor_settings.handle(key_code); break; - case Action::VibrationsTuning: vibrations.handle(key_code); break; - case Action::NoSensor: no_sensor.handle(key_code); break; - case Action::LCD: lcd_settings.handle(key_code); break; - case Action::Statistics: statistics.handle(key_code); break; - case Action::Versions: versions.handle(key_code); break; - case Action::PrintSettings: print_settings.handle(key_code); break; - case Action::PIDSettings: pid_settings.handle(key_code); break; - case Action::StepsSettings: steps_settings.handle(key_code); break; - case Action::FeedrateSettings: feedrates_settings.handle(key_code); break; - case Action::AccelerationSettings: accelerations_settings.handle(key_code); break; - case Action::PauseOptions: pause_options.handle(key_code); break; - case Action::Copyrights: copyrights.handle(key_code); break; - case Action::AutomaticLeveling: automatic_leveling.handle(key_code); break; - case Action::SensorGrid: leveling_grid.handle(key_code); break; - case Action::SensorZHeight: sensor_z_height.handle(key_code); break; - case Action::ChangeFilament: change_filament.handle(key_code); break; - case Action::EEPROMMismatch: eeprom_mismatch.handle(key_code); break; - case Action::USB2LCD: usb_2_lcd.handle(key_code); break; - case Action::BLTouchTesting: bltouch_testing.handle(key_code); break; - case Action::LinearAdvanceSettings: linear_advance_settings.handle(key_code); break; - case Action::Diagnosis: io.handle(key_code); break; - case Action::Temperatures: temperatures.handle(key_code); break; - case Action::Setup: setup.handle(key_code); break; - case Action::XTwist: xtwist.handle(key_code); break; - case Action::Runout: runout_settings.handle(key_code); break; - case Action::Skew: skew_settings.handle(key_code); break; - case Action::BeeperSettings: beeper_settings.handle(key_code); break; - - case Action::MoveXPlus: move.x_plus_command(); break; - case Action::MoveXMinus: move.x_minus_command(); break; - case Action::MoveYPlus: move.y_plus_command(); break; - case Action::MoveYMinus: move.y_minus_command(); break; - case Action::MoveZPlus: move.z_plus_command(); break; - case Action::MoveZMinus: move.z_minus_command(); break; - case Action::MoveEPlus: move.e_plus_command(); break; - case Action::MoveEMinus: move.e_minus_command(); break; - case Action::BabyMinus: print_settings.baby_minus_command(); break; - case Action::BabyPlus: print_settings.baby_plus_command(); break; - case Action::ZHeightMinus: sensor_z_height.minus(); break; - case Action::ZHeightPlus: sensor_z_height.plus(); break; - case Action::FeedrateMinus: print_settings.feedrate_minus_command(); break; - case Action::FeedratePlus: print_settings.feedrate_plus_command(); break; - case Action::FanMinus: print_settings.fan_minus_command(); break; - case Action::FanPlus: print_settings.fan_plus_command(); break; - case Action::HotendMinus: print_settings.hotend_minus_command(); break; - case Action::HotendPlus: print_settings.hotend_plus_command(); break; - case Action::BedMinus: print_settings.bed_minus_command(); break; - case Action::BedPlus: print_settings.bed_plus_command(); break; - case Action::XTwistMinus: xtwist.minus(); break; - case Action::XTwistPlus: xtwist.plus(); break; - case Action::BeepDuration: beeper_settings.duration_command(raw_value); break; - case Action::NormalBrightness: lcd_settings.normal_brightness_command(raw_value); break; - case Action::DimmingBrightness: lcd_settings.dimming_brightness_command(raw_value); break; - - default: Log::error() << F("Invalid action ") << static_cast(action) << Log::endl(); break; - } +void Core::from_lcd() { + if(dimming.receive()) + return; + + ReadAction frame{}; + if(!frame.receive()) + return; + + buzzer.buzz_on_press(); + ui.refresh_screen_timeout(); + + Action action = frame.get_parameter(); + auto key_code = frame.read_key_value(); + millis_t now = millis(); + bool bounce = action == last_action_ && (now - last_action_time_) < ANTI_BOUNCE_DELAY; + last_action_ = action; + last_action_time_ = now; + + if(bounce) { + Log::log() << "Bounce detected" << Log::endl(); + return; + } + + Log::frame(LogState::Start) << F("=R==> Action =") << static_cast(action) + << F("KeyValue =") << static_cast(key_code) << Log::endl(); + + process_action(action, key_code); +} + +void Core::process_action(Action action, KeyValue key_code) { + uint16_t raw_value = static_cast(key_code); + + switch(action) { + case controls.ACTION: controls.handle(key_code); break; + case print.ACTION: print.handle(key_code); break; + case wait.ACTION: wait.handle(key_code); break; + case load_unload.ACTION: load_unload.handle(key_code); break; + case preheat.ACTION: preheat.handle(key_code); break; + case move.ACTION: move.handle(key_code); break; + case sd_card.ACTION: sd_card.handle(key_code); break; + case factory_reset.ACTION: factory_reset.handle(key_code); break; + case manual_leveling.ACTION: manual_leveling.handle(key_code); break; + case extruder_tuning.ACTION: extruder_tuning.handle(key_code); break; + case pid_tuning.ACTION: pid_tuning.handle(key_code); break; + case vibrations.ACTION: vibrations.handle(key_code); break; + case lcd_settings.ACTION: lcd_settings.handle(key_code); break; + case statistics.ACTION: statistics.handle(key_code); break; + case versions.ACTION: versions.handle(key_code); break; + case print_settings.ACTION: print_settings.handle(key_code); break; + case baby_steps.ACTION: baby_steps.handle(key_code); break; + case pid_settings.ACTION: pid_settings.handle(key_code); break; + case steps_settings.ACTION: steps_settings.handle(key_code); break; + case feedrates_settings.ACTION: feedrates_settings.handle(key_code); break; + case accelerations_settings.ACTION: accelerations_settings.handle(key_code); break; + case pause_options.ACTION: pause_options.handle(key_code); break; + case copyrights.ACTION: copyrights.handle(key_code); break; + case eeprom_mismatch.ACTION: eeprom_mismatch.handle(key_code); break; + case linear_advance_settings.ACTION: linear_advance_settings.handle(key_code); break; + case io.ACTION: io.handle(key_code); break; + case temperatures.ACTION: temperatures.handle(key_code); break; + case setup.ACTION: setup.handle(key_code); break; + case runout_settings.ACTION: runout_settings.handle(key_code); break; + case skew_settings.ACTION: skew_settings.handle(key_code); break; + case beeper_settings.ACTION: beeper_settings.handle(key_code); break; + +#ifdef ADVi3PP_PROBE + case no_sensor.ACTION: no_sensor.handle(key_code); break; + case automatic_leveling.ACTION: automatic_leveling.handle(key_code); break; + case leveling_grid.ACTION: leveling_grid.handle(key_code); break; + case sensor_z_height.ACTION: sensor_z_height.handle(key_code); break; + case xtwist.ACTION: xtwist.handle(key_code); break; + case sensor_settings.ACTION: sensor_settings.handle(key_code); break; +#endif +#ifdef BLTOUCH + case bltouch_testing.ACTION: bltouch_testing.handle(key_code); break; +#endif + + case Action::MoveXPlus: move.x_plus_command(); break; + case Action::MoveXMinus: move.x_minus_command(); break; + case Action::MoveYPlus: move.y_plus_command(); break; + case Action::MoveYMinus: move.y_minus_command(); break; + case Action::MoveZPlus: move.z_plus_command(); break; + case Action::MoveZMinus: move.z_minus_command(); break; + case Action::MoveEPlus: move.e_plus_command(); break; + case Action::MoveEMinus: move.e_minus_command(); break; + case Action::BabyMinus: baby_steps.baby_minus_command(); break; + case Action::BabyPlus: baby_steps.baby_plus_command(); break; + case Action::ZHeightMinus: sensor_z_height.minus(); break; + case Action::ZHeightPlus: sensor_z_height.plus(); break; + case Action::FeedrateMinus: print_settings.feedrate_minus_command(); break; + case Action::FeedratePlus: print_settings.feedrate_plus_command(); break; + case Action::FlowrateMinus: print_settings.flowrate_minus_command(); break; + case Action::FlowratePlus: print_settings.flowrate_plus_command(); break; + case Action::FanMinus: print_settings.fan_minus_command(); break; + case Action::FanPlus: print_settings.fan_plus_command(); break; + case Action::HotendMinus: print_settings.hotend_minus_command(); break; + case Action::HotendPlus: print_settings.hotend_plus_command(); break; + case Action::BedMinus: print_settings.bed_minus_command(); break; + case Action::BedPlus: print_settings.bed_plus_command(); break; + case Action::XTwistMinus: xtwist.minus(); break; + case Action::XTwistPlus: xtwist.plus(); break; + case Action::BeepDuration: beeper_settings.duration_command(raw_value); break; + case Action::NormalBrightness: lcd_settings.normal_brightness_command(raw_value); break; + case Action::DimmingBrightness: lcd_settings.dimming_brightness_command(raw_value); break; + + default: Log::error() << F("Invalid action ") << static_cast(action) << Log::endl(); break; + } } void Core::send_lcd_touch_request() { @@ -279,85 +282,72 @@ void Core::send_lcd_touch_request() { } //! Update the status of the printer on the LCD. -void Core::send_lcd_data() -{ - // The progress bar is split into two parts because of a limitation of the DWIN panel - // so compute the progress of each part. - int16_t progress_bar_low = ExtUI::getProgress_percent() >= 50 ? 10 : ExtUI::getProgress_percent() / 5; - int16_t progress_var_high = ExtUI::getProgress_percent() < 50 ? 0 : (ExtUI::getProgress_percent() - 50) / 5; +void Core::send_lcd_data() { + // The progress bar is split into two parts because of a limitation of the DWIN panel + // so compute the progress of each part. + int16_t progress_bar_low = ExtUI::getProgress_percent() >= 50 ? 10 : ExtUI::getProgress_percent() / 5; + int16_t progress_var_high = ExtUI::getProgress_percent() < 50 ? 0 : (ExtUI::getProgress_percent() - 50) / 5; #ifdef ADVi3PP_PROBE - uint16_t probe_state = ExtUI::getLevelingActive() ? 2 : 1; + uint16_t probe_state = ExtUI::getLevelingActive() ? 2 : 1; #else - uint16_t probe_state = 0; + uint16_t probe_state = 0; #endif - NoFrameLogging no_logging{}; - // Send the current status in one frame - WriteRamRequest{Variable::TargetBed}.write_words( - ExtUI::getTargetTemp_celsius(ExtUI::BED), - ExtUI::getActualTemp_celsius(ExtUI::BED), - ExtUI::getTargetTemp_celsius(ExtUI::E0), - ExtUI::getActualTemp_celsius(ExtUI::E0), - ExtUI::getActualFan_percent(ExtUI::FAN0), - lround(ExtUI::getAxisPosition_mm(ExtUI::Z) * 100.0), - progress_bar_low, - progress_var_high, - 0, // Reserved - probe_state, - ExtUI::getFeedrate_percent() - ); - - status.send(); -} - -bool Core::ensure_not_printing() -{ - if(!ExtUI::isPrinting()) - return true; - - wait.wait_back(F("Not accessible when the printer is busy")); - return false; + NoFrameLogging no_logging{}; + // Send the current status in one frame + WriteRamRequest{Variable::TargetBed}.write_words( + lround(ExtUI::getTargetTemp_celsius(ExtUI::BED)), + lround(ExtUI::getActualTemp_celsius(ExtUI::BED)), + lround(ExtUI::getTargetTemp_celsius(ExtUI::E0)), + lround(ExtUI::getActualTemp_celsius(ExtUI::E0)), + lround(ExtUI::getActualFan_percent(ExtUI::FAN0)), + lround(ExtUI::getAxisPosition_mm(ExtUI::Z) * 100.0), + progress_bar_low, + progress_var_high, + 0, // Reserved + probe_state, + lround(ExtUI::getFeedrate_percent()), + ExtUI::getFlow_percent(ExtUI::E0) + ); + + status.send(); } -bool Core::is_busy() -{ - return - ExtUI::isMoving() || - ExtUI::commandsInQueue() || - ExtUI::getHostKeepaliveState() == GcodeSuite::MarlinBusyState::IN_HANDLER || - ExtUI::getHostKeepaliveState() == GcodeSuite::MarlinBusyState::IN_PROCESS; +bool Core::is_busy() { + return + ExtUI::isMoving() || + ExtUI::commandsInQueue() || + ExtUI::getHostKeepaliveState() == GcodeSuite::MarlinBusyState::IN_HANDLER || + ExtUI::getHostKeepaliveState() == GcodeSuite::MarlinBusyState::IN_PROCESS; } -void Core::inject_commands(const FlashChar* commands) -{ - ExtUI::injectCommands_P(from_flash(commands)); +void Core::inject_commands(const FlashChar* commands) { + ExtUI::injectCommands_P(from_flash(commands)); } -void Core::inject_commands(const char *commands) -{ - ExtUI::injectCommands(commands); +void Core::inject_commands(const char *commands) { + ExtUI::injectCommands(commands); } //! Get current digital pin state (adapted from Arduino source code). //! @param pin Pin number to check. //! @return The current state: On (input), Off (input), Output -Core::PinState Core::get_pin_state(uint8_t pin) -{ - uint8_t mask = digitalPinToBitMask(pin); - uint8_t port = digitalPinToPort(pin); - if(port == NOT_A_PIN) - return PinState::Off; - - volatile uint8_t* reg = portModeRegister(port); - if(*reg & mask) - return PinState::Output; - - uint8_t timer = digitalPinToTimer(pin); - if(timer != NOT_ON_TIMER) - return PinState::Output; - - return (*portInputRegister(port) & mask) ? PinState::On : PinState::Off; +Core::PinState Core::get_pin_state(uint8_t pin) { + uint8_t mask = digitalPinToBitMask(pin); + uint8_t port = digitalPinToPort(pin); + if(port == NOT_A_PIN) + return PinState::Off; + + volatile uint8_t* reg = portModeRegister(port); + if(*reg & mask) + return PinState::Output; + + uint8_t timer = digitalPinToTimer(pin); + if(timer != NOT_ON_TIMER) + return PinState::Output; + + return (*portInputRegister(port) & mask) ? PinState::On : PinState::Off; } float Core::ensure_z_enough_room() { @@ -367,4 +357,26 @@ float Core::ensure_z_enough_room() { return previous_z; } +void Core::media_inserted() { + status.set(F("SD card detected.")); + if(pages.get_current_page() != Page::SdCard) + return; + sd_card.on_media_inserted(); +} + +void Core::media_removed() { + status.set(F("SD card removed.")); + if(pages.get_current_page() != Page::SdCard) + return; + sd_card.on_media_removed(); +} + +void Core::media_error() { + status.set(F("Error reading SD card.")); + if(pages.get_current_page() != Page::SdCard) + return; + sd_card.on_media_error(); +} + + } diff --git a/Marlin/src/advi3pp/core/core.h b/Marlin/src/advi3pp/core/core.h index a96002068e..17327bb0d7 100644 --- a/Marlin/src/advi3pp/core/core.h +++ b/Marlin/src/advi3pp/core/core.h @@ -22,6 +22,7 @@ #include "string.h" #include "task.h" +#include "enums.h" class GCodeParser; @@ -33,45 +34,49 @@ namespace ADVi3pp { // ---------------------------------------------------------------------------- struct Once { - operator bool(); + operator bool(); private: - bool once_ = true; + bool once_ = true; }; // ---------------------------------------------------------------------------- // Core // ---------------------------------------------------------------------------- -struct Core -{ - enum class PinState: uint8_t { Off = 0, On = 1, Output = 2}; +struct Core { + enum class PinState: uint8_t { Off = 0, On = 1, Output = 2}; - void startup(); - void idle(); - void killed(float temp, const FlashChar* error, const FlashChar* component); + void startup(); + void idle(); + void killed(float temp, const FlashChar* error, const FlashChar* component); - bool ensure_not_printing(); - bool is_busy(); - void inject_commands(const FlashChar* commands); - void inject_commands(const char *commands); + bool is_busy(); + void inject_commands(const FlashChar* commands); + void inject_commands(const char *commands); + void process_action(Action action, KeyValue key_value); - template ADVString& convert_version(ADVString& version, uint16_t hex_version); + template ADVString& convert_version(ADVString& version, uint16_t hex_version); - static PinState get_pin_state(uint8_t pin); - static float ensure_z_enough_room(); + static PinState get_pin_state(uint8_t pin); + static float ensure_z_enough_room(); + + void media_inserted(); + void media_removed(); + void media_error(); private: - bool init(); - void send_gplv3_7b_notice(); - void send_sponsors(); - void update_progress(); - void from_lcd(); - void to_lcd(); - void send_lcd_data(); - void send_lcd_touch_request(); + bool init(); + void send_gplv3_7b_notice(); + void update_progress(); + void from_lcd(); + void to_lcd(); + void send_lcd_data(); + void send_lcd_touch_request(); private: - Once once_{}; + Once once_{}; + Action last_action_ = Action::None; + millis_t last_action_time_ = 0; }; extern Core core; @@ -80,11 +85,9 @@ extern Core core; //! @param hex_version Hexadecimal representation of the version //! @return Version as a string template -ADVString& Core::convert_version(ADVString& version, uint16_t hex_version) -{ - version << hex_version / 0x0100 << '.' << (hex_version % 0x100) / 0x10 << '.' << hex_version % 0x10; - return version; +ADVString& Core::convert_version(ADVString& version, uint16_t hex_version) { + version << hex_version / 0x0100 << '.' << (hex_version % 0x100) / 0x10 << '.' << hex_version % 0x10; + return version; } - } \ No newline at end of file diff --git a/Marlin/src/advi3pp/core/dgus-impl.h b/Marlin/src/advi3pp/core/dgus-impl.h index b7de6a6edd..4948cd2c90 100644 --- a/Marlin/src/advi3pp/core/dgus-impl.h +++ b/Marlin/src/advi3pp/core/dgus-impl.h @@ -20,12 +20,12 @@ void Dgus::reset(const uint8_t (&buffer)[S]) { #ifdef ADVi3PP_DEBUG template inline void OutFrame::check_overflow(size_t size) const { - uint8_t total = data_written_ + size; - if(total > data_size_) { - Log::error() << F("Overflow") << data_size_ << F("expected") << total << F("written.") << Log::endl(); - debug_break(); - } - data_written_ += size; + uint8_t total = data_written_ + size; + if(total > data_size_) { + Log::error() << F("Overflow") << data_size_ << F("expected") << total << F("written.") << Log::endl(); + debug_break(); + } + data_written_ += size; } #else template @@ -36,47 +36,47 @@ template bool OutFrame::write_header(uint8_t data_size) { #ifdef ADVi3PP_DEBUG - assert(data_size_ == 0); - data_size_ = data_size + sizeof(Param) + 1; - data_written_ = 1; // For the Command (1 byte) + assert(data_size_ == 0); + data_size_ = data_size + sizeof(Param) + 1; + data_written_ = 1; // For the Command (1 byte) #endif - return dgus.write_header(cmd, sizeof(Param), data_size) && write_parameter(); + return dgus.write_header(cmd, sizeof(Param), data_size) && write_parameter(); } template inline OutFrame::~OutFrame() { - Log::frame() << Log::endl(); + Log::frame() << Log::endl(); #ifdef ADVi3PP_DEBUG - if(data_written_ != data_size_) { - Log::error() << F("OutFrame") << data_size_ << F("expected") << data_written_ << F("written.") << Log::endl(); - debug_break(); - } + if(data_written_ != data_size_) { + Log::error() << F("OutFrame") << data_size_ << F("expected") << data_written_ << F("written.") << Log::endl(); + debug_break(); + } #endif } template inline bool OutFrame::write_byte_data(uint8_t byte) const { - if(!dgus.write_byte(byte)) - return false; - check_overflow(1); - return true; + if(!dgus.write_byte(byte)) + return false; + check_overflow(1); + return true; } template inline bool OutFrame::write_bytes_data(const uint8_t *bytes, size_t length) const { - if(!dgus.write_bytes(bytes, length)) - return false; - check_overflow(length); - return true; + if(!dgus.write_bytes(bytes, length)) + return false; + check_overflow(length); + return true; } template inline bool OutFrame::write_bytes_data(const char *bytes, size_t length) const { - if(!dgus.write_bytes(bytes, length)) - return false; - check_overflow(length); - return true; + if(!dgus.write_bytes(bytes, length)) + return false; + check_overflow(length); + return true; } template @@ -89,44 +89,41 @@ inline bool OutFrame::write_word_data(uint16_t word) const { template inline bool OutFrame::write_words_data(const uint16_t *words, size_t length) const { - if(!dgus.write_words(words, length)) - return false; - check_overflow(2 * length); - return true; + if(!dgus.write_words(words, length)) + return false; + check_overflow(2 * length); + return true; } template inline bool OutFrame::write_text(const char* text, size_t text_length, size_t total_length) const { - if(!dgus.write_text(text, text_length, total_length)) - return false; - check_overflow(total_length); - return true; + if(!dgus.write_text(text, text_length, total_length)) + return false; + check_overflow(total_length); + return true; } template inline bool OutFrame::write_centered_text(const char* text, size_t text_length, size_t total_length) const { - if(!dgus.write_centered_text(text, text_length, total_length)) - return false; - check_overflow(total_length); - return true; + if(!dgus.write_centered_text(text, text_length, total_length)) + return false; + check_overflow(total_length); + return true; } template -inline bool OutFrame::write_parameter() const -{ - return sizeof(Param) == 1 ? write_byte_parameter() : write_word_parameter(); +inline bool OutFrame::write_parameter() const { + return sizeof(Param) == 1 ? write_byte_parameter() : write_word_parameter(); } template -inline bool OutFrame::write_byte_parameter() const -{ - return write_byte_data(static_cast(parameter_)); +inline bool OutFrame::write_byte_parameter() const { + return write_byte_data(static_cast(parameter_)); } template -inline bool OutFrame::write_word_parameter() const -{ - return write_word_data(static_cast(parameter_)); +inline bool OutFrame::write_word_parameter() const { + return write_word_data(static_cast(parameter_)); } // -------------------------------------------------------------------- @@ -134,9 +131,8 @@ inline bool OutFrame::write_word_parameter() const // -------------------------------------------------------------------- template -bool ReadOutFrame::write(uint8_t nb_elements) -{ - return Parent::write_header(1) && Parent::write_byte_data(nb_elements); +bool ReadOutFrame::write(uint8_t nb_elements) { + return Parent::write_header(1) && Parent::write_byte_data(nb_elements); } // -------------------------------------------------------------------- @@ -144,43 +140,39 @@ bool ReadOutFrame::write(uint8_t nb_elements) // -------------------------------------------------------------------- template -bool WriteOutFrame::write_byte(uint8_t value) -{ - return Parent::write_header(1) && Parent::write_byte_data(value); +bool WriteOutFrame::write_byte(uint8_t value) { + return Parent::write_header(1) && Parent::write_byte_data(value); } template -bool WriteOutFrame::write_word(uint16_t value) -{ - return Parent::write_header(2) & Parent::write_word_data(value); +bool WriteOutFrame::write_word(uint16_t value) { + return Parent::write_header(2) && Parent::write_word_data(value); } template -bool WriteOutFrame::write_bytes_data(const uint8_t *first, size_t size) -{ - return Parent::write_header(size) && Parent::write_bytes_data(first, size); +bool WriteOutFrame::write_bytes_data(const uint8_t *first, size_t size) { + return Parent::write_header(size) && Parent::write_bytes_data(first, size); } template bool WriteOutFrame::write_words_data(const uint16_t *first, size_t size) { - return Parent::write_header(size * 2) && Parent::write_words_data(first, size); + return Parent::write_header(size * 2) && Parent::write_words_data(first, size); } template template -bool WriteOutFrame::write_bytes(T... args) -{ - const auto size = sizeof...(args); - const adv::array data = {static_cast(args)...}; - return write_bytes_data(data.data(), size); +bool WriteOutFrame::write_bytes(T... args) { + const auto size = sizeof...(args); + const adv::array data = {static_cast(args)...}; + return write_bytes_data(data.data(), size); } template template bool WriteOutFrame::write_words(T... args) { - const auto size = sizeof...(args); - const adv::array data = {static_cast(args)...}; - return write_words_data(data.data(), size); + const auto size = sizeof...(args); + const adv::array data = {static_cast(args)...}; + return write_words_data(data.data(), size); } // -------------------------------------------------------------------- @@ -188,15 +180,13 @@ bool WriteOutFrame::write_words(T... args) { // -------------------------------------------------------------------- template -bool WriteRamRequest::write_text(const ADVString& data) -{ - return Parent::write_header(N) && Parent::write_text(data.get(), data.length(), N); +bool WriteRamRequest::write_text(const ADVString& data) { + return Parent::write_header(N) && Parent::write_text(data.get(), data.length(), N); } template -bool WriteRamRequest::write_centered_text(const ADVString& data) -{ - return Parent::write_header(N) && Parent::write_centered_text(data.get(), data.length(), N); +bool WriteRamRequest::write_centered_text(const ADVString& data) { + return Parent::write_header(N) && Parent::write_centered_text(data.get(), data.length(), N); } // -------------------------------------------------------------------- @@ -204,111 +194,102 @@ bool WriteRamRequest::write_centered_text(const ADVString& data) // -------------------------------------------------------------------- template -InFrame::~InFrame() -{ - if(nb_data_expected_ != nb_data_read_) { - Log::error() << F("InFrame") << nb_data_expected_ << F("expected") << nb_data_read_ << F("read.") << Log::endl(); - debug_break(); - } +InFrame::~InFrame() { + if(nb_data_expected_ != nb_data_read_) { + Log::error() << F("InFrame") << nb_data_expected_ << F("expected") << nb_data_read_ << F("read.") << Log::endl(); + debug_break(); + } } template -bool InFrame::receive(bool blocking) -{ - if(!dgus.receive(cmd, blocking && mode == ReceiveMode::Known) || !read_parameter()) - return false; - nb_data_expected_ = dgus.read_byte(); - return true; +bool InFrame::receive(bool blocking) { + if(!dgus.receive(cmd, blocking && mode == ReceiveMode::Known) || !read_parameter()) + return false; + nb_data_expected_ = dgus.read_byte(); + return true; } template -uint8_t InFrame::read_byte() -{ - nb_data_read_ += 1; - return dgus.read_byte(); +uint8_t InFrame::read_byte() { + nb_data_read_ += 1; + return dgus.read_byte(); } template -uint16_t InFrame::read_word() -{ - nb_data_read_ += 2 / sizeof(Param); - auto byte0 = dgus.read_byte(); - auto byte1 = dgus.read_byte(); - return adv::word_from_bytes(byte0, byte1); +uint16_t InFrame::read_word() { + nb_data_read_ += 2 / sizeof(Param); + auto byte0 = dgus.read_byte(); + auto byte1 = dgus.read_byte(); + return adv::word_from_bytes(byte0, byte1); } template int16_t InFrame::read_signed_word() { - return static_cast(read_word()); + return static_cast(read_word()); } template -Param InFrame::get_parameter() const -{ - return parameter_; +Param InFrame::get_parameter() const { + return parameter_; } template -uint8_t InFrame::get_nb_data() const -{ - return nb_data_expected_; +uint8_t InFrame::get_nb_data() const { + return nb_data_expected_; } template -bool InFrame::read_parameter() -{ - if(mode == ReceiveMode::Known) - return sizeof(Param) == 1 ? check_byte_parameter() : check_word_parameter(); - else - return sizeof(Param) == 1 ? read_byte_parameter() : read_word_parameter(); +bool InFrame::read_parameter() { + if(mode == ReceiveMode::Known) + return sizeof(Param) == 1 ? check_byte_parameter() : check_word_parameter(); + else + return sizeof(Param) == 1 ? read_byte_parameter() : read_word_parameter(); } template -bool InFrame::read_byte_parameter() -{ - if(!dgus.wait_for_data(1, mode == ReceiveMode::Known)) - return false; - parameter_ = static_cast(dgus.read_byte()); - return true; +bool InFrame::read_byte_parameter() { + if(!dgus.wait_for_data(1, mode == ReceiveMode::Known)) + return false; + parameter_ = static_cast(dgus.read_byte()); + return true; } template bool InFrame::read_word_parameter() { - if(!dgus.wait_for_data(2, mode == ReceiveMode::Known)) - return false; - auto byte0 = dgus.read_byte(); - auto byte1 = dgus.read_byte(); - parameter_ = static_cast(adv::word_from_bytes(byte0, byte1)); - return true; + if(!dgus.wait_for_data(2, mode == ReceiveMode::Known)) + return false; + auto byte0 = dgus.read_byte(); + auto byte1 = dgus.read_byte(); + parameter_ = static_cast(adv::word_from_bytes(byte0, byte1)); + return true; } template bool InFrame::check_byte_parameter() const { - if(!dgus.wait_for_data(1, mode == ReceiveMode::Known)) - return false; - auto byte = dgus.read_byte(); - auto parameter = static_cast(byte); - if(parameter != parameter_) { - dgus.push_back(byte); - return false; - } - return true; + if(!dgus.wait_for_data(1, mode == ReceiveMode::Known)) + return false; + auto byte = dgus.read_byte(); + auto parameter = static_cast(byte); + if(parameter != parameter_) { + dgus.push_back(byte); + return false; + } + return true; } template -bool InFrame::check_word_parameter() const -{ - if(!dgus.wait_for_data(2, mode == ReceiveMode::Known)) - return false; - auto byte0 = dgus.read_byte(); - auto byte1 = dgus.read_byte(); - auto parameter = static_cast(adv::word_from_bytes(byte0, byte1)); - if(parameter != parameter_) { - dgus.push_back(byte1); - dgus.push_back(byte0); - return false; - } - return true; +bool InFrame::check_word_parameter() const { + if(!dgus.wait_for_data(2, mode == ReceiveMode::Known)) + return false; + auto byte0 = dgus.read_byte(); + auto byte1 = dgus.read_byte(); + auto parameter = static_cast(adv::word_from_bytes(byte0, byte1)); + if(parameter != parameter_) { + dgus.push_back(byte1); + dgus.push_back(byte0); + return false; + } + return true; } // -------------------------------------------------------------------- @@ -316,11 +297,10 @@ bool InFrame::check_word_parameter() const // -------------------------------------------------------------------- template -bool OutInFrame::send_receive(uint8_t nb_elements) -{ - if(!ReadOutFrame{Parent::parameter_}.write(nb_elements)) - return false; - return Parent::receive(); +bool OutInFrame::send_receive(uint8_t nb_elements) { + if(!ReadOutFrame{Parent::parameter_}.write(nb_elements)) + return false; + return Parent::receive(); } // -------------------------------------------------------------------- diff --git a/Marlin/src/advi3pp/core/dgus.cpp b/Marlin/src/advi3pp/core/dgus.cpp index b13699e1d0..6e5206184f 100755 --- a/Marlin/src/advi3pp/core/dgus.cpp +++ b/Marlin/src/advi3pp/core/dgus.cpp @@ -27,13 +27,12 @@ namespace ADVi3pp { -namespace -{ - auto& DgusSerial = Serial2; - const uint32_t LCD_BAUDRATE = 115200; // Between the LCD panel and the mainboard - const uint16_t LCD_READ_DELAY = 50; // ms - const uint16_t LCD_READ_KILL_COUNT = 16; // must be less that the watchdog time - const byte R2 = 0x0D; // SYS_CFG, disable buzzer, L22 init, auto key codes +namespace { + auto& DgusSerial = Serial2; + const uint32_t LCD_BAUDRATE = 115200; // Between the LCD panel and the mainboard + const uint16_t LCD_READ_DELAY = 50; // ms + const uint16_t LCD_READ_KILL_COUNT = 16; // must be less that the watchdog time + const byte R2 = 0x0D; // SYS_CFG, disable buzzer, L22 init, auto key codes } Dgus dgus; @@ -43,49 +42,45 @@ Dgus dgus; // -------------------------------------------------------------------- //! Open the serial communication between the mainboard and the LCD panel -void Dgus::open() -{ - DgusSerial.begin(LCD_BAUDRATE); +void Dgus::open() { + DgusSerial.begin(LCD_BAUDRATE); } -void Dgus::setup() -{ - ReadRegister read{Register::R2}; - if(!read.send_receive(1)) - kill(); - uint8_t r2 = read.read_byte(); +void Dgus::setup() { + ReadRegister read{Register::R2}; + if(!read.send_receive(1)) + kill(); + uint8_t r2 = read.read_byte(); - if(r2 == R2) - return; + if(r2 == R2) + return; - Log::log() << F("Reprogram R2 register to") << R2 << F("was") << r2 << Log::endl(); - WriteRegisterRequest{Register::R2}.write_byte(R2); + Log::log() << F("Reprogram R2 register to") << R2 << F("was") << r2 << Log::endl(); + WriteRegisterRequest{Register::R2}.write_byte(R2); } -void Dgus::kill() -{ +void Dgus::kill() { #ifndef ADV_UNIT_TESTS - SERIAL_ERROR_START(); - SERIAL_ECHOLNPGM("LCD panel does not respond. Check cable between mainboard and LCD Panel. Printer is stopped."); - ExtUI::killRightNow(); + SERIAL_ERROR_START(); + SERIAL_ECHOLNPGM("LCD panel does not respond. Check cable between mainboard and LCD Panel. Printer is stopped."); + ExtUI::killRightNow(); #else - throw log_exception(); + throw log_exception(); #endif } #ifndef ADV_UNIT_TESTS -void Dgus::forwarding_loop() -{ - while(true) - { - ExtUI::watchdogReset(); +void Dgus::forwarding_loop() { + while(true) + { + ExtUI::watchdogReset(); - if(MYSERIAL1.available()) - DgusSerial.write(MYSERIAL1.read()); + if(MYSERIAL1.available()) + DgusSerial.write(MYSERIAL1.read()); - if(DgusSerial.available()) - MYSERIAL1.write(DgusSerial.read()); - } + if(DgusSerial.available()) + MYSERIAL1.write(DgusSerial.read()); + } } #endif @@ -100,234 +95,207 @@ void Dgus::reset() { } #endif -bool Dgus::write_header(Command cmd, uint8_t param_size, uint8_t data_size) -{ - // Format of the frame: - // header | length | command | parameter | data - // -------|--------|---------|-----------|------- - // 2 | 1 | 1 | 1 or 2 | N bytes - // 5A A5 | 06 | 80 | ... | ... - - adv::array header = - { - HEADER_BYTE_0, - HEADER_BYTE_1, - static_cast(1 + param_size + data_size), - static_cast(cmd) - }; - - Log::frame(LogState::Start) << F("<==S=") << header; - if(header.size() != DgusSerial.write(header.data(), header.size())) - return false; - - return true; +bool Dgus::write_header(Command cmd, uint8_t param_size, uint8_t data_size) { + // Format of the frame: + // header | length | command | parameter | data + // -------|--------|---------|-----------|------- + // 2 | 1 | 1 | 1 or 2 | N bytes + // 5A A5 | 06 | 80 | ... | ... + + adv::array header = + { + HEADER_BYTE_0, + HEADER_BYTE_1, + static_cast(1 + param_size + data_size), + static_cast(cmd) + }; + + Log::frame(LogState::Start) << F("<==S=") << header; + if(header.size() != DgusSerial.write(header.data(), header.size())) + return false; + + return true; } //! Wait for the given amount of bytes from the LCD display. //! @param length Number of bytes to be available before returning -bool Dgus::wait_for_data(uint8_t size, bool blocking) -{ - if(nb_pushed_back_ >= size) - return true; - size -= nb_pushed_back_; +bool Dgus::wait_for_data(uint8_t size, bool blocking) { + if(nb_pushed_back_ >= size) + return true; + size -= nb_pushed_back_; - if(!blocking && DgusSerial.available() < size) { - return false; - } - - unsigned count = 0; - while(DgusSerial.available() < size) - { - delay(LCD_READ_DELAY); - count += 1; - if(count > LCD_READ_KILL_COUNT) - kill(); - } + if(!blocking && DgusSerial.available() < size) + return false; - return true; + unsigned count = 0; + while(DgusSerial.available() < size) { + delay(LCD_READ_DELAY); + count += 1; + if(count > LCD_READ_KILL_COUNT) + kill(); + } + + return true; } -bool Dgus::receive_header() -{ - for(size_t index = 0; ; ++index) - { - uint8_t header0 = DgusSerial.read(); - if(header0 != HEADER_BYTE_0 && index >= MAX_GARBAGE_BYTES) { - Log::error() << F("Not able to find the start of a frame") << Log::endl(); - return false; - } - if(header0 == HEADER_BYTE_0) - break; - Log::log() << F("Discard garbage") << header0 << Log::endl(); +bool Dgus::receive_header() { + for(size_t index = 0; ; ++index) { + uint8_t header0 = DgusSerial.read(); + if(header0 != HEADER_BYTE_0 && index >= MAX_GARBAGE_BYTES) { + Log::error() << F("Not able to find the start of a frame") << Log::endl(); + return false; } + if(header0 == HEADER_BYTE_0) + break; + Log::log() << F("Discard garbage") << header0 << Log::endl(); + } + + uint8_t header1 = DgusSerial.read(); + if(header1 != HEADER_BYTE_1) { + Log::error() << F("Not able to find the start of a frame") << header1 << Log::endl(); + return false; + } + + Log::frame(LogState::Start) << F("=R==>") << HEADER_BYTE_0 << HEADER_BYTE_1; + return true; +} - uint8_t header1 = DgusSerial.read(); - if(header1 != HEADER_BYTE_1) { - Log::error() << F("Not able to find the start of a frame") << header1 << Log::endl(); +bool Dgus::receive(Command cmd, bool blocking) { + // Format of the frame: + // header | length | command | data + // -------|--------|---------|------ + // 2 | 1 | 1 | N bytes + // 5A A5 | 06 | 83 | ... + + if(state_ == State::Start) { + if(!wait_for_data(4, blocking)) return false; - } - Log::frame(LogState::Start) << F("=R==>") << HEADER_BYTE_0 << HEADER_BYTE_1; - return true; -} + if(!receive_header()) + return false; -bool Dgus::receive(Command cmd, bool blocking) -{ - // Format of the frame: - // header | length | command | data - // -------|--------|---------|------ - // 2 | 1 | 1 | N bytes - // 5A A5 | 06 | 83 | ... - - if(state_ == State::Start) - { - if(!wait_for_data(4, blocking)) - return false; - - if(!receive_header()) - return false; - - auto length = static_cast(DgusSerial.read()); - if(length < 3) - { - Log::error() << F("Invalid frame length:") << length << Log::endl(); - return false; - } - auto command = static_cast(DgusSerial.read()); - if(command < 0x80 || command > 0x84) - { - Log::error() << F("Invalid frame command:") << command << Log::endl(); - return false; - } - - length_ = length; - command_ = static_cast(command); - state_ = State::Command; - read_ = 1; // Command is 1 byte - - Log::frame() << length << command; + auto length = static_cast(DgusSerial.read()); + if(length < 3) { + Log::error() << F("Invalid frame length:") << length << Log::endl(); + return false; + } + auto command = static_cast(DgusSerial.read()); + if(command < 0x80 || command > 0x84) { + Log::error() << F("Invalid frame command:") << command << Log::endl(); + return false; } - if(command_ != cmd) - return false; + length_ = length; + command_ = static_cast(command); + state_ = State::Command; + read_ = 1; // Command is 1 byte - if(!wait_for_data(length_ - read_, blocking)) - return false; + Log::frame() << length << command; + } - return true; + if(command_ != cmd) + return false; + + if(!wait_for_data(length_ - read_, blocking)) + return false; + + return true; } -bool Dgus::has_pushed_back() const -{ +bool Dgus::has_pushed_back() const { return nb_pushed_back_ > 0; } -uint8_t Dgus::get_pushed_back() -{ +uint8_t Dgus::get_pushed_back() { return pushed_back_[--nb_pushed_back_]; } -uint8_t Dgus::read_byte() -{ - uint8_t byte = has_pushed_back() ? get_pushed_back() : DgusSerial.read(); - read_ += 1; - Log::frame() << byte; - if(read_ == length_) { - state_ = State::Start; - Log::frame() << Log::endl(); - } - return byte; +uint8_t Dgus::read_byte() { + uint8_t byte = has_pushed_back() ? get_pushed_back() : DgusSerial.read(); + read_ += 1; + Log::frame() << byte; + if(read_ == length_) { + state_ = State::Start; + Log::frame() << Log::endl(); + } + return byte; } -size_t Dgus::read_bytes(uint8_t *buffer, size_t length) -{ - size_t n = length; - while(n--) - *(buffer++) = read_byte(); - return length; +size_t Dgus::read_bytes(uint8_t *buffer, size_t length) { + size_t n = length; + while(n--) + *(buffer++) = read_byte(); + return length; } -void Dgus::push_back(uint8_t byte) -{ - if(nb_pushed_back_ >= MAX_PUSH_BACK) - { - Log::error() << F("Pushback overflow") << Log::endl(); - return; - } +void Dgus::push_back(uint8_t byte) { + if(nb_pushed_back_ >= MAX_PUSH_BACK) { + Log::error() << F("Pushback overflow") << Log::endl(); + return; + } - pushed_back_[nb_pushed_back_++] = byte; - assert(read_ > 0); - read_ -= 1; - Log::frame() << F("//") << byte << F("//"); + pushed_back_[nb_pushed_back_++] = byte; + assert(read_ > 0); + read_ -= 1; + Log::frame() << F("//") << byte << F("//"); } -bool Dgus::write_byte(uint8_t byte) -{ - Log::frame() << byte; - return DgusSerial.write(byte) == 1; +bool Dgus::write_byte(uint8_t byte) { + Log::frame() << byte; + return DgusSerial.write(byte) == 1; } -bool Dgus::write_bytes(const uint8_t *bytes, size_t length) -{ - Log::frame().write(bytes, length); - return DgusSerial.write(bytes, length) == length; +bool Dgus::write_bytes(const uint8_t *bytes, size_t length) { + Log::frame().write(bytes, length); + return DgusSerial.write(bytes, length) == length; } -bool Dgus::write_bytes(const char *bytes, size_t length) -{ - Log::frame().write(reinterpret_cast(bytes), length); - return DgusSerial.write(bytes, length) == length; +bool Dgus::write_bytes(const char *bytes, size_t length) { + Log::frame().write(reinterpret_cast(bytes), length); + return DgusSerial.write(bytes, length) == length; } -bool Dgus::write_word(uint16_t word) -{ - if(!Dgus::write_byte(highByte(word)) || !Dgus::write_byte(lowByte(word))) - return false; - return true; +bool Dgus::write_word(uint16_t word) { + if(!Dgus::write_byte(highByte(word)) || !Dgus::write_byte(lowByte(word))) + return false; + return true; } -bool Dgus::write_words(const uint16_t *words, size_t length) -{ - for(size_t i = 0; i < length; ++i) - { - if(!write_word(words[i])) - return false; - } - return true; +bool Dgus::write_words(const uint16_t *words, size_t length) { + for(size_t i = 0; i < length; ++i) { + if(!write_word(words[i])) + return false; + } + return true; } -bool Dgus::write_text(const char* text, size_t text_length, size_t total_length) -{ - if(!Dgus::write_bytes(text, text_length)) - return false; - // Fill the remaining of string with spaces - for(size_t i = text_length; i < total_length; ++i) - { - if(!write_byte(' ')) - return false; - } - return true; +bool Dgus::write_text(const char* text, size_t text_length, size_t total_length) { + if(!Dgus::write_bytes(text, text_length)) + return false; + // Fill the remaining of string with spaces + for(size_t i = text_length; i < total_length; ++i) { + if(!write_byte(' ')) + return false; + } + return true; } -bool Dgus::write_centered_text(const char* text, size_t text_length, size_t total_length) -{ - // Pad the beginning to center the string - auto pad = (total_length - text_length) / 2; - for(size_t i = 0; i < pad; ++i) - { - if(!Dgus::write_byte(' ')) - return false; - } - // The string itself - if(!Dgus::write_bytes(text, text_length)) - return false; - // Fill the remaining of the string with spaces - for(size_t i = text_length + pad; i < total_length; ++i) - { - if(!Dgus::write_byte(' ')) - return false; - } - return true; +bool Dgus::write_centered_text(const char* text, size_t text_length, size_t total_length) { + // Pad the beginning to center the string + auto pad = (total_length - text_length) / 2; + for(size_t i = 0; i < pad; ++i) { + if(!Dgus::write_byte(' ')) + return false; + } + // The string itself + if(!Dgus::write_bytes(text, text_length)) + return false; + // Fill the remaining of the string with spaces + for(size_t i = text_length + pad; i < total_length; ++i) { + if(!Dgus::write_byte(' ')) + return false; + } + return true; } Command last_command_; diff --git a/Marlin/src/advi3pp/core/dgus.h b/Marlin/src/advi3pp/core/dgus.h index 2165517ff8..35b06b246d 100755 --- a/Marlin/src/advi3pp/core/dgus.h +++ b/Marlin/src/advi3pp/core/dgus.h @@ -31,54 +31,52 @@ namespace ADVi3pp { //! List of commands and their values (DGUS Mini) -enum class Command: uint8_t -{ - None = 0x00, - WriteRegister = 0x80, // 128 - ReadRegister = 0x81, // 129 - WriteRam = 0x82, // 130 - ReadRam = 0x83, // 131 - WriteCurve = 0x84 // 132 +enum class Command: uint8_t { + None = 0x00, + WriteRegister = 0x80, // 128 + ReadRegister = 0x81, // 129 + WriteRam = 0x82, // 130 + ReadRam = 0x83, // 131 + WriteCurve = 0x84 // 132 }; //! List of registers and their values (DGUS Mini) -enum class Register: uint8_t -{ - Version = 0x00, - Brightness = 0x01, - BuzzerBeepingTime = 0x02, - PictureID = 0x03, - TouchPanelFlag = 0x05, - TouchPanelStatus = 0x06, - TouchPanelPosition = 0x07, - TouchPanelEnable = 0x0B, - RunTime = 0x0C, - R0 = 0x10, - R1 = 0x11, - R2 = 0x12, - R3 = 0x13, - R4 = 0x14, - R5 = 0x15, - R6 = 0x16, - R7 = 0x17, - R8 = 0x18, - R9 = 0x19, - RA = 0x1A, - RtcComAdj = 0x1F, - RtcNow = 0x20, - EnLibOP = 0x40, - LibOPMode = 0x41, - LibID = 0x42, - LibAddress = 0x43, - VP = 0x46, - OPLength = 0x48, - Timer0 = 0x4A, - Timer1 = 0x4C, - Timer2 = 0x4D, - Timer3 = 0x4E, - KeyCode = 0x4F, - TrendlineClear = 0xEB, - ResetTrigger = 0xEE +enum class Register: uint8_t { + Version = 0x00, + Brightness = 0x01, + BuzzerBeepingTime = 0x02, + PictureID = 0x03, + TouchPanelFlag = 0x05, + TouchPanelStatus = 0x06, + TouchPanelPosition = 0x07, + TouchPanelEnable = 0x0B, + RunTime = 0x0C, + R0 = 0x10, + R1 = 0x11, + R2 = 0x12, + R3 = 0x13, + R4 = 0x14, + R5 = 0x15, + R6 = 0x16, + R7 = 0x17, + R8 = 0x18, + R9 = 0x19, + RA = 0x1A, + RtcComAdj = 0x1F, + RtcNow = 0x20, + EnLibOP = 0x40, + LibOPMode = 0x41, + LibID = 0x42, + LibAddress = 0x43, + VP = 0x46, + OPLength = 0x48, + Timer0 = 0x4A, + Timer1 = 0x4C, + Timer2 = 0x4D, + Timer3 = 0x4E, + KeyCode = 0x4F, + TrendlineClear = 0xEB, + ResetTrigger = 0xEE }; enum class Variable: uint16_t; @@ -87,59 +85,57 @@ enum class KeyValue: uint16_t; enum class Page: uint16_t; enum class ReceiveMode { Known, Unknown }; -namespace -{ - const uint8_t HEADER_BYTE_0 = 0x5A; - const uint8_t HEADER_BYTE_1 = 0xA5; - const size_t MAX_GARBAGE_BYTES = 5; +namespace { + const uint8_t HEADER_BYTE_0 = 0x5A; + const uint8_t HEADER_BYTE_1 = 0xA5; + const size_t MAX_GARBAGE_BYTES = 5; } // -------------------------------------------------------------------- // Dgus - DGUS LCD panel // -------------------------------------------------------------------- -struct Dgus -{ - void open(); - void setup(); - [[noreturn]] void forwarding_loop(); +struct Dgus { + void open(); + void setup(); + [[noreturn]] void forwarding_loop(); #ifdef ADV_UNIT_TESTS - void reset(); - template void reset(const uint8_t (&buffer)[S]); + void reset(); + template void reset(const uint8_t (&buffer)[S]); #endif - bool write_header(Command cmd, uint8_t param_size, uint8_t data_size); - bool wait_for_data(uint8_t size, bool blocking); - bool receive(Command cmd, bool blocking); + bool write_header(Command cmd, uint8_t param_size, uint8_t data_size); + bool wait_for_data(uint8_t size, bool blocking); + bool receive(Command cmd, bool blocking); - uint8_t read_byte(); - size_t read_bytes(uint8_t *buffer, size_t length); - void push_back(uint8_t byte); + uint8_t read_byte(); + size_t read_bytes(uint8_t *buffer, size_t length); + void push_back(uint8_t byte); - bool write_byte(uint8_t byte); - bool write_bytes(const uint8_t *bytes, size_t length); - bool write_bytes(const char *bytes, size_t length); - bool write_word(uint16_t word); - bool write_words(const uint16_t *words, size_t length); - bool write_text(const char* text, size_t text_length, size_t total_length); - bool write_centered_text(const char* text, size_t text_length, size_t total_length); + bool write_byte(uint8_t byte); + bool write_bytes(const uint8_t *bytes, size_t length); + bool write_bytes(const char *bytes, size_t length); + bool write_word(uint16_t word); + bool write_words(const uint16_t *words, size_t length); + bool write_text(const char* text, size_t text_length, size_t total_length); + bool write_centered_text(const char* text, size_t text_length, size_t total_length); private: - void kill(); - bool receive_header(); - bool has_pushed_back() const; - uint8_t get_pushed_back(); - - static const size_t MAX_PUSH_BACK = 5; - enum class State { Start = 0, Command = 1, Data = 2}; - - State state_ = State::Start; - uint8_t length_ = 0; - uint8_t read_ = 0; - Command command_ = Command::None; - uint8_t nb_pushed_back_ = 0; - uint8_t pushed_back_[MAX_PUSH_BACK] = {}; + void kill(); + bool receive_header(); + bool has_pushed_back() const; + uint8_t get_pushed_back(); + + static const size_t MAX_PUSH_BACK = 5; + enum class State { Start = 0, Command = 1, Data = 2}; + + State state_ = State::Start; + uint8_t length_ = 0; + uint8_t read_ = 0; + Command command_ = Command::None; + uint8_t nb_pushed_back_ = 0; + uint8_t pushed_back_[MAX_PUSH_BACK] = {}; }; extern Dgus dgus; // Singleton @@ -149,33 +145,32 @@ extern Dgus dgus; // Singleton // -------------------------------------------------------------------- template -struct OutFrame -{ - ~OutFrame(); +struct OutFrame { + ~OutFrame(); protected: - explicit OutFrame(Param param): parameter_{param} {} - bool write_header(uint8_t data_size); - bool write_parameter() const; - bool write_byte_data(uint8_t byte) const; - bool write_bytes_data(const uint8_t *bytes, size_t length) const; - bool write_bytes_data(const char *bytes, size_t length) const; - bool write_word_data(uint16_t word) const; - bool write_words_data(const uint16_t *words, size_t length) const; - bool write_text(const char* text, size_t text_length, size_t total_length) const; - bool write_centered_text(const char* text, size_t text_length, size_t total_length) const; + explicit OutFrame(Param param): parameter_{param} {} + bool write_header(uint8_t data_size); + bool write_parameter() const; + bool write_byte_data(uint8_t byte) const; + bool write_bytes_data(const uint8_t *bytes, size_t length) const; + bool write_bytes_data(const char *bytes, size_t length) const; + bool write_word_data(uint16_t word) const; + bool write_words_data(const uint16_t *words, size_t length) const; + bool write_text(const char* text, size_t text_length, size_t total_length) const; + bool write_centered_text(const char* text, size_t text_length, size_t total_length) const; private: - bool write_byte_parameter() const; - bool write_word_parameter() const; - void check_overflow(size_t size) const; + bool write_byte_parameter() const; + bool write_word_parameter() const; + void check_overflow(size_t size) const; private: - const Param parameter_{}; + const Param parameter_{}; #ifdef ADVi3PP_DEBUG - uint8_t data_size_ = 0; - mutable uint8_t data_written_ = 0; + uint8_t data_size_ = 0; + mutable uint8_t data_written_ = 0; #endif }; @@ -184,8 +179,7 @@ struct OutFrame // -------------------------------------------------------------------- template -struct ReadOutFrame: OutFrame -{ +struct ReadOutFrame: OutFrame { using Parent = OutFrame; explicit ReadOutFrame(Param param): Parent{param} {} bool write(uint8_t nb_bytes); @@ -196,19 +190,18 @@ struct ReadOutFrame: OutFrame // -------------------------------------------------------------------- template -struct WriteOutFrame: OutFrame -{ +struct WriteOutFrame: OutFrame { protected: - using Parent = OutFrame; - explicit WriteOutFrame(Param param): Parent{param} {}; + using Parent = OutFrame; + explicit WriteOutFrame(Param param): Parent{param} {}; - bool write_byte(uint8_t value); - bool write_word(uint16_t value); + bool write_byte(uint8_t value); + bool write_word(uint16_t value); - bool write_bytes_data(const uint8_t *data, size_t size); - bool write_words_data(const uint16_t *data, size_t size); - template bool write_bytes(T... data); - template bool write_words(T... data); + bool write_bytes_data(const uint8_t *data, size_t size); + bool write_words_data(const uint16_t *data, size_t size); + template bool write_bytes(T... data); + template bool write_words(T... data); }; // -------------------------------------------------------------------- @@ -216,8 +209,7 @@ struct WriteOutFrame: OutFrame // -------------------------------------------------------------------- template -struct InFrame -{ +struct InFrame { InFrame() = default; ~InFrame(); @@ -252,13 +244,12 @@ struct InFrame // -------------------------------------------------------------------- template -struct OutInFrame: InFrame -{ +struct OutInFrame: InFrame { bool send_receive(uint8_t nb_bytes); protected: - using Parent = InFrame; - explicit OutInFrame(Param param): Parent{param} {} + using Parent = InFrame; + explicit OutInFrame(Param param): Parent{param} {} }; @@ -266,8 +257,7 @@ struct OutInFrame: InFrame // WriteRegisterRequest // -------------------------------------------------------------------- -struct WriteRegisterRequest: WriteOutFrame -{ +struct WriteRegisterRequest: WriteOutFrame { using Parent = WriteOutFrame; explicit WriteRegisterRequest(Register reg): Parent{reg} {} using Parent::write_byte; @@ -278,18 +268,16 @@ struct WriteRegisterRequest: WriteOutFrame // ReadRegisterRequest // -------------------------------------------------------------------- -struct ReadRegisterRequest: ReadOutFrame -{ - using Parent = ReadOutFrame; - explicit ReadRegisterRequest(Register reg): Parent{reg} {} +struct ReadRegisterRequest: ReadOutFrame { + using Parent = ReadOutFrame; + explicit ReadRegisterRequest(Register reg): Parent{reg} {} }; // -------------------------------------------------------------------- // ReadRegisterDataResponse // -------------------------------------------------------------------- -struct ReadRegisterResponse: InFrame -{ +struct ReadRegisterResponse: InFrame { using Parent = InFrame; explicit ReadRegisterResponse(Register reg): Parent{reg} {} uint8_t get_nb_bytes() const { return get_nb_data(); } @@ -301,8 +289,7 @@ struct ReadRegisterResponse: InFrame -{ +struct ReadRegister: OutInFrame { using Parent = OutInFrame; explicit ReadRegister(Register reg): Parent{reg} {} using Parent::read_byte; @@ -313,8 +300,7 @@ struct ReadRegister: OutInFrame -{ +struct WriteRamRequest: WriteOutFrame { using Parent = WriteOutFrame; explicit WriteRamRequest(Variable var): Parent{var} {} using Parent::write_word; @@ -328,8 +314,7 @@ struct WriteRamRequest: WriteOutFrame // ReadRamDataRequest // -------------------------------------------------------------------- -struct ReadRamRequest: ReadOutFrame -{ +struct ReadRamRequest: ReadOutFrame { using Parent = ReadOutFrame; explicit ReadRamRequest(Variable var): Parent{var} {} }; @@ -338,8 +323,7 @@ struct ReadRamRequest: ReadOutFrame // ReadRamDataResponse // -------------------------------------------------------------------- -struct ReadRamResponse: InFrame -{ +struct ReadRamResponse: InFrame { using Parent = InFrame; explicit ReadRamResponse(Variable var): Parent{var} {} uint16_t get_nb_words() const { return get_nb_data(); } @@ -352,23 +336,21 @@ struct ReadRamResponse: InFrame // ReadAction // -------------------------------------------------------------------- -struct ReadAction: InFrame -{ - using Parent = InFrame; - ReadAction(): Parent{} {} - KeyValue read_key_value() { return static_cast(read_word()); } +struct ReadAction: InFrame { + using Parent = InFrame; + ReadAction(): Parent{} {} + KeyValue read_key_value() { return static_cast(read_word()); } }; // -------------------------------------------------------------------- // ReadRam (Request and Response) // -------------------------------------------------------------------- -struct ReadRam: OutInFrame -{ - using Parent = OutInFrame; - explicit ReadRam(Variable var): Parent{var} {} - using Parent::read_word; - using Parent::read_signed_word; +struct ReadRam: OutInFrame { + using Parent = OutInFrame; + explicit ReadRam(Variable var): Parent{var} {} + using Parent::read_word; + using Parent::read_signed_word; }; @@ -376,11 +358,10 @@ struct ReadRam: OutInFrame // WriteCurveDataRequest // -------------------------------------------------------------------- -struct WriteCurveRequest: WriteOutFrame -{ - using Parent = WriteOutFrame; - explicit WriteCurveRequest(uint8_t channels): Parent{channels} {} - using Parent::write_words; +struct WriteCurveRequest: WriteOutFrame { + using Parent = WriteOutFrame; + explicit WriteCurveRequest(uint8_t channels): Parent{channels} {} + using Parent::write_words; }; } diff --git a/Marlin/src/advi3pp/core/dimming.cpp b/Marlin/src/advi3pp/core/dimming.cpp index 6f3ebe8a85..56aa132d2b 100755 --- a/Marlin/src/advi3pp/core/dimming.cpp +++ b/Marlin/src/advi3pp/core/dimming.cpp @@ -31,15 +31,13 @@ namespace ADVi3pp { Dimming dimming; //! Constructor. Initialize dimming check time and dimming delay time -Dimming::Dimming() -{ - set_next_checking_time(); +Dimming::Dimming() { + set_next_checking_time(); } //! Set the next dimming check time -void Dimming::set_next_checking_time() -{ - next_check_time_ = millis() + 200; +void Dimming::set_next_checking_time() { + next_check_time_ = millis() + 200; } void Dimming::set_settings(bool dimming, uint8_t dimming_time, uint8_t normal_brightness, uint8_t dimming_brightness) { @@ -89,17 +87,14 @@ uint16_t Dimming::do_size_of() const { return sizeof(enabled_) + sizeof(dimming_brightness_) + sizeof(dimming_time_); } - -void Dimming::send() -{ - if(!is_enabled() || !dimmed_ || !ELAPSED(millis(), next_check_time_)) - return; - set_next_checking_time(); - ReadRegisterRequest{Register::TouchPanelFlag}.write(1); +void Dimming::send() { + if(!is_enabled() || !dimmed_ || !ELAPSED(millis(), next_check_time_)) + return; + set_next_checking_time(); + ReadRegisterRequest{Register::TouchPanelFlag}.write(1); } -bool Dimming::receive() -{ +bool Dimming::receive() { NoFrameLogging no_log{}; bool received = false; @@ -127,14 +122,12 @@ void Dimming::reset_touch() { } //! Set the brightness of the LCD panel -void Dimming::send_brightness_to_lcd(uint8_t brightness) -{ +void Dimming::send_brightness_to_lcd(uint8_t brightness) { WriteRegisterRequest{Register::Brightness}.write_byte(brightness); } //! Set the brightness of the LCD panel -void Dimming::send_brightness_to_lcd() -{ +void Dimming::send_brightness_to_lcd() { send_brightness_to_lcd(dimmed_ ? dimming_brightness_ : get_normal_brightness()); } diff --git a/Marlin/src/advi3pp/core/eeprom.h b/Marlin/src/advi3pp/core/eeprom.h index 2b1479d41d..9982e6f7bc 100644 --- a/Marlin/src/advi3pp/core/eeprom.h +++ b/Marlin/src/advi3pp/core/eeprom.h @@ -28,8 +28,7 @@ using eeprom_write = ExtUI::eeprom_write; using eeprom_read = ExtUI::eeprom_read; //! EEPROM writer: utility class to write values into EEPROM -struct EepromWrite -{ +struct EepromWrite { EepromWrite(eeprom_write write, int& eeprom_index, uint16_t& working_crc); template void write(const T& data); @@ -40,8 +39,7 @@ struct EepromWrite }; //! EEPROM reader: utility class to read values from EEPROM -struct EepromRead -{ +struct EepromRead { EepromRead(eeprom_read read, int& eeprom_index, uint16_t& working_crc); template inline void read(T& data); @@ -56,25 +54,19 @@ struct EepromRead // -------------------------------------------------------------------- inline EepromWrite::EepromWrite(eeprom_write write, int& eeprom_index, uint16_t& working_crc) - : write_(write), eeprom_index_(eeprom_index), working_crc_(working_crc) -{ -} +: write_(write), eeprom_index_(eeprom_index), working_crc_(working_crc) {} template -inline void EepromWrite::write(const T& data) -{ - write_(eeprom_index_, reinterpret_cast(&data), sizeof(T), &working_crc_); +inline void EepromWrite::write(const T& data) { + write_(eeprom_index_, reinterpret_cast(&data), sizeof(T), &working_crc_); } inline EepromRead::EepromRead(eeprom_read read, int& eeprom_index, uint16_t& working_crc) - : read_(read), eeprom_index_(eeprom_index), working_crc_(working_crc) -{ -} +: read_(read), eeprom_index_(eeprom_index), working_crc_(working_crc) {} template -inline void EepromRead::read(T& data) -{ - read_(eeprom_index_, reinterpret_cast(&data), sizeof(T), &working_crc_, true); +inline void EepromRead::read(T& data) { + read_(eeprom_index_, reinterpret_cast(&data), sizeof(T), &working_crc_, true); } } diff --git a/Marlin/src/advi3pp/core/enums.h b/Marlin/src/advi3pp/core/enums.h index 09ffde2055..c8a6f296aa 100644 --- a/Marlin/src/advi3pp/core/enums.h +++ b/Marlin/src/advi3pp/core/enums.h @@ -25,331 +25,341 @@ namespace ADVi3pp { -enum class Page: uint16_t -{ - Temporary = 0x8000, - - None = 0, - Main = 22, // 0x0016 - Controls = 24, // 0x0018 - Tuning = 26, // 0x001A - Settings = 28, // 0x001C - LoadUnload = 30, // 0x001E - WaitBack = 32 | Temporary, // 0x8020 - WaitBackContinue = 34 | Temporary, // 0x8022 - Preheat = 36, // 0x0024 - Move = 38, // 0x0026 - SdCard = 40 | Temporary, // 0x0028 - Print = 42, // 0x002A - Sponsors = 44, // 0x002C - Waiting = 46 | Temporary, // 0x802E - ManualLeveling = 48, // 0x0030 - ExtruderTuningTemp = 50, // 0x0032 - WaitContinue = 52 | Temporary, // 0x8034 - ExtruderTuningMeasure = 54, // 0x0036 - Leveling = 56, // 0x0038 - PidTuning = 58, // 0x003A - Killed = 60 | Temporary, // 0x803C - MotorsSettings = 62, // 0x003E - PidSettings = 64, // 0x0040 - FactoryReset = 66 | Temporary, // 0x8042 - Statistics = 68, // 0x0044 - Versions = 70, // 0x0046 - StepsSettings = 72, // 0x0048 - FeedrateSettings = 74, // 0x004A - AccelerationSettings = 76, // 0x004C - PauseOptions = 78 | Temporary, // 0x804E - PrintSettings = 80, // 0x0050 - Setup = 82, // 0x0052 - SetupNoSensor = 84, // 0x0054 - Temperature = 86, // 0x0056 - Infos = 88, // 0x0058 - VibrationsTuning = 90, // 0x005A - NoSensor = 92 | Temporary, // 0x805C - SensorSettings = 94, // 0x005E - LCD = 96, // 0x0060 - Copyrights = 98, // 0x0062 - KeyboardInteger = 100, // 0x0064 - SensorGrid = 102, // 0x0066 - EEPROMMismatch = 104 | Temporary, // 0x8068 - ZHeightTuning = 106, // 0x006A - LinearAdvanceTuning = 108, // 0x006C - LinearAdvanceSettings = 110, // 0x006E - IO = 112, // 0x0070 - BLTouchTesting1 = 114 | Temporary, // 0x8072 - BLTouchTesting2 = 116 | Temporary, // 0x8074 - BLTouchTesting3 = 118 | Temporary, // 0x8076 - BLTouchTesting4 = 120 | Temporary, // 0x8078 - KeyboardDecimal = 122, // 0x007A - KeyboardSignedInteger = 124, // 0x007C - KeyboardSignedDecimal = 126, // 0x007E - LevelingNoSensor = 128, // 0x0080 - ManualMesh = 130, // 0x0082 - XTwist = 132, // 0x0084 - Runout = 134, // 0x0086 - Skew1Settings = 136, - Skew2Settings = 138, - Skew3Settings = 140, - BuzzerSettings = 142, - - Boot = 200 | Temporary // 0x00C8 +enum class Page: uint16_t { + Temporary = 0x8000, // Temporary screen + ExitFinishMove = 0x4000, // Wait end of moved when exiting + EnterNoPrint = 0x2000, // Forbidden to enter if printing + PageNumber = 0x00FF, // Mask for the page number + + None = 0, + Main = 22, + Controls = 24, + Tuning = 26, + Settings = 28, + LoadUnload = 30 | EnterNoPrint | ExitFinishMove, + WaitBack = 32 | Temporary, + WaitBackContinue = 34 | Temporary, + Preheat = 36 | EnterNoPrint | ExitFinishMove, + Move = 38 | EnterNoPrint | ExitFinishMove, + SdCard = 40 | ExitFinishMove | Temporary, + Print = 42, + BabySteps = 44, + Waiting = 46 | Temporary, + ManualLeveling = 48 | EnterNoPrint | ExitFinishMove, + ExtruderTuning = 50 | EnterNoPrint | ExitFinishMove, + WaitContinue = 52 | Temporary, + ExtruderTuningMeasure = 54 | ExitFinishMove, + Leveling = 56, + PidTuning = 58 | EnterNoPrint | ExitFinishMove, + Killed = 60 | Temporary, + MotorsSettings = 62, + PidSettings = 64 | EnterNoPrint, + FactoryReset = 66 | EnterNoPrint | Temporary, + Statistics = 68, + Versions = 70, + StepsSettings = 72 | EnterNoPrint, + FeedrateSettings = 74 | EnterNoPrint, + AccelerationSettings = 76 | EnterNoPrint, + PauseOptions = 78 | Temporary, + PrintSettings = 80, + Setup = 82, + SetupNoSensor = 84, + Temperature = 86, + Infos = 88, + VibrationsTuning = 90 | EnterNoPrint | ExitFinishMove, + NoSensor = 92 | Temporary, + SensorSettings = 94 | EnterNoPrint, + LCD = 96, + Copyrights = 98, + KeyboardInteger = 100, + SensorGrid = 102, + EEPROMMismatch = 104 | Temporary, + ZHeightTuning = 106 | EnterNoPrint | ExitFinishMove, + LinearAdvanceTuning = 108 | EnterNoPrint | ExitFinishMove, + LinearAdvanceSettings = 110 | EnterNoPrint, + IO = 112, + BLTouchTesting1A = 114 | EnterNoPrint | Temporary, + BLTouchTesting2 = 116 | Temporary, + BLTouchTesting3 = 118 | Temporary, + BLTouchTesting4 = 120 | ExitFinishMove | Temporary, + KeyboardDecimal = 122, + KeyboardSignedInteger = 124, + KeyboardSignedDecimal = 126, + LevelingNoSensor = 128, + ManualMesh = 130, + XTwist = 132 | EnterNoPrint | ExitFinishMove, + Runout = 134, + Skew = 136 | EnterNoPrint | ExitFinishMove, + Skew2 = 138 | EnterNoPrint | ExitFinishMove, + Skew3 = 140 | EnterNoPrint | ExitFinishMove, + BuzzerSettings = 142, + AutomaticLeveling = 144 | EnterNoPrint | ExitFinishMove, + BLTouchTesting1B = 146 | EnterNoPrint | Temporary, + + Boot = 200 | Temporary }; ENABLE_BITMASK_OPERATOR(Page); + //! List of variables and their addresses. -enum class Variable: uint16_t -{ - // 0 - Statuses - TargetBed = 0x0000, - Bed = 0x0001, - TargetHotEnd = 0x0002, - HotEnd = 0x0003, - FanSpeed = 0x0004, - ZHeight = 0x0005, - ProgressLow = 0x0006, - ProgressHigh = 0x0007, - ZLayer = 0x0008, - SensorActive = 0x0009, - Feedrate = 0x000A, - Babysteps = 0x000B, - Message = 0x0010, - CenteredMessage = 0x0028, - ProgressText = 0x0040, - ProgressPercent = 0x0058, - ET = 0x005C, - TC = 0x0060, - - // 1 - Short Texts - ShortText0 = 0x0100, - ShortText1 = 0x0108, - ShortText2 = 0x0110, - ShortText3 = 0x0118, - ShortText4 = 0x0120, - - // 2 - Long Texts - LongText0 = 0x0200, - LongText1 = 0x0218, - LongText2 = 0x0230, - LongText3 = 0x0248, - LongText4 = 0x0260, - LongTextCentered0 = 0x0278, - - // 3 - Values - Value0 = 0x0300, - Value1 = 0x0301, - Value2 = 0x0302, - Value3 = 0x0303, - Value4 = 0x0304, - Value5 = 0x0305, - Value6 = 0x0306, - Value7 = 0x0307, - - // 5 - Versions - ADVi3ppVersion = 0x0500, - ADVi3ppBuild = 0x0508, - ADVi3ppDGUSVersion = 0x0510, - ADVi3ppMarlinVersion = 0x0518, - - BeepDuration = 0x0617, - NormalBrightness = 0x0618, - DimmingBrightness = 0x0619 +enum class Variable: uint16_t { + // 0 - Statuses + TargetBed = 0x0000, + Bed = 0x0001, + TargetHotEnd = 0x0002, + HotEnd = 0x0003, + FanSpeed = 0x0004, + ZHeight = 0x0005, + ProgressLow = 0x0006, + ProgressHigh = 0x0007, + ZLayer = 0x0008, + SensorActive = 0x0009, + Feedrate = 0x000A, + Flowrate = 0x000B, + Message = 0x0010, + CenteredMessage = 0x0028, + ProgressText = 0x0040, + ProgressPercent = 0x0058, + ET = 0x005C, + TC = 0x0060, + + // 1 - Short Texts + ShortText0 = 0x0100, + ShortText1 = 0x0108, + ShortText2 = 0x0110, + ShortText3 = 0x0118, + ShortText4 = 0x0120, + + // 2 - Long Texts + LongText0 = 0x0200, + LongText1 = 0x0218, + LongText2 = 0x0230, + LongText3 = 0x0248, + LongText4 = 0x0260, + LongTextCentered0 = 0x0278, + + // 3 - Values + Value0 = 0x0300, + Value1 = 0x0301, + Value2 = 0x0302, + Value3 = 0x0303, + Value4 = 0x0304, + Value5 = 0x0305, + Value6 = 0x0306, + Value7 = 0x0307, + + // 5 - Versions + ADVi3ppVersion = 0x0500, + ADVi3ppBuild = 0x0508, + ADVi3ppDGUSVersion = 0x0510, + ADVi3ppMarlinVersion = 0x0518, + + BeepDuration = 0x0617, + NormalBrightness = 0x0618, + DimmingBrightness = 0x0619 }; //! List of actions sent by the LCD. -enum class Action: uint16_t -{ - // 4 - Actions - Controls = 0x0400, - PrintCommand = 0x0401, - Wait = 0x0402, - LoadUnload = 0x0403, - Preheat = 0x0404, - Move = 0x0405, - SdCard = 0x0406, - FactoryReset = 0x0407, - ManualLeveling = 0x0408, - ExtruderTuning = 0x0409, - AutomaticLeveling = 0x040A, - PidTuning = 0x040B, - SensorSettings = 0x040C, - VibrationsTuning = 0x040D, - NoSensor = 0x040E, - LCD = 0x040F, - Statistics = 0x0410, - Versions = 0x0411, - PrintSettings = 0x0412, - PIDSettings = 0x0413, - StepsSettings = 0x0414, - FeedrateSettings = 0x0415, - AccelerationSettings = 0x0416, - PauseOptions = 0x0417, - Copyrights = 0x0418, - Sponsors = 0x0419, - SensorGrid = 0x041A, - SensorZHeight = 0x041B, - ChangeFilament = 0x041C, - EEPROMMismatch = 0x041D, - USB2LCD = 0x041E, - BLTouchTesting = 0x041F, - LinearAdvanceSettings = 0x0420, - Diagnosis = 0x0421, - Temperatures = 0x0422, - Setup = 0x0423, - XTwist = 0x0424, - Runout = 0x0425, - Skew = 0x0426, - BeeperSettings = 0x0427, - - // 6 - Moves - MoveXMinus = 0x0600, - MoveXPlus = 0x0601, - MoveYMinus = 0x0602, - MoveYPlus = 0x0603, - MoveZMinus = 0x0604, - MoveZPlus = 0x0605, - MoveEMinus = 0x0606, - MoveEPlus = 0x0607, - BabyMinus = 0x0608, - BabyPlus = 0x0609, - ZHeightMinus = 0x060A, - ZHeightPlus = 0x060B, - // UNUSED = 0x060C, - FeedrateMinus = 0x060D, - FeedratePlus = 0x060E, - FanMinus = 0x060F, - FanPlus = 0x0610, - HotendMinus = 0x0611, - HotendPlus = 0x0612, - BedMinus = 0x0613, - BedPlus = 0x0614, - XTwistMinus = 0x0615, - XTwistPlus = 0x0616, - BeepDuration = 0x0617, - NormalBrightness = 0x0618, - DimmingBrightness = 0x0619, - - Undefined = 0xFFFF +enum class Action: uint16_t { + None = 0, + // 4 - Actions + Controls = 0x0400, + Print = 0x0401, + Wait = 0x0402, + LoadUnload = 0x0403, + Preheat = 0x0404, + Move = 0x0405, + SdCard = 0x0406, + FactoryReset = 0x0407, + ManualLeveling = 0x0408, + ExtruderTuning = 0x0409, + AutomaticLeveling = 0x040A, + PidTuning = 0x040B, + SensorSettings = 0x040C, + VibrationsTuning = 0x040D, + NoSensor = 0x040E, + LCD = 0x040F, + Statistics = 0x0410, + Versions = 0x0411, + PrintSettings = 0x0412, + PidSettings = 0x0413, + StepsSettings = 0x0414, + FeedrateSettings = 0x0415, + AccelerationSettings = 0x0416, + PauseOptions = 0x0417, + Copyrights = 0x0418, + //unused = 0x0419, + SensorGrid = 0x041A, + ZHeightTuning = 0x041B, + ChangeFilament = 0x041C, // Not used + EEPROMMismatch = 0x041D, // Not used + USB2LCD = 0x041E, + BLTouchTesting = 0x041F, + LinearAdvanceSettings = 0x0420, + IO = 0x0421, + Temperatures = 0x0422, + Setup = 0x0423, + XTwist = 0x0424, + Runout = 0x0425, + Skew = 0x0426, + BuzzerSettings = 0x0427, + BabySteps = 0x0428, + + // 6 - Moves + MoveXMinus = 0x0600, + MoveXPlus = 0x0601, + MoveYMinus = 0x0602, + MoveYPlus = 0x0603, + MoveZMinus = 0x0604, + MoveZPlus = 0x0605, + MoveEMinus = 0x0606, + MoveEPlus = 0x0607, + BabyMinus = 0x0608, + BabyPlus = 0x0609, + ZHeightMinus = 0x060A, + ZHeightPlus = 0x060B, + // UNUSED = 0x060C, + FeedrateMinus = 0x060D, + FeedratePlus = 0x060E, + FanMinus = 0x060F, + FanPlus = 0x0610, + HotendMinus = 0x0611, + HotendPlus = 0x0612, + BedMinus = 0x0613, + BedPlus = 0x0614, + XTwistMinus = 0x0615, + XTwistPlus = 0x0616, + BeepDuration = 0x0617, + NormalBrightness = 0x0618, + DimmingBrightness = 0x0619, + FlowrateMinus = 0x061A, + FlowratePlus = 0x061B, + + Undefined = 0xFFFF }; //! Key values used by the LCD screens. -enum class KeyValue: uint16_t -{ - Show = 0x0000, - - Temps = 0x0000, - Print = 0x0001, - Controls = 0x0002, - Tuning = 0x0003, - Settings = 0x0004, - Infos = 0x0005, - Motors = 0x0006, - Leveling = 0x0007, - PrintSettings = 0x0008, - - PrintStop = 0x0001, - PrintPause = 0x0002, - PrintAdvancedPause = 0x0003, - - Load = 0x0001, - Unload = 0x0002, - - PresetPrevious = 0x0001, - PresetNext = 0x0002, - Cooldown = 0x0003, - - MoveXHome = 0x0001, - MoveYHome = 0x0002, - MoveZHome = 0x0003, - MoveAllHome = 0x0004, - DisableMotors = 0x0005, - - SDLine1 = 0x0001, - SDLine2 = 0x0002, - SDLine3 = 0x0003, - SDLine4 = 0x0004, - SDLine5 = 0x0005, - SDUp = 0x0006, - SDDown = 0x0007, - SDParent = 0x0008, - - LevelingPoint1 = 0x0001, - LevelingPoint2 = 0x0002, - LevelingPoint3 = 0x0003, - LevelingPoint4 = 0x0004, - LevelingPoint5 = 0x0005, - LevelingPointA = 0x0006, - LevelingPointB = 0x0007, - LevelingPointC = 0x0008, - LevelingPointD = 0x0009, - - LevelingTest = 0x0001, - LevelingResetProbe = 0x0002, - - TuningStart = 0x0001, - TuningSettings = 0x0002, - - PidTuningStep2 = 0x0001, - PidTuningHotend = 0x0002, - PidTuningBed = 0x0003, - - SensorSettingsPrevious = 0x0001, - SensorSettingsNext = 0x0002, - - LCDDimming = 0x0001, - - BuzzOnAction = 0x0001, - BuzzOnPress = 0x0002, - - MismatchForward = 0x0001, - - PidSettingsHotend = 0x0001, - PidSettingsBed = 0x0002, - PidSettingPrevious = 0x0003, - PidSettingNext = 0x0004, - - SensorSelfTest = 0x0001, - SensorReset = 0x0002, - SensorDeploy = 0x0003, - SensorStow = 0x0004, - - Multiplier1 = 0x0001, - Multiplier2 = 0x0002, - Multiplier3 = 0x0003, - Point_L = 0x0004, - Point_M = 0x0005, - Point_R = 0x0006, - - Baby1 = 0x0001, - Baby2 = 0x0002, - Baby3 = 0x0003, - - Extrude = 0x0001, - Resume = 0x0002, - - BLTouchTestingStep1Yes = 0x0001, - BLTouchTestingStep1No = 0x0002, - BLTouchTestingStep2Yes = 0x0003, - BLTouchTestingStep2No = 0x0004, - BLTouchTestingStep3Yes = 0x0005, - BLTouchTestingStep3No = 0x0006, - - VibrationsX = 0x0001, - VibrationsY = 0x0002, - VibrationsXY = 0x0003, - VibrationsYX = 0x0004, - VibrationsZ = 0x0005, - - RunoutEnable = 0x0001, - RunoutHigh2Low = 0x0002, - RunoutLow2High = 0x0003, - RunoutLED = 0x0004, - RunoutDistance = 0x0005, - - SkewStep2 = 0x0001, - SkewStep3 = 0x0002, - - Save = 0xFFFE, - Back = 0xFFFF +enum class KeyValue: uint16_t { + Show = 0x0000, + + Temps = 0x0000, + Print = 0x0001, + Controls = 0x0002, + Tuning = 0x0003, + Settings = 0x0004, + Infos = 0x0005, + Motors = 0x0006, + Leveling = 0x0007, + PrintSettings = 0x0008, + BabySteps = 0x0009, + + PrintStop = 0x0001, + PrintPause = 0x0002, + PrintAdvancedPause = 0x0003, + + Load = 0x0001, + Unload = 0x0002, + + PresetPrevious = 0x0001, + PresetNext = 0x0002, + Cooldown = 0x0003, + + MoveXHome = 0x0001, + MoveYHome = 0x0002, + MoveZHome = 0x0003, + MoveAllHome = 0x0004, + DisableMotors = 0x0005, + + SDLine1 = 0x0001, + SDLine2 = 0x0002, + SDLine3 = 0x0003, + SDLine4 = 0x0004, + SDLine5 = 0x0005, + SDUp = 0x0006, + SDDown = 0x0007, + SDParent = 0x0008, + + LevelingPoint1 = 0x0001, + LevelingPoint2 = 0x0002, + LevelingPoint3 = 0x0003, + LevelingPoint4 = 0x0004, + LevelingPoint5 = 0x0005, + LevelingPointA = 0x0006, + LevelingPointB = 0x0007, + LevelingPointC = 0x0008, + LevelingPointD = 0x0009, + + LevelingTest = 0x0001, + LevelingResetProbe = 0x0002, + + TuningStart = 0x0001, + TuningSettings = 0x0002, + + PidTuningStep2 = 0x0001, + PidTuningHotend = 0x0002, + PidTuningBed = 0x0003, + + SensorSettingsPrevious = 0x0001, + SensorSettingsNext = 0x0002, + SensorSettingsHighSpeed = 0x0003, + + LCDDimming = 0x0001, + + BuzzOnAction = 0x0001, + BuzzOnPress = 0x0002, + + MismatchForward = 0x0001, + + PidSettingsHotend = 0x0001, + PidSettingsBed = 0x0002, + PidSettingPrevious = 0x0003, + PidSettingNext = 0x0004, + + SensorSelfTest = 0x0001, + SensorReset = 0x0002, + SensorDeploy = 0x0003, + SensorStow = 0x0004, + + Multiplier1 = 0x0001, + Multiplier2 = 0x0002, + Multiplier3 = 0x0003, + Point_L = 0x0004, + Point_M = 0x0005, + Point_R = 0x0006, + + Baby1 = 0x0001, + Baby2 = 0x0002, + Baby3 = 0x0003, + + Extrude = 0x0001, + Resume = 0x0002, + + BLTouchTestingStep1aYes = 0x0001, + BLTouchTestingStep1aNo = 0x0002, + BLTouchTestingStep1bSlow = 0x0003, + BLTouchTestingStep1bQuick = 0x0004, + BLTouchTestingStep1bNo = 0x0005, + BLTouchTestingStep2Yes = 0x0006, + BLTouchTestingStep2No = 0x0007, + + VibrationsX = 0x0001, + VibrationsY = 0x0002, + VibrationsXY = 0x0003, + VibrationsYX = 0x0004, + VibrationsZ = 0x0005, + + RunoutEnable = 0x0001, + RunoutHigh2Low = 0x0002, + RunoutLow2High = 0x0003, + RunoutLED = 0x0004, + RunoutDistance = 0x0005, + + SkewStep2 = 0x0001, + SkewStep3 = 0x0002, + + Abort = 0xFFFD, + Save = 0xFFFE, + Back = 0xFFFF }; diff --git a/Marlin/src/advi3pp/core/graphs.cpp b/Marlin/src/advi3pp/core/graphs.cpp index e5ad9de165..c694ff59a8 100644 --- a/Marlin/src/advi3pp/core/graphs.cpp +++ b/Marlin/src/advi3pp/core/graphs.cpp @@ -30,35 +30,31 @@ Graphs graphs; //! Constructor //! Initialize the update time -Graphs::Graphs() -{ - next_update_graph_time_ = millis() + 1000L * 10; // Wait 10 sec before starting updating graphs +Graphs::Graphs() { + next_update_graph_time_ = millis() + 1000L * 10; // Wait 10 sec before starting updating graphs } //! Update the graphs (if the update delay has elapsed) -void Graphs::update() -{ - if(!ELAPSED(millis(), next_update_graph_time_)) - return; +void Graphs::update() { + if(!ELAPSED(millis(), next_update_graph_time_)) + return; - send_data(); - next_update_graph_time_ = millis() + 500; + send_data(); + next_update_graph_time_ = millis() + 500; } //! Update the graphs on the LCD panel (two channels: the bed and the hotend). -void Graphs::send_data() -{ - NoFrameLogging no_logging{}; - WriteCurveRequest{0b00000011}.write_words( - ExtUI::getActualTemp_celsius(ExtUI::BED), - ExtUI::getActualTemp_celsius(ExtUI::E0) - ); +void Graphs::send_data() { + NoFrameLogging no_logging{}; + WriteCurveRequest{0b00000011}.write_words( + ExtUI::getActualTemp_celsius(ExtUI::BED), + ExtUI::getActualTemp_celsius(ExtUI::E0) + ); } //! Clear the graphs -void Graphs::clear() -{ - WriteRegisterRequest{Register::TrendlineClear}.write_byte(0x55); +void Graphs::clear() { + WriteRegisterRequest{Register::TrendlineClear}.write_byte(0x55); } } diff --git a/Marlin/src/advi3pp/core/graphs.h b/Marlin/src/advi3pp/core/graphs.h index 78b397a886..ce691cff8a 100644 --- a/Marlin/src/advi3pp/core/graphs.h +++ b/Marlin/src/advi3pp/core/graphs.h @@ -23,16 +23,15 @@ namespace ADVi3pp { //! Graphs -struct Graphs -{ - Graphs(); +struct Graphs { + Graphs(); - void clear(); - void send_data(); - void update(); + void clear(); + void send_data(); + void update(); private: - uint32_t next_update_graph_time_; + uint32_t next_update_graph_time_; }; extern Graphs graphs; diff --git a/Marlin/src/advi3pp/core/logging.cpp b/Marlin/src/advi3pp/core/logging.cpp index 0fa86f4a4d..e597ce64ba 100755 --- a/Marlin/src/advi3pp/core/logging.cpp +++ b/Marlin/src/advi3pp/core/logging.cpp @@ -38,42 +38,40 @@ Log Log::frame_logging_{false}; #endif void space() { - SERIAL_CHAR(' '); + SERIAL_CHAR(' '); } Log& Log::log(LogState state) { - if(state == LogState::Start) - logging_ << F("// LOG:"); - return logging_; + if(state == LogState::Start) + logging_ << F("// LOG:"); + return logging_; } Log& Log::frame(LogState state) { - if(state == LogState::Start) - frame_logging_ << F("// FRAME:"); - return frame_logging_; + if(state == LogState::Start) + frame_logging_ << F("// FRAME:"); + return frame_logging_; } Log& Log::error() { - logging_ << F("// ERROR:"); - return logging_; + logging_ << F("// ERROR:"); + return logging_; } -Log& Log::operator<<(const char* data) -{ - if(enabled_ && !suspend_) { - SERIAL_ECHO(data); - space(); - } - return *this; +Log& Log::operator<<(const char* data) { + if(enabled_ && !suspend_) { + SERIAL_ECHO(data); + space(); + } + return *this; } -Log& Log::operator<<(const FlashChar* data) -{ - if(enabled_ && !suspend_) { - serial_print_P(from_flash(data)); - space(); - } - return *this; +Log& Log::operator<<(const FlashChar* data) { + if(enabled_ && !suspend_) { + serial_print_P(from_flash(data)); + space(); + } + return *this; } Log& Log::operator<<(bool data) { @@ -82,13 +80,12 @@ Log& Log::operator<<(bool data) { return *this; } -Log& Log::operator<<(uint8_t data) -{ - if(enabled_ && !suspend_) { - dump(&data); - space(); - } - return *this; +Log& Log::operator<<(uint8_t data) { + if(enabled_ && !suspend_) { + dump(&data); + space(); + } + return *this; } Log& Log::operator<<(uint16_t data) @@ -102,70 +99,75 @@ Log& Log::operator<<(uint16_t data) return *this; } -Log& Log::operator<<(uint32_t data) -{ - if(enabled_ && !suspend_) { - auto bytes = reinterpret_cast(&data); - dump(bytes + 3); - dump(bytes + 2); - dump(bytes + 1); - dump(bytes + 0); - space(); - } - return *this; +Log& Log::operator<<(uint32_t data) { + if(enabled_ && !suspend_) { + auto bytes = reinterpret_cast(&data); + dump(bytes + 3); + dump(bytes + 2); + dump(bytes + 1); + dump(bytes + 0); + space(); + } + return *this; } -Log& Log::operator<<(double data) -{ - if(enabled_ && !suspend_) { - SERIAL_ECHO(data); - space(); - } - return *this; +Log& Log::operator<<(int8_t data) { + return this->operator<<(static_cast(data)); } -Log& Log::operator<<(EndOfLine) -{ - if(enabled_ && !suspend_) - SERIAL_EOL(); - return *this; +Log& Log::operator<<(int16_t data) { + return this->operator<<(static_cast(data)); } -Log& Log::write(const uint8_t* data, size_t size) -{ - if(enabled_ && !suspend_ && size > 0) { - dump(data, size); - space(); - } - return *this; +Log& Log::operator<<(int32_t data) { + return this->operator<<(static_cast(data)); +} + +Log& Log::operator<<(double data) { + if(enabled_ && !suspend_) { + SERIAL_ECHO(data); + space(); + } + return *this; +} + +Log& Log::operator<<(EndOfLine) { + if(enabled_ && !suspend_) + SERIAL_EOL(); + return *this; +} + +Log& Log::write(const uint8_t* data, size_t size) { + if(enabled_ && !suspend_ && size > 0) { + dump(data, size); + space(); + } + return *this; } //! Dump the bytes in hexadecimal and print them (serial) -void Log::dump(const uint8_t* bytes, size_t size, bool separator) -{ - static const char digits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; +void Log::dump(const uint8_t* bytes, size_t size, bool separator) { + static const char digits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; - if(!enabled_ || suspend_) - return; + if(!enabled_ || suspend_) + return; - for(size_t index = 0; index < size; ++index) - { - SERIAL_CHAR(digits[bytes[index] / 16]); - SERIAL_CHAR(digits[bytes[index] % 16]); - if(separator && index < size - 1) - space(); - } + for(size_t index = 0; index < size; ++index) { + SERIAL_CHAR(digits[bytes[index] / 16]); + SERIAL_CHAR(digits[bytes[index] % 16]); + if(separator && index < size - 1) + space(); + } } -void assert_(const char *msg, const char *file, uint16_t line) -{ - Log::error() << F("ASSERTION FAILED:") << msg << "in file" << file << "line" << line << Log::endl(); - debug_break(); +void assert_(const char *msg, const char *file, uint16_t line) { + Log::error() << F("ASSERTION FAILED:") << msg << "in file" << file << "line" << line << Log::endl(); + debug_break(); } void debug_break() { #ifdef ADVi3PP_HARD_BREAK - asm("break \n"); + asm("break \n"); #endif } diff --git a/Marlin/src/advi3pp/core/logging.h b/Marlin/src/advi3pp/core/logging.h index 11912ab11c..9567096d22 100755 --- a/Marlin/src/advi3pp/core/logging.h +++ b/Marlin/src/advi3pp/core/logging.h @@ -40,51 +40,52 @@ struct log_exception: std::exception {}; // NoLogging // -------------------------------------------------------------------- -struct NoFrameLogging -{ - NoFrameLogging(); - ~NoFrameLogging(); +struct NoFrameLogging { + NoFrameLogging(); + ~NoFrameLogging(); - void allow(); + void allow(); private: - bool suspend_ = false; + bool suspend_ = false; }; // -------------------------------------------------------------------- // Log // -------------------------------------------------------------------- -struct Log -{ - Log(bool enabled); - - struct EndOfLine {}; - - Log& operator<<(const char* data); - Log& operator<<(const FlashChar* data); - Log& operator<<(bool data); - Log& operator<<(uint8_t data); - Log& operator<<(uint16_t data); - Log& operator<<(uint32_t data); - Log& operator<<(double data); - template Log& operator<<(adv::array data); - Log& write(const uint8_t* data, size_t size); - Log& operator<<(EndOfLine eol); - - static Log& log(LogState state = LogState::Start); - static Log& error(); - static Log& frame(LogState state = LogState::Continue); - static EndOfLine endl() { return EndOfLine{}; } - void dump(const uint8_t* bytes, size_t size = 1, bool separator = true); +struct Log { + Log(bool enabled); + + struct EndOfLine {}; + + Log& operator<<(const char* data); + Log& operator<<(const FlashChar* data); + Log& operator<<(bool data); + Log& operator<<(uint8_t data); + Log& operator<<(uint16_t data); + Log& operator<<(uint32_t data); + Log& operator<<(int8_t data); + Log& operator<<(int16_t data); + Log& operator<<(int32_t data); + Log& operator<<(double data); + template Log& operator<<(adv::array data); + Log& write(const uint8_t* data, size_t size); + Log& operator<<(EndOfLine eol); + + static Log& log(LogState state = LogState::Start); + static Log& error(); + static Log& frame(LogState state = LogState::Continue); + static EndOfLine endl() { return EndOfLine{}; } + void dump(const uint8_t* bytes, size_t size = 1, bool separator = true); private: - static Log logging_; - static Log frame_logging_; - bool enabled_ = true; - bool suspend_ = false; + static Log logging_; + static Log frame_logging_; + bool enabled_ = true; + bool suspend_ = false; - friend NoFrameLogging; + friend NoFrameLogging; }; // -------------------------------------------------------------------- @@ -96,8 +97,8 @@ inline Log::Log(bool enabled): enabled_{enabled} { template Log& Log::operator<<(adv::array data) { - write(data.data(), S); - return *this; + write(data.data(), S); + return *this; } // -------------------------------------------------------------------- @@ -107,17 +108,17 @@ Log& Log::operator<<(adv::array data) { inline NoFrameLogging::NoFrameLogging() : suspend_{Log::frame_logging_.suspend_} { #ifndef ADVi3PP_LOG_ALL_FRAMES - Log::frame_logging_.suspend_ = true; + Log::frame_logging_.suspend_ = true; #endif } inline NoFrameLogging::~NoFrameLogging() { - allow(); + allow(); } inline void NoFrameLogging::allow() { #ifndef ADVi3PP_LOG_ALL_FRAMES - Log::frame_logging_.suspend_ = suspend_; + Log::frame_logging_.suspend_ = suspend_; #endif } @@ -131,45 +132,46 @@ void assert_(const char *msg, const char *file, uint16_t line); void debug_break(); #else -struct Log -{ - struct EndOfLine {}; - - Log& operator<<(const char*) { return log(); } - Log& operator<<(const FlashChar*) { return log(); } - Log& operator<<(bool data) { return log(); } - Log& operator<<(uint8_t) { return log(); } - Log& operator<<(uint16_t) { return log(); } - Log& operator<<(uint32_t) { return log(); } - Log& operator<<(double) { return log(); } - template Log& operator<<(adv::array data) { return log(); } - Log& write(const uint8_t* data, size_t size) { return log(); } - void operator<<(EndOfLine) {}; - - static Log& log() { static Log log; return log; } - static Log& error(); - static Log& frame(LogState state = LogState::Continue) { return log(); } - static EndOfLine endl() { return EndOfLine{}; } - static void dump(const uint8_t*, size_t) {} +struct Log { + struct EndOfLine {}; + + Log& operator<<(const char*) { return log(); } + Log& operator<<(const FlashChar*) { return log(); } + Log& operator<<(bool data) { return log(); } + Log& operator<<(uint8_t) { return log(); } + Log& operator<<(uint16_t) { return log(); } + Log& operator<<(uint32_t) { return log(); } + Log& operator<<(int8_t data) { return log(); } + Log& operator<<(int16_t data) { return log(); } + Log& operator<<(int32_t data) { return log(); } + Log& operator<<(double) { return log(); } + template Log& operator<<(adv::array data) { return log(); } + Log& write(const uint8_t* data, size_t size) { return log(); } + void operator<<(EndOfLine) {}; + + static Log& log() { static Log log; return log; } + static Log& error(); + static Log& frame(LogState state = LogState::Continue) { return log(); } + static EndOfLine endl() { return EndOfLine{}; } + static void dump(const uint8_t*, size_t) {} #ifdef ADVi3PP_UNIT_TEST - Log& operator<<(unsigned long data) { return log(); } + Log& operator<<(unsigned long data) { return log(); } #endif }; -struct NoFrameLogging -{ - NoFrameLogging() {} - ~NoFrameLogging() {} +struct NoFrameLogging { + NoFrameLogging() {} + ~NoFrameLogging() {} - void allow() {} + void allow() {} }; inline Log& Log::error() { #ifdef ADV_UNIT_TESTS - throw log_exception(); + throw log_exception(); #endif - return log(); + return log(); } #ifndef assert diff --git a/Marlin/src/advi3pp/core/pages.cpp b/Marlin/src/advi3pp/core/pages.cpp index af58581267..1ebc8712c4 100755 --- a/Marlin/src/advi3pp/core/pages.cpp +++ b/Marlin/src/advi3pp/core/pages.cpp @@ -21,102 +21,154 @@ #include "../parameters.h" #include "dgus.h" #include "pages.h" +#include "core.h" +#include "settings.h" +#include "wait.h" namespace ADVi3pp { Pages pages; -Log& operator<<(Log& log, Page page) -{ - log << static_cast(page); - return log; -} - -bool Pages::is_temporary(Page page) { - return test_one_bit(page, Page::Temporary); +inline Log& operator<<(Log& log, Page page) { + log << static_cast(page); + return log; } //! Show the given page on the LCD screen //! @param [in] page The page to be displayed on the LCD screen -void Pages::show(Page page) -{ - auto current = get_current_page(); - if(!is_temporary(current) && current != Page::Main) - back_pages_.push(current); +void Pages::show(Page page, Action action) { + auto current = get_current_context(); + // Don't push temporary screens or Main (Main is implicitly always at the top) + if(!is_temporary(current.page) && current.page != Page::Main) + back_.push(current); - show_(page); + send_page_to_lcd(Context{page, action}); } -void Pages::show_(Page page) -{ - WriteRegisterRequest{Register::PictureID}.write_page(get_cleared_bits(page, Page::Temporary)); - - current_page_ = page; +void Pages::send_page_to_lcd(Context context) { + WriteRegisterRequest{Register::PictureID}.write_page(context.page & Page::PageNumber); + current_ = context; } //! Retrieve the current page on the LCD screen -Page Pages::get_current_page() { - // Boot page switches automatically (animation) to the Main page - if(current_page_ == Page::None || current_page_ == Page::Boot) - current_page_ = Page::Main; - return current_page_; -} - -bool Pages::is_current_page_temporary() { - return is_temporary(get_current_page()); +Pages::Context Pages::get_current_context() { + // Boot page switches automatically (animation) to the Main page + if(current_.page == Page::None || current_.page == Page::Boot) + current_= Context{Page::Main, Action::Controls}; + return current_; } //! Set page to display after the completion of an operation. -void Pages::save_forward_page() -{ - auto current = get_current_page(); - forward_page_ = current; +void Pages::save_forward_page() { + forward_ = get_current_context(); } //! Show the "Back" page on the LCD display. -void Pages::show_back_page() -{ - if(back_pages_.is_empty()) - { - show_(Page::Main); - return; - } +void Pages::show_back_page(unsigned nb_back) { + Context context{Page::Main, Action::Controls}; - auto back = back_pages_.pop(); - if(back == forward_page_) - forward_page_ = Page::None; - show_(back); + for(; nb_back > 0; --nb_back) { + if (back_.is_empty()) + break; + + context = back_.pop(); + if (context.page == forward_.page) + forward_ = Context{Page::None, Action::None}; + } + + send_page_to_lcd(context); } //! Show the "Next" page on the LCD display. -void Pages::show_forward_page() -{ - if(forward_page_ == Page::None) - { - show_back_page(); - return; +void Pages::show_forward_page() { + // If no forward page defined, use the back page + if(forward_.page == Page::None) { + show_back_page(); + return; + } + + while(!back_.is_empty()) { + auto back = back_.pop(); + if(back.page == forward_.page) { + send_page_to_lcd(forward_); + forward_ = Context{Page::None, Action::None}; + return; } + } - while(!back_pages_.is_empty()) - { - Page back_page = back_pages_.pop(); - if(back_page == forward_page_) - { - show_(forward_page_); - forward_page_ = Page::None; - return; - } - } + Log::error() << F("Back pages do not contain page") << forward_.page << Log::endl(); + forward_ = Context{Page::None, Action::None}; + send_page_to_lcd(Context{Page::Main, Action::Controls}); +} + +void Pages::reset() { + back_.empty(); +} + +void Pages::save() { + settings.save(); + if(current_page_ensure_no_move() && core.is_busy()) { + wait.wait(F("Please wait...")); + background_task.set(Callback{&Pages::save_task}); + } + else + pages.show_forward_page(); +} + +void Pages::save_task() { + if(core.is_busy()) return; + background_task.clear(); + status.reset(); + pages.show_forward_page(); +} + +void Pages::back() { + if(current_page_ensure_no_move() && core.is_busy()) { + wait.wait(F("Please wait...")); + background_task.set(Callback{&Pages::back_task}); + } + else + pages.show_back_page(); +} + +void Pages::back_task() { + if(core.is_busy()) return; + background_task.clear(); + status.reset(); + pages.clear_temporaries(); + pages.show_back_page(); +} + +void Pages::clear_temporaries() { + auto current = get_current_context(); + if(!is_temporary(current.page)) + return; + + while(is_temporary(current.page) && !back_.is_empty()) + current = back_.pop(); + send_page_to_lcd(current); +} - Log::error() << F("Back pages do not contain page") << forward_page_ << Log::endl(); - forward_page_ = Page::None; - reset(); - show_(Page::Main); +bool Pages::check_no_print(Page page) { + if(!test_one_bit(page, Page::EnterNoPrint) || !ExtUI::isPrinting()) + return true; + wait.wait_back(F("This is not accessible when printing")); + return false; } -void Pages::reset() -{ - back_pages_.empty(); +void Pages::go_to_print() { + auto current = pages.get_current_context(); + // If already on the print page, do nothing + if(current.page == Page::Print) + return; + + // Otherwise, pop the back pages and send abort messages + while(!back_.is_empty() && current.page != Page::Print) { + core.process_action(current.action, KeyValue::Abort); + current = back_.pop(); + } + // Display print page + send_page_to_lcd(Context{Page::Print, Action::Print}); } } diff --git a/Marlin/src/advi3pp/core/pages.h b/Marlin/src/advi3pp/core/pages.h index f880cea0f2..9ab5e7c040 100644 --- a/Marlin/src/advi3pp/core/pages.h +++ b/Marlin/src/advi3pp/core/pages.h @@ -28,26 +28,56 @@ namespace ADVi3pp { //! Display a page on top of the others; display back and forward pages -struct Pages -{ - void show(Page page); - Page get_current_page(); - bool is_current_page_temporary(); - void save_forward_page(); - void show_back_page(); - void show_forward_page(); - void reset(); +struct Pages { + void show(Page page, Action action); + Page get_current_page() { return get_current_context().page; } + void clear_temporaries(); + void go_to_print(); + bool current_page_ensure_no_move(); + bool check_no_print(Page page); + void save_forward_page(); + void show_back_page(unsigned nb_back = 1); + void show_forward_page(); + void reset(); + void save(); + void back(); private: - void show_(Page page); - static bool is_temporary(Page page); + struct Context {Page page = Page::None; Action action = Action::None; }; + + static void save_task(); + static void back_task(); + Context get_current_context(); + void send_page_to_lcd(Context context); + static bool is_temporary(Page page); + static bool ensure_no_move(Page page); + + friend inline Log& operator<<(Log& log, Pages::Context context) { + log << "(P:" << static_cast(context.page) << "A:" << static_cast(context.action) << ")"; + return log; + } private: - Stack back_pages_{}; - Page forward_page_ = Page::None; - Page current_page_ = Page::Main; + static constexpr size_t STACK_SIZE = 8; + + Stack back_{}; + Context forward_ = Context{Page::None, Action::None}; + Context current_ = Context{Page::Main, Action::None}; }; +inline bool Pages::is_temporary(Page page) { + return test_one_bit(page, Page::Temporary); +} + +inline bool Pages::ensure_no_move(Page page) { + return test_one_bit(page, Page::ExitFinishMove); +} + +inline bool Pages::current_page_ensure_no_move() { + return ensure_no_move(get_current_page()); +} + + extern Pages pages; } diff --git a/Marlin/src/advi3pp/core/pid.cpp b/Marlin/src/advi3pp/core/pid.cpp index b6a7c21f1b..3d2c6e74f8 100644 --- a/Marlin/src/advi3pp/core/pid.cpp +++ b/Marlin/src/advi3pp/core/pid.cpp @@ -30,10 +30,8 @@ Pid pid; //! Store current data in permanent memory (EEPROM) //! @param eeprom EEPROM writer -void Pid::do_write(EepromWrite& eeprom) const -{ - for(size_t i = 0; i < NB_PIDs; ++i) - { +void Pid::do_write(EepromWrite& eeprom) const { + for(size_t i = 0; i < NB_PIDs; ++i) { eeprom.write(bed_pid_[i]); eeprom.write(hotend_pid_[i]); } @@ -41,11 +39,9 @@ void Pid::do_write(EepromWrite& eeprom) const //! Validate data from permanent memory (EEPROM). //! @param eeprom EEPROM reader -bool Pid::do_validate(EepromRead &eeprom) -{ +bool Pid::do_validate(EepromRead &eeprom) { PidValue pid{}; - for(size_t i = 0; i < NB_PIDs; ++i) - { + for(size_t i = 0; i < NB_PIDs; ++i) { eeprom.read(pid); eeprom.read(pid); } @@ -54,10 +50,8 @@ bool Pid::do_validate(EepromRead &eeprom) //! Restore data from permanent memory (EEPROM). //! @param eeprom EEPROM reader -void Pid::do_read(EepromRead& eeprom) -{ - for(size_t i = 0; i < NB_PIDs; ++i) - { +void Pid::do_read(EepromRead& eeprom) { + for(size_t i = 0; i < NB_PIDs; ++i) { eeprom.read(bed_pid_[i]); eeprom.read(hotend_pid_[i]); } @@ -66,8 +60,7 @@ void Pid::do_read(EepromRead& eeprom) //! Reset settings void Pid::do_reset() { - for(size_t i = 0; i < NB_PIDs; ++i) - { + for(size_t i = 0; i < NB_PIDs; ++i) { bed_pid_[i].temperature_ = default_bed_temperature; bed_pid_[i].Kp_ = DEFAULT_bedKp; bed_pid_[i].Ki_ = DEFAULT_bedKi; @@ -82,8 +75,7 @@ void Pid::do_reset() //! Return the amount of data (in bytes) necessary to save settings in permanent memory (EEPROM). //! @return Number of bytes -uint16_t Pid::do_size_of() const -{ +uint16_t Pid::do_size_of() const { return NB_PIDs * 2 * sizeof(PidValue); } @@ -91,13 +83,10 @@ uint16_t Pid::do_size_of() const //! Record new PID values for a given temperature //! @param kind Kind of PID values: Hotend or Bed //! @param temperature Temperature for these PID values -void Pid::add_pid(TemperatureKind kind, uint16_t temperature) -{ +void Pid::add_pid(TemperatureKind kind, uint16_t temperature) { auto& pid = get_pids(kind); - for(size_t i = 0; i < NB_PIDs; ++i) - { - if(temperature == pid[i].temperature_) - { + for(size_t i = 0; i < NB_PIDs; ++i) { + if(temperature == pid[i].temperature_) { get_marlin_pid(kind, i); return; } @@ -114,18 +103,15 @@ void Pid::add_pid(TemperatureKind kind, uint16_t temperature) //! Choose the best PID values for the given temperature //! @param kind Kind of PID values: Hotend or Bed //! @param temperature Temperature for these PID values -void Pid::choose_best_pid(TemperatureKind kind, uint16_t temperature) -{ +void Pid::choose_best_pid(TemperatureKind kind, uint16_t temperature) { size_t index = 0; uint16_t best_difference = 500; const auto& pid = get_pids(kind); - for(size_t i = 0; i < NB_PIDs; ++i) - { + for(size_t i = 0; i < NB_PIDs; ++i) { auto difference = abs(temperature - pid[i].temperature_); - if(difference < best_difference) - { + if(difference < best_difference) { best_difference = difference; index = i; } @@ -135,8 +121,7 @@ void Pid::choose_best_pid(TemperatureKind kind, uint16_t temperature) } //! Set the current PID values from what is recorded -void Pid::set_marlin_pid(TemperatureKind kind, size_t index) const -{ +void Pid::set_marlin_pid(TemperatureKind kind, size_t index) const { assert(kind <= TemperatureKind::Hotend); const PidValue& pid = get_pid(kind, index); @@ -151,8 +136,7 @@ void Pid::set_marlin_pid(TemperatureKind kind, size_t index) const } //! Record the current PID values -void Pid::get_marlin_pid(TemperatureKind kind, size_t index) -{ +void Pid::get_marlin_pid(TemperatureKind kind, size_t index) { assert(kind <= TemperatureKind::Hotend); PidValue& pid = get_pid(kind, index); diff --git a/Marlin/src/advi3pp/core/screen.h b/Marlin/src/advi3pp/core/screen.h new file mode 100644 index 0000000000..8c335b765f --- /dev/null +++ b/Marlin/src/advi3pp/core/screen.h @@ -0,0 +1,101 @@ +/** + * ADVi3++ Firmware For Wanhao Duplicator i3 Plus (based on Marlin) + * + * Copyright (C) 2017-2022 Sebastien Andrivet [https://github.com/andrivet/] + * + * This program 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. + * + * This program 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 this program. If not, see . + * + */ + +#pragma once + +#include "../../lcd/extui/ui_api.h" +#include "../lib/ADVstd/ADVcrtp.h" +#include "../core/settings.h" +#include "../core/enums.h" +#include "../core/eeprom.h" +#include "../core/pages.h" + +namespace ADVi3pp { + +//! Handle inputs from the LCD Panel +template +struct Screen: adv::Crtp { + void handle(KeyValue value); + void show(); + +protected: + bool on_dispatch(KeyValue value); + Page on_get_page() const; + void on_enter(); + void on_save_command(); + void on_back_command(); + void on_abort(); +}; + +// -------------------------------------------------------------------- +// Screen implementation +// -------------------------------------------------------------------- + +template +void Screen::handle(KeyValue value) { + if(!this->self().on_dispatch(value)) + Log::error() << F("Invalid key value ") << static_cast(value) << Log::endl(); +} + +template +Page Screen::on_get_page() const { + return this->self().PAGE; +} + +template +void Screen::on_enter() {} + +template +bool Screen::on_dispatch(KeyValue value) { + switch(value) { + case KeyValue::Show: show(); break; + case KeyValue::Abort: this->self().on_abort(); break; + case KeyValue::Save: this->self().on_save_command(); break; + case KeyValue::Back: this->self().on_back_command(); break; + default: return false; + } + + return true; +} + +template +void Screen::show() { + Page page = this->self().on_get_page(); + if(!pages.check_no_print(page)) return; + + this->self().on_enter(); + if(page != Page::None) + pages.show(page, this->self().ACTION); +} + +template +void Screen::on_save_command() { + pages.save(); +} + +template +void Screen::on_back_command() { + pages.back(); +} + +template +void Screen::on_abort() {} + +} diff --git a/Marlin/src/advi3pp/core/settings.cpp b/Marlin/src/advi3pp/core/settings.cpp index f975e89b00..0873009041 100755 --- a/Marlin/src/advi3pp/core/settings.cpp +++ b/Marlin/src/advi3pp/core/settings.cpp @@ -35,141 +35,124 @@ namespace ADVi3pp { ExtendedSettings settings; -void ExtendedSettings::on_factory_reset() -{ - settings.reset(); - if(does_eeprom_mismatch()) - return; +void ExtendedSettings::on_factory_reset() { + settings.reset(); + if(does_eeprom_mismatch()) + return; - pages.reset(); - setup.show(); + pages.reset(); + setup.show(); } -void ExtendedSettings::on_store_settings(ExtUI::eeprom_write write, int& eeprom_index, uint16_t& working_crc) -{ - settings.write(write, eeprom_index, working_crc); +void ExtendedSettings::on_store_settings(ExtUI::eeprom_write write, int& eeprom_index, uint16_t& working_crc) { + settings.write(write, eeprom_index, working_crc); } -bool ExtendedSettings::on_load_settings(ExtUI::eeprom_read read, int& eeprom_index, uint16_t& working_crc, bool validating) -{ - if(validating) - return settings.validate(read, eeprom_index, working_crc); - settings.read(read, eeprom_index, working_crc); - return true; +bool ExtendedSettings::on_load_settings(ExtUI::eeprom_read read, int& eeprom_index, uint16_t& working_crc, bool validating) { + if(validating) + return settings.validate(read, eeprom_index, working_crc); + settings.read(read, eeprom_index, working_crc); + return true; } -uint16_t ExtendedSettings::on_sizeof_settings() -{ - return settings.size_of(); +uint16_t ExtendedSettings::on_sizeof_settings() { + return settings.size_of(); } -void ExtendedSettings::on_settings_written(bool success) -{ -} +void ExtendedSettings::on_settings_written(bool success) {} -void ExtendedSettings::on_settings_loaded(bool success) -{ - if(!success) - eeprom_mismatch_ = true; +void ExtendedSettings::on_settings_loaded(bool success) { + if(!success) + eeprom_mismatch_ = true; } -void ExtendedSettings::on_settings_validated(bool success) -{ - if(!success) - eeprom_mismatch_ = true; +void ExtendedSettings::on_settings_validated(bool success) { + if(!success) + eeprom_mismatch_ = true; } -bool ExtendedSettings::write(eeprom_write write, int& eeprom_index, uint16_t& working_crc) -{ - EepromWrite eeprom{write, eeprom_index, working_crc}; +bool ExtendedSettings::write(eeprom_write write, int& eeprom_index, uint16_t& working_crc) { + EepromWrite eeprom{write, eeprom_index, working_crc}; - eeprom.write(settings_version); - pid.write(eeprom); - dimming.write(eeprom); - buzzer.write(eeprom); + eeprom.write(settings_version); + pid.write(eeprom); + dimming.write(eeprom); + buzzer.write(eeprom); return true; } -bool ExtendedSettings::validate(eeprom_read read, int& eeprom_index, uint16_t& working_crc) -{ - bool valid = true; - EepromRead eeprom{read, eeprom_index, working_crc}; +bool ExtendedSettings::validate(eeprom_read read, int& eeprom_index, uint16_t& working_crc) { + bool valid = true; + EepromRead eeprom{read, eeprom_index, working_crc}; - uint16_t version = 0; - eeprom.read(version); - if(version != settings_version) - valid = false; + uint16_t version = 0; + eeprom.read(version); + if(version != settings_version) + valid = false; - if(!pid.validate(eeprom) || - !dimming.validate(eeprom) || - !buzzer.validate(eeprom) - ) - valid = false; + if(!pid.validate(eeprom) || + !dimming.validate(eeprom) || + !buzzer.validate(eeprom) + ) + valid = false; - return valid; + return valid; } -void ExtendedSettings::read(eeprom_read read, int& eeprom_index, uint16_t& working_crc) -{ - EepromRead eeprom{read, eeprom_index, working_crc}; +void ExtendedSettings::read(eeprom_read read, int& eeprom_index, uint16_t& working_crc) { + EepromRead eeprom{read, eeprom_index, working_crc}; - uint16_t version = 0; - eeprom.read(version); - pid.read(eeprom); - dimming.read(eeprom); - buzzer.read(eeprom); + uint16_t version = 0; + eeprom.read(version); + pid.read(eeprom); + dimming.read(eeprom); + buzzer.read(eeprom); } //! Reset presets. -void ExtendedSettings::reset() -{ - pid.reset(); - dimming.reset(); - buzzer.reset(); +void ExtendedSettings::reset() { + pid.reset(); + dimming.reset(); + buzzer.reset(); } //! Return the size of data specific to ADVi3++ -uint16_t ExtendedSettings::size_of() const -{ - return - sizeof(settings_version) + - pid.size_of() + - dimming.size_of() + - buzzer.size_of(); +uint16_t ExtendedSettings::size_of() const { + return + sizeof(settings_version) + + pid.size_of() + + dimming.size_of() + + buzzer.size_of(); } //! Save the current settings permanently in EEPROM memory -void ExtendedSettings::save() -{ - eeprom_mismatch_ = false; - ExtUI::saveSettings(); +void ExtendedSettings::save() { + eeprom_mismatch_ = false; + ExtUI::saveSettings(); } //! Restore settings from EEPROM memory -void ExtendedSettings::restore() -{ - // Note: Previously, M420 (bed leveling compensation) was reset by M501. It is no more the case. - ExtUI::loadSettings(); +void ExtendedSettings::restore() { + // Note: Previously, M420 (bed leveling compensation) was reset by M501. It is no more the case. + ExtUI::loadSettings(); } //! Get the last used temperature for the hotend or the bad //! @param kind Kind of temperature: hotend or bed //! @return The last used themperature -uint16_t ExtendedSettings::get_last_used_temperature(TemperatureKind kind) const -{ - return last_used_temperature_[kind == TemperatureKind::Hotend]; +uint16_t ExtendedSettings::get_last_used_temperature(TemperatureKind kind) const { + return last_used_temperature_[kind == TemperatureKind::Hotend]; } //! To be called when a new temperature is selected as a target //! @param kind Kind of temperature: hotend or bed //! @param temperature The new target temperature -void ExtendedSettings::on_set_temperature(TemperatureKind kind, uint16_t temperature) -{ - if(temperature == 0) - return; - last_used_temperature_[kind == TemperatureKind::Hotend] = temperature; - pid.choose_best_pid(kind, temperature); +void ExtendedSettings::on_set_temperature(TemperatureKind kind, uint16_t temperature) { + if(temperature == 0) + return; + last_used_temperature_[kind == TemperatureKind::Hotend] = temperature; + pid.choose_best_pid(kind, temperature); } diff --git a/Marlin/src/advi3pp/core/settings.h b/Marlin/src/advi3pp/core/settings.h index 856483a121..99d6f29814 100755 --- a/Marlin/src/advi3pp/core/settings.h +++ b/Marlin/src/advi3pp/core/settings.h @@ -46,33 +46,32 @@ struct Settings : adv::Crtp { }; -struct ExtendedSettings -{ - void on_factory_reset(); - bool does_eeprom_mismatch() const { return eeprom_mismatch_; } - - uint16_t on_sizeof_settings(); - void on_store_settings(ExtUI::eeprom_write write, int& eeprom_index, uint16_t& working_crc); - bool on_load_settings(ExtUI::eeprom_read read, int& eeprom_index, uint16_t& working_crc, bool validating); - void on_settings_written(bool success); - void on_settings_loaded(bool success); - void on_settings_validated(bool success); - - uint16_t size_of() const; - bool write(eeprom_write write, int& eeprom_index, uint16_t& working_crc); - void read(eeprom_read read, int& eeprom_index, uint16_t& working_crc); - bool validate(eeprom_read read, int& eeprom_index, uint16_t& working_crc); - void reset(); - - void save(); - void restore(); - - uint16_t get_last_used_temperature(TemperatureKind kind) const; - void on_set_temperature(TemperatureKind kind, uint16_t temperature); +struct ExtendedSettings { + void on_factory_reset(); + bool does_eeprom_mismatch() const { return eeprom_mismatch_; } + + uint16_t on_sizeof_settings(); + void on_store_settings(ExtUI::eeprom_write write, int& eeprom_index, uint16_t& working_crc); + bool on_load_settings(ExtUI::eeprom_read read, int& eeprom_index, uint16_t& working_crc, bool validating); + void on_settings_written(bool success); + void on_settings_loaded(bool success); + void on_settings_validated(bool success); + + uint16_t size_of() const; + bool write(eeprom_write write, int& eeprom_index, uint16_t& working_crc); + void read(eeprom_read read, int& eeprom_index, uint16_t& working_crc); + bool validate(eeprom_read read, int& eeprom_index, uint16_t& working_crc); + void reset(); + + void save(); + void restore(); + + uint16_t get_last_used_temperature(TemperatureKind kind) const; + void on_set_temperature(TemperatureKind kind, uint16_t temperature); private: - adv::array last_used_temperature_ {{default_bed_temperature, default_hotend_temperature}}; - bool eeprom_mismatch_ = false; + adv::array last_used_temperature_ {{default_bed_temperature, default_hotend_temperature}}; + bool eeprom_mismatch_ = false; }; extern ExtendedSettings settings; diff --git a/Marlin/src/advi3pp/core/stack.h b/Marlin/src/advi3pp/core/stack.h index ae1e27e998..b69d0a6707 100644 --- a/Marlin/src/advi3pp/core/stack.h +++ b/Marlin/src/advi3pp/core/stack.h @@ -27,63 +27,62 @@ namespace ADVi3pp { template -struct Stack -{ - void push(T e); - T pop(); - bool is_empty() const; - void empty(); - bool contains(T e) const; - void log(Log& l) const; +struct Stack { + void push(T e); + T pop(); + bool is_empty() const; + void empty(); + bool contains(T e) const; + void log(Log& l) const; private: - adv::array elements_; - size_t top_ = 0; + adv::array elements_; + size_t top_ = 0; }; template -void Stack::push(T e) -{ - assert(top_ <= S); - elements_[top_++] = e; +inline Log& operator<<(Log& log, Stack stack) { + stack.log(log); + return log; } template -T Stack::pop() -{ - assert(!is_empty()); - return elements_[--top_]; +inline void Stack::push(T e) { + assert(top_ <= S); + elements_[top_++] = e; } template -bool Stack::is_empty() const -{ - return top_ == 0; +inline T Stack::pop() { + assert(!is_empty()); + return elements_[--top_]; } template -void Stack::empty() -{ - top_ = 0; +bool Stack::is_empty() const { + return top_ == 0; } template -bool Stack::contains(T e) const -{ - for(size_t i = 0; i < top_; ++i) - if(elements_[top_ - i - 1] == e) - return true; - return false; +inline void Stack::empty() { + top_ = 0; } template -void Stack::log(Log& l) const -{ +bool Stack::contains(T e) const { + for(size_t i = 0; i < top_; ++i) + if(elements_[top_ - i - 1] == e) + return true; + return false; +} + +template +void Stack::log(Log& l) const { #ifdef ADVi3PP_DEBUG - if(is_empty()) - l << F(""); - for(size_t i = 0; i < top_; ++i) - l << elements_[i]; + if(is_empty()) + l << F(""); + for(size_t i = 0; i < top_; ++i) + l << elements_[i]; #endif } diff --git a/Marlin/src/advi3pp/core/status.cpp b/Marlin/src/advi3pp/core/status.cpp index 0fe0b29806..fe3bbd981e 100755 --- a/Marlin/src/advi3pp/core/status.cpp +++ b/Marlin/src/advi3pp/core/status.cpp @@ -22,6 +22,7 @@ #include "../../lcd/extui/ui_api.h" #include "logging.h" #include "status.h" +#include "pages.h" #include "dgus.h" #include "enums.h" @@ -30,121 +31,121 @@ namespace ADVi3pp { Status status; -void Status::reset() -{ - has_status_ = false; - set(""); +void Status::reset() { + has_status_ = false; + set(""); } -bool Status::has() const -{ - return has_status_; +void Status::reset_and_clear() { + pages.clear_temporaries(); + reset(); } -void Status::set(const FlashChar* message) -{ - ADVString text{message}; - send_status(text); - has_status_ = true; +bool Status::has() const { + return has_status_; } -void Status::set(const char* message) -{ - ADVString text{message}; - send_status(text); - has_status_ = true; +void Status::set(const FlashChar* message) { + ADVString text{message}; + send_status(text); + has_status_ = true; } -void Status::set(const FlashChar* fmt, va_list& args) -{ - ADVString text{}; - text.set(fmt, args); - send_status(text); - has_status_ = true; +void Status::set(const char* message) { + ADVString text{message}; + send_status(text); + has_status_ = true; } -void Status::send() -{ - send_progress(); - send_times(); +void Status::format(const FlashChar* fmt, va_list& args) { + ADVString text{}; + text.set(fmt, args); + send_status(text); + has_status_ = true; } -void Status::send_progress() -{ - auto done = ExtUI::getProgress_percent(); - if(done == percent_) - return; - percent_ = done; +void Status::format(const FlashChar* fmt, ...) { + va_list args; + va_start(args, fmt); + format(fmt, args); + va_end(args); +} + +void Status::send() { + send_progress(); + send_times(); +} + +void Status::send_progress() { + auto done = ExtUI::getProgress_percent(); + if(done == percent_) + return; + percent_ = done; - ADVString progress{filename_}; - if(progress.length() > 0) - progress << " " << done << "%"; + ADVString progress{filename_}; + if(progress.length() > 0) + progress << " " << done << "%"; - ADVString progress_percent{}; - progress_percent << done << "%"; + ADVString progress_percent{}; + progress_percent << done << "%"; - WriteRamRequest{Variable::ProgressText}.write_text(progress); - WriteRamRequest{Variable::ProgressPercent}.write_text(progress_percent); + WriteRamRequest{Variable::ProgressText}.write_text(progress); + WriteRamRequest{Variable::ProgressPercent}.write_text(progress_percent); } template void set_duration(ADVString& str, uint32_t seconds) { - uint16_t h = uint16_t(seconds / (60 * 60)); - uint16_t m = uint16_t((seconds / 60) % 60UL); + auto h = uint16_t(seconds / (60 * 60)); + auto m = uint16_t((seconds / 60) % 60UL); - if(h < 100) - str.format(F("%02hu:%02hu"), h, m); - else - str.format(F("%hu:%02hu"), h, m); + if(h < 100) + str.format(F("%02hu:%02hu"), h, m); + else + str.format(F("%hu:%02hu"), h, m); } -void Status::send_times() -{ - if(!ExtUI::isPrinting()) - return; - auto current_time = millis(); - if(!ELAPSED(current_time, next_update_times_time_)) - return; - next_update_times_time_ = current_time + 2000; // every 2 seconds +void Status::send_times() { + if(!ExtUI::isPrinting()) return; + auto current_time = millis(); + if(!ELAPSED(current_time, next_update_times_time_)) + return; + next_update_times_time_ = current_time + 2000; // every 2 seconds - ADVString tc; // time to complete - ADVString et; // elapsed time + ADVString tc; // time to complete + ADVString et; // elapsed time - auto durationSec = ExtUI::getProgress_seconds_elapsed(); - auto progress = ExtUI::getProgress_percent(); + auto durationSec = ExtUI::getProgress_seconds_elapsed(); + auto progress = ExtUI::getProgress_percent(); - set_duration(et, durationSec); + set_duration(et, durationSec); - auto tcSec = progress <= 0 ? 0 : (durationSec * (100 - progress) / progress); - if (progress < 5) - tc.set(F("--:--")); - else - set_duration(tc, tcSec); + auto tcSec = progress <= 0 ? 0 : (durationSec * (100 - progress) / progress); + if (progress < 5) + tc.set(F("--:--")); + else + set_duration(tc, tcSec); - WriteRamRequest{Variable::ET}.write_text(et); - WriteRamRequest{Variable::TC}.write_text(tc); + WriteRamRequest{Variable::ET}.write_text(et); + WriteRamRequest{Variable::TC}.write_text(tc); } //! Set the name for the progress message. Usually, it is the name of the file printed. -void Status::set_filename(const char* name) -{ - filename_ = name; - percent_ = -1; - send_progress(); +void Status::set_filename(const char* name) { + filename_ = name; + percent_ = -1; + send_progress(); } //! Clear the progress message -void Status::reset_progress() -{ - filename_.reset(); - percent_ = -1; - send_progress(); +void Status::reset_progress() { + filename_.reset(); + percent_ = -1; + send_progress(); } -void Status::send_status(ADVString& message) -{ - WriteRamRequest{Variable::Message}.write_text(message); - WriteRamRequest{Variable::CenteredMessage}.write_centered_text(message); +void Status::send_status(ADVString& message) { + WriteRamRequest{Variable::Message}.write_text(message); + WriteRamRequest{Variable::CenteredMessage}.write_centered_text(message); } } diff --git a/Marlin/src/advi3pp/core/status.h b/Marlin/src/advi3pp/core/status.h index 9ef2da1a97..ed9758b9c2 100644 --- a/Marlin/src/advi3pp/core/status.h +++ b/Marlin/src/advi3pp/core/status.h @@ -33,28 +33,29 @@ const size_t progress_percent_length = 8; //!< Size of the progress percent text const size_t tc_length = 8; //!< Size of the time to complete message to be displayed on the LCD Panel const size_t et_length = 8; //!< Size of the elaplsed time message to be displayed on the LCD Panel -struct Status -{ - void reset(); - void set(const FlashChar* message); - void set(const char* message); - void set(const FlashChar* fmt, va_list& args); - bool has() const; - - void send(); - void set_filename(const char* name); - void reset_progress(); +struct Status { + void reset(); + void reset_and_clear(); + void set(const FlashChar* message); + void set(const char* message); + void format(const FlashChar* fmt, va_list& args); + void format(const FlashChar* fmt, ...); + bool has() const; + + void send(); + void set_filename(const char* name); + void reset_progress(); private: - void send_progress(); - void send_times(); - void send_status(ADVString& message); + void send_progress(); + void send_times(); + void send_status(ADVString& message); private: - bool has_status_ = false; - ADVString filename_; - int percent_ = -1; - uint32_t next_update_times_time_ = 0; + bool has_status_ = false; + ADVString filename_; + int percent_ = -1; + uint32_t next_update_times_time_ = 0; }; extern Status status; diff --git a/Marlin/src/advi3pp/core/string.h b/Marlin/src/advi3pp/core/string.h index 98fdb11745..7a8f8855ba 100644 --- a/Marlin/src/advi3pp/core/string.h +++ b/Marlin/src/advi3pp/core/string.h @@ -36,66 +36,64 @@ namespace ADVi3pp { // String without dynamic allocation and a fixed maximum size // -------------------------------------------------------------------- -enum class Base: uint8_t -{ - Decimal = 10, - Hexadecimal = 16 +enum class Base: uint8_t { + Decimal = 10, + Hexadecimal = 16 }; template -struct ADVString -{ - ADVString() = default; - template explicit ADVString(const ADVString& str); - explicit ADVString(const char* s); - explicit ADVString(const FlashChar* s); - explicit ADVString(char c); - explicit ADVString(int16_t n, Base b = Base::Decimal); - explicit ADVString(int32_t n, Base b = Base::Decimal); - explicit ADVString(uint16_t n, Base b = Base::Decimal); - explicit ADVString(uint32_t n, Base b = Base::Decimal); - explicit ADVString(double n, uint8_t decimals = 2); - - ADVString& operator=(const char* str); - ADVString& operator=(const FlashChar* str); - ADVString& operator=(char c); - template ADVString& operator=(const ADVString& str); - - ADVString& set(const char* s); - ADVString& set(const char* fmt, va_list& args); - ADVString& set(const FlashChar* s); - ADVString& set(const FlashChar* fmt, va_list& args); - template ADVString& set(const ADVString& s); - ADVString& set(char c); - ADVString& set(int16_t n, Base base = Base::Decimal); - ADVString& set(int32_t n, Base base = Base::Decimal); - ADVString& set(uint16_t n, Base base = Base::Decimal); - ADVString& set(uint32_t n, Base base = Base::Decimal); - ADVString& set(double n, uint8_t decimals = 2); - ADVString& reset(); - - ADVString& format(const char* fmt, ...); - ADVString& format(const FlashChar* fmt, ...); - - ADVString& append(const char* s); - ADVString& append(const FlashChar* s); - ADVString& append(char c); - ADVString& append(int16_t n, Base base = Base::Decimal); - ADVString& append(int32_t n, Base base = Base::Decimal); - ADVString& append(uint16_t n, Base base = Base::Decimal); - ADVString& append(uint32_t n, Base base = Base::Decimal); - ADVString& append(double n, uint8_t decimals = 2); - void operator+=(const char* s); - void operator+=(const FlashChar* s); - void operator+=(char c); - - size_t length() const; - char operator[](size_t i) const; - bool is_empty() const; - const char* get() const; +struct ADVString { + ADVString() = default; + template explicit ADVString(const ADVString& str); + explicit ADVString(const char* s); + explicit ADVString(const FlashChar* s); + explicit ADVString(char c); + explicit ADVString(int16_t n, Base b = Base::Decimal); + explicit ADVString(int32_t n, Base b = Base::Decimal); + explicit ADVString(uint16_t n, Base b = Base::Decimal); + explicit ADVString(uint32_t n, Base b = Base::Decimal); + explicit ADVString(double n, uint8_t decimals = 2); + + ADVString& operator=(const char* str); + ADVString& operator=(const FlashChar* str); + ADVString& operator=(char c); + template ADVString& operator=(const ADVString& str); + + ADVString& set(const char* s); + ADVString& set(const char* fmt, va_list& args); + ADVString& set(const FlashChar* s); + ADVString& set(const FlashChar* fmt, va_list& args); + template ADVString& set(const ADVString& s); + ADVString& set(char c); + ADVString& set(int16_t n, Base base = Base::Decimal); + ADVString& set(int32_t n, Base base = Base::Decimal); + ADVString& set(uint16_t n, Base base = Base::Decimal); + ADVString& set(uint32_t n, Base base = Base::Decimal); + ADVString& set(double n, uint8_t decimals = 2); + ADVString& reset(); + + ADVString& format(const char* fmt, ...); + ADVString& format(const FlashChar* fmt, ...); + + ADVString& append(const char* s); + ADVString& append(const FlashChar* s); + ADVString& append(char c); + ADVString& append(int16_t n, Base base = Base::Decimal); + ADVString& append(int32_t n, Base base = Base::Decimal); + ADVString& append(uint16_t n, Base base = Base::Decimal); + ADVString& append(uint32_t n, Base base = Base::Decimal); + ADVString& append(double n, uint8_t decimals = 2); + void operator+=(const char* s); + void operator+=(const FlashChar* s); + void operator+=(char c); + + size_t length() const; + char operator[](size_t i) const; + bool is_empty() const; + const char* get() const; private: - adv::array string_{}; + adv::array string_{}; }; // -------------------------------------------------------------------- @@ -120,116 +118,103 @@ template inline ADVString& ADVString::operator=(const FlashChar* template inline ADVString& ADVString::operator=(const char c) { set(c); return *this; } template template inline ADVString& ADVString::operator=(const ADVString& str) { set(str); return *this; } -template template ADVString& ADVString::set(const ADVString& s) -{ - strlcpy(string_.data(), s.get(), L + 1); - return *this; +template template ADVString& ADVString::set(const ADVString& s) { + strlcpy(string_.data(), s.get(), L + 1); + return *this; } template -inline ADVString& ADVString::set(const char* s) -{ - strlcpy(string_.data(), s, L + 1); - return *this; +inline ADVString& ADVString::set(const char* s) { + strlcpy(string_.data(), s, L + 1); + return *this; } template -ADVString& ADVString::set(const char c) -{ - if(L < 1) - return *this; - string_[0] = c; - string_[1] = 0; - +ADVString& ADVString::set(const char c) { + if(L < 1) return *this; + string_[0] = c; + string_[1] = 0; + + return *this; } template -ADVString& ADVString::set(const char* fmt, va_list& args) -{ - vsnprintf(string_.data(), L + 1, fmt, args); - return *this; +ADVString& ADVString::set(const char* fmt, va_list& args) { + vsnprintf(string_.data(), L + 1, fmt, args); + return *this; } #ifndef ADVi3PP_UNIT_TEST template -inline ADVString& ADVString::set(const FlashChar* s) -{ - strlcpy_P(string_.data(), reinterpret_cast(s), L + 1); - return *this; +inline ADVString& ADVString::set(const FlashChar* s) { + strlcpy_P(string_.data(), reinterpret_cast(s), L + 1); + return *this; } template -ADVString& ADVString::set(const FlashChar* fmt, va_list& args) -{ - vsnprintf_P(string_.data(), L + 1, reinterpret_cast(fmt), args); - return *this; +ADVString& ADVString::set(const FlashChar* fmt, va_list& args) { + vsnprintf_P(string_.data(), L + 1, reinterpret_cast(fmt), args); + return *this; } #endif template -ADVString& ADVString::set(int16_t n, Base base) -{ - char buffer[2 + 8 * sizeof(int16_t)]; - itoa(n, buffer, static_cast(base)); - return set(buffer); +ADVString& ADVString::set(int16_t n, Base base) { + char buffer[2 + 8 * sizeof(int16_t)]; + itoa(n, buffer, static_cast(base)); + return set(buffer); } template -ADVString& ADVString::set(int32_t n, Base base) -{ - char buffer[2 + 8 * sizeof(int32_t)]; - ltoa(n, buffer, static_cast(base)); - return set(buffer); +ADVString& ADVString::set(int32_t n, Base base) { + char buffer[2 + 8 * sizeof(int32_t)]; + ltoa(n, buffer, static_cast(base)); + return set(buffer); } template -ADVString& ADVString::set(uint16_t n, Base base) -{ - char buffer[1 + 8 * sizeof(uint16_t)]; - utoa(n, buffer, static_cast(base)); - return set(buffer); +ADVString& ADVString::set(uint16_t n, Base base) { + char buffer[1 + 8 * sizeof(uint16_t)]; + utoa(n, buffer, static_cast(base)); + return set(buffer); } template -ADVString& ADVString::set(uint32_t n, Base base) -{ - char buffer[1 + 8 * sizeof(uint16_t)]; - ultoa(n, buffer, static_cast(base)); - return set(buffer); +ADVString& ADVString::set(uint32_t n, Base base) { + char buffer[1 + 8 * sizeof(uint16_t)]; + ultoa(n, buffer, static_cast(base)); + return set(buffer); } template -ADVString& ADVString::set(double n, uint8_t decimals) -{ - char buffer[33]; - dtostrf(n, decimals + 2, decimals, buffer); - return set(buffer); +ADVString& ADVString::set(double n, uint8_t decimals) { + char buffer[33]; + dtostrf(n, decimals + 2, decimals, buffer); + return set(buffer); } template inline ADVString& ADVString::reset() { string_[0] = 0; return *this; } template -ADVString& ADVString::format(const char* fmt, ...) -{ - va_list args; - va_start(args, fmt); - set(fmt, args); - va_end(args); - return *this; +ADVString& ADVString::format(const char* fmt, ...) { + va_list args; + va_start(args, fmt); + set(fmt, args); + va_end(args); + return *this; } template -ADVString& ADVString::format(const FlashChar* fmt, ...) -{ - va_list args; - va_start(args, fmt); - set(fmt, args); - va_end(args); - return *this; +ADVString& ADVString::format(const FlashChar* fmt, ...) { + va_list args; + va_start(args, fmt); + set(fmt, args); + va_end(args); + return *this; } template inline void ADVString::operator+=(const char* s) { append(s); } @@ -237,74 +222,66 @@ template inline void ADVString::operator+=(const FlashChar* s) { ap template inline void ADVString::operator+=(char c) { append(c); } template -ADVString& ADVString::append(const char* s) -{ - strlcat(string_.data(), s, L + 1); - return *this; +ADVString& ADVString::append(const char* s) { + strlcat(string_.data(), s, L + 1); + return *this; } template -ADVString& ADVString::append(char c) -{ - auto l = length(); - if(l >= L) - return *this; - - string_[l] = c; - string_[l + 1] = 0; +ADVString& ADVString::append(char c) { + auto l = length(); + if(l >= L) return *this; + + string_[l] = c; + string_[l + 1] = 0; + return *this; } template -ADVString& ADVString::append(const FlashChar* s) -{ - strlcat_P(string_.data(), reinterpret_cast(s), L + 1); - return *this; +ADVString& ADVString::append(const FlashChar* s) { + strlcat_P(string_.data(), reinterpret_cast(s), L + 1); + return *this; } template -ADVString& ADVString::append(int16_t n, Base base) -{ - char buffer[2 + 8 * sizeof(int16_t)]; - itoa(n, buffer, static_cast(base)); - append(buffer); - return *this; +ADVString& ADVString::append(int16_t n, Base base) { + char buffer[2 + 8 * sizeof(int16_t)]; + itoa(n, buffer, static_cast(base)); + append(buffer); + return *this; } template -ADVString& ADVString::append(int32_t n, Base base) -{ - char buffer[2 + 8 * sizeof(int32_t)]; - ltoa(n, buffer, static_cast(base)); - append(buffer); - return *this; +ADVString& ADVString::append(int32_t n, Base base) { + char buffer[2 + 8 * sizeof(int32_t)]; + ltoa(n, buffer, static_cast(base)); + append(buffer); + return *this; } template -ADVString& ADVString::append(uint16_t n, Base base) -{ - char buffer[1 + 8 * sizeof(uint16_t)]; - utoa(n, buffer, static_cast(base)); - append(buffer); - return *this; +ADVString& ADVString::append(uint16_t n, Base base) { + char buffer[1 + 8 * sizeof(uint16_t)]; + utoa(n, buffer, static_cast(base)); + append(buffer); + return *this; } template -ADVString& ADVString::append(uint32_t n, Base base) -{ - char buffer[1 + 8 * sizeof(uint16_t)]; - ultoa(n, buffer, static_cast(base)); - append(buffer); - return *this; +ADVString& ADVString::append(uint32_t n, Base base) { + char buffer[1 + 8 * sizeof(uint16_t)]; + ultoa(n, buffer, static_cast(base)); + append(buffer); + return *this; } template -ADVString& ADVString::append(double n, uint8_t decimals) -{ - char buffer[33]; - dtostrf(n, decimals + 2, decimals, buffer); - append(buffer); - return *this; +ADVString& ADVString::append(double n, uint8_t decimals) { + char buffer[33]; + dtostrf(n, decimals + 2, decimals, buffer); + append(buffer); + return *this; } template inline size_t ADVString::length() const { return strlen(string_.data()); } diff --git a/Marlin/src/advi3pp/core/task.cpp b/Marlin/src/advi3pp/core/task.cpp index a8c7b3e9b6..c26626f315 100644 --- a/Marlin/src/advi3pp/core/task.cpp +++ b/Marlin/src/advi3pp/core/task.cpp @@ -21,11 +21,10 @@ #include "../parameters.h" #include #include "task.h" +#include "logging.h" namespace ADVi3pp { -Task task; - Task::Task(const Callback& callback, unsigned int delay, Activation activation) : delay_{delay}, activation_{activation}, callback_{callback} { set_next_execute_time(); @@ -33,43 +32,44 @@ Task::Task(const Callback& callback, unsigned int delay, Activation activation) //! Set the next task and its delay //! @param task The next background task -//! @param delta Duration to be added to the current time to execute the background task -void Task::set(const Callback& callback, unsigned int delay, Activation activation) -{ - delay_ = delay; - activation_ = activation; - callback_ = callback; - set_next_execute_time(); +//! @param delay Duration to be added to the current time to execute the background task +//! @param activation The kind of activation for the task (one time, multiple times) +void Task::set(const Callback& callback, unsigned int delay, Activation activation) { + if(callback_) + Log::error() << F("Task::set but there is already an active task") << Log::endl(); + + delay_ = delay; + activation_ = activation; + callback_ = callback; + set_next_execute_time(); } //! Reset the background task -void Task::clear() -{ - callback_ = nullptr; +void Task::clear() { + callback_ = nullptr; } //! If there is an operating running, execute its next step -bool Task::execute(bool force_execute) -{ - if(!callback_) - return false; +bool Task::execute(bool force_execute) { + if(!callback_) + return false; - if(!force_execute && !ELAPSED(millis(), next_execute_time_)) - return false; + if(!force_execute && !ELAPSED(millis(), next_execute_time_)) + return false; - // Clear before calling to avoid reentrancy issues - Callback callback{callback_}; - if(activation_ == Activation::ONE_TIME) - callback_ = nullptr; - else - set_next_execute_time(); + // Clear before calling to avoid reentrancy issues + Callback callback{callback_}; + if(activation_ == Activation::ONE_TIME) + callback_ = nullptr; + else + set_next_execute_time(); - callback(); - return true; + callback(); + return true; } void Task::set_next_execute_time() { - next_execute_time_ = millis() + delay_; + next_execute_time_ = millis() + delay_; } } diff --git a/Marlin/src/advi3pp/core/task.h b/Marlin/src/advi3pp/core/task.h index bc17970b43..d687e76443 100644 --- a/Marlin/src/advi3pp/core/task.h +++ b/Marlin/src/advi3pp/core/task.h @@ -28,26 +28,25 @@ namespace ADVi3pp { using Callback = adv::Callback; //! Task -struct Task -{ - enum class Activation { MULIPLE, ONE_TIME }; - static const unsigned DEFAULT_DELAY = 100; // ms +struct Task { + enum class Activation { MULIPLE, ONE_TIME }; + static const unsigned DEFAULT_DELAY = 100; // ms - Task() = default; - explicit Task(const Callback& callback, unsigned int delay = DEFAULT_DELAY, Activation activation = Activation::MULIPLE); + Task() = default; + explicit Task(const Callback& callback, unsigned int delay = DEFAULT_DELAY, Activation activation = Activation::MULIPLE); - void set(const Callback& callback, unsigned int delay = DEFAULT_DELAY, Activation activation = Activation::MULIPLE); - void clear(); - bool execute(bool force_excute = false); + void set(const Callback& callback, unsigned int delay = DEFAULT_DELAY, Activation activation = Activation::MULIPLE); + void clear(); + bool execute(bool force_execute = false); private: - void set_next_execute_time(); + void set_next_execute_time(); private: - unsigned int delay_; - Activation activation_; - millis_t next_execute_time_ = 0; - Callback callback_; + unsigned int delay_ = DEFAULT_DELAY; + Activation activation_ = Activation::MULIPLE; + millis_t next_execute_time_ = 0; + Callback callback_; }; extern Task background_task; diff --git a/Marlin/src/advi3pp/screens/core/wait.cpp b/Marlin/src/advi3pp/core/wait.cpp similarity index 53% rename from Marlin/src/advi3pp/screens/core/wait.cpp rename to Marlin/src/advi3pp/core/wait.cpp index 5864fd7490..022b0621ac 100644 --- a/Marlin/src/advi3pp/screens/core/wait.cpp +++ b/Marlin/src/advi3pp/core/wait.cpp @@ -18,8 +18,9 @@ * */ -#include "../../parameters.h" -#include "../../core/status.h" +#include "../parameters.h" +#include "../core/core.h" +#include "../core/status.h" #include "wait.h" namespace ADVi3pp { @@ -27,38 +28,29 @@ namespace ADVi3pp { Wait wait; -Page Wait::do_prepare_page() -{ - return Page::Waiting; -} - //! Show a simple wait page with a message -void Wait::wait_() -{ - back_ = nullptr; - continue_ = nullptr; - pages.show(Page::Waiting); +void Wait::wait_() { + back_ = nullptr; + continue_ = nullptr; + pages.show(Page::Waiting, ACTION); } //! Show a simple wait page with a message -void Wait::wait() -{ - status.set(F("Please wait...")); - wait_(); +void Wait::wait() { + status.set(F("Please wait...")); + wait_(); } //! Show a simple wait page with a message //! @param message The message to display -void Wait::wait(const FlashChar* message) -{ - status.set(message); - wait_(); +void Wait::wait(const FlashChar* message) { + status.set(message); + wait_(); } //! Show a simple wait page with a message //! @param message The message to display -void Wait::wait(const char* message) -{ +void Wait::wait(const char* message) { status.set(message); wait_(); } @@ -66,33 +58,30 @@ void Wait::wait(const char* message) //! Show a simple wait page with a message //! @param message The message to display //! @param back Callback to be called when the back button is pressed -void Wait::wait_back(const FlashChar* message, const WaitCallback& back) -{ - status.set(message); - back_ = back; - continue_ = nullptr; - pages.show(Page::WaitBack); +void Wait::wait_back(const FlashChar* message, const WaitCallback& back) { + status.set(message); + back_ = back; + continue_ = nullptr; + pages.show(Page::WaitBack, ACTION); } //! Ensure a print is not running and if so, display a message -void Wait::wait_back(const FlashChar* message) -{ - status.set(message); - back_ = WaitCallback{this, &Wait::on_back}; - continue_ = nullptr; - pages.show(Page::WaitBack); +void Wait::wait_back(const FlashChar* message) { + status.set(message); + back_ = WaitCallback{this, &Wait::back}; + continue_ = nullptr; + pages.show(Page::WaitBack, ACTION); } //! Show a simple wait page with a message //! @param message The message to display //! @param back Callback to be called when the back button is pressed //! @param cont Callback to be called when the continue button is pressed -void Wait::wait_back_continue(const FlashChar* message, const WaitCallback& back, const WaitCallback& cont) -{ - status.set(message); - back_ = back; - continue_ = cont; - pages.show(Page::WaitBackContinue); +void Wait::wait_back_continue(const FlashChar* message, const WaitCallback& back, const WaitCallback& cont) { + status.set(message); + back_ = back; + continue_ = cont; + pages.show(Page::WaitBackContinue, ACTION); } void Wait::wait_user(const char* message) { @@ -100,68 +89,71 @@ void Wait::wait_user(const char* message) { status.set(message); if(ExtUI::awaitingUserConfirm()) { - continue_ = WaitCallback{this, &Wait::on_continue}; - pages.show(Page::WaitContinue); + continue_ = WaitCallback{this, &Wait::cont}; + pages.show(Page::WaitContinue, ACTION); } else { continue_ = nullptr; - pages.show(Page::Waiting); + pages.show(Page::Waiting, ACTION); } } -void Wait::set_status(const char* message) { - if(pages.is_current_page_temporary()) - pages.show_back_page(); - status.set(message); +void Wait::home_and_wait(const Callback &f, const FlashChar* cmd, const FlashChar* msg) { + wait(msg == nullptr ? F("Homing...") : msg); + core.inject_commands(cmd == nullptr ? F("G28 O") : cmd); // Homing, if needed + background_task.set(f, 200); } -//! Default action when the continue button is pressed (inform Marlin) -bool Wait::on_continue() -{ - ExtUI::setUserConfirmed(); - wait(); +bool Wait::check_homed() { + if(core.is_busy() || !ExtUI::isMachineHomed()) return false; + + background_task.clear(); + pages.clear_temporaries(); + return true; +} + +//! Default action when the continue button is pressed (inform Marlin) +bool Wait::cont() { + ExtUI::setUserConfirmed(); + wait(); + return false; } //! Action when the back button is pressed -bool Wait::on_back() -{ - pages.show_back_page(); - return false; +bool Wait::back() { + pages.show_back_page(); + return false; } //! Handles the Back command -void Wait::do_back_command() -{ - bool continue_processing = true; - - if(!back_) - Log::error() << F("No Back action defined") << Log::endl(); - else - { - continue_processing = back_(); - back_ = nullptr; - } - - if(continue_processing) - Parent::do_back_command(); +void Wait::on_back_command() { + bool continue_processing = true; + + if(!back_) + Log::error() << F("No Back action defined") << Log::endl(); + else { + continue_processing = back_(); + back_ = nullptr; + } + + if(continue_processing) + Parent::on_back_command(); } //! Handles the Save (Continue) command -void Wait::do_save_command() -{ - bool continue_processing = true; - - if(!continue_) - Log::error() << F("No Continue action defined") << Log::endl(); - else - { - continue_processing = continue_(); - continue_ = nullptr; - } - - if(continue_processing) - pages.show_forward_page(); +void Wait::on_save_command() { + bool continue_processing = true; + + if(!continue_) + Log::error() << F("No Continue action defined") << Log::endl(); + else { + continue_processing = continue_(); + continue_ = nullptr; + } + + if(continue_processing) + pages.show_forward_page(); } } diff --git a/Marlin/src/advi3pp/screens/core/wait.h b/Marlin/src/advi3pp/core/wait.h similarity index 54% rename from Marlin/src/advi3pp/screens/core/wait.h rename to Marlin/src/advi3pp/core/wait.h index 3cc2f6395f..636c89b85c 100644 --- a/Marlin/src/advi3pp/screens/core/wait.h +++ b/Marlin/src/advi3pp/core/wait.h @@ -20,10 +20,11 @@ #pragma once -#include "../../core/task.h" -#include "../../core/string.h" -#include "../../core/status.h" -#include "../../core/dgus.h" +#include "../core/task.h" +#include "../core/string.h" +#include "../core/core.h" +#include "../core/status.h" +#include "../core/dgus.h" #include "../core/screen.h" namespace ADVi3pp { @@ -31,29 +32,34 @@ namespace ADVi3pp { using WaitCallback = adv::Callback; //! Display wait page and messages -struct Wait: Screen -{ - void wait(); - void wait(const FlashChar* message); - void wait(const char* message); - void wait_back(const FlashChar* message, const WaitCallback& back); - void wait_back(const FlashChar* message); - void wait_back_continue(const FlashChar* message, const WaitCallback& back, const WaitCallback& cont); - void wait_user(const char* message); - void set_status(const char* message); +struct Wait: Screen { + static constexpr Page PAGE = Page::Waiting; + static constexpr Action ACTION = Action::Wait; + + void wait(); + void wait(const FlashChar* message); + void wait(const char* message); + void wait_back(const FlashChar* message, const WaitCallback& back); + void wait_back(const FlashChar* message); + void wait_back_continue(const FlashChar* message, const WaitCallback& back, const WaitCallback& cont); + void wait_user(const char* message); + + void home_and_wait(const Callback &f, const FlashChar* cmd = nullptr, const FlashChar* msg = nullptr); + bool check_homed(); private: - Page do_prepare_page(); - void do_save_command(); - void do_back_command(); - bool on_continue(); - bool on_back(); - void wait_(); + void on_save_command(); + void on_back_command(); - WaitCallback back_; - WaitCallback continue_; + bool cont(); + bool back(); + void wait_(); + +private: + WaitCallback back_; + WaitCallback continue_; - friend Parent; + friend Parent; }; extern Wait wait; diff --git a/Marlin/src/advi3pp/marlin/extui.cpp b/Marlin/src/advi3pp/marlin/extui.cpp index 29632ff608..65705c1ed0 100755 --- a/Marlin/src/advi3pp/marlin/extui.cpp +++ b/Marlin/src/advi3pp/marlin/extui.cpp @@ -23,8 +23,7 @@ #include "../core/core.h" #include "../core/buzzer.h" #include "../core/status.h" -#include "../core/settings.h" -#include "../screens/core/wait.h" +#include "../core/wait.h" #include "../screens/leveling/automatic.h" #include "../screens/tuning/pid_tuning.h" @@ -37,26 +36,23 @@ void onStartup() { core.startup(); } -void onIdle() -{ +void onIdle() { core.idle(); } -// There is no way to detect media changes, so this part is not implemented void onMediaInserted() { - Log::log() << F("ExtUI::onMediaInserted") << Log::endl(); + core.media_inserted(); } void onMediaError() { - Log::log() << F("ExtUI::onMediaError") << Log::endl(); + core.media_error(); } void onMediaRemoved() { - Log::log() << F("ExtUI::onMediaRemoved") << Log::endl(); + core.media_removed(); } void onMediaOpenError(const char* filename) { - Log::log() << F("ExtUI::onMediaOpenError ") << filename << Log::endl(); status.set(F("Error opening file")); } @@ -71,7 +67,7 @@ void onPrinterKilled(float temp, FSTR_P const error, FSTR_P const component) { } void onPrintTimerStarted() { - Log::log() << F("ExtUI::onPrintTimerStarted") << Log::endl(); + pages.go_to_print(); } void onPrintTimerPaused() { @@ -98,7 +94,10 @@ void onUserConfirmRequired(const char * const msg) { void onStatusChanged(const char * const msg) { Log::log() << F("ExtUI::onStatusChanged") << msg << Log::endl(); - wait.set_status(msg); + if(msg == NULL || *msg == 0) + status.reset_and_clear(); + else + status.set(msg); } void onHomingStart() { @@ -168,11 +167,15 @@ void onSettingsValidated(bool success) { } void onLevelingStart() { - Log::log() << F("ExtUI::onLevelingStart") << Log::endl(); + automatic_leveling.on_start(); +} + +void onLevelingProgress(const int8_t index, const int8_t xpos, const int8_t ypos) { + automatic_leveling.on_progress(index, xpos, ypos); } -void onLevelingDone() { - Log::log() << F("ExtUI::onLevelingDone") << Log::endl(); +void onLevelingDone(bool success) { + automatic_leveling.on_done(success); } void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) { @@ -185,14 +188,6 @@ void onMeshUpdate(const int8_t xpos, const int8_t ypos, probe_state_t state) { Log::log() << F("ExtUI::onMeshUpdate") << Log::endl(); } -void onAutomaticLevelingFinished(bool success) { - Log::log() << F("ExtUI::onAutomaticLevelingFinished") << Log::endl(); - -#if HAS_LEVELING - automatic_leveling.leveling_finished(success); -#endif -} - #if ENABLED(POWER_LOSS_RECOVERY) void onPowerLossResume() { diff --git a/Marlin/src/advi3pp/marlin/marlin_ui.cpp b/Marlin/src/advi3pp/marlin/marlin_ui.cpp index 3bfadae9f5..1656e8e199 100755 --- a/Marlin/src/advi3pp/marlin/marlin_ui.cpp +++ b/Marlin/src/advi3pp/marlin/marlin_ui.cpp @@ -36,13 +36,13 @@ void MarlinUI::buzz_m300(const long duration, const uint16_t) { } void MarlinUI::sleep_on() { - dimming.sleep_on(); + dimming.sleep_on(); } void MarlinUI::sleep_off() { - dimming.sleep_off(); + dimming.sleep_off(); } void MarlinUI::_set_brightness() { - dimming.send_brightness_to_lcd(); + dimming.send_brightness_to_lcd(); } diff --git a/Marlin/src/advi3pp/screens/controls/controls.cpp b/Marlin/src/advi3pp/screens/controls/controls.cpp index 0b11a82aeb..f4fb3f20a8 100644 --- a/Marlin/src/advi3pp/screens/controls/controls.cpp +++ b/Marlin/src/advi3pp/screens/controls/controls.cpp @@ -22,11 +22,11 @@ #include "../../../lcd/extui/ui_api.h" #include "controls.h" #include "../../core/dgus.h" -#include "../../core/status.h" -#include "../core/wait.h" +#include "../../core/wait.h" #include "../print/temperatures.h" #include "../print/sd_card.h" -#include "../settings/print_settings.h" +#include "../print/print_settings.h" +#include "../print/baby_steps.h" namespace ADVi3pp { @@ -35,87 +35,80 @@ Controls controls; //! Dispatch a key value to the right handler //! @param key_value The sub-action to handle //! @return True if the action was handled -bool Controls::do_dispatch(KeyValue key_value) -{ - // Do not call Parent::do_dispatch - - switch(key_value) - { - case KeyValue::Temps: show_temps(); break; - case KeyValue::Print: show_print(); break; - case KeyValue::Controls: pages.show(Page::Controls); break; - case KeyValue::Tuning: pages.show(Page::Tuning); break; - case KeyValue::Settings: pages.show(Page::Settings); break; - case KeyValue::Infos: pages.show(Page::Infos); break; - case KeyValue::Motors: pages.show(Page::MotorsSettings); break; - case KeyValue::Leveling: pages.show(Page::Leveling); break; - case KeyValue::PrintSettings: show_print_settings(); break; - case KeyValue::Back: back_command(); break; - default: return false; - } - - return true; +bool Controls::on_dispatch(KeyValue key_value) { + // Do not call Parent::on_dispatch + // No need to implement save or abort + + switch(key_value) { + case KeyValue::Temps: show_temps(); break; + case KeyValue::Print: show_print(); break; + case KeyValue::Controls: pages.show(Page::Controls, Action::None); break; + case KeyValue::Tuning: pages.show(Page::Tuning, Action::None); break; + case KeyValue::Settings: pages.show(Page::Settings, Action::None); break; + case KeyValue::Infos: pages.show(Page::Infos, Action::None); break; + case KeyValue::Motors: pages.show(Page::MotorsSettings, Action::None); break; + case KeyValue::Leveling: pages.show(Page::Leveling, Action::None); break; + case KeyValue::PrintSettings: show_print_settings(); break; + case KeyValue::BabySteps: show_baby_steps(); break; + case KeyValue::Back: on_back_command(); break; + default: return false; + } + + return true; } //! Show one of the temperature graph screens depending of the context: either the SD printing screen, //! the printing screen or the temperature screen. -void Controls::show_temps() -{ - if(!ExtUI::isPrinting() && !ExtUI::isPrintingPaused()) - { - temperatures.show(); - return; - } - - // If there is a print running (or paused), display the print screen. - pages.show(Page::Print); +void Controls::show_temps() { + if(!ExtUI::isPrinting() && !ExtUI::isPrintingPaused()) { + temperatures.show(); + return; + } + + // If there is a print running (or paused), display the print screen. + pages.show(Page::Print, Action::Print); } //! Show Print Settings page (only if a print is running or paused) -void Controls::show_print_settings() -{ - if(!ExtUI::isPrinting() && !ExtUI::isPrintingPaused()) - { - temperatures.show(); - return; - } - - // If there is a print running (or paused), display the print settings. - print_settings.show(); +void Controls::show_print_settings() { + if(!ExtUI::isPrinting() && !ExtUI::isPrintingPaused()) { + temperatures.show(); + return; + } + + // If there is a print running (or paused), display the print settings. + print_settings.show(); +} + +//! Show Print Settings page (only if a print is running or paused) +void Controls::show_baby_steps() { + if(!ExtUI::isPrinting() && !ExtUI::isPrintingPaused()) { + temperatures.show(); + return; + } + + // If there is a print running (or paused), display the print settings. + baby_steps.show(); } //! Show one of the Printing screens depending of the context: //! - If a print is running, display the Print screen //! - Otherwise, try to access the SD card. Depending of the result, display the SD card Page or the Temperatures page -void Controls::show_print() -{ - // If there is a print running (or paused), display the SD or USB print screen - if(ExtUI::isPrinting() || ExtUI::isPrintingPaused()) - { - pages.show(Page::Print); - return; - } - - wait.wait(F("Accessing the SD card...")); - background_task.set(Callback {this, &Controls::show_sd}); +void Controls::show_print() { + // If there is a print running (or paused), display the SD or USB print screen + if(ExtUI::isPrinting() || ExtUI::isPrintingPaused()) { + pages.show(Page::Print, Action::Print); + return; + } + + wait.wait(F("Accessing the SD card...")); + background_task.set(Callback {this, &Controls::show_sd}); } //! Show the SD card page (if a SD card is inserted) -void Controls::show_sd() -{ - background_task.clear(); - - ExtUI::mountMedia(); - ExtUI::FileList{}.refresh(); - status.reset(); - if(!ExtUI::isMediaInserted()) - { - status.set(F("No SD card detected.")); - pages.show_back_page(); - return; - } - - sd_card.show(); +void Controls::show_sd() { + background_task.clear(); + sd_card.show(); } } diff --git a/Marlin/src/advi3pp/screens/controls/controls.h b/Marlin/src/advi3pp/screens/controls/controls.h index 77916fd156..5175684b83 100644 --- a/Marlin/src/advi3pp/screens/controls/controls.h +++ b/Marlin/src/advi3pp/screens/controls/controls.h @@ -20,25 +20,27 @@ #pragma once -#include "../core/screen.h" +#include "../../core/screen.h" namespace ADVi3pp { //! Controls Page -struct Controls: Screen -{ -private: - bool do_dispatch(KeyValue key_value); - Page do_prepare_page(); +struct Controls: Screen { + static constexpr Page PAGE = Page::Controls; + static constexpr Action ACTION = Action::Controls; private: - void show_temps(); - void show_print_settings(); - void show_print(); - void show_sd(); + bool on_dispatch(KeyValue key_value); + void on_enter(); + + void show_temps(); + void show_print_settings(); + void show_baby_steps(); + void show_print(); + void show_sd(); private: - friend Parent; + friend Parent; }; extern Controls controls; diff --git a/Marlin/src/advi3pp/screens/controls/load_unload.cpp b/Marlin/src/advi3pp/screens/controls/load_unload.cpp index aed023dc32..9b8414acfb 100644 --- a/Marlin/src/advi3pp/screens/controls/load_unload.cpp +++ b/Marlin/src/advi3pp/screens/controls/load_unload.cpp @@ -20,7 +20,7 @@ #include "../../parameters.h" #include "load_unload.h" -#include "../core/wait.h" +#include "../../core/wait.h" #include "../../core/core.h" #include "../../core/settings.h" #include "../../core/dgus.h" @@ -33,68 +33,57 @@ LoadUnload load_unload; //! Handle Load & Unload actions. //! @param key_value The sub-action to handle //! @return True if the action was handled -bool LoadUnload::do_dispatch(KeyValue key_value) -{ - if(Parent::do_dispatch(key_value)) - return true; - - switch(key_value) - { - case KeyValue::Load: load_command(); break; - case KeyValue::Unload: unload_command(); break; - default: return false; - } - +bool LoadUnload::on_dispatch(KeyValue key_value) { + if(Parent::on_dispatch(key_value)) return true; + + switch(key_value){ + case KeyValue::Load: load_command(); break; + case KeyValue::Unload: unload_command(); break; + default: return false; + } + + return true; } -void LoadUnload::send_data() -{ - WriteRamRequest{Variable::Value0}.write_word(settings.get_last_used_temperature(TemperatureKind::Hotend)); +void LoadUnload::send_data() { + WriteRamRequest{Variable::Value0}.write_word(settings.get_last_used_temperature(TemperatureKind::Hotend)); } //! Prepare the page before being displayed and return the right Page value //! @return The index of the page to display -Page LoadUnload::do_prepare_page() -{ - if(!core.ensure_not_printing()) - return Page::None; - send_data(); - previous_z_ = Core::ensure_z_enough_room();; - return Page::LoadUnload; +void LoadUnload::on_enter() { + send_data(); + previous_z_ = Core::ensure_z_enough_room();; } -void LoadUnload::do_back_command() { +void LoadUnload::on_back_command() { ExtUI::setAxisPosition_mm(previous_z_, ExtUI::Z, 20); - Parent::do_back_command(); + Parent::on_back_command(); } //! Prepare Load or Unload step #1: set the target temperature, setup the next step and display a wait message //! @param background Background task to detect if it is time for step #2 -void LoadUnload::prepare() -{ - ReadRam frame{Variable::Value0}; - if(!frame.send_receive(1)) - { - Log::error() << F("Receiving Frame (Target Temperature)") << Log::endl(); - return; - } - - ExtUI::setTargetTemp_celsius(frame.read_word(), ExtUI::E0); +void LoadUnload::prepare() { + ReadRam frame{Variable::Value0}; + if(!frame.send_receive(1)) { + Log::error() << F("Receiving Frame (Target Temperature)") << Log::endl(); + return; + } + + ExtUI::setTargetTemp_celsius(frame.read_word(), ExtUI::E0); } //! Start Load action. -void LoadUnload::load_command() -{ - prepare(); - core.inject_commands(F("M701 Z0\nM104 S0")); // Load filament, set hotend temp +void LoadUnload::load_command() { + prepare(); + core.inject_commands(F("M701 Z0\nM104 S0")); // Load filament, set hotend temp } //! Start Unload action. -void LoadUnload::unload_command() -{ - prepare(); - core.inject_commands(F("M702 Z0\nM104 S0")); // Unload filament, set hotend temp +void LoadUnload::unload_command() { + prepare(); + core.inject_commands(F("M702 Z0\nM104 S0")); // Unload filament, set hotend temp } diff --git a/Marlin/src/advi3pp/screens/controls/load_unload.h b/Marlin/src/advi3pp/screens/controls/load_unload.h index 86caac2324..3a61870ad6 100644 --- a/Marlin/src/advi3pp/screens/controls/load_unload.h +++ b/Marlin/src/advi3pp/screens/controls/load_unload.h @@ -21,23 +21,26 @@ #pragma once #include "../../core/task.h" -#include "../core/screen.h" +#include "../../core/screen.h" namespace ADVi3pp { //! Load and Unload Page -struct LoadUnload: Screen -{ +struct LoadUnload: Screen { + static constexpr Page PAGE = Page::LoadUnload; + static constexpr Action ACTION = Action::LoadUnload; + private: - bool do_dispatch(KeyValue key_value); - Page do_prepare_page(); - void do_back_command(); - void prepare(); - void load_command(); - void unload_command(); - void send_data(); - - friend Parent; + bool on_dispatch(KeyValue key_value); + void on_enter(); + void on_back_command(); + + void prepare(); + void load_command(); + void unload_command(); + void send_data(); + + friend Parent; private: float previous_z_ = 0; diff --git a/Marlin/src/advi3pp/screens/controls/move.cpp b/Marlin/src/advi3pp/screens/controls/move.cpp index 8050f67d6e..e3f1038d48 100644 --- a/Marlin/src/advi3pp/screens/controls/move.cpp +++ b/Marlin/src/advi3pp/screens/controls/move.cpp @@ -21,6 +21,7 @@ #include "../../parameters.h" #include "move.h" #include "../../core/core.h" +#include "../../core/wait.h" namespace ADVi3pp { @@ -93,33 +94,27 @@ void Move::set_position() const { //! Execute a move command //! @param key_value The sub-action to handle //! @return True if the action was handled -bool Move::do_dispatch(KeyValue key_value) -{ - if(Parent::do_dispatch(key_value)) - return true; - - switch(key_value) - { - case KeyValue::MoveXHome: x_home_command(); break; - case KeyValue::MoveYHome: y_home_command(); break; - case KeyValue::MoveZHome: z_home_command(); break; - case KeyValue::MoveAllHome: all_home_command(); break; - case KeyValue::DisableMotors: disable_motors_command(); break; - default: Log::log() << "Invalid KeyValue" << Log::endl(); return false; - } - +bool Move::on_dispatch(KeyValue key_value) { + if(Parent::on_dispatch(key_value)) return true; + + switch(key_value) { + case KeyValue::MoveXHome: x_home_command(); break; + case KeyValue::MoveYHome: y_home_command(); break; + case KeyValue::MoveZHome: z_home_command(); break; + case KeyValue::MoveAllHome: all_home_command(); break; + case KeyValue::DisableMotors: disable_motors_command(); break; + default: Log::log() << "Invalid KeyValue" << Log::endl(); return false; + } + + return true; } //! Prepare the page before being displayed and return the right Page value //! @return The index of the page to display -Page Move::do_prepare_page() -{ - if(!core.ensure_not_printing()) - return Page::None; - ExtUI::finishAndDisableHeaters(); // To circumvent homing problems - direction_ = Direction::None; - return Page::Move; +void Move::on_enter() { + ExtUI::finishAndDisableHeaters(); // To circumvent homing problems + direction_ = Direction::None; } void Move::move(Direction direction) { @@ -184,6 +179,8 @@ void Move::e_minus_command() { //! Disable the motors. void Move::disable_motors_command() { + // If printing, do nothing + if(ExtUI::isPrinting()) return; stop_move(); core.inject_commands(F("M84")); // Disable steppers ExtUI::setAllAxisUnhomed(); @@ -192,26 +189,26 @@ void Move::disable_motors_command() { //! Go to home on the X axis. void Move::x_home_command() { - stop_move(); - core.inject_commands(F("G28 X F6000")); + wait.home_and_wait(Callback{this, &Move::home_task}, F("G28 X")); } //! Go to home on the Y axis. void Move::y_home_command() { - stop_move(); - core.inject_commands(F("G28 Y F6000")); + wait.home_and_wait(Callback{this, &Move::home_task}, F("G28 Y")); } //! Go to home on the Z axis. void Move::z_home_command() { - stop_move(); - core.inject_commands(F("G28 Z F1200")); + wait.home_and_wait(Callback{this, &Move::home_task}, F("G28 Z")); } //! Go to home on all axis. void Move::all_home_command() { - stop_move(); - core.inject_commands(F("G28 F6000")); + wait.home_and_wait(Callback{this, &Move::home_task}, F("G28")); +} + +void Move::home_task() { + wait.check_homed(); } } diff --git a/Marlin/src/advi3pp/screens/controls/move.h b/Marlin/src/advi3pp/screens/controls/move.h index 467470ea98..2979c7ea00 100644 --- a/Marlin/src/advi3pp/screens/controls/move.h +++ b/Marlin/src/advi3pp/screens/controls/move.h @@ -20,13 +20,14 @@ #pragma once -#include "../core/screen.h" +#include "../../core/screen.h" namespace ADVi3pp { //! Move Page struct Move: Screen { - friend Parent; + static constexpr Page PAGE = Page::Move; + static constexpr Action ACTION = Action::Move; enum class Direction: uint8_t { None, @@ -56,8 +57,9 @@ struct Move: Screen { void disable_motors_command(); private: - bool do_dispatch(KeyValue key_value); - Page do_prepare_page(); + bool on_dispatch(KeyValue key_value); + void on_enter(); + float get_target() const; feedRate_t get_feedrate() const; float get_position() const; @@ -65,9 +67,12 @@ struct Move: Screen { void move(Direction direction); void stop_move(); void task(); + void home_task(); private: Direction direction_ = Direction::None; + + friend Parent; }; extern Move move; diff --git a/Marlin/src/advi3pp/screens/controls/preheat.cpp b/Marlin/src/advi3pp/screens/controls/preheat.cpp index 1ee8176834..1b8960e83c 100755 --- a/Marlin/src/advi3pp/screens/controls/preheat.cpp +++ b/Marlin/src/advi3pp/screens/controls/preheat.cpp @@ -32,106 +32,93 @@ Preheat preheat; //! Handle Preheat actions. //! @param key_value Sub-action to handle //! @return True if the action was handled -bool Preheat::do_dispatch(KeyValue key_value) -{ - if(Parent::do_dispatch(key_value)) - return true; - - switch(key_value) - { - case KeyValue::PresetPrevious: previous_command(); break; - case KeyValue::PresetNext: next_command(); break; - case KeyValue::Cooldown: cooldown_command(); break; - default: return false; - } - +bool Preheat::on_dispatch(KeyValue key_value) { + if(Parent::on_dispatch(key_value)) return true; + + switch(key_value) { + case KeyValue::PresetPrevious: previous_command(); break; + case KeyValue::PresetNext: next_command(); break; + case KeyValue::Cooldown: cooldown_command(); break; + default: return false; + } + + return true; } //! Send the presets t the LCD Panel -void Preheat::send_presets() -{ - WriteRamRequest{Variable::Value0}.write_words( - ExtUI::getMaterialPresetHotendTemp_celsius(index_), - ExtUI::getMaterialPresetBedTemp_celsius(index_), - ExtUI::getMaterialPresetFanSpeed_percent(index_) - ); - - ADVString<8> preset; - preset << index_ + 1 << F(" / ") << NB_PRESETS; - WriteRamRequest{Variable::ShortText0}.write_text(preset); +void Preheat::send_presets() { + WriteRamRequest{Variable::Value0}.write_words( + ExtUI::getMaterialPresetHotendTemp_celsius(index_), + ExtUI::getMaterialPresetBedTemp_celsius(index_), + ExtUI::getMaterialPresetFanSpeed_percent(index_) + ); + + ADVString<8> preset; + preset << index_ + 1 << F(" / ") << NB_PRESETS; + WriteRamRequest{Variable::ShortText0}.write_text(preset); } //! Retrieve presets values from the LCD Panel -void Preheat::retrieve_presets() -{ - ReadRam frame{Variable::Value0}; - if(!frame.send_receive(3)) - { - Log::error() << F("Error receiving presets") << Log::endl(); - return; - } - - uint16_t hotend = frame.read_word(); - uint16_t bed = frame.read_word(); - uint16_t fan = frame.read_word(); - - ExtUI::setMaterialPreset(index_, hotend, bed, fan); +void Preheat::retrieve_presets() { + ReadRam frame{Variable::Value0}; + if(!frame.send_receive(3)) { + Log::error() << F("Error receiving presets") << Log::endl(); + return; + } + + uint16_t hotend = frame.read_word(); + uint16_t bed = frame.read_word(); + uint16_t fan = frame.read_word(); + + ExtUI::setMaterialPreset(index_, hotend, bed, fan); } //! Prepare the page before being displayed and return the right Page value //! @return The index of the page to display -Page Preheat::do_prepare_page() -{ - if(!core.ensure_not_printing()) - return Page::None; - send_presets(); - return Page::Preheat; +void Preheat::on_enter() { + send_presets(); } //! Handle Previous command -void Preheat::previous_command() -{ - if(index_ <= 0) - return; - retrieve_presets(); - --index_; - send_presets(); +void Preheat::previous_command() { + if(index_ <= 0) + return; + retrieve_presets(); + --index_; + send_presets(); } //! Handle Next command -void Preheat::next_command() -{ - if(index_ >= NB_PRESETS - 1) - return; - retrieve_presets(); - ++index_; - send_presets(); +void Preheat::next_command() { + if(index_ >= NB_PRESETS - 1) + return; + retrieve_presets(); + ++index_; + send_presets(); } //! Handles the Save (Continue) command -void Preheat::do_save_command() -{ - retrieve_presets(); +void Preheat::on_save_command() { + retrieve_presets(); - ExtUI::setTargetTemp_celsius(ExtUI::getMaterialPresetHotendTemp_celsius(index_), ExtUI::E0); - ExtUI::setTargetTemp_celsius(ExtUI::getMaterialPresetBedTemp_celsius(index_), ExtUI::BED); - ExtUI::setTargetFan_percent(ExtUI::getMaterialPresetFanSpeed_percent(index_), ExtUI::FAN0); + ExtUI::setTargetTemp_celsius(ExtUI::getMaterialPresetHotendTemp_celsius(index_), ExtUI::E0); + ExtUI::setTargetTemp_celsius(ExtUI::getMaterialPresetBedTemp_celsius(index_), ExtUI::BED); + ExtUI::setTargetFan_percent(ExtUI::getMaterialPresetFanSpeed_percent(index_), ExtUI::FAN0); - settings.save(); - status.set(F("Preheat...")); - temperatures.show(); + settings.save(); + status.set(F("Preheat...")); + temperatures.show(); } //! Cooldown the bed and the nozzle, turn off the fan -void Preheat::cooldown_command() -{ - if(!core.ensure_not_printing()) - return; - - ExtUI::setTargetTemp_celsius(0, ExtUI::BED); - ExtUI::setTargetTemp_celsius(0, ExtUI::E0); - ExtUI::setTargetFan_percent(0, ExtUI::FAN0); +void Preheat::cooldown_command() { + // If printing, do nothing + if(ExtUI::isPrinting()) return; + ExtUI::setTargetTemp_celsius(0, ExtUI::BED); + ExtUI::setTargetTemp_celsius(0, ExtUI::E0); + ExtUI::setTargetFan_percent(0, ExtUI::FAN0); + status.set(F("Cool down...")); } } diff --git a/Marlin/src/advi3pp/screens/controls/preheat.h b/Marlin/src/advi3pp/screens/controls/preheat.h index 763bbda431..d1a7428840 100644 --- a/Marlin/src/advi3pp/screens/controls/preheat.h +++ b/Marlin/src/advi3pp/screens/controls/preheat.h @@ -20,30 +20,31 @@ #pragma once -#include "../core/screen.h" +#include "../../core/screen.h" namespace ADVi3pp { //! Preheat Page -struct Preheat: Screen -{ - static const size_t NB_PRESETS = 5; +struct Preheat: Screen { + static constexpr Page PAGE = Page::Preheat; + static constexpr Action ACTION = Action::Preheat; + static constexpr size_t NB_PRESETS = 5; private: - bool do_dispatch(KeyValue key_value); - Page do_prepare_page(); - void do_save_command(); + bool on_dispatch(KeyValue key_value); + void on_enter(); + void on_save_command(); - void send_presets(); - void retrieve_presets(); - void previous_command(); - void next_command(); - void cooldown_command(); + void send_presets(); + void retrieve_presets(); + void previous_command(); + void next_command(); + void cooldown_command(); private: - size_t index_ = 0; + size_t index_ = 0; - friend Parent; + friend Parent; }; extern Preheat preheat; diff --git a/Marlin/src/advi3pp/screens/core/screen.h b/Marlin/src/advi3pp/screens/core/screen.h deleted file mode 100644 index d00ed3524c..0000000000 --- a/Marlin/src/advi3pp/screens/core/screen.h +++ /dev/null @@ -1,120 +0,0 @@ -/** - * ADVi3++ Firmware For Wanhao Duplicator i3 Plus (based on Marlin) - * - * Copyright (C) 2017-2022 Sebastien Andrivet [https://github.com/andrivet/] - * - * This program 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. - * - * This program 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 this program. If not, see . - * - */ - -#pragma once - -#include "../../../lcd/extui/ui_api.h" -#include "../../lib/ADVstd/ADVcrtp.h" -#include "../../core/settings.h" -#include "../../core/enums.h" -#include "../../core/eeprom.h" -#include "../../core/pages.h" - -namespace ADVi3pp { - - -//! Handle inputs from the LCD Panel -template -struct Screen: adv::Crtp -{ -public: - void handle(KeyValue value); - void show(); - - bool dispatch(KeyValue value) { return this->self().do_dispatch(value); } - void show_command() { this->self().do_show_command(); } - void save_command() { this->self().do_save_command(); } - void back_command() { this->self().do_back_command(); } - Page prepare_page() { return this->self().do_prepare_page(); } - -protected: - Page do_prepare_page(); - bool do_dispatch(KeyValue value); - void do_show_command(); - void do_save_command(); - void do_back_command(); - void invalid(KeyValue value); -}; - -// -------------------------------------------------------------------- -// Screen implementation -// -------------------------------------------------------------------- - -template -Page Screen::do_prepare_page() -{ - return Page::None; -} - -template -void Screen::handle(KeyValue value) -{ - if(!dispatch(value)) - invalid(value); -} - -template -bool Screen::do_dispatch(KeyValue value) -{ - switch(value) - { - case KeyValue::Show: show_command(); break; - case KeyValue::Save: save_command(); break; - case KeyValue::Back: back_command(); break; - default: return false; - } - - return true; -} - -template -void Screen::invalid(KeyValue value) -{ - Log::error() << F("Invalid key value ") << static_cast(value) << Log::endl(); -} - -template -void Screen::show() -{ - Page page = prepare_page(); - if(page != Page::None) - pages.show(page); -} - -template -void Screen::do_show_command() -{ - show(); -} - -template -void Screen::do_save_command() -{ - settings.save(); - pages.show_forward_page(); -} - -template -void Screen::do_back_command() -{ - pages.show_back_page(); -} - -} diff --git a/Marlin/src/advi3pp/screens/info/copyrights.cpp b/Marlin/src/advi3pp/screens/info/copyrights.cpp index 0220da4785..447828b78a 100644 --- a/Marlin/src/advi3pp/screens/info/copyrights.cpp +++ b/Marlin/src/advi3pp/screens/info/copyrights.cpp @@ -25,11 +25,4 @@ namespace ADVi3pp { Copyrights copyrights; -//! Prepare the page before being displayed and return the right Page value -//! @return The index of the page to display -Page Copyrights::do_prepare_page() -{ - return Page::Copyrights; -} - } diff --git a/Marlin/src/advi3pp/screens/info/copyrights.h b/Marlin/src/advi3pp/screens/info/copyrights.h index 74b8930248..fe9b035c8b 100644 --- a/Marlin/src/advi3pp/screens/info/copyrights.h +++ b/Marlin/src/advi3pp/screens/info/copyrights.h @@ -20,17 +20,17 @@ #pragma once -#include "../core/screen.h" +#include "../../core/screen.h" namespace ADVi3pp { //! Copyrights Page -struct Copyrights: Screen -{ -private: - Page do_prepare_page(); +struct Copyrights: Screen { + static constexpr Page PAGE = Page::Copyrights; + static constexpr Action ACTION = Action::Copyrights; - friend Parent; +private: + friend Parent; }; extern Copyrights copyrights; diff --git a/Marlin/src/advi3pp/screens/info/killed.cpp b/Marlin/src/advi3pp/screens/info/killed.cpp index 3bbdf7669b..9e4a152175 100755 --- a/Marlin/src/advi3pp/screens/info/killed.cpp +++ b/Marlin/src/advi3pp/screens/info/killed.cpp @@ -26,13 +26,6 @@ namespace ADVi3pp { Killed killed_page; -//! Prepare the page before being displayed and return the right Page value -//! @return The index of the page to display -Page Killed::do_prepare_page() -{ - return Page::Killed; -} - void Killed::show(float temp, const FlashChar* component) { if(component != nullptr) { ADVString<48> message{component}; diff --git a/Marlin/src/advi3pp/screens/info/killed.h b/Marlin/src/advi3pp/screens/info/killed.h index 84e0d17ba5..272cb14e67 100644 --- a/Marlin/src/advi3pp/screens/info/killed.h +++ b/Marlin/src/advi3pp/screens/info/killed.h @@ -20,19 +20,19 @@ #pragma once -#include "../core/screen.h" +#include "../../core/screen.h" namespace ADVi3pp { //! Killed Page -struct Killed: Screen -{ +struct Killed: Screen { + static constexpr Page PAGE = Page::Killed; + static constexpr Action ACTION = Action::None; + void show(float temp, const FlashChar* component); private: - Page do_prepare_page(); - - friend Parent; + friend Parent; }; extern Killed killed_page; diff --git a/Marlin/src/advi3pp/screens/info/statistics.cpp b/Marlin/src/advi3pp/screens/info/statistics.cpp index 9dac0249f9..7909b5ad65 100755 --- a/Marlin/src/advi3pp/screens/info/statistics.cpp +++ b/Marlin/src/advi3pp/screens/info/statistics.cpp @@ -29,32 +29,29 @@ Statistics statistics; //! Prepare the page before being displayed and return the right Page value //! @return The index of the page to display -Page Statistics::do_prepare_page() -{ - send_stats(); - return Page::Statistics; +void Statistics::on_enter() { + send_stats(); } -void Statistics::send_stats() -{ - WriteRamRequest{Variable::Value0}.write_words( - ExtUI::getTotalPrints(), - ExtUI::getFinishedPrints(), - freeMemory() - ); +void Statistics::send_stats() { + WriteRamRequest{Variable::Value0}.write_words( + ExtUI::getTotalPrints(), + ExtUI::getFinishedPrints(), + freeMemory() + ); - // Minimize the RAM used so send each value separately. - char buffer[21]; - ADVString<16> value; + // Minimize the RAM used so send each value separately. + char buffer[21]; + ADVString<16> value; - value.set(ExtUI::getTotalPrintTime_str(buffer)); - WriteRamRequest{Variable::LongText0}.write_text(value); + value.set(ExtUI::getTotalPrintTime_str(buffer)); + WriteRamRequest{Variable::LongText0}.write_text(value); - value.set(ExtUI::getLongestPrint_str(buffer)); - WriteRamRequest{Variable::LongText1}.write_text(value); + value.set(ExtUI::getLongestPrint_str(buffer)); + WriteRamRequest{Variable::LongText1}.write_text(value); - value.set(ExtUI::getFilamentUsed_str(buffer)); - WriteRamRequest{Variable::LongText2}.write_text(value); + value.set(ExtUI::getFilamentUsed_str(buffer)); + WriteRamRequest{Variable::LongText2}.write_text(value); } } diff --git a/Marlin/src/advi3pp/screens/info/statistics.h b/Marlin/src/advi3pp/screens/info/statistics.h index e5e58f8e20..4600f35147 100644 --- a/Marlin/src/advi3pp/screens/info/statistics.h +++ b/Marlin/src/advi3pp/screens/info/statistics.h @@ -20,18 +20,19 @@ #pragma once -#include "../core/screen.h" +#include "../../core/screen.h" namespace ADVi3pp { //! Statistics Page -struct Statistics: Screen -{ -private: - Page do_prepare_page(); - void send_stats(); +struct Statistics: Screen { + static constexpr Page PAGE = Page::Statistics; + static constexpr Action ACTION = Action::Statistics; - friend Parent; +private: + void on_enter(); + void send_stats(); + friend Parent; }; extern Statistics statistics; diff --git a/Marlin/src/advi3pp/screens/info/versions.cpp b/Marlin/src/advi3pp/screens/info/versions.cpp index 0e02bce7fb..a6ba3c9202 100755 --- a/Marlin/src/advi3pp/screens/info/versions.cpp +++ b/Marlin/src/advi3pp/screens/info/versions.cpp @@ -33,53 +33,48 @@ Versions versions; //! Get the current DGUS firmware version. //! @return The version as a string. template -ADVString& get_lcd_firmware_version(ADVString& lcd_version) -{ - ReadRegister response{Register::Version}; - if(!response.send_receive(1)) - { - Log::error() << F("Receiving Frame (Version)") << Log::endl(); - return lcd_version; - } - - uint8_t version = response.read_byte(); - lcd_version.reset(); - lcd_version << (version / 0x10) << '.' << (version % 0x10); +ADVString& get_lcd_firmware_version(ADVString& lcd_version) { + ReadRegister response{Register::Version}; + if(!response.send_receive(1)) { + Log::error() << F("Receiving Frame (Version)") << Log::endl(); return lcd_version; + } + + uint8_t version = response.read_byte(); + lcd_version.reset(); + lcd_version << (version / 0x10) << '.' << (version % 0x10); + return lcd_version; } //! Send the different versions to the LCD screen. -void Versions::send_versions() const -{ - // Minimize memory usage (SRAM) +void Versions::send_versions() const { + // Minimize memory usage (SRAM) + + ADVString<16> text; + core.convert_version(text, advi3_pp_version); + WriteRamRequest{Variable::ADVi3ppVersion}.write_text(text); + + text.reset(); + text << (YEAR__ - 2000) + << (MONTH__ < 10 ? "0" : "") << MONTH__ + << (DAY__ < 10 ? "0" : "") << DAY__ + << (HOUR__ < 10 ? "0" : "") << HOUR__ + << (MIN__ < 10 ? "0" : "") << MIN__ + << (SEC__ < 10 ? "0" : "") << SEC__; + WriteRamRequest{Variable::ADVi3ppBuild}.write_text(text); - ADVString<16> text; - core.convert_version(text, advi3_pp_version); - WriteRamRequest{Variable::ADVi3ppVersion}.write_text(text); + get_lcd_firmware_version(text); + WriteRamRequest{Variable::ADVi3ppDGUSVersion}.write_text(text); - text.reset(); - text << (YEAR__ - 2000) - << (MONTH__ < 10 ? "0" : "") << MONTH__ - << (DAY__ < 10 ? "0" : "") << DAY__ - << (HOUR__ < 10 ? "0" : "") << HOUR__ - << (MIN__ < 10 ? "0" : "") << MIN__ - << (SEC__ < 10 ? "0" : "") << SEC__; - WriteRamRequest{Variable::ADVi3ppBuild}.write_text(text); - - get_lcd_firmware_version(text); - WriteRamRequest{Variable::ADVi3ppDGUSVersion}.write_text(text); - - text.set(SHORT_BUILD_VERSION); - WriteRamRequest{Variable::ADVi3ppMarlinVersion}.write_text(text); + text.set(SHORT_BUILD_VERSION); + WriteRamRequest{Variable::ADVi3ppMarlinVersion}.write_text(text); } //! Prepare the page before being displayed and return the right Page value //! @return The index of the page to display -Page Versions::do_prepare_page() -{ +void Versions::on_enter() { send_versions(); - return Page::Versions; } } diff --git a/Marlin/src/advi3pp/screens/info/versions.h b/Marlin/src/advi3pp/screens/info/versions.h index 92b8790386..560cdb45a6 100644 --- a/Marlin/src/advi3pp/screens/info/versions.h +++ b/Marlin/src/advi3pp/screens/info/versions.h @@ -20,19 +20,21 @@ #pragma once -#include "../core/screen.h" +#include "../../core/screen.h" namespace ADVi3pp { //! Versions Page -struct Versions: Screen -{ - void send_versions() const; +struct Versions: Screen { + static constexpr Page PAGE = Page::Versions; + static constexpr Action ACTION = Action::Versions; + + void send_versions() const; private: - Page do_prepare_page(); + void on_enter(); - friend Parent; + friend Parent; }; extern Versions versions; diff --git a/Marlin/src/advi3pp/screens/leveling/automatic.cpp b/Marlin/src/advi3pp/screens/leveling/automatic.cpp index 40e8f7f996..34bb903d79 100755 --- a/Marlin/src/advi3pp/screens/leveling/automatic.cpp +++ b/Marlin/src/advi3pp/screens/leveling/automatic.cpp @@ -21,7 +21,7 @@ #include "../../parameters.h" #include "../../core/core.h" #include "../../core/status.h" -#include "../../screens/core/wait.h" +#include "../../core/wait.h" #include "grid.h" #include "automatic.h" @@ -29,93 +29,93 @@ namespace ADVi3pp { AutomaticLeveling automatic_leveling; -bool AutomaticLeveling::do_dispatch(KeyValue key_value) -{ - if(Parent::do_dispatch(key_value)) - return true; +bool AutomaticLeveling::on_dispatch(KeyValue key_value) { + if(Parent::on_dispatch(key_value)) + return true; - switch(key_value) - { - case KeyValue::LevelingResetProbe: reset_command(); break; - default: return false; - } + switch(key_value) { + case KeyValue::LevelingResetProbe: reset_command(); break; + default: return false; + } - return true; + return true; } //! Prepare the page before being displayed and return the right Page value //! @return The index of the page to display -Page AutomaticLeveling::do_prepare_page() -{ +void AutomaticLeveling::on_enter() { #ifdef ADVi3PP_PROBE - if(!core.ensure_not_printing()) - return Page::None; - start(); - return Page::None; -#else - return Page::NoSensor; + start(); #endif } -void AutomaticLeveling::reset_command() -{ +void AutomaticLeveling::reset_command() { #ifdef ADVi3PP_PROBE - core.inject_commands(F("M280 P0 S160")); + core.inject_commands(F("M280 P0 S160")); #else - pages.show(Page::NoSensor); + pages.show(PAGE, ACTION); #endif } -void AutomaticLeveling::start() -{ - sensor_interactive_leveling_ = true; - pages.save_forward_page(); - wait.wait(F("Homing...")); +void AutomaticLeveling::on_back_command() { + status.set(F("Canceling leveling...")); + ExtUI::cancelLeveling(); + Parent::on_back_command(); +} - // homing, raise head, leveling, go back to corner, activate compensation -#ifdef ADVi3PP_PROBE - core.inject_commands(F("G28 O F6000\nG1 Z4 F1200\nG29 E\nG28 X Y F6000\nM420 S1")); -#else - core.inject_commands(F("G28 O F6000\nG1 Z4 F1200\nG29 S1\nG28 X Y F6000\nM420 S1")); -#endif +void AutomaticLeveling::on_abort() { + ExtUI::cancelLeveling(); +} + +void AutomaticLeveling::start() { + lcd_leveling_ = true; + pages.save_forward_page(); + adv::array data{}; + WriteRamRequest{Variable::Value0}.write_words_data(data.data(), data.size()); + wait.home_and_wait(Callback{this, &AutomaticLeveling::home_task}, F("G28\nG1 Z4 F1200")); // Homing, always +} + +//! Check if the printer is homed, and continue the Z Height Tuning process. +void AutomaticLeveling::home_task() { + if(!wait.check_homed()) + return; + core.inject_commands(ExtUI::isLevelingHighSpeed() ? F("G29") : F("G29 E")); +} + +void AutomaticLeveling::on_progress(uint8_t index, uint8_t x, uint8_t y) { + status.format(F("Probing #%i at %i x %i mm"), index, x, y); + + if(pages.get_current_page() != Page::AutomaticLeveling) + return; + + adv::array data{}; + data[index - 1] = 2; // index starts at 1 + + WriteRamRequest{Variable::Value0}.write_words_data(data.data(), data.size()); } //! Called by Marlin when G29 (automatic bed leveling) is finished. //! @param success Boolean indicating if the leveling was successful or not. -void AutomaticLeveling::leveling_finished(bool success) -{ - if(!success) - { - if(sensor_interactive_leveling_) - wait.wait_back(F("Leveling failed"), WaitCallback{this, &AutomaticLeveling::leveling_failed}); - else - status.set(F("Leveling failed")); - - sensor_interactive_leveling_ = false; - return; +void AutomaticLeveling::on_done(bool success) { + Log::log() << "on_done" << success << Log::endl(); + if(!success) + status.set(F("Leveling failure or aborted, please wait...")); + + if(!lcd_leveling_) { + if(success) { + settings.save(); + ExtUI::setLevelingActive(true); } + return; + } - status.reset(); + lcd_leveling_ = false; + if(!success) + return; - if(sensor_interactive_leveling_) - { - sensor_interactive_leveling_ = false; - leveling_grid.show(); - } - else - { - settings.save(); - ExtUI::setLevelingActive(true); - } + status.reset(); + leveling_grid.show(); } -//! Show the back page when G29 (automatic bed leveling) failed. -bool AutomaticLeveling::leveling_failed() -{ - pages.show_back_page(); - return true; -} - - } diff --git a/Marlin/src/advi3pp/screens/leveling/automatic.h b/Marlin/src/advi3pp/screens/leveling/automatic.h index 728823b01b..2781d689b7 100755 --- a/Marlin/src/advi3pp/screens/leveling/automatic.h +++ b/Marlin/src/advi3pp/screens/leveling/automatic.h @@ -20,26 +20,38 @@ #pragma once -#include "../core/screen.h" +#include "../../core/screen.h" namespace ADVi3pp { //! Automatic Leveling Page -struct AutomaticLeveling: Screen -{ - void leveling_finished(bool success); +struct AutomaticLeveling: Screen { +#ifdef ADVi3PP_PROBE + static constexpr Page PAGE = Page::AutomaticLeveling; + static constexpr Action ACTION = Action::AutomaticLeveling; +#else + static constexpr Page PAGE = Page::NoSensor; + static constexpr Action ACTION = Action::None; +#endif + + void on_start() {} + void on_progress(uint8_t index, uint8_t x, uint8_t y); + void on_done(bool success); private: - bool do_dispatch(KeyValue key_value); - Page do_prepare_page(); - void reset_command(); - void start(); - bool leveling_failed(); + bool on_dispatch(KeyValue key_value); + void on_enter(); + void on_back_command(); + void on_abort(); + + void reset_command(); + void start(); + void home_task(); private: - bool sensor_interactive_leveling_ = false; + bool lcd_leveling_ = false; - friend Parent; + friend Parent; }; extern AutomaticLeveling automatic_leveling; diff --git a/Marlin/src/advi3pp/screens/leveling/grid.cpp b/Marlin/src/advi3pp/screens/leveling/grid.cpp index a24c833f6c..c53e8b1e6f 100755 --- a/Marlin/src/advi3pp/screens/leveling/grid.cpp +++ b/Marlin/src/advi3pp/screens/leveling/grid.cpp @@ -31,34 +31,26 @@ LevelingGrid leveling_grid; //! Prepare the page before being displayed and return the right Page value //! @return The index of the page to display -Page LevelingGrid::do_prepare_page() -{ - ExtUI::bed_mesh_t& z_values = ExtUI::getMeshArray(); +void LevelingGrid::on_enter() { + ExtUI::bed_mesh_t& z_values = ExtUI::getMeshArray(); - adv::array data{}; - for(auto y = 0; y < GRID_MAX_POINTS_Y; y++) - for(auto x = 0; x < GRID_MAX_POINTS_X; x++) - data[y * GRID_MAX_POINTS_X + x] = static_cast(lround(z_values[x][y] * 100)); + adv::array data{}; + for(auto y = 0; y < GRID_MAX_POINTS_Y; y++) + for(auto x = 0; x < GRID_MAX_POINTS_X; x++) + data[y * GRID_MAX_POINTS_X + x] = static_cast(lround(z_values[x][y] * 100)); - WriteRamRequest{Variable::Value0}.write_words_data(data.data(), data.size()); - - return Page::SensorGrid; + WriteRamRequest{Variable::Value0}.write_words_data(data.data(), data.size()); } //! Handles the Save (Continue) command -void LevelingGrid::do_save_command() -{ - ExtUI::setLevelingActive(true); - Parent::do_save_command(); +void LevelingGrid::on_save_command() { + ExtUI::setLevelingActive(true); + Parent::on_save_command(); } -#else - -//! Prepare the page before being displayed and return the right Page value -//! @return The index of the page to display -Page LevelingGrid::do_prepare_page() -{ - return Page::NoSensor; +void LevelingGrid::on_back_command() { + pages.back(); + Parent::on_back_command(); } #endif diff --git a/Marlin/src/advi3pp/screens/leveling/grid.h b/Marlin/src/advi3pp/screens/leveling/grid.h index d5b9fba92f..1361fd87fe 100755 --- a/Marlin/src/advi3pp/screens/leveling/grid.h +++ b/Marlin/src/advi3pp/screens/leveling/grid.h @@ -20,28 +20,36 @@ #pragma once -#include "../../screens/core/screen.h" +#include "../../core/screen.h" namespace ADVi3pp { #ifdef ADVi3PP_PROBE + //! Leveling Grid Page -struct LevelingGrid: Screen -{ +struct LevelingGrid: Screen { + static constexpr Page PAGE = Page::SensorGrid; + static constexpr Action ACTION = Action::SensorGrid; + private: - Page do_prepare_page(); - void do_save_command(); + void on_enter(); + void on_save_command(); + void on_back_command(); - friend Parent; + friend Parent; }; + #else + //! Leveling Grid Page struct LevelingGrid: Screen { private: - Page do_prepare_page(); + static constexpr Page PAGE = Page::NoSensor; + static constexpr Action ACTION = Action::None; friend Parent; }; + #endif extern LevelingGrid leveling_grid; diff --git a/Marlin/src/advi3pp/screens/leveling/manual.cpp b/Marlin/src/advi3pp/screens/leveling/manual.cpp index 48bba42c65..e367543042 100755 --- a/Marlin/src/advi3pp/screens/leveling/manual.cpp +++ b/Marlin/src/advi3pp/screens/leveling/manual.cpp @@ -22,7 +22,7 @@ #include "manual.h" #include "xtwist.h" #include "../../core/core.h" -#include "../../screens/core/wait.h" +#include "../../core/wait.h" namespace ADVi3pp { @@ -37,64 +37,62 @@ ManualLeveling manual_leveling; //! Execute a Manual Leveling command //! @param key_value The sub-action to handle //! @return True if the action was handled -bool ManualLeveling::do_dispatch(KeyValue key_value) -{ - if(Parent::do_dispatch(key_value)) - return true; - - switch(key_value) - { - case KeyValue::LevelingPoint1: point1_command(); break; - case KeyValue::LevelingPoint2: point2_command(); break; - case KeyValue::LevelingPoint3: point3_command(); break; - case KeyValue::LevelingPoint4: point4_command(); break; - case KeyValue::LevelingPoint5: point5_command(); break; - case KeyValue::LevelingPointA: pointA_command(); break; - case KeyValue::LevelingPointB: pointB_command(); break; - case KeyValue::LevelingPointC: pointC_command(); break; - case KeyValue::LevelingPointD: pointD_command(); break; - default: return false; - } - - return true; +bool ManualLeveling::on_dispatch(KeyValue key_value) { + if(Parent::on_dispatch(key_value)) + return true; + + switch(key_value) { + case KeyValue::LevelingPoint1: point1_command(); break; + case KeyValue::LevelingPoint2: point2_command(); break; + case KeyValue::LevelingPoint3: point3_command(); break; + case KeyValue::LevelingPoint4: point4_command(); break; + case KeyValue::LevelingPoint5: point5_command(); break; + case KeyValue::LevelingPointA: pointA_command(); break; + case KeyValue::LevelingPointB: pointB_command(); break; + case KeyValue::LevelingPointC: pointC_command(); break; + case KeyValue::LevelingPointD: pointD_command(); break; + default: return false; + } + + return true; } //! Execute the Back command -void ManualLeveling::do_back_command() -{ +void ManualLeveling::on_back_command() { +#if HAS_LEVELING + ExtUI::setLevelingActive(true); // Enable back compensation +#endif + ExtUI::setAxisPosition_mm(Z_AFTER_HOMING, ExtUI::Z, FEEDRATE_Z); + Parent::on_back_command(); +} + +void ManualLeveling::on_abort() { #if HAS_LEVELING - ExtUI::setLevelingActive(true); // Enable back compensation + ExtUI::setLevelingActive(true); // Enable back compensation #endif - ExtUI::setAxisPosition_mm(Z_AFTER_HOMING, ExtUI::Z, FEEDRATE_Z); - Parent::do_back_command(); } -void ManualLeveling::do_save_command() -{ +void ManualLeveling::on_save_command() { #if HAS_LEVELING - ExtUI::setLevelingActive(false); // Disable ABL mesh (already disabled but prefer to be explicit) + ExtUI::setLevelingActive(false); // Disable ABL mesh (already disabled but prefer to be explicit) #endif - ExtUI::setAxisPosition_mm(Z_AFTER_HOMING, ExtUI::Z, FEEDRATE_Z); - Parent::do_save_command(); + ExtUI::setAxisPosition_mm(Z_AFTER_HOMING, ExtUI::Z, FEEDRATE_Z); + // Do not call parent, there nothing to save + pages.show_forward_page(); } //! Prepare the page before being displayed and return the right Page value //! @return The index of the page to display -Page ManualLeveling::do_prepare_page() -{ - if(!core.ensure_not_printing()) - return Page::None; - pages.save_forward_page(); - - if(ExtUI::getActualTemp_celsius(ExtUI::E0) > 50) - wait.wait_back_continue(F("Warning: Hotend is hot"), - WaitCallback{this, &ManualLeveling::abort}, - WaitCallback{this, &ManualLeveling::start}); - else - start(); +void ManualLeveling::on_enter() { + pages.save_forward_page(); - return Page::None; + if(ExtUI::getActualTemp_celsius(ExtUI::E0) > 50) + wait.wait_back_continue(F("Warning: Hotend is hot"), + WaitCallback{this, &ManualLeveling::abort}, + WaitCallback{this, &ManualLeveling::start}); + else + start(); } bool ManualLeveling::abort() { @@ -102,90 +100,70 @@ bool ManualLeveling::abort() { } bool ManualLeveling::start() { - wait.wait(F("Homing...")); - ExtUI::setAllAxisUnhomed(); - ExtUI::setAllAxisPositionUnknown(); - core.inject_commands(F("G28 O F6000")); // Homing -#if HAS_LEVELING ExtUI::setLevelingActive(false); // We do not want compensation during manual leveling -#endif - background_task.set(Callback{this, &ManualLeveling::leveling_task}, 200); + wait.home_and_wait(Callback{this, &ManualLeveling::leveling_task}, F("G28")); // Homing (always) return false; } //! Leveling Background task. -void ManualLeveling::leveling_task() -{ - if(!ExtUI::isMachineHomed()) - return; - - background_task.clear(); - pages.show(Page::ManualLeveling); +void ManualLeveling::leveling_task() { + if(!wait.check_homed()) + return; } -void ManualLeveling::move(float x, float y) -{ - ExtUI::setAxisPosition_mm(Z_HOMING_HEIGHT, ExtUI::Z, FEEDRATE_Z); +void ManualLeveling::move(float x, float y) { + ExtUI::setAxisPosition_mm(Z_HOMING_HEIGHT, ExtUI::Z, FEEDRATE_Z); - float positions[2] = {x, y}; - ExtUI::axis_t axis[2] = { ExtUI::X, ExtUI::Y }; - ExtUI::setMultipleAxisPosition_mm(2, positions, axis, FEEDRATE_XY); + float positions[2] = {x, y}; + ExtUI::axis_t axis[2] = { ExtUI::X, ExtUI::Y }; + ExtUI::setMultipleAxisPosition_mm(2, positions, axis, FEEDRATE_XY); - ExtUI::setAxisPosition_mm(0, ExtUI::Z, FEEDRATE_Z); + ExtUI::setAxisPosition_mm(0, ExtUI::Z, FEEDRATE_Z); } //! Handle leveling point #1. -void ManualLeveling::point1_command() -{ - move(30, 30); +void ManualLeveling::point1_command() { + move(30, 30); } //! Handle leveling point #2. -void ManualLeveling::point2_command() -{ - move(30, 170); +void ManualLeveling::point2_command() { + move(30, 170); } //! Handle leveling point #3. -void ManualLeveling::point3_command() -{ - move(170, 170); +void ManualLeveling::point3_command() { + move(170, 170); } //! Handle leveling point #4. -void ManualLeveling::point4_command() -{ - move(170, 30); +void ManualLeveling::point4_command() { + move(170, 30); } //! Handle leveling point #5. -void ManualLeveling::point5_command() -{ - move(100, 100); +void ManualLeveling::point5_command() { + move(100, 100); } //! Handle leveling point #A. -void ManualLeveling::pointA_command() -{ - move(100, 30); +void ManualLeveling::pointA_command() { + move(100, 30); } //! Handle leveling point #B. -void ManualLeveling::pointB_command() -{ - move(30, 100); +void ManualLeveling::pointB_command() { + move(30, 100); } //! Handle leveling point #C. -void ManualLeveling::pointC_command() -{ - move(100, 170); +void ManualLeveling::pointC_command() { + move(100, 170); } //! Handle leveling point #D. -void ManualLeveling::pointD_command() -{ - move(170, 100); +void ManualLeveling::pointD_command() { + move(170, 100); } } diff --git a/Marlin/src/advi3pp/screens/leveling/manual.h b/Marlin/src/advi3pp/screens/leveling/manual.h index 81b7929bca..56046c9670 100755 --- a/Marlin/src/advi3pp/screens/leveling/manual.h +++ b/Marlin/src/advi3pp/screens/leveling/manual.h @@ -20,36 +20,40 @@ #pragma once -#include "../../screens/core/screen.h" +#include "../../core/screen.h" namespace ADVi3pp { //! Manual Leveling Page -struct ManualLeveling: Screen -{ +struct ManualLeveling: Screen { + static constexpr Page PAGE = Page::ManualLeveling; + static constexpr Action ACTION = Action::ManualLeveling; + private: - bool do_dispatch(KeyValue value); - Page do_prepare_page(); - void do_back_command(); - void do_save_command(); - - bool start(); - bool abort(); - - void point1_command(); - void point2_command(); - void point3_command(); - void point4_command(); - void point5_command(); - void pointA_command(); - void pointB_command(); - void pointC_command(); - void pointD_command(); - void leveling_task(); - void move(float x, float y); - - friend Parent; + bool on_dispatch(KeyValue value); + void on_enter(); + void on_back_command(); + void on_save_command(); + void on_abort(); + + bool start(); + bool abort(); + + void point1_command(); + void point2_command(); + void point3_command(); + void point4_command(); + void point5_command(); + void pointA_command(); + void pointB_command(); + void pointC_command(); + void pointD_command(); + void leveling_task(); + void move(float x, float y); + + friend Parent; }; + extern ManualLeveling manual_leveling; } diff --git a/Marlin/src/advi3pp/screens/core/no_sensor.cpp b/Marlin/src/advi3pp/screens/leveling/no_sensor.cpp similarity index 83% rename from Marlin/src/advi3pp/screens/core/no_sensor.cpp rename to Marlin/src/advi3pp/screens/leveling/no_sensor.cpp index 4674679552..9700556acd 100644 --- a/Marlin/src/advi3pp/screens/core/no_sensor.cpp +++ b/Marlin/src/advi3pp/screens/leveling/no_sensor.cpp @@ -25,11 +25,4 @@ namespace ADVi3pp { NoSensor no_sensor; -//! Prepare the page before being displayed and return the right Page value -//! @return The index of the page to display -Page NoSensor::do_prepare_page() -{ - return Page::NoSensor; -} - } diff --git a/Marlin/src/advi3pp/screens/core/no_sensor.h b/Marlin/src/advi3pp/screens/leveling/no_sensor.h similarity index 83% rename from Marlin/src/advi3pp/screens/core/no_sensor.h rename to Marlin/src/advi3pp/screens/leveling/no_sensor.h index e635c094b3..55afa9e875 100644 --- a/Marlin/src/advi3pp/screens/core/no_sensor.h +++ b/Marlin/src/advi3pp/screens/leveling/no_sensor.h @@ -20,17 +20,17 @@ #pragma once -#include "screen.h" +#include "../../core/screen.h" namespace ADVi3pp { //! No Sensor Page -struct NoSensor: Screen -{ -private: - Page do_prepare_page(); +struct NoSensor: Screen { + static constexpr Page PAGE = Page::NoSensor; + static constexpr Action ACTION = Action::NoSensor; - friend Parent; +private: + friend Parent; }; extern NoSensor no_sensor; diff --git a/Marlin/src/advi3pp/screens/leveling/xtwist.cpp b/Marlin/src/advi3pp/screens/leveling/xtwist.cpp index c2b425826a..63d935710f 100755 --- a/Marlin/src/advi3pp/screens/leveling/xtwist.cpp +++ b/Marlin/src/advi3pp/screens/leveling/xtwist.cpp @@ -20,18 +20,16 @@ #include "../../parameters.h" #include "../../core/core.h" -#include "../../screens/core/wait.h" +#include "../../core/wait.h" #include "xtwist.h" namespace ADVi3pp { namespace { - constexpr xyz_feedrate_t homing_feedrate_mm_m = HOMING_FEEDRATE_MM_M; constexpr float FEEDRATE_X = MMM_TO_MMS(homing_feedrate_mm_m.x); constexpr float FEEDRATE_Y = MMM_TO_MMS(homing_feedrate_mm_m.y); constexpr float FEEDRATE_Z = MMM_TO_MMS(homing_feedrate_mm_m.z); - } XTwist xtwist; @@ -45,185 +43,148 @@ const int MARGIN = 10; //! Handle Sensor Z Height command //! @param key_value The sub-action to handle //! @return True if the action was handled -bool XTwist::do_dispatch(KeyValue key_value) -{ - if(Parent::do_dispatch(key_value)) - return true; - - switch(key_value) - { - case KeyValue::Multiplier1: multiplier1_command(); break; - case KeyValue::Multiplier2: multiplier2_command(); break; - case KeyValue::Multiplier3: multiplier3_command(); break; - case KeyValue::Point_L: point_L_command(); break; - case KeyValue::Point_M: point_M_command(); break; - case KeyValue::Point_R: point_R_command(); break; - default: return false; - } - +bool XTwist::on_dispatch(KeyValue key_value) { + if(Parent::on_dispatch(key_value)) return true; + + switch(key_value) { + case KeyValue::Multiplier1: multiplier1_command(); break; + case KeyValue::Multiplier2: multiplier2_command(); break; + case KeyValue::Multiplier3: multiplier3_command(); break; + case KeyValue::Point_L: point_L_command(); break; + case KeyValue::Point_M: point_M_command(); break; + case KeyValue::Point_R: point_R_command(); break; + default: return false; + } + + return true; } //! Prepare the page before being displayed and return the right Page value //! @return The index of the page to display -Page XTwist::do_prepare_page() -{ - if(!core.ensure_not_printing()) - return Page::None; - - if(!ExtUI::getLevelingActive()) - { - wait.wait_back(F("Please do an automated bed leveling.")); - return Page::None; - } - - pages.save_forward_page(); - - z_offsets_.fill(0); - - wait.wait(F("Homing...")); - core.inject_commands(F("G28 O F6000")); // homing - background_task.set(Callback{this, &XTwist::post_home_task}, 200); +void XTwist::on_enter() { + if(!ExtUI::getLevelingActive()) { + wait.wait_back(F("Please do an automated bed leveling.")); + return; + } - return Page::None; + z_offsets_.fill(0); + pages.save_forward_page(); + wait.home_and_wait(Callback{this, &XTwist::post_home_task}); } //! Check if the printer is homed, and continue the process. -void XTwist::post_home_task() -{ - if(core.is_busy() || !ExtUI::isMachineHomed()) - return; +void XTwist::post_home_task() { + if(!wait.check_homed()) + return; - background_task.clear(); + send_data(); + status.reset(); - send_data(); - status.reset(); + ExtUI::setSoftEndstopState(false); + point_M_command(); +} - ExtUI::setSoftEndstopState(false); - point_M_command(); +//! Execute the Back command +void XTwist::on_back_command() { + // enable enstops, raise head + ExtUI::setSoftEndstopState(true); + ExtUI::setAxisPosition_mm(4, ExtUI::Z, FEEDRATE_Z); - pages.show(Page::XTwist); + Parent::on_back_command(); } //! Execute the Back command -void XTwist::do_back_command() -{ - // enable enstops, raise head - ExtUI::setSoftEndstopState(true); - ExtUI::setAxisPosition_mm(4, ExtUI::Z, FEEDRATE_Z); - - Parent::do_back_command(); +void XTwist::on_abort() { + // enable enstops, raise head + ExtUI::setSoftEndstopState(true); } //! Handles the Save (Continue) command -void XTwist::do_save_command() -{ - ExtUI::setXTwistStartSpacing(MARGIN, (X_BED_SIZE - MARGIN) / 2.0f); - for(size_t i = 0; i < ExtUI::xTwistPoints; ++i) ExtUI::setXTwistZOffset(i, z_offsets_[i]); +void XTwist::on_save_command() { + ExtUI::setXTwistStartSpacing(MARGIN, (X_BED_SIZE - MARGIN) / 2.0f); + for(size_t i = 0; i < ExtUI::xTwistPoints; ++i) ExtUI::setXTwistZOffset(i, z_offsets_[i]); - // enable enstops, raise head - ExtUI::setSoftEndstopState(true);; - ExtUI::setAxisPosition_mm(4, ExtUI::Z, FEEDRATE_Z); + // enable enstops, raise head + ExtUI::setSoftEndstopState(true);; + ExtUI::setAxisPosition_mm(4, ExtUI::Z, FEEDRATE_Z); - Parent::do_save_command(); + Parent::on_save_command(); } //! Change the multiplier. -void XTwist::multiplier1_command() -{ - multiplier_ = Multiplier::M1; - send_data(); +void XTwist::multiplier1_command() { + multiplier_ = Multiplier::M1; + send_data(); } //! Change the multiplier. -void XTwist::multiplier2_command() -{ - multiplier_ = Multiplier::M2; - send_data(); +void XTwist::multiplier2_command() { + multiplier_ = Multiplier::M2; + send_data(); } //! Change the multiplier. -void XTwist::multiplier3_command() -{ - multiplier_ = Multiplier::M3; - send_data(); +void XTwist::multiplier3_command() { + multiplier_ = Multiplier::M3; + send_data(); } -float XTwist::get_x_mm(Point x) const -{ - return (x == Point::L ? MARGIN : (x == Point::R ? X_BED_SIZE - MARGIN : (X_BED_SIZE / 2.0f))); +float XTwist::get_x_mm(Point x) const { + return (x == Point::L ? MARGIN : (x == Point::R ? X_BED_SIZE - MARGIN : (X_BED_SIZE / 2.0f))); } -void XTwist::move_x(Point x) -{ - ExtUI::setAxisPosition_mm(4, ExtUI::Z, FEEDRATE_Z); - ExtUI::setAxisPosition_mm(get_x_mm(x), ExtUI::X, FEEDRATE_X); - ExtUI::setAxisPosition_mm(Y_BED_SIZE / 2.0f, ExtUI::Y, FEEDRATE_X); - ExtUI::setAxisPosition_mm(z_offsets_[static_cast(x)], ExtUI::Z, FEEDRATE_Z); +void XTwist::move_x(Point x) { + ExtUI::setAxisPosition_mm(4, ExtUI::Z, FEEDRATE_Z); + ExtUI::setAxisPosition_mm(get_x_mm(x), ExtUI::X, FEEDRATE_X); + ExtUI::setAxisPosition_mm(Y_BED_SIZE / 2.0f, ExtUI::Y, FEEDRATE_X); + ExtUI::setAxisPosition_mm(z_offsets_[static_cast(x)], ExtUI::Z, FEEDRATE_Z); - point_ = x; + point_ = x; } -void XTwist::point_M_command() -{ - move_x(Point::M); +void XTwist::point_M_command() { + move_x(Point::M); } -void XTwist::point_L_command() -{ - move_x(Point::L); +void XTwist::point_L_command() { + move_x(Point::L); } -void XTwist::point_R_command() -{ - move_x(Point::R); +void XTwist::point_R_command() { + move_x(Point::R); } //! Change the position of the nozzle (-Z). -void XTwist::minus() -{ - adjust_height(-get_multiplier_value()); +void XTwist::minus() { + adjust_height(-get_multiplier_value()); } //! Change the position of the nozzle (+Z). -void XTwist::plus() -{ - adjust_height(+get_multiplier_value()); +void XTwist::plus() { + adjust_height(+get_multiplier_value()); } //! Get the current multiplier value on the LCD panel. -double XTwist::get_multiplier_value() const -{ - if(multiplier_ < Multiplier::M1 || multiplier_ > Multiplier::M3) - { - Log::error() << F("Invalid multiplier value: ") << static_cast(multiplier_) << Log::endl(); - return SENSOR_Z_HEIGHT_MULTIPLIERS[0]; - } +double XTwist::get_multiplier_value() const { + if(multiplier_ < Multiplier::M1 || multiplier_ > Multiplier::M3) { + Log::error() << F("Invalid multiplier value: ") << static_cast(multiplier_) << Log::endl(); + return SENSOR_Z_HEIGHT_MULTIPLIERS[0]; + } - return SENSOR_Z_HEIGHT_MULTIPLIERS[static_cast(multiplier_)]; + return SENSOR_Z_HEIGHT_MULTIPLIERS[static_cast(multiplier_)]; } //! Adjust the Z height. //! @param offset Offset for the adjustment. -void XTwist::adjust_height(double offset_value) -{ - ExtUI::setAxisPosition_mm(ExtUI::getAxisPosition_mm(ExtUI::Z) + offset_value, ExtUI::Z, FEEDRATE_Z); - z_offsets_[static_cast(point_)] = ExtUI::getAxisPosition_mm(ExtUI::Z); +void XTwist::adjust_height(double offset_value) { + ExtUI::setAxisPosition_mm(ExtUI::getAxisPosition_mm(ExtUI::Z) + offset_value, ExtUI::Z, FEEDRATE_Z); + z_offsets_[static_cast(point_)] = ExtUI::getAxisPosition_mm(ExtUI::Z); } //! Send the current data (i.e. multiplier) to the LCD panel. -void XTwist::send_data() const -{ - WriteRamRequest{Variable::Value0}.write_word(static_cast(multiplier_)); -} - -#else - -//! Prepare the page before being displayed and return the right Page value -//! @return The index of the page to display -Page XTwist::do_prepare_page() -{ - return Page::NoSensor; +void XTwist::send_data() const { + WriteRamRequest{Variable::Value0}.write_word(static_cast(multiplier_)); } #endif diff --git a/Marlin/src/advi3pp/screens/leveling/xtwist.h b/Marlin/src/advi3pp/screens/leveling/xtwist.h index f3854fe372..e640bdba5b 100755 --- a/Marlin/src/advi3pp/screens/leveling/xtwist.h +++ b/Marlin/src/advi3pp/screens/leveling/xtwist.h @@ -21,58 +21,63 @@ #pragma once #include "../../lib/ADVstd/array.h" -#include "../../screens/core/screen.h" +#include "../../core/screen.h" namespace ADVi3pp { #ifdef ADVi3PP_PROBE //! X Twist Tuning Page -struct XTwist: Screen -{ - enum class Point: uint8_t {L, M, R}; +struct XTwist: Screen { + static constexpr Page PAGE = Page::XTwist; + static constexpr Action ACTION = Action::XTwist; - void minus(); - void plus(); + enum class Point: uint8_t {L, M, R}; + + void minus(); + void plus(); private: - enum class Multiplier: uint8_t { M1, M2, M3 }; - - bool do_dispatch(KeyValue key_value); - Page do_prepare_page(); - void post_home_task(); - void do_save_command(); - void do_back_command(); - void multiplier1_command(); - void multiplier2_command(); - void multiplier3_command(); - void move_x(Point x); - void point_L_command(); - void point_M_command(); - void point_R_command(); - double get_multiplier_value() const; - void adjust_height(double offset); - void send_data() const; - float get_x_mm(Point x) const; + enum class Multiplier: uint8_t { M1, M2, M3 }; + + bool on_dispatch(KeyValue key_value); + void on_enter(); + void on_save_command(); + void on_back_command(); + void on_abort(); + + void post_home_task(); + void multiplier1_command(); + void multiplier2_command(); + void multiplier3_command(); + void move_x(Point x); + void point_L_command(); + void point_M_command(); + void point_R_command(); + double get_multiplier_value() const; + void adjust_height(double offset); + void send_data() const; + float get_x_mm(Point x) const; private: - Multiplier multiplier_ = Multiplier::M1; - Point point_ = Point::L; - adv::array z_offsets_; - friend Parent; + Multiplier multiplier_ = Multiplier::M1; + Point point_ = Point::L; + adv::array z_offsets_; + + friend Parent; }; #else -struct XTwist: Screen -{ - void on_mesh_updated(const int8_t xpos, const int8_t ypos, const float zval) {} - void minus() {} - void plus() {} +struct XTwist: Screen { + void on_mesh_updated(const int8_t xpos, const int8_t ypos, const float zval) {} + void minus() {} + void plus() {} private: - Page do_prepare_page(); - friend Parent; + static constexpr Page PAGE = Page::NoSensor; + + friend Parent; }; #endif diff --git a/Marlin/src/advi3pp/screens/leveling/z_height.cpp b/Marlin/src/advi3pp/screens/leveling/z_height.cpp index 402c375641..ae02926398 100755 --- a/Marlin/src/advi3pp/screens/leveling/z_height.cpp +++ b/Marlin/src/advi3pp/screens/leveling/z_height.cpp @@ -20,16 +20,16 @@ #include "../../parameters.h" #include "../../core/core.h" -#include "../../screens/core/wait.h" +#include "../../core/wait.h" #include "z_height.h" namespace ADVi3pp { namespace { - constexpr xyz_feedrate_t homing_feedrate_mm_m = HOMING_FEEDRATE_MM_M; - constexpr float FEEDRATE_XY = MMM_TO_MMS(homing_feedrate_mm_m.x); - constexpr float FEEDRATE_Z = MMM_TO_MMS(homing_feedrate_mm_m.z); - constexpr unsigned MINIMAL_CLICK_DELAY = 200; // ms + constexpr xyz_feedrate_t homing_feedrate_mm_m = HOMING_FEEDRATE_MM_M; + constexpr float FEEDRATE_XY = MMM_TO_MMS(homing_feedrate_mm_m.x); + constexpr float FEEDRATE_Z = MMM_TO_MMS(homing_feedrate_mm_m.z); + constexpr unsigned MINIMAL_CLICK_DELAY = 200; // ms } SensorZHeight sensor_z_height; @@ -41,156 +41,134 @@ const double SENSOR_Z_HEIGHT_MULTIPLIERS[] = {0.02, 0.10, 1.0}; //! Handle Sensor Z Height command //! @param key_value The sub-action to handle //! @return True if the action was handled -bool SensorZHeight::do_dispatch(KeyValue key_value) -{ - if(Parent::do_dispatch(key_value)) - return true; - - switch(key_value) - { - case KeyValue::Multiplier1: multiplier1_command(); break; - case KeyValue::Multiplier2: multiplier2_command(); break; - case KeyValue::Multiplier3: multiplier3_command(); break; - default: return false; - } - +bool SensorZHeight::on_dispatch(KeyValue key_value) { + if(Parent::on_dispatch(key_value)) return true; + + switch(key_value) { + case KeyValue::Multiplier1: multiplier1_command(); break; + case KeyValue::Multiplier2: multiplier2_command(); break; + case KeyValue::Multiplier3: multiplier3_command(); break; + default: return false; + } + + return true; } //! Prepare the page before being displayed and return the right Page value //! @return The index of the page to display -Page SensorZHeight::do_prepare_page() -{ - if(!core.ensure_not_printing()) - return Page::None; - pages.save_forward_page(); +void SensorZHeight::on_enter() { + pages.save_forward_page(); - old_offset_ = ExtUI::getZOffset_mm(); - last_click_time_ = 0; - ExtUI::setZOffset_mm(0); // Before homing otherwise, Marlin is lost - ExtUI::setAbsoluteZAxisPosition_mm(ExtUI::getAxisPosition_mm(ExtUI::Z) + old_offset_); + old_offset_ = ExtUI::getZOffset_mm(); + last_click_time_ = 0; + ExtUI::setZOffset_mm(0); // Before homing otherwise, Marlin is lost + ExtUI::setAbsoluteZAxisPosition_mm(ExtUI::getAxisPosition_mm(ExtUI::Z) + old_offset_); - wait.wait(F("Homing...")); - core.inject_commands(F("G28 Z O")); // homing (if not already homed) - background_task.set(Callback{this, &SensorZHeight::post_home_task}, 200); - return Page::None; + wait.wait(F("Homing...")); + core.inject_commands(F("G28 Z O")); // homing (if not already homed) + background_task.set(Callback{this, &SensorZHeight::post_home_task}, 200); } //! Reset Sensor Z Height data. -void SensorZHeight::reset() -{ - multiplier_ = Multiplier::M1; +void SensorZHeight::reset() { + multiplier_ = Multiplier::M1; } //! Check if the printer is homed, and continue the Z Height Tuning process. -void SensorZHeight::post_home_task() -{ - if(core.is_busy() || !ExtUI::isMachineHomed()) - return; +void SensorZHeight::post_home_task() { + if(core.is_busy() || !ExtUI::isMachineHomed()) + return; - background_task.clear(); - reset(); + background_task.clear(); + reset(); - float positions[2] = {X_CENTER, Y_CENTER}; - ExtUI::axis_t axis[2] = { ExtUI::X, ExtUI::Y }; - ExtUI::setMultipleAxisPosition_mm(2, positions, axis, FEEDRATE_XY); - ExtUI::setAxisPosition_mm(0, ExtUI::Z, FEEDRATE_Z); - ExtUI::setSoftEndstopState(false); + float positions[2] = {X_CENTER, Y_CENTER}; + ExtUI::axis_t axis[2] = { ExtUI::X, ExtUI::Y }; + ExtUI::setMultipleAxisPosition_mm(2, positions, axis, FEEDRATE_XY); + ExtUI::setAxisPosition_mm(0, ExtUI::Z, FEEDRATE_Z); + ExtUI::setSoftEndstopState(false); - send_data(); - pages.show(Page::ZHeightTuning); + send_data(); + pages.clear_temporaries(); } //! Execute the Back command -void SensorZHeight::do_back_command() -{ - ExtUI::setSoftEndstopState(true); - ExtUI::setZOffset_mm(old_offset_); - ExtUI::setAbsoluteZAxisPosition_mm(ExtUI::getAxisPosition_mm(ExtUI::Z) - old_offset_); - ExtUI::setAxisPosition_mm(Z_AFTER_HOMING, ExtUI::Z, FEEDRATE_Z); - Parent::do_back_command(); +void SensorZHeight::on_back_command() { + ExtUI::setSoftEndstopState(true); + ExtUI::setZOffset_mm(old_offset_); + ExtUI::setAbsoluteZAxisPosition_mm(ExtUI::getAxisPosition_mm(ExtUI::Z) - old_offset_); + ExtUI::setAxisPosition_mm(Z_AFTER_HOMING, ExtUI::Z, FEEDRATE_Z); + Parent::on_back_command(); } +void SensorZHeight::on_abort() { + ExtUI::setSoftEndstopState(true); + ExtUI::setZOffset_mm(old_offset_); +} + + //! Handles the Save (Continue) command -void SensorZHeight::do_save_command() -{ - // Current Z position becomes Z offset - ExtUI::setSoftEndstopState(true); - ExtUI::setZOffset_mm(ExtUI::getAxisPosition_mm(ExtUI::Z)); - ExtUI::setAbsoluteZAxisPosition_mm(0); - ExtUI::setAxisPosition_mm(Z_AFTER_HOMING, ExtUI::Z, FEEDRATE_Z); - Parent::do_save_command(); +void SensorZHeight::on_save_command() { + // Current Z position becomes Z offset + ExtUI::setSoftEndstopState(true); + ExtUI::setZOffset_mm(ExtUI::getAxisPosition_mm(ExtUI::Z)); + ExtUI::setAbsoluteZAxisPosition_mm(0); + ExtUI::setAxisPosition_mm(Z_AFTER_HOMING, ExtUI::Z, FEEDRATE_Z); + Parent::on_save_command(); } //! Change the multiplier. -void SensorZHeight::multiplier1_command() -{ - multiplier_ = Multiplier::M1; - send_data(); +void SensorZHeight::multiplier1_command() { + multiplier_ = Multiplier::M1; + send_data(); } //! Change the multiplier. -void SensorZHeight::multiplier2_command() -{ - multiplier_ = Multiplier::M2; - send_data(); +void SensorZHeight::multiplier2_command() { + multiplier_ = Multiplier::M2; + send_data(); } //! Change the multiplier. -void SensorZHeight::multiplier3_command() -{ - multiplier_ = Multiplier::M3; - send_data(); +void SensorZHeight::multiplier3_command() { + multiplier_ = Multiplier::M3; + send_data(); } //! Change the position of the nozzle (-Z). -void SensorZHeight::minus() -{ - adjust_height(-get_multiplier_value()); +void SensorZHeight::minus() { + adjust_height(-get_multiplier_value()); } //! Change the position of the nozzle (+Z). -void SensorZHeight::plus() -{ - adjust_height(+get_multiplier_value()); +void SensorZHeight::plus() { + adjust_height(+get_multiplier_value()); } //! Get the current multiplier value on the LCD panel. -double SensorZHeight::get_multiplier_value() const -{ - if(multiplier_ < Multiplier::M1 || multiplier_ > Multiplier::M3) - { - Log::error() << F("Invalid multiplier value: ") << static_cast(multiplier_) << Log::endl(); - return SENSOR_Z_HEIGHT_MULTIPLIERS[0]; - } +double SensorZHeight::get_multiplier_value() const { + if(multiplier_ < Multiplier::M1 || multiplier_ > Multiplier::M3) { + Log::error() << F("Invalid multiplier value: ") << static_cast(multiplier_) << Log::endl(); + return SENSOR_Z_HEIGHT_MULTIPLIERS[0]; + } - return SENSOR_Z_HEIGHT_MULTIPLIERS[static_cast(multiplier_)]; + return SENSOR_Z_HEIGHT_MULTIPLIERS[static_cast(multiplier_)]; } //! Adjust the Z height. //! @param offset Offset for the adjustment. -void SensorZHeight::adjust_height(double offset) -{ - if(!ELAPSED(millis(), last_click_time_)) - return; - last_click_time_ = millis(); - ExtUI::setAxisPosition_mm(ExtUI::getAxisPosition_mm(ExtUI::Z) + offset, ExtUI::Z, FEEDRATE_Z); - send_data(); +void SensorZHeight::adjust_height(double offset) { + if(!ELAPSED(millis(), last_click_time_)) + return; + last_click_time_ = millis(); + ExtUI::setAxisPosition_mm(ExtUI::getAxisPosition_mm(ExtUI::Z) + offset, ExtUI::Z, FEEDRATE_Z); + send_data(); } //! Send the current data (i.e. multiplier) to the LCD panel. -void SensorZHeight::send_data() const -{ - WriteRamRequest{Variable::Value0}.write_word(static_cast(multiplier_)); -} - -#else - -//! Prepare the page before being displayed and return the right Page value -//! @return The index of the page to display -Page SensorZHeight::do_prepare_page() -{ - return Page::NoSensor; +void SensorZHeight::send_data() const { + WriteRamRequest{Variable::Value0}.write_word(static_cast(multiplier_)); } #endif diff --git a/Marlin/src/advi3pp/screens/leveling/z_height.h b/Marlin/src/advi3pp/screens/leveling/z_height.h index c56d800c84..627ddc9503 100755 --- a/Marlin/src/advi3pp/screens/leveling/z_height.h +++ b/Marlin/src/advi3pp/screens/leveling/z_height.h @@ -20,54 +20,56 @@ #pragma once -#include "../../screens/core/screen.h" +#include "../../core/screen.h" namespace ADVi3pp { #ifdef ADVi3PP_PROBE //! Sensor Z Height Tuning Page -struct SensorZHeight: Screen -{ - void minus(); - void plus(); +struct SensorZHeight: Screen { + static constexpr Page PAGE = Page::ZHeightTuning; + static constexpr Action ACTION = Action::ZHeightTuning; - enum class Multiplier: uint8_t - { - M1 = 0, - M2 = 1, - M3 = 2 - }; + void minus(); + void plus(); + + enum class Multiplier: uint8_t { + M1 = 0, + M2 = 1, + M3 = 2 + }; private: - bool do_dispatch(KeyValue key_value); - Page do_prepare_page(); - void do_save_command(); - void do_back_command(); - void post_home_task(); - void multiplier1_command(); - void multiplier2_command(); - void multiplier3_command(); - double get_multiplier_value() const; - void adjust_height(double offset); - void send_data() const; - void reset(); + bool on_dispatch(KeyValue key_value); + void on_enter(); + void on_save_command(); + void on_back_command(); + void on_abort(); + + void post_home_task(); + void multiplier1_command(); + void multiplier2_command(); + void multiplier3_command(); + double get_multiplier_value() const; + void adjust_height(double offset); + void send_data() const; + void reset(); private: - Multiplier multiplier_ = Multiplier::M1; - float old_offset_ = 0; - millis_t last_click_time_ = 0; - friend Parent; + Multiplier multiplier_ = Multiplier::M1; + float old_offset_ = 0; + millis_t last_click_time_ = 0; + friend Parent; }; #else //! Sensor Z Height Tuning Page -struct SensorZHeight: Screen -{ - void minus() {} - void plus() {} +struct SensorZHeight: Screen { + void minus() {} + void plus() {} private: - Page do_prepare_page(); - friend Parent; + static constexpr Page PAGE = Page::NoSensor; + friend Parent; }; #endif diff --git a/Marlin/src/advi3pp/screens/print/baby_steps.cpp b/Marlin/src/advi3pp/screens/print/baby_steps.cpp new file mode 100644 index 0000000000..a2045a2b8c --- /dev/null +++ b/Marlin/src/advi3pp/screens/print/baby_steps.cpp @@ -0,0 +1,99 @@ +/** + * ADVi3++ Firmware For Wanhao Duplicator i3 Plus (based on Marlin 2) + * + * Copyright (C) 2017-2022 Sebastien Andrivet [https://github.com/andrivet/] + * + * This program 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. + * + * This program 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 this program. If not, see . + * + */ + +#include "../../parameters.h" +#include "baby_steps.h" +#include "../../core/dgus.h" + +namespace ADVi3pp { + +//! List of multipliers in Print Settings +const int BABYSTEPS_MULTIPLIERS[] = {8, 16, 32}; + +BabySteps baby_steps; + + +//! Handle Baby Steps command +//! @param key_value The sub-action to handle +//! @return True if the action was handled +bool BabySteps::on_dispatch(KeyValue key_value) { + if(Parent::on_dispatch(key_value)) + return true; + + switch(key_value) { + case KeyValue::Baby1: multiplier_ = Multiplier::M1; break; + case KeyValue::Baby2: multiplier_ = Multiplier::M2; break; + case KeyValue::Baby3: multiplier_ = Multiplier::M3; break; + default: return false; + } + + send_multiplier(); + return true; +} + +//! Get the value corresponding the the current multiplier. +//! @return The value of the current multiplier (in steps), or the first one in the case of an invalid multiplier +int BabySteps::get_multiplier_value() const { + if(multiplier_ < Multiplier::M1 || multiplier_ > Multiplier::M3) { + Log::error() << F("Invalid multiplier value: ") << static_cast(multiplier_) << Log::endl(); + return BABYSTEPS_MULTIPLIERS[0]; + } + + return BABYSTEPS_MULTIPLIERS[static_cast(multiplier_)]; +} + +//! Send the current data to the LCD panel. +void BabySteps::send_multiplier() const { + WriteRamRequest{Variable::Value0}.write_words(multiplier_); +} + +//! Send the current data to the LCD panel. +void BabySteps::send_z_offset() { + WriteRamRequest{Variable::Value1}.write_words(lround(100.0 * ExtUI::getZOffset_mm())); +} + + +//! Prepare the page before being displayed and return the right Page value +//! @return The index of the page to display +void BabySteps::on_enter() { + save_ = false; + send_multiplier(); + background_task.set(Callback{this, &BabySteps::send_z_offset}, 200); +} + +void BabySteps::on_back_command() { + background_task.clear(); + if(save_) settings.save(); + Parent::on_back_command(); +} + +//! Handle the -Babystep command +void BabySteps::baby_minus_command() { + save_= true; + ExtUI::smartAdjustAxis_steps(-get_multiplier_value(), ExtUI::Z, true); +} + +//! Handle the +Babystep command +void BabySteps::baby_plus_command() { + save_= true; + ExtUI::smartAdjustAxis_steps(get_multiplier_value(), ExtUI::Z, true); +} + +} diff --git a/Marlin/src/advi3pp/screens/tuning/usb_to_lcd.cpp b/Marlin/src/advi3pp/screens/print/baby_steps.h similarity index 57% rename from Marlin/src/advi3pp/screens/tuning/usb_to_lcd.cpp rename to Marlin/src/advi3pp/screens/print/baby_steps.h index 5e2ea65fa9..ab7b44ef8a 100644 --- a/Marlin/src/advi3pp/screens/tuning/usb_to_lcd.cpp +++ b/Marlin/src/advi3pp/screens/print/baby_steps.h @@ -18,23 +18,38 @@ * */ -#include "../../parameters.h" -#include "usb_to_lcd.h" -#include "../../core/dgus.h" -#include "../core/wait.h" +#pragma once + +#include "../../core/screen.h" namespace ADVi3pp { -Usb2Lcd usb_2_lcd; +//! Print Settings Page +struct BabySteps: Screen { + static constexpr Page PAGE = Page::BabySteps; + static constexpr Action ACTION = Action::BabySteps; -//! Prepare the page before being displayed and return the right Page value -//! @return The index of the page to display -Page Usb2Lcd::do_prepare_page() -{ - wait.wait(F("USB is now connected to LCD serial port.")); - dgus.forwarding_loop(); - return Page::None; -} + void baby_minus_command(); + void baby_plus_command(); + + enum class Multiplier: uint8_t { M1, M2, M3 }; + +private: + bool on_dispatch(KeyValue value); + void on_enter(); + void on_back_command(); + void send_multiplier() const; + void send_z_offset(); + int get_multiplier_value() const; -} \ No newline at end of file +private: + Multiplier multiplier_ = Multiplier::M1; + bool save_ = false; + + friend Parent; +}; + +extern BabySteps baby_steps; + +} diff --git a/Marlin/src/advi3pp/screens/print/change_filament.cpp b/Marlin/src/advi3pp/screens/print/change_filament.cpp deleted file mode 100644 index c28d549006..0000000000 --- a/Marlin/src/advi3pp/screens/print/change_filament.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/** - * ADVi3++ Firmware For Wanhao Duplicator i3 Plus (based on Marlin 2) - * - * Copyright (C) 2017-2022 Sebastien Andrivet [https://github.com/andrivet/] - * - * This program 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. - * - * This program 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 this program. If not, see . - * - */ - -#include "../../parameters.h" -#include "change_filament.h" - -namespace ADVi3pp { - -ChangeFilament change_filament; - -//! Prepare the page before being displayed and return the right Page value -//! @return The index of the page to display -Page ChangeFilament::do_prepare_page() -{ - return Page::None; -} - -} diff --git a/Marlin/src/advi3pp/screens/print/pause_options.cpp b/Marlin/src/advi3pp/screens/print/pause_options.cpp index cb56170b91..350a26fd63 100644 --- a/Marlin/src/advi3pp/screens/print/pause_options.cpp +++ b/Marlin/src/advi3pp/screens/print/pause_options.cpp @@ -20,7 +20,7 @@ #include "../../parameters.h" #include "pause_options.h" -#include "../core/wait.h" +#include "../../core/wait.h" namespace ADVi3pp { @@ -29,38 +29,32 @@ PauseOptions pause_options; //! Handle Preheat actions. //! @param key_value Sub-action to handle //! @return True if the action was handled -bool PauseOptions::do_dispatch(KeyValue key_value) -{ - if(Parent::do_dispatch(key_value)) - return true; +bool PauseOptions::on_dispatch(KeyValue key_value) { + if(Parent::on_dispatch(key_value)) + return true; - switch(key_value) - { - case KeyValue::Extrude: extrude_command(); break; - case KeyValue::Resume: resume_command(); break; - default: return false; - } + switch(key_value) { + case KeyValue::Extrude: extrude_command(); break; + case KeyValue::Resume: resume_command(); break; + default: return false; + } - return true; + return true; } //! Prepare the page before being displayed and return the right Page value //! @return The index of the page to display -Page PauseOptions::do_prepare_page() -{ - pause_menu_response = PAUSE_RESPONSE_WAIT_FOR; - return Page::PauseOptions; +void PauseOptions::on_enter() { + pause_menu_response = PAUSE_RESPONSE_WAIT_FOR; } -void PauseOptions::extrude_command() -{ - pause_menu_response = PAUSE_RESPONSE_EXTRUDE_MORE; +void PauseOptions::extrude_command() { + pause_menu_response = PAUSE_RESPONSE_EXTRUDE_MORE; } -void PauseOptions::resume_command() -{ - wait.wait(F("Please wait...")); - pause_menu_response = PAUSE_RESPONSE_RESUME_PRINT; +void PauseOptions::resume_command() { + wait.wait(F("Please wait...")); + pause_menu_response = PAUSE_RESPONSE_RESUME_PRINT; } } diff --git a/Marlin/src/advi3pp/screens/print/pause_options.h b/Marlin/src/advi3pp/screens/print/pause_options.h index 96507920ce..7954ffd6b5 100644 --- a/Marlin/src/advi3pp/screens/print/pause_options.h +++ b/Marlin/src/advi3pp/screens/print/pause_options.h @@ -20,20 +20,23 @@ #pragma once -#include "../core/screen.h" +#include "../../core/screen.h" namespace ADVi3pp { //! Pause Options Page -struct PauseOptions: Screen -{ +struct PauseOptions: Screen { + static constexpr Page PAGE = Page::PauseOptions; + static constexpr Action ACTION = Action::PauseOptions; + private: - bool do_dispatch(KeyValue key_value); - Page do_prepare_page(); - void extrude_command(); - void resume_command(); + bool on_dispatch(KeyValue key_value); + void on_enter(); + + void extrude_command(); + void resume_command(); - friend Parent; + friend Parent; }; extern PauseOptions pause_options; diff --git a/Marlin/src/advi3pp/screens/print/print.cpp b/Marlin/src/advi3pp/screens/print/print.cpp index 11c087c1e4..8bab94821e 100644 --- a/Marlin/src/advi3pp/screens/print/print.cpp +++ b/Marlin/src/advi3pp/screens/print/print.cpp @@ -22,7 +22,7 @@ #include "print.h" #include "../../core/core.h" #include "../../core/status.h" -#include "../core/wait.h" +#include "../../core/wait.h" namespace ADVi3pp { @@ -32,103 +32,70 @@ Print print; //! Handle print commands. //! @param key_value The sub-action to handle //! @return True if the action was handled -bool Print::do_dispatch(KeyValue value) -{ - if(Parent::do_dispatch(value)) - return true; - - switch(value) - { - case KeyValue::PrintStop: stop_command(); break; - case KeyValue::PrintPause: pause_resume_command(); break; - case KeyValue::PrintAdvancedPause: advanced_pause_command(); break; - default: return false; - } - +bool Print::on_dispatch(KeyValue value) { + if(Parent::on_dispatch(value)) return true; + + switch(value) { + case KeyValue::PrintStop: stop_command(); break; + case KeyValue::PrintPause: pause_resume_command(); break; + case KeyValue::PrintAdvancedPause: advanced_pause_command(); break; + default: return false; + } + + return true; } //! Prepare the page before being displayed and return the right Page value //! @return The index of the page to display -Page Print::do_prepare_page() -{ +void Print::on_enter() { #ifdef ADVi3PP_PROBE - if(!ExtUI::getLevelingActive()) - status.set(F("WARNING: Bed leveling not active.")); + if(!ExtUI::getLevelingActive()) + status.set(F("WARNING: Bed leveling not active.")); #endif - return Page::Print; } //! Stop printing -void Print::stop_command() -{ - if(!ExtUI::isPrinting()) - return; +void Print::stop_command() { + if(!ExtUI::isPrinting()) return; - wait.wait_back_continue(F("Abort printing?"), - WaitCallback{this, &Print::cancel_abort_print}, WaitCallback{this, &Print::abort_print}); + wait.wait_back_continue(F("Abort printing?"), + WaitCallback{this, &Print::cancel_abort_print}, WaitCallback{this, &Print::abort_print}); } -bool Print::cancel_abort_print() -{ - status.set(F("Continue printing")); - return true; +bool Print::cancel_abort_print() { + status.set(F("Continue printing")); + return true; } -bool Print::abort_print() -{ - ExtUI::stopPrint(); - return false; +bool Print::abort_print() { + pages.clear_temporaries(); + ExtUI::stopPrint(); + return false; } //! Pause printing -void Print::pause_resume_command() -{ - if(!ExtUI::isPrinting()) - return; - - if(ExtUI::isPrintingPaused()) - { - wait.wait(F("Resume printing...")); - ExtUI::resumePrint(); - } - else - { - wait.wait(F("Pause printing...")); - ExtUI::pausePrint(); - } +void Print::pause_resume_command() { + if(!ExtUI::isPrinting()) + return; + + if(ExtUI::isPrintingPaused()) { + wait.wait(F("Resume printing...")); + ExtUI::resumePrint(); + } + else{ + wait.wait(F("Pause printing...")); + ExtUI::pausePrint(); + } } //! Advanced Pause for filament change -void Print::advanced_pause_command() -{ - if(!ExtUI::isPrinting()) - return; - - wait.wait(F("Pausing...")); - core.inject_commands(F("M600")); -} +void Print::advanced_pause_command() { + if(!ExtUI::isPrinting()) + return; -//! Process Stop (A1) code and actually stop the print (if any running). -void Print::process_stop_code() -{ - ExtUI::stopPrint(); - - status.set(F("Print Stopped")); - pages.show_back_page(); - pages.show_back_page(); -} - -//! Process Pause (A0) code and actually pause the print (if any running). -void Print::process_pause_resume_code() -{ - core.inject_commands(F("M600")); + wait.wait(F("Pausing...")); + core.inject_commands(F("M600")); } -void Print::pause_finished() -{ - pages.show_back_page(); -} - - } diff --git a/Marlin/src/advi3pp/screens/print/print.h b/Marlin/src/advi3pp/screens/print/print.h index e05a01bb3b..5cb802f8a2 100644 --- a/Marlin/src/advi3pp/screens/print/print.h +++ b/Marlin/src/advi3pp/screens/print/print.h @@ -20,27 +20,28 @@ #pragma once -#include "../core/screen.h" +#include "../../core/screen.h" namespace ADVi3pp { //! Printing Page -struct Print: Screen -{ - void process_pause_resume_code(); - void process_stop_code(); - void pause_finished(); +struct Print: Screen { + static constexpr Page PAGE = Page::Print; + static constexpr Action ACTION = Action::Print; private: - bool do_dispatch(KeyValue value); - Page do_prepare_page(); - void stop_command(); - bool cancel_abort_print(); - bool abort_print(); - void pause_resume_command(); - void advanced_pause_command(); - - friend Parent; + bool on_dispatch(KeyValue value); + void on_enter(); + + void stop_command(); + bool cancel_abort_print(); + bool abort_print(); + void pause_resume_command(); + void advanced_pause_command(); + +private: + + friend Parent; }; extern Print print; diff --git a/Marlin/src/advi3pp/screens/print/print_settings.cpp b/Marlin/src/advi3pp/screens/print/print_settings.cpp new file mode 100644 index 0000000000..2318271180 --- /dev/null +++ b/Marlin/src/advi3pp/screens/print/print_settings.cpp @@ -0,0 +1,132 @@ +/** + * ADVi3++ Firmware For Wanhao Duplicator i3 Plus (based on Marlin 2) + * + * Copyright (C) 2017-2022 Sebastien Andrivet [https://github.com/andrivet/] + * + * This program 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. + * + * This program 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 this program. If not, see . + * + */ + +#include "../../parameters.h" +#include "print_settings.h" +#include "../../core/dgus.h" + +namespace ADVi3pp { + +PrintSettings print_settings; + + +//! Handle Print Settings command +//! @param key_value The sub-action to handle +//! @return True if the action was handled +bool PrintSettings::on_dispatch(KeyValue key_value) { + if(Parent::on_dispatch(key_value)) + return true; + return true; +} + +//! Handle the -Feedrate command +void PrintSettings::feedrate_minus_command() { + auto feedrate = ExtUI::getFeedrate_percent(); + if(feedrate <= 50) + return; + + ExtUI::setFeedrate_percent(feedrate - 1); +} + +//! Handle the +Feedrate command +void PrintSettings::feedrate_plus_command() { + auto feedrate = ExtUI::getFeedrate_percent(); + if(feedrate >= 150) + return; + + ExtUI::setFeedrate_percent(feedrate + 1); +} + +//! Handle the -Flowrate command +void PrintSettings::flowrate_minus_command() { + auto flowrate = ExtUI::getFlow_percent(ExtUI::E0); + if(flowrate <= 50) + return; + + ExtUI::setFlow_percent(flowrate - 1, ExtUI::E0); +} + +//! Handle the +Flowrate command +void PrintSettings::flowrate_plus_command() { + auto flowrate = ExtUI::getFlow_percent(ExtUI::E0); + if(flowrate >= 150) + return; + + ExtUI::setFlow_percent(flowrate + 1, ExtUI::E0); +} + + +//! Handle the -Fan command +void PrintSettings::fan_minus_command() { + auto speed = ExtUI::getTargetFan_percent(ExtUI::FAN0); + if(speed <= 0) + return; + + speed = speed <= 5 ? 0 : speed - 5; + ExtUI::setTargetFan_percent(speed, ExtUI::FAN0); +} + +//! Handle the +Fan command +void PrintSettings::fan_plus_command() { + auto speed = ExtUI::getTargetFan_percent(ExtUI::FAN0); + if(speed >= 100) + return; + + speed = speed >= 100 - 5 ? 100 : speed + 5; + ExtUI::setTargetFan_percent(speed, ExtUI::FAN0); +} + +//! Handle the -Hotend Temperature command +void PrintSettings::hotend_minus_command() { + auto temperature = ExtUI::getTargetTemp_celsius(ExtUI::E0); + if(temperature <= 0) + return; + + ExtUI::setTargetTemp_celsius(temperature - 1, ExtUI::E0); +} + +//! Handle the +Hotend Temperature command +void PrintSettings::hotend_plus_command() { + auto temperature = ExtUI::getTargetTemp_celsius(ExtUI::E0); + if(temperature >= 300) + return; + + ExtUI::setTargetTemp_celsius(temperature + 1, ExtUI::E0); +} + +//! Handle the -Bed Temperature command +void PrintSettings::bed_minus_command() { + auto temperature = ExtUI::getTargetTemp_celsius(ExtUI::BED); + if(temperature <= 0) + return; + + ExtUI::setTargetTemp_celsius(temperature - 1, ExtUI::BED); +} + +//! Handle the +Bed Temperature command +void PrintSettings::bed_plus_command() { + auto temperature = ExtUI::getTargetTemp_celsius(ExtUI::BED); + if(temperature >= 180) + return; + + ExtUI::setTargetTemp_celsius(temperature + 1, ExtUI::BED); +} + +} diff --git a/Marlin/src/advi3pp/screens/print/change_filament.h b/Marlin/src/advi3pp/screens/print/print_settings.h similarity index 60% rename from Marlin/src/advi3pp/screens/print/change_filament.h rename to Marlin/src/advi3pp/screens/print/print_settings.h index a2c8b242b0..bcc84c47ab 100644 --- a/Marlin/src/advi3pp/screens/print/change_filament.h +++ b/Marlin/src/advi3pp/screens/print/print_settings.h @@ -20,19 +20,32 @@ #pragma once -#include "../core/screen.h" +#include "../../core/screen.h" namespace ADVi3pp { -//! Change Filament Page -struct ChangeFilament: Screen -{ +//! Print Settings Page +struct PrintSettings: Screen { + static constexpr Page PAGE = Page::PrintSettings; + static constexpr Action ACTION = Action::PrintSettings; + + void feedrate_minus_command(); + void feedrate_plus_command(); + void flowrate_minus_command(); + void flowrate_plus_command(); + void fan_minus_command(); + void fan_plus_command(); + void hotend_minus_command(); + void hotend_plus_command(); + void bed_minus_command(); + void bed_plus_command(); + private: - Page do_prepare_page(); + bool on_dispatch(KeyValue value); friend Parent; }; -extern ChangeFilament change_filament; +extern PrintSettings print_settings; } diff --git a/Marlin/src/advi3pp/screens/print/sd_card.cpp b/Marlin/src/advi3pp/screens/print/sd_card.cpp index 87f6267b3b..e3e171352e 100755 --- a/Marlin/src/advi3pp/screens/print/sd_card.cpp +++ b/Marlin/src/advi3pp/screens/print/sd_card.cpp @@ -31,163 +31,195 @@ SdCard sd_card; //! Execute a SD Card command //! @param key_value The sub-action to handle //! @return True if the action was handled -bool SdCard::do_dispatch(KeyValue key_value) -{ - if(Parent::do_dispatch(key_value)) - return true; - - switch(key_value) - { - case KeyValue::SDUp: up_command(); break; - case KeyValue::SDDown: down_command(); break; - case KeyValue::SDParent: parent_command(); break; - case KeyValue::SDLine1: - case KeyValue::SDLine2: - case KeyValue::SDLine3: - case KeyValue::SDLine4: - case KeyValue::SDLine5: - select_command(static_cast(key_value) - 1); break; - default: return false; - } - +bool SdCard::on_dispatch(KeyValue key_value) { + if(Parent::on_dispatch(key_value)) return true; + + switch(key_value) { + case KeyValue::SDUp: up_command(); break; + case KeyValue::SDDown: down_command(); break; + case KeyValue::SDParent: parent_command(); break; + case KeyValue::SDLine1: + case KeyValue::SDLine2: + case KeyValue::SDLine3: + case KeyValue::SDLine4: + case KeyValue::SDLine5: + select_command(static_cast(key_value) - 1); break; + default: return false; + } + + return true; } //! Prepare the page before being displayed and return the right Page value //! @return The index of the page to display -Page SdCard::do_prepare_page() -{ - show_first_page(); - return Page::SdCard; +void SdCard::on_enter() { + show_initial(); } //! Show first SD card page -void SdCard::show_first_page() -{ - if(!ExtUI::isMediaInserted()) - return; +void SdCard::show_initial() { + ExtUI::mountMedia(); + status.reset(); - page_index_ = 0; - nb_files_ = files_.count(); - last_file_index_ = nb_files_ > 0 ? nb_files_ - 1 : 0; + if(!ExtUI::isMediaInserted() || !ExtUI::isMediaMounted()) { + show_empty(); + return; + } - show_current_page(); + files_.refresh(); + show_folder_first_page(); +} + +//! Show first SD card page +void SdCard::show_folder_first_page() { + page_index_ = 0; + show_folder_current_page(); +} + +bool SdCard::check_media() { + if(ExtUI::isMediaInserted() && ExtUI::isMediaMounted()) + return true; + show_empty(); + return false; } //! Handle Page Down command. -void SdCard::down_command() -{ - if(!ExtUI::isMediaInserted()) - return; +void SdCard::down_command() { + if(!check_media()) + return; + + if(files_.count() <= page_index_ * NB_VISIBLE_SD_FILES + NB_VISIBLE_SD_FILES) + return; - if(last_file_index_ >= nb_visible_sd_files) - { - page_index_ += 1; - last_file_index_ -= nb_visible_sd_files; - show_current_page(); - } + page_index_ += 1; + show_folder_current_page(); } //! Handle Page Up command. -void SdCard::up_command() -{ - if(!ExtUI::isMediaInserted()) - return; +void SdCard::up_command() { + if(!check_media()) + return; + + if(page_index_ <= 0) + return; - if(last_file_index_ + nb_visible_sd_files < nb_files_) - { - page_index_ -= 1; - last_file_index_ += nb_visible_sd_files; - show_current_page(); - } + page_index_ -= 1; + show_folder_current_page(); } //! Handle Page Up command. -void SdCard::parent_command() -{ - if(!ExtUI::isMediaInserted() || files_.isAtRootDir()) - return; +void SdCard::parent_command() { + if(!check_media()) + return; - files_.upDir(); - files_.refresh(); - show_first_page(); + if( files_.isAtRootDir()) + return; + + files_.upDir(); + files_.refresh(); + show_folder_current_page(); } //! Show the list of files on SD (current page) -void SdCard::show_current_page() -{ - ADVString<48> name; - FileType file_type = FileType::None; +void SdCard::show_folder_current_page() { + ADVString<48> name; + FileType file_type = FileType::None; + + for(uint8_t index = 0; index < NB_VISIBLE_SD_FILES; ++index) { + get_file_name(index, name, file_type); + Log::log() << index << static_cast(file_type) << name.get() << Log::endl(); + + auto var = static_cast(static_cast(Variable::LongText0) + 24 * index); + WriteRamRequest{var}.write_text(name); - for(uint8_t index = 0; index < nb_visible_sd_files; ++index) - { - get_file_name(index, name, file_type); + var = static_cast(static_cast(Variable::Value0) + index); + WriteRamRequest{var}.write_word(static_cast(file_type)); + } - auto var = static_cast(static_cast(Variable::LongText0) + 24 * index); - WriteRamRequest{var}.write_text(name); + auto nb_pages = (files_.count() + NB_VISIBLE_SD_FILES - 1) / NB_VISIBLE_SD_FILES; + WriteRamRequest{Variable::Value5}.write_words(page_index_ + 1, nb_pages <= 0 ? 1 : nb_pages); +} + +void SdCard::show_empty() { + page_index_ = 0; + + ADVString<48> name; + FileType file_type = FileType::None; + + for(uint8_t index = 0; index < NB_VISIBLE_SD_FILES; ++index) { + auto var = static_cast(static_cast(Variable::LongText0) + 24 * index); + WriteRamRequest{var}.write_text(name); - var = static_cast(static_cast(Variable::Value0) + index); - WriteRamRequest{var}.write_word(static_cast(file_type)); - } + var = static_cast(static_cast(Variable::Value0) + index); + WriteRamRequest{var}.write_word(static_cast(file_type)); + } - WriteRamRequest{Variable::Value5}.write_words( - page_index_ + 1, - (files_.count() + nb_visible_sd_files - 1) / nb_visible_sd_files - ); + WriteRamRequest{Variable::Value5}.write_words(0, 0); } //! Get a filename with a given index. //! @param index Index of the filename //! @param name Copy the filename into this Chars -void SdCard::get_file_name(uint8_t index_in_page, ADVString<48>& name, FileType &type) -{ - name.reset(); - type = FileType::None; - - if(last_file_index_ >= index_in_page) - { - ExtUI::FileList files{}; - files.seek(last_file_index_ - index_in_page); - name += files.filename(); - type = files.isDir() ? FileType::Folder : FileType::File; - } +void SdCard::get_file_name(uint8_t index_in_page, ADVString<48>& name, FileType &type) { + name.reset(); + type = FileType::None; + + auto absolute_index = index_in_page + page_index_ * NB_VISIBLE_SD_FILES; + if(absolute_index < files_.count()) { + ExtUI::FileList files{}; + files.seek(absolute_index); + name += files.filename(); + type = files.isDir() ? FileType::Folder : FileType::File; + } } //! Select a filename as sent by the LCD screen. //! @param file_index The index of the filename to select -void SdCard::select_command(uint16_t file_index) -{ - if(!ExtUI::isMediaInserted()) - return; - - if(file_index > last_file_index_) - return; +void SdCard::select_command(uint16_t file_index) { + if(!check_media()) + return; + + auto absolute_index = file_index + page_index_ * NB_VISIBLE_SD_FILES; + if(absolute_index >= files_.count()) + return; + + files_.seek(absolute_index); + + const char* filename = files_.shortFilename(); + if(filename == nullptr) { // If the SD card is not readable + ExtUI::onMediaOpenError(filename); + return; + } + + if(files_.isDir()) + select_directory(); + else + select_file(); +} - files_.seek(last_file_index_ - file_index); +void SdCard::select_file() { + status.set_filename(files_.filename()); + ExtUI::printFile(files_.shortFilename()); + pages.show(Page::Print, Action::Print); +} - const char* filename = files_.shortFilename(); - if(filename == nullptr) // If the SD card is not readable - { - ExtUI::onMediaOpenError(filename); - return; - } +void SdCard::select_directory() { + files_.changeDir(files_.shortFilename()); + files_.refresh(); + show_folder_first_page(); +} - if(files_.isDir()) - select_directory(); - else - select_file(); +void SdCard::on_media_inserted() { + show_initial(); } -void SdCard::select_file() { - status.set_filename(files_.filename()); - ExtUI::printFile(files_.shortFilename()); - pages.show(Page::Print); +void SdCard::on_media_removed() { + show_empty(); } -void SdCard::select_directory() { - files_.changeDir(files_.shortFilename()); - files_.refresh(); - show_first_page(); +void SdCard::on_media_error() { + show_empty(); } } \ No newline at end of file diff --git a/Marlin/src/advi3pp/screens/print/sd_card.h b/Marlin/src/advi3pp/screens/print/sd_card.h index c0cd74bbe1..c586361630 100644 --- a/Marlin/src/advi3pp/screens/print/sd_card.h +++ b/Marlin/src/advi3pp/screens/print/sd_card.h @@ -21,38 +21,45 @@ #pragma once #include "../../core/string.h" -#include "../core/screen.h" +#include "../../core/screen.h" namespace ADVi3pp { //! SD Card Page -struct SdCard: Screen -{ - enum class FileType { None, File, Folder }; +struct SdCard: Screen { + static constexpr Page PAGE = Page::SdCard; + static constexpr Action ACTION = Action::SdCard; - void show_first_page(); + enum class FileType { None, File, Folder }; + + void on_media_inserted(); + void on_media_removed(); + void on_media_error(); private: - bool do_dispatch(KeyValue value); - Page do_prepare_page(); - void show_current_page(); - void get_file_name(uint8_t index_in_page, ADVString<48>& name, FileType &type); - void up_command(); - void down_command(); - void parent_command(); - void select_command(uint16_t file_index); - void select_file(); - void select_directory(); + bool on_dispatch(KeyValue value); + void on_enter(); + + void show_initial(); + void show_folder_first_page(); + void show_folder_current_page(); + void show_empty(); + void get_file_name(uint8_t index_in_page, ADVString<48>& name, FileType &type); + void up_command(); + void down_command(); + void parent_command(); + void select_command(uint16_t file_index); + void select_file(); + void select_directory(); + bool check_media(); private: - static constexpr uint16_t nb_visible_sd_files = 5; //!< Number of files per page on the SD screen + static constexpr uint16_t NB_VISIBLE_SD_FILES = 5; //!< Number of files per page on the SD screen - uint16_t nb_files_ = 0; - uint16_t last_file_index_ = 0; - uint16_t page_index_ = 0; - ExtUI::FileList files_{}; + uint16_t page_index_ = 0; + ExtUI::FileList files_{}; - friend Parent; + friend Parent; }; extern SdCard sd_card; diff --git a/Marlin/src/advi3pp/screens/print/temperatures.cpp b/Marlin/src/advi3pp/screens/print/temperatures.cpp index 9578032689..d7e17bba6f 100644 --- a/Marlin/src/advi3pp/screens/print/temperatures.cpp +++ b/Marlin/src/advi3pp/screens/print/temperatures.cpp @@ -26,39 +26,28 @@ namespace ADVi3pp { Temperatures temperatures; -//! Prepare the page before being displayed and return the right Page value -//! @return The index of the page to display -Page Temperatures::do_prepare_page() -{ - return Page::Temperature; -} - //! Show the temperature page and record and action to be executed when the back button is pressed //! @param back Action to be executed when the back button is pressed -void Temperatures::show(const Callback& back) -{ - back_ = back; - Parent::show(); +void Temperatures::show(const Callback& back) { + back_ = back; + Parent::show(); } //! Show the temperature page //! @param options Options when displaying the page (i.e. save the current page or not) -void Temperatures::show() -{ - back_ = nullptr; - Parent::show(); +void Temperatures::show() { + back_ = nullptr; + Parent::show(); } //! Execute the Back command -void Temperatures::do_back_command() -{ - if(back_) - { - back_(); - back_ = nullptr; - } +void Temperatures::on_back_command() { + if(back_) { + back_(); + back_ = nullptr; + } - Parent::do_back_command(); + Parent::on_back_command(); } } diff --git a/Marlin/src/advi3pp/screens/print/temperatures.h b/Marlin/src/advi3pp/screens/print/temperatures.h index 9325c5eb16..7d5934a834 100644 --- a/Marlin/src/advi3pp/screens/print/temperatures.h +++ b/Marlin/src/advi3pp/screens/print/temperatures.h @@ -21,23 +21,25 @@ #pragma once #include "../../core/task.h" -#include "../core/screen.h" +#include "../../core/screen.h" namespace ADVi3pp { //! Temperatures Graph -struct Temperatures: Screen -{ - void show(const Callback& back); - void show(); +struct Temperatures: Screen { + static constexpr Page PAGE = Page::Temperature; + static constexpr Action ACTION = Action::Temperatures; + + void show(const Callback& back); + void show(); private: - Page do_prepare_page(); - void do_back_command(); + void on_back_command(); - Callback back_; +private: + Callback back_; - friend Parent; + friend Parent; }; extern Temperatures temperatures; diff --git a/Marlin/src/advi3pp/screens/settings/acceleration_settings.cpp b/Marlin/src/advi3pp/screens/settings/acceleration_settings.cpp index 62b7b98bd9..0e456af4bf 100644 --- a/Marlin/src/advi3pp/screens/settings/acceleration_settings.cpp +++ b/Marlin/src/advi3pp/screens/settings/acceleration_settings.cpp @@ -28,50 +28,46 @@ AccelerationSettings accelerations_settings; //! Prepare the page before being displayed and return the right Page value //! @return The index of the page to display -Page AccelerationSettings::do_prepare_page() -{ - WriteRamRequest{Variable::Value0}.write_words( - ExtUI::getAxisMaxAcceleration_mm_s2(ExtUI::X), - ExtUI::getAxisMaxAcceleration_mm_s2(ExtUI::Y), - ExtUI::getAxisMaxAcceleration_mm_s2(ExtUI::Z), - ExtUI::getAxisMaxAcceleration_mm_s2(ExtUI::E0), - ExtUI::getPrintingAcceleration_mm_s2(), - ExtUI::getRetractAcceleration_mm_s2(), - ExtUI::getTravelAcceleration_mm_s2(), - ExtUI::getJunctionDeviation_mm() * 1000 - ); - return Page::AccelerationSettings; +void AccelerationSettings::on_enter() { + WriteRamRequest{Variable::Value0}.write_words( + ExtUI::getAxisMaxAcceleration_mm_s2(ExtUI::X), + ExtUI::getAxisMaxAcceleration_mm_s2(ExtUI::Y), + ExtUI::getAxisMaxAcceleration_mm_s2(ExtUI::Z), + ExtUI::getAxisMaxAcceleration_mm_s2(ExtUI::E0), + ExtUI::getPrintingAcceleration_mm_s2(), + ExtUI::getRetractAcceleration_mm_s2(), + ExtUI::getTravelAcceleration_mm_s2(), + ExtUI::getJunctionDeviation_mm() * 1000 + ); } //! Save the Acceleration settings -void AccelerationSettings::do_save_command() -{ - ReadRam response{Variable::Value0}; - if(!response.send_receive(8)) - { - Log::error() << F("Receiving Frame (Acceleration Settings)") << Log::endl(); - return; - } +void AccelerationSettings::on_save_command() { + ReadRam response{Variable::Value0}; + if(!response.send_receive(8)) { + Log::error() << F("Receiving Frame (Acceleration Settings)") << Log::endl(); + return; + } - uint16_t x = response.read_word(); - uint16_t y = response.read_word(); - uint16_t z = response.read_word(); - uint16_t e = response.read_word(); - uint16_t print = response.read_word(); - uint16_t retract = response.read_word(); - uint16_t travel = response.read_word(); - uint16_t deviation = response.read_word(); + uint16_t x = response.read_word(); + uint16_t y = response.read_word(); + uint16_t z = response.read_word(); + uint16_t e = response.read_word(); + uint16_t print = response.read_word(); + uint16_t retract = response.read_word(); + uint16_t travel = response.read_word(); + uint16_t deviation = response.read_word(); - ExtUI::setAxisMaxAcceleration_mm_s2(static_cast(x), ExtUI::X); - ExtUI::setAxisMaxAcceleration_mm_s2(static_cast(y), ExtUI::Y); - ExtUI::setAxisMaxAcceleration_mm_s2(static_cast(z), ExtUI::Z); - ExtUI::setAxisMaxAcceleration_mm_s2(static_cast(e), ExtUI::E0); - ExtUI::setPrintingAcceleration_mm_s2(static_cast(print)); - ExtUI::setRetractAcceleration_mm_s2(static_cast(retract)); - ExtUI::setTravelAcceleration_mm_s2(static_cast(travel)); - ExtUI::setJunctionDeviation_mm(static_cast(deviation / 1000.0)); + ExtUI::setAxisMaxAcceleration_mm_s2(static_cast(x), ExtUI::X); + ExtUI::setAxisMaxAcceleration_mm_s2(static_cast(y), ExtUI::Y); + ExtUI::setAxisMaxAcceleration_mm_s2(static_cast(z), ExtUI::Z); + ExtUI::setAxisMaxAcceleration_mm_s2(static_cast(e), ExtUI::E0); + ExtUI::setPrintingAcceleration_mm_s2(static_cast(print)); + ExtUI::setRetractAcceleration_mm_s2(static_cast(retract)); + ExtUI::setTravelAcceleration_mm_s2(static_cast(travel)); + ExtUI::setJunctionDeviation_mm(static_cast(deviation / 1000.0)); - Parent::do_save_command(); + Parent::on_save_command(); } } diff --git a/Marlin/src/advi3pp/screens/settings/acceleration_settings.h b/Marlin/src/advi3pp/screens/settings/acceleration_settings.h index 634a123260..acaa691580 100644 --- a/Marlin/src/advi3pp/screens/settings/acceleration_settings.h +++ b/Marlin/src/advi3pp/screens/settings/acceleration_settings.h @@ -20,18 +20,21 @@ #pragma once -#include "../core/screen.h" +#include "../../core/screen.h" namespace ADVi3pp { //! Acceleration Settings Page -struct AccelerationSettings: Screen -{ +struct AccelerationSettings: Screen { + static constexpr Page PAGE = Page::AccelerationSettings; + static constexpr Action ACTION = Action::AccelerationSettings; + private: - Page do_prepare_page(); - void do_save_command(); + void on_enter(); + void on_save_command(); - friend Parent; +private: + friend Parent; }; extern AccelerationSettings accelerations_settings; diff --git a/Marlin/src/advi3pp/screens/settings/beeper_settings.cpp b/Marlin/src/advi3pp/screens/settings/beeper_settings.cpp index 4aee4d4018..e3a2514417 100755 --- a/Marlin/src/advi3pp/screens/settings/beeper_settings.cpp +++ b/Marlin/src/advi3pp/screens/settings/beeper_settings.cpp @@ -31,12 +31,11 @@ BeeperSettings beeper_settings; //! Handle command //! @param key_value The sub-action to handle //! @return True if the action was handled -bool BeeperSettings::do_dispatch(KeyValue key_value) { - if(Parent::do_dispatch(key_value)) +bool BeeperSettings::on_dispatch(KeyValue key_value) { + if(Parent::on_dispatch(key_value)) return true; - switch(key_value) - { + switch(key_value) { case KeyValue::BuzzOnAction: on_action_command(); break; case KeyValue::BuzzOnPress: on_press_command(); break; default: return false; @@ -47,33 +46,29 @@ bool BeeperSettings::do_dispatch(KeyValue key_value) { //! Prepare the page before being displayed and return the right Page value //! @return The index of the page to display -Page BeeperSettings::do_prepare_page() -{ +void BeeperSettings::on_enter() { buzz_on_action_ = buzzer.is_buzz_on_action_enabled(); buzz_on_press_ = buzzer.is_buzz_on_press_enabled(); auto buzz_duration = buzzer.get_buzz_duration(); send_values(buzz_on_action_, buzz_on_press_, buzz_duration); - return Page::BuzzerSettings; } -void BeeperSettings::do_save_command() { +void BeeperSettings::on_save_command() { bool on_action, on_press; uint8_t duration; if(get_values(on_action, on_press, duration)) buzzer.set_settings(on_action, on_press, duration); - Parent::do_save_command(); + Parent::on_save_command(); } -void BeeperSettings::send_values(bool on_action, bool on_press, uint8_t duration) const -{ +void BeeperSettings::send_values(bool on_action, bool on_press, uint8_t duration) const { WriteRamRequest{Variable::Value0}.write_words(on_action, on_press); WriteRamRequest{Variable::BeepDuration}.write_words(duration * 10ul); } bool BeeperSettings::get_values(bool &on_action, bool &on_press, uint8_t &duration) { ReadRam frame{Variable::Value0}; - if(!frame.send_receive(2)) - { + if(!frame.send_receive(2)) { Log::error() << F("Receiving Frame (Buzzer ExtendedSettings)") << Log::endl(); return false; } @@ -82,8 +77,7 @@ bool BeeperSettings::get_values(bool &on_action, bool &on_press, uint8_t &durati on_press = frame.read_word(); ReadRam frame2{Variable::BeepDuration}; - if(!frame2.send_receive(1)) - { + if(!frame2.send_receive(1)) { Log::error() << F("Receiving Frame (Buzzer ExtendedSettings)") << Log::endl(); return false; } @@ -94,8 +88,7 @@ bool BeeperSettings::get_values(bool &on_action, bool &on_press, uint8_t &durati } //! Handle the change duration command. -void BeeperSettings::duration_command(uint16_t duration) -{ +void BeeperSettings::duration_command(uint16_t duration) { buzzer.buzz(duration / 10); } diff --git a/Marlin/src/advi3pp/screens/settings/beeper_settings.h b/Marlin/src/advi3pp/screens/settings/beeper_settings.h index d6e750f636..145f2a94c8 100644 --- a/Marlin/src/advi3pp/screens/settings/beeper_settings.h +++ b/Marlin/src/advi3pp/screens/settings/beeper_settings.h @@ -20,28 +20,32 @@ #pragma once -#include "../core/screen.h" +#include "../../core/screen.h" #include "../../core/buzzer.h" namespace ADVi3pp { //! Beeper Setting Page -struct BeeperSettings: Screen -{ +struct BeeperSettings: Screen { + static constexpr Page PAGE = Page::BuzzerSettings; + static constexpr Action ACTION = Action::BuzzerSettings; + void duration_command(uint16_t duration); private: - friend Parent; + bool on_dispatch(KeyValue key_value); + void on_enter(); + void on_save_command(); - bool do_dispatch(KeyValue key_value); - Page do_prepare_page(); - void do_save_command(); void send_values(bool on_action, bool on_press, uint8_t duration) const; bool get_values(bool &on_action, bool &on_press, uint8_t &duration); void on_action_command(); void on_press_command(); + friend Parent; + +private: bool buzz_on_action_ = true; bool buzz_on_press_ = false; }; diff --git a/Marlin/src/advi3pp/screens/settings/eeprom_mismatch.cpp b/Marlin/src/advi3pp/screens/settings/eeprom_mismatch.cpp index a08f451b5d..00725f1749 100755 --- a/Marlin/src/advi3pp/screens/settings/eeprom_mismatch.cpp +++ b/Marlin/src/advi3pp/screens/settings/eeprom_mismatch.cpp @@ -25,18 +25,10 @@ namespace ADVi3pp { EepromMismatch eeprom_mismatch; -//! Prepare the page before being displayed and return the right Page value -//! @return The index of the page to display -Page EepromMismatch::do_prepare_page() -{ - return Page::EEPROMMismatch; -} - //! Handles the Save (Continue) command -void EepromMismatch::do_save_command() -{ - settings.save(); - pages.show(Page::Setup); +void EepromMismatch::on_save_command() { + settings.save(); + pages.show(Page::Setup, Action::Setup); } } diff --git a/Marlin/src/advi3pp/screens/settings/eeprom_mismatch.h b/Marlin/src/advi3pp/screens/settings/eeprom_mismatch.h index d1cb6caf75..3b8c39cf99 100644 --- a/Marlin/src/advi3pp/screens/settings/eeprom_mismatch.h +++ b/Marlin/src/advi3pp/screens/settings/eeprom_mismatch.h @@ -20,18 +20,19 @@ #pragma once -#include "../core/screen.h" +#include "../../core/screen.h" namespace ADVi3pp { //! EEPROM Mismatch Page -struct EepromMismatch: Screen -{ +struct EepromMismatch: Screen { + static constexpr Page PAGE = Page::EEPROMMismatch; + static constexpr Action ACTION = Action::EEPROMMismatch; + private: - Page do_prepare_page(); - void do_save_command(); + void on_save_command(); - friend Parent; + friend Parent; }; extern EepromMismatch eeprom_mismatch; diff --git a/Marlin/src/advi3pp/screens/settings/factory_reset.cpp b/Marlin/src/advi3pp/screens/settings/factory_reset.cpp index e8afbf4829..8a06cbf8b7 100644 --- a/Marlin/src/advi3pp/screens/settings/factory_reset.cpp +++ b/Marlin/src/advi3pp/screens/settings/factory_reset.cpp @@ -26,18 +26,12 @@ namespace ADVi3pp { FactoryReset factory_reset; -//! Prepare the page before being displayed and return the right Page value -//! @return The index of the page to display -Page FactoryReset::do_prepare_page() -{ - return Page::FactoryReset; -} - //! Handles the Save (Continue) command -void FactoryReset::do_save_command() -{ - ExtUI::resetSettings(); - ExtUI::saveSettings(); +void FactoryReset::on_save_command() { + ExtUI::resetSettings(); + ExtUI::saveSettings(); + ExtUI::setAllAxisUnhomed(); + ExtUI::setAllAxisPositionUnknown(); } } diff --git a/Marlin/src/advi3pp/screens/settings/factory_reset.h b/Marlin/src/advi3pp/screens/settings/factory_reset.h index b29dcbbb4a..8bf8d66c9e 100644 --- a/Marlin/src/advi3pp/screens/settings/factory_reset.h +++ b/Marlin/src/advi3pp/screens/settings/factory_reset.h @@ -20,18 +20,19 @@ #pragma once -#include "../core/screen.h" +#include "../../core/screen.h" namespace ADVi3pp { //! Factory Reset Page -struct FactoryReset: Screen -{ +struct FactoryReset: Screen { + static constexpr Page PAGE = Page::FactoryReset; + static constexpr Action ACTION = Action::FactoryReset; + private: - Page do_prepare_page(); - void do_save_command(); + void on_save_command(); - friend Parent; + friend Parent; }; extern FactoryReset factory_reset; diff --git a/Marlin/src/advi3pp/screens/settings/feedrate_settings.cpp b/Marlin/src/advi3pp/screens/settings/feedrate_settings.cpp index 7e4f12e2ea..38289b15ae 100644 --- a/Marlin/src/advi3pp/screens/settings/feedrate_settings.cpp +++ b/Marlin/src/advi3pp/screens/settings/feedrate_settings.cpp @@ -28,44 +28,40 @@ FeedrateSettings feedrates_settings; //! Prepare the page before being displayed and return the right Page value //! @return The index of the page to display -Page FeedrateSettings::do_prepare_page() -{ - WriteRamRequest{Variable::Value0}.write_words( - ExtUI::getAxisMaxFeedrate_mm_s(ExtUI::X), - ExtUI::getAxisMaxFeedrate_mm_s(ExtUI::Y), - ExtUI::getAxisMaxFeedrate_mm_s(ExtUI::Z), - ExtUI::getAxisMaxFeedrate_mm_s(ExtUI::E0), - ExtUI::getMinFeedrate_mm_s(), - ExtUI::getMinTravelFeedrate_mm_s() - ); - return Page::FeedrateSettings; +void FeedrateSettings::on_enter() { + WriteRamRequest{Variable::Value0}.write_words( + ExtUI::getAxisMaxFeedrate_mm_s(ExtUI::X), + ExtUI::getAxisMaxFeedrate_mm_s(ExtUI::Y), + ExtUI::getAxisMaxFeedrate_mm_s(ExtUI::Z), + ExtUI::getAxisMaxFeedrate_mm_s(ExtUI::E0), + ExtUI::getMinFeedrate_mm_s(), + ExtUI::getMinTravelFeedrate_mm_s() + ); } //! Save the Feedrate settings -void FeedrateSettings::do_save_command() -{ - ReadRam response{Variable::Value0}; - if(!response.send_receive(6)) - { - Log::error() << F("Receiving Frame (Feedrate Settings)") << Log::endl(); - return; - } +void FeedrateSettings::on_save_command() { + ReadRam response{Variable::Value0}; + if(!response.send_receive(6)) { + Log::error() << F("Receiving Frame (Feedrate Settings)") << Log::endl(); + return; + } - uint16_t x = response.read_word(); - uint16_t y = response.read_word(); - uint16_t z = response.read_word(); - uint16_t e = response.read_word(); - uint16_t min = response.read_word(); - uint16_t travel = response.read_word(); + uint16_t x = response.read_word(); + uint16_t y = response.read_word(); + uint16_t z = response.read_word(); + uint16_t e = response.read_word(); + uint16_t min = response.read_word(); + uint16_t travel = response.read_word(); - ExtUI::setAxisMaxFeedrate_mm_s(static_cast(x), ExtUI::X); - ExtUI::setAxisMaxFeedrate_mm_s(static_cast(y), ExtUI::Y); - ExtUI::setAxisMaxFeedrate_mm_s(static_cast(z), ExtUI::Z); - ExtUI::setAxisMaxFeedrate_mm_s(static_cast(e), ExtUI::E0); - ExtUI::setMinFeedrate_mm_s(static_cast(min)); - ExtUI::setMinTravelFeedrate_mm_s(static_cast(travel)); + ExtUI::setAxisMaxFeedrate_mm_s(static_cast(x), ExtUI::X); + ExtUI::setAxisMaxFeedrate_mm_s(static_cast(y), ExtUI::Y); + ExtUI::setAxisMaxFeedrate_mm_s(static_cast(z), ExtUI::Z); + ExtUI::setAxisMaxFeedrate_mm_s(static_cast(e), ExtUI::E0); + ExtUI::setMinFeedrate_mm_s(static_cast(min)); + ExtUI::setMinTravelFeedrate_mm_s(static_cast(travel)); - Parent::do_save_command(); + Parent::on_save_command(); } } diff --git a/Marlin/src/advi3pp/screens/settings/feedrate_settings.h b/Marlin/src/advi3pp/screens/settings/feedrate_settings.h index 713f673d3b..eb26232413 100644 --- a/Marlin/src/advi3pp/screens/settings/feedrate_settings.h +++ b/Marlin/src/advi3pp/screens/settings/feedrate_settings.h @@ -20,18 +20,20 @@ #pragma once -#include "../core/screen.h" +#include "../../core/screen.h" namespace ADVi3pp { //! Feedrate Settings Page -struct FeedrateSettings: Screen -{ +struct FeedrateSettings: Screen { + static constexpr Page PAGE = Page::FeedrateSettings; + static constexpr Action ACTION = Action::FeedrateSettings; + private: - Page do_prepare_page(); - void do_save_command(); + void on_enter(); + void on_save_command(); - friend Parent; + friend Parent; }; extern FeedrateSettings feedrates_settings; diff --git a/Marlin/src/advi3pp/screens/settings/lcd_settings.cpp b/Marlin/src/advi3pp/screens/settings/lcd_settings.cpp index 5a314bdb51..78fd48f415 100755 --- a/Marlin/src/advi3pp/screens/settings/lcd_settings.cpp +++ b/Marlin/src/advi3pp/screens/settings/lcd_settings.cpp @@ -31,14 +31,13 @@ LcdSettings lcd_settings; //! Handle LCD ExtendedSettings command //! @param key_value The sub-action to handle //! @return True if the action was handled -bool LcdSettings::do_dispatch(KeyValue key_value) { - if(Parent::do_dispatch(key_value)) +bool LcdSettings::on_dispatch(KeyValue key_value) { + if(Parent::on_dispatch(key_value)) return true; - switch(key_value) - { - case KeyValue::LCDDimming: dimming_command(); break; - default: return false; + switch(key_value) { + case KeyValue::LCDDimming: dimming_command(); break; + default: return false; } return true; @@ -46,26 +45,29 @@ bool LcdSettings::do_dispatch(KeyValue key_value) { //! Prepare the page before being displayed and return the right Page value //! @return The index of the page to display -Page LcdSettings::do_prepare_page() { +void LcdSettings::on_enter() { dimming_ = dimming.is_enabled(); auto dimming_time = dimming.get_dimming_time(); auto normal_brightness = dimming.get_normal_brightness(); auto dimming_brightness = dimming.get_dimming_brightness(); send_values(dimming_time, normal_brightness, dimming_brightness); - return Page::LCD; } -void LcdSettings::do_back_command() { +void LcdSettings::on_back_command() { dimming.send_brightness_to_lcd(); // Restore previous brightness - Parent::do_back_command(); + Parent::on_back_command(); } -void LcdSettings::do_save_command() { +void LcdSettings::on_abort() { + dimming.send_brightness_to_lcd(); // Restore previous brightness +} + +void LcdSettings::on_save_command() { uint16_t dimming_time; uint8_t normal_brightness, dimming_brightness; if(get_values(dimming_time, normal_brightness, dimming_brightness)) dimming.set_settings(dimming_, dimming_time, normal_brightness, dimming_brightness); dimming.send_brightness_to_lcd(); - Parent::do_save_command(); + Parent::on_save_command(); } void LcdSettings::send_values(uint16_t time, uint8_t normal, uint8_t dimmed) { @@ -75,16 +77,14 @@ void LcdSettings::send_values(uint16_t time, uint8_t normal, uint8_t dimmed) { bool LcdSettings::get_values(uint16_t &time, uint8_t &normal, uint8_t &dimmed) const { ReadRam frame{Variable::Value1}; - if(!frame.send_receive(1)) - { + if(!frame.send_receive(1)) { Log::error() << F("Receiving Frame (Dimming time)") << Log::endl(); return false; } time = frame.read_word(); ReadRam frame2{Variable::NormalBrightness}; - if(!frame2.send_receive(2)) - { + if(!frame2.send_receive(2)) { Log::error() << F("Receiving Frame (brightness)") << Log::endl(); return false; } diff --git a/Marlin/src/advi3pp/screens/settings/lcd_settings.h b/Marlin/src/advi3pp/screens/settings/lcd_settings.h index d108e87958..1cda7b745f 100644 --- a/Marlin/src/advi3pp/screens/settings/lcd_settings.h +++ b/Marlin/src/advi3pp/screens/settings/lcd_settings.h @@ -20,33 +20,39 @@ #pragma once -#include "../core/screen.h" +#include "../../core/screen.h" namespace ADVi3pp { //! LCD Setting Page -struct LcdSettings: Screen -{ - void normal_brightness_command(uint16_t brightness); - void dimming_brightness_command(uint16_t brightness); +struct LcdSettings: Screen { + static constexpr Page PAGE = Page::LCD; + static constexpr Action ACTION = Action::LCD; - bool receive(); - void send(); - void sleep_on(); - void sleep_off(); + void normal_brightness_command(uint16_t brightness); + void dimming_brightness_command(uint16_t brightness); + + bool receive(); + void send(); + void sleep_on(); + void sleep_off(); private: - friend Parent; - bool do_dispatch(KeyValue key_value); - Page do_prepare_page(); - void do_back_command(); - void do_save_command(); - void dimming_command(); - void send_values(uint16_t time, uint8_t normal, uint8_t dimmed); - bool get_values(uint16_t &time, uint8_t &normal, uint8_t &dimmed) const; + bool on_dispatch(KeyValue key_value); + void on_enter(); + void on_back_command(); + void on_save_command(); + void on_abort(); + + void dimming_command(); + void send_values(uint16_t time, uint8_t normal, uint8_t dimmed); + bool get_values(uint16_t &time, uint8_t &normal, uint8_t &dimmed) const; - bool dimming_ = false; + friend Parent; + +private: + bool dimming_ = false; }; extern LcdSettings lcd_settings; diff --git a/Marlin/src/advi3pp/screens/settings/linear_advance_settings.cpp b/Marlin/src/advi3pp/screens/settings/linear_advance_settings.cpp index e828e9d59d..404f3b8b68 100644 --- a/Marlin/src/advi3pp/screens/settings/linear_advance_settings.cpp +++ b/Marlin/src/advi3pp/screens/settings/linear_advance_settings.cpp @@ -28,26 +28,22 @@ LinearAdvanceSettings linear_advance_settings; //! Prepare the page before being displayed and return the right Page value //! @return The index of the page to display -Page LinearAdvanceSettings::do_prepare_page() -{ - WriteRamRequest{Variable::Value0}.write_word(ExtUI::getLinearAdvance_mm_mm_s(ExtUI::E0) * 100); - return Page::LinearAdvanceSettings; +void LinearAdvanceSettings::on_enter() { + WriteRamRequest{Variable::Value0}.write_word(lround(ExtUI::getLinearAdvance_mm_mm_s(ExtUI::E0) * 100.0)); } //! Handles the Save (Continue) command -void LinearAdvanceSettings::do_save_command() -{ - ReadRam response{Variable::Value0}; - if(!response.send_receive(1)) - { - Log::error() << F("Receiving Frame (Linear Advance Settings)") << Log::endl(); - return; - } - - uint16_t k = response.read_word(); - ExtUI::setLinearAdvance_mm_mm_s(k / 100.0, ExtUI::E0); - - Parent::do_save_command(); +void LinearAdvanceSettings::on_save_command() { + ReadRam response{Variable::Value0}; + if(!response.send_receive(1)) { + Log::error() << F("Receiving Frame (Linear Advance Settings)") << Log::endl(); + return; + } + + uint16_t k = response.read_word(); + ExtUI::setLinearAdvance_mm_mm_s(k / 100.0, ExtUI::E0); + + Parent::on_save_command(); } } diff --git a/Marlin/src/advi3pp/screens/settings/linear_advance_settings.h b/Marlin/src/advi3pp/screens/settings/linear_advance_settings.h index 914806ba58..2bab2d3764 100644 --- a/Marlin/src/advi3pp/screens/settings/linear_advance_settings.h +++ b/Marlin/src/advi3pp/screens/settings/linear_advance_settings.h @@ -20,18 +20,21 @@ #pragma once -#include "../core/screen.h" +#include "../../core/screen.h" namespace ADVi3pp { //! Linear Advance Settings Page -struct LinearAdvanceSettings: Screen -{ +struct LinearAdvanceSettings: Screen { + static constexpr Page PAGE = Page::LinearAdvanceSettings; + static constexpr Action ACTION = Action::LinearAdvanceSettings; + private: - Page do_prepare_page(); - void do_save_command(); + void on_enter(); + void on_save_command(); - friend Parent; +private: + friend Parent; }; extern LinearAdvanceSettings linear_advance_settings; diff --git a/Marlin/src/advi3pp/screens/settings/pid_settings.cpp b/Marlin/src/advi3pp/screens/settings/pid_settings.cpp index 31e79cb706..3e910e382f 100755 --- a/Marlin/src/advi3pp/screens/settings/pid_settings.cpp +++ b/Marlin/src/advi3pp/screens/settings/pid_settings.cpp @@ -32,123 +32,111 @@ PidSettings pid_settings; //! Handle PID Settings command //! @param key_value The sub-action to handle //! @return True if the action was handled -bool PidSettings::do_dispatch(KeyValue key_value) -{ - if(Parent::do_dispatch(key_value)) - return true; - - switch(key_value) - { - case KeyValue::PidSettingsHotend: hotend_command(); break; - case KeyValue::PidSettingsBed: bed_command(); break; - case KeyValue::PidSettingPrevious: previous_command(); break; - case KeyValue::PidSettingNext: next_command(); break; - default: return false; - } - +bool PidSettings::on_dispatch(KeyValue key_value) { + if(Parent::on_dispatch(key_value)) return true; + + switch(key_value) { + case KeyValue::PidSettingsHotend: hotend_command(); break; + case KeyValue::PidSettingsBed: bed_command(); break; + case KeyValue::PidSettingPrevious: previous_command(); break; + case KeyValue::PidSettingNext: next_command(); break; + default: return false; + } + + return true; } //! Handle the select Hotend PID command -void PidSettings::hotend_command() -{ - from_lcd(); - kind_ = TemperatureKind::Hotend; - to_lcd(); +void PidSettings::hotend_command() { + from_lcd(); + kind_ = TemperatureKind::Hotend; + to_lcd(); } //! Handle the select Bed PID command -void PidSettings::bed_command() -{ - from_lcd(); - kind_ = TemperatureKind::Bed; - to_lcd(); +void PidSettings::bed_command() { + from_lcd(); + kind_ = TemperatureKind::Bed; + to_lcd(); } //! Handle the show previous PID values command -void PidSettings::previous_command() -{ - if(index_ <= 0) - return; - from_lcd(); - index_ -= 1; - to_lcd(); +void PidSettings::previous_command() { + if(index_ <= 0) + return; + from_lcd(); + index_ -= 1; + to_lcd(); } //! Handle the show next PID values command -void PidSettings::next_command() -{ - if(index_ >= Pid::NB_PIDs - 1) - return; - from_lcd(); - index_ += 1; - to_lcd(); +void PidSettings::next_command() { + if(index_ >= Pid::NB_PIDs - 1) + return; + from_lcd(); + index_ += 1; + to_lcd(); } //! Prepare the page before being displayed and return the right Page value //! @return The index of the page to display -Page PidSettings::do_prepare_page() -{ - to_lcd(); - return Page::PidSettings; +void PidSettings::on_enter() { + to_lcd(); } //! Save the PID settings -void PidSettings::do_save_command() -{ - from_lcd(); - assert(kind_ <= TemperatureKind::Hotend); - pid.set_marlin_pid(kind_, index_); - Parent::do_save_command(); +void PidSettings::on_save_command() { + from_lcd(); + assert(kind_ <= TemperatureKind::Hotend); + pid.set_marlin_pid(kind_, index_); + Parent::on_save_command(); } //! Execute the Back command -void PidSettings::do_back_command() -{ - settings.restore(); - Parent::do_back_command(); +void PidSettings::on_back_command() { + settings.restore(); + Parent::on_back_command(); } //! Send the current data to the LCD panel. -void PidSettings::to_lcd() const -{ - const PidValue& value = pid.get_pid(kind_, index_); - WriteRamRequest{Variable::Value0}.write_words( - kind_ == TemperatureKind::Hotend ? 0u : 1u, - value.temperature_, - value.Kp_ * 100, - value.Ki_ * 100, - value.Kd_ * 100 - ); - - ADVString<8> indexes; - indexes << index_ + 1 << F(" / ") << Pid::NB_PIDs; - WriteRamRequest{Variable::ShortText0}.write_text(indexes); +void PidSettings::to_lcd() const { + const PidValue& value = pid.get_pid(kind_, index_); + WriteRamRequest{Variable::Value0}.write_words( + kind_ == TemperatureKind::Hotend ? 0u : 1u, + value.temperature_, + value.Kp_ * 100, + value.Ki_ * 100, + value.Kd_ * 100 + ); + + ADVString<8> indexes; + indexes << index_ + 1 << F(" / ") << Pid::NB_PIDs; + WriteRamRequest{Variable::ShortText0}.write_text(indexes); } //! Save the settings from the LCD Panel. -void PidSettings::from_lcd() -{ - ReadRam response{Variable::Value0}; - if(!response.send_receive(5)) - return; - - uint16_t kind = response.read_word(); - uint16_t temperature = response.read_word(); - uint16_t p = response.read_word(); - uint16_t i = response.read_word(); - uint16_t d = response.read_word(); - - kind_ = kind ? TemperatureKind::Bed : TemperatureKind::Hotend; - PidValue& value = pid.get_pid(kind_, index_); - - value.Kp_ = static_cast(p) / 100; - value.Ki_ = static_cast(i) / 100; - value.Kd_ = static_cast(d) / 100; - value.temperature_ = temperature; - - pid.set_marlin_pid(kind_, index_); +void PidSettings::from_lcd() { + ReadRam response{Variable::Value0}; + if(!response.send_receive(5)) + return; + + uint16_t kind = response.read_word(); + uint16_t temperature = response.read_word(); + uint16_t p = response.read_word(); + uint16_t i = response.read_word(); + uint16_t d = response.read_word(); + + kind_ = kind ? TemperatureKind::Bed : TemperatureKind::Hotend; + PidValue& value = pid.get_pid(kind_, index_); + + value.Kp_ = static_cast(p) / 100; + value.Ki_ = static_cast(i) / 100; + value.Kd_ = static_cast(d) / 100; + value.temperature_ = temperature; + + pid.set_marlin_pid(kind_, index_); } diff --git a/Marlin/src/advi3pp/screens/settings/pid_settings.h b/Marlin/src/advi3pp/screens/settings/pid_settings.h index fc541cbecf..02e5ade707 100644 --- a/Marlin/src/advi3pp/screens/settings/pid_settings.h +++ b/Marlin/src/advi3pp/screens/settings/pid_settings.h @@ -21,32 +21,35 @@ #pragma once #include "../../lib/ADVstd/array.h" -#include "../core/screen.h" +#include "../../core/screen.h" namespace ADVi3pp { -struct PidSettings: Screen -{ +struct PidSettings: Screen { + static constexpr Page PAGE = Page::PidSettings; + static constexpr Action ACTION = Action::PidSettings; + private: - bool do_dispatch(KeyValue key_value); - Page do_prepare_page(); - void do_save_command(); - void do_back_command(); - void save_bed_pid() const; - void hotend_command(); - void save_hotend_pid() const; - void bed_command(); - void previous_command(); - void next_command(); - void to_lcd() const; - void from_lcd(); + bool on_dispatch(KeyValue key_value); + void on_enter(); + void on_save_command(); + void on_back_command(); + + void save_bed_pid() const; + void hotend_command(); + void save_hotend_pid() const; + void bed_command(); + void previous_command(); + void next_command(); + void to_lcd() const; + void from_lcd(); private: - TemperatureKind kind_ = TemperatureKind::Hotend; - uint8_t index_ = 0; + TemperatureKind kind_ = TemperatureKind::Hotend; + uint8_t index_ = 0; - friend Parent; + friend Parent; }; extern PidSettings pid_settings; diff --git a/Marlin/src/advi3pp/screens/settings/print_settings.cpp b/Marlin/src/advi3pp/screens/settings/print_settings.cpp deleted file mode 100644 index 25f6c5f83f..0000000000 --- a/Marlin/src/advi3pp/screens/settings/print_settings.cpp +++ /dev/null @@ -1,186 +0,0 @@ -/** - * ADVi3++ Firmware For Wanhao Duplicator i3 Plus (based on Marlin 2) - * - * Copyright (C) 2017-2022 Sebastien Andrivet [https://github.com/andrivet/] - * - * This program 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. - * - * This program 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 this program. If not, see . - * - */ - -#include "../../parameters.h" -#include "print_settings.h" -#include "../../core/dgus.h" - -namespace ADVi3pp { - -//! List of multipliers in Print Settings -const double BABYSTEPS_MULTIPLIERS[] = {0.02, 0.05, 0.10}; - -PrintSettings print_settings; - - -//! Handle Print Settings command -//! @param key_value The sub-action to handle -//! @return True if the action was handled -bool PrintSettings::do_dispatch(KeyValue key_value) -{ - if(Parent::do_dispatch(key_value)) - return true; - - switch(key_value) - { - case KeyValue::Baby1: multiplier_ = Multiplier::M1; break; - case KeyValue::Baby2: multiplier_ = Multiplier::M2; break; - case KeyValue::Baby3: multiplier_ = Multiplier::M3; break; - case KeyValue::Save: save_babysteps(); break; - default: return false; - } - - send_data(); - return true; -} - -//! Get the value corresponding the the current multiplier. -//! @return The value of the current multiplier, or the first one in the case of an invalid multiplier -double PrintSettings::get_multiplier_value() const -{ - if(multiplier_ < Multiplier::M1 || multiplier_ > Multiplier::M3) - { - Log::error() << F("Invalid multiplier value: ") << static_cast(multiplier_) << Log::endl(); - return BABYSTEPS_MULTIPLIERS[0]; - } - - return BABYSTEPS_MULTIPLIERS[static_cast(multiplier_)]; -} - -//! Send the current data to the LCD panel. -void PrintSettings::send_data() const -{ - WriteRamRequest{Variable::Value0}.write_words(multiplier_, offset_); -} - -//! Prepare the page before being displayed and return the right Page value -//! @return The index of the page to display -Page PrintSettings::do_prepare_page() -{ - send_data(); - return Page::PrintSettings; -} - -//! Handle the -Feedrate command -void PrintSettings::feedrate_minus_command() -{ - auto feedrate = ExtUI::getFeedrate_percent(); - if(feedrate <= 50) - return; - - ExtUI::setFeedrate_percent(feedrate - 1); -} - -//! Handle the +Feedrate command -void PrintSettings::feedrate_plus_command() -{ - auto feedrate = ExtUI::getFeedrate_percent(); - if(feedrate >= 150) - return; - - ExtUI::setFeedrate_percent(feedrate + 1); -} - -//! Handle the -Fan command -void PrintSettings::fan_minus_command() -{ - auto speed = ExtUI::getTargetFan_percent(ExtUI::FAN0); - if(speed <= 0) - return; - - speed = speed <= 5 ? 0 : speed - 5; - ExtUI::setTargetFan_percent(speed, ExtUI::FAN0); -} - -//! Handle the +Fan command -void PrintSettings::fan_plus_command() -{ - auto speed = ExtUI::getTargetFan_percent(ExtUI::FAN0); - if(speed >= 100) - return; - - speed = speed >= 100 - 5 ? 100 : speed + 5; - ExtUI::setTargetFan_percent(speed, ExtUI::FAN0); -} - -//! Handle the -Hotend Temperature command -void PrintSettings::hotend_minus_command() -{ - auto temperature = ExtUI::getTargetTemp_celsius(ExtUI::E0); - if(temperature <= 0) - return; - - ExtUI::setTargetTemp_celsius(temperature - 1, ExtUI::E0); -} - -//! Handle the +Hotend Temperature command -void PrintSettings::hotend_plus_command() -{ - auto temperature = ExtUI::getTargetTemp_celsius(ExtUI::E0); - if(temperature >= 300) - return; - - ExtUI::setTargetTemp_celsius(temperature + 1, ExtUI::E0); -} - -//! Handle the -Bed Temperature command -void PrintSettings::bed_minus_command() -{ - auto temperature = ExtUI::getTargetTemp_celsius(ExtUI::BED); - if(temperature <= 0) - return; - - ExtUI::setTargetTemp_celsius(temperature - 1, ExtUI::BED); -} - -//! Handle the +Bed Temperature command -void PrintSettings::bed_plus_command() -{ - auto temperature = ExtUI::getTargetTemp_celsius(ExtUI::BED); - if(temperature >= 180) - return; - - ExtUI::setTargetTemp_celsius(temperature + 1, ExtUI::BED); -} - -//! Handle the -Babystep command -void PrintSettings::baby_minus_command() -{ - auto distance = -ExtUI::mmToWholeSteps(get_multiplier_value(), ExtUI::Z); - ExtUI::smartAdjustAxis_steps(distance, ExtUI::Z, true); - offset_ -= static_cast(get_multiplier_value() * 100); - send_data(); -} - -//! Handle the +Babystep command -void PrintSettings::baby_plus_command() -{ - auto distance = ExtUI::mmToWholeSteps(get_multiplier_value(), ExtUI::Z); - ExtUI::smartAdjustAxis_steps(distance, ExtUI::Z, true); - offset_ += static_cast(get_multiplier_value() * 100); - send_data(); -} - -void PrintSettings::save_babysteps() -{ - settings.save(); -} - -} diff --git a/Marlin/src/advi3pp/screens/settings/print_settings.h b/Marlin/src/advi3pp/screens/settings/print_settings.h deleted file mode 100644 index 8a7c447fa6..0000000000 --- a/Marlin/src/advi3pp/screens/settings/print_settings.h +++ /dev/null @@ -1,61 +0,0 @@ -/** - * ADVi3++ Firmware For Wanhao Duplicator i3 Plus (based on Marlin 2) - * - * Copyright (C) 2017-2022 Sebastien Andrivet [https://github.com/andrivet/] - * - * This program 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. - * - * This program 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 this program. If not, see . - * - */ - -#pragma once - -#include "../core/screen.h" - -namespace ADVi3pp { - -//! Print Settings Page -struct PrintSettings: Screen -{ - void feedrate_minus_command(); - void feedrate_plus_command(); - void fan_minus_command(); - void fan_plus_command(); - void hotend_minus_command(); - void hotend_plus_command(); - void bed_minus_command(); - void bed_plus_command(); - void baby_minus_command(); - void baby_plus_command(); - - enum class Multiplier: uint8_t { M1 = 0, M2 = 1, M3 = 2 }; - -protected: - bool do_dispatch(KeyValue value); - -private: - Page do_prepare_page(); - void send_data() const; - double get_multiplier_value() const; - void save_babysteps(); - -private: - Multiplier multiplier_ = Multiplier::M1; - uint16_t offset_ = 0; - - friend Parent; -}; - -extern PrintSettings print_settings; - -} diff --git a/Marlin/src/advi3pp/screens/settings/runout_settings.cpp b/Marlin/src/advi3pp/screens/settings/runout_settings.cpp index 70f77df7f3..f3f0fbe52a 100755 --- a/Marlin/src/advi3pp/screens/settings/runout_settings.cpp +++ b/Marlin/src/advi3pp/screens/settings/runout_settings.cpp @@ -31,105 +31,93 @@ RunoutSettings runout_settings; //! Handle LCD Settings command //! @param key_value The sub-action to handle //! @return True if the action was handled -bool RunoutSettings::do_dispatch(KeyValue key_value) -{ - if(Parent::do_dispatch(key_value)) - return true; - - switch(key_value) - { - case KeyValue::RunoutEnable: enable_command(); break; - case KeyValue::RunoutHigh2Low: high2low_command(); break; - case KeyValue::RunoutLow2High: low2high_command(); break; - default: return false; - } - - return true; +bool RunoutSettings::on_dispatch(KeyValue key_value) { + if(Parent::on_dispatch(key_value)) + return true; + + switch(key_value) { + case KeyValue::RunoutEnable: enable_command(); break; + case KeyValue::RunoutHigh2Low: high2low_command(); break; + case KeyValue::RunoutLow2High: low2high_command(); break; + default: return false; + } + + return true; } //! Prepare the page before being displayed and return the right Page value //! @return The index of the page to display -Page RunoutSettings::do_prepare_page() -{ - inverted_ = ExtUI::getFilamentRunoutInverted(); +void RunoutSettings::on_enter() { + inverted_ = ExtUI::getFilamentRunoutInverted(); - WriteRamRequest{Variable::Value0}.write_words( - ExtUI::getFilamentRunoutEnabled(), - get_filament_state(), - ExtUI::getFilamentRunoutDistance_mm() * 10, - ExtUI::getFilamentRunoutInverted() ? 0 : 1 - ); + WriteRamRequest{Variable::Value0}.write_words( + ExtUI::getFilamentRunoutEnabled(), + get_filament_state(), + ExtUI::getFilamentRunoutDistance_mm() * 10, + ExtUI::getFilamentRunoutInverted() ? 0 : 1 + ); - background_task.set(Callback{this, &RunoutSettings::send_data}, 250); - - return Page::Runout; + background_task.set(Callback{this, &RunoutSettings::send_data}, 250); } -void RunoutSettings::do_back_command() -{ - background_task.clear(); - Parent::do_back_command(); +void RunoutSettings::on_back_command() { + background_task.clear(); + Parent::on_back_command(); } -void RunoutSettings::do_save_command() { - ReadRam response{Variable::Value0}; - if(!response.send_receive(4)) - { - Log::error() << F("Receiving Frame (Runout Settings)") << Log::endl(); - return; - } +void RunoutSettings::on_save_command() { + ReadRam response{Variable::Value0}; + if(!response.send_receive(4)) { + Log::error() << F("Receiving Frame (Runout Settings)") << Log::endl(); + return; + } - uint16_t enabled = response.read_word(); - [[maybe_unused]] uint16_t state = response.read_word(); - float distance = response.read_word() / 10.0f; - uint16_t trigger = response.read_word(); + uint16_t enabled = response.read_word(); + [[maybe_unused]] uint16_t state = response.read_word(); + float distance = response.read_word() / 10.0f; + uint16_t trigger = response.read_word(); - ExtUI::setFilamentRunoutEnabled(enabled == 1); - ExtUI::setFilamentRunoutDistance_mm(distance); - ExtUI::setFilamentRunoutInverted(trigger == 0); + ExtUI::setFilamentRunoutEnabled(enabled == 1); + ExtUI::setFilamentRunoutDistance_mm(distance); + ExtUI::setFilamentRunoutInverted(trigger == 0); - Parent::do_save_command(); + Parent::on_save_command(); } //! Handle the Enable/Disable command -void RunoutSettings::enable_command() -{ - ReadRam response{Variable::Value0}; - if(!response.send_receive(1)) - { - Log::error() << F("Receiving Frame (Runout Settings)") << Log::endl(); - return; - } - - WriteRamRequest{Variable::Value0}.write_word(!response.read_word()); +void RunoutSettings::enable_command() { + ReadRam response{Variable::Value0}; + if(!response.send_receive(1)) { + Log::error() << F("Receiving Frame (Runout Settings)") << Log::endl(); + return; + } + + WriteRamRequest{Variable::Value0}.write_word(!response.read_word()); } //! Handle the Trigger (High/Low) command -void RunoutSettings::high2low_command() -{ - inverted_ = false; - WriteRamRequest{Variable::Value3}.write_word(1); +void RunoutSettings::high2low_command() { + inverted_ = false; + WriteRamRequest{Variable::Value3}.write_word(1); } //! Handle the Trigger (Low/High) command -void RunoutSettings::low2high_command() -{ - inverted_ = true; - WriteRamRequest{Variable::Value3}.write_word(0); +void RunoutSettings::low2high_command() { + inverted_ = true; + WriteRamRequest{Variable::Value3}.write_word(0); } uint16_t RunoutSettings::get_filament_state() { auto pin_state = Core::get_pin_state(FIL_RUNOUT_PIN); - return inverted_ ? - (pin_state == Core::PinState::On ? 0: 1) : - (pin_state == Core::PinState::On ? 1 : 0); + return inverted_ ? + (pin_state == Core::PinState::On ? 0: 1) : + (pin_state == Core::PinState::On ? 1 : 0); } //! Send the current data to the LCD panel. -void RunoutSettings::send_data() -{ - WriteRamRequest{Variable::Value1}.write_word(get_filament_state()); +void RunoutSettings::send_data() { + WriteRamRequest{Variable::Value1}.write_word(get_filament_state()); } } diff --git a/Marlin/src/advi3pp/screens/settings/runout_settings.h b/Marlin/src/advi3pp/screens/settings/runout_settings.h index b5ce27bdab..cae949d54a 100755 --- a/Marlin/src/advi3pp/screens/settings/runout_settings.h +++ b/Marlin/src/advi3pp/screens/settings/runout_settings.h @@ -20,28 +20,31 @@ #pragma once -#include "../core/screen.h" +#include "../../core/screen.h" namespace ADVi3pp { //! Runout Setting Page -struct RunoutSettings: Screen -{ +struct RunoutSettings: Screen { + static constexpr Page PAGE = Page::Runout; + static constexpr Action ACTION = Action::Runout; + private: - bool do_dispatch(KeyValue key_value); - Page do_prepare_page(); - void do_back_command(); - void do_save_command(); - void enable_command(); - void high2low_command(); - void low2high_command(); - uint16_t get_filament_state(); - void send_data(); - - friend Parent; + bool on_dispatch(KeyValue key_value); + void on_enter(); + void on_back_command(); + void on_save_command(); + + void enable_command(); + void high2low_command(); + void low2high_command(); + uint16_t get_filament_state(); + void send_data(); + + friend Parent; private: - bool inverted_ = false; + bool inverted_ = false; }; extern RunoutSettings runout_settings; diff --git a/Marlin/src/advi3pp/screens/settings/sensor_settings.cpp b/Marlin/src/advi3pp/screens/settings/sensor_settings.cpp index bf8be2919c..c857a46a30 100755 --- a/Marlin/src/advi3pp/screens/settings/sensor_settings.cpp +++ b/Marlin/src/advi3pp/screens/settings/sensor_settings.cpp @@ -25,47 +25,45 @@ namespace ADVi3pp { -SensorSettings sensor_settings; - #ifdef ADVi3PP_PROBE +SensorSettings sensor_settings; + namespace { const size_t NB_SENSOR_POSITIONS = 3; } //! Get the name of a sensor holder //! @param index Index of the holder //! @return The name (in Flash memory) of the holder -const FlashChar* get_sensor_name(size_t index) -{ - // Note: F macro can be used only in a function, this is why this is coded like this - auto your = F("Your Sensor"); - auto teaching_tech_side = F("Teaching Tech Left"); - auto advi3pp = F("ADVi3++ Left"); +const FlashChar* get_sensor_name(size_t index) { + // Note: F macro can be used only in a function, this is why this is coded like this + auto your = F("Your Sensor"); + auto teaching_tech_side = F("Teaching Tech"); + auto advi3pp = F("ADVi3++"); #if defined(BLTOUCH) - auto baseggio = F("Indianagio Front"); - static const FlashChar* names[NB_SENSOR_POSITIONS + 1] = {your, baseggio, teaching_tech_side, advi3pp}; + auto baseggio = F("Indianagio"); + static const FlashChar* names[NB_SENSOR_POSITIONS + 1] = {your, baseggio, teaching_tech_side, advi3pp}; #elif defined(ADVi3PP_54) - auto mark2 = F("Mark II"); - static const FlashChar* names[NB_SENSOR_POSITIONS + 1] = {your, mark2, teaching_tech_side, advi3pp}; + auto mark2 = F("Mark II"); + static const FlashChar* names[NB_SENSOR_POSITIONS + 1] = {your, mark2, teaching_tech_side, advi3pp}; #else #error "ADVi3PP_PROBE is defined but the kind of probe is unknown" #endif - assert(index <= NB_SENSOR_POSITIONS); - return names[index]; + assert(index <= NB_SENSOR_POSITIONS); + return names[index]; } //! Default position of the sensor for the different holders -const SensorPosition SENSOR_POSITION[NB_SENSOR_POSITIONS] = -{ +const SensorPosition SENSOR_POSITION[NB_SENSOR_POSITIONS] = { #if ENABLED(BLTOUCH) - { +150, -4270 }, // Baseggio/Indianagio Front - { -2400, -3800 }, // Teaching Tech Left - { -2800, -4000 } // ADVi3++ Left + { +150, -4270 }, // Baseggio/Indianagio Front + { -2400, -3800 }, // Teaching Tech Left + { -2800, -4000 } // ADVi3++ Left #elif defined(ADVi3PP_54) - { 0, 6000 }, // Mark II - { -2400, -3800 }, // Teaching Tech Left - { -2800, -4000 } // ADVi3++ Left + { 0, 6000 }, // Mark II + { -2400, -3800 }, // Teaching Tech Left + { -2800, -4000 } // ADVi3++ Left #else #error "ADVi3PP_PROBE is defined but the kind of probe is unknown" #endif @@ -77,104 +75,100 @@ const SensorPosition SENSOR_POSITION[NB_SENSOR_POSITIONS] = //! Handle Sensor Settings command //! @param key_value The sub-action to handle //! @return True if the action was handled -bool SensorSettings::do_dispatch(KeyValue key_value) -{ - if(Parent::do_dispatch(key_value)) - return true; - - switch(key_value) - { - case KeyValue::SensorSettingsPrevious: previous_command(); break; - case KeyValue::SensorSettingsNext: next_command(); break; - default: return false; - } +bool SensorSettings::on_dispatch(KeyValue key_value) { + if(Parent::on_dispatch(key_value)) + return true; + + switch(key_value) { + case KeyValue::SensorSettingsPrevious: previous_command(); break; + case KeyValue::SensorSettingsNext: next_command(); break; + case KeyValue::SensorSettingsHighSpeed: highspeed_command(); break; + default: return false; + } return true; } //! Prepare the page before being displayed and return the right Page value //! @return The index of the page to display -Page SensorSettings::do_prepare_page() -{ - index_ = 0; - send_name(); - send_values(); - pages.save_forward_page(); - return Page::SensorSettings; +void SensorSettings::on_enter() { + index_ = 0; + highspeed_ = ExtUI::isLevelingHighSpeed(); + send_name(); + send_values(); + send_highspeed_value(); + pages.save_forward_page(); } //! Handles the Save (Continue) command -void SensorSettings::do_save_command() -{ - get_values(); - Parent::do_save_command(); +void SensorSettings::on_save_command() { + get_values(); + ExtUI::setLevelingHighSpeed(highspeed_); + Parent::on_save_command(); } //! Show the previous settings. -void SensorSettings::previous_command() -{ - if(index_ <= 0) - return; - index_ -= 1; - send_name(); - send_values(); +void SensorSettings::previous_command() { + if(index_ <= 0) return; + index_ -= 1; + send_name(); + send_values(); } //! Show the next settings. -void SensorSettings::next_command() -{ - if(index_ >= NB_SENSOR_POSITIONS) // not -1 because we have also index #0 not counted in NB_SENSOR_POSITIONS - return; - index_ += 1; - send_name(); - send_values(); +void SensorSettings::next_command() { + if(index_ >= NB_SENSOR_POSITIONS) // not -1 because we have also index #0 not counted in NB_SENSOR_POSITIONS + return; + index_ += 1; + send_name(); + send_values(); } -void SensorSettings::send_values() const -{ - if(index_ == 0) - WriteRamRequest{Variable::Value0}.write_words( - ExtUI::getProbeOffset_mm(ExtUI::X) * 100.0f, - ExtUI::getProbeOffset_mm(ExtUI::Y) * 100.0f - ); - else - WriteRamRequest{Variable::Value0}.write_words( - SENSOR_POSITION[index_ - 1].x, - SENSOR_POSITION[index_ - 1].y - ); +void SensorSettings::highspeed_command() { + highspeed_ = !highspeed_; + send_highspeed_value(); } -void SensorSettings::send_name() const -{ - ADVString<28> title{get_sensor_name(index_)}; - WriteRamRequest{Variable::LongTextCentered0}.write_centered_text(title); +void SensorSettings::send_highspeed_value() const { + WriteRamRequest{Variable::Value3}.write_word(highspeed_ ? 1 : 0); } -//! Get current data from the LCD Panel. -void SensorSettings::get_values() -{ - ReadRam frame{Variable::Value0}; - if(!frame.send_receive(2)) - { - Log::error() << F("Receiving Frame (Sensor Settings)") << Log::endl(); - return; - } - - int16_t x = frame.read_signed_word(); - int16_t y = frame.read_signed_word(); - - ExtUI::setProbeOffset_mm(x / 100.0f, ExtUI::X); - ExtUI::setProbeOffset_mm(y / 100.0f, ExtUI::Y); +void SensorSettings::send_values() const { + if(index_ == 0) + WriteRamRequest{Variable::Value0}.write_words( + lround(ExtUI::getProbeOffset_mm(ExtUI::X) * 100.0), + lround(ExtUI::getProbeOffset_mm(ExtUI::Y) * 100.0), + lround(ExtUI::getZOffset_mm() * 100.0) + ); + else + WriteRamRequest{Variable::Value0}.write_words( + SENSOR_POSITION[index_ - 1].x, + SENSOR_POSITION[index_ - 1].y, + lround(ExtUI::getZOffset_mm() * 100.0) + ); } -#else +void SensorSettings::send_name() const { + ADVString<14> title{get_sensor_name(index_)}; + WriteRamRequest{Variable::LongTextCentered0}.write_centered_text(title); +} -//! Prepare the page before being displayed and return the right Page value -//! @return The index of the page to display -Page SensorSettings::do_prepare_page() -{ - return Page::NoSensor; +//! Get current data from the LCD Panel. +void SensorSettings::get_values() { + ReadRam frame{Variable::Value0}; + if(!frame.send_receive(3)) { + Log::error() << F("Receiving Frame (Sensor Settings)") << Log::endl(); + return; + } + + int16_t x = frame.read_signed_word(); + int16_t y = frame.read_signed_word(); + int16_t z = frame.read_signed_word(); + + ExtUI::setProbeOffset_mm(x / 100.0f, ExtUI::X); + ExtUI::setProbeOffset_mm(y / 100.0f, ExtUI::Y); + ExtUI::setZOffset_mm(z / 100.0f); } #endif diff --git a/Marlin/src/advi3pp/screens/settings/sensor_settings.h b/Marlin/src/advi3pp/screens/settings/sensor_settings.h index 09d5fda506..c2d4a6ce8c 100644 --- a/Marlin/src/advi3pp/screens/settings/sensor_settings.h +++ b/Marlin/src/advi3pp/screens/settings/sensor_settings.h @@ -20,34 +20,42 @@ #pragma once -#include "../core/screen.h" +#include "../../core/screen.h" namespace ADVi3pp { +#ifdef ADVi3PP_PROBE + struct SensorPosition { int16_t x, y; }; //! Sensor Settings Page -struct SensorSettings: Screen -{ +struct SensorSettings: Screen { + static constexpr Page PAGE = Page::SensorSettings; + static constexpr Action ACTION = Action::SensorSettings; + private: - Page do_prepare_page(); + void on_enter(); -#ifdef ADVi3PP_PROBE - bool do_dispatch(KeyValue value); - void do_save_command(); - void previous_command(); - void next_command(); - void send_values() const; - void send_name() const; - void get_values(); -#endif + bool on_dispatch(KeyValue value); + void on_save_command(); + + void previous_command(); + void next_command(); + void highspeed_command(); + void send_values() const; + void send_name() const; + void get_values(); + void send_highspeed_value() const; private: - uint16_t index_ = 0; + uint16_t index_ = 0; + bool highspeed_ = false; - friend Parent; + friend Parent; }; extern SensorSettings sensor_settings; +#endif + } diff --git a/Marlin/src/advi3pp/screens/settings/skew_settings.cpp b/Marlin/src/advi3pp/screens/settings/skew_settings.cpp index ad2db2162b..d6130c1b0a 100644 --- a/Marlin/src/advi3pp/screens/settings/skew_settings.cpp +++ b/Marlin/src/advi3pp/screens/settings/skew_settings.cpp @@ -36,12 +36,11 @@ SkewSettings skew_settings; //! Execute a command //! @param key_value The sub-action to handle //! @return True if the action was handled -bool SkewSettings::do_dispatch(KeyValue key_value) { - if(Parent::do_dispatch(key_value)) +bool SkewSettings::on_dispatch(KeyValue key_value) { + if(Parent::on_dispatch(key_value)) return true; - switch(key_value) - { + switch(key_value) { case KeyValue::SkewStep2: step2(); break; case KeyValue::SkewStep3: step3(); break; default: return false; @@ -52,10 +51,9 @@ bool SkewSettings::do_dispatch(KeyValue key_value) { //! Prepare the page before being displayed and return the right Page value //! @return The index of the page to display -Page SkewSettings::do_prepare_page() { +void SkewSettings::on_enter() { pages.save_forward_page(); step1(); - return Page::Skew1Settings; } void SkewSettings::set_default_values() { @@ -69,13 +67,13 @@ void SkewSettings::step1() { void SkewSettings::step2() { xy_ = get_factor(); set_default_values(); - pages.show(Page::Skew2Settings); + pages.show(Page::Skew2, ACTION); } void SkewSettings::step3() { xz_ = get_factor(); set_default_values(); - pages.show(Page::Skew3Settings); + pages.show(Page::Skew3, ACTION); } float SkewSettings::get_factor() { @@ -93,7 +91,7 @@ float SkewSettings::get_factor() { } //! Save the settings -void SkewSettings::do_save_command() { +void SkewSettings::on_save_command() { float yz = get_factor(); if(abs(xy_) < 0.000001) xy_ = 0; if(abs(xz_) < 0.000001) xz_ = 0; @@ -105,7 +103,7 @@ void SkewSettings::do_save_command() { ) ExtUI::setSkewFactors(xy_, xz_, yz); - Parent::do_save_command(); + Parent::on_save_command(); } } diff --git a/Marlin/src/advi3pp/screens/settings/skew_settings.h b/Marlin/src/advi3pp/screens/settings/skew_settings.h index 20616f90b2..87d49a448b 100644 --- a/Marlin/src/advi3pp/screens/settings/skew_settings.h +++ b/Marlin/src/advi3pp/screens/settings/skew_settings.h @@ -20,16 +20,19 @@ #pragma once -#include "../core/screen.h" +#include "../../core/screen.h" namespace ADVi3pp { //! Skew Settings Page struct SkewSettings: Screen { + static constexpr Page PAGE = Page::Skew; + static constexpr Action ACTION = Action::Skew; + private: - bool do_dispatch(KeyValue key_value); - Page do_prepare_page(); - void do_save_command(); + bool on_dispatch(KeyValue key_value); + void on_enter(); + void on_save_command(); void step1(); void step2(); diff --git a/Marlin/src/advi3pp/screens/settings/step_settings.cpp b/Marlin/src/advi3pp/screens/settings/step_settings.cpp index 4af823f62d..d9eba7fb82 100644 --- a/Marlin/src/advi3pp/screens/settings/step_settings.cpp +++ b/Marlin/src/advi3pp/screens/settings/step_settings.cpp @@ -30,38 +30,34 @@ static const unsigned SCALE = 10; //! Prepare the page before being displayed and return the right Page value //! @return The index of the page to display -Page StepSettings::do_prepare_page() -{ - WriteRamRequest{Variable::Value0}.write_words( - ExtUI::getAxisSteps_per_mm(ExtUI::X) * SCALE, - ExtUI::getAxisSteps_per_mm(ExtUI::Y) * SCALE, - ExtUI::getAxisSteps_per_mm(ExtUI::Z) * SCALE, - ExtUI::getAxisSteps_per_mm(ExtUI::E0) * SCALE - ); - return Page::StepsSettings; +void StepSettings::on_enter() { + WriteRamRequest{Variable::Value0}.write_words( + ExtUI::getAxisSteps_per_mm(ExtUI::X) * SCALE, + ExtUI::getAxisSteps_per_mm(ExtUI::Y) * SCALE, + ExtUI::getAxisSteps_per_mm(ExtUI::Z) * SCALE, + ExtUI::getAxisSteps_per_mm(ExtUI::E0) * SCALE + ); } //! Save the Steps settings -void StepSettings::do_save_command() -{ - ReadRam response{Variable::Value0}; - if(!response.send_receive(4)) - { - Log::error() << F("Receiving Frame (Steps Settings)") << Log::endl(); - return; - } +void StepSettings::on_save_command() { + ReadRam response{Variable::Value0}; + if(!response.send_receive(4)) { + Log::error() << F("Receiving Frame (Steps Settings)") << Log::endl(); + return; + } - uint16_t x = response.read_word(); - uint16_t y = response.read_word(); - uint16_t z = response.read_word(); - uint16_t e = response.read_word(); + uint16_t x = response.read_word(); + uint16_t y = response.read_word(); + uint16_t z = response.read_word(); + uint16_t e = response.read_word(); - ExtUI::setAxisSteps_per_mm(static_cast(x) / SCALE, ExtUI::X); - ExtUI::setAxisSteps_per_mm(static_cast(y) / SCALE, ExtUI::Y); - ExtUI::setAxisSteps_per_mm(static_cast(z) / SCALE, ExtUI::Z); - ExtUI::setAxisSteps_per_mm(static_cast(e) / SCALE, ExtUI::E0); + ExtUI::setAxisSteps_per_mm(static_cast(x) / SCALE, ExtUI::X); + ExtUI::setAxisSteps_per_mm(static_cast(y) / SCALE, ExtUI::Y); + ExtUI::setAxisSteps_per_mm(static_cast(z) / SCALE, ExtUI::Z); + ExtUI::setAxisSteps_per_mm(static_cast(e) / SCALE, ExtUI::E0); - Parent::do_save_command(); + Parent::on_save_command(); } diff --git a/Marlin/src/advi3pp/screens/settings/step_settings.h b/Marlin/src/advi3pp/screens/settings/step_settings.h index 8849481d3b..2ef0a33396 100644 --- a/Marlin/src/advi3pp/screens/settings/step_settings.h +++ b/Marlin/src/advi3pp/screens/settings/step_settings.h @@ -20,18 +20,20 @@ #pragma once -#include "../core/screen.h" +#include "../../core/screen.h" namespace ADVi3pp { //! Step Settings Page -struct StepSettings: Screen -{ +struct StepSettings: Screen { + static constexpr Page PAGE = Page::StepsSettings; + static constexpr Action ACTION = Action::StepsSettings; + private: - Page do_prepare_page(); - void do_save_command(); + void on_enter(); + void on_save_command(); - friend Parent; + friend Parent; }; extern StepSettings steps_settings; diff --git a/Marlin/src/advi3pp/screens/tuning/bltouch_testing.cpp b/Marlin/src/advi3pp/screens/tuning/bltouch_testing.cpp index de0cb42721..bc5d24c23e 100755 --- a/Marlin/src/advi3pp/screens/tuning/bltouch_testing.cpp +++ b/Marlin/src/advi3pp/screens/tuning/bltouch_testing.cpp @@ -18,176 +18,202 @@ * */ +#ifdef BLTOUCH + #include "../../parameters.h" #include "../../core/core.h" #include "../../core/dgus.h" #include "../../core/status.h" +#include "../../core/wait.h" #include "bltouch_testing.h" +#include "../../../feature/bltouch.h" // Use directly the BLTouch class namespace ADVi3pp { BLTouchTesting bltouch_testing; +inline bool triggered() { return Z_MIN_ENDSTOP_INVERTING != READ(Z_MIN_PIN); } -#ifdef BLTOUCH - -void reset_bltouch_command() { core.inject_commands(F("M280 P0 S160")); } -void selftest_bltouch_command() { core.inject_commands(F("M280 P0 S120")); } +static void status_red_brown() { status.set(F("Check red (VCC) and brown (GND) wires")); } +static void status_orange() { status.set(F("Check the orange (Servo) wire")); } +static void status_white_black() { status.set(F("Check white (Z-stop) and black (GND) wires")); } +static void status_pin() { status.set(F("Check the pin of the BLTouch")); } -//! Execute acommand +//! Execute a command //! @param key_value The sub-action to handle //! @return True if the action was handled -bool BLTouchTesting::do_dispatch(KeyValue key_value) -{ - if(Parent::do_dispatch(key_value)) - return true; - - switch(key_value) - { - case KeyValue::BLTouchTestingStep1Yes: step1yes(); break; - case KeyValue::BLTouchTestingStep1No: step1no(); break; - case KeyValue::BLTouchTestingStep2Yes: step2yes(); break; - case KeyValue::BLTouchTestingStep2No: step2no(); break; - case KeyValue::BLTouchTestingStep3Yes: step3yes(); break; - case KeyValue::BLTouchTestingStep3No: step3no(); break; - default: return false; - } - +bool BLTouchTesting::on_dispatch(KeyValue key_value) { + if(Parent::on_dispatch(key_value)) return true; + + switch(key_value) { + case KeyValue::BLTouchTestingStep1aYes: step_1a_yes(); break; + case KeyValue::BLTouchTestingStep1aNo: step_1a_no(); break; + case KeyValue::BLTouchTestingStep1bSlow: step_1b_slow(); break; + case KeyValue::BLTouchTestingStep1bQuick: step_1b_quick(); break; + case KeyValue::BLTouchTestingStep1bNo: step_1b_no(); break; + case KeyValue::BLTouchTestingStep2Yes: step_2_yes(); break; + case KeyValue::BLTouchTestingStep2No: step_2_no(); break; + default: return false; + } + + return true; } //! Prepare the page before being displayed and return the right Page value //! @return The index of the page to display -Page BLTouchTesting::do_prepare_page() -{ - if(!core.ensure_not_printing()) - return Page::None; - pages.save_forward_page(); - step1(); - return Page::BLTouchTesting1; +void BLTouchTesting::on_enter() { + pages.save_forward_page(); + step_1a(); } -void BLTouchTesting::do_back_command() -{ - reset_bltouch_command(); - Parent::do_back_command(); +void BLTouchTesting::on_back_command() { + bltouch._reset();; + Parent::on_back_command(); } -void BLTouchTesting::do_save_command() -{ - // Do not call parent, there nothing to save - pages.show_forward_page(); +void BLTouchTesting::on_abort() { + bltouch._reset(); } -void BLTouchTesting::step1() -{ - status.reset(); - tested_ = ok_ = Wires::None; - set_bits(tested_, Wires::Brown | Wires::Red); - reset_bltouch_command(); +void BLTouchTesting::on_save_command() { + // Do not call parent, there nothing to save + pages.show_forward_page(); } -void BLTouchTesting::step1yes() -{ - set_bits(ok_, Wires::Brown | Wires::Red); - step2(); +//! Test if the BLTouch is powered +void BLTouchTesting::step_1a() { + wait.wait(F("Initialize the BLTouch...")); + tested_ = ok_ = Wires::None; + set_bits(tested_, Wires::Brown | Wires::Red); + bltouch._reset(); } -void BLTouchTesting::step1no() -{ - status.set(F("Problem with Red/Brown wiring")); - step4(); +void BLTouchTesting::step_1a_yes() { + step_1b(); } -void BLTouchTesting::step2() -{ - set_bits(tested_, Wires::Orange); - selftest_bltouch_command(); - pages.show(Page::BLTouchTesting2); +void BLTouchTesting::step_1a_no() { + status_red_brown(); + step_4(); } -void BLTouchTesting::step2yes() -{ - set_bits(ok_, Wires::Orange); - reset_bltouch_command(); - step3(); +//! Is the BLTouch blinking? +void BLTouchTesting::step_1b() { + pages.show(Page::BLTouchTesting1B, ACTION); } -void BLTouchTesting::step2no() -{ - reset_bltouch_command(); - status.set(F("Problem with Orange wiring")); - step4(); +void BLTouchTesting::step_1b_no() { + set_bits(ok_, Wires::Brown | Wires::Red); + step_2(); } -void BLTouchTesting::step3() -{ - ExtUI::delay_ms(500); +void BLTouchTesting::step_1b_slow() { + set_bits(tested_, Wires::Brown | Wires::Red); + status_red_brown(); + step_4(); +} - set_bits(tested_, Wires::White | Wires::Black); - pages.show(Page::BLTouchTesting3); - if(ExtUI::bltouchDeploy()) - { - status.set(F("Deployment of BLTouch failed")); - clear_bits(ok_, Wires::Orange); - step4(); - } +void BLTouchTesting::step_1b_quick() { + status_pin(); + step_4(); } -void BLTouchTesting::step3yes() -{ - if(digitalRead(Z_MIN_PIN) == HIGH) - set_bits(ok_, Wires::White | Wires::Black); - else - status.set(F("Are white and black wires inverted?")); - step4(); +//! BLTouch deploy and stow (self test) +void BLTouchTesting::step_2() { + set_bits(tested_, Wires::Orange); + pages.show(Page::BLTouchTesting2, ACTION); + bltouch._selftest(); } -void BLTouchTesting::step3no() -{ - status.set(F("Problem with white or black wires")); - step4(); +void BLTouchTesting::step_2_yes() { + set_bits(ok_, Wires::Orange); + step_3(); } -uint16_t BLTouchTesting::wire_value(Wires wire) -{ - return test_one_bit(ok_, wire) ? 1 : test_one_bit(tested_, wire) ? 2 : 0; +void BLTouchTesting::step_2_no() { + status_orange(); + step_4(); } -void BLTouchTesting::step4() -{ - ExtUI::bltouchStow(); +void BLTouchTesting::step_3() { + set_bits(tested_, Wires::White | Wires::Black); - auto brown = wire_value(Wires::Brown); - auto red = wire_value(Wires::Red); - auto orange = wire_value(Wires::Orange); - auto black = /*wire_value(Wires::Black);*/ true; // Temporary workaround - auto white = /*wire_value(Wires::White);*/ true; + wait.wait(F("Testing BLTouch triggering, please wait...")); - if(brown == 1 && red == 1 && orange == 1 && black == 1 && white == 1) - status.set(F("No problem detected with BLTouch")); + // Adapted from M43 code + // This code will try to detect a BLTouch probe + bltouch._reset(); + bltouch._stow(); + if(triggered()) { status_white_black(); step_4(); return; } - WriteRamRequest{Variable::Value0}.write_words( - brown, - red, - orange, - black, - white - ); + bltouch._set_SW_mode(); + if(!triggered()) { status_white_black(); step_4(); return; } - pages.show(Page::BLTouchTesting4); -} + bltouch._deploy(); + if(triggered()) { status_white_black(); step_4(); return; } -#else + bltouch._stow(); -//! Prepare the page before being displayed and return the right Page value -//! @return The index of the page to display -Page BLTouchTesting::do_prepare_page() -{ - return Page::NoSensor; + // BLTouch Classic 1.2, 1.3, Smart 1.0, 2.0, 2.2, 3.0, 3.1 detected + // Check for a 3.1 by letting the user trigger it, later + + bltouch._deploy(); + safe_delay(500); + + pages.show(Page::BLTouchTesting3, ACTION); + + // Wait 30 seconds for user to trigger probe + for(uint16_t j = 0; j < 500 * 30; j++) { + safe_delay(2); + + if(0 == j % (500 * 1)) gcode.reset_stepper_timeout(); // Keep steppers powered + + if(triggered()) { + uint16_t probe_counter = 0; // Pulse width / 2 + for(probe_counter = 0; probe_counter < 15 && triggered(); ++probe_counter) safe_delay(2); + Log::log() << F("BLTouch pulse width 0x") << probe_counter << Log::endl(); + + wait.wait(); + if(probe_counter < 4) { + status.set(F("Noise detected")); + step_4(); + return; + } + + status.set(probe_counter == 15 ? F("BLTouch 3.1 detected") : F("BLTouch V3.0 or lower detected")); + bltouch._stow(); + set_bits(ok_, Wires::White | Wires::Black); + step_4(); + return; + } + } + + status_white_black(); + step_4(); } -#endif +void BLTouchTesting::step_4() { + bltouch._reset(); + + auto brown = wire_value(Wires::Brown); + auto red = wire_value(Wires::Red); + auto orange = wire_value(Wires::Orange); + auto black = wire_value(Wires::Black); + auto white = wire_value(Wires::White); + WriteRamRequest{Variable::Value0}.write_words( + brown, + red, + orange, + black, + white + ); + + pages.show(Page::BLTouchTesting4, ACTION); } + +} + +#endif diff --git a/Marlin/src/advi3pp/screens/tuning/bltouch_testing.h b/Marlin/src/advi3pp/screens/tuning/bltouch_testing.h index af24bc2141..0a0c915689 100755 --- a/Marlin/src/advi3pp/screens/tuning/bltouch_testing.h +++ b/Marlin/src/advi3pp/screens/tuning/bltouch_testing.h @@ -21,58 +21,67 @@ #pragma once #include "../../lib/ADVstd/bitmasks.h" -#include "../core/screen.h" +#include "../../core/screen.h" namespace ADVi3pp { #ifdef BLTOUCH //! BLTouch Testing Page -struct BLTouchTesting: Screen -{ +struct BLTouchTesting: Screen { + static constexpr Page PAGE = Page::BLTouchTesting1A; + static constexpr Action ACTION = Action::BLTouchTesting; + private: - enum class Wires: uint8_t - { - None = 0b00000000, - Brown = 0b00000001, - Red = 0b00000010, - Orange = 0b00000100, - Black = 0b00001000, - White = 0b00010000 - }; + enum class Wires: uint8_t { + None = 0b00000000, + Brown = 0b00000001, + Red = 0b00000010, + Orange = 0b00000100, + Black = 0b00001000, + White = 0b00010000 + }; private: - bool do_dispatch(KeyValue key_value); - Page do_prepare_page(); - void do_back_command(); - void do_save_command(); - void step1(); - void step1yes(); - void step1no(); - void step2(); - void step2yes(); - void step2no(); - void step3(); - void step3yes(); - void step3no(); - void step4(); - uint16_t wire_value(Wires wire); + bool on_dispatch(KeyValue key_value); + void on_enter(); + void on_back_command(); + void on_save_command(); + void on_abort(); + + void step_1a(); + void step_1a_yes(); + void step_1a_no(); + void step_1b(); + void step_1b_slow(); + void step_1b_quick(); + void step_1b_no(); + void step_2(); + void step_2_yes(); + void step_2_no(); + void step_3(); + void step_4(); + void step_3_task(); + uint16_t wire_value(Wires wire); private: - Wires tested_ = Wires::None; - Wires ok_ = Wires::None; + Wires tested_ = Wires::None; + Wires ok_ = Wires::None; - friend Parent; + friend Parent; }; ENABLE_BITMASK_OPERATOR(BLTouchTesting::Wires); +inline uint16_t BLTouchTesting::wire_value(Wires wire) { + return test_one_bit(ok_, wire) ? 1 : test_one_bit(tested_, wire) ? 2 : 0; +} + #else //! BLTouch Testing Page -struct BLTouchTesting: Screen -{ +struct BLTouchTesting: Screen { private: - Page do_prepare_page(); - friend Parent; + static constexpr Page PAGE = Page::NoSensor; + friend Parent; }; #endif diff --git a/Marlin/src/advi3pp/screens/tuning/extruder_tuning.cpp b/Marlin/src/advi3pp/screens/tuning/extruder_tuning.cpp index f72e8ede84..8eebccb3a3 100755 --- a/Marlin/src/advi3pp/screens/tuning/extruder_tuning.cpp +++ b/Marlin/src/advi3pp/screens/tuning/extruder_tuning.cpp @@ -22,7 +22,7 @@ #include "extruder_tuning.h" #include "../../core/core.h" #include "../../core/dgus.h" -#include "../core/wait.h" +#include "../../core/wait.h" #include "../settings/step_settings.h" namespace ADVi3pp { @@ -37,47 +37,40 @@ ExtruderTuning extruder_tuning; //! Handle Extruder Tuning command //! @param key_value The sub-action to handle //! @return True if the action was handled -bool ExtruderTuning::do_dispatch(KeyValue key_value) -{ - switch(key_value) - { - case KeyValue::TuningStart: start_command(); return true; - case KeyValue::TuningSettings: settings_command(); return true; - default: break; - } - - // Do this after since we handle Save before - if(Parent::do_dispatch(key_value)) - return true; - - return false; +bool ExtruderTuning::on_dispatch(KeyValue key_value) { + switch(key_value) { + case KeyValue::TuningStart: start_command(); return true; + case KeyValue::TuningSettings: settings_command(); return true; + default: break; + } + + // Do this after since we handle Save before + if(Parent::on_dispatch(key_value)) + return true; + + return false; } -void ExtruderTuning::send_data() -{ - WriteRamRequest{Variable::Value0}.write_word(settings.get_last_used_temperature(TemperatureKind::Hotend)); +void ExtruderTuning::send_data() { + WriteRamRequest{Variable::Value0}.write_word(settings.get_last_used_temperature(TemperatureKind::Hotend)); } //! Prepare the page before being displayed and return the right Page value //! @return The index of the page to display -Page ExtruderTuning::do_prepare_page() -{ - if(!core.ensure_not_printing()) - return Page::None; - pages.save_forward_page(); - send_data(); - previous_z_ = Core::ensure_z_enough_room(); - return Page::ExtruderTuningTemp; +void ExtruderTuning::on_enter() { + pages.save_forward_page(); + send_data(); + previous_z_ = Core::ensure_z_enough_room(); } -void ExtruderTuning::do_back_command() { +void ExtruderTuning::on_back_command() { ExtUI::setAxisPosition_mm(previous_z_, ExtUI::Z, 20); - Parent::do_back_command(); + Parent::on_back_command(); } -void ExtruderTuning::do_save_command() { +void ExtruderTuning::on_save_command() { ExtUI::setAxisPosition_mm(previous_z_, ExtUI::Z, 20); - Parent::do_save_command(); + Parent::on_save_command(); } //! Start extruder tuning. @@ -124,7 +117,7 @@ void ExtruderTuning::extruding() { // Always set default to 20mm WriteRamRequest{Variable::Value0}.write_word(200); - pages.show(Page::ExtruderTuningMeasure); + pages.show(Page::ExtruderTuningMeasure, ACTION); } bool ExtruderTuning::cancel_extrude() { @@ -135,22 +128,20 @@ bool ExtruderTuning::cancel_extrude() { } //! Compute the extruder (E axis) new value and show the steps settings. -void ExtruderTuning::settings_command() -{ - ReadRam frame{Variable::Value0}; - if(!frame.send_receive(1)) - { - Log::error() << F("Receiving Frame (Measures)") << Log::endl(); - return; - } - - uint16_t e = frame.read_word(); - // Note: e is divided by 10 because the LCD panel gives a value in 0.1 mm unit - // Formula: new_value = old_value * theoretical_extruded / actual_extruded - auto new_value = ExtUI::getAxisSteps_per_mm(ExtUI::E0) * extruded_ / (extruded_ + REMAINING_FILAMENT - e / 10.0); - - ExtUI::setAxisSteps_per_mm(new_value, ExtUI::E0); - steps_settings.show(); +void ExtruderTuning::settings_command() { + ReadRam frame{Variable::Value0}; + if(!frame.send_receive(1)) { + Log::error() << F("Receiving Frame (Measures)") << Log::endl(); + return; + } + + uint16_t e = frame.read_word(); + // Note: e is divided by 10 because the LCD panel gives a value in 0.1 mm unit + // Formula: new_value = old_value * theoretical_extruded / actual_extruded + auto new_value = ExtUI::getAxisSteps_per_mm(ExtUI::E0) * extruded_ / (extruded_ + REMAINING_FILAMENT - e / 10.0); + + ExtUI::setAxisSteps_per_mm(new_value, ExtUI::E0); + steps_settings.show(); } } diff --git a/Marlin/src/advi3pp/screens/tuning/extruder_tuning.h b/Marlin/src/advi3pp/screens/tuning/extruder_tuning.h index b09d6a82e9..78741f41c7 100644 --- a/Marlin/src/advi3pp/screens/tuning/extruder_tuning.h +++ b/Marlin/src/advi3pp/screens/tuning/extruder_tuning.h @@ -20,31 +20,34 @@ #pragma once -#include "../core/screen.h" +#include "../../core/screen.h" namespace ADVi3pp { //! Extruder Tuning Page -struct ExtruderTuning: Screen -{ +struct ExtruderTuning: Screen { + static constexpr Page PAGE = Page::ExtruderTuning; + static constexpr Action ACTION = Action::ExtruderTuning; + private: - bool do_dispatch(KeyValue value); - Page do_prepare_page(); - void do_back_command(); - void do_save_command(); - void start_command(); - void settings_command(); - void send_data(); - void heating(); - bool cancel_heating(); - void extrude(); - void extruding(); - bool cancel_extrude(); + bool on_dispatch(KeyValue value); + void on_enter(); + void on_back_command(); + void on_save_command(); + + void start_command(); + void settings_command(); + void send_data(); + void heating(); + bool cancel_heating(); + void extrude(); + void extruding(); + bool cancel_extrude(); private: - float extruded_ = 0.0; - float previous_z_ = 0.0; - friend Parent; + float extruded_ = 0.0; + float previous_z_ = 0.0; + friend Parent; }; extern ExtruderTuning extruder_tuning; diff --git a/Marlin/src/advi3pp/screens/tuning/io.cpp b/Marlin/src/advi3pp/screens/tuning/io.cpp index 36ea0ccff1..e1b2cb5c9b 100644 --- a/Marlin/src/advi3pp/screens/tuning/io.cpp +++ b/Marlin/src/advi3pp/screens/tuning/io.cpp @@ -27,23 +27,22 @@ namespace ADVi3pp { //! List of digital pins for the Diagnosis page -const uint8_t diagnosis_digital_pins[] = -{ - 54, // PF0 / ADC0 - A0 - 24, // PA2 / AD2 - 23, // PA1 / AD1 - 6, // PH3 / OC4A - 25, // PA3 / AD3 +const uint8_t diagnosis_digital_pins[] = { + 54, // PF0 / ADC0 - A0 + 24, // PA2 / AD2 + 23, // PA1 / AD1 + 6, // PH3 / OC4A + 25, // PA3 / AD3 - 40, // PG1 / !RD - 56, // PF2 / ADC2 - A2 - 36, // PC1 / A9 - 37, // PC0 / A8 + 40, // PG1 / !RD + 56, // PF2 / ADC2 - A2 + 36, // PC1 / A9 + 37, // PC0 / A8 - 34, // PC3 / A11 - 35, // PC2 / A10 - 32, // PC5 / A13 - 33, // PC4 / A12 + 34, // PC3 / A11 + 35, // PC2 / A10 + 32, // PC5 / A13 + 33, // PC4 / A12 }; //! List of analog pins for the Diagnosis page @@ -54,36 +53,30 @@ IO io; //! Prepare the page before being displayed and return the right Page value //! @return The index of the page to display -Page IO::do_prepare_page() -{ - background_task.set(Callback{this, &IO::send_data}, 250); - return Page::IO; +void IO::on_enter() { + background_task.set(Callback{this, &IO::send_data}, 250); } //! Execute the Back command -void IO::do_back_command() -{ - background_task.clear(); - Parent::do_back_command(); +void IO::on_back_command() { + background_task.clear(); + Parent::on_back_command(); } //! Send the current data to the LCD panel. -void IO::send_data() -{ - WriteRamRequest request{Variable::Value0}; +void IO::send_data() { + WriteRamRequest request{Variable::Value0}; - for(size_t i = 0; i < adv::count_of(diagnosis_digital_pins); ++i) - { - auto var = static_cast(static_cast(Variable::Value0) + i); - WriteRamRequest{var}.write_word(static_cast(Core::get_pin_state(diagnosis_digital_pins[i]))); - } + for(size_t i = 0; i < adv::count_of(diagnosis_digital_pins); ++i) { + auto var = static_cast(static_cast(Variable::Value0) + i); + WriteRamRequest{var}.write_word(static_cast(Core::get_pin_state(diagnosis_digital_pins[i]))); + } - for(size_t i = 0; i < adv::count_of(diagnosis_analog_pins); ++i) - { - auto var = static_cast(static_cast(Variable::Value0) + 0x20 + i); - WriteRamRequest{var}.write_word(static_cast(analogRead(diagnosis_analog_pins[i]))); - } + for(size_t i = 0; i < adv::count_of(diagnosis_analog_pins); ++i) { + auto var = static_cast(static_cast(Variable::Value0) + 0x20 + i); + WriteRamRequest{var}.write_word(static_cast(analogRead(diagnosis_analog_pins[i]))); + } } } diff --git a/Marlin/src/advi3pp/screens/tuning/io.h b/Marlin/src/advi3pp/screens/tuning/io.h index 48e463e1e3..b905a79d3d 100644 --- a/Marlin/src/advi3pp/screens/tuning/io.h +++ b/Marlin/src/advi3pp/screens/tuning/io.h @@ -20,19 +20,23 @@ #pragma once -#include "../core/screen.h" +#include "../../core/screen.h" namespace ADVi3pp { //! Diagnosis Page -struct IO: Screen -{ +struct IO: Screen { + static constexpr Page PAGE = Page::IO; + static constexpr Action ACTION = Action::IO; + private: - Page do_prepare_page(); - void do_back_command(); - void send_data(); + void on_enter(); + void on_back_command(); + + void send_data(); - friend Parent; +private: + friend Parent; }; extern IO io; diff --git a/Marlin/src/advi3pp/screens/tuning/pid_tuning.cpp b/Marlin/src/advi3pp/screens/tuning/pid_tuning.cpp index 5a93d810eb..ac4cc24c2e 100755 --- a/Marlin/src/advi3pp/screens/tuning/pid_tuning.cpp +++ b/Marlin/src/advi3pp/screens/tuning/pid_tuning.cpp @@ -34,143 +34,127 @@ PidTuning pid_tuning; //! Handle PID tuning command //! @param key_value The step of the PID tuning //! @return True if the action was handled -bool PidTuning::do_dispatch(KeyValue key_value) -{ - if(Parent::do_dispatch(key_value)) - return true; - - switch(key_value) - { - case KeyValue::PidTuningStep2: step2_command(); break; - case KeyValue::PidTuningHotend: hotend_command(); break; - case KeyValue::PidTuningBed: bed_command(); break; - default: return false; - } - +bool PidTuning::on_dispatch(KeyValue key_value) { + if(Parent::on_dispatch(key_value)) return true; + + switch(key_value) { + case KeyValue::PidTuningStep2: step2_command(); break; + case KeyValue::PidTuningHotend: hotend_command(); break; + case KeyValue::PidTuningBed: bed_command(); break; + default: return false; + } + + return true; } //! Prepare the page before being displayed and return the right Page value //! @return The index of the page to display -Page PidTuning::do_prepare_page() -{ - if(!core.ensure_not_printing()) - return Page::None; - pages.save_forward_page(); - hotend_command(); - status.reset(); - return Page::PidTuning; +void PidTuning::on_enter() { + pages.save_forward_page(); + hotend_command(); + status.reset(); } //! Send the current data to the LCD panel. -void PidTuning::send_data() -{ - WriteRamRequest{Variable::Value0}.write_words(temperature_, kind_ != TemperatureKind::Hotend); +void PidTuning::send_data() { + WriteRamRequest{Variable::Value0}.write_words(temperature_, kind_ != TemperatureKind::Hotend); } //! Select the hotend PID -void PidTuning::hotend_command() -{ - temperature_ = settings.get_last_used_temperature(TemperatureKind::Hotend); - kind_ = TemperatureKind::Hotend; - send_data(); +void PidTuning::hotend_command() { + temperature_ = settings.get_last_used_temperature(TemperatureKind::Hotend); + kind_ = TemperatureKind::Hotend; + send_data(); } //! Select the bed PID -void PidTuning::bed_command() -{ - temperature_ = settings.get_last_used_temperature(TemperatureKind::Bed); - kind_ = TemperatureKind::Bed; - send_data(); +void PidTuning::bed_command() { + temperature_ = settings.get_last_used_temperature(TemperatureKind::Bed); + kind_ = TemperatureKind::Bed; + send_data(); } //! Show step #2 of PID tuning -void PidTuning::step2_command() -{ - status.reset(); +void PidTuning::step2_command() { + status.reset(); - ReadRam frame{Variable::Value0}; - if(!frame.send_receive(2)) - { - Log::error() << F("Receiving Frame (Target Temperature)") << Log::endl(); - return; - } + ReadRam frame{Variable::Value0}; + if(!frame.send_receive(2)) { + Log::error() << F("Receiving Frame (Target Temperature)") << Log::endl(); + return; + } - temperature_ = frame.read_word(); - [[maybe_unused]] uint16_t kind = frame.read_word(); - assert(static_cast(kind) == kind_); + temperature_ = frame.read_word(); + [[maybe_unused]] uint16_t kind = frame.read_word(); + assert(static_cast(kind) == kind_); - state_ |= State::FromLCDMenu; + state_ |= State::FromLCDMenu; - if(kind_ == TemperatureKind::Hotend) - ExtUI::setTargetFan_percent(100, ExtUI::FAN0); // Turn on fan (only for hotend) + if(kind_ == TemperatureKind::Hotend) + ExtUI::setTargetFan_percent(100, ExtUI::FAN0); // Turn on fan (only for hotend) - background_task.set(Callback{this, &PidTuning::step3_command}); + background_task.set(Callback{this, &PidTuning::step3_command}); } void PidTuning::step3_command() { - background_task.clear(); + background_task.clear(); - temperatures.show(Callback{this, &PidTuning::cancel_pid}); + temperatures.show(Callback{this, &PidTuning::cancel_pid}); - if(kind_ == TemperatureKind::Hotend) - ExtUI::startPIDTune(temperature_, ExtUI::E0); - else - ExtUI::startBedPIDTune(temperature_); + if(kind_ == TemperatureKind::Hotend) + ExtUI::startPIDTune(temperature_, ExtUI::E0); + else + ExtUI::startBedPIDTune(temperature_); } //! Cancel PID process. -void PidTuning::cancel_pid() -{ - status.set(F("Canceling PID tuning")); - ExtUI::cancelWaitForHeatup(); - ExtUI::setTargetFan_percent(0, ExtUI::FAN0); - state_ = State::None; +void PidTuning::cancel_pid() { + status.set(F("Canceling PID tuning")); + ExtUI::cancelWaitForHeatup(); + ExtUI::setTargetFan_percent(0, ExtUI::FAN0); + state_ = State::None; } void PidTuning::on_start() { - status.set(F("Starting PID tuning...")); - state_ |= State::Processing; + status.set(F("Starting PID tuning...")); + state_ |= State::Processing; } -void PidTuning::on_progress(int cycle, int nb) -{ - ADVString<18> format{F("PID tuning %i / %i")}; - ADVString<18> progress{}; - progress.format(format.get(), cycle, nb); - status.set(progress.get()); +void PidTuning::on_progress(int cycle, int nb) { + ADVString<18> format{F("PID tuning %i / %i")}; + ADVString<18> progress{}; + progress.format(format.get(), cycle, nb); + status.set(progress.get()); } -const FlashChar* get_message(ExtUI::result_t result) -{ - switch(result) - { - case ExtUI::PID_BAD_EXTRUDER_NUM: return F(STR_PID_BAD_HEATER_ID); - case ExtUI::PID_TEMP_TOO_HIGH: return F(STR_PID_TEMP_TOO_HIGH); - case ExtUI::PID_TUNING_TIMEOUT: return F(STR_PID_TIMEOUT); - case ExtUI::PID_DONE: return F("PID tuning successful"); - default: Log::error() << F("Unknown result_t ") << static_cast(result) << Log::endl(); break; - } - - return F(""); +const FlashChar* get_message(ExtUI::result_t result) { + switch(result) { + case ExtUI::PID_BAD_EXTRUDER_NUM: return F(STR_PID_BAD_HEATER_ID); + case ExtUI::PID_TEMP_TOO_HIGH: return F(STR_PID_TEMP_TOO_HIGH); + case ExtUI::PID_TUNING_TIMEOUT: return F(STR_PID_TIMEOUT); + case ExtUI::PID_DONE: return F("PID tuning successful"); + default: Log::error() << F("Unknown result_t ") << static_cast(result) << Log::endl(); break; + } + + return F(""); } //! PID automatic tuning is finished. -void PidTuning::on_finished(ExtUI::result_t result) -{ - if((state_ & ~State::FromLCDMenu) != State::Processing) - return; - state_ = State::None; - - auto message = get_message(result); - status.set(message); - - ExtUI::setTargetFan_percent(0, ExtUI::FAN0); - if(result != ExtUI::PID_DONE) - return; - - pid.add_pid(kind_, temperature_); - pid_settings.show(); +void PidTuning::on_finished(ExtUI::result_t result) { + if((state_ & ~State::FromLCDMenu) != State::Processing) + return; + state_ = State::None; + + auto message = get_message(result); + status.set(message); + + ExtUI::setTargetFan_percent(0, ExtUI::FAN0); + if(result != ExtUI::PID_DONE) + return; + + pid.add_pid(kind_, temperature_); + pid_settings.show(); } diff --git a/Marlin/src/advi3pp/screens/tuning/pid_tuning.h b/Marlin/src/advi3pp/screens/tuning/pid_tuning.h index 5f432bd43d..57f70ff303 100644 --- a/Marlin/src/advi3pp/screens/tuning/pid_tuning.h +++ b/Marlin/src/advi3pp/screens/tuning/pid_tuning.h @@ -21,40 +21,42 @@ #pragma once #include "../../lib/ADVstd/bitmasks.h" -#include "../core/screen.h" +#include "../../core/screen.h" namespace ADVi3pp { //! PID Tuning Page -struct PidTuning: Screen -{ - void on_start(); - void on_progress(int cycleIndex, int nbCycles); - void on_finished(ExtUI::result_t result); - void send_data(); +struct PidTuning: Screen { + static constexpr Page PAGE = Page::PidTuning; + static constexpr Action ACTION = Action::PidTuning; + + void on_start(); + void on_progress(int cycleIndex, int nbCycles); + void on_finished(ExtUI::result_t result); + void send_data(); private: - bool do_dispatch(KeyValue value); - Page do_prepare_page(); - void step2_command(); - void step3_command(); - void cancel_pid(); - void hotend_command(); - void bed_command(); + bool on_dispatch(KeyValue value); + void on_enter(); + + void step2_command(); + void step3_command(); + void cancel_pid(); + void hotend_command(); + void bed_command(); private: - enum class State: uint8_t - { - None, - Processing, - FromLCDMenu = 0x80 - }; + enum class State: uint8_t { + None, + Processing, + FromLCDMenu = 0x80 + }; - uint16_t temperature_ = 0; - TemperatureKind kind_ = TemperatureKind::Hotend; - State state_ = State::None; + uint16_t temperature_ = 0; + TemperatureKind kind_ = TemperatureKind::Hotend; + State state_ = State::None; - friend Parent; + friend Parent; }; ENABLE_BITMASK_OPERATOR(PidTuning::State); diff --git a/Marlin/src/advi3pp/screens/tuning/setup.cpp b/Marlin/src/advi3pp/screens/tuning/setup.cpp index d5715fe20c..a0ddf19d2b 100644 --- a/Marlin/src/advi3pp/screens/tuning/setup.cpp +++ b/Marlin/src/advi3pp/screens/tuning/setup.cpp @@ -26,16 +26,4 @@ namespace ADVi3pp { Setup setup; -//! Prepare the page before being displayed and return the right Page value -//! @return The index of the page to display -Page Setup::do_prepare_page() -{ -#ifdef ADVi3PP_PROBE - return Page::Setup; -#else - return Page::SetupNoSensor; -#endif -} - - } diff --git a/Marlin/src/advi3pp/screens/tuning/setup.h b/Marlin/src/advi3pp/screens/tuning/setup.h index 8513f0ee1b..40ea14d5cf 100644 --- a/Marlin/src/advi3pp/screens/tuning/setup.h +++ b/Marlin/src/advi3pp/screens/tuning/setup.h @@ -20,18 +20,22 @@ #pragma once -#include "../core/screen.h" +#include "../../core/screen.h" namespace ADVi3pp { //! Setup Page -struct Setup: Screen -{ -private: - Page do_prepare_page(); +struct Setup: Screen { +#ifdef ADVi3PP_PROBE + static constexpr Page PAGE = Page::Setup; + static constexpr Action ACTION = Action::Setup; +#else + static constexpr Page PAGE = Page::SetupNoSensor; + static constexpr Action ACTION = Action::Setup; +#endif private: - friend Parent; + friend Parent; }; extern Setup setup; diff --git a/Marlin/src/advi3pp/screens/tuning/vibrations.cpp b/Marlin/src/advi3pp/screens/tuning/vibrations.cpp index ccf1dcd3ea..e85f678241 100644 --- a/Marlin/src/advi3pp/screens/tuning/vibrations.cpp +++ b/Marlin/src/advi3pp/screens/tuning/vibrations.cpp @@ -21,7 +21,7 @@ #include "../../parameters.h" #include "../../core/core.h" #include "../../core/dgus.h" -#include "../core/wait.h" +#include "../../core/wait.h" #include "vibrations.h" namespace ADVi3pp { @@ -38,227 +38,205 @@ const int Z_FAST = 1400; //! Execute command //! @param key_value The sub-action to handle //! @return True if the action was handled -bool Vibrations::do_dispatch(KeyValue key_value) -{ - if(Parent::do_dispatch(key_value)) - return true; - - switch(key_value) - { - case KeyValue::VibrationsX: x_command(); break; - case KeyValue::VibrationsY: y_command(); break; - case KeyValue::VibrationsXY: xy_command(); break; - case KeyValue::VibrationsYX: yx_command(); break; - case KeyValue::VibrationsZ: z_command(); break; - default: return false; - } - - return true; +bool Vibrations::on_dispatch(KeyValue key_value) { + if(Parent::on_dispatch(key_value)) + return true; + + switch(key_value) { + case KeyValue::VibrationsX: x_command(); break; + case KeyValue::VibrationsY: y_command(); break; + case KeyValue::VibrationsXY: xy_command(); break; + case KeyValue::VibrationsYX: yx_command(); break; + case KeyValue::VibrationsZ: z_command(); break; + default: return false; + } + + return true; } //! Prepare the page before being displayed and return the right Page value //! @return The index of the page to display -Page Vibrations::do_prepare_page() -{ - if(!core.ensure_not_printing()) - return Page::None; - - set_values(); - if(ExtUI::isMachineHomed()) - return Page::VibrationsTuning; - - wait.wait(F("Please wait while the printer is homed...")); - core.inject_commands(F("G28 O F6000")); - background_task.set(Callback{this, &Vibrations::homing}); - return Page::None; +void Vibrations::on_enter() { + set_values(); + wait.home_and_wait(Callback{this, &Vibrations::homing}, F("Please wait while the printer is homed...")); } void Vibrations::homing() { - if(!ExtUI::isMachineHomed()) - return; - background_task.clear(); - pages.show(Page::VibrationsTuning); + if(!wait.check_homed()) return; } //! Execute the Back command -void Vibrations::do_back_command() -{ - wait.wait(F("Please wait for the move to finish...")); - background_task.set(Callback{this, &Vibrations::move_finished}); +void Vibrations::on_back_command() { + wait.wait(F("Please wait for the move to finish...")); + background_task.set(Callback{this, &Vibrations::move_finished}); } void Vibrations::move_finished() { - if(core.is_busy()) return; - - if(ExtUI::getAxisPosition_mm(ExtUI::Z) != 10) { - core.inject_commands(F("G1 Z10 F1200")); - background_task.set(Callback{this, &Vibrations::move_finished2}); - return; - } - - background_task.clear(); - status.reset(); - pages.show_back_page(); - pages.show_back_page(); + if(core.is_busy()) return; + + if(ExtUI::getAxisPosition_mm(ExtUI::Z) != 10) { + core.inject_commands(F("G1 Z10 F1200")); + background_task.set(Callback{this, &Vibrations::move_finished2}); + return; + } + + background_task.clear(); + status.reset(); + pages.show_back_page(2); } void Vibrations::move_finished2() { - if(core.is_busy()) return; + if(core.is_busy()) return; - background_task.clear(); - status.reset(); - pages.show_back_page(); - pages.show_back_page(); + background_task.clear(); + status.reset(); + pages.show_back_page(2); } void Vibrations::move_x() { - if(core.is_busy()) return; + if(core.is_busy()) return; - int min, max; - if(!get_values(min, max)) - return; + int min, max; + if(!get_values(min, max)) return; - if(min < X_MIN_BED) min = X_MIN_BED; - if(max > X_MAX_BED) max = X_MAX_BED; + if(min < X_MIN_BED) min = X_MIN_BED; + if(max > X_MAX_BED) max = X_MAX_BED; - int new_position = (ExtUI::getAxisPosition_mm(ExtUI::X) == max) ? min : max; + int new_position = (ExtUI::getAxisPosition_mm(ExtUI::X) == max) ? min : max; - ADVString<20> cmd; - cmd.format(F("G1 X%i F%i"), new_position, get_xy_speed()); - core.inject_commands(cmd.get()); + ADVString<20> cmd; + cmd.format(F("G1 X%i F%i"), new_position, get_xy_speed()); + core.inject_commands(cmd.get()); } void Vibrations::move_y() { - if(core.is_busy()) return; + if(core.is_busy()) return; - int min, max; - if(!get_values(min, max)) - return; + int min, max; + if(!get_values(min, max)) return; - if(min < Y_MIN_BED) min = Y_MIN_BED; - if(max > Y_MAX_BED) max = Y_MAX_BED; + if(min < Y_MIN_BED) min = Y_MIN_BED; + if(max > Y_MAX_BED) max = Y_MAX_BED; - int new_position = (ExtUI::getAxisPosition_mm(ExtUI::Y) == max) ? min : max; + int new_position = (ExtUI::getAxisPosition_mm(ExtUI::Y) == max) ? min : max; - ADVString<20> cmd; - cmd.format(F("G1 Y%i F%i"), new_position, get_xy_speed()); - core.inject_commands(cmd.get()); + ADVString<20> cmd; + cmd.format(F("G1 Y%i F%i"), new_position, get_xy_speed()); + core.inject_commands(cmd.get()); } void Vibrations::move_start_z() { - ADVString<40> cmd; - cmd.format(F("G1 X%i F6000\nG1 Y%i F6000"), X_CENTER, Y_CENTER); - core.inject_commands(cmd.get()); - background_task.set(Callback{this, &Vibrations::move_z}); + ADVString<40> cmd; + cmd.format(F("G1 X%i F6000\nG1 Y%i F6000"), X_CENTER, Y_CENTER); + core.inject_commands(cmd.get()); + background_task.set(Callback{this, &Vibrations::move_z}); } void Vibrations::move_z() { - if(core.is_busy()) return; + if(core.is_busy()) return; - int min, max; - if(!get_values(min, max)) - return; + int min, max; + if(!get_values(min, max)) return; - if(min < 5) min = 5; - if(max > 150) max = 150; // Don't go to the limit, could be dangerous with some mods + if(min < 5) min = 5; + if(max > 150) max = 150; // Don't go to the limit, could be dangerous with some mods - int new_position = (ExtUI::getAxisPosition_mm(ExtUI::Z) == max) ? min : max; + int new_position = (ExtUI::getAxisPosition_mm(ExtUI::Z) == max) ? min : max; - ADVString<20> cmd; - cmd.format(F("G1 Z%i F%i"), new_position, get_z_speed()); - core.inject_commands(cmd.get()); + ADVString<20> cmd; + cmd.format(F("G1 Z%i F%i"), new_position, get_z_speed()); + core.inject_commands(cmd.get()); } void Vibrations::move_start_xy() { - ADVString<40> cmd; - cmd.format(F("G1 X%i F6000\nG1 Y%i F6000"), X_MIN_BED, Y_MIN_BED); - core.inject_commands(cmd.get()); - background_task.set(Callback{this, &Vibrations::move_xy}); + ADVString<40> cmd; + cmd.format(F("G1 X%i F6000\nG1 Y%i F6000"), X_MIN_BED, Y_MIN_BED); + core.inject_commands(cmd.get()); + background_task.set(Callback{this, &Vibrations::move_xy}); } void Vibrations::move_start_yx() { - ADVString<40> cmd; - cmd.format(F("G1 X%i F6000\nG1 Y%i F6000"), X_MIN_BED, Y_MAX_BED); - core.inject_commands(cmd.get()); - background_task.set(Callback{this, &Vibrations::move_xy}); + ADVString<40> cmd; + cmd.format(F("G1 X%i F6000\nG1 Y%i F6000"), X_MIN_BED, Y_MAX_BED); + core.inject_commands(cmd.get()); + background_task.set(Callback{this, &Vibrations::move_xy}); } void Vibrations::move_xy() { - if(core.is_busy()) return; + if(core.is_busy()) return; - int min, max; - if(!get_values(min, max)) return; + int min, max; + if(!get_values(min, max)) return; - int min_x = (min < X_MIN_BED) ? X_MIN_BED : min; - int max_x = (max > X_MAX_BED) ? X_MAX_BED : max; - int min_y = (min < Y_MIN_BED) ? Y_MIN_BED : min; - int max_y = (max > Y_MAX_BED) ? Y_MAX_BED : max; + int min_x = (min < X_MIN_BED) ? X_MIN_BED : min; + int max_x = (max > X_MAX_BED) ? X_MAX_BED : max; + int min_y = (min < Y_MIN_BED) ? Y_MIN_BED : min; + int max_y = (max > Y_MAX_BED) ? Y_MAX_BED : max; - int new_x_position = (ExtUI::getAxisPosition_mm(ExtUI::X) == max_x) ? min_x : max_x; - int new_y_position = (ExtUI::getAxisPosition_mm(ExtUI::Y) == max_y) ? min_y : max_y; + int new_x_position = (ExtUI::getAxisPosition_mm(ExtUI::X) == max_x) ? min_x : max_x; + int new_y_position = (ExtUI::getAxisPosition_mm(ExtUI::Y) == max_y) ? min_y : max_y; - ADVString<40> cmd; - cmd.format(F("G1 X%i Y%i F%i"), new_x_position, new_y_position, get_xy_speed()); - core.inject_commands(cmd.get()); + ADVString<40> cmd; + cmd.format(F("G1 X%i Y%i F%i"), new_x_position, new_y_position, get_xy_speed()); + core.inject_commands(cmd.get()); } bool Vibrations::get_values(int &min, int &max) { - ReadRam frame{Variable::Value0}; - if(!frame.send_receive(3)) - { - Log::error() << F("Receiving Frame (Min Max)") << Log::endl(); - return false; - } - - min = frame.read_word(); - max = frame.read_word(); - speed_ = static_cast(frame.read_word()); - if(min < 0) min = 0; - if(min >= max) return false; - - return true; + ReadRam frame{Variable::Value0}; + if(!frame.send_receive(3)) { + Log::error() << F("Receiving Frame (Min Max)") << Log::endl(); + return false; + } + + min = frame.read_word(); + max = frame.read_word(); + speed_ = static_cast(frame.read_word()); + if(min < 0) min = 0; + if(min >= max) return false; + + return true; } void Vibrations::set_values() { - WriteRamRequest{Variable::Value0}.write_words(X_MIN_BED, X_MAX_BED, 1); + WriteRamRequest{Variable::Value0}.write_words(X_MIN_BED, X_MAX_BED, 1); } int Vibrations::get_xy_speed() { - switch(speed_) { - case Speed::Slow: return XY_SLOW; - case Speed::Medium: return XY_MEDIUM; - case Speed::Fast: return XY_FAST; - default: return XY_MEDIUM; - } + switch(speed_) { + case Speed::Slow: return XY_SLOW; + case Speed::Medium: return XY_MEDIUM; + case Speed::Fast: return XY_FAST; + default: return XY_MEDIUM; + } } int Vibrations::get_z_speed() { - switch(speed_) { - case Speed::Slow: return Z_SLOW; - case Speed::Medium: return Z_MEDIUM; - case Speed::Fast: return Z_FAST; - default: return Z_MEDIUM; - } + switch(speed_) { + case Speed::Slow: return Z_SLOW; + case Speed::Medium: return Z_MEDIUM; + case Speed::Fast: return Z_FAST; + default: return Z_MEDIUM; + } } void Vibrations::x_command() { - background_task.set(Callback{this, &Vibrations::move_x}); + background_task.set(Callback{this, &Vibrations::move_x}); } void Vibrations::y_command() { - background_task.set(Callback{this, &Vibrations::move_y}); + background_task.set(Callback{this, &Vibrations::move_y}); } void Vibrations::xy_command() { - background_task.set(Callback{this, &Vibrations::move_start_xy}); + background_task.set(Callback{this, &Vibrations::move_start_xy}); } void Vibrations::yx_command() { - background_task.set(Callback{this, &Vibrations::move_start_yx}); + background_task.set(Callback{this, &Vibrations::move_start_yx}); } void Vibrations::z_command() { - background_task.set(Callback{this, &Vibrations::move_start_z}); + background_task.set(Callback{this, &Vibrations::move_start_z}); } } diff --git a/Marlin/src/advi3pp/screens/tuning/vibrations.h b/Marlin/src/advi3pp/screens/tuning/vibrations.h index de5f69d226..d249d6fac8 100644 --- a/Marlin/src/advi3pp/screens/tuning/vibrations.h +++ b/Marlin/src/advi3pp/screens/tuning/vibrations.h @@ -20,48 +20,50 @@ #pragma once -#include "../core/screen.h" +#include "../../core/screen.h" namespace ADVi3pp { //! Vibrations Tuning Page -struct Vibrations: Screen -{ +struct Vibrations: Screen { + static constexpr Page PAGE = Page::VibrationsTuning; + static constexpr Action ACTION = Action::VibrationsTuning; + private: - bool do_dispatch(KeyValue key_value); - Page do_prepare_page(); - void do_back_command(); + bool on_dispatch(KeyValue key_value); + void on_enter(); + void on_back_command(); private: - enum class Speed { Slow, Medium, Fast}; + enum class Speed { Slow, Medium, Fast}; - void homing(); + void homing(); - void x_command(); - void y_command(); - void xy_command(); - void yx_command(); - void z_command(); + void x_command(); + void y_command(); + void xy_command(); + void yx_command(); + void z_command(); - void move_x(); - void move_y(); - void move_start_xy(); - void move_start_yx(); - void move_xy(); - void move_start_z(); - void move_z(); - void move_finished(); - void move_finished2(); + void move_x(); + void move_y(); + void move_start_xy(); + void move_start_yx(); + void move_xy(); + void move_start_z(); + void move_z(); + void move_finished(); + void move_finished2(); - bool get_values(int &min, int &max); - void set_values(); - int get_xy_speed(); - int get_z_speed(); + bool get_values(int &min, int &max); + void set_values(); + int get_xy_speed(); + int get_z_speed(); - friend Parent; + friend Parent; private: - Speed speed_ = Speed::Medium; + Speed speed_ = Speed::Medium; }; extern Vibrations vibrations; diff --git a/Marlin/src/advi3pp/versions.h b/Marlin/src/advi3pp/versions.h index 720027baab..c35257387f 100644 --- a/Marlin/src/advi3pp/versions.h +++ b/Marlin/src/advi3pp/versions.h @@ -22,7 +22,7 @@ namespace ADVi3pp { -const uint16_t advi3_pp_version = 0x542; +const uint16_t advi3_pp_version = 0x550; const uint16_t settings_version = 0x0005; // Version of ADVi3++ settings stored in EEPROM } diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index f40b5dab69..f6e795b173 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -246,6 +246,7 @@ #define BOARD_BTT_SKR_V1_1 2012 // BigTreeTech SKR v1.1 #define BOARD_BTT_SKR_V1_3 2013 // BigTreeTech SKR v1.3 #define BOARD_BTT_SKR_V1_4 2014 // BigTreeTech SKR v1.4 +#define BOARD_EMOTRONIC 2015 // eMotion-Tech eMotronic // // LPC1769 ARM Cortex M3 @@ -340,40 +341,41 @@ #define BOARD_BTT_SKR_E3_DIP 4029 // BigTreeTech SKR E3 DIP V1.0 (STM32F103RC / STM32F103RE) #define BOARD_BTT_SKR_CR6 4030 // BigTreeTech SKR CR6 v1.0 (STM32F103RE) #define BOARD_JGAURORA_A5S_A1 4031 // JGAurora A5S A1 (STM32F103ZE) -#define BOARD_FYSETC_AIO_II 4032 // FYSETC AIO_II -#define BOARD_FYSETC_CHEETAH 4033 // FYSETC Cheetah -#define BOARD_FYSETC_CHEETAH_V12 4034 // FYSETC Cheetah V1.2 -#define BOARD_LONGER3D_LK 4035 // Alfawise U20/U20+/U30 (Longer3D LK1/2) / STM32F103VE +#define BOARD_FYSETC_AIO_II 4032 // FYSETC AIO_II (STM32F103RC) +#define BOARD_FYSETC_CHEETAH 4033 // FYSETC Cheetah (STM32F103RC) +#define BOARD_FYSETC_CHEETAH_V12 4034 // FYSETC Cheetah V1.2 (STM32F103RC) +#define BOARD_LONGER3D_LK 4035 // Longer3D LK1/2 - Alfawise U20/U20+/U30 (STM32F103VE) #define BOARD_CCROBOT_MEEB_3DP 4036 // ccrobot-online.com MEEB_3DP (STM32F103RC) -#define BOARD_CHITU3D_V5 4037 // Chitu3D TronXY X5SA V5 Board -#define BOARD_CHITU3D_V6 4038 // Chitu3D TronXY X5SA V6 Board -#define BOARD_CHITU3D_V9 4039 // Chitu3D TronXY X5SA V9 Board +#define BOARD_CHITU3D_V5 4037 // Chitu3D TronXY X5SA V5 Board (STM32F103ZE) +#define BOARD_CHITU3D_V6 4038 // Chitu3D TronXY X5SA V6 Board (STM32F103ZE) +#define BOARD_CHITU3D_V9 4039 // Chitu3D TronXY X5SA V9 Board (STM32F103ZE) #define BOARD_CREALITY_V4 4040 // Creality v4.x (STM32F103RC / STM32F103RE) #define BOARD_CREALITY_V422 4041 // Creality v4.2.2 (STM32F103RC / STM32F103RE) #define BOARD_CREALITY_V423 4042 // Creality v4.2.3 (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V427 4043 // Creality v4.2.7 (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V4210 4044 // Creality v4.2.10 (STM32F103RC / STM32F103RE) as found in the CR-30 -#define BOARD_CREALITY_V431 4045 // Creality v4.3.1 (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V431_A 4046 // Creality v4.3.1a (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V431_B 4047 // Creality v4.3.1b (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V431_C 4048 // Creality v4.3.1c (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V431_D 4049 // Creality v4.3.1d (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V452 4050 // Creality v4.5.2 (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V453 4051 // Creality v4.5.3 (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V24S1 4052 // Creality v2.4.S1 (STM32F103RC / STM32F103RE) v101 as found in the Ender-7 -#define BOARD_CREALITY_V24S1_301 4053 // Creality v2.4.S1_301 (STM32F103RC / STM32F103RE) v301 as found in the Ender-3 S1 -#define BOARD_CREALITY_V25S1 4054 // Creality v2.5.S1 (STM32F103RE) as found in the CR-10 Smart Pro -#define BOARD_TRIGORILLA_PRO 4055 // Trigorilla Pro (STM32F103ZE) -#define BOARD_FLY_MINI 4056 // FLYmaker FLY MINI (STM32F103RC) -#define BOARD_FLSUN_HISPEED 4057 // FLSUN HiSpeedV1 (STM32F103VE) -#define BOARD_BEAST 4058 // STM32F103RE Libmaple-based controller -#define BOARD_MINGDA_MPX_ARM_MINI 4059 // STM32F103ZE Mingda MD-16 -#define BOARD_GTM32_PRO_VD 4060 // STM32F103VE controller -#define BOARD_ZONESTAR_ZM3E2 4061 // Zonestar ZM3E2 (STM32F103RC) -#define BOARD_ZONESTAR_ZM3E4 4062 // Zonestar ZM3E4 V1 (STM32F103VC) -#define BOARD_ZONESTAR_ZM3E4V2 4063 // Zonestar ZM3E4 V2 (STM32F103VC) -#define BOARD_ERYONE_ERY32_MINI 4064 // Eryone Ery32 mini (STM32F103VE) -#define BOARD_PANDA_PI_V29 4065 // Panda Pi V2.9 - Standalone (STM32F103RC) +#define BOARD_CREALITY_V425 4043 // Creality v4.2.5 (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V427 4044 // Creality v4.2.7 (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V4210 4045 // Creality v4.2.10 (STM32F103RC / STM32F103RE) as found in the CR-30 +#define BOARD_CREALITY_V431 4046 // Creality v4.3.1 (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V431_A 4047 // Creality v4.3.1a (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V431_B 4048 // Creality v4.3.1b (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V431_C 4049 // Creality v4.3.1c (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V431_D 4050 // Creality v4.3.1d (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V452 4051 // Creality v4.5.2 (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V453 4052 // Creality v4.5.3 (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V24S1 4053 // Creality v2.4.S1 (STM32F103RC / STM32F103RE) v101 as found in the Ender-7 +#define BOARD_CREALITY_V24S1_301 4054 // Creality v2.4.S1_301 (STM32F103RC / STM32F103RE) v301 as found in the Ender-3 S1 +#define BOARD_CREALITY_V25S1 4055 // Creality v2.5.S1 (STM32F103RE) as found in the CR-10 Smart Pro +#define BOARD_TRIGORILLA_PRO 4056 // Trigorilla Pro (STM32F103ZE) +#define BOARD_FLY_MINI 4057 // FLYmaker FLY MINI (STM32F103RC) +#define BOARD_FLSUN_HISPEED 4058 // FLSUN HiSpeedV1 (STM32F103VE) +#define BOARD_BEAST 4059 // STM32F103RE Libmaple-based controller +#define BOARD_MINGDA_MPX_ARM_MINI 4060 // STM32F103ZE Mingda MD-16 +#define BOARD_GTM32_PRO_VD 4061 // STM32F103VE controller +#define BOARD_ZONESTAR_ZM3E2 4062 // Zonestar ZM3E2 (STM32F103RC) +#define BOARD_ZONESTAR_ZM3E4 4063 // Zonestar ZM3E4 V1 (STM32F103VC) +#define BOARD_ZONESTAR_ZM3E4V2 4064 // Zonestar ZM3E4 V2 (STM32F103VC) +#define BOARD_ERYONE_ERY32_MINI 4065 // Eryone Ery32 mini (STM32F103VE) +#define BOARD_PANDA_PI_V29 4066 // Panda Pi V2.9 - Standalone (STM32F103RC) // // ARM Cortex-M4F @@ -393,35 +395,35 @@ #define BOARD_RUMBA32_BTT 4204 // RUMBA32 STM32F446VE based controller from BIGTREETECH #define BOARD_BLACK_STM32F407VE 4205 // BLACK_STM32F407VE #define BOARD_BLACK_STM32F407ZE 4206 // BLACK_STM32F407ZE -#define BOARD_STEVAL_3DP001V1 4207 // STEVAL-3DP001V1 3D PRINTER BOARD -#define BOARD_BTT_SKR_PRO_V1_1 4208 // BigTreeTech SKR Pro v1.1 (STM32F407ZG) -#define BOARD_BTT_SKR_PRO_V1_2 4209 // BigTreeTech SKR Pro v1.2 (STM32F407ZG) -#define BOARD_BTT_BTT002_V1_0 4210 // BigTreeTech BTT002 v1.0 (STM32F407VG) -#define BOARD_BTT_E3_RRF 4211 // BigTreeTech E3 RRF (STM32F407VG) -#define BOARD_BTT_SKR_V2_0_REV_A 4212 // BigTreeTech SKR v2.0 Rev A (STM32F407VG) -#define BOARD_BTT_SKR_V2_0_REV_B 4213 // BigTreeTech SKR v2.0 Rev B (STM32F407VG/STM32F429VG) -#define BOARD_BTT_GTR_V1_0 4214 // BigTreeTech GTR v1.0 (STM32F407IGT) -#define BOARD_BTT_OCTOPUS_V1_0 4215 // BigTreeTech Octopus v1.0 (STM32F446ZE) -#define BOARD_BTT_OCTOPUS_V1_1 4216 // BigTreeTech Octopus v1.1 (STM32F446ZE) -#define BOARD_BTT_OCTOPUS_PRO_V1_0 4217 // BigTreeTech Octopus Pro v1.0 (STM32F446ZE/STM32F429ZG) -#define BOARD_LERDGE_K 4218 // Lerdge K (STM32F407ZG) -#define BOARD_LERDGE_S 4219 // Lerdge S (STM32F407VE) -#define BOARD_LERDGE_X 4220 // Lerdge X (STM32F407VE) -#define BOARD_VAKE403D 4221 // VAkE 403D (STM32F446VE) -#define BOARD_FYSETC_S6 4222 // FYSETC S6 (STM32F446VE) -#define BOARD_FYSETC_S6_V2_0 4223 // FYSETC S6 v2.0 (STM32F446VE) -#define BOARD_FYSETC_SPIDER 4224 // FYSETC Spider (STM32F446VE) -#define BOARD_FLYF407ZG 4225 // FLYmaker FLYF407ZG (STM32F407ZG) -#define BOARD_MKS_ROBIN2 4226 // MKS_ROBIN2 (STM32F407ZE) -#define BOARD_MKS_ROBIN_PRO_V2 4227 // MKS Robin Pro V2 (STM32F407VE) -#define BOARD_MKS_ROBIN_NANO_V3 4228 // MKS Robin Nano V3 (STM32F407VG) -#define BOARD_MKS_ROBIN_NANO_V3_1 4229 // MKS Robin Nano V3.1 (STM32F407VE) -#define BOARD_MKS_MONSTER8 4230 // MKS Monster8 (STM32F407VG) +#define BOARD_BTT_SKR_PRO_V1_1 4207 // BigTreeTech SKR Pro v1.1 (STM32F407ZG) +#define BOARD_BTT_SKR_PRO_V1_2 4208 // BigTreeTech SKR Pro v1.2 (STM32F407ZG) +#define BOARD_BTT_BTT002_V1_0 4209 // BigTreeTech BTT002 v1.0 (STM32F407VG) +#define BOARD_BTT_E3_RRF 4210 // BigTreeTech E3 RRF (STM32F407VG) +#define BOARD_BTT_SKR_V2_0_REV_A 4211 // BigTreeTech SKR v2.0 Rev A (STM32F407VG) +#define BOARD_BTT_SKR_V2_0_REV_B 4212 // BigTreeTech SKR v2.0 Rev B (STM32F407VG/STM32F429VG) +#define BOARD_BTT_GTR_V1_0 4213 // BigTreeTech GTR v1.0 (STM32F407IGT) +#define BOARD_BTT_OCTOPUS_V1_0 4214 // BigTreeTech Octopus v1.0 (STM32F446ZE) +#define BOARD_BTT_OCTOPUS_V1_1 4215 // BigTreeTech Octopus v1.1 (STM32F446ZE) +#define BOARD_BTT_OCTOPUS_PRO_V1_0 4216 // BigTreeTech Octopus Pro v1.0 (STM32F446ZE / STM32F429ZG) +#define BOARD_LERDGE_K 4217 // Lerdge K (STM32F407ZG) +#define BOARD_LERDGE_S 4218 // Lerdge S (STM32F407VE) +#define BOARD_LERDGE_X 4219 // Lerdge X (STM32F407VE) +#define BOARD_VAKE403D 4220 // VAkE 403D (STM32F446VE) +#define BOARD_FYSETC_S6 4221 // FYSETC S6 (STM32F446VE) +#define BOARD_FYSETC_S6_V2_0 4222 // FYSETC S6 v2.0 (STM32F446VE) +#define BOARD_FYSETC_SPIDER 4223 // FYSETC Spider (STM32F446VE) +#define BOARD_FLYF407ZG 4224 // FLYmaker FLYF407ZG (STM32F407ZG) +#define BOARD_MKS_ROBIN2 4225 // MKS_ROBIN2 (STM32F407ZE) +#define BOARD_MKS_ROBIN_PRO_V2 4226 // MKS Robin Pro V2 (STM32F407VE) +#define BOARD_MKS_ROBIN_NANO_V3 4227 // MKS Robin Nano V3 (STM32F407VG) +#define BOARD_MKS_ROBIN_NANO_V3_1 4228 // MKS Robin Nano V3.1 (STM32F407VE) +#define BOARD_MKS_MONSTER8_V1 4229 // MKS Monster8 V1 (STM32F407VE) +#define BOARD_MKS_MONSTER8_V2 4230 // MKS Monster8 V2 (STM32F407VE) #define BOARD_ANET_ET4 4231 // ANET ET4 V1.x (STM32F407VG) #define BOARD_ANET_ET4P 4232 // ANET ET4P V1.x (STM32F407VG) -#define BOARD_FYSETC_CHEETAH_V20 4233 // FYSETC Cheetah V2.0 -#define BOARD_TH3D_EZBOARD_V2 4234 // TH3D EZBoard v2.0 -#define BOARD_INDEX_REV03 4235 // Index PnP Controller REV03 (STM32F407VE/VG) +#define BOARD_FYSETC_CHEETAH_V20 4233 // FYSETC Cheetah V2.0 (STM32F401RC) +#define BOARD_TH3D_EZBOARD_V2 4234 // TH3D EZBoard v2.0 (STM32F405RG) +#define BOARD_OPULO_LUMEN_REV3 4235 // Opulo Lumen PnP Controller REV3 (STM32F407VE / STM32F407VG) #define BOARD_MKS_ROBIN_NANO_V1_3_F4 4236 // MKS Robin Nano V1.3 and MKS Robin Nano-S V1.3 (STM32F407VE) #define BOARD_MKS_EAGLE 4237 // MKS Eagle (STM32F407VE) #define BOARD_ARTILLERY_RUBY 4238 // Artillery Ruby (STM32F401RC) @@ -436,9 +438,10 @@ #define BOARD_TEENSY41 5001 // Teensy 4.1 #define BOARD_T41U5XBB 5002 // T41U5XBB Teensy 4.1 breakout board #define BOARD_NUCLEO_F767ZI 5003 // ST NUCLEO-F767ZI Dev Board -#define BOARD_BTT_SKR_SE_BX 5004 // BigTreeTech SKR SE BX (STM32H743II) -#define BOARD_BTT_SKR_V3_0 5005 // BigTreeTech SKR V3.0 (STM32H743VG) -#define BOARD_BTT_SKR_V3_0_EZ 5006 // BigTreeTech SKR V3.0 EZ (STM32H743VG) +#define BOARD_BTT_SKR_SE_BX_V2 5004 // BigTreeTech SKR SE BX V2.0 (STM32H743II) +#define BOARD_BTT_SKR_SE_BX_V3 5005 // BigTreeTech SKR SE BX V3.0 (STM32H743II) +#define BOARD_BTT_SKR_V3_0 5006 // BigTreeTech SKR V3.0 (STM32H743VG) +#define BOARD_BTT_SKR_V3_0_EZ 5007 // BigTreeTech SKR V3.0 EZ (STM32H743VG) // // Espressif ESP32 WiFi diff --git a/Marlin/src/core/drivers.h b/Marlin/src/core/drivers.h index 7f9da909b2..8cf03d342a 100644 --- a/Marlin/src/core/drivers.h +++ b/Marlin/src/core/drivers.h @@ -30,10 +30,6 @@ #define _A5984 0x5984 #define _DRV8825 0x8825 #define _LV8729 0x8729 -#define _L6470 0x6470 -#define _L6474 0x6474 -#define _L6480 0x6480 -#define _POWERSTEP01 0xF00D #define _TB6560 0x6560 #define _TB6600 0x6600 #define _TMC2100 0x2100 @@ -193,16 +189,3 @@ #if HAS_DRIVER(TMC26X) #define HAS_TMC26X 1 #endif - -// -// L64XX Stepper Drivers -// - -#if HAS_DRIVER(L6470) || HAS_DRIVER(L6474) || HAS_DRIVER(L6480) || HAS_DRIVER(POWERSTEP01) - #define HAS_L64XX 1 -#endif -#if HAS_L64XX && !HAS_DRIVER(L6474) - #define HAS_L64XX_NOT_L6474 1 -#endif - -#define AXIS_IS_L64XX(A) (AXIS_DRIVER_TYPE_##A(L6470) || AXIS_DRIVER_TYPE_##A(L6474) || AXIS_DRIVER_TYPE_##A(L6480) || AXIS_DRIVER_TYPE_##A(POWERSTEP01)) diff --git a/Marlin/src/core/language.h b/Marlin/src/core/language.h index acbc94dbe0..157bd69185 100644 --- a/Marlin/src/core/language.h +++ b/Marlin/src/core/language.h @@ -227,10 +227,6 @@ #define STR_PID_DEBUG " PID_DEBUG " #define STR_PID_DEBUG_INPUT ": Input " #define STR_PID_DEBUG_OUTPUT " Output " -#define STR_PID_DEBUG_PTERM " pTerm " -#define STR_PID_DEBUG_ITERM " iTerm " -#define STR_PID_DEBUG_DTERM " dTerm " -#define STR_PID_DEBUG_CTERM " cTerm " #define STR_INVALID_EXTRUDER_NUM " - Invalid extruder number !" #define STR_MPC_AUTOTUNE "MPC Autotune" #define STR_MPC_AUTOTUNE_START " start for " STR_E @@ -356,7 +352,7 @@ #define STR_X "X" #define STR_Y "Y" #define STR_Z "Z" -#define STR_E "Extruder" // @advi3++ +#define STR_E "E" #if IS_KINEMATIC #define STR_A "A" #define STR_B "B" diff --git a/Marlin/src/core/macros.h b/Marlin/src/core/macros.h index 09a6164568..ddcf27b2b8 100644 --- a/Marlin/src/core/macros.h +++ b/Marlin/src/core/macros.h @@ -730,3 +730,8 @@ #define __MAPLIST() _MAPLIST #define MAPLIST(OP,V...) EVAL(_MAPLIST(OP,V)) + +// Temperature Sensor Config +#define _HAS_E_TEMP(N) || (TEMP_SENSOR_##N != 0) +#define HAS_E_TEMP_SENSOR (0 REPEAT(EXTRUDERS, _HAS_E_TEMP)) +#define TEMP_SENSOR_IS_MAX_TC(T) (TEMP_SENSOR_##T == -5 || TEMP_SENSOR_##T == -3 || TEMP_SENSOR_##T == -2) diff --git a/Marlin/src/core/types.h b/Marlin/src/core/types.h index 335aa3a334..c9bb7d8c30 100644 --- a/Marlin/src/core/types.h +++ b/Marlin/src/core/types.h @@ -688,7 +688,7 @@ struct XYZEval { FI const T& operator[](const int n) const { return pos[n]; } // Assignment operator overrides do the expected thing - FI XYZEval& operator= (const T v) { set(LIST_N_1(NUM_AXES, v)); return *this; } + FI XYZEval& operator= (const T v) { set(LOGICAL_AXIS_LIST_1(v)); return *this; } FI XYZEval& operator= (const XYval &rs) { set(rs.x, rs.y); return *this; } FI XYZEval& operator= (const XYZval &rs) { set(NUM_AXIS_ELEM(rs)); return *this; } diff --git a/Marlin/src/core/utility.cpp b/Marlin/src/core/utility.cpp index 84e4c1f696..64f083e197 100644 --- a/Marlin/src/core/utility.cpp +++ b/Marlin/src/core/utility.cpp @@ -29,10 +29,10 @@ void safe_delay(millis_t ms) { while (ms > 50) { ms -= 50; delay(50); - thermalManager.manage_heater(); + thermalManager.task(); } delay(ms); - thermalManager.manage_heater(); // This keeps us safe if too many small safe_delay() calls are made + thermalManager.task(); // This keeps us safe if too many small safe_delay() calls are made } // A delay to provide brittle hosts time to receive bytes @@ -51,7 +51,7 @@ void safe_delay(millis_t ms) { #include "../module/probe.h" #include "../module/motion.h" - #include "../module/stepper.h" + #include "../module/planner.h" #include "../libs/numtostr.h" #include "../feature/bedlevel/bedlevel.h" @@ -70,6 +70,7 @@ void safe_delay(millis_t ms) { TERN_(NOZZLE_AS_PROBE, "NOZZLE_AS_PROBE") TERN_(FIX_MOUNTED_PROBE, "FIX_MOUNTED_PROBE") TERN_(HAS_Z_SERVO_PROBE, TERN(BLTOUCH, "BLTOUCH", "SERVO PROBE")) + TERN_(BD_SENSOR, "BD_SENSOR") TERN_(TOUCH_MI_PROBE, "TOUCH_MI_PROBE") TERN_(Z_PROBE_SLED, "Z_PROBE_SLED") TERN_(Z_PROBE_ALLEN_KEY, "Z_PROBE_ALLEN_KEY") diff --git a/Marlin/src/core/utility.h b/Marlin/src/core/utility.h index 10c8201610..2731e62b67 100644 --- a/Marlin/src/core/utility.h +++ b/Marlin/src/core/utility.h @@ -59,6 +59,11 @@ void safe_delay(millis_t ms); // Delay ensuring that temperatures are #define log_machine_info() NOOP #endif +/** + * A restorer instance remembers a variable's value before setting a + * new value, then restores the old value when it goes out of scope. + * Put operator= on your type to get extended behavior on value change. + */ template class restorer { T& ref_; diff --git a/Marlin/src/feature/babystep.cpp b/Marlin/src/feature/babystep.cpp index 54ad9588f4..2e3d6a9fd2 100644 --- a/Marlin/src/feature/babystep.cpp +++ b/Marlin/src/feature/babystep.cpp @@ -54,6 +54,18 @@ void Babystep::add_mm(const AxisEnum axis, const_float_t mm) { add_steps(axis, mm * planner.settings.axis_steps_per_mm[axis]); } +#if ENABLED(BD_SENSOR) + void Babystep::set_mm(const AxisEnum axis, const_float_t mm) { + //if (DISABLED(BABYSTEP_WITHOUT_HOMING) && axes_should_home(_BV(axis))) return; + const int16_t distance = mm * planner.settings.axis_steps_per_mm[axis]; + accum = distance; // Count up babysteps for the UI + steps[BS_AXIS_IND(axis)] = distance; + TERN_(BABYSTEP_DISPLAY_TOTAL, axis_total[BS_TOTAL_IND(axis)] = distance); + TERN_(BABYSTEP_ALWAYS_AVAILABLE, gcode.reset_stepper_timeout()); + TERN_(INTEGRATED_BABYSTEPPING, if (has_steps()) stepper.initiateBabystepping()); + } +#endif + void Babystep::add_steps(const AxisEnum axis, const int16_t distance) { if (DISABLED(BABYSTEP_WITHOUT_HOMING) && axes_should_home(_BV(axis))) return; diff --git a/Marlin/src/feature/babystep.h b/Marlin/src/feature/babystep.h index 5693afb4fc..bbf0c5a260 100644 --- a/Marlin/src/feature/babystep.h +++ b/Marlin/src/feature/babystep.h @@ -63,6 +63,10 @@ class Babystep { static void add_steps(const AxisEnum axis, const int16_t distance); static void add_mm(const AxisEnum axis, const_float_t mm); + #if ENABLED(BD_SENSOR) + static void set_mm(const AxisEnum axis, const_float_t mm); + #endif + static bool has_steps() { return steps[BS_AXIS_IND(X_AXIS)] || steps[BS_AXIS_IND(Y_AXIS)] || steps[BS_AXIS_IND(Z_AXIS)]; } diff --git a/Marlin/src/feature/bedlevel/bdl/bdl.cpp b/Marlin/src/feature/bedlevel/bdl/bdl.cpp new file mode 100644 index 0000000000..0668eb705c --- /dev/null +++ b/Marlin/src/feature/bedlevel/bdl/bdl.cpp @@ -0,0 +1,195 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program 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. + * + * This program 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 this program. If not, see . + * + */ + +#include "../../../inc/MarlinConfig.h" + +#if ENABLED(BD_SENSOR) + +#include "../../../MarlinCore.h" +#include "../../../gcode/gcode.h" +#include "../../../module/settings.h" +#include "../../../module/motion.h" +#include "../../../module/planner.h" +#include "../../../module/stepper.h" +#include "../../../module/probe.h" +#include "../../../module/temperature.h" +#include "../../../module/endstops.h" +#include "../../babystep.h" + +// I2C software Master library for segment bed heating and bed distance sensor +#include + +#include "bdl.h" +BDS_Leveling bdl; + +//#define DEBUG_OUT_BD + +// M102 S-5 Read raw Calibrate data +// M102 S-6 Start Calibrate +// M102 S4 Set the adjustable Z height value (e.g., 'M102 S4' means it will do adjusting while the Z height <= 0.4mm , disable with 'M102 S0'.) +// M102 S-1 Read sensor information + +#define MAX_BD_HEIGHT 4.0f +#define CMD_START_READ_CALIBRATE_DATA 1017 +#define CMD_END_READ_CALIBRATE_DATA 1018 +#define CMD_START_CALIBRATE 1019 +#define CMD_END_CALIBRATE 1021 +#define CMD_READ_VERSION 1016 + +I2C_SegmentBED BD_I2C_SENSOR; + +#define BD_SENSOR_I2C_ADDR 0x3C + +int8_t BDS_Leveling::config_state; +uint8_t BDS_Leveling::homing; + +void BDS_Leveling::echo_name() { SERIAL_ECHOPGM("Bed Distance Leveling"); } + +void BDS_Leveling::init(uint8_t _sda, uint8_t _scl, uint16_t delay_s) { + int ret = BD_I2C_SENSOR.i2c_init(_sda, _scl, BD_SENSOR_I2C_ADDR, delay_s); + if (ret != 1) SERIAL_ECHOLNPGM("BD_I2C_SENSOR Init Fail return code:", ret); + config_state = 0; +} + +float BDS_Leveling::read() { + const uint16_t tmp = BD_I2C_SENSOR.BD_i2c_read(); + float BD_z = NAN; + if (BD_I2C_SENSOR.BD_Check_OddEven(tmp) && (tmp & 0x3FF) < 1020) + BD_z = (tmp & 0x3FF) / 100.0f; + return BD_z; +} + +void BDS_Leveling::process() { + //if (config_state == 0) return; + static millis_t next_check_ms = 0; // starting at T=0 + static float z_pose = 0.0f; + const millis_t ms = millis(); + if (ELAPSED(ms, next_check_ms)) { // timed out (or first run) + next_check_ms = ms + (config_state < 0 ? 1000 : 100); // check at 1Hz or 10Hz + + unsigned short tmp = 0; + const float cur_z = planner.get_axis_position_mm(Z_AXIS); //current_position.z + static float old_cur_z = cur_z, + old_buf_z = current_position.z; + + tmp = BD_I2C_SENSOR.BD_i2c_read(); + if (BD_I2C_SENSOR.BD_Check_OddEven(tmp) && (tmp & 0x3FF) < 1020) { + const float z_sensor = (tmp & 0x3FF) / 100.0f; + if (cur_z < 0) config_state = 0; + //float abs_z = current_position.z > cur_z ? (current_position.z - cur_z) : (cur_z - current_position.z); + if ( cur_z < config_state * 0.1f + && config_state > 0 + && old_cur_z == cur_z + && old_buf_z == current_position.z + && z_sensor < (MAX_BD_HEIGHT) + ) { + babystep.set_mm(Z_AXIS, cur_z - z_sensor); + #if ENABLED(DEBUG_OUT_BD) + SERIAL_ECHOLNPGM("BD:", z_sensor, ", Z:", cur_z, "|", current_position.z); + #endif + } + else { + babystep.set_mm(Z_AXIS, 0); + //if (old_cur_z <= cur_z) Z_DIR_WRITE(!INVERT_Z_DIR); + stepper.set_directions(); + } + old_cur_z = cur_z; + old_buf_z = current_position.z; + endstops.bdp_state_update(z_sensor <= 0.01f); + //endstops.update(); + } + else + stepper.set_directions(); + + #if ENABLED(DEBUG_OUT_BD) + SERIAL_ECHOLNPGM("BD:", tmp & 0x3FF, ", Z:", cur_z, "|", current_position.z); + if (BD_I2C_SENSOR.BD_Check_OddEven(tmp) == 0) SERIAL_ECHOLNPGM("errorCRC"); + #endif + + if ((tmp & 0x3FF) > 1020) { + BD_I2C_SENSOR.BD_i2c_stop(); + safe_delay(10); + } + + // read raw calibrate data + if (config_state == -5) { + BD_I2C_SENSOR.BD_i2c_write(CMD_START_READ_CALIBRATE_DATA); + safe_delay(1000); + + for (int i = 0; i < MAX_BD_HEIGHT * 10; i++) { + tmp = BD_I2C_SENSOR.BD_i2c_read(); + SERIAL_ECHOLNPGM("Calibrate data:", i, ",", tmp & 0x3FF, ", check:", BD_I2C_SENSOR.BD_Check_OddEven(tmp)); + safe_delay(500); + } + config_state = 0; + BD_I2C_SENSOR.BD_i2c_write(CMD_END_READ_CALIBRATE_DATA); + safe_delay(500); + } + else if (config_state <= -6) { // Start Calibrate + safe_delay(100); + if (config_state == -6) { + //BD_I2C_SENSOR.BD_i2c_write(1019); // begin calibrate + //delay(1000); + gcode.stepper_inactive_time = SEC_TO_MS(60 * 5); + gcode.process_subcommands_now(F("M17 Z")); + gcode.process_subcommands_now(F("G1 Z0.0")); + z_pose = 0; + safe_delay(1000); + BD_I2C_SENSOR.BD_i2c_write(CMD_START_CALIBRATE); // Begin calibrate + SERIAL_ECHOLNPGM("Begin calibrate"); + safe_delay(2000); + config_state = -7; + } + else if (planner.get_axis_position_mm(Z_AXIS) < 10.0f) { + if (z_pose >= MAX_BD_HEIGHT) { + BD_I2C_SENSOR.BD_i2c_write(CMD_END_CALIBRATE); // End calibrate + SERIAL_ECHOLNPGM("End calibrate data"); + z_pose = 7; + config_state = 0; + safe_delay(1000); + } + else { + float tmp_k = 0; + char tmp_1[30]; + sprintf_P(tmp_1, PSTR("G1 Z%d.%d"), int(z_pose), int(int(z_pose * 10) % 10)); + gcode.process_subcommands_now(tmp_1); + + SERIAL_ECHO(tmp_1); + SERIAL_ECHOLNPGM(" ,Z:", current_position.z); + + while (tmp_k < (z_pose - 0.1f)) { + tmp_k = planner.get_axis_position_mm(Z_AXIS); + safe_delay(1); + } + safe_delay(800); + tmp = (z_pose + 0.0001f) * 10; + BD_I2C_SENSOR.BD_i2c_write(tmp); + SERIAL_ECHOLNPGM("w:", tmp, ",Zpose:", z_pose); + z_pose += 0.1001f; + //queue.enqueue_now_P(PSTR("G90")); + } + } + } + } +} + +#endif // BD_SENSOR diff --git a/Marlin/src/advi3pp/screens/info/sponsors.cpp b/Marlin/src/feature/bedlevel/bdl/bdl.h similarity index 51% rename from Marlin/src/advi3pp/screens/info/sponsors.cpp rename to Marlin/src/feature/bedlevel/bdl/bdl.h index 273b20f8b0..6307b1ab28 100644 --- a/Marlin/src/advi3pp/screens/info/sponsors.cpp +++ b/Marlin/src/feature/bedlevel/bdl/bdl.h @@ -1,7 +1,9 @@ /** - * ADVi3++ Firmware For Wanhao Duplicator i3 Plus (based on Marlin 2) + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] * - * Copyright (C) 2017-2022 Sebastien Andrivet [https://github.com/andrivet/] + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,22 +16,21 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . * */ +#pragma once -#include "../../parameters.h" -#include "sponsors.h" +#include -namespace ADVi3pp { +class BDS_Leveling { +public: + static int8_t config_state; + static uint8_t homing; + static void echo_name(); + static void init(uint8_t _sda, uint8_t _scl, uint16_t delay_s); + static void process(); + static float read(); +}; -Sponsors sponsors; - -//! Prepare the page before being displayed and return the right Page value -//! @return The index of the page to display -Page Sponsors::do_prepare_page() -{ - return Page::Sponsors; -} - -} +extern BDS_Leveling bdl; diff --git a/Marlin/src/feature/bedlevel/bedlevel.cpp b/Marlin/src/feature/bedlevel/bedlevel.cpp index 1ca9696a3a..9e647847a3 100644 --- a/Marlin/src/feature/bedlevel/bedlevel.cpp +++ b/Marlin/src/feature/bedlevel/bedlevel.cpp @@ -35,6 +35,8 @@ bool g29_in_progress = false; #endif +bool g29_cancel = false; // @advi3++ + #if ENABLED(LCD_BED_LEVELING) #include "../../lcd/marlinui.h" #endif @@ -154,7 +156,7 @@ void reset_bed_level() { #endif LOOP_L_N(x, sx) { SERIAL_CHAR(' '); - const float offset = values[x * sx + y]; + const float offset = values[x * sy + y]; if (!isnan(offset)) { if (offset >= 0) SERIAL_CHAR('+'); SERIAL_ECHO_F(offset, int(precision)); diff --git a/Marlin/src/feature/bedlevel/bedlevel.h b/Marlin/src/feature/bedlevel/bedlevel.h index aeafec10d6..f926a35a6e 100644 --- a/Marlin/src/feature/bedlevel/bedlevel.h +++ b/Marlin/src/feature/bedlevel/bedlevel.h @@ -33,6 +33,8 @@ constexpr bool g29_in_progress = false; #endif +extern bool g29_cancel; // @advi3++ + bool leveling_is_valid(); void set_bed_leveling_enabled(const bool enable=true); void reset_bed_level(); diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index a02918ff29..f1e88006ff 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -31,7 +31,6 @@ #include "../../../libs/hex_print.h" #include "../../../module/settings.h" #include "../../../lcd/marlinui.h" -#include "../../../module/stepper.h" #include "../../../module/planner.h" #include "../../../module/motion.h" #include "../../../module/probe.h" diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp index e6eec0de63..18110c67fa 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp @@ -26,7 +26,6 @@ #include "../bedlevel.h" #include "../../../module/planner.h" -#include "../../../module/stepper.h" #include "../../../module/motion.h" #if ENABLED(DELTA) @@ -36,8 +35,18 @@ #include "../../../MarlinCore.h" #include +//#define DEBUG_UBL_MOTION +#define DEBUG_OUT ENABLED(DEBUG_UBL_MOTION) +#include "../../../core/debug_out.h" + #if !UBL_SEGMENTED + // TODO: The first and last parts of a move might result in very short segment(s) + // after getting split on the cell boundary, so moves like that should not + // get split. This will be most common for moves that start/end near the + // corners of cells. To fix the issue, simply check if the start/end of the line + // is very close to a cell boundary in advance and don't split the line there. + void unified_bed_leveling::line_to_destination_cartesian(const_feedRate_t scaled_fr_mm_s, const uint8_t extruder) { /** * Much of the nozzle movement will be within the same cell. So we will do as little computation @@ -176,7 +185,9 @@ dest.z += z0; planner.buffer_segment(dest, scaled_fr_mm_s, extruder); - } //else printf("FIRST MOVE PRUNED "); + } + else + DEBUG_ECHOLNPGM("[ubl] skip Y segment"); } // At the final destination? Usually not, but when on a Y Mesh Line it's completed. @@ -225,7 +236,9 @@ dest.z += z0; if (!planner.buffer_segment(dest, scaled_fr_mm_s, extruder)) break; - } //else printf("FIRST MOVE PRUNED "); + } + else + DEBUG_ECHOLNPGM("[ubl] skip Y segment"); } if (xy_pos_t(current_position) != xy_pos_t(end)) @@ -360,11 +373,12 @@ #endif NOLESS(segments, 1U); // Must have at least one segment - const float inv_segments = 1.0f / segments, // Reciprocal to save calculation - segment_xyz_mm = SQRT(cart_xy_mm_2 + sq(total.z)) * inv_segments; // Length of each segment + const float inv_segments = 1.0f / segments; // Reciprocal to save calculation + // Add hints to help optimize the move + PlannerHints hints(SQRT(cart_xy_mm_2 + sq(total.z)) * inv_segments); // Length of each segment #if ENABLED(SCARA_FEEDRATE_SCALING) - const float inv_duration = scaled_fr_mm_s / segment_xyz_mm; + hints.inv_duration = scaled_fr_mm_s / hints.millimeters; #endif xyze_float_t diff = total * inv_segments; @@ -378,13 +392,9 @@ if (!planner.leveling_active || !planner.leveling_active_at_z(destination.z)) { while (--segments) { raw += diff; - planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, segment_xyz_mm - OPTARG(SCARA_FEEDRATE_SCALING, inv_duration) - ); + planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, hints); } - planner.buffer_line(destination, scaled_fr_mm_s, active_extruder, segment_xyz_mm - OPTARG(SCARA_FEEDRATE_SCALING, inv_duration) - ); + planner.buffer_line(destination, scaled_fr_mm_s, active_extruder, hints); return false; // Did not set current from destination } @@ -453,7 +463,7 @@ TERN_(ENABLE_LEVELING_FADE_HEIGHT, * fade_scaling_factor); // apply fade factor to interpolated height const float oldz = raw.z; raw.z += z_cxcy; - planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, segment_xyz_mm OPTARG(SCARA_FEEDRATE_SCALING, inv_duration) ); + planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, hints); raw.z = oldz; if (segments == 0) // done with last segment diff --git a/Marlin/src/feature/dac/dac_dac084s085.cpp b/Marlin/src/feature/dac/dac_dac084s085.cpp index b88aaf802b..772bb68de4 100644 --- a/Marlin/src/feature/dac/dac_dac084s085.cpp +++ b/Marlin/src/feature/dac/dac_dac084s085.cpp @@ -11,7 +11,6 @@ #include "dac_dac084s085.h" #include "../../MarlinCore.h" -#include "../../module/stepper.h" #include "../../HAL/shared/Delay.h" dac084s085::dac084s085() { } diff --git a/Marlin/src/feature/direct_stepping.cpp b/Marlin/src/feature/direct_stepping.cpp index 052e79de41..13cf71e076 100644 --- a/Marlin/src/feature/direct_stepping.cpp +++ b/Marlin/src/feature/direct_stepping.cpp @@ -143,14 +143,16 @@ namespace DirectStepping { // special case for 8-bit, check if rolled back to 0 if (Cfg::DIRECTIONAL || !write_page_size) { // full 256 bytes if (write_byte_idx) return true; - } else { - if (write_byte_idx < write_page_size) return true; } - } else if (Cfg::DIRECTIONAL) { - if (write_byte_idx != Cfg::PAGE_SIZE) return true; - } else { - if (write_byte_idx < write_page_size) return true; + else if (write_byte_idx < write_page_size) + return true; + } + else if (Cfg::DIRECTIONAL) { + if (write_byte_idx != Cfg::PAGE_SIZE) + return true; } + else if (write_byte_idx < write_page_size) + return true; state = State::CHECKSUM; return true; @@ -161,11 +163,10 @@ namespace DirectStepping { return true; } case State::UNFAIL: - if (c == 0) { + if (c == 0) set_page_state(write_page_idx, PageState::FREE); - } else { + else fatal_error = true; - } state = State::MONITOR; return true; } diff --git a/Marlin/src/feature/fwretract.cpp b/Marlin/src/feature/fwretract.cpp index 172c97accd..28355640d2 100644 --- a/Marlin/src/feature/fwretract.cpp +++ b/Marlin/src/feature/fwretract.cpp @@ -34,7 +34,6 @@ FWRetract fwretract; // Single instance - this calls the constructor #include "../module/motion.h" #include "../module/planner.h" -#include "../module/stepper.h" #include "../gcode/gcode.h" diff --git a/Marlin/src/feature/joystick.cpp b/Marlin/src/feature/joystick.cpp index daa642d32e..acab5d7437 100644 --- a/Marlin/src/feature/joystick.cpp +++ b/Marlin/src/feature/joystick.cpp @@ -172,8 +172,9 @@ Joystick joystick; current_position += move_dist; apply_motion_limits(current_position); const float length = sqrt(hypot2); + PlannerHints hints(length); injecting_now = true; - planner.buffer_line(current_position, length / seg_time, active_extruder, length); + planner.buffer_line(current_position, length / seg_time, active_extruder, hints); injecting_now = false; } } diff --git a/Marlin/src/feature/leds/neopixel.h b/Marlin/src/feature/leds/neopixel.h index d71aa25770..2048e2c2ee 100644 --- a/Marlin/src/feature/leds/neopixel.h +++ b/Marlin/src/feature/leds/neopixel.h @@ -131,6 +131,13 @@ class Marlin_NeoPixel { // Accessors static uint16_t pixels() { return adaneo1.numPixels() * TERN1(NEOPIXEL2_INSERIES, 2); } + static uint32_t pixel_color(const uint16_t n) { + #if ENABLED(NEOPIXEL2_INSERIES) + if (n >= NEOPIXEL_PIXELS) return adaneo2.getPixelColor(n - (NEOPIXEL_PIXELS)); + #endif + return adaneo1.getPixelColor(n); + } + static uint8_t brightness() { return adaneo1.getBrightness(); } static uint32_t Color(uint8_t r, uint8_t g, uint8_t b OPTARG(HAS_WHITE_LED, uint8_t w)) { @@ -174,6 +181,7 @@ extern Marlin_NeoPixel neo; // Accessors static uint16_t pixels() { return adaneo.numPixels();} + static uint32_t pixel_color(const uint16_t n) { return adaneo.getPixelColor(n); } static uint8_t brightness() { return adaneo.getBrightness(); } static uint32_t Color(uint8_t r, uint8_t g, uint8_t b OPTARG(HAS_WHITE_LED2, uint8_t w)) { return adaneo.Color(r, g, b OPTARG(HAS_WHITE_LED2, w)); diff --git a/Marlin/src/feature/max7219.cpp b/Marlin/src/feature/max7219.cpp index 6a4dbbec73..2fdfcba32d 100644 --- a/Marlin/src/feature/max7219.cpp +++ b/Marlin/src/feature/max7219.cpp @@ -44,7 +44,6 @@ #include "max7219.h" #include "../module/planner.h" -#include "../module/stepper.h" #include "../MarlinCore.h" #include "../HAL/shared/Delay.h" @@ -52,6 +51,7 @@ #define HAS_SIDE_BY_SIDE 1 #endif +#define _ROT ((MAX7219_ROTATE + 360) % 360) #if _ROT == 0 || _ROT == 180 #define MAX7219_X_LEDS TERN(HAS_SIDE_BY_SIDE, 8, MAX7219_LINES) #define MAX7219_Y_LEDS TERN(HAS_SIDE_BY_SIDE, MAX7219_LINES, 8) @@ -597,7 +597,15 @@ void Max7219::range16(const uint8_t y, const uint8_t ot, const uint8_t nt, const // Apply changes to update a quantity void Max7219::quantity(const uint8_t pos, const uint8_t ov, const uint8_t nv, uint8_t * const rcm/*=nullptr*/) { for (uint8_t i = _MIN(nv, ov); i < _MAX(nv, ov); i++) - led_set(i, pos, nv >= ov, rcm); + led_set( + #if MAX7219_X_LEDS >= MAX7219_Y_LEDS + i, pos // Single matrix or multiple matrices in Landscape + #else + pos, i // Multiple matrices in Portrait + #endif + , nv >= ov + , rcm + ); } void Max7219::quantity16(const uint8_t pos, const uint8_t ov, const uint8_t nv, uint8_t * const rcm/*=nullptr*/) { diff --git a/Marlin/src/feature/max7219.h b/Marlin/src/feature/max7219.h index 3fae275499..a6b110fdf4 100644 --- a/Marlin/src/feature/max7219.h +++ b/Marlin/src/feature/max7219.h @@ -47,7 +47,6 @@ #ifndef MAX7219_ROTATE #define MAX7219_ROTATE 0 #endif -#define _ROT ((MAX7219_ROTATE + 360) % 360) #ifndef MAX7219_NUMBER_UNITS #define MAX7219_NUMBER_UNITS 1 diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index 8585710830..922d118a56 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -35,10 +35,13 @@ #include "../gcode/gcode.h" #include "../module/motion.h" #include "../module/planner.h" -#include "../module/stepper.h" #include "../module/printcounter.h" #include "../module/temperature.h" +#if HAS_EXTRUDERS + #include "../module/stepper.h" +#endif + #if ENABLED(AUTO_BED_LEVELING_UBL) #include "bedlevel/bedlevel.h" #endif @@ -63,7 +66,7 @@ #include "../lcd/marlinui.h" -#if HAS_BUZZER +#if HAS_SOUND #include "../libs/buzzer.h" #endif @@ -98,7 +101,7 @@ fil_change_settings_t fc_settings[EXTRUDERS]; #define _PMSG(L) L##_LCD #endif -#if HAS_BUZZER +#if HAS_SOUND static void impatient_beep(const int8_t max_beep_count, const bool restart=false) { if (TERN0(HAS_MARLINUI_MENU, pause_mode == PAUSE_MODE_PAUSE_PRINT)) return; diff --git a/Marlin/src/feature/pause.h b/Marlin/src/feature/pause.h index beedda7c92..134b1d1b32 100644 --- a/Marlin/src/feature/pause.h +++ b/Marlin/src/feature/pause.h @@ -122,9 +122,6 @@ bool unload_filament( #endif ); -// @advi3++ -bool extrude_filament(const float &purge_length); - #else // !ADVANCED_PAUSE_FEATURE constexpr uint8_t did_pause_print = 0; diff --git a/Marlin/src/feature/power.cpp b/Marlin/src/feature/power.cpp index c2ed169aa8..8a16628bac 100644 --- a/Marlin/src/feature/power.cpp +++ b/Marlin/src/feature/power.cpp @@ -30,7 +30,7 @@ #include "power.h" #include "../module/planner.h" -#include "../module/stepper.h" +#include "../module/stepper/indirection.h" // for restore_stepper_drivers #include "../module/temperature.h" #include "../MarlinCore.h" @@ -46,6 +46,7 @@ Power powerManager; bool Power::psu_on; #if ENABLED(AUTO_POWER_CONTROL) + #include "../module/stepper.h" #include "../module/temperature.h" #if BOTH(USE_CONTROLLER_FAN, AUTO_POWER_CONTROLLERFAN) diff --git a/Marlin/src/feature/power_monitor.cpp b/Marlin/src/feature/power_monitor.cpp index 504f1ea48e..5a9db1ec24 100644 --- a/Marlin/src/feature/power_monitor.cpp +++ b/Marlin/src/feature/power_monitor.cpp @@ -53,7 +53,7 @@ PowerMonitor power_monitor; // Single instance - this calls the constructor void PowerMonitor::draw_current() { const float amps = getAmps(); lcd_put_u8str(amps < 100 ? ftostr31ns(amps) : ui16tostr4rj((uint16_t)amps)); - lcd_put_wchar('A'); + lcd_put_lchar('A'); } #endif @@ -61,7 +61,7 @@ PowerMonitor power_monitor; // Single instance - this calls the constructor void PowerMonitor::draw_voltage() { const float volts = getVolts(); lcd_put_u8str(volts < 100 ? ftostr31ns(volts) : ui16tostr4rj((uint16_t)volts)); - lcd_put_wchar('V'); + lcd_put_lchar('V'); } #endif @@ -69,7 +69,7 @@ PowerMonitor power_monitor; // Single instance - this calls the constructor void PowerMonitor::draw_power() { const float power = getPower(); lcd_put_u8str(power < 100 ? ftostr31ns(power) : ui16tostr4rj((uint16_t)power)); - lcd_put_wchar('W'); + lcd_put_lchar('W'); } #endif diff --git a/Marlin/src/feature/spindle_laser.cpp b/Marlin/src/feature/spindle_laser.cpp index 4f8f4d49dc..e7898268e8 100644 --- a/Marlin/src/feature/spindle_laser.cpp +++ b/Marlin/src/feature/spindle_laser.cpp @@ -39,18 +39,26 @@ #endif SpindleLaser cutter; -uint8_t SpindleLaser::power, +bool SpindleLaser::enable_state; // Virtual enable state, controls enable pin if present and or apply power if > 0 +uint8_t SpindleLaser::power, // Actual power output 0-255 ocr or "0 = off" > 0 = "on" SpindleLaser::last_power_applied; // = 0 // Basic power state tracking + #if ENABLED(LASER_FEATURE) - cutter_test_pulse_t SpindleLaser::testPulse = 50; // Test fire Pulse time ms value. + cutter_test_pulse_t SpindleLaser::testPulse = 50; // (ms) Test fire pulse default duration + uint8_t SpindleLaser::last_block_power; // = 0 // Track power changes for dynamic inline power + feedRate_t SpindleLaser::feedrate_mm_m = 1500, + SpindleLaser::last_feedrate_mm_m; // = 0 // (mm/min) Track feedrate changes for dynamic power #endif -bool SpindleLaser::isReady; // Ready to apply power setting from the UI to OCR -cutter_power_t SpindleLaser::menuPower, // Power set via LCD menu in PWM, PERCENT, or RPM - SpindleLaser::unitPower; // LCD status power in PWM, PERCENT, or RPM -#if ENABLED(MARLIN_DEV_MODE) - cutter_frequency_t SpindleLaser::frequency; // PWM frequency setting; range: 2K - 50K -#endif +bool SpindleLaser::isReadyForUI = false; // Ready to apply power setting from the UI to OCR +CutterMode SpindleLaser::cutter_mode = CUTTER_MODE_STANDARD; // Default is standard mode + +constexpr cutter_cpower_t SpindleLaser::power_floor; +cutter_power_t SpindleLaser::menuPower = 0, // Power value via LCD menu in PWM, PERCENT, or RPM based on configured format set by CUTTER_POWER_UNIT. + SpindleLaser::unitPower = 0; // Unit power is in PWM, PERCENT, or RPM based on CUTTER_POWER_UNIT. + +cutter_frequency_t SpindleLaser::frequency; // PWM frequency setting; range: 2K - 50K + #define SPINDLE_LASER_PWM_OFF TERN(SPINDLE_LASER_PWM_INVERT, 255, 0) /** @@ -59,20 +67,20 @@ cutter_power_t SpindleLaser::menuPower, // Power s void SpindleLaser::init() { #if ENABLED(SPINDLE_SERVO) servo[SPINDLE_SERVO_NR].move(SPINDLE_SERVO_MIN); - #else + #elif PIN_EXISTS(SPINDLE_LASER_ENA) OUT_WRITE(SPINDLE_LASER_ENA_PIN, !SPINDLE_LASER_ACTIVE_STATE); // Init spindle to off #endif #if ENABLED(SPINDLE_CHANGE_DIR) OUT_WRITE(SPINDLE_DIR_PIN, SPINDLE_INVERT_DIR); // Init rotation to clockwise (M3) #endif + #if ENABLED(HAL_CAN_SET_PWM_FREQ) && SPINDLE_LASER_FREQUENCY + frequency = SPINDLE_LASER_FREQUENCY; + hal.set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), SPINDLE_LASER_FREQUENCY); + #endif #if ENABLED(SPINDLE_LASER_USE_PWM) SET_PWM(SPINDLE_LASER_PWM_PIN); hal.set_pwm_duty(pin_t(SPINDLE_LASER_PWM_PIN), SPINDLE_LASER_PWM_OFF); // Set to lowest speed #endif - #if ENABLED(HAL_CAN_SET_PWM_FREQ) && SPINDLE_LASER_FREQUENCY - hal.set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), SPINDLE_LASER_FREQUENCY); - TERN_(MARLIN_DEV_MODE, frequency = SPINDLE_LASER_FREQUENCY); - #endif #if ENABLED(AIR_EVACUATION) OUT_WRITE(AIR_EVACUATION_PIN, !AIR_EVACUATION_ACTIVE); // Init Vacuum/Blower OFF #endif @@ -90,52 +98,62 @@ void SpindleLaser::init() { */ void SpindleLaser::_set_ocr(const uint8_t ocr) { #if ENABLED(HAL_CAN_SET_PWM_FREQ) && SPINDLE_LASER_FREQUENCY - hal.set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), TERN(MARLIN_DEV_MODE, frequency, SPINDLE_LASER_FREQUENCY)); + hal.set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), frequency); #endif hal.set_pwm_duty(pin_t(SPINDLE_LASER_PWM_PIN), ocr ^ SPINDLE_LASER_PWM_OFF); } void SpindleLaser::set_ocr(const uint8_t ocr) { - WRITE(SPINDLE_LASER_ENA_PIN, SPINDLE_LASER_ACTIVE_STATE); // Cutter ON + #if PIN_EXISTS(SPINDLE_LASER_ENA) + WRITE(SPINDLE_LASER_ENA_PIN, SPINDLE_LASER_ACTIVE_STATE); // Cutter ON + #endif _set_ocr(ocr); } void SpindleLaser::ocr_off() { - WRITE(SPINDLE_LASER_ENA_PIN, !SPINDLE_LASER_ACTIVE_STATE); // Cutter OFF + #if PIN_EXISTS(SPINDLE_LASER_ENA) + WRITE(SPINDLE_LASER_ENA_PIN, !SPINDLE_LASER_ACTIVE_STATE); // Cutter OFF + #endif _set_ocr(0); } #endif // SPINDLE_LASER_USE_PWM /** - * Apply power for laser/spindle + * Apply power for Laser or Spindle * * Apply cutter power value for PWM, Servo, and on/off pin. * - * @param opwr Power value. Range 0 to MAX. When 0 disable spindle/laser. + * @param opwr Power value. Range 0 to MAX. */ void SpindleLaser::apply_power(const uint8_t opwr) { - if (opwr == last_power_applied) return; - last_power_applied = opwr; - power = opwr; - #if ENABLED(SPINDLE_LASER_USE_PWM) - if (cutter.unitPower == 0 && CUTTER_UNIT_IS(RPM)) { - ocr_off(); - isReady = false; - } - else if (ENABLED(CUTTER_POWER_RELATIVE) || enabled()) { - set_ocr(power); - isReady = true; - } - else { - ocr_off(); - isReady = false; - } - #elif ENABLED(SPINDLE_SERVO) - servo[SPINDLE_SERVO_NR].move(power); - #else - WRITE(SPINDLE_LASER_ENA_PIN, enabled() ? SPINDLE_LASER_ACTIVE_STATE : !SPINDLE_LASER_ACTIVE_STATE); - isReady = true; - #endif + if (enabled() || opwr == 0) { // 0 check allows us to disable where no ENA pin exists + // Test and set the last power used to improve performance + if (opwr == last_power_applied) return; + last_power_applied = opwr; + // Handle PWM driven or just simple on/off + #if ENABLED(SPINDLE_LASER_USE_PWM) + if (CUTTER_UNIT_IS(RPM) && unitPower == 0) + ocr_off(); + else if (ENABLED(CUTTER_POWER_RELATIVE) || enabled() || opwr == 0) { + set_ocr(opwr); + isReadyForUI = true; + } + else + ocr_off(); + #elif ENABLED(SPINDLE_SERVO) + MOVE_SERVO(SPINDLE_SERVO_NR, power); + #else + WRITE(SPINDLE_LASER_ENA_PIN, enabled() ? SPINDLE_LASER_ACTIVE_STATE : !SPINDLE_LASER_ACTIVE_STATE); + isReadyForUI = true; + #endif + } + else { + #if PIN_EXISTS(SPINDLE_LASER_ENA) + WRITE(SPINDLE_LASER_ENA_PIN, !SPINDLE_LASER_ACTIVE_STATE); + #endif + isReadyForUI = false; // Only used for UI display updates. + TERN_(SPINDLE_LASER_USE_PWM, ocr_off()); + } } #if ENABLED(SPINDLE_CHANGE_DIR) diff --git a/Marlin/src/feature/spindle_laser.h b/Marlin/src/feature/spindle_laser.h index 808fa634e1..b667da25bb 100644 --- a/Marlin/src/feature/spindle_laser.h +++ b/Marlin/src/feature/spindle_laser.h @@ -34,85 +34,98 @@ #include "../libs/buzzer.h" #endif -#if ENABLED(LASER_POWER_INLINE) - #include "../module/planner.h" -#endif +// Inline laser power +#include "../module/planner.h" #define PCT_TO_PWM(X) ((X) * 255 / 100) #define PCT_TO_SERVO(X) ((X) * 180 / 100) + +// Laser/Cutter operation mode +enum CutterMode : int8_t { + CUTTER_MODE_ERROR = -1, + CUTTER_MODE_STANDARD, // M3 power is applied directly and waits for planner moves to sync. + CUTTER_MODE_CONTINUOUS, // M3 or G1/2/3 move power is controlled within planner blocks, set with 'M3 I', cleared with 'M5 I'. + CUTTER_MODE_DYNAMIC // M4 laser power is proportional to the feed rate, set with 'M4 I', cleared with 'M5 I'. +}; + class SpindleLaser { public: - static const inline uint8_t pct_to_ocr(const_float_t pct) { return uint8_t(PCT_TO_PWM(pct)); } + static CutterMode cutter_mode; - // cpower = configured values (e.g., SPEED_POWER_MAX) + static constexpr uint8_t pct_to_ocr(const_float_t pct) { return uint8_t(PCT_TO_PWM(pct)); } + // cpower = configured values (e.g., SPEED_POWER_MAX) // Convert configured power range to a percentage - static const inline uint8_t cpwr_to_pct(const cutter_cpower_t cpwr) { - constexpr cutter_cpower_t power_floor = TERN(CUTTER_POWER_RELATIVE, SPEED_POWER_MIN, 0), - power_range = SPEED_POWER_MAX - power_floor; - return cpwr ? round(100.0f * (cpwr - power_floor) / power_range) : 0; + static constexpr cutter_cpower_t power_floor = TERN(CUTTER_POWER_RELATIVE, SPEED_POWER_MIN, 0); + static constexpr uint8_t cpwr_to_pct(const cutter_cpower_t cpwr) { + return cpwr ? round(100.0f * (cpwr - power_floor) / (SPEED_POWER_MAX - power_floor)) : 0; } - // Convert a cpower (e.g., SPEED_POWER_STARTUP) to unit power (upwr, upower), - // which can be PWM, Percent, Servo angle, or RPM (rel/abs). - static const inline cutter_power_t cpwr_to_upwr(const cutter_cpower_t cpwr) { // STARTUP power to Unit power - const cutter_power_t upwr = ( + // Convert config defines from RPM to %, angle or PWM when in Spindle mode + // and convert from PERCENT to PWM when in Laser mode + static constexpr cutter_power_t cpwr_to_upwr(const cutter_cpower_t cpwr) { // STARTUP power to Unit power + return ( #if ENABLED(SPINDLE_FEATURE) - // Spindle configured values are in RPM + // Spindle configured define values are in RPM #if CUTTER_UNIT_IS(RPM) - cpwr // to RPM - #elif CUTTER_UNIT_IS(PERCENT) // to PCT - cpwr_to_pct(cpwr) - #elif CUTTER_UNIT_IS(SERVO) // to SERVO angle - PCT_TO_SERVO(cpwr_to_pct(cpwr)) - #else // to PWM - PCT_TO_PWM(cpwr_to_pct(cpwr)) + cpwr // to same + #elif CUTTER_UNIT_IS(PERCENT) + cpwr_to_pct(cpwr) // to Percent + #elif CUTTER_UNIT_IS(SERVO) + PCT_TO_SERVO(cpwr_to_pct(cpwr)) // to SERVO angle + #else + PCT_TO_PWM(cpwr_to_pct(cpwr)) // to PWM #endif #else - // Laser configured values are in PCT + // Laser configured define values are in Percent #if CUTTER_UNIT_IS(PWM255) - PCT_TO_PWM(cpwr) + PCT_TO_PWM(cpwr) // to PWM #else - cpwr // to RPM/PCT + cpwr // to same #endif #endif ); - return upwr; } - static const cutter_power_t mpower_min() { return cpwr_to_upwr(SPEED_POWER_MIN); } - static const cutter_power_t mpower_max() { return cpwr_to_upwr(SPEED_POWER_MAX); } + static constexpr cutter_power_t mpower_min() { return cpwr_to_upwr(SPEED_POWER_MIN); } + static constexpr cutter_power_t mpower_max() { return cpwr_to_upwr(SPEED_POWER_MAX); } #if ENABLED(LASER_FEATURE) - static cutter_test_pulse_t testPulse; // Test fire Pulse ms value + static cutter_test_pulse_t testPulse; // (ms) Test fire pulse duration + static uint8_t last_block_power; // Track power changes for dynamic power + + static feedRate_t feedrate_mm_m, last_feedrate_mm_m; // (mm/min) Track feedrate changes for dynamic power + static bool laser_feedrate_changed() { + const bool changed = last_feedrate_mm_m != feedrate_mm_m; + if (changed) last_feedrate_mm_m = feedrate_mm_m; + return changed; + } #endif - static bool isReady; // Ready to apply power setting from the UI to OCR + static bool isReadyForUI; // Ready to apply power setting from the UI to OCR + static bool enable_state; static uint8_t power, last_power_applied; // Basic power state tracking - #if ENABLED(MARLIN_DEV_MODE) - static cutter_frequency_t frequency; // Set PWM frequency; range: 2K-50K - #endif + static cutter_frequency_t frequency; // Set PWM frequency; range: 2K-50K static cutter_power_t menuPower, // Power as set via LCD menu in PWM, Percentage or RPM unitPower; // Power as displayed status in PWM, Percentage or RPM static void init(); - #if ENABLED(MARLIN_DEV_MODE) + #if ENABLED(HAL_CAN_SET_PWM_FREQ) && SPINDLE_LASER_FREQUENCY static void refresh_frequency() { hal.set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), frequency); } #endif // Modifying this function should update everywhere static bool enabled(const cutter_power_t opwr) { return opwr > 0; } - static bool enabled() { return enabled(power); } + static bool enabled() { return enable_state; } static void apply_power(const uint8_t inpow); FORCE_INLINE static void refresh() { apply_power(power); } - FORCE_INLINE static void set_power(const uint8_t upwr) { power = upwr; refresh(); } #if ENABLED(SPINDLE_LASER_USE_PWM) @@ -123,7 +136,6 @@ class SpindleLaser { public: static void set_ocr(const uint8_t ocr); - static void ocr_set_power(const uint8_t ocr) { power = ocr; set_ocr(ocr); } static void ocr_off(); /** @@ -141,78 +153,76 @@ class SpindleLaser { ); } - /** - * Correct power to configured range - */ - static cutter_power_t power_to_range(const cutter_power_t pwr) { - return power_to_range(pwr, _CUTTER_POWER(CUTTER_POWER_UNIT)); - } - - static cutter_power_t power_to_range(const cutter_power_t pwr, const uint8_t pwrUnit) { - static constexpr float - min_pct = TERN(CUTTER_POWER_RELATIVE, 0, TERN(SPINDLE_FEATURE, round(100.0f * (SPEED_POWER_MIN) / (SPEED_POWER_MAX)), SPEED_POWER_MIN)), - max_pct = TERN(SPINDLE_FEATURE, 100, SPEED_POWER_MAX); - if (pwr <= 0) return 0; - cutter_power_t upwr; - switch (pwrUnit) { - case _CUTTER_POWER_PWM255: - upwr = cutter_power_t( - (pwr < pct_to_ocr(min_pct)) ? pct_to_ocr(min_pct) // Use minimum if set below - : (pwr > pct_to_ocr(max_pct)) ? pct_to_ocr(max_pct) // Use maximum if set above - : pwr - ); - break; - case _CUTTER_POWER_PERCENT: - upwr = cutter_power_t( - (pwr < min_pct) ? min_pct // Use minimum if set below - : (pwr > max_pct) ? max_pct // Use maximum if set above - : pwr // PCT - ); - break; - case _CUTTER_POWER_RPM: - upwr = cutter_power_t( - (pwr < SPEED_POWER_MIN) ? SPEED_POWER_MIN // Use minimum if set below - : (pwr > SPEED_POWER_MAX) ? SPEED_POWER_MAX // Use maximum if set above - : pwr // Calculate OCR value - ); - break; - default: break; - } - return upwr; - } - #endif // SPINDLE_LASER_USE_PWM /** - * Enable/Disable spindle/laser - * @param enable true = enable; false = disable + * Correct power to configured range */ - static void set_enabled(const bool enable) { - uint8_t value = 0; - if (enable) { - #if ENABLED(SPINDLE_LASER_USE_PWM) - if (power) - value = power; - else if (unitPower) - value = upower_to_ocr(cpwr_to_upwr(SPEED_POWER_STARTUP)); - #else - value = 255; - #endif + static cutter_power_t power_to_range(const cutter_power_t pwr, const uint8_t pwrUnit=_CUTTER_POWER(CUTTER_POWER_UNIT)) { + static constexpr float + min_pct = TERN(CUTTER_POWER_RELATIVE, 0, TERN(SPINDLE_FEATURE, round(100.0f * (SPEED_POWER_MIN) / (SPEED_POWER_MAX)), SPEED_POWER_MIN)), + max_pct = TERN(SPINDLE_FEATURE, 100, SPEED_POWER_MAX); + if (pwr <= 0) return 0; + cutter_power_t upwr; + switch (pwrUnit) { + case _CUTTER_POWER_PWM255: { // PWM + const uint8_t pmin = pct_to_ocr(min_pct), pmax = pct_to_ocr(max_pct); + upwr = cutter_power_t(constrain(pwr, pmin, pmax)); + } break; + case _CUTTER_POWER_PERCENT: // Percent + upwr = cutter_power_t(constrain(pwr, min_pct, max_pct)); + break; + case _CUTTER_POWER_RPM: // Calculate OCR value + upwr = cutter_power_t(constrain(pwr, SPEED_POWER_MIN, SPEED_POWER_MAX)); + break; + default: break; } - set_power(value); + return upwr; } - static void disable() { isReady = false; set_enabled(false); } - /** - * Wait for spindle to spin up or spin down + * Enable Laser or Spindle output. + * It's important to prevent changing the power output value during inline cutter operation. + * Inline power is adjusted in the planner to support LASER_TRAP_POWER and CUTTER_MODE_DYNAMIC mode. + * + * This method accepts one of the following control states: + * + * - For CUTTER_MODE_STANDARD the cutter power is either full on/off or ocr-based and it will apply + * SPEED_POWER_STARTUP if no value is assigned. * - * @param on true = state to on; false = state to off. + * - For CUTTER_MODE_CONTINUOUS inline and power remains where last set and the cutter output enable flag is set. + * + * - CUTTER_MODE_DYNAMIC is also inline-based and it just sets the enable output flag. + * + * - For CUTTER_MODE_ERROR set the output enable_state flag directly and set power to 0 for any mode. + * This mode allows a global power shutdown action to occur. */ - static void power_delay(const bool on) { - #if DISABLED(LASER_POWER_INLINE) - safe_delay(on ? SPINDLE_LASER_POWERUP_DELAY : SPINDLE_LASER_POWERDOWN_DELAY); + static void set_enabled(bool enable) { + switch (cutter_mode) { + case CUTTER_MODE_STANDARD: + apply_power(enable ? TERN(SPINDLE_LASER_USE_PWM, (power ?: (unitPower ? upower_to_ocr(cpwr_to_upwr(SPEED_POWER_STARTUP)) : 0)), 255) : 0); + break; + case CUTTER_MODE_CONTINUOUS: + TERN_(LASER_FEATURE, set_inline_enabled(enable)); + break; + case CUTTER_MODE_DYNAMIC: + TERN_(LASER_FEATURE, set_inline_enabled(enable)); + break; + case CUTTER_MODE_ERROR: // Error mode, no enable and kill power. + enable = false; + apply_power(0); + } + #if SPINDLE_LASER_ENA_PIN + WRITE(SPINDLE_LASER_ENA_PIN, enable ? SPINDLE_LASER_ACTIVE_STATE : !SPINDLE_LASER_ACTIVE_STATE); #endif + enable_state = enable; + } + + static void disable() { isReadyForUI = false; set_enabled(false); } + + // Wait for spindle/laser to startup or shutdown + static void power_delay(const bool on) { + safe_delay(on ? SPINDLE_LASER_POWERUP_DELAY : SPINDLE_LASER_POWERDOWN_DELAY); } #if ENABLED(SPINDLE_CHANGE_DIR) @@ -224,122 +234,98 @@ class SpindleLaser { #endif #if ENABLED(AIR_EVACUATION) - static void air_evac_enable(); // Turn On Cutter Vacuum or Laser Blower motor - static void air_evac_disable(); // Turn Off Cutter Vacuum or Laser Blower motor - static void air_evac_toggle(); // Toggle Cutter Vacuum or Laser Blower motor - static bool air_evac_state() { // Get current state + static void air_evac_enable(); // Turn On Cutter Vacuum or Laser Blower motor + static void air_evac_disable(); // Turn Off Cutter Vacuum or Laser Blower motor + static void air_evac_toggle(); // Toggle Cutter Vacuum or Laser Blower motor + static bool air_evac_state() { // Get current state return (READ(AIR_EVACUATION_PIN) == AIR_EVACUATION_ACTIVE); } #endif #if ENABLED(AIR_ASSIST) - static void air_assist_enable(); // Turn on air assist - static void air_assist_disable(); // Turn off air assist - static void air_assist_toggle(); // Toggle air assist - static bool air_assist_state() { // Get current state + static void air_assist_enable(); // Turn on air assist + static void air_assist_disable(); // Turn off air assist + static void air_assist_toggle(); // Toggle air assist + static bool air_assist_state() { // Get current state return (READ(AIR_ASSIST_PIN) == AIR_ASSIST_ACTIVE); } #endif #if HAS_MARLINUI_MENU - static void enable_with_dir(const bool reverse) { - isReady = true; - const uint8_t ocr = TERN(SPINDLE_LASER_USE_PWM, upower_to_ocr(menuPower), 255); - if (menuPower) - power = ocr; - else - menuPower = cpwr_to_upwr(SPEED_POWER_STARTUP); - unitPower = menuPower; - set_reverse(reverse); - set_enabled(true); - } - FORCE_INLINE static void enable_forward() { enable_with_dir(false); } - FORCE_INLINE static void enable_reverse() { enable_with_dir(true); } - FORCE_INLINE static void enable_same_dir() { enable_with_dir(is_reverse()); } + + #if ENABLED(SPINDLE_FEATURE) + static void enable_with_dir(const bool reverse) { + isReadyForUI = true; + const uint8_t ocr = TERN(SPINDLE_LASER_USE_PWM, upower_to_ocr(menuPower), 255); + if (menuPower) + power = ocr; + else + menuPower = cpwr_to_upwr(SPEED_POWER_STARTUP); + unitPower = menuPower; + set_reverse(reverse); + set_enabled(true); + } + FORCE_INLINE static void enable_forward() { enable_with_dir(false); } + FORCE_INLINE static void enable_reverse() { enable_with_dir(true); } + FORCE_INLINE static void enable_same_dir() { enable_with_dir(is_reverse()); } + #endif // SPINDLE_FEATURE #if ENABLED(SPINDLE_LASER_USE_PWM) static void update_from_mpower() { - if (isReady) power = upower_to_ocr(menuPower); + if (isReadyForUI) power = upower_to_ocr(menuPower); unitPower = menuPower; } #endif #if ENABLED(LASER_FEATURE) + // Toggle the laser on/off with menuPower. Apply SPEED_POWER_STARTUP if it was 0 on entry. + static void menu_set_enabled(const bool state) { + set_enabled(state); + if (state) { + if (!menuPower) menuPower = cpwr_to_upwr(SPEED_POWER_STARTUP); + power = upower_to_ocr(menuPower); + apply_power(power); + } else + apply_power(0); + } + /** * Test fire the laser using the testPulse ms duration * Also fires with any PWM power that was previous set * If not set defaults to 80% power */ static void test_fire_pulse() { - TERN_(HAS_BEEPER, buzzer.tone(30, 3000)); - enable_forward(); // Turn Laser on (Spindle speak but same funct) - delay(testPulse); // Delay for time set by user in pulse ms menu screen. - disable(); // Turn laser off + BUZZ(30, 3000); + cutter_mode = CUTTER_MODE_STANDARD; // Menu needs standard mode. + menu_set_enabled(true); // Laser On + delay(testPulse); // Delay for time set by user in pulse ms menu screen. + menu_set_enabled(false); // Laser Off } - #endif + #endif // LASER_FEATURE #endif // HAS_MARLINUI_MENU - #if ENABLED(LASER_POWER_INLINE) - /** - * Inline power adds extra fields to the planner block - * to handle laser power and scale to movement speed. - */ + #if ENABLED(LASER_FEATURE) - // Force disengage planner power control - static void inline_disable() { - isReady = false; - unitPower = 0; - planner.laser_inline.status.isPlanned = false; - planner.laser_inline.status.isEnabled = false; - planner.laser_inline.power = 0; + // Dynamic mode rate calculation + static uint8_t calc_dynamic_power() { + if (feedrate_mm_m > 65535) return 255; // Too fast, go always on + uint16_t rate = uint16_t(feedrate_mm_m); // 16 bits from the G-code parser float input + rate >>= 8; // Take the G-code input e.g. F40000 and shift off the lower bits to get an OCR value from 1-255 + return uint8_t(rate); } // Inline modes of all other functions; all enable planner inline power control - static void set_inline_enabled(const bool enable) { - if (enable) - inline_power(255); - else { - isReady = false; - unitPower = menuPower = 0; - planner.laser_inline.status.isPlanned = false; - TERN(SPINDLE_LASER_USE_PWM, inline_ocr_power, inline_power)(0); - } - } + static void set_inline_enabled(const bool enable) { planner.laser_inline.status.isEnabled = enable; } // Set the power for subsequent movement blocks - static void inline_power(const cutter_power_t upwr) { - unitPower = menuPower = upwr; - #if ENABLED(SPINDLE_LASER_USE_PWM) - #if ENABLED(SPEED_POWER_RELATIVE) && !CUTTER_UNIT_IS(RPM) // relative mode does not turn laser off at 0, except for RPM - planner.laser_inline.status.isEnabled = true; - planner.laser_inline.power = upower_to_ocr(upwr); - isReady = true; - #else - inline_ocr_power(upower_to_ocr(upwr)); - #endif - #else - planner.laser_inline.status.isEnabled = enabled(upwr); - planner.laser_inline.power = upwr; - isReady = enabled(upwr); - #endif + static void inline_power(const cutter_power_t cpwr) { + TERN(SPINDLE_LASER_USE_PWM, power = planner.laser_inline.power = cpwr, planner.laser_inline.power = cpwr > 0 ? 255 : 0); } - static void inline_direction(const bool) { /* never */ } - - #if ENABLED(SPINDLE_LASER_USE_PWM) - static void inline_ocr_power(const uint8_t ocrpwr) { - isReady = ocrpwr > 0; - planner.laser_inline.status.isEnabled = ocrpwr > 0; - planner.laser_inline.power = ocrpwr; - } - #endif - #endif // LASER_POWER_INLINE + #endif // LASER_FEATURE - static void kill() { - TERN_(LASER_POWER_INLINE, inline_disable()); - disable(); - } + static void kill() { disable(); } }; extern SpindleLaser cutter; diff --git a/Marlin/src/feature/spindle_laser_types.h b/Marlin/src/feature/spindle_laser_types.h index d249a20e75..2f36a68a1a 100644 --- a/Marlin/src/feature/spindle_laser_types.h +++ b/Marlin/src/feature/spindle_laser_types.h @@ -74,12 +74,10 @@ typedef IF<(SPEED_POWER_MAX > 255), uint16_t, uint8_t>::type cutter_cpower_t; #endif #endif +typedef uint16_t cutter_frequency_t; + #if ENABLED(LASER_FEATURE) typedef uint16_t cutter_test_pulse_t; #define CUTTER_MENU_PULSE_TYPE uint16_3 -#endif - -#if ENABLED(MARLIN_DEV_MODE) - typedef uint16_t cutter_frequency_t; #define CUTTER_MENU_FREQUENCY_TYPE uint16_5 #endif diff --git a/Marlin/src/feature/tmc_util.cpp b/Marlin/src/feature/tmc_util.cpp index cb970c7ebc..0867686363 100644 --- a/Marlin/src/feature/tmc_util.cpp +++ b/Marlin/src/feature/tmc_util.cpp @@ -33,17 +33,12 @@ #include "../gcode/gcode.h" #if ENABLED(TMC_DEBUG) - #include "../module/planner.h" #include "../libs/hex_print.h" #if ENABLED(MONITOR_DRIVER_STATUS) static uint16_t report_tmc_status_interval; // = 0 #endif #endif -#if HAS_MARLINUI_MENU - #include "../module/stepper.h" -#endif - /** * Check for over temperature or short to ground error flags. * Report and log warning of overtemperature condition. diff --git a/Marlin/src/gcode/bedlevel/G26.cpp b/Marlin/src/gcode/bedlevel/G26.cpp index 21fa08fc10..aa6e0c1f0c 100644 --- a/Marlin/src/gcode/bedlevel/G26.cpp +++ b/Marlin/src/gcode/bedlevel/G26.cpp @@ -107,7 +107,6 @@ #include "../../MarlinCore.h" #include "../../module/planner.h" -#include "../../module/stepper.h" #include "../../module/motion.h" #include "../../module/tool_change.h" #include "../../module/temperature.h" @@ -306,7 +305,7 @@ typedef struct { LIMIT(e.x, X_MIN_POS + 1, X_MAX_POS - 1); #endif - if (position_is_reachable(s.x, s.y) && position_is_reachable(e.x, e.y)) + if (position_is_reachable(s) && position_is_reachable(e)) print_line_from_here_to_there(s, e); } } diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index 34c5614505..d9615e8d79 100755 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -32,7 +32,6 @@ #include "../../../feature/bedlevel/bedlevel.h" #include "../../../module/motion.h" #include "../../../module/planner.h" -#include "../../../module/stepper.h" #include "../../../module/probe.h" #include "../../queue.h" @@ -74,18 +73,20 @@ #endif #endif -static void pre_g29_return(const bool retry, const bool did) { +// @advi3++ add failure +static void pre_g29_return(const bool retry, const bool failure, const bool did) { if (!retry) { TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_IDLE, false)); } - if (did) { + if (true) { // @advi3++ always call onLevelingDone TERN_(HAS_DWIN_E3V2_BASIC, DWIN_LevelingDone()); - TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone()); + TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone(!failure && did)); } } +// @advi3++ #define G29_RETURN(retry, did) do{ \ - pre_g29_return(TERN0(G29_RETRY_AND_RECOVER, retry), did); \ + pre_g29_return(TERN0(G29_RETRY_AND_RECOVER, retry), retry, did); \ return TERN_(G29_RETRY_AND_RECOVER, retry); \ }while(0) @@ -437,6 +438,7 @@ G29_TYPE GcodeSuite::G29() { TERN_(DWIN_LCD_PROUI, DWIN_LevelingStart()); #endif + ::g29_cancel = false; // @advi3++ TERN_(EXTENSIBLE_UI, ExtUI::onLevelingStart()); if (!faux) { @@ -711,13 +713,14 @@ G29_TYPE GcodeSuite::G29() { if (abl.verbose_level) SERIAL_ECHOLNPGM("Probing mesh point ", pt_index, "/", abl.abl_points, "."); // @advi3++: Display x, y + ExtUI::onLevelingProgress(pt_index, abl.probePos.x, abl.probePos.y); //TERN_(HAS_STATUS_MESSAGE, ui.status_printf(0, F(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_POINT), int(pt_index), int(abl.abl_points))); - TERN_(HAS_STATUS_MESSAGE, ui.status_printf(0, F(S_FMT " %i/%i (%i, %i mm)"), - GET_TEXT(MSG_PROBING_POINT), - int(pt_index), - int(abl.abl_points), - int(abl.probePos.x), - int(abl.probePos.y))); + + // @advi3++ + if(::g29_cancel) { + abl.measured_z = NAN; // To break loops + break; + } abl.measured_z = faux ? 0.001f * random(-100, 101) : probe.probe_at_point(abl.probePos, raise_after, abl.verbose_level); diff --git a/Marlin/src/gcode/bedlevel/mbl/G29.cpp b/Marlin/src/gcode/bedlevel/mbl/G29.cpp index b9440f78b2..27ee1b070e 100644 --- a/Marlin/src/gcode/bedlevel/mbl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/mbl/G29.cpp @@ -36,7 +36,7 @@ #include "../../../libs/buzzer.h" #include "../../../lcd/marlinui.h" #include "../../../module/motion.h" -#include "../../../module/stepper.h" +#include "../../../module/planner.h" #if ENABLED(EXTENSIBLE_UI) #include "../../../lcd/extui/ui_api.h" @@ -206,7 +206,7 @@ void GcodeSuite::G29() { #endif TERN_(LCD_BED_LEVELING, ui.wait_for_move = false); - TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone()); + TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone(true)); // @advi3++ } break; diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index 27551fb109..a6dff2d75a 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -24,8 +24,9 @@ #include "../gcode.h" -#include "../../module/stepper.h" #include "../../module/endstops.h" +#include "../../module/planner.h" +#include "../../module/stepper.h" // for various #if HAS_MULTI_HOTEND #include "../../module/tool_change.h" @@ -35,6 +36,10 @@ #include "../../feature/bedlevel/bedlevel.h" #endif +#if ENABLED(BD_SENSOR) + #include "../../feature/bedlevel/bdl/bdl.h" +#endif + #if ENABLED(SENSORLESS_HOMING) #include "../../feature/tmc_util.h" #endif @@ -55,11 +60,7 @@ #include "../../lcd/e3v2/proui/dwin.h" #endif -#if HAS_L64XX // set L6470 absolute position registers to counts - #include "../../libs/L64XX/L64XX_Marlin.h" -#endif - -#if ENABLED(LASER_MOVE_G28_OFF) +#if ENABLED(LASER_FEATURE) #include "../../feature/spindle_laser.h" #endif @@ -169,7 +170,7 @@ motion_state.jerk_state = planner.max_jerk; planner.max_jerk.set(0, 0 OPTARG(DELTA, 0)); #endif - planner.reset_acceleration_rates(); + planner.refresh_acceleration_rates(); return motion_state; } @@ -178,7 +179,7 @@ planner.settings.max_acceleration_mm_per_s2[Y_AXIS] = motion_state.acceleration.y; TERN_(DELTA, planner.settings.max_acceleration_mm_per_s2[Z_AXIS] = motion_state.acceleration.z); TERN_(HAS_CLASSIC_JERK, planner.max_jerk = motion_state.jerk_state); - planner.reset_acceleration_rates(); + planner.refresh_acceleration_rates(); } #endif // IMPROVE_HOMING_RELIABILITY @@ -205,7 +206,14 @@ void GcodeSuite::G28() { DEBUG_SECTION(log_G28, "G28", DEBUGGING(LEVELING)); if (DEBUGGING(LEVELING)) log_machine_info(); - TERN_(LASER_MOVE_G28_OFF, cutter.set_inline_enabled(false)); // turn off laser + TERN_(BD_SENSOR, bdl.config_state = 0); + + /** + * Set the laser power to false to stop the planner from processing the current power setting. + */ + #if ENABLED(LASER_FEATURE) + planner.laser_inline.status.isPowered = false; + #endif #if ENABLED(DUAL_X_CARRIAGE) bool IDEX_saved_duplication_state = extruder_duplication_enabled; @@ -596,20 +604,4 @@ void GcodeSuite::G28() { TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(old_grblstate)); - #if HAS_L64XX - // Set L6470 absolute position registers to counts - // constexpr *might* move this to PROGMEM. - // If not, this will need a PROGMEM directive and an accessor. - #define _EN_ITEM(N) , E_AXIS - static constexpr AxisEnum L64XX_axis_xref[MAX_L64XX] = { - NUM_AXIS_LIST(X_AXIS, Y_AXIS, Z_AXIS, I_AXIS, J_AXIS, K_AXIS, U_AXIS, V_AXIS, W_AXIS), - X_AXIS, Y_AXIS, Z_AXIS, Z_AXIS, Z_AXIS - REPEAT(E_STEPPERS, _EN_ITEM) - }; - #undef _EN_ITEM - for (uint8_t j = 1; j <= L64XX::chain[0]; j++) { - const uint8_t cv = L64XX::chain[j]; - L64xxManager.set_param((L64XX_axis_t)cv, L6470_ABS_POS, stepper.position(L64XX_axis_xref[cv])); - } - #endif } diff --git a/Marlin/src/gcode/calibrate/G33.cpp b/Marlin/src/gcode/calibrate/G33.cpp index ffe53b63fb..656c23cb78 100644 --- a/Marlin/src/gcode/calibrate/G33.cpp +++ b/Marlin/src/gcode/calibrate/G33.cpp @@ -27,7 +27,7 @@ #include "../gcode.h" #include "../../module/delta.h" #include "../../module/motion.h" -#include "../../module/stepper.h" +#include "../../module/planner.h" #include "../../module/endstops.h" #include "../../lcd/marlinui.h" diff --git a/Marlin/src/gcode/calibrate/G34.cpp b/Marlin/src/gcode/calibrate/G34.cpp index 6fdebb69b0..1be3952ffe 100644 --- a/Marlin/src/gcode/calibrate/G34.cpp +++ b/Marlin/src/gcode/calibrate/G34.cpp @@ -26,9 +26,12 @@ #include "../gcode.h" #include "../../module/motion.h" -#include "../../module/stepper.h" #include "../../module/endstops.h" +#if ANY(HAS_MOTOR_CURRENT_SPI, HAS_MOTOR_CURRENT_PWM, HAS_TRINAMIC_CONFIG) + #include "../../module/stepper.h" +#endif + #if HAS_LEVELING #include "../../feature/bedlevel/bedlevel.h" #endif diff --git a/Marlin/src/gcode/calibrate/G34_M422.cpp b/Marlin/src/gcode/calibrate/G34_M422.cpp index d68207885d..8cf652cd84 100644 --- a/Marlin/src/gcode/calibrate/G34_M422.cpp +++ b/Marlin/src/gcode/calibrate/G34_M422.cpp @@ -224,13 +224,15 @@ void GcodeSuite::G34() { // Safe clearance even on an incline if ((iteration == 0 || i > 0) && z_probe > current_position.z) do_blocking_move_to_z(z_probe); + xy_pos_t &ppos = z_stepper_align.xy[iprobe]; + if (DEBUGGING(LEVELING)) - DEBUG_ECHOLNPGM_P(PSTR("Probing X"), z_stepper_align.xy[iprobe].x, SP_Y_STR, z_stepper_align.xy[iprobe].y); + DEBUG_ECHOLNPGM_P(PSTR("Probing X"), ppos.x, SP_Y_STR, ppos.y); // Probe a Z height for each stepper. // Probing sanity check is disabled, as it would trigger even in normal cases because // current_position.z has been manually altered in the "dirty trick" above. - const float z_probed_height = probe.probe_at_point(z_stepper_align.xy[iprobe], raise_after, 0, true, false); + const float z_probed_height = probe.probe_at_point(DIFF_TERN(HAS_HOME_OFFSET, ppos, xy_pos_t(home_offset)), raise_after, 0, true, false); if (isnan(z_probed_height)) { SERIAL_ECHOLNPGM("Probing failed"); LCD_MESSAGE(MSG_LCD_PROBING_FAILED); diff --git a/Marlin/src/gcode/calibrate/M665.cpp b/Marlin/src/gcode/calibrate/M665.cpp index aa21471b60..7dc657a61b 100644 --- a/Marlin/src/gcode/calibrate/M665.cpp +++ b/Marlin/src/gcode/calibrate/M665.cpp @@ -86,13 +86,13 @@ * * Parameters: * - * S[segments-per-second] - Segments-per-second + * S[segments] - Segments-per-second * * Without NO_WORKSPACE_OFFSETS: * - * P[theta-psi-offset] - Theta-Psi offset, added to the shoulder (A/X) angle - * T[theta-offset] - Theta offset, added to the elbow (B/Y) angle - * Z[z-offset] - Z offset, added to Z + * P[theta-psi-offset] - Theta-Psi offset, added to the shoulder (A/X) angle + * T[theta-offset] - Theta offset, added to the elbow (B/Y) angle + * Z[z-offset] - Z offset, added to Z * * A, P, and X are all aliases for the shoulder angle * B, T, and Y are all aliases for the elbow angle @@ -152,18 +152,35 @@ * * Parameters: * - * S[segments-per-second] - Segments-per-second + * S[segments] - Segments-per-second + * L[left] - Work area minimum X + * R[right] - Work area maximum X + * T[top] - Work area maximum Y + * B[bottom] - Work area minimum Y + * H[length] - Maximum belt length */ void GcodeSuite::M665() { - if (parser.seenval('S')) - segments_per_second = parser.value_float(); - else - M665_report(); + if (!parser.seen_any()) return M665_report(); + if (parser.seenval('S')) segments_per_second = parser.value_float(); + if (parser.seenval('L')) draw_area_min.x = parser.value_linear_units(); + if (parser.seenval('R')) draw_area_max.x = parser.value_linear_units(); + if (parser.seenval('T')) draw_area_max.y = parser.value_linear_units(); + if (parser.seenval('B')) draw_area_min.y = parser.value_linear_units(); + if (parser.seenval('H')) polargraph_max_belt_len = parser.value_linear_units(); + draw_area_size.x = draw_area_max.x - draw_area_min.x; + draw_area_size.y = draw_area_max.y - draw_area_min.y; } void GcodeSuite::M665_report(const bool forReplay/*=true*/) { - report_heading_etc(forReplay, F(STR_POLARGRAPH_SETTINGS " (" STR_S_SEG_PER_SEC ")")); - SERIAL_ECHOLNPGM(" M665 S", segments_per_second); + report_heading_etc(forReplay, F(STR_POLARGRAPH_SETTINGS)); + SERIAL_ECHOLNPGM_P( + PSTR(" M665 S"), LINEAR_UNIT(segments_per_second), + PSTR(" L"), LINEAR_UNIT(draw_area_min.x), + PSTR(" R"), LINEAR_UNIT(draw_area_max.x), + SP_T_STR, LINEAR_UNIT(draw_area_max.y), + SP_B_STR, LINEAR_UNIT(draw_area_min.y), + PSTR(" H"), LINEAR_UNIT(polargraph_max_belt_len) + ); } #endif diff --git a/Marlin/src/gcode/config/M540.cpp b/Marlin/src/gcode/config/M540.cpp index 54d52f3a31..e751248dd6 100644 --- a/Marlin/src/gcode/config/M540.cpp +++ b/Marlin/src/gcode/config/M540.cpp @@ -25,7 +25,7 @@ #if ENABLED(SD_ABORT_ON_ENDSTOP_HIT) #include "../gcode.h" -#include "../../module/stepper.h" +#include "../../module/planner.h" /** * M540: Set whether SD card print should abort on endstop hit (M540 S<0|1>) diff --git a/Marlin/src/gcode/control/M17_M18_M84.cpp b/Marlin/src/gcode/control/M17_M18_M84.cpp index c2c8a702a1..4ff48568fa 100644 --- a/Marlin/src/gcode/control/M17_M18_M84.cpp +++ b/Marlin/src/gcode/control/M17_M18_M84.cpp @@ -24,6 +24,7 @@ #include "../../MarlinCore.h" // for stepper_inactive_time, disable_e_steppers #include "../../lcd/marlinui.h" #include "../../module/motion.h" // for e_axis_mask +#include "../../module/planner.h" #include "../../module/stepper.h" #if ENABLED(AUTO_BED_LEVELING_UBL) diff --git a/Marlin/src/gcode/control/M226.cpp b/Marlin/src/gcode/control/M226.cpp index 63f022e82b..4eb3db4bc3 100644 --- a/Marlin/src/gcode/control/M226.cpp +++ b/Marlin/src/gcode/control/M226.cpp @@ -26,7 +26,7 @@ #include "../gcode.h" #include "../../MarlinCore.h" // for pin_is_protected and idle() -#include "../../module/stepper.h" +#include "../../module/planner.h" void protected_pin_err(); diff --git a/Marlin/src/gcode/control/M3-M5.cpp b/Marlin/src/gcode/control/M3-M5.cpp index 817ed4fcb4..5d5d44e8bf 100644 --- a/Marlin/src/gcode/control/M3-M5.cpp +++ b/Marlin/src/gcode/control/M3-M5.cpp @@ -26,22 +26,32 @@ #include "../gcode.h" #include "../../feature/spindle_laser.h" -#include "../../module/stepper.h" +#include "../../module/planner.h" /** * Laser: * M3 - Laser ON/Power (Ramped power) - * M4 - Laser ON/Power (Continuous power) + * M4 - Laser ON/Power (Ramped power) + * M5 - Set power output to 0 (leaving inline mode unchanged). + * + * M3I - Enable continuous inline power to be processed by the planner, with power + * calculated and set in the planner blocks, processed inline during stepping. + * Within inline mode M3 S-Values will set the power for the next moves e.g. G1 X10 Y10 powers on with the last S-Value. + * M3I must be set before using planner-synced M3 inline S-Values (LASER_POWER_SYNC). + * + * M4I - Set dynamic mode which calculates laser power OCR based on the current feedrate. + * + * M5I - Clear inline mode and set power to 0. * * Spindle: * M3 - Spindle ON (Clockwise) * M4 - Spindle ON (Counter-clockwise) + * M5 - Spindle OFF * * Parameters: - * S - Set power. S0 will turn the spindle/laser off, except in relative mode. - * O - Set power and OCR (oscillator count register) + * S - Set power. S0 will turn the spindle/laser off. * - * If no PWM pin is defined then M3/M4 just turns it on. + * If no PWM pin is defined then M3/M4 just turns it on or off. * * At least 12.8kHz (50Hz * 256) is needed for Spindle PWM. * Hardware PWM is required on AVR. ISRs are too slow. @@ -70,77 +80,77 @@ void GcodeSuite::M3_M4(const bool is_M4) { reset_stepper_timeout(); // Reset timeout to allow subsequent G-code to power the laser (imm.) #endif - #if EITHER(SPINDLE_LASER_USE_PWM, SPINDLE_SERVO) - auto get_s_power = [] { - if (parser.seenval('S')) { - const float spwr = parser.value_float(); - #if ENABLED(SPINDLE_SERVO) - cutter.unitPower = spwr; - #else - cutter.unitPower = TERN(SPINDLE_LASER_USE_PWM, - cutter.power_to_range(cutter_power_t(round(spwr))), - spwr > 0 ? 255 : 0); - #endif - } - else - cutter.unitPower = cutter.cpwr_to_upwr(SPEED_POWER_STARTUP); - return cutter.unitPower; - }; - #endif + if (cutter.cutter_mode == CUTTER_MODE_STANDARD) + planner.synchronize(); // Wait for previous movement commands (G0/G1/G2/G3) to complete before changing power - #if ENABLED(LASER_POWER_INLINE) - if (parser.seen('I') == DISABLED(LASER_POWER_INLINE_INVERT)) { - // Laser power in inline mode - cutter.inline_direction(is_M4); // Should always be unused - #if ENABLED(SPINDLE_LASER_USE_PWM) - if (parser.seenval('O')) { - cutter.unitPower = cutter.power_to_range(parser.value_byte(), 0); - cutter.inline_ocr_power(cutter.unitPower); // The OCR is a value from 0 to 255 (uint8_t) - } - else - cutter.inline_power(cutter.upower_to_ocr(get_s_power())); - #else - cutter.set_inline_enabled(true); - #endif - return; + #if ENABLED(LASER_FEATURE) + if (parser.seen_test('I')) { + cutter.cutter_mode = is_M4 ? CUTTER_MODE_DYNAMIC : CUTTER_MODE_CONTINUOUS; + cutter.inline_power(0); + cutter.set_enabled(true); } - // Non-inline, standard case - cutter.inline_disable(); // Prevent future blocks re-setting the power #endif - planner.synchronize(); // Wait for previous movement commands (G0/G0/G2/G3) to complete before changing power - cutter.set_reverse(is_M4); - - #if ENABLED(SPINDLE_LASER_USE_PWM) - if (parser.seenval('O')) { - cutter.unitPower = cutter.power_to_range(parser.value_byte(), 0); - cutter.ocr_set_power(cutter.unitPower); // The OCR is a value from 0 to 255 (uint8_t) + auto get_s_power = [] { + float u; + if (parser.seenval('S')) { + const float v = parser.value_float(); + u = TERN(LASER_POWER_TRAP, v, cutter.power_to_range(v)); } - else - cutter.set_power(cutter.upower_to_ocr(get_s_power())); - #elif ENABLED(SPINDLE_SERVO) - cutter.set_power(get_s_power()); - #else + else if (cutter.cutter_mode == CUTTER_MODE_STANDARD) + u = cutter.cpwr_to_upwr(SPEED_POWER_STARTUP); + + cutter.menuPower = cutter.unitPower = u; + + // PWM not implied, power converted to OCR from unit definition and on/off if not PWM. + cutter.power = TERN(SPINDLE_LASER_USE_PWM, cutter.upower_to_ocr(u), u > 0 ? 255 : 0); + return u; + }; + + if (cutter.cutter_mode == CUTTER_MODE_CONTINUOUS || cutter.cutter_mode == CUTTER_MODE_DYNAMIC) { // Laser power in inline mode + #if ENABLED(LASER_FEATURE) + planner.laser_inline.status.isPowered = true; // M3 or M4 is powered either way + get_s_power(); // Update cutter.power if seen + #if ENABLED(LASER_POWER_SYNC) + // With power sync we only set power so it does not effect queued inline power sets + planner.buffer_sync_block(BLOCK_BIT_LASER_PWR); // Send the flag, queueing inline power + #else + planner.synchronize(); + cutter.inline_power(cutter.power); + #endif + #endif + } + else { cutter.set_enabled(true); - #endif - cutter.menuPower = cutter.unitPower; + get_s_power(); + cutter.apply_power( + #if ENABLED(SPINDLE_SERVO) + cutter.unitPower + #elif ENABLED(SPINDLE_LASER_USE_PWM) + cutter.upower_to_ocr(cutter.unitPower) + #else + cutter.unitPower > 0 ? 255 : 0 + #endif + ); + TERN_(SPINDLE_CHANGE_DIR, cutter.set_reverse(is_M4)); + } } /** * M5 - Cutter OFF (when moves are complete) */ void GcodeSuite::M5() { - #if ENABLED(LASER_POWER_INLINE) - if (parser.seen('I') == DISABLED(LASER_POWER_INLINE_INVERT)) { - cutter.set_inline_enabled(false); // Laser power in inline mode - return; - } - // Non-inline, standard case - cutter.inline_disable(); // Prevent future blocks re-setting the power - #endif planner.synchronize(); - cutter.set_enabled(false); - cutter.menuPower = cutter.unitPower; + cutter.power = 0; + cutter.apply_power(0); // M5 just kills power, leaving inline mode unchanged + if (cutter.cutter_mode != CUTTER_MODE_STANDARD) { + if (parser.seen_test('I')) { + TERN_(LASER_FEATURE, cutter.inline_power(cutter.power)); + cutter.set_enabled(false); // Needs to happen while we are in inline mode to clear inline power. + cutter.cutter_mode = CUTTER_MODE_STANDARD; // Switch from inline to standard mode. + } + } + cutter.set_enabled(false); // Disable enable output setting } #endif // HAS_CUTTER diff --git a/Marlin/src/gcode/control/M400.cpp b/Marlin/src/gcode/control/M400.cpp index 9a5ad4e9df..6058fb894e 100644 --- a/Marlin/src/gcode/control/M400.cpp +++ b/Marlin/src/gcode/control/M400.cpp @@ -21,7 +21,7 @@ */ #include "../gcode.h" -#include "../../module/stepper.h" +#include "../../module/planner.h" /** * M400: Finish all moves diff --git a/Marlin/src/gcode/control/M605.cpp b/Marlin/src/gcode/control/M605.cpp index 06d92c8448..e3ca43e17f 100644 --- a/Marlin/src/gcode/control/M605.cpp +++ b/Marlin/src/gcode/control/M605.cpp @@ -28,7 +28,6 @@ #include "../gcode.h" #include "../../module/motion.h" -#include "../../module/stepper.h" #include "../../module/tool_change.h" #include "../../module/planner.h" diff --git a/Marlin/src/gcode/feature/L6470/M122.cpp b/Marlin/src/gcode/feature/L6470/M122.cpp deleted file mode 100644 index 4a5629b049..0000000000 --- a/Marlin/src/gcode/feature/L6470/M122.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * - * Based on Sprinter and grbl. - * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm - * - * This program 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. - * - * This program 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 this program. If not, see . - * - */ - -#include "../../../inc/MarlinConfig.h" - -#if HAS_L64XX - -#include "../../gcode.h" -#include "../../../libs/L64XX/L64XX_Marlin.h" -#include "../../../module/stepper/indirection.h" - -void echo_yes_no(const bool yes); - -inline void L6470_say_status(const L64XX_axis_t axis) { - if (L64xxManager.spi_abort) return; - const L64XX_Marlin::L64XX_shadow_t &sh = L64xxManager.shadow; - L64xxManager.get_status(axis); - L64xxManager.say_axis(axis); - #if ENABLED(L6470_CHITCHAT) - char temp_buf[20]; - sprintf_P(temp_buf, PSTR(" status: %4x "), sh.STATUS_AXIS_RAW); - SERIAL_ECHO(temp_buf); - print_bin(sh.STATUS_AXIS_RAW); - switch (sh.STATUS_AXIS_LAYOUT) { - case L6470_STATUS_LAYOUT: SERIAL_ECHOPGM(" L6470"); break; - case L6474_STATUS_LAYOUT: SERIAL_ECHOPGM(" L6474"); break; - case L6480_STATUS_LAYOUT: SERIAL_ECHOPGM(" L6480/powerSTEP01"); break; - } - #endif - SERIAL_ECHOPGM("\n...OUTPUT: "); - SERIAL_ECHOF(sh.STATUS_AXIS & STATUS_HIZ ? F("OFF") : F("ON ")); - SERIAL_ECHOPGM(" BUSY: "); echo_yes_no((sh.STATUS_AXIS & STATUS_BUSY) == 0); - SERIAL_ECHOPGM(" DIR: "); - SERIAL_ECHOF((((sh.STATUS_AXIS & STATUS_DIR) >> 4) ^ L64xxManager.index_to_dir[axis]) ? F("FORWARD") : F("REVERSE")); - if (sh.STATUS_AXIS_LAYOUT == L6480_STATUS_LAYOUT) { - SERIAL_ECHOPGM(" Last Command: "); - if (sh.STATUS_AXIS & sh.STATUS_AXIS_WRONG_CMD) SERIAL_ECHOPGM("VALID"); - else SERIAL_ECHOPGM("ERROR"); - SERIAL_ECHOPGM("\n...THERMAL: "); - switch ((sh.STATUS_AXIS & (sh.STATUS_AXIS_TH_SD | sh.STATUS_AXIS_TH_WRN)) >> 11) { - case 0: SERIAL_ECHOPGM("DEVICE SHUTDOWN"); break; - case 1: SERIAL_ECHOPGM("BRIDGE SHUTDOWN"); break; - case 2: SERIAL_ECHOPGM("WARNING "); break; - case 3: SERIAL_ECHOPGM("OK "); break; - } - } - else { - SERIAL_ECHOPGM(" Last Command: "); - if (!(sh.STATUS_AXIS & sh.STATUS_AXIS_WRONG_CMD)) SERIAL_ECHOPGM("IN"); - SERIAL_ECHOPGM("VALID "); - SERIAL_ECHOF(sh.STATUS_AXIS & sh.STATUS_AXIS_NOTPERF_CMD ? F("COMPLETED ") : F("Not PERFORMED")); - SERIAL_ECHOPGM("\n...THERMAL: ", !(sh.STATUS_AXIS & sh.STATUS_AXIS_TH_SD) ? "SHUTDOWN " : !(sh.STATUS_AXIS & sh.STATUS_AXIS_TH_WRN) ? "WARNING " : "OK "); - } - SERIAL_ECHOPGM(" OVERCURRENT:"); echo_yes_no((sh.STATUS_AXIS & sh.STATUS_AXIS_OCD) == 0); - if (sh.STATUS_AXIS_LAYOUT != L6474_STATUS_LAYOUT) { - SERIAL_ECHOPGM(" STALL:"); echo_yes_no((sh.STATUS_AXIS & sh.STATUS_AXIS_STEP_LOSS_A) == 0 || (sh.STATUS_AXIS & sh.STATUS_AXIS_STEP_LOSS_B) == 0); - SERIAL_ECHOPGM(" STEP-CLOCK MODE:"); echo_yes_no((sh.STATUS_AXIS & sh.STATUS_AXIS_SCK_MOD) != 0); - } - else { - SERIAL_ECHOPGM(" STALL: NA " - " STEP-CLOCK MODE: NA" - " UNDER VOLTAGE LOCKOUT: "); echo_yes_no((sh.STATUS_AXIS & sh.STATUS_AXIS_UVLO) == 0); - } - SERIAL_EOL(); -} - -/** - * M122: Debug L6470 drivers - */ -void GcodeSuite::M122() { - L64xxManager.pause_monitor(true); // Keep monitor_driver() from stealing status - L64xxManager.spi_active = true; // Tell set_directions() a series of SPI transfers is underway - - //if (parser.seen('S')) - // tmc_set_report_interval(parser.value_bool()); - //else - - #if AXIS_IS_L64XX(X) - L6470_say_status(X); - #endif - #if AXIS_IS_L64XX(X2) - L6470_say_status(X2); - #endif - #if AXIS_IS_L64XX(Y) - L6470_say_status(Y); - #endif - #if AXIS_IS_L64XX(Y2) - L6470_say_status(Y2); - #endif - #if AXIS_IS_L64XX(Z) - L6470_say_status(Z); - #endif - #if AXIS_IS_L64XX(Z2) - L6470_say_status(Z2); - #endif - #if AXIS_IS_L64XX(Z3) - L6470_say_status(Z3); - #endif - #if AXIS_IS_L64XX(Z4) - L6470_say_status(Z4); - #endif - #if AXIS_IS_L64XX(E0) - L6470_say_status(E0); - #endif - #if AXIS_IS_L64XX(E1) - L6470_say_status(E1); - #endif - #if AXIS_IS_L64XX(E2) - L6470_say_status(E2); - #endif - #if AXIS_IS_L64XX(E3) - L6470_say_status(E3); - #endif - #if AXIS_IS_L64XX(E4) - L6470_say_status(E4); - #endif - #if AXIS_IS_L64XX(E5) - L6470_say_status(E5); - #endif - #if AXIS_IS_L64XX(E6) - L6470_say_status(E6); - #endif - #if AXIS_IS_L64XX(E7) - L6470_say_status(E7); - #endif - - L64xxManager.spi_active = false; // done with all SPI transfers - clear handshake flags - L64xxManager.spi_abort = false; - L64xxManager.pause_monitor(false); -} - -#endif // HAS_L64XX diff --git a/Marlin/src/gcode/feature/L6470/M906.cpp b/Marlin/src/gcode/feature/L6470/M906.cpp deleted file mode 100644 index 26c637df27..0000000000 --- a/Marlin/src/gcode/feature/L6470/M906.cpp +++ /dev/null @@ -1,417 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * - * Based on Sprinter and grbl. - * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm - * - * This program 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. - * - * This program 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 this program. If not, see . - * - */ - -#include "../../../inc/MarlinConfig.h" - -#if HAS_L64XX - -#if AXIS_COLLISION('I') - #error "M906 parameter 'I' collision with axis name." -#endif - -#include "../../gcode.h" -#include "../../../libs/L64XX/L64XX_Marlin.h" -#include "../../../module/stepper/indirection.h" -#include "../../../module/planner.h" - -#define DEBUG_OUT ENABLED(L6470_CHITCHAT) -#include "../../../core/debug_out.h" - -/** - * MACRO to fetch information on the items associated with current limiting - * and maximum voltage output. - * - * L6470 can be setup to shutdown if either current threshold is exceeded. - * - * L6470 output current can not be set directly. It is set indirectly by - * setting the maximum effective output voltage. - * - * Effective output voltage is set by PWM duty cycle. - * - * Maximum effective output voltage is affected by MANY variables. The main ones are: - * KVAL_HOLD - * KVAL_RUN - * KVAL_ACC - * KVAL_DEC - * Vs compensation (if enabled) - */ -void L64XX_report_current(L64XX &motor, const L64XX_axis_t axis) { - - if (L64xxManager.spi_abort) return; // don't do anything if set_directions() has occurred - - const L64XX_Marlin::L64XX_shadow_t &sh = L64xxManager.shadow; - const uint16_t status = L64xxManager.get_status(axis); //also populates shadow structure - const uint8_t OverCurrent_Threshold = uint8_t(motor.GetParam(L6470_OCD_TH)); - - auto say_axis_status = [](const L64XX_axis_t axis, const uint16_t status) { - L64xxManager.say_axis(axis); - #if ENABLED(L6470_CHITCHAT) - char tmp[10]; - sprintf_P(tmp, PSTR("%4x "), status); - DEBUG_ECHOPGM(" status: ", tmp); - print_bin(status); - #else - UNUSED(status); - #endif - SERIAL_EOL(); - }; - - char temp_buf[10]; - - switch (sh.STATUS_AXIS_LAYOUT) { - case L6470_STATUS_LAYOUT: // L6470 - case L6480_STATUS_LAYOUT: { // L6480 & powerstep01 - const uint16_t Stall_Threshold = (uint8_t)motor.GetParam(L6470_STALL_TH), - motor_status = (status & (STATUS_MOT_STATUS)) >> 5, - L6470_ADC_out = motor.GetParam(L6470_ADC_OUT), - L6470_ADC_out_limited = constrain(L6470_ADC_out, 8, 24); - const float comp_coef = 1600.0f / L6470_ADC_out_limited; - const uint16_t MicroSteps = _BV(motor.GetParam(L6470_STEP_MODE) & 0x07); - - say_axis_status(axis, sh.STATUS_AXIS_RAW); - - SERIAL_ECHOPGM("...OverCurrent Threshold: "); - sprintf_P(temp_buf, PSTR("%2d ("), OverCurrent_Threshold); - SERIAL_ECHO(temp_buf); - SERIAL_ECHO((OverCurrent_Threshold + 1) * motor.OCD_CURRENT_CONSTANT_INV); - SERIAL_ECHOPGM(" mA)"); - SERIAL_ECHOPGM(" Stall Threshold: "); - sprintf_P(temp_buf, PSTR("%2d ("), Stall_Threshold); - SERIAL_ECHO(temp_buf); - SERIAL_ECHO((Stall_Threshold + 1) * motor.STALL_CURRENT_CONSTANT_INV); - SERIAL_ECHOPGM(" mA)"); - SERIAL_ECHOPGM(" Motor Status: "); - switch (motor_status) { - case 0: SERIAL_ECHOPGM("stopped"); break; - case 1: SERIAL_ECHOPGM("accelerating"); break; - case 2: SERIAL_ECHOPGM("decelerating"); break; - case 3: SERIAL_ECHOPGM("at constant speed"); break; - } - SERIAL_EOL(); - - SERIAL_ECHOPGM("...MicroSteps: ", MicroSteps, - " ADC_OUT: ", L6470_ADC_out); - SERIAL_ECHOPGM(" Vs_compensation: "); - SERIAL_ECHOF((motor.GetParam(sh.L6470_AXIS_CONFIG) & CONFIG_EN_VSCOMP) ? F("ENABLED ") : F("DISABLED")); - SERIAL_ECHOLNPGM(" Compensation coefficient: ~", comp_coef * 0.01f); - - SERIAL_ECHOPGM("...KVAL_HOLD: ", motor.GetParam(L6470_KVAL_HOLD), - " KVAL_RUN : ", motor.GetParam(L6470_KVAL_RUN), - " KVAL_ACC: ", motor.GetParam(L6470_KVAL_ACC), - " KVAL_DEC: ", motor.GetParam(L6470_KVAL_DEC), - " V motor max = "); - switch (motor_status) { - case 0: SERIAL_ECHO(motor.GetParam(L6470_KVAL_HOLD) * 100 / 256); SERIAL_ECHOPGM("% (KVAL_HOLD)"); break; - case 1: SERIAL_ECHO(motor.GetParam(L6470_KVAL_RUN) * 100 / 256); SERIAL_ECHOPGM("% (KVAL_RUN)"); break; - case 2: SERIAL_ECHO(motor.GetParam(L6470_KVAL_ACC) * 100 / 256); SERIAL_ECHOPGM("% (KVAL_ACC)"); break; - case 3: SERIAL_ECHO(motor.GetParam(L6470_KVAL_DEC) * 100 / 256); SERIAL_ECHOPGM("% (KVAL_HOLD)"); break; - } - SERIAL_EOL(); - - #if ENABLED(L6470_CHITCHAT) - DEBUG_ECHOPGM("...SLEW RATE: "); - switch (sh.STATUS_AXIS_LAYOUT) { - case L6470_STATUS_LAYOUT: { - switch ((motor.GetParam(sh.L6470_AXIS_CONFIG) & CONFIG_POW_SR) >> CONFIG_POW_SR_BIT) { - case 0: { DEBUG_ECHOLNPGM("320V/uS") ; break; } - case 1: { DEBUG_ECHOLNPGM("75V/uS") ; break; } - case 2: { DEBUG_ECHOLNPGM("110V/uS") ; break; } - case 3: { DEBUG_ECHOLNPGM("260V/uS") ; break; } - } - break; - } - case L6480_STATUS_LAYOUT: { - switch (motor.GetParam(L6470_GATECFG1) & CONFIG1_SR ) { - case CONFIG1_SR_220V_us: { DEBUG_ECHOLNPGM("220V/uS") ; break; } - case CONFIG1_SR_400V_us: { DEBUG_ECHOLNPGM("400V/uS") ; break; } - case CONFIG1_SR_520V_us: { DEBUG_ECHOLNPGM("520V/uS") ; break; } - case CONFIG1_SR_980V_us: { DEBUG_ECHOLNPGM("980V/uS") ; break; } - default: { DEBUG_ECHOLNPGM("unknown") ; break; } - } - } - } - #endif - SERIAL_EOL(); - break; - } - - case L6474_STATUS_LAYOUT: { // L6474 - const uint16_t L6470_ADC_out = motor.GetParam(L6470_ADC_OUT) & 0x1F, - L6474_TVAL_val = motor.GetParam(L6474_TVAL) & 0x7F; - - say_axis_status(axis, sh.STATUS_AXIS_RAW); - - SERIAL_ECHOPGM("...OverCurrent Threshold: "); - sprintf_P(temp_buf, PSTR("%2d ("), OverCurrent_Threshold); - SERIAL_ECHO(temp_buf); - SERIAL_ECHO((OverCurrent_Threshold + 1) * motor.OCD_CURRENT_CONSTANT_INV); - SERIAL_ECHOPGM(" mA)"); - SERIAL_ECHOPGM(" TVAL: "); - sprintf_P(temp_buf, PSTR("%2d ("), L6474_TVAL_val); - SERIAL_ECHO(temp_buf); - SERIAL_ECHO((L6474_TVAL_val + 1) * motor.STALL_CURRENT_CONSTANT_INV); - SERIAL_ECHOLNPGM(" mA) Motor Status: NA"); - - const uint16_t MicroSteps = _BV(motor.GetParam(L6470_STEP_MODE) & 0x07); //NOMORE(MicroSteps, 16); - SERIAL_ECHOPGM("...MicroSteps: ", MicroSteps, - " ADC_OUT: ", L6470_ADC_out); - - SERIAL_ECHOLNPGM(" Vs_compensation: NA\n"); - SERIAL_ECHOLNPGM("...KVAL_HOLD: NA" - " KVAL_RUN : NA" - " KVAL_ACC: NA" - " KVAL_DEC: NA" - " V motor max = NA"); - - #if ENABLED(L6470_CHITCHAT) - DEBUG_ECHOPGM("...SLEW RATE: "); - switch ((motor.GetParam(sh.L6470_AXIS_CONFIG) & CONFIG_POW_SR) >> CONFIG_POW_SR_BIT) { - case 0: DEBUG_ECHOLNPGM("320V/uS") ; break; - case 1: DEBUG_ECHOLNPGM("75V/uS") ; break; - case 2: DEBUG_ECHOLNPGM("110V/uS") ; break; - case 3: DEBUG_ECHOLNPGM("260V/uS") ; break; - default: DEBUG_ECHOLNPGM("slew rate: ", (motor.GetParam(sh.L6470_AXIS_CONFIG) & CONFIG_POW_SR) >> CONFIG_POW_SR_BIT); break; - } - #endif - SERIAL_EOL(); - SERIAL_EOL(); - break; - } - } -} - -/** - * M906: report or set KVAL_HOLD which sets the maximum effective voltage provided by the - * PWMs to the steppers - * - * On L6474 this sets the TVAL register (same address). - * - * I - select which driver(s) to change on multi-driver axis - * (default) all drivers on the axis - * 0 - monitor only the first XYZ... driver - * 1 - monitor only X2, Y2, Z2 - * 2 - monitor only Z3 - * 3 - monitor only Z4 - * Xxxx, Yxxx, Zxxx, Axxx, Bxxx, Cxxx, Uxxx, Vxxx, Wxxx, Exxx - axis to change (optional) - * L6474 - current in mA (4A max) - * All others - 0-255 - * - * Sets KVAL_HOLD which affects the current being driven through the stepper. - * - * L6470 is used in the STEP-CLOCK mode. KVAL_HOLD is the only KVAL_xxx - * that affects the effective voltage seen by the stepper. - */ -void GcodeSuite::M906() { - - L64xxManager.pause_monitor(true); // Keep monitor_driver() from stealing status - - #define L6470_SET_KVAL_HOLD(Q) (AXIS_IS_L64XX(Q) ? stepper##Q.setTVALCurrent(value) : stepper##Q.SetParam(L6470_KVAL_HOLD, uint8_t(value))) - - DEBUG_ECHOLNPGM("M906"); - - uint8_t report_current = true; - - #if AXIS_IS_L64XX(X2) || AXIS_IS_L64XX(Y2) || AXIS_IS_L64XX(Z2) || AXIS_IS_L64XX(Z3) || AXIS_IS_L64XX(Z4) - const int8_t index = parser.byteval('I', -1); - #else - constexpr int8_t index = -1; - #endif - - LOOP_LOGICAL_AXES(i) if (uint16_t value = parser.intval(AXIS_CHAR(i))) { - - report_current = false; - - if (planner.has_blocks_queued() || planner.cleaning_buffer_counter) { - SERIAL_ECHOLNPGM("Test aborted. Can't set KVAL_HOLD while steppers are moving."); - return; - } - - switch (i) { - #if AXIS_IS_L64XX(X) || AXIS_IS_L64XX(X2) - case X_AXIS: - #if AXIS_IS_L64XX(X) - if (index < 0 || index == 0) L6470_SET_KVAL_HOLD(X); - #endif - #if AXIS_IS_L64XX(X2) - if (index < 0 || index == 1) L6470_SET_KVAL_HOLD(X2); - #endif - break; - #endif - - #if AXIS_IS_L64XX(Y) || AXIS_IS_L64XX(Y2) - case Y_AXIS: - #if AXIS_IS_L64XX(Y) - if (index < 0 || index == 0) L6470_SET_KVAL_HOLD(Y); - #endif - #if AXIS_IS_L64XX(Y2) - if (index < 0 || index == 1) L6470_SET_KVAL_HOLD(Y2); - #endif - break; - #endif - - #if AXIS_IS_L64XX(Z) || AXIS_IS_L64XX(Z2) || AXIS_IS_L64XX(Z3) || AXIS_IS_L64XX(Z4) - case Z_AXIS: - #if AXIS_IS_L64XX(Z) - if (index < 0 || index == 0) L6470_SET_KVAL_HOLD(Z); - #endif - #if AXIS_IS_L64XX(Z2) - if (index < 0 || index == 1) L6470_SET_KVAL_HOLD(Z2); - #endif - #if AXIS_IS_L64XX(Z3) - if (index < 0 || index == 2) L6470_SET_KVAL_HOLD(Z3); - #endif - #if AXIS_IS_L64XX(Z4) - if (index < 0 || index == 3) L6470_SET_KVAL_HOLD(Z4); - #endif - break; - #endif - - #if AXIS_IS_L64XX(I) - case I_AXIS: L6470_SET_KVAL_HOLD(I); break; - #endif - #if AXIS_IS_L64XX(J) - case J_AXIS: L6470_SET_KVAL_HOLD(J); break; - #endif - #if AXIS_IS_L64XX(K) - case K_AXIS: L6470_SET_KVAL_HOLD(K); break; - #endif - #if AXIS_IS_L64XX(U) - case U_AXIS: L6470_SET_KVAL_HOLD(U); break; - #endif - #if AXIS_IS_L64XX(V) - case V_AXIS: L6470_SET_KVAL_HOLD(V); break; - #endif - #if AXIS_IS_L64XX(W) - case W_AXIS: L6470_SET_KVAL_HOLD(W); break; - #endif - - #if AXIS_IS_L64XX(E0) || AXIS_IS_L64XX(E1) || AXIS_IS_L64XX(E2) || AXIS_IS_L64XX(E3) || AXIS_IS_L64XX(E4) || AXIS_IS_L64XX(E5) || AXIS_IS_L64XX(E6) || AXIS_IS_L64XX(E7) - case E_AXIS: { - const int8_t eindex = get_target_e_stepper_from_command(-2); - #if AXIS_IS_L64XX(E0) - if (eindex < 0 || eindex == 0) L6470_SET_KVAL_HOLD(E0); - #endif - #if AXIS_IS_L64XX(E1) - if (eindex < 0 || eindex == 1) L6470_SET_KVAL_HOLD(E1); - #endif - #if AXIS_IS_L64XX(E2) - if (eindex < 0 || eindex == 2) L6470_SET_KVAL_HOLD(E2); - #endif - #if AXIS_IS_L64XX(E3) - if (eindex < 0 || eindex == 3) L6470_SET_KVAL_HOLD(E3); - #endif - #if AXIS_IS_L64XX(E4) - if (eindex < 0 || eindex == 4) L6470_SET_KVAL_HOLD(E4); - #endif - #if AXIS_IS_L64XX(E5) - if (eindex < 0 || eindex == 5) L6470_SET_KVAL_HOLD(E5); - #endif - #if AXIS_IS_L64XX(E6) - if (eindex < 0 || eindex == 6) L6470_SET_KVAL_HOLD(E6); - #endif - #if AXIS_IS_L64XX(E7) - if (eindex < 0 || eindex == 7) L6470_SET_KVAL_HOLD(E7); - #endif - } break; - #endif - } - } - - if (report_current) { - #define L64XX_REPORT_CURRENT(Q) L64XX_report_current(stepper##Q, Q) - - L64xxManager.spi_active = true; // Tell set_directions() a series of SPI transfers is underway - - #if AXIS_IS_L64XX(X) - L64XX_REPORT_CURRENT(X); - #endif - #if AXIS_IS_L64XX(X2) - L64XX_REPORT_CURRENT(X2); - #endif - #if AXIS_IS_L64XX(Y) - L64XX_REPORT_CURRENT(Y); - #endif - #if AXIS_IS_L64XX(Y2) - L64XX_REPORT_CURRENT(Y2); - #endif - #if AXIS_IS_L64XX(Z) - L64XX_REPORT_CURRENT(Z); - #endif - #if AXIS_IS_L64XX(Z2) - L64XX_REPORT_CURRENT(Z2); - #endif - #if AXIS_IS_L64XX(Z3) - L64XX_REPORT_CURRENT(Z3); - #endif - #if AXIS_IS_L64XX(Z4) - L64XX_REPORT_CURRENT(Z4); - #endif - #if AXIS_IS_L64XX(I) - L64XX_REPORT_CURRENT(I); - #endif - #if AXIS_IS_L64XX(J) - L64XX_REPORT_CURRENT(J); - #endif - #if AXIS_IS_L64XX(K) - L64XX_REPORT_CURRENT(K); - #endif - #if AXIS_IS_L64XX(U) - L64XX_REPORT_CURRENT(U); - #endif - #if AXIS_IS_L64XX(V) - L64XX_REPORT_CURRENT(V); - #endif - #if AXIS_IS_L64XX(W) - L64XX_REPORT_CURRENT(W); - #endif - #if AXIS_IS_L64XX(E0) - L64XX_REPORT_CURRENT(E0); - #endif - #if AXIS_IS_L64XX(E1) - L64XX_REPORT_CURRENT(E1); - #endif - #if AXIS_IS_L64XX(E2) - L64XX_REPORT_CURRENT(E2); - #endif - #if AXIS_IS_L64XX(E3) - L64XX_REPORT_CURRENT(E3); - #endif - #if AXIS_IS_L64XX(E4) - L64XX_REPORT_CURRENT(E4); - #endif - #if AXIS_IS_L64XX(E5) - L64XX_REPORT_CURRENT(E5); - #endif - #if AXIS_IS_L64XX(E6) - L64XX_REPORT_CURRENT(E6); - #endif - #if AXIS_IS_L64XX(E7) - L64XX_REPORT_CURRENT(E7); - #endif - - L64xxManager.spi_active = false; // done with all SPI transfers - clear handshake flags - L64xxManager.spi_abort = false; - L64xxManager.pause_monitor(false); - } -} - -#endif // HAS_L64XX diff --git a/Marlin/src/gcode/feature/L6470/M916-M918.cpp b/Marlin/src/gcode/feature/L6470/M916-M918.cpp deleted file mode 100644 index 9e1f1b98da..0000000000 --- a/Marlin/src/gcode/feature/L6470/M916-M918.cpp +++ /dev/null @@ -1,650 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * - * Based on Sprinter and grbl. - * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm - * - * This program 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. - * - * This program 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 this program. If not, see . - * - */ - -// -// NOTE: All tests assume each axis uses matching driver chips. -// - -#include "../../../inc/MarlinConfig.h" - -#if HAS_L64XX - -#include "../../gcode.h" -#include "../../../module/stepper/indirection.h" -#include "../../../module/planner.h" -#include "../../../libs/L64XX/L64XX_Marlin.h" - -#define DEBUG_OUT ENABLED(L6470_CHITCHAT) -#include "../../../core/debug_out.h" - -/** - * M916: increase KVAL_HOLD until get thermal warning - * NOTE - on L6474 it is TVAL that is used - * - * J - select which driver(s) to monitor on multi-driver axis - * 0 - (default) monitor all drivers on the axis or E0 - * 1 - monitor only X, Y, Z, E1 - * 2 - monitor only X2, Y2, Z2, E2 - * 3 - monitor only Z3, E3 - * 4 - monitor only Z4, E4 - * - * Xxxx, Yxxx, Zxxx, Exxx - axis to be monitored with displacement - * xxx (1-255) is distance moved on either side of current position - * - * F - feedrate - * optional - will use default max feedrate from configuration.h if not specified - * - * T - current (mA) setting for TVAL (0 - 4A in 31.25mA increments, rounds down) - L6474 only - * optional - will report current value from driver if not specified - * - * K - value for KVAL_HOLD (0 - 255) (ignored for L6474) - * optional - will report current value from driver if not specified - * - * D - time (in seconds) to run each setting of KVAL_HOLD/TVAL - * optional - defaults to zero (runs each setting once) - */ - -/** - * This routine is also useful for determining the approximate KVAL_HOLD - * where the stepper stops losing steps. The sound will get noticeably quieter - * as it stops losing steps. - */ - -void GcodeSuite::M916() { - - DEBUG_ECHOLNPGM("M916"); - - L64xxManager.pause_monitor(true); // Keep monitor_driver() from stealing status - - // Variables used by L64xxManager.get_user_input function - some may not be used - char axis_mon[3][3] = { {" "}, {" "}, {" "} }; // list of Axes to be monitored - L64XX_axis_t axis_index[3]; - uint16_t axis_status[3]; - uint8_t driver_count = 1; - float position_max; - float position_min; - float final_feedrate; - uint8_t kval_hold; - uint8_t OCD_TH_val = 0; - uint8_t STALL_TH_val = 0; - uint16_t over_current_threshold; - constexpr uint8_t over_current_flag = false; // M916 doesn't play with the overcurrent thresholds - - #define DRIVER_TYPE_L6474(Q) AXIS_DRIVER_TYPE_##Q(L6474) - - uint8_t j; // general purpose counter - - if (L64xxManager.get_user_input(driver_count, axis_index, axis_mon, position_max, position_min, final_feedrate, kval_hold, over_current_flag, OCD_TH_val, STALL_TH_val, over_current_threshold)) - return; // quit if invalid user input - - DEBUG_ECHOLNPGM("feedrate = ", final_feedrate); - - planner.synchronize(); // wait for all current movement commands to complete - - const L64XX_Marlin::L64XX_shadow_t &sh = L64xxManager.shadow; - for (j = 0; j < driver_count; j++) - L64xxManager.get_status(axis_index[j]); // clear out any pre-existing error flags - - char temp_axis_string[] = " "; - temp_axis_string[0] = axis_mon[0][0]; // need to have a string for use within sprintf format section - char gcode_string[80]; - uint16_t status_composite = 0; - - uint16_t M91x_counter = kval_hold; - uint16_t M91x_counter_max; - if (sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT) { - M91x_counter_max = 128; // TVAL is 7 bits - LIMIT(M91x_counter, 0U, 127U); - } - else - M91x_counter_max = 256; // KVAL_HOLD is 8 bits - - uint8_t M91x_delay_s = parser.byteval('D'); // get delay in seconds - millis_t M91x_delay_ms = SEC_TO_MS(M91x_delay_s * 60); - millis_t M91x_delay_end; - - DEBUG_ECHOLNPGM(".\n."); - - do { - - if (sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT) - DEBUG_ECHOLNPGM("TVAL current (mA) = ", (M91x_counter + 1) * sh.AXIS_STALL_CURRENT_CONSTANT_INV); // report TVAL current for this run - else - DEBUG_ECHOLNPGM("kval_hold = ", M91x_counter); // report KVAL_HOLD for this run - - for (j = 0; j < driver_count; j++) - L64xxManager.set_param(axis_index[j], L6470_KVAL_HOLD, M91x_counter); //set KVAL_HOLD or TVAL (same register address) - - M91x_delay_end = millis() + M91x_delay_ms; - do { - // turn the motor(s) both directions - sprintf_P(gcode_string, PSTR("G0 %s%03d F%03d"), temp_axis_string, uint16_t(position_min), uint16_t(final_feedrate)); - process_subcommands_now(gcode_string); - - sprintf_P(gcode_string, PSTR("G0 %s%03d F%03d"), temp_axis_string, uint16_t(position_max), uint16_t(final_feedrate)); - process_subcommands_now(gcode_string); - - // get the status after the motors have stopped - planner.synchronize(); - - status_composite = 0; // clear out the old bits - - for (j = 0; j < driver_count; j++) { - axis_status[j] = (~L64xxManager.get_status(axis_index[j])) & sh.L6470_ERROR_MASK; // bits of interest are all active low - status_composite |= axis_status[j] ; - } - - if (status_composite) break; - } while (millis() < M91x_delay_end); - - if (status_composite) break; - - M91x_counter++; - - } while (!(status_composite & (sh.STATUS_AXIS_TH_WRN | sh.STATUS_AXIS_TH_SD)) && (M91x_counter < M91x_counter_max)); - - DEBUG_ECHOLNPGM("."); - - #if ENABLED(L6470_CHITCHAT) - if (status_composite) { - L64xxManager.error_status_decode(status_composite, axis_index[0], - sh.STATUS_AXIS_TH_SD, sh.STATUS_AXIS_TH_WRN, - sh.STATUS_AXIS_STEP_LOSS_A, sh.STATUS_AXIS_STEP_LOSS_B, - sh.STATUS_AXIS_OCD, sh.STATUS_AXIS_LAYOUT); - DEBUG_ECHOLNPGM("."); - } - #endif - - if ((status_composite & (sh.STATUS_AXIS_TH_WRN | sh.STATUS_AXIS_TH_SD))) - DEBUG_ECHOLNPGM(".\n.\nTest completed normally - Thermal warning/shutdown has occurred"); - else if (status_composite) - DEBUG_ECHOLNPGM(".\n.\nTest completed abnormally - non-thermal error has occurred"); - else - DEBUG_ECHOLNPGM(".\n.\nTest completed normally - Unable to get to thermal warning/shutdown"); - - L64xxManager.pause_monitor(false); -} - -/** - * M917: Find minimum current thresholds - * - * Decrease OCD current until overcurrent error - * Increase OCD until overcurrent error goes away - * Decrease stall threshold until stall (not done on L6474) - * Increase stall until stall error goes away (not done on L6474) - * - * J - select which driver(s) to monitor on multi-driver axis - * 0 - (default) monitor all drivers on the axis or E0 - * 1 - monitor only X, Y, Z, E1 - * 2 - monitor only X2, Y2, Z2, E2 - * Xxxx, Yxxx, Zxxx, Exxx - axis to be monitored with displacement - * xxx (1-255) is distance moved on either side of current position - * - * F - feedrate - * optional - will use default max feedrate from Configuration.h if not specified - * - * I - starting over-current threshold - * optional - will report current value from driver if not specified - * if there are multiple drivers on the axis then all will be set the same - * - * T - current (mA) setting for TVAL (0 - 4A in 31.25mA increments, rounds down) - L6474 only - * optional - will report current value from driver if not specified - * - * K - value for KVAL_HOLD (0 - 255) (ignored for L6474) - * optional - will report current value from driver if not specified - */ -void GcodeSuite::M917() { - - DEBUG_ECHOLNPGM("M917"); - - L64xxManager.pause_monitor(true); // Keep monitor_driver() from stealing status - - char axis_mon[3][3] = { {" "}, {" "}, {" "} }; // list of Axes to be monitored - L64XX_axis_t axis_index[3]; - uint16_t axis_status[3]; - uint8_t driver_count = 1; - float position_max; - float position_min; - float final_feedrate; - uint8_t kval_hold; - uint8_t OCD_TH_val = 0; - uint8_t STALL_TH_val = 0; - uint16_t over_current_threshold; - constexpr uint8_t over_current_flag = true; - - uint8_t j; // general purpose counter - - if (L64xxManager.get_user_input(driver_count, axis_index, axis_mon, position_max, position_min, final_feedrate, kval_hold, over_current_flag, OCD_TH_val, STALL_TH_val, over_current_threshold)) - return; // quit if invalid user input - - DEBUG_ECHOLNPGM("feedrate = ", final_feedrate); - - planner.synchronize(); // wait for all current movement commands to complete - - const L64XX_Marlin::L64XX_shadow_t &sh = L64xxManager.shadow; - for (j = 0; j < driver_count; j++) - L64xxManager.get_status(axis_index[j]); // clear error flags - char temp_axis_string[] = " "; - temp_axis_string[0] = axis_mon[0][0]; // need a sprintf format string - char gcode_string[80]; - uint16_t status_composite = 0; - uint8_t test_phase = 0; // 0 - decreasing OCD - exit when OCD warning occurs (ignore STALL) - // 1 - increasing OCD - exit when OCD warning stops (ignore STALL) - // 2 - OCD finalized - decreasing STALL - exit when STALL warning happens - // 3 - OCD finalized - increasing STALL - exit when STALL warning stop - // 4 - all testing completed - DEBUG_ECHOPGM(".\n.\n.\nover_current threshold : ", (OCD_TH_val + 1) * 375); // first status display - DEBUG_ECHOPGM(" (OCD_TH: : ", OCD_TH_val); - if (sh.STATUS_AXIS_LAYOUT != L6474_STATUS_LAYOUT) { - DEBUG_ECHOPGM(") Stall threshold: ", (STALL_TH_val + 1) * 31.25); - DEBUG_ECHOPGM(" (STALL_TH: ", STALL_TH_val); - } - DEBUG_ECHOLNPGM(")"); - - do { - - if (sh.STATUS_AXIS_LAYOUT != L6474_STATUS_LAYOUT) DEBUG_ECHOPGM("STALL threshold : ", (STALL_TH_val + 1) * 31.25); - DEBUG_ECHOLNPGM(" OCD threshold : ", (OCD_TH_val + 1) * 375); - - sprintf_P(gcode_string, PSTR("G0 %s%03d F%03d"), temp_axis_string, uint16_t(position_min), uint16_t(final_feedrate)); - process_subcommands_now(gcode_string); - - sprintf_P(gcode_string, PSTR("G0 %s%03d F%03d"), temp_axis_string, uint16_t(position_max), uint16_t(final_feedrate)); - process_subcommands_now(gcode_string); - - planner.synchronize(); - - status_composite = 0; // clear out the old bits - - for (j = 0; j < driver_count; j++) { - axis_status[j] = (~L64xxManager.get_status(axis_index[j])) & sh.L6470_ERROR_MASK; // bits of interest are all active low - status_composite |= axis_status[j]; - } - - if (status_composite && (status_composite & sh.STATUS_AXIS_UVLO)) { - DEBUG_ECHOLNPGM("Test aborted (Undervoltage lockout active)"); - #if ENABLED(L6470_CHITCHAT) - for (j = 0; j < driver_count; j++) { - if (j) DEBUG_ECHOPGM("..."); - L64xxManager.error_status_decode(axis_status[j], axis_index[j], - sh.STATUS_AXIS_TH_SD, sh.STATUS_AXIS_TH_WRN, - sh.STATUS_AXIS_STEP_LOSS_A, sh.STATUS_AXIS_STEP_LOSS_B, - sh.STATUS_AXIS_OCD, sh.STATUS_AXIS_LAYOUT); - } - #endif - return; - } - - if (status_composite & (sh.STATUS_AXIS_TH_WRN | sh.STATUS_AXIS_TH_SD)) { - DEBUG_ECHOLNPGM("thermal problem - waiting for chip(s) to cool down "); - uint16_t status_composite_temp = 0; - uint8_t k = 0; - do { - k++; - if (!(k % 4)) { - kval_hold *= 0.95; - DEBUG_EOL(); - DEBUG_ECHOLNPGM("Lowering KVAL_HOLD by about 5% to ", kval_hold); - for (j = 0; j < driver_count; j++) - L64xxManager.set_param(axis_index[j], L6470_KVAL_HOLD, kval_hold); - } - DEBUG_ECHOLNPGM("."); - reset_stepper_timeout(); // keep steppers powered - safe_delay(5000); - status_composite_temp = 0; - for (j = 0; j < driver_count; j++) { - axis_status[j] = (~L64xxManager.get_status(axis_index[j])) & sh.L6470_ERROR_MASK; // bits of interest are all active low - status_composite_temp |= axis_status[j]; - } - } - while (status_composite_temp & (sh.STATUS_AXIS_TH_WRN | sh.STATUS_AXIS_TH_SD)); - DEBUG_EOL(); - } - if (status_composite & (sh.STATUS_AXIS_STEP_LOSS_A | sh.STATUS_AXIS_STEP_LOSS_B | sh.STATUS_AXIS_OCD)) { - switch (test_phase) { - - case 0: { - if (status_composite & sh.STATUS_AXIS_OCD) { - // phase 0 with OCD warning - time to go to next phase - if (OCD_TH_val >= sh.AXIS_OCD_TH_MAX) { - OCD_TH_val = sh.AXIS_OCD_TH_MAX; // limit to max - test_phase = 2; // at highest value so skip phase 1 - //DEBUG_ECHOLNPGM("LOGIC E0A OCD at highest - skip to 2"); - DEBUG_ECHOLNPGM("OCD at highest - OCD finalized"); - } - else { - OCD_TH_val++; // normal exit to next phase - test_phase = 1; // setup for first pass of phase 1 - //DEBUG_ECHOLNPGM("LOGIC E0B - inc OCD & go to 1"); - DEBUG_ECHOLNPGM("inc OCD"); - } - } - else { // phase 0 without OCD warning - keep on decrementing if can - if (OCD_TH_val) { - OCD_TH_val--; // try lower value - //DEBUG_ECHOLNPGM("LOGIC E0C - dec OCD"); - DEBUG_ECHOLNPGM("dec OCD"); - } - else { - test_phase = 2; // at lowest value without warning so skip phase 1 - //DEBUG_ECHOLNPGM("LOGIC E0D - OCD at latest - go to 2"); - DEBUG_ECHOLNPGM("OCD finalized"); - } - } - } break; - - case 1: { - if (status_composite & sh.STATUS_AXIS_OCD) { - // phase 1 with OCD warning - increment if can - if (OCD_TH_val >= sh.AXIS_OCD_TH_MAX) { - OCD_TH_val = sh.AXIS_OCD_TH_MAX; // limit to max - test_phase = 2; // at highest value so go to next phase - //DEBUG_ECHOLNPGM("LOGIC E1A - OCD at max - go to 2"); - DEBUG_ECHOLNPGM("OCD finalized"); - } - else { - OCD_TH_val++; // try a higher value - //DEBUG_ECHOLNPGM("LOGIC E1B - inc OCD"); - DEBUG_ECHOLNPGM("inc OCD"); - } - } - else { // phase 1 without OCD warning - normal exit to phase 2 - test_phase = 2; - //DEBUG_ECHOLNPGM("LOGIC E1C - no OCD warning - go to 1"); - DEBUG_ECHOLNPGM("OCD finalized"); - } - } break; - - case 2: { - if (sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT) { // skip all STALL_TH steps if L6474 - test_phase = 4; - break; - } - if (status_composite & (sh.STATUS_AXIS_STEP_LOSS_A | sh.STATUS_AXIS_STEP_LOSS_B)) { - // phase 2 with stall warning - time to go to next phase - if (STALL_TH_val >= 127) { - STALL_TH_val = 127; // limit to max - //DEBUG_ECHOLNPGM("LOGIC E2A - STALL warning, STALL at max, quit"); - DEBUG_ECHOLNPGM("finished - STALL at maximum value but still have stall warning"); - test_phase = 4; - } - else { - test_phase = 3; // normal exit to next phase (found failing value of STALL) - STALL_TH_val++; // setup for first pass of phase 3 - //DEBUG_ECHOLNPGM("LOGIC E2B - INC - STALL warning, inc Stall, go to 3"); - DEBUG_ECHOLNPGM("inc Stall"); - } - } - else { // phase 2 without stall warning - decrement if can - if (STALL_TH_val) { - STALL_TH_val--; // try a lower value - //DEBUG_ECHOLNPGM("LOGIC E2C - no STALL, dec STALL"); - DEBUG_ECHOLNPGM("dec STALL"); - } - else { - DEBUG_ECHOLNPGM("finished - STALL at lowest value but still do NOT have stall warning"); - test_phase = 4; - //DEBUG_ECHOLNPGM("LOGIC E2D - no STALL, at lowest so quit"); - } - } - } break; - - case 3: { - if (sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT) { // skip all STALL_TH steps if L6474 - test_phase = 4; - break; - } - if (status_composite & (sh.STATUS_AXIS_STEP_LOSS_A | sh.STATUS_AXIS_STEP_LOSS_B)) { - // phase 3 with stall warning - increment if can - if (STALL_TH_val >= 127) { - STALL_TH_val = 127; // limit to max - DEBUG_ECHOLNPGM("finished - STALL at maximum value but still have stall warning"); - test_phase = 4; - //DEBUG_ECHOLNPGM("LOGIC E3A - STALL, at max so quit"); - } - else { - STALL_TH_val++; // still looking for passing value - //DEBUG_ECHOLNPGM("LOGIC E3B - STALL, inc stall"); - DEBUG_ECHOLNPGM("inc stall"); - } - } - else { //phase 3 without stall warning but have OCD warning - DEBUG_ECHOLNPGM("Hardware problem - OCD warning without STALL warning"); - test_phase = 4; - //DEBUG_ECHOLNPGM("LOGIC E3C - not STALLED, hardware problem (quit)"); - } - } break; - - } - - } - else { - switch (test_phase) { - case 0: { // phase 0 without OCD warning - keep on decrementing if can - if (OCD_TH_val) { - OCD_TH_val--; // try lower value - //DEBUG_ECHOLNPGM("LOGIC N0A - DEC OCD"); - DEBUG_ECHOLNPGM("DEC OCD"); - } - else { - test_phase = 2; // at lowest value without warning so skip phase 1 - //DEBUG_ECHOLNPGM("LOGIC N0B - OCD at lowest (go to phase 2)"); - DEBUG_ECHOLNPGM("OCD finalized"); - } - } break; - - case 1: //DEBUG_ECHOLNPGM("LOGIC N1 (go directly to 2)"); // phase 1 without OCD warning - drop directly to phase 2 - DEBUG_ECHOLNPGM("OCD finalized"); - - case 2: { // phase 2 without stall warning - keep on decrementing if can - if (sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT) { // skip all STALL_TH steps if L6474 - test_phase = 4; - break; - } - if (STALL_TH_val) { - STALL_TH_val--; // try a lower value (stay in phase 2) - //DEBUG_ECHOLNPGM("LOGIC N2B - dec STALL"); - DEBUG_ECHOLNPGM("dec STALL"); - } - else { - DEBUG_ECHOLNPGM("finished - STALL at lowest value but still no stall warning"); - test_phase = 4; - //DEBUG_ECHOLNPGM("LOGIC N2C - STALL at lowest (quit)"); - } - } break; - - case 3: { - if (sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT) { // skip all STALL_TH steps if L6474 - test_phase = 4; - break; - } - test_phase = 4; - //DEBUG_ECHOLNPGM("LOGIC N3 - finished!"); - DEBUG_ECHOLNPGM("finished!"); - } break; // phase 3 without any warnings - desired exit - } // - } // end of status checks - - if (test_phase != 4) { - for (j = 0; j < driver_count; j++) { // update threshold(s) - L64xxManager.set_param(axis_index[j], L6470_OCD_TH, OCD_TH_val); - if (sh.STATUS_AXIS_LAYOUT != L6474_STATUS_LAYOUT) L64xxManager.set_param(axis_index[j], L6470_STALL_TH, STALL_TH_val); - if (L64xxManager.get_param(axis_index[j], L6470_OCD_TH) != OCD_TH_val) DEBUG_ECHOLNPGM("OCD mismatch"); - if ((L64xxManager.get_param(axis_index[j], L6470_STALL_TH) != STALL_TH_val) && (sh.STATUS_AXIS_LAYOUT != L6474_STATUS_LAYOUT)) DEBUG_ECHOLNPGM("STALL mismatch"); - } - } - - } while (test_phase != 4); - - DEBUG_ECHOLNPGM("."); - if (status_composite) { - #if ENABLED(L6470_CHITCHAT) - for (j = 0; j < driver_count; j++) { - if (j) DEBUG_ECHOPGM("..."); - L64xxManager.error_status_decode(axis_status[j], axis_index[j], - sh.STATUS_AXIS_TH_SD, sh.STATUS_AXIS_TH_WRN, - sh.STATUS_AXIS_STEP_LOSS_A, sh.STATUS_AXIS_STEP_LOSS_B, - sh.STATUS_AXIS_OCD, sh.STATUS_AXIS_LAYOUT); - } - DEBUG_ECHOLNPGM("."); - #endif - DEBUG_ECHOLNPGM("Completed with errors"); - } - else - DEBUG_ECHOLNPGM("Completed with no errors"); - DEBUG_ECHOLNPGM("."); - - L64xxManager.pause_monitor(false); -} - -/** - * M918: increase speed until error or max feedrate achieved (as shown in configuration.h)) - * - * J - select which driver(s) to monitor on multi-driver axis - * 0 - (default) monitor all drivers on the axis or E0 - * 1 - monitor only X, Y, Z, E1 - * 2 - monitor only X2, Y2, Z2, E2 - * Xxxx, Yxxx, Zxxx, Exxx - axis to be monitored with displacement - * xxx (1-255) is distance moved on either side of current position - * - * I - over current threshold - * optional - will report current value from driver if not specified - * - * T - current (mA) setting for TVAL (0 - 4A in 31.25mA increments, rounds down) - L6474 only - * optional - will report current value from driver if not specified - * - * K - value for KVAL_HOLD (0 - 255) (ignored for L6474) - * optional - will report current value from driver if not specified - * - * M - value for microsteps (1 - 128) (optional) - * optional - will report current value from driver if not specified - */ -void GcodeSuite::M918() { - - DEBUG_ECHOLNPGM("M918"); - - L64xxManager.pause_monitor(true); // Keep monitor_driver() from stealing status - - char axis_mon[3][3] = { {" "}, {" "}, {" "} }; // list of Axes to be monitored - L64XX_axis_t axis_index[3]; - uint16_t axis_status[3]; - uint8_t driver_count = 1; - float position_max, position_min; - float final_feedrate; - uint8_t kval_hold; - uint8_t OCD_TH_val = 0; - uint8_t STALL_TH_val = 0; - uint16_t over_current_threshold; - constexpr uint8_t over_current_flag = true; - - const L64XX_Marlin::L64XX_shadow_t &sh = L64xxManager.shadow; - - uint8_t j; // general purpose counter - - if (L64xxManager.get_user_input(driver_count, axis_index, axis_mon, position_max, position_min, final_feedrate, kval_hold, over_current_flag, OCD_TH_val, STALL_TH_val, over_current_threshold)) - return; // quit if invalid user input - - L64xxManager.get_status(axis_index[0]); // populate shadow array - - uint8_t m_steps = parser.byteval('M'); - - if (m_steps != 0) { - LIMIT(m_steps, 1, sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT ? 16 : 128); // L6474 - - uint8_t stepVal; - for (stepVal = 0; stepVal < 8; stepVal++) { // convert to L64xx register value - if (m_steps == 1) break; - m_steps >>= 1; - } - - if (sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT) - stepVal |= 0x98; // NO SYNC - else - stepVal |= (!SYNC_EN) | SYNC_SEL_1 | stepVal; - - for (j = 0; j < driver_count; j++) { - L64xxManager.set_param(axis_index[j], dSPIN_HARD_HIZ, 0); // can't write STEP register if stepper being powered - // results in an extra NOOP being sent (data 00) - L64xxManager.set_param(axis_index[j], L6470_STEP_MODE, stepVal); // set microsteps - } - } - m_steps = L64xxManager.get_param(axis_index[0], L6470_STEP_MODE) & 0x07; // get microsteps - - DEBUG_ECHOLNPGM("Microsteps = ", _BV(m_steps)); - DEBUG_ECHOLNPGM("target (maximum) feedrate = ", final_feedrate); - - const float feedrate_inc = final_feedrate / 10, // Start at 1/10 of max & go up by 1/10 per step - fr_limit = final_feedrate * 0.99f; // Rounding-safe comparison value - float current_feedrate = 0; - - planner.synchronize(); // Wait for moves to complete - - for (j = 0; j < driver_count; j++) - L64xxManager.get_status(axis_index[j]); // Clear error flags - - char temp_axis_string[2] = " "; - temp_axis_string[0] = axis_mon[0][0]; // Need a sprintf format string - //temp_axis_string[1] = '\n'; - - char gcode_string[80]; - uint16_t status_composite = 0; - DEBUG_ECHOLNPGM(".\n.\n."); // Make feedrate outputs easier to read - - do { - current_feedrate += feedrate_inc; - DEBUG_ECHOLNPGM("...feedrate = ", current_feedrate); - - sprintf_P(gcode_string, PSTR("G0 %s%03d F%03d"), temp_axis_string, uint16_t(position_min), uint16_t(current_feedrate)); - process_subcommands_now(gcode_string); - - sprintf_P(gcode_string, PSTR("G0 %s%03d F%03d"), temp_axis_string, uint16_t(position_max), uint16_t(current_feedrate)); - process_subcommands_now(gcode_string); - - planner.synchronize(); - - for (j = 0; j < driver_count; j++) { - axis_status[j] = (~L64xxManager.get_status(axis_index[j])) & 0x0800; // Bits of interest are all active LOW - status_composite |= axis_status[j]; - } - if (status_composite) break; // Break on any error - } while (current_feedrate < fr_limit); - - DEBUG_ECHOPGM("Completed with "); - if (status_composite) { - DEBUG_ECHOLNPGM("errors"); - #if ENABLED(L6470_CHITCHAT) - for (j = 0; j < driver_count; j++) { - if (j) DEBUG_ECHOPGM("..."); - L64xxManager.error_status_decode(axis_status[j], axis_index[j], - sh.STATUS_AXIS_TH_SD, sh.STATUS_AXIS_TH_WRN, - sh.STATUS_AXIS_STEP_LOSS_A, sh.STATUS_AXIS_STEP_LOSS_B, - sh.STATUS_AXIS_OCD, sh.STATUS_AXIS_LAYOUT); - } - #endif - } - else - DEBUG_ECHOLNPGM("no errors"); - - L64xxManager.pause_monitor(false); -} - -#endif // HAS_L64XX diff --git a/Marlin/src/gcode/feature/advance/M900.cpp b/Marlin/src/gcode/feature/advance/M900.cpp index 8b59e88fb1..db09faa883 100644 --- a/Marlin/src/gcode/feature/advance/M900.cpp +++ b/Marlin/src/gcode/feature/advance/M900.cpp @@ -26,7 +26,6 @@ #include "../../gcode.h" #include "../../../module/planner.h" -#include "../../../module/stepper.h" #if ENABLED(EXTRA_LIN_ADVANCE_K) float other_extruder_advance_K[EXTRUDERS]; diff --git a/Marlin/src/gcode/feature/leds/M150.cpp b/Marlin/src/gcode/feature/leds/M150.cpp index 95e7367b6e..77c58411a3 100644 --- a/Marlin/src/gcode/feature/leds/M150.cpp +++ b/Marlin/src/gcode/feature/leds/M150.cpp @@ -31,11 +31,13 @@ * M150: Set Status LED Color - Use R-U-B-W for R-G-B-W * and Brightness - Use P (for NEOPIXEL only) * - * Always sets all 3 or 4 components. If a component is left out, set to 0. - * If brightness is left out, no value changed + * Always sets all 3 or 4 components unless the K flag is specified. + * If a component is left out, set to 0. + * If brightness is left out, no value changed. * * With NEOPIXEL_LED: * I Set the NeoPixel index to affect. Default: All + * K Keep all unspecified values unchanged instead of setting to 0. * * With NEOPIXEL2_SEPARATE: * S The NeoPixel strip to set. Default: All. @@ -51,16 +53,19 @@ * M150 P ; Set LED full brightness * M150 I1 R ; Set NEOPIXEL index 1 to red * M150 S1 I1 R ; Set SEPARATE index 1 to red + * M150 K R127 ; Set LED red to 50% without changing blue or green */ void GcodeSuite::M150() { + int32_t old_color = 0; + #if ENABLED(NEOPIXEL_LED) const pixel_index_t index = parser.intval('I', -1); #if ENABLED(NEOPIXEL2_SEPARATE) int8_t brightness = neo.brightness(), unit = parser.intval('S', -1); switch (unit) { case -1: neo2.neoindex = index; // fall-thru - case 0: neo.neoindex = index; break; - case 1: neo2.neoindex = index; brightness = neo2.brightness(); break; + case 0: neo.neoindex = index; old_color = parser.seen('K') ? neo.pixel_color(index >= 0 ? index : 0) : 0; break; + case 1: neo2.neoindex = index; brightness = neo2.brightness(); old_color = parser.seen('K') ? neo2.pixel_color(index >= 0 ? index : 0) : 0; break; } #else const uint8_t brightness = neo.brightness(); @@ -69,10 +74,10 @@ void GcodeSuite::M150() { #endif const LEDColor color = LEDColor( - parser.seen('R') ? (parser.has_value() ? parser.value_byte() : 255) : 0, - parser.seen('U') ? (parser.has_value() ? parser.value_byte() : 255) : 0, - parser.seen('B') ? (parser.has_value() ? parser.value_byte() : 255) : 0 - OPTARG(HAS_WHITE_LED, parser.seen('W') ? (parser.has_value() ? parser.value_byte() : 255) : 0) + parser.seen('R') ? (parser.has_value() ? parser.value_byte() : 255) : (old_color >> 16) & 0xFF, + parser.seen('U') ? (parser.has_value() ? parser.value_byte() : 255) : (old_color >> 8) & 0xFF, + parser.seen('B') ? (parser.has_value() ? parser.value_byte() : 255) : old_color & 0xFF + OPTARG(HAS_WHITE_LED, parser.seen('W') ? (parser.has_value() ? parser.value_byte() : 255) : (old_color >> 24) & 0xFF) OPTARG(NEOPIXEL_LED, parser.seen('P') ? (parser.has_value() ? parser.value_byte() : 255) : brightness) ); diff --git a/Marlin/src/gcode/feature/pause/M125.cpp b/Marlin/src/gcode/feature/pause/M125.cpp index ae450cc5e9..9b18eda4fb 100644 --- a/Marlin/src/gcode/feature/pause/M125.cpp +++ b/Marlin/src/gcode/feature/pause/M125.cpp @@ -71,12 +71,12 @@ void GcodeSuite::M125() { if (parser.seenval('X')) park_point.x = RAW_X_POSITION(parser.linearval('X')), if (parser.seenval('Y')) park_point.y = RAW_Y_POSITION(parser.linearval('Y')), NOOP, - if (parser.seenval(AXIS4_NAME)) park_point.i = RAW_X_POSITION(parser.linearval(AXIS4_NAME)), - if (parser.seenval(AXIS5_NAME)) park_point.j = RAW_X_POSITION(parser.linearval(AXIS5_NAME)), - if (parser.seenval(AXIS6_NAME)) park_point.k = RAW_X_POSITION(parser.linearval(AXIS6_NAME)), - if (parser.seenval(AXIS7_NAME)) park_point.u = RAW_X_POSITION(parser.linearval(AXIS7_NAME)), - if (parser.seenval(AXIS8_NAME)) park_point.v = RAW_X_POSITION(parser.linearval(AXIS8_NAME)), - if (parser.seenval(AXIS9_NAME)) park_point.w = RAW_X_POSITION(parser.linearval(AXIS9_NAME)) + if (parser.seenval(AXIS4_NAME)) park_point.i = RAW_I_POSITION(parser.linearval(AXIS4_NAME)), + if (parser.seenval(AXIS5_NAME)) park_point.j = RAW_J_POSITION(parser.linearval(AXIS5_NAME)), + if (parser.seenval(AXIS6_NAME)) park_point.k = RAW_K_POSITION(parser.linearval(AXIS6_NAME)), + if (parser.seenval(AXIS7_NAME)) park_point.u = RAW_U_POSITION(parser.linearval(AXIS7_NAME)), + if (parser.seenval(AXIS8_NAME)) park_point.v = RAW_V_POSITION(parser.linearval(AXIS8_NAME)), + if (parser.seenval(AXIS9_NAME)) park_point.w = RAW_W_POSITION(parser.linearval(AXIS9_NAME)) ); // Lift Z axis diff --git a/Marlin/src/gcode/feature/trinamic/M122.cpp b/Marlin/src/gcode/feature/trinamic/M122.cpp index 2941632406..07fe9e5bd8 100644 --- a/Marlin/src/gcode/feature/trinamic/M122.cpp +++ b/Marlin/src/gcode/feature/trinamic/M122.cpp @@ -26,7 +26,7 @@ #include "../../gcode.h" #include "../../../feature/tmc_util.h" -#include "../../../module/stepper/indirection.h" +#include "../../../module/stepper/indirection.h" // for restore_stepper_drivers /** * M122: Debug TMC drivers diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index f4dac89b0e..405e2d460c 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -53,7 +53,7 @@ GcodeSuite gcode; #include "../feature/cancel_object.h" #endif -#if ENABLED(LASER_MOVE_POWER) +#if ENABLED(LASER_FEATURE) #include "../feature/spindle_laser.h" #endif @@ -210,8 +210,11 @@ void GcodeSuite::get_destination_from_command() { recovery.save(); #endif - if (parser.floatval('F') > 0) + if (parser.floatval('F') > 0) { feedrate_mm_s = parser.value_feedrate(); + // Update the cutter feed rate for use by M4 I set inline moves. + TERN_(LASER_FEATURE, cutter.feedrate_mm_m = MMS_TO_MMM(feedrate_mm_s)); + } #if BOTH(PRINTCOUNTER, HAS_EXTRUDERS) if (!DEBUGGING(DRYRUN) && !skip_move) @@ -223,15 +226,29 @@ void GcodeSuite::get_destination_from_command() { M165(); #endif - #if ENABLED(LASER_MOVE_POWER) - // Set the laser power in the planner to configure this move - if (parser.seen('S')) { - const float spwr = parser.value_float(); - cutter.inline_power(TERN(SPINDLE_LASER_USE_PWM, cutter.power_to_range(cutter_power_t(round(spwr))), spwr > 0 ? 255 : 0)); + #if ENABLED(LASER_FEATURE) + if (cutter.cutter_mode == CUTTER_MODE_CONTINUOUS || cutter.cutter_mode == CUTTER_MODE_DYNAMIC) { + // Set the cutter power in the planner to configure this move + cutter.last_feedrate_mm_m = 0; + if (WITHIN(parser.codenum, 1, TERN(ARC_SUPPORT, 3, 1)) || TERN0(BEZIER_CURVE_SUPPORT, parser.codenum == 5)) { + planner.laser_inline.status.isPowered = true; + if (parser.seen('I')) cutter.set_enabled(true); // This is set for backward LightBurn compatibility. + if (parser.seenval('S')) { + const float v = parser.value_float(), + u = TERN(LASER_POWER_TRAP, v, cutter.power_to_range(v)); + cutter.menuPower = cutter.unitPower = u; + cutter.inline_power(TERN(SPINDLE_LASER_USE_PWM, cutter.upower_to_ocr(u), u > 0 ? 255 : 0)); + } + } + else if (parser.codenum == 0) { + // For dynamic mode we need to flag isPowered off, dynamic power is calculated in the stepper based on feedrate. + if (cutter.cutter_mode == CUTTER_MODE_DYNAMIC) planner.laser_inline.status.isPowered = false; + cutter.inline_power(0); // This is planner-based so only set power and do not disable inline control flags. + } } - else if (ENABLED(LASER_MOVE_G0_OFF) && parser.codenum == 0) // G0 - cutter.set_inline_enabled(false); - #endif + else if (parser.codenum == 0) + cutter.apply_power(0); + #endif // LASER_FEATURE } /** @@ -560,6 +577,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 100: M100(); break; // M100: Free Memory Report #endif + #if ENABLED(BD_SENSOR) + case 102: M102(); break; // M102: Configure Bed Distance Sensor + #endif + #if HAS_EXTRUDERS case 104: M104(); break; // M104: Set hot end temperature case 109: M109(); break; // M109: Wait for hotend temperature to reach target @@ -748,7 +769,7 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 290: M290(); break; // M290: Babystepping #endif - #if HAS_BUZZER + #if HAS_SOUND case 300: M300(); break; // M300: Play beep tone #endif @@ -916,7 +937,7 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { #endif #if IS_KINEMATIC - case 665: M665(); break; // M665: Set Delta/SCARA parameters + case 665: M665(); break; // M665: Set Kinematics parameters #endif #if ENABLED(DELTA) || HAS_EXTRA_ENDSTOPS @@ -988,14 +1009,6 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 919: M919(); break; // M919: Set stepper Chopper Times #endif - #if HAS_L64XX - case 122: M122(); break; // M122: Report status - case 906: M906(); break; // M906: Set or get motor drive level - case 916: M916(); break; // M916: L6470 tuning: Increase drive level until thermal warning - case 917: M917(); break; // M917: L6470 tuning: Find minimum current thresholds - case 918: M918(); break; // M918: L6470 tuning: Increase speed until max or error - #endif - #if HAS_MICROSTEPS case 350: M350(); break; // M350: Set microstepping mode. Warning: Steps per unit remains unchanged. S code sets stepping mode for all drivers. case 351: M351(); break; // M351: Toggle MS1 MS2 pins directly, S# determines MS1 or MS2, X# sets the pin high/low. diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 1efcb1cf93..2b15706395 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -132,6 +132,8 @@ * * M100 - Watch Free Memory (for debugging) (Requires M100_FREE_MEMORY_WATCHER) * + * M102 - Configure Bed Distance Sensor. (Requires BD_SENSOR) + * * M104 - Set extruder target temp. * M105 - Report current temperatures. * M106 - Set print fan speed. @@ -155,7 +157,7 @@ * M120 - Enable endstops detection. * M121 - Disable endstops detection. * - * M122 - Debug stepper (Requires at least one _DRIVER_TYPE defined as TMC2130/2160/5130/5160/2208/2209/2660 or L6470) + * M122 - Debug stepper (Requires at least one _DRIVER_TYPE defined as TMC2130/2160/5130/5160/2208/2209/2660) * M123 - Report fan tachometers. (Requires En_FAN_TACHO_PIN) Optionally set auto-report interval. (Requires AUTO_REPORT_FANS) * M125 - Save current position and move to filament change position. (Requires PARK_HEAD_ON_PAUSE) * @@ -262,6 +264,7 @@ * M605 - Set Dual X-Carriage movement mode: "M605 S [X] [R]". (Requires DUAL_X_CARRIAGE) * M665 - Set delta configurations: "M665 H L R S B X Y Z (Requires DELTA) * Set SCARA configurations: "M665 S P T Z (Requires MORGAN_SCARA or MP_SCARA) + * Set Polargraph draw area and belt length: "M665 S L R T B H" * M666 - Set/get offsets for delta (Requires DELTA) or dual endstops. (Requires [XYZ]_DUAL_ENDSTOPS) * M672 - Set/Reset Duet Smart Effector's sensitivity. (Requires DUET_SMART_EFFECTOR and SMART_EFFECTOR_MOD_PIN) * M701 - Load filament (Requires FILAMENT_LOAD_UNLOAD_GCODES) @@ -286,7 +289,7 @@ * M871 - Print/reset/clear first layer temperature offset values. (Requires PTC_PROBE, PTC_BED, or PTC_HOTEND) * M876 - Handle Prompt Response. (Requires HOST_PROMPT_SUPPORT and not EMERGENCY_PARSER) * M900 - Get or Set Linear Advance K-factor. (Requires LIN_ADVANCE) - * M906 - Set or get motor current in milliamps using axis codes XYZE, etc. Report values if no axis codes given. (Requires at least one _DRIVER_TYPE defined as TMC2130/2160/5130/5160/2208/2209/2660 or L6470) + * M906 - Set or get motor current in milliamps using axis codes XYZE, etc. Report values if no axis codes given. (Requires at least one _DRIVER_TYPE defined as TMC2130/2160/5130/5160/2208/2209/2660) * M907 - Set digital trimpot motor current using axis codes. (Requires a board with digital trimpots) * M908 - Control digital trimpot directly. (Requires HAS_MOTOR_CURRENT_DAC or DIGIPOTSS_PIN) * M909 - Print digipot/DAC current value. (Requires HAS_MOTOR_CURRENT_DAC) @@ -295,9 +298,6 @@ * M912 - Clear stepper driver overtemperature pre-warn condition flag. (Requires at least one _DRIVER_TYPE defined as TMC2130/2160/5130/5160/2208/2209/2660) * M913 - Set HYBRID_THRESHOLD speed. (Requires HYBRID_THRESHOLD) * M914 - Set StallGuard sensitivity. (Requires SENSORLESS_HOMING or SENSORLESS_PROBING) - * M916 - L6470 tuning: Increase KVAL_HOLD until thermal warning. (Requires at least one _DRIVER_TYPE L6470) - * M917 - L6470 tuning: Find minimum current thresholds. (Requires at least one _DRIVER_TYPE L6470) - * M918 - L6470 tuning: Increase speed until max or error. (Requires at least one _DRIVER_TYPE L6470) * M919 - Get or Set motor Chopper Times (time_off, hysteresis_end, hysteresis_start) using axis codes XYZE, etc. If no parameters are given, report. (Requires at least one _DRIVER_TYPE defined as TMC2130/2160/5130/5160/2208/2209/2660) * M951 - Set Magnetic Parking Extruder parameters. (Requires MAGNETIC_PARKING_EXTRUDER) * M3426 - Read MCP3426 ADC over I2C. (Requires HAS_MCP3426_ADC) @@ -707,6 +707,11 @@ class GcodeSuite { static void M100(); #endif + #if ENABLED(BD_SENSOR) + static void M102(); + static void M102_report(const bool forReplay=true); + #endif + #if HAS_EXTRUDERS static void M104_M109(const bool isM109); FORCE_INLINE static void M104() { M104_M109(false); } @@ -886,7 +891,7 @@ class GcodeSuite { static void M250_report(const bool forReplay=true); #endif - #if HAS_DISPLAY_SLEEP + #if HAS_GCODE_M255 static void M255(); static void M255_report(const bool forReplay=true); #endif @@ -916,7 +921,7 @@ class GcodeSuite { static void M290(); #endif - #if HAS_BUZZER + #if HAS_SOUND static void M300(); #endif @@ -1163,14 +1168,6 @@ class GcodeSuite { static void M919(); #endif - #if HAS_L64XX - static void M122(); - static void M906(); - static void M916(); - static void M917(); - static void M918(); - #endif - #if HAS_MOTOR_CURRENT_SPI || HAS_MOTOR_CURRENT_PWM || HAS_MOTOR_CURRENT_I2C || HAS_MOTOR_CURRENT_DAC static void M907(); #if HAS_MOTOR_CURRENT_SPI || HAS_MOTOR_CURRENT_PWM diff --git a/Marlin/src/gcode/geometry/G53-G59.cpp b/Marlin/src/gcode/geometry/G53-G59.cpp index 092c141228..c51c29f423 100644 --- a/Marlin/src/gcode/geometry/G53-G59.cpp +++ b/Marlin/src/gcode/geometry/G53-G59.cpp @@ -25,8 +25,6 @@ #if ENABLED(CNC_COORDINATE_SYSTEMS) -#include "../../module/stepper.h" - //#define DEBUG_M53 /** diff --git a/Marlin/src/gcode/geometry/G92.cpp b/Marlin/src/gcode/geometry/G92.cpp index 58ed26a15a..b36f21d3c0 100644 --- a/Marlin/src/gcode/geometry/G92.cpp +++ b/Marlin/src/gcode/geometry/G92.cpp @@ -22,7 +22,6 @@ #include "../gcode.h" #include "../../module/motion.h" -#include "../../module/stepper.h" #if ENABLED(I2C_POSITION_ENCODERS) #include "../../feature/encoder_i2c.h" diff --git a/Marlin/src/gcode/host/M114.cpp b/Marlin/src/gcode/host/M114.cpp index 8ea300b5e0..60359eeecf 100644 --- a/Marlin/src/gcode/host/M114.cpp +++ b/Marlin/src/gcode/host/M114.cpp @@ -28,12 +28,6 @@ #if ENABLED(M114_DETAIL) - #if HAS_L64XX - #include "../../libs/L64XX/L64XX_Marlin.h" - #define DEBUG_OUT ENABLED(L6470_CHITCHAT) - #include "../../core/debug_out.h" - #endif - void report_all_axis_pos(const xyze_pos_t &pos, const uint8_t n=LOGICAL_AXES, const uint8_t precision=3) { char str[12]; LOOP_L_N(a, n) { @@ -84,89 +78,6 @@ planner.synchronize(); - #if HAS_L64XX - char temp_buf[80]; - int32_t temp; - //#define ABS_POS_SIGN_MASK 0b1111 1111 1110 0000 0000 0000 0000 0000 - #define ABS_POS_SIGN_MASK 0b11111111111000000000000000000000 - #define REPORT_ABSOLUTE_POS(Q) do{ \ - L64xxManager.say_axis(Q, false); \ - temp = L6470_GETPARAM(L6470_ABS_POS,Q); \ - if (temp & ABS_POS_SIGN_MASK) temp |= ABS_POS_SIGN_MASK; \ - sprintf_P(temp_buf, PSTR(":%8ld "), temp); \ - DEBUG_ECHO(temp_buf); \ - }while(0) - - DEBUG_ECHOPGM("\nL6470:"); - #if AXIS_IS_L64XX(X) - REPORT_ABSOLUTE_POS(X); - #endif - #if AXIS_IS_L64XX(X2) - REPORT_ABSOLUTE_POS(X2); - #endif - #if AXIS_IS_L64XX(Y) - REPORT_ABSOLUTE_POS(Y); - #endif - #if AXIS_IS_L64XX(Y2) - REPORT_ABSOLUTE_POS(Y2); - #endif - #if AXIS_IS_L64XX(Z) - REPORT_ABSOLUTE_POS(Z); - #endif - #if AXIS_IS_L64XX(Z2) - REPORT_ABSOLUTE_POS(Z2); - #endif - #if AXIS_IS_L64XX(Z3) - REPORT_ABSOLUTE_POS(Z3); - #endif - #if AXIS_IS_L64XX(Z4) - REPORT_ABSOLUTE_POS(Z4); - #endif - #if AXIS_IS_L64XX(I) - REPORT_ABSOLUTE_POS(I); - #endif - #if AXIS_IS_L64XX(J) - REPORT_ABSOLUTE_POS(J); - #endif - #if AXIS_IS_L64XX(K) - REPORT_ABSOLUTE_POS(K); - #endif - #if AXIS_IS_L64XX(U) - REPORT_ABSOLUTE_POS(U); - #endif - #if AXIS_IS_L64XX(V) - REPORT_ABSOLUTE_POS(V); - #endif - #if AXIS_IS_L64XX(W) - REPORT_ABSOLUTE_POS(W); - #endif - #if AXIS_IS_L64XX(E0) - REPORT_ABSOLUTE_POS(E0); - #endif - #if AXIS_IS_L64XX(E1) - REPORT_ABSOLUTE_POS(E1); - #endif - #if AXIS_IS_L64XX(E2) - REPORT_ABSOLUTE_POS(E2); - #endif - #if AXIS_IS_L64XX(E3) - REPORT_ABSOLUTE_POS(E3); - #endif - #if AXIS_IS_L64XX(E4) - REPORT_ABSOLUTE_POS(E4); - #endif - #if AXIS_IS_L64XX(E5) - REPORT_ABSOLUTE_POS(E5); - #endif - #if AXIS_IS_L64XX(E6) - REPORT_ABSOLUTE_POS(E6); - #endif - #if AXIS_IS_L64XX(E7) - REPORT_ABSOLUTE_POS(E7); - #endif - SERIAL_EOL(); - #endif // HAS_L64XX - SERIAL_ECHOPGM("Stepper:"); LOOP_LOGICAL_AXES(i) { SERIAL_ECHOPGM_P((PGM_P)pgm_read_ptr(&SP_AXIS_LBL[i]), stepper.position((AxisEnum)i)); diff --git a/Marlin/src/gcode/lcd/M255.cpp b/Marlin/src/gcode/lcd/M255.cpp index cfdf27b8a1..4a9049ab2c 100644 --- a/Marlin/src/gcode/lcd/M255.cpp +++ b/Marlin/src/gcode/lcd/M255.cpp @@ -36,7 +36,7 @@ void GcodeSuite::M255() { const int m = parser.value_int(); ui.sleep_timeout_minutes = constrain(m, SLEEP_TIMEOUT_MIN, SLEEP_TIMEOUT_MAX); #else - const int s = parser.value_int() * 60; + const unsigned int s = parser.value_ushort() * 60; ui.lcd_backlight_timeout = constrain(s, LCD_BKL_TIMEOUT_MIN, LCD_BKL_TIMEOUT_MAX); #endif } diff --git a/Marlin/src/gcode/lcd/M256.cpp b/Marlin/src/gcode/lcd/M256.cpp index cdcdf56891..9842cc2583 100644 --- a/Marlin/src/gcode/lcd/M256.cpp +++ b/Marlin/src/gcode/lcd/M256.cpp @@ -38,7 +38,7 @@ void GcodeSuite::M256() { void GcodeSuite::M256_report(const bool forReplay/*=true*/) { report_heading_etc(forReplay, F(STR_LCD_BRIGHTNESS)); - SERIAL_ECHOLNPGM(" M256 B", ui.brightness); // @advi3++ + SERIAL_ECHOLNPGM(" M256 B", ui.brightness); } #endif // HAS_LCD_BRIGHTNESS diff --git a/Marlin/src/gcode/lcd/M300.cpp b/Marlin/src/gcode/lcd/M300.cpp index 2a820b6e48..827aca26c8 100644 --- a/Marlin/src/gcode/lcd/M300.cpp +++ b/Marlin/src/gcode/lcd/M300.cpp @@ -22,7 +22,7 @@ #include "../../inc/MarlinConfig.h" -#if HAS_BUZZER +#if HAS_SOUND #include "../gcode.h" @@ -42,4 +42,4 @@ void GcodeSuite::M300() { BUZZ_M300(duration, frequency); // @advi3++ } -#endif // HAS_BUZZER +#endif // HAS_SOUND diff --git a/Marlin/src/gcode/motion/G0_G1.cpp b/Marlin/src/gcode/motion/G0_G1.cpp index 933bf3d5d9..cee2f05080 100644 --- a/Marlin/src/gcode/motion/G0_G1.cpp +++ b/Marlin/src/gcode/motion/G0_G1.cpp @@ -32,7 +32,7 @@ #include "../../sd/cardreader.h" #if ENABLED(NANODLP_Z_SYNC) - #include "../../module/stepper.h" + #include "../../module/planner.h" #endif extern xyze_pos_t destination; diff --git a/Marlin/src/gcode/motion/G2_G3.cpp b/Marlin/src/gcode/motion/G2_G3.cpp index cd8225de69..1a0a9c8ccc 100644 --- a/Marlin/src/gcode/motion/G2_G3.cpp +++ b/Marlin/src/gcode/motion/G2_G3.cpp @@ -214,9 +214,12 @@ void plan_arc( const uint16_t segments = nominal_segment_mm > (MAX_ARC_SEGMENT_MM) ? CEIL(flat_mm / (MAX_ARC_SEGMENT_MM)) : nominal_segment_mm < (MIN_ARC_SEGMENT_MM) ? _MAX(1, FLOOR(flat_mm / (MIN_ARC_SEGMENT_MM))) : nominal_segments; + const float segment_mm = flat_mm / segments; + // Add hints to help optimize the move + PlannerHints hints; #if ENABLED(SCARA_FEEDRATE_SCALING) - const float inv_duration = (scaled_fr_mm_s / flat_mm) * segments; + hints.inv_duration = (scaled_fr_mm_s / flat_mm) * segments; #endif /** @@ -288,9 +291,20 @@ void plan_arc( int8_t arc_recalc_count = N_ARC_CORRECTION; #endif + // An arc can always complete within limits from a speed which... + // a) is <= any configured maximum speed, + // b) does not require centripetal force greater than any configured maximum acceleration, + // c) is <= nominal speed, + // d) allows the print head to stop in the remining length of the curve within all configured maximum accelerations. + // The last has to be calculated every time through the loop. + const float limiting_accel = _MIN(planner.settings.max_acceleration_mm_per_s2[axis_p], planner.settings.max_acceleration_mm_per_s2[axis_q]), + limiting_speed = _MIN(planner.settings.max_feedrate_mm_s[axis_p], planner.settings.max_acceleration_mm_per_s2[axis_q]), + limiting_speed_sqr = _MIN(sq(limiting_speed), limiting_accel * radius, sq(scaled_fr_mm_s)); + float arc_mm_remaining = flat_mm; + for (uint16_t i = 1; i < segments; i++) { // Iterate (segments-1) times - thermalManager.manage_heater(); + thermalManager.task(); const millis_t ms = millis(); if (ELAPSED(ms, next_idle_ms)) { next_idle_ms = ms + 200UL; @@ -315,7 +329,7 @@ void plan_arc( // Compute exact location by applying transformation matrix from initial radius vector(=-offset). // To reduce stuttering, the sin and cos could be computed at different times. // For now, compute both at the same time. - const float cos_Ti = cos(i * theta_per_segment), sin_Ti = sin(i * theta_per_segment); + const float Ti = i * theta_per_segment, cos_Ti = cos(Ti), sin_Ti = sin(Ti); rvec.a = -offset[0] * cos_Ti + offset[1] * sin_Ti; rvec.b = -offset[0] * sin_Ti - offset[1] * cos_Ti; } @@ -342,8 +356,14 @@ void plan_arc( planner.apply_leveling(raw); #endif - if (!planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, 0 OPTARG(SCARA_FEEDRATE_SCALING, inv_duration))) + // calculate safe speed for stopping by the end of the arc + arc_mm_remaining -= segment_mm; + hints.safe_exit_speed_sqr = _MIN(limiting_speed_sqr, 2 * limiting_accel * arc_mm_remaining); + + if (!planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, hints)) break; + + hints.curve_radius = radius; } } @@ -363,7 +383,9 @@ void plan_arc( planner.apply_leveling(raw); #endif - planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, 0 OPTARG(SCARA_FEEDRATE_SCALING, inv_duration)); + hints.curve_radius = 0; + hints.safe_exit_speed_sqr = 0.0f; + planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, hints); #if ENABLED(AUTO_BED_LEVELING_UBL) ARC_LIJKUVW_CODE( diff --git a/Marlin/src/gcode/motion/G4.cpp b/Marlin/src/gcode/motion/G4.cpp index df3f5b010e..ebaa6aabc0 100644 --- a/Marlin/src/gcode/motion/G4.cpp +++ b/Marlin/src/gcode/motion/G4.cpp @@ -21,7 +21,7 @@ */ #include "../gcode.h" -#include "../../module/stepper.h" +#include "../../module/planner.h" #include "../../lcd/marlinui.h" /** diff --git a/Marlin/src/gcode/motion/G6.cpp b/Marlin/src/gcode/motion/G6.cpp index a57a293e06..fb6281707b 100644 --- a/Marlin/src/gcode/motion/G6.cpp +++ b/Marlin/src/gcode/motion/G6.cpp @@ -50,7 +50,7 @@ void GcodeSuite::G6() { // No speed is set, can't schedule the move if (!planner.last_page_step_rate) return; - const page_idx_t page_idx = (page_idx_t) parser.value_ulong(); + const page_idx_t page_idx = (page_idx_t)parser.value_ulong(); uint16_t num_steps = DirectStepping::Config::TOTAL_STEPS; if (parser.seen('S')) num_steps = parser.value_ushort(); diff --git a/Marlin/src/gcode/probe/G30.cpp b/Marlin/src/gcode/probe/G30.cpp index a16853bdf8..e474ffe9d6 100644 --- a/Marlin/src/gcode/probe/G30.cpp +++ b/Marlin/src/gcode/probe/G30.cpp @@ -33,7 +33,11 @@ #include "../../feature/probe_temp_comp.h" #endif -#if ENABLED(DWIN_LCD_PROUI) +#if HAS_MULTI_HOTEND + #include "../../module/tool_change.h" +#endif + +#if EITHER(DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI) #include "../../lcd/marlinui.h" #endif @@ -49,6 +53,11 @@ */ void GcodeSuite::G30() { + #if HAS_MULTI_HOTEND + const uint8_t old_tool_index = active_extruder; + tool_change(0); + #endif + const xy_pos_t pos = { parser.linearval('X', current_position.x + probe.offset_xy.x), parser.linearval('Y', current_position.y + probe.offset_xy.y) }; @@ -57,40 +66,45 @@ void GcodeSuite::G30() { SERIAL_ECHOLNF(GET_EN_TEXT_F(MSG_ZPROBE_OUT)); LCD_MESSAGE(MSG_ZPROBE_OUT); #endif - return; } + else { + // Disable leveling so the planner won't mess with us + TERN_(HAS_LEVELING, set_bed_leveling_enabled(false)); - // Disable leveling so the planner won't mess with us - TERN_(HAS_LEVELING, set_bed_leveling_enabled(false)); - - remember_feedrate_scaling_off(); - - TERN_(DWIN_LCD_PROUI, process_subcommands_now(F("G28O"))); + remember_feedrate_scaling_off(); - const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE; - - TERN_(HAS_PTC, ptc.set_enabled(!parser.seen('C') || parser.value_bool())); - const float measured_z = probe.probe_at_point(pos, raise_after, 1); - TERN_(HAS_PTC, ptc.set_enabled(true)); - if (!isnan(measured_z)) { - SERIAL_ECHOLNPGM("Bed X: ", pos.x, " Y: ", pos.y, " Z: ", measured_z); - #if ENABLED(DWIN_LCD_PROUI) - char msg[31], str_1[6], str_2[6], str_3[6]; - sprintf_P(msg, PSTR("X:%s, Y:%s, Z:%s"), - dtostrf(pos.x, 1, 1, str_1), - dtostrf(pos.y, 1, 1, str_2), - dtostrf(measured_z, 1, 2, str_3) - ); - ui.set_status(msg); + #if EITHER(DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI) + process_subcommands_now(F("G28O")); #endif - } - restore_feedrate_and_scaling(); - - if (raise_after == PROBE_PT_STOW) - probe.move_z_after_probing(); + const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE; + + TERN_(HAS_PTC, ptc.set_enabled(!parser.seen('C') || parser.value_bool())); + const float measured_z = probe.probe_at_point(pos, raise_after, 1); + TERN_(HAS_PTC, ptc.set_enabled(true)); + if (!isnan(measured_z)) { + SERIAL_ECHOLNPGM("Bed X: ", pos.x, " Y: ", pos.y, " Z: ", measured_z); + #if EITHER(DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI) + char msg[31], str_1[6], str_2[6], str_3[6]; + sprintf_P(msg, PSTR("X:%s, Y:%s, Z:%s"), + dtostrf(pos.x, 1, 1, str_1), + dtostrf(pos.y, 1, 1, str_2), + dtostrf(measured_z, 1, 2, str_3) + ); + ui.set_status(msg); + #endif + } + + restore_feedrate_and_scaling(); + + if (raise_after == PROBE_PT_STOW) + probe.move_z_after_probing(); + + report_current_position(); + } - report_current_position(); + // Restore the active tool + TERN_(HAS_MULTI_HOTEND, tool_change(old_tool_index)); } #endif // HAS_BED_PROBE diff --git a/Marlin/src/gcode/probe/G38.cpp b/Marlin/src/gcode/probe/G38.cpp index ed24ce3258..1b2da756b1 100644 --- a/Marlin/src/gcode/probe/G38.cpp +++ b/Marlin/src/gcode/probe/G38.cpp @@ -28,7 +28,7 @@ #include "../../module/endstops.h" #include "../../module/motion.h" -#include "../../module/stepper.h" +#include "../../module/planner.h" #include "../../module/probe.h" inline void G38_single_probe(const uint8_t move_value) { diff --git a/Marlin/src/gcode/probe/M102.cpp b/Marlin/src/gcode/probe/M102.cpp new file mode 100644 index 0000000000..b70c9aed18 --- /dev/null +++ b/Marlin/src/gcode/probe/M102.cpp @@ -0,0 +1,57 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program 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. + * + * This program 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 this program. If not, see . + * + */ + +/** + * M102.cpp - Configure Bed Distance Sensor + */ + +#include "../../inc/MarlinConfig.h" + +#if ENABLED(BD_SENSOR) + +#include "../gcode.h" +#include "../../feature/bedlevel/bdl/bdl.h" + +/** + * M102: Configure the Bed Distance Sensor + * + * M102 S<10ths> : Set adjustable Z height in 10ths of a mm (e.g., 'M102 S4' enables adjusting for Z <= 0.4mm.) + * M102 S0 : Disable adjustable Z height. + * + * Negative S values are commands: + * M102 S-1 : Read sensor information + * M102 S-5 : Read raw Calibration data + * M102 S-6 : Start Calibration + */ +void GcodeSuite::M102() { + if (parser.seenval('S')) + bdl.config_state = parser.value_int(); + else + M102_report(); +} + +void GcodeSuite::M102_report(const bool forReplay/*=true*/) { + report_heading(forReplay, F("Bed Distance Sensor")); + SERIAL_ECHOLNPGM(" M102 S", bdl.config_state); +} + +#endif // BD_SENSOR diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index 454a009b85..a390a46d8e 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -384,7 +384,7 @@ inline bool process_line_done(uint8_t &sis, char (&buff)[MAX_CMD_SIZE], int &ind buff[ind] = '\0'; // Of course, I'm a Terminator. const bool is_empty = (ind == 0); // An empty line? if (is_empty) - thermalManager.manage_heater(); // Keep sensors satisfied + thermalManager.task(); // Keep sensors satisfied else ind = 0; // Start a new line return is_empty; // Inform the caller diff --git a/Marlin/src/gcode/temp/M106_M107.cpp b/Marlin/src/gcode/temp/M106_M107.cpp index 98e87c415d..ae517c977b 100644 --- a/Marlin/src/gcode/temp/M106_M107.cpp +++ b/Marlin/src/gcode/temp/M106_M107.cpp @@ -90,7 +90,7 @@ void GcodeSuite::M106() { // Set speed, with constraint thermalManager.set_fan_speed(pfan, speed); - TERN_(LASER_SYNCHRONOUS_M106_M107, planner.buffer_sync_block(BLOCK_FLAG_SYNC_FANS)); + TERN_(LASER_SYNCHRONOUS_M106_M107, planner.buffer_sync_block(BLOCK_BIT_SYNC_FANS)); if (TERN0(DUAL_X_CARRIAGE, idex_is_duplicating())) // pfan == 0 when duplicating thermalManager.set_fan_speed(1 - pfan, speed); @@ -111,7 +111,7 @@ void GcodeSuite::M107() { if (TERN0(DUAL_X_CARRIAGE, idex_is_duplicating())) // pfan == 0 when duplicating thermalManager.set_fan_speed(1 - pfan, 0); - TERN_(LASER_SYNCHRONOUS_M106_M107, planner.buffer_sync_block(BLOCK_FLAG_SYNC_FANS)); + TERN_(LASER_SYNCHRONOUS_M106_M107, planner.buffer_sync_block(BLOCK_BIT_SYNC_FANS)); } #endif // HAS_FAN diff --git a/Marlin/src/gcode/temp/M303.cpp b/Marlin/src/gcode/temp/M303.cpp index ce362984a6..a4d514c733 100644 --- a/Marlin/src/gcode/temp/M303.cpp +++ b/Marlin/src/gcode/temp/M303.cpp @@ -48,7 +48,7 @@ void GcodeSuite::M303() { - #if ANY(PID_DEBUG, PID_BED_DEBUG, PID_CHAMBER_DEBUG) + #if HAS_PID_DEBUG if (parser.seen_test('D')) { thermalManager.pid_debug_flag ^= true; SERIAL_ECHO_START(); diff --git a/Marlin/src/gcode/units/M149.cpp b/Marlin/src/gcode/units/M149.cpp index 3f1ea3654e..a04247cbcb 100644 --- a/Marlin/src/gcode/units/M149.cpp +++ b/Marlin/src/gcode/units/M149.cpp @@ -30,9 +30,9 @@ * M149: Set temperature units */ void GcodeSuite::M149() { - if (parser.seenval('C')) parser.set_input_temp_units(TEMPUNIT_C); - else if (parser.seenval('K')) parser.set_input_temp_units(TEMPUNIT_K); - else if (parser.seenval('F')) parser.set_input_temp_units(TEMPUNIT_F); + if (parser.seen('C')) parser.set_input_temp_units(TEMPUNIT_C); + else if (parser.seen('K')) parser.set_input_temp_units(TEMPUNIT_K); + else if (parser.seen('F')) parser.set_input_temp_units(TEMPUNIT_F); else M149_report(); } diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index e41bc0d489..c1c174da46 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -99,7 +99,7 @@ #define IS_ULTIPANEL 1 #define STD_ENCODER_PULSES_PER_STEP 2 -#elif ANY(miniVIKI, VIKI2, WYH_L12864, ELB_FULL_GRAPHIC_CONTROLLER, AZSMZ_12864) +#elif ANY(miniVIKI, VIKI2, WYH_L12864, ELB_FULL_GRAPHIC_CONTROLLER, AZSMZ_12864, EMOTION_TECH_LCD) #define DOGLCD #define IS_DOGM_12864 1 @@ -116,6 +116,9 @@ #define IS_U8GLIB_LM6059_AF 1 #elif ENABLED(AZSMZ_12864) #define IS_U8GLIB_ST7565_64128N 1 + #elif ENABLED(EMOTION_TECH_LCD) + #define IS_U8GLIB_ST7565_64128N 1 + #define ST7565_VOLTAGE_DIVIDER_VALUE 0x07 #endif #elif ENABLED(OLED_PANEL_TINYBOY2) @@ -461,7 +464,7 @@ #define HAS_DGUS_LCD_CLASSIC 1 #endif -#if ANY(HAS_DGUS_LCD_CLASSIC, DGUS_LCD_UI_RELOADED) +#if EITHER(HAS_DGUS_LCD_CLASSIC, DGUS_LCD_UI_RELOADED) #define HAS_DGUS_LCD 1 #endif @@ -665,6 +668,31 @@ #define E_MANUAL EXTRUDERS #endif +#if E_STEPPERS <= 7 + #undef INVERT_E7_DIR + #if E_STEPPERS <= 6 + #undef INVERT_E6_DIR + #if E_STEPPERS <= 5 + #undef INVERT_E5_DIR + #if E_STEPPERS <= 4 + #undef INVERT_E4_DIR + #if E_STEPPERS <= 3 + #undef INVERT_E3_DIR + #if E_STEPPERS <= 2 + #undef INVERT_E2_DIR + #if E_STEPPERS <= 1 + #undef INVERT_E1_DIR + #if E_STEPPERS == 0 + #undef INVERT_E0_DIR + #endif + #endif + #endif + #endif + #endif + #endif + #endif +#endif + /** * Number of Linear Axes (e.g., XYZIJKUVW) * All the logical axes except for the tool (E) axis @@ -765,6 +793,9 @@ #undef Y_MIN_POS #undef Y_MAX_POS #undef MANUAL_Y_HOME_POS + #undef MIN_SOFTWARE_ENDSTOP_Y + #undef MAX_SOFTWARE_ENDSTOP_Y + #undef SAFE_BED_LEVELING_START_Y #endif #if !HAS_Z_AXIS @@ -782,6 +813,9 @@ #undef Z_MIN_POS #undef Z_MAX_POS #undef MANUAL_Z_HOME_POS + #undef MIN_SOFTWARE_ENDSTOP_Z + #undef MAX_SOFTWARE_ENDSTOP_Z + #undef SAFE_BED_LEVELING_START_Z #endif #if !HAS_I_AXIS @@ -796,6 +830,9 @@ #undef I_MIN_POS #undef I_MAX_POS #undef MANUAL_I_HOME_POS + #undef MIN_SOFTWARE_ENDSTOP_I + #undef MAX_SOFTWARE_ENDSTOP_I + #undef SAFE_BED_LEVELING_START_I #endif #if !HAS_J_AXIS @@ -810,6 +847,9 @@ #undef J_MIN_POS #undef J_MAX_POS #undef MANUAL_J_HOME_POS + #undef MIN_SOFTWARE_ENDSTOP_J + #undef MAX_SOFTWARE_ENDSTOP_J + #undef SAFE_BED_LEVELING_START_J #endif #if !HAS_K_AXIS @@ -824,6 +864,9 @@ #undef K_MIN_POS #undef K_MAX_POS #undef MANUAL_K_HOME_POS + #undef MIN_SOFTWARE_ENDSTOP_K + #undef MAX_SOFTWARE_ENDSTOP_K + #undef SAFE_BED_LEVELING_START_K #endif #if !HAS_U_AXIS @@ -838,6 +881,9 @@ #undef U_MIN_POS #undef U_MAX_POS #undef MANUAL_U_HOME_POS + #undef MIN_SOFTWARE_ENDSTOP_U + #undef MAX_SOFTWARE_ENDSTOP_U + #undef SAFE_BED_LEVELING_START_U #endif #if !HAS_V_AXIS @@ -852,6 +898,9 @@ #undef V_MIN_POS #undef V_MAX_POS #undef MANUAL_V_HOME_POS + #undef MIN_SOFTWARE_ENDSTOP_V + #undef MAX_SOFTWARE_ENDSTOP_V + #undef SAFE_BED_LEVELING_START_V #endif #if !HAS_W_AXIS @@ -866,6 +915,9 @@ #undef W_MIN_POS #undef W_MAX_POS #undef MANUAL_W_HOME_POS + #undef MIN_SOFTWARE_ENDSTOP_W + #undef MAX_SOFTWARE_ENDSTOP_W + #undef SAFE_BED_LEVELING_START_W #endif #ifdef X2_DRIVER_TYPE @@ -1046,9 +1098,12 @@ #endif /** - * Set a flag for any type of bed probe, including the paper-test + * Set flags for any form of bed probe */ -#if ANY(HAS_Z_SERVO_PROBE, FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE, TOUCH_MI_PROBE, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, SOLENOID_PROBE, SENSORLESS_PROBING, RACK_AND_PINION_PROBE, MAGLEV4) +#if ANY(TOUCH_MI_PROBE, Z_PROBE_ALLEN_KEY, SOLENOID_PROBE, Z_PROBE_SLED, RACK_AND_PINION_PROBE, SENSORLESS_PROBING, MAGLEV4, MAG_MOUNTED_PROBE) + #define HAS_STOWABLE_PROBE 1 +#endif +#if ANY(HAS_STOWABLE_PROBE, HAS_Z_SERVO_PROBE, FIX_MOUNTED_PROBE, BD_SENSOR, NOZZLE_AS_PROBE) #define HAS_BED_PROBE 1 #endif @@ -1206,13 +1261,13 @@ #if NONE(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN, HAS_DELTA_SENSORLESS_PROBING) #define USES_Z_MIN_PROBE_PIN 1 #endif - #if Z_HOME_TO_MIN && TERN1(USES_Z_MIN_PROBE_PIN, ENABLED(USE_PROBE_FOR_Z_HOMING)) + #if Z_HOME_TO_MIN && (DISABLED(USES_Z_MIN_PROBE_PIN) || ENABLED(USE_PROBE_FOR_Z_HOMING)) #define HOMING_Z_WITH_PROBE 1 #endif #ifndef Z_PROBE_LOW_POINT #define Z_PROBE_LOW_POINT -5 #endif - #if ENABLED(Z_PROBE_ALLEN_KEY) + #if EITHER(Z_PROBE_ALLEN_KEY, MAG_MOUNTED_PROBE) #define PROBE_TRIGGERED_WHEN_STOWED_TEST 1 // Extra test for Allen Key Probe #endif #if MULTIPLE_PROBING > 1 @@ -1392,6 +1447,10 @@ #define EXTRUDE_MINTEMP 170 #endif +#if ANY(PID_DEBUG, PID_BED_DEBUG, PID_CHAMBER_DEBUG) + #define HAS_PID_DEBUG 1 +#endif + /** * TFT Displays * @@ -1427,7 +1486,7 @@ #define TFT_DEFAULT_ORIENTATION 0 #define TFT_RES_480x272 #define TFT_INTERFACE_FSMC -#elif ANY(MKS_ROBIN_TFT_V1_1R, LONGER_LK_TFT28) // ILI9328 or R61505 +#elif EITHER(MKS_ROBIN_TFT_V1_1R, LONGER_LK_TFT28) // ILI9328 or R61505 #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_X | TFT_INVERT_Y) #define TFT_RES_320x240 #define TFT_INTERFACE_FSMC @@ -1463,8 +1522,13 @@ #elif ENABLED(TFT_RES_1024x600) #define TFT_WIDTH 1024 #define TFT_HEIGHT 600 - #define GRAPHICAL_TFT_UPSCALE 6 - #define TFT_PIXEL_OFFSET_X 120 + #if ENABLED(TOUCH_SCREEN) + #define GRAPHICAL_TFT_UPSCALE 6 + #define TFT_PIXEL_OFFSET_X 120 + #else + #define GRAPHICAL_TFT_UPSCALE 8 + #define TFT_PIXEL_OFFSET_X 0 + #endif #endif // FSMC/SPI TFT Panels using standard HAL/tft/tft_(fsmc|spi|ltdc).h diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 2a204c6cf3..21bc424f59 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -79,6 +79,10 @@ #define SERVO_DELAY { 50 } #endif +#if !HAS_STOWABLE_PROBE + #undef PROBE_DEPLOY_STOW_MENU +#endif + #if !HAS_EXTRUDERS #define NO_VOLUMETRICS #undef TEMP_SENSOR_0 @@ -112,6 +116,31 @@ #undef STEALTHCHOP_E #endif +#if HOTENDS <= 7 + #undef E7_AUTO_FAN_PIN + #if HOTENDS <= 6 + #undef E6_AUTO_FAN_PIN + #if HOTENDS <= 5 + #undef E5_AUTO_FAN_PIN + #if HOTENDS <= 4 + #undef E4_AUTO_FAN_PIN + #if HOTENDS <= 3 + #undef E3_AUTO_FAN_PIN + #if HOTENDS <= 2 + #undef E2_AUTO_FAN_PIN + #if HOTENDS <= 1 + #undef E1_AUTO_FAN_PIN + #if HOTENDS == 0 + #undef E0_AUTO_FAN_PIN + #endif + #endif + #endif + #endif + #endif + #endif + #endif +#endif + /** * Temperature Sensors; define what sensor(s) we have. */ @@ -150,8 +179,7 @@ #define REDUNDANT_TEMP_MATCH(...) 0 #endif -#if TEMP_SENSOR_0 == -5 || TEMP_SENSOR_0 == -3 || TEMP_SENSOR_0 == -2 - #define TEMP_SENSOR_0_IS_MAX_TC 1 +#if TEMP_SENSOR_IS_MAX_TC(0) #if TEMP_SENSOR_0 == -5 #define TEMP_SENSOR_0_IS_MAX31865 1 #define TEMP_SENSOR_0_MAX_TC_TMIN 0 @@ -187,8 +215,7 @@ #undef HEATER_0_MAXTEMP #endif -#if TEMP_SENSOR_1 == -5 || TEMP_SENSOR_1 == -3 || TEMP_SENSOR_1 == -2 - #define TEMP_SENSOR_1_IS_MAX_TC 1 +#if TEMP_SENSOR_IS_MAX_TC(1) #if TEMP_SENSOR_1 == -5 #define TEMP_SENSOR_1_IS_MAX31865 1 #define TEMP_SENSOR_1_MAX_TC_TMIN 0 @@ -234,9 +261,7 @@ #undef HEATER_1_MAXTEMP #endif -#if TEMP_SENSOR_REDUNDANT == -5 || TEMP_SENSOR_REDUNDANT == -3 || TEMP_SENSOR_REDUNDANT == -2 - #define TEMP_SENSOR_REDUNDANT_IS_MAX_TC 1 - +#if TEMP_SENSOR_IS_MAX_TC(REDUNDANT) #if TEMP_SENSOR_REDUNDANT == -5 #if !REDUNDANT_TEMP_MATCH(SOURCE, E0) && !REDUNDANT_TEMP_MATCH(SOURCE, E1) #error "MAX31865 Thermocouples (-5) not supported for TEMP_SENSOR_REDUNDANT_SOURCE other than TEMP_SENSOR_0/TEMP_SENSOR_1 (0/1)." @@ -278,7 +303,7 @@ #endif #endif - #if (TEMP_SENSOR_0_IS_MAX_TC && TEMP_SENSOR_REDUNDANT != TEMP_SENSOR_0) || (TEMP_SENSOR_1_IS_MAX_TC && TEMP_SENSOR_REDUNDANT != TEMP_SENSOR_1) + #if (TEMP_SENSOR_IS_MAX_TC(0) && TEMP_SENSOR_REDUNDANT != TEMP_SENSOR_0) || (TEMP_SENSOR_IS_MAX_TC(1) && TEMP_SENSOR_REDUNDANT != TEMP_SENSOR_1) #if TEMP_SENSOR_REDUNDANT == -5 #error "If MAX31865 Thermocouple (-5) is used for TEMP_SENSOR_0/TEMP_SENSOR_1 then TEMP_SENSOR_REDUNDANT must match." #elif TEMP_SENSOR_REDUNDANT == -3 @@ -300,7 +325,7 @@ #endif #endif -#if TEMP_SENSOR_0_IS_MAX_TC || TEMP_SENSOR_1_IS_MAX_TC || TEMP_SENSOR_REDUNDANT_IS_MAX_TC +#if TEMP_SENSOR_IS_MAX_TC(0) || TEMP_SENSOR_IS_MAX_TC(1) || TEMP_SENSOR_IS_MAX_TC(REDUNDANT) #define HAS_MAX_TC 1 #endif #if TEMP_SENSOR_0_IS_MAX6675 || TEMP_SENSOR_1_IS_MAX6675 || TEMP_SENSOR_REDUNDANT_IS_MAX6675 @@ -556,16 +581,6 @@ #endif #endif -// Probe Temperature Compensation -#if !TEMP_SENSOR_PROBE - #undef PTC_PROBE -#endif -#if !TEMP_SENSOR_BED - #undef PTC_BED -#endif -#if !HAS_EXTRUDERS - #undef PTC_HOTEND -#endif #if ANY(PTC_PROBE, PTC_BED, PTC_HOTEND) #define HAS_PTC 1 #endif @@ -587,6 +602,10 @@ #define HAS_PRINT_PROGRESS 1 #endif +#if ANY(HAS_MARLINUI_MENU, ULTIPANEL_FEEDMULTIPLY, SOFT_RESET_ON_KILL) + #define HAS_ENCODER_ACTION 1 +#endif + #if STATUS_MESSAGE_TIMEOUT_SEC > 0 #define HAS_STATUS_MESSAGE_TIMEOUT 1 #endif diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index d8bac0468c..e3cb7927e3 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -48,7 +48,7 @@ // Set additional flags to let HALs choose in their Conditionals_post.h #if ANY(FLASH_EEPROM_EMULATION, SRAM_EEPROM_EMULATION, SDCARD_EEPROM_EMULATION, QSPI_EEPROM) #define USE_EMULATED_EEPROM 1 - #elif ANY(I2C_EEPROM, SPI_EEPROM) + #elif EITHER(I2C_EEPROM, SPI_EEPROM) #define USE_WIRED_EEPROM 1 #elif ENABLED(IIC_BL24CXX_EEPROM) // nothing @@ -471,6 +471,8 @@ #elif ENABLED(ZONESTAR_12864OLED) #define _LCD_CONTRAST_MIN 64 #define _LCD_CONTRAST_INIT 128 +#elif ENABLED(EMOTION_TECH_LCD) + #define _LCD_CONTRAST_INIT 140 #elif IS_TFTGLCD_PANEL #define _LCD_CONTRAST_INIT 250 #endif @@ -679,7 +681,7 @@ #if HAS_MAX_TC // Translate old _SS, _CS, _SCK, _DO, _DI, _MISO, and _MOSI PIN defines. - #if TEMP_SENSOR_0_IS_MAX_TC || (TEMP_SENSOR_REDUNDANT_IS_MAX_TC && REDUNDANT_TEMP_MATCH(SOURCE, E1)) + #if TEMP_SENSOR_IS_MAX_TC(0) || (TEMP_SENSOR_IS_MAX_TC(REDUNDANT) && REDUNDANT_TEMP_MATCH(SOURCE, E1)) #if !PIN_EXISTS(TEMP_0_CS) // SS, CS #if PIN_EXISTS(MAX6675_SS) @@ -746,9 +748,9 @@ #endif #endif - #endif // TEMP_SENSOR_0_IS_MAX_TC + #endif // TEMP_SENSOR_IS_MAX_TC(0) - #if TEMP_SENSOR_1_IS_MAX_TC || (TEMP_SENSOR_REDUNDANT_IS_MAX_TC && REDUNDANT_TEMP_MATCH(SOURCE, E1)) + #if TEMP_SENSOR_IS_MAX_TC(1) || (TEMP_SENSOR_IS_MAX_TC(REDUNDANT) && REDUNDANT_TEMP_MATCH(SOURCE, E1)) #if !PIN_EXISTS(TEMP_1_CS) // SS2, CS2 #if PIN_EXISTS(MAX6675_SS2) @@ -815,7 +817,7 @@ #endif #endif - #endif // TEMP_SENSOR_1_IS_MAX_TC + #endif // TEMP_SENSOR_IS_MAX_TC(1) // // User-defined thermocouple libraries @@ -1610,7 +1612,7 @@ #define HAS_X_MS_PINS 1 #endif -#if PIN_EXISTS(X2_ENABLE) || AXIS_IS_L64XX(X2) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(X2)) +#if PIN_EXISTS(X2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(X2)) #define HAS_X2_ENABLE 1 #endif #if PIN_EXISTS(X2_DIR) @@ -1631,7 +1633,7 @@ #endif #if HAS_Y_AXIS - #if PIN_EXISTS(Y_ENABLE) || AXIS_IS_L64XX(Y) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Y)) + #if PIN_EXISTS(Y_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Y)) #define HAS_Y_ENABLE 1 #endif #if PIN_EXISTS(Y_DIR) @@ -1644,7 +1646,7 @@ #define HAS_Y_MS_PINS 1 #endif - #if PIN_EXISTS(Y2_ENABLE) || AXIS_IS_L64XX(Y2) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Y2)) + #if PIN_EXISTS(Y2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Y2)) #define HAS_Y2_ENABLE 1 #endif #if PIN_EXISTS(Y2_DIR) @@ -1664,7 +1666,7 @@ #endif #if HAS_Z_AXIS - #if PIN_EXISTS(Z_ENABLE) || AXIS_IS_L64XX(Z) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z)) + #if PIN_EXISTS(Z_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z)) #define HAS_Z_ENABLE 1 #endif #if PIN_EXISTS(Z_DIR) @@ -1684,7 +1686,7 @@ #endif #if NUM_Z_STEPPERS >= 2 - #if PIN_EXISTS(Z2_ENABLE) || AXIS_IS_L64XX(Z2) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z2)) + #if PIN_EXISTS(Z2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z2)) #define HAS_Z2_ENABLE 1 #endif #if PIN_EXISTS(Z2_DIR) @@ -1699,7 +1701,7 @@ #endif #if NUM_Z_STEPPERS >= 3 - #if PIN_EXISTS(Z3_ENABLE) || AXIS_IS_L64XX(Z3) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z3)) + #if PIN_EXISTS(Z3_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z3)) #define HAS_Z3_ENABLE 1 #endif #if PIN_EXISTS(Z3_DIR) @@ -1714,7 +1716,7 @@ #endif #if NUM_Z_STEPPERS >= 4 - #if PIN_EXISTS(Z4_ENABLE) || AXIS_IS_L64XX(Z4) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z4)) + #if PIN_EXISTS(Z4_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z4)) #define HAS_Z4_ENABLE 1 #endif #if PIN_EXISTS(Z4_DIR) @@ -1729,7 +1731,7 @@ #endif #if HAS_I_AXIS - #if PIN_EXISTS(I_ENABLE) || AXIS_IS_L64XX(I) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(I)) + #if PIN_EXISTS(I_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(I)) #define HAS_I_ENABLE 1 #endif #if PIN_EXISTS(I_DIR) @@ -1749,7 +1751,7 @@ #endif #if HAS_J_AXIS - #if PIN_EXISTS(J_ENABLE) || AXIS_IS_L64XX(J) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(J)) + #if PIN_EXISTS(J_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(J)) #define HAS_J_ENABLE 1 #endif #if PIN_EXISTS(J_DIR) @@ -1769,7 +1771,7 @@ #endif #if HAS_K_AXIS - #if PIN_EXISTS(K_ENABLE) || AXIS_IS_L64XX(K) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(K)) + #if PIN_EXISTS(K_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(K)) #define HAS_K_ENABLE 1 #endif #if PIN_EXISTS(K_DIR) @@ -1789,7 +1791,7 @@ #endif #if HAS_U_AXIS - #if PIN_EXISTS(U_ENABLE) || AXIS_IS_L64XX(U) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(U)) + #if PIN_EXISTS(U_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(U)) #define HAS_U_ENABLE 1 #endif #if PIN_EXISTS(U_DIR) @@ -1809,7 +1811,7 @@ #endif #if HAS_V_AXIS - #if PIN_EXISTS(V_ENABLE) || AXIS_IS_L64XX(V) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(V)) + #if PIN_EXISTS(V_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(V)) #define HAS_V_ENABLE 1 #endif #if PIN_EXISTS(V_DIR) @@ -1829,7 +1831,7 @@ #endif #if HAS_W_AXIS - #if PIN_EXISTS(W_ENABLE) || AXIS_IS_L64XX(W) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(W)) + #if PIN_EXISTS(W_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(W)) #define HAS_W_ENABLE 1 #endif #if PIN_EXISTS(W_DIR) @@ -1851,7 +1853,7 @@ // Extruder steppers and solenoids #if HAS_EXTRUDERS - #if PIN_EXISTS(E0_ENABLE) || AXIS_IS_L64XX(E0) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E0)) + #if PIN_EXISTS(E0_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E0)) #define HAS_E0_ENABLE 1 #endif #if PIN_EXISTS(E0_DIR) @@ -1865,7 +1867,7 @@ #endif #if E_STEPPERS > 1 || ENABLED(E_DUAL_STEPPER_DRIVERS) - #if PIN_EXISTS(E1_ENABLE) || AXIS_IS_L64XX(E1) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E1)) + #if PIN_EXISTS(E1_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E1)) #define HAS_E1_ENABLE 1 #endif #if PIN_EXISTS(E1_DIR) @@ -1880,7 +1882,7 @@ #endif #if E_STEPPERS > 2 - #if PIN_EXISTS(E2_ENABLE) || AXIS_IS_L64XX(E2) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E2)) + #if PIN_EXISTS(E2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E2)) #define HAS_E2_ENABLE 1 #endif #if PIN_EXISTS(E2_DIR) @@ -1895,7 +1897,7 @@ #endif #if E_STEPPERS > 3 - #if PIN_EXISTS(E3_ENABLE) || AXIS_IS_L64XX(E3) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E3)) + #if PIN_EXISTS(E3_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E3)) #define HAS_E3_ENABLE 1 #endif #if PIN_EXISTS(E3_DIR) @@ -1910,7 +1912,7 @@ #endif #if E_STEPPERS > 4 - #if PIN_EXISTS(E4_ENABLE) || AXIS_IS_L64XX(E4) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E4)) + #if PIN_EXISTS(E4_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E4)) #define HAS_E4_ENABLE 1 #endif #if PIN_EXISTS(E4_DIR) @@ -1925,7 +1927,7 @@ #endif #if E_STEPPERS > 5 - #if PIN_EXISTS(E5_ENABLE) || AXIS_IS_L64XX(E5) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E5)) + #if PIN_EXISTS(E5_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E5)) #define HAS_E5_ENABLE 1 #endif #if PIN_EXISTS(E5_DIR) @@ -1940,7 +1942,7 @@ #endif #if E_STEPPERS > 6 - #if PIN_EXISTS(E6_ENABLE) || AXIS_IS_L64XX(E6) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E6)) + #if PIN_EXISTS(E6_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E6)) #define HAS_E6_ENABLE 1 #endif #if PIN_EXISTS(E6_DIR) @@ -1955,7 +1957,7 @@ #endif #if E_STEPPERS > 7 - #if PIN_EXISTS(E7_ENABLE) || AXIS_IS_L64XX(E7) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E7)) + #if PIN_EXISTS(E7_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E7)) #define HAS_E7_ENABLE 1 #endif #if PIN_EXISTS(E7_DIR) @@ -2654,7 +2656,7 @@ // // ADC Temp Sensors (Thermistor or Thermocouple with amplifier ADC interface) // -#define HAS_ADC_TEST(P) (PIN_EXISTS(TEMP_##P) && TEMP_SENSOR_##P != 0 && NONE(TEMP_SENSOR_##P##_IS_MAX_TC, TEMP_SENSOR_##P##_IS_DUMMY)) +#define HAS_ADC_TEST(P) (PIN_EXISTS(TEMP_##P) && TEMP_SENSOR_##P != 0 && !TEMP_SENSOR_IS_MAX_TC(P) && !TEMP_SENSOR_##P##_IS_DUMMY) #if HOTENDS > 0 && HAS_ADC_TEST(0) #define HAS_TEMP_ADC_0 1 #endif @@ -2698,7 +2700,7 @@ #define HAS_TEMP_ADC_REDUNDANT 1 #endif -#define HAS_TEMP(N) ANY(HAS_TEMP_ADC_##N, TEMP_SENSOR_##N##_IS_MAX_TC, TEMP_SENSOR_##N##_IS_DUMMY) +#define HAS_TEMP(N) (TEMP_SENSOR_IS_MAX_TC(N) || EITHER(HAS_TEMP_ADC_##N, TEMP_SENSOR_##N##_IS_DUMMY)) #if HAS_HOTEND && HAS_TEMP(0) #define HAS_TEMP_HOTEND 1 #endif @@ -3562,8 +3564,11 @@ #if PIN_EXISTS(BEEPER) #define HAS_BEEPER 1 #endif -#if ANY(HAS_BEEPER, LCD_USE_I2C_BUZZER, PCA9632_BUZZER) - #define HAS_BUZZER 1 +#if ANY(IS_TFTGLCD_PANEL, PCA9632_BUZZER, LCD_USE_I2C_BUZZER, ADVi3PP_UI) // @advi3++ + #define USE_MARLINUI_BUZZER 1 +#endif +#if EITHER(HAS_BEEPER, USE_MARLINUI_BUZZER) + #define HAS_SOUND 1 #endif #if ENABLED(LCD_USE_I2C_BUZZER) @@ -3573,7 +3578,7 @@ #ifndef LCD_FEEDBACK_FREQUENCY_DURATION_MS #define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 #endif -#elif HAS_BUZZER +#elif HAS_SOUND #ifndef LCD_FEEDBACK_FREQUENCY_HZ #define LCD_FEEDBACK_FREQUENCY_HZ 5000 #endif @@ -3582,12 +3587,13 @@ #endif #endif -#if HAS_BUZZER +#if HAS_SOUND #if LCD_FEEDBACK_FREQUENCY_DURATION_MS && LCD_FEEDBACK_FREQUENCY_HZ #define HAS_CHIRP 1 #endif #else #undef SOUND_MENU_ITEM // No buzzer menu item without a buzzer + #undef SOUND_ON_DEFAULT #endif /** diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index aa0f237da4..306f8d6c2d 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -350,7 +350,7 @@ #elif defined(HAVE_TMC2208) #error "HAVE_TMC2208 is now [AXIS]_DRIVER_TYPE TMC2208." #elif defined(HAVE_L6470DRIVER) - #error "HAVE_L6470DRIVER is now [AXIS]_DRIVER_TYPE L6470." + #error "HAVE_L6470DRIVER is obsolete. L64xx stepper drivers are no longer supported in Marlin." #elif defined(X_IS_TMC) || defined(X2_IS_TMC) || defined(Y_IS_TMC) || defined(Y2_IS_TMC) || defined(Z_IS_TMC) || defined(Z2_IS_TMC) || defined(Z3_IS_TMC) \ || defined(E0_IS_TMC) || defined(E1_IS_TMC) || defined(E2_IS_TMC) || defined(E3_IS_TMC) || defined(E4_IS_TMC) || defined(E5_IS_TMC) || defined(E6_IS_TMC) || defined(E7_IS_TMC) #error "[AXIS]_IS_TMC is now [AXIS]_DRIVER_TYPE TMC26X." @@ -363,9 +363,6 @@ #elif defined(X_IS_TMC2208) || defined(X2_IS_TMC2208) || defined(Y_IS_TMC2208) || defined(Y2_IS_TMC2208) || defined(Z_IS_TMC2208) || defined(Z2_IS_TMC2208) || defined(Z3_IS_TMC2208) \ || defined(E0_IS_TMC2208) || defined(E1_IS_TMC2208) || defined(E2_IS_TMC2208) || defined(E3_IS_TMC2208) || defined(E4_IS_TMC2208) || defined(E5_IS_TMC2208) || defined(E6_IS_TMC2208) || defined(E7_IS_TMC2208) #error "[AXIS]_IS_TMC2208 is now [AXIS]_DRIVER_TYPE TMC2208." -#elif defined(X_IS_L6470) || defined(X2_IS_L6470) || defined(Y_IS_L6470) || defined(Y2_IS_L6470) || defined(Z_IS_L6470) || defined(Z2_IS_L6470) || defined(Z3_IS_L6470) \ - || defined(E0_IS_L6470) || defined(E1_IS_L6470) || defined(E2_IS_L6470) || defined(E3_IS_L6470) || defined(E4_IS_L6470) || defined(E5_IS_L6470) || defined(E6_IS_L6470) || defined(E7_IS_L6470) - #error "[AXIS]_IS_L6470 is now [AXIS]_DRIVER_TYPE L6470." #elif defined(AUTOMATIC_CURRENT_CONTROL) #error "AUTOMATIC_CURRENT_CONTROL is now MONITOR_DRIVER_STATUS." #elif defined(FILAMENT_CHANGE_LOAD_LENGTH) @@ -447,6 +444,16 @@ #error "SPINDLE_LASER_ACTIVE_HIGH is now SPINDLE_LASER_ACTIVE_STATE." #elif defined(SPINDLE_LASER_ENABLE_INVERT) #error "SPINDLE_LASER_ENABLE_INVERT is now SPINDLE_LASER_ACTIVE_STATE." +#elif defined(LASER_POWER_INLINE) + #error "LASER_POWER_INLINE is not required, inline mode is enabled with 'M3 I' and disabled with 'M5 I'." +#elif defined(LASER_POWER_INLINE_TRAPEZOID) + #error "LASER_POWER_INLINE_TRAPEZOID is now LASER_POWER_TRAP." +#elif defined(LASER_POWER_INLINE_TRAPEZOID_CONT) + #error "LASER_POWER_INLINE_TRAPEZOID_CONT is replaced with LASER_POWER_TRAP." +#elif defined(LASER_POWER_INLINE_TRAPEZOID_PER) + #error "LASER_POWER_INLINE_TRAPEZOID_CONT_PER replaced with LASER_POWER_TRAP." +#elif defined(LASER_POWER_INLINE_CONTINUOUS) + #error "LASER_POWER_INLINE_CONTINUOUS is not required, inline mode is enabled with 'M3 I' and disabled with 'M5 I'." #elif defined(CUTTER_POWER_DISPLAY) #error "CUTTER_POWER_DISPLAY is now CUTTER_POWER_UNIT." #elif defined(CHAMBER_HEATER_PIN) @@ -595,6 +602,8 @@ #error "ARC_SUPPORT no longer uses ARC_SEGMENTS_PER_R." #elif ENABLED(ARC_SUPPORT) && (!defined(MIN_ARC_SEGMENT_MM) || !defined(MAX_ARC_SEGMENT_MM)) #error "ARC_SUPPORT now requires MIN_ARC_SEGMENT_MM and MAX_ARC_SEGMENT_MM." +#elif defined(LASER_POWER_INLINE) + #error "LASER_POWER_INLINE is obsolete." #elif defined(SPINDLE_LASER_PWM) #error "SPINDLE_LASER_PWM (true) is now set with SPINDLE_LASER_USE_PWM (enabled)." #elif ANY(IS_RAMPS_EEB, IS_RAMPS_EEF, IS_RAMPS_EFB, IS_RAMPS_EFF, IS_RAMPS_SF) @@ -635,6 +644,26 @@ #error "LEVEL_CENTER_TOO is now BED_TRAMMING_INCLUDE_CENTER." #endif +// L64xx stepper drivers have been removed +#define _L6470 0x6470 +#define _L6474 0x6474 +#define _L6480 0x6480 +#define _POWERSTEP01 0xF00D +#if HAS_DRIVER(L6470) + #error "L6470 stepper drivers are no longer supported in Marlin." +#elif HAS_DRIVER(L6474) + #error "L6474 stepper drivers are no longer supported in Marlin." +#elif HAS_DRIVER(L6480) + #error "L6480 stepper drivers are no longer supported in Marlin." +#elif HAS_DRIVER(POWERSTEP01) + #error "POWERSTEP01 stepper drivers are no longer supported in Marlin." +#endif +#undef _L6470 +#undef _L6474 +#undef _L6480 +#undef _POWERSTEP01 + +// Check AXIS_RELATIVE_MODES constexpr float arm[] = AXIS_RELATIVE_MODES; static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _LOGICAL_AXES_STR "elements."); @@ -654,34 +683,46 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L #endif #endif - #ifdef PTC_PROBE_START - constexpr auto _ptc_sample_start = PTC_PROBE_START; - constexpr decltype(_ptc_sample_start) _test_ptc_sample_start = 12.3f; - static_assert(_test_ptc_sample_start != 12.3f, "PTC_PROBE_START must be a whole number."); - #endif - #ifdef PTC_PROBE_RES - constexpr auto _ptc_sample_res = PTC_PROBE_RES; - constexpr decltype(_ptc_sample_res) _test_ptc_sample_res = 12.3f; - static_assert(_test_ptc_sample_res != 12.3f, "PTC_PROBE_RES must be a whole number."); - #endif - #ifdef PTC_BED_START - constexpr auto _btc_sample_start = PTC_BED_START; - constexpr decltype(_btc_sample_start) _test_btc_sample_start = 12.3f; - static_assert(_test_btc_sample_start != 12.3f, "PTC_BED_START must be a whole number."); - #endif - #ifdef PTC_BED_RES - constexpr auto _btc_sample_res = PTC_BED_RES; - constexpr decltype(_btc_sample_res) _test_btc_sample_res = 12.3f; - static_assert(_test_btc_sample_res != 12.3f, "PTC_BED_RES must be a whole number."); + #if ENABLED(PTC_PROBE) + #if !TEMP_SENSOR_PROBE + #error "PTC_PROBE requires a probe with a thermistor." + #endif + #ifdef PTC_PROBE_START + constexpr auto _ptc_sample_start = PTC_PROBE_START; + constexpr decltype(_ptc_sample_start) _test_ptc_sample_start = 12.3f; + static_assert(_test_ptc_sample_start != 12.3f, "PTC_PROBE_START must be a whole number."); + #endif + #ifdef PTC_PROBE_RES + constexpr auto _ptc_sample_res = PTC_PROBE_RES; + constexpr decltype(_ptc_sample_res) _test_ptc_sample_res = 12.3f; + static_assert(_test_ptc_sample_res != 12.3f, "PTC_PROBE_RES must be a whole number."); + #endif + #if ENABLED(PTC_BED) && defined(PTC_PROBE_TEMP) + constexpr auto _btc_probe_temp = PTC_PROBE_TEMP; + constexpr decltype(_btc_probe_temp) _test_btc_probe_temp = 12.3f; + static_assert(_test_btc_probe_temp != 12.3f, "PTC_PROBE_TEMP must be a whole number."); + #endif #endif - #ifdef PTC_PROBE_TEMP - constexpr auto _btc_probe_temp = PTC_PROBE_TEMP; - constexpr decltype(_btc_probe_temp) _test_btc_probe_temp = 12.3f; - static_assert(_test_btc_probe_temp != 12.3f, "PTC_PROBE_TEMP must be a whole number."); + + #if ENABLED(PTC_BED) + #if !TEMP_SENSOR_BED + #error "PTC_BED requires a bed with a thermistor." + #endif + #ifdef PTC_BED_START + constexpr auto _btc_sample_start = PTC_BED_START; + constexpr decltype(_btc_sample_start) _test_btc_sample_start = 12.3f; + static_assert(_test_btc_sample_start != 12.3f, "PTC_BED_START must be a whole number."); + #endif + #ifdef PTC_BED_RES + constexpr auto _btc_sample_res = PTC_BED_RES; + constexpr decltype(_btc_sample_res) _test_btc_sample_res = 12.3f; + static_assert(_test_btc_sample_res != 12.3f, "PTC_BED_RES must be a whole number."); + #endif #endif + #if ENABLED(PTC_HOTEND) #if EXTRUDERS != 1 - #error "PTC_HOTEND only works with a single extruder." + #error "PTC_HOTEND requires a single extruder." #endif #ifdef PTC_HOTEND_START constexpr auto _etc_sample_start = PTC_HOTEND_START; @@ -872,6 +913,10 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "SD_REPRINT_LAST_SELECTED_FILE currently requires a Marlin-native LCD menu." #endif +#if ANY(HAS_MARLINUI_MENU, TOUCH_UI_FTDI_EVE, EXTENSIBLE_UI) && !defined(MANUAL_FEEDRATE) + #error "MANUAL_FEEDRATE is required for MarlinUI, ExtUI, or FTDI EVE Touch UI." +#endif + /** * Custom Boot and Status screens */ @@ -1629,8 +1674,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS */ #if 1 < 0 \ + (DISABLED(BLTOUCH) && HAS_Z_SERVO_PROBE) \ - + COUNT_ENABLED(PROBE_MANUALLY, BLTOUCH, FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE, TOUCH_MI_PROBE, SOLENOID_PROBE, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, RACK_AND_PINION_PROBE, SENSORLESS_PROBING, MAGLEV4) - #error "Please enable only one probe option: PROBE_MANUALLY, SENSORLESS_PROBING, BLTOUCH, FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE, TOUCH_MI_PROBE, SOLENOID_PROBE, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, MAGLEV4, or Z Servo." + + COUNT_ENABLED(PROBE_MANUALLY, BLTOUCH, BD_SENSOR, FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE, TOUCH_MI_PROBE, SOLENOID_PROBE, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, RACK_AND_PINION_PROBE, SENSORLESS_PROBING, MAGLEV4, MAG_MOUNTED_PROBE) + #error "Please enable only one probe option: PROBE_MANUALLY, SENSORLESS_PROBING, BLTOUCH, BD_SENSOR, FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE, TOUCH_MI_PROBE, SOLENOID_PROBE, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, MAGLEV4, MAG_MOUNTED_PROBE or Z Servo." #endif #if HAS_BED_PROBE @@ -1736,13 +1781,20 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif #endif + /** + * Mag mounted probe requirements + */ + #if BOTH(MAG_MOUNTED_PROBE, USE_PROBE_FOR_Z_HOMING) && DISABLED(Z_SAFE_HOMING) + #error "MAG_MOUNTED_PROBE requires Z_SAFE_HOMING if it's being used to home Z." + #endif + /** * MagLev V4 probe requirements */ #if ENABLED(MAGLEV4) #if !PIN_EXISTS(MAGLEV_TRIGGER) #error "MAGLEV4 requires MAGLEV_TRIGGER_PIN to be defined." - #elif DISABLED(Z_SAFE_HOMING) + #elif ENABLED(HOMING_Z_WITH_PROBE) && DISABLED(Z_SAFE_HOMING) #error "MAGLEV4 requires Z_SAFE_HOMING." #elif MAGLEV_TRIGGER_DELAY != 15 #error "MAGLEV_TRIGGER_DELAY should not be changed. Comment out this line to continue." @@ -2132,13 +2184,13 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS */ #if HAS_AUTO_FAN #if HAS_FAN0 - #if E0_AUTO_FAN_PIN == FAN_PIN + #if PIN_EXISTS(E0_AUTO_FAN) && E0_AUTO_FAN_PIN == FAN_PIN #error "You cannot set E0_AUTO_FAN_PIN equal to FAN_PIN." - #elif E1_AUTO_FAN_PIN == FAN_PIN + #elif PIN_EXISTS(E1_AUTO_FAN) && E1_AUTO_FAN_PIN == FAN_PIN #error "You cannot set E1_AUTO_FAN_PIN equal to FAN_PIN." - #elif E2_AUTO_FAN_PIN == FAN_PIN + #elif PIN_EXISTS(E2_AUTO_FAN) && E2_AUTO_FAN_PIN == FAN_PIN #error "You cannot set E2_AUTO_FAN_PIN equal to FAN_PIN." - #elif E3_AUTO_FAN_PIN == FAN_PIN + #elif PIN_EXISTS(E3_AUTO_FAN) && E3_AUTO_FAN_PIN == FAN_PIN #error "You cannot set E3_AUTO_FAN_PIN equal to FAN_PIN." #endif #endif @@ -2290,9 +2342,9 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "TEMP_SENSOR_REDUNDANT_TARGET can't be COOLER without TEMP_COOLER_PIN defined." #endif - #if TEMP_SENSOR_REDUNDANT_IS_MAX_TC && REDUNDANT_TEMP_MATCH(SOURCE, E0) && !PIN_EXISTS(TEMP_0_CS) + #if TEMP_SENSOR_IS_MAX_TC(REDUNDANT) && REDUNDANT_TEMP_MATCH(SOURCE, E0) && !PIN_EXISTS(TEMP_0_CS) #error "TEMP_SENSOR_REDUNDANT MAX Thermocouple with TEMP_SENSOR_REDUNDANT_SOURCE E0 requires TEMP_0_CS_PIN." - #elif TEMP_SENSOR_REDUNDANT_IS_MAX_TC && REDUNDANT_TEMP_MATCH(SOURCE, E1) && !PIN_EXISTS(TEMP_1_CS) + #elif TEMP_SENSOR_IS_MAX_TC(REDUNDANT) && REDUNDANT_TEMP_MATCH(SOURCE, E1) && !PIN_EXISTS(TEMP_1_CS) #error "TEMP_SENSOR_REDUNDANT MAX Thermocouple with TEMP_SENSOR_REDUNDANT_SOURCE E1 requires TEMP_1_CS_PIN." #endif #endif @@ -2305,7 +2357,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "TEMP_0_PIN or TEMP_0_CS_PIN not defined for this board." #elif HAS_EXTRUDERS && !HAS_HEATER_0 #error "HEATER_0_PIN not defined for this board." -#elif TEMP_SENSOR_0_IS_MAX_TC && !PIN_EXISTS(TEMP_0_CS) +#elif TEMP_SENSOR_IS_MAX_TC(0) && !PIN_EXISTS(TEMP_0_CS) #error "TEMP_SENSOR_0 MAX thermocouple requires TEMP_0_CS_PIN." #elif HAS_HOTEND && !HAS_TEMP_HOTEND && !TEMP_SENSOR_0_IS_DUMMY #error "TEMP_0_PIN (required for TEMP_SENSOR_0) not defined for this board." @@ -2314,7 +2366,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif #if HAS_MULTI_HOTEND - #if TEMP_SENSOR_1_IS_MAX_TC && !PIN_EXISTS(TEMP_1_CS) + #if TEMP_SENSOR_IS_MAX_TC(1) && !PIN_EXISTS(TEMP_1_CS) #error "TEMP_SENSOR_1 MAX thermocouple requires TEMP_1_CS_PIN." #elif TEMP_SENSOR_1 == 0 #error "TEMP_SENSOR_1 is required with 2 or more HOTENDS." @@ -2937,8 +2989,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif #endif -#if defined(GRAPHICAL_TFT_UPSCALE) && !WITHIN(GRAPHICAL_TFT_UPSCALE, 2, 6) - #error "GRAPHICAL_TFT_UPSCALE must be between 2 and 6." +#if defined(GRAPHICAL_TFT_UPSCALE) && !WITHIN(GRAPHICAL_TFT_UPSCALE, 2, 8) + #error "GRAPHICAL_TFT_UPSCALE must be between 2 and 8." #endif #if BOTH(CHIRON_TFT_STANDARD, CHIRON_TFT_NEW) @@ -3516,7 +3568,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS /** * TMC SPI Chaining */ -#define IN_CHAIN(A) ((A##_CHAIN_POS > 0) && !HAS_L64XX) +#define IN_CHAIN(A) A##_CHAIN_POS > 0 #if IN_CHAIN(X ) || IN_CHAIN(Y ) || IN_CHAIN(Z ) || IN_CHAIN(X2) || IN_CHAIN(Y2) || IN_CHAIN(Z2) || IN_CHAIN(Z3) || IN_CHAIN(Z4) \ || IN_CHAIN(E0) || IN_CHAIN(E1) || IN_CHAIN(E2) || IN_CHAIN(E3) || IN_CHAIN(E4) || IN_CHAIN(E5) || IN_CHAIN(E6) || IN_CHAIN(E7) #define BAD_CHAIN(A) (IN_CHAIN(A) && !PIN_EXISTS(A##_CS)) @@ -3581,13 +3633,6 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif #undef IN_CHAIN -/** - * L64XX requirement - */ -#if HAS_L64XX && NUM_AXES > 3 - #error "L64XX requires NUM_AXES <= 3. Homing with L64XX is not yet implemented for NUM_AXES > 3." -#endif - /** * Digipot requirement */ @@ -3855,45 +3900,34 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); #error "CUTTER_POWER_UNIT must be PWM255, PERCENT, RPM, or SERVO." #endif - #if ENABLED(LASER_POWER_INLINE) + #if ENABLED(LASER_FEATURE) #if ENABLED(SPINDLE_CHANGE_DIR) - #error "SPINDLE_CHANGE_DIR and LASER_POWER_INLINE are incompatible." - #elif ENABLED(LASER_MOVE_G0_OFF) && DISABLED(LASER_MOVE_POWER) - #error "LASER_MOVE_G0_OFF requires LASER_MOVE_POWER." + #error "SPINDLE_CHANGE_DIR and LASER_FEATURE are incompatible." + #elif ENABLED(LASER_MOVE_G0_OFF) + #error "LASER_MOVE_G0_OFF is no longer required, G0 and G28 cannot apply power." + #elif ENABLED(LASER_MOVE_G28_OFF) + #error "LASER_MOVE_G0_OFF is no longer required, G0 and G28 cannot apply power." + #elif ENABLED(LASER_MOVE_POWER) + #error "LASER_MOVE_POWER is no longer applicable." #endif - #if ENABLED(LASER_POWER_INLINE_TRAPEZOID) + #if ENABLED(LASER_POWER_TRAP) #if DISABLED(SPINDLE_LASER_USE_PWM) - #error "LASER_POWER_INLINE_TRAPEZOID requires SPINDLE_LASER_USE_PWM to function." - #elif ENABLED(S_CURVE_ACCELERATION) - //#ifndef LASER_POWER_INLINE_S_CURVE_ACCELERATION_WARN - // #define LASER_POWER_INLINE_S_CURVE_ACCELERATION_WARN - // #warning "Combining LASER_POWER_INLINE_TRAPEZOID with S_CURVE_ACCELERATION may result in unintended behavior." - //#endif + #error "LASER_POWER_TRAP requires SPINDLE_LASER_USE_PWM to function." #endif #endif - #if ENABLED(LASER_POWER_INLINE_INVERT) - //#ifndef LASER_POWER_INLINE_INVERT_WARN - // #define LASER_POWER_INLINE_INVERT_WARN - // #warning "Enabling LASER_POWER_INLINE_INVERT means that `M5` won't kill the laser immediately; use `M5 I` instead." - //#endif - #endif #else #if SPINDLE_LASER_POWERUP_DELAY < 1 #error "SPINDLE_LASER_POWERUP_DELAY must be greater than 0." #elif SPINDLE_LASER_POWERDOWN_DELAY < 1 #error "SPINDLE_LASER_POWERDOWN_DELAY must be greater than 0." - #elif ENABLED(LASER_MOVE_POWER) - #error "LASER_MOVE_POWER requires LASER_POWER_INLINE." - #elif ANY(LASER_POWER_INLINE_TRAPEZOID, LASER_POWER_INLINE_INVERT, LASER_MOVE_G0_OFF, LASER_MOVE_POWER) - #error "Enabled an inline laser feature without inline laser power being enabled." #endif #endif #define _PIN_CONFLICT(P) (PIN_EXISTS(P) && P##_PIN == SPINDLE_LASER_PWM_PIN) #if BOTH(SPINDLE_FEATURE, LASER_FEATURE) #error "Enable only one of SPINDLE_FEATURE or LASER_FEATURE." - #elif !PIN_EXISTS(SPINDLE_LASER_ENA) && DISABLED(SPINDLE_SERVO) - #error "(SPINDLE|LASER)_FEATURE requires SPINDLE_LASER_ENA_PIN or SPINDLE_SERVO to control the power." + #elif NONE(SPINDLE_SERVO, SPINDLE_LASER_USE_PWM) && !PIN_EXISTS(SPINDLE_LASER_ENA) + #error "(SPINDLE|LASER)_FEATURE requires SPINDLE_LASER_ENA_PIN, SPINDLE_LASER_USE_PWM, or SPINDLE_SERVO to control the power." #elif ENABLED(SPINDLE_CHANGE_DIR) && !PIN_EXISTS(SPINDLE_DIR) #error "SPINDLE_DIR_PIN is required for SPINDLE_CHANGE_DIR." #elif ENABLED(SPINDLE_LASER_USE_PWM) @@ -3903,7 +3937,7 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); #error "SPINDLE_LASER_PWM_PIN not assigned to a PWM pin." #elif !defined(SPINDLE_LASER_PWM_INVERT) #error "SPINDLE_LASER_PWM_INVERT is required for (SPINDLE|LASER)_FEATURE." - #elif !(defined(SPEED_POWER_INTERCEPT) && defined(SPEED_POWER_MIN) && defined(SPEED_POWER_MAX) && defined(SPEED_POWER_STARTUP)) + #elif !(defined(SPEED_POWER_MIN) && defined(SPEED_POWER_MAX) && defined(SPEED_POWER_STARTUP)) #error "SPINDLE_LASER_USE_PWM equation constant(s) missing." #elif _PIN_CONFLICT(X_MIN) #error "SPINDLE_LASER_USE_PWM pin conflicts with X_MIN_PIN." diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 4c59acc1ef..3f60677793 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * Release version. Leave the Marlin version or apply a custom scheme. */ #ifndef SHORT_BUILD_VERSION - #define SHORT_BUILD_VERSION "2.1" + #define SHORT_BUILD_VERSION "2.1.1" #endif /** @@ -50,7 +50,7 @@ * vendor name, download location, GitHub account, etc. */ #ifndef DETAILED_BUILD_VERSION - #define DETAILED_BUILD_VERSION SHORT_BUILD_VERSION " (" ADVi3PP_NAME " 5.1.0-dev)" + #define DETAILED_BUILD_VERSION SHORT_BUILD_VERSION " (" ADVi3PP_NAME " 5.5.0)" #endif /** @@ -59,7 +59,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2022-06-04" + #define STRING_DISTRIBUTION_DATE "2022-11-02" #endif /** @@ -69,7 +69,7 @@ * to alert users to major changes. */ -#define MARLIN_HEX_VERSION 02010000 +#define MARLIN_HEX_VERSION 02010100 #ifndef REQUIRED_CONFIGURATION_H_VERSION #define REQUIRED_CONFIGURATION_H_VERSION MARLIN_HEX_VERSION #endif diff --git a/Marlin/src/inc/Warnings.cpp b/Marlin/src/inc/Warnings.cpp index e48788b7b4..e665ac5bca 100644 --- a/Marlin/src/inc/Warnings.cpp +++ b/Marlin/src/inc/Warnings.cpp @@ -35,8 +35,8 @@ #warning "WARNING! Disable MARLIN_DEV_MODE for the final build!" #endif -#if LINEAR_AXES_WARNING - #warning "Note: LINEAR_AXES is now based on the *_DRIVER_TYPE settings so you can remove LINEAR_AXES from Configuration.h." +#if NUM_AXES_WARNING + #warning "Note: NUM_AXES is now based on the *_DRIVER_TYPE settings so you can remove NUM_AXES from Configuration.h." #endif // Safety Features @@ -773,3 +773,10 @@ #if MB(BTT_BTT002_V1_0, EINSY_RAMBO) && DISABLED(NO_MK3_FAN_PINS_WARNING) #warning "Define MK3_FAN_PINS to swap hotend and part cooling fan pins. (Define NO_MK3_FAN_PINS_WARNING to suppress this warning.)" #endif + +/** + * BD Sensor should always include BABYSTEPPING + */ +#if ENABLED(BD_SENSOR) && DISABLED(BABYSTEPPING) + #warning "BABYSTEPPING is recommended with BD_SENSOR." +#endif diff --git a/Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp b/Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp index 1e82fe403d..fe31c21e39 100644 --- a/Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp +++ b/Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp @@ -50,7 +50,7 @@ extern LCD_CLASS lcd; int lcd_glyph_height() { return 1; } typedef struct _hd44780_charmap_t { - wchar_t uchar; // the unicode char + lchar_t uchar; // the unicode char uint8_t idx; // the glyph of the char in the ROM uint8_t idx2; // the char used to be combined with the idx to simulate a single char } hd44780_charmap_t; @@ -992,7 +992,7 @@ void lcd_put_int(const int i) { lcd.print(i); } // return < 0 on error // return the advanced cols -int lcd_put_wchar_max(const wchar_t c, const pixel_len_t max_length) { +int lcd_put_lchar_max(const lchar_t &c, const pixel_len_t max_length) { // find the HD44780 internal ROM first int ret; @@ -1051,10 +1051,10 @@ static int lcd_put_u8str_max_cb(const char * utf8_str, read_byte_cb_t cb_read_by pixel_len_t ret = 0; const uint8_t *p = (uint8_t *)utf8_str; while (ret < max_length) { - wchar_t ch = 0; - p = get_utf8_value_cb(p, cb_read_byte, &ch); - if (!ch) break; - ret += lcd_put_wchar_max(ch, max_length - ret); + lchar_t wc; + p = get_utf8_value_cb(p, cb_read_byte, wc); + if (!wc) break; + ret += lcd_put_lchar_max(wc, max_length - ret); } return (int)ret; } diff --git a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp index da4db8b2d4..b8dc8db817 100644 --- a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp @@ -120,10 +120,11 @@ static void createChar_P(const char c, const byte * const ptr) { #endif #if ENABLED(LCD_USE_I2C_BUZZER) + void MarlinUI::buzz(const long duration, const uint16_t freq) { - if (!sound_on) return; - lcd.buzz(duration, freq); + if (sound_on) lcd.buzz(duration, freq); } + #endif void MarlinUI::set_custom_characters(const HD44780CharSet screen_charset/*=CHARSET_INFO*/) { @@ -405,7 +406,7 @@ void MarlinUI::clear_lcd() { lcd.clear(); } void lcd_erase_line(const lcd_uint_t line) { lcd_moveto(0, line); for (uint8_t i = LCD_WIDTH + 1; --i;) - lcd_put_wchar(' '); + lcd_put_lchar(' '); } // Scroll the PSTR 'text' in a 'len' wide field for 'time' milliseconds at position col,line @@ -413,7 +414,7 @@ void MarlinUI::clear_lcd() { lcd.clear(); } uint8_t slen = utf8_strlen(ftxt); if (slen < len) { lcd_put_u8str_max(col, line, ftxt, len); - for (; slen < len; ++slen) lcd_put_wchar(' '); + for (; slen < len; ++slen) lcd_put_lchar(' '); safe_delay(time); } else { @@ -425,7 +426,7 @@ void MarlinUI::clear_lcd() { lcd.clear(); } lcd_put_u8str_max_P(col, line, p, len); // Fill with spaces - for (uint8_t ix = slen - i; ix < len; ++ix) lcd_put_wchar(' '); + for (uint8_t ix = slen - i; ix < len; ++ix) lcd_put_lchar(' '); // Delay safe_delay(dly); @@ -439,9 +440,9 @@ void MarlinUI::clear_lcd() { lcd.clear(); } static void logo_lines(FSTR_P const extra) { int16_t indent = (LCD_WIDTH - 8 - utf8_strlen(extra)) / 2; - lcd_put_wchar(indent, 0, '\x00'); lcd_put_u8str(F( "------" )); lcd_put_wchar('\x01'); + lcd_put_lchar(indent, 0, '\x00'); lcd_put_u8str(F( "------" )); lcd_put_lchar('\x01'); lcd_put_u8str(indent, 1, F("|Marlin|")); lcd_put_u8str(extra); - lcd_put_wchar(indent, 2, '\x02'); lcd_put_u8str(F( "------" )); lcd_put_wchar('\x03'); + lcd_put_lchar(indent, 2, '\x02'); lcd_put_u8str(F( "------" )); lcd_put_lchar('\x03'); } void MarlinUI::show_bootscreen() { @@ -510,11 +511,11 @@ void MarlinUI::draw_kill_screen() { // Homed and known, display constantly. // FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const bool blink) { - lcd_put_wchar('X' + uint8_t(axis)); + lcd_put_lchar('X' + uint8_t(axis)); if (blink) lcd_put_u8str(value); else if (axis_should_home(axis)) - while (const char c = *value++) lcd_put_wchar(c <= '.' ? c : '?'); + while (const char c = *value++) lcd_put_lchar(c <= '.' ? c : '?'); else if (NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) && !axis_is_trusted(axis)) lcd_put_u8str(axis == Z_AXIS ? F(" ") : F(" ")); else @@ -531,27 +532,27 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char pr const celsius_t t1 = thermalManager.wholeDegHotend(heater_id), t2 = thermalManager.degTargetHotend(heater_id); #endif - if (prefix >= 0) lcd_put_wchar(prefix); + if (prefix >= 0) lcd_put_lchar(prefix); lcd_put_u8str(t1 < 0 ? "err" : i16tostr3rj(t1)); - lcd_put_wchar('/'); + lcd_put_lchar('/'); #if !HEATER_IDLE_HANDLER UNUSED(blink); #else if (!blink && thermalManager.heater_idle[thermalManager.idle_index_for_id(heater_id)].timed_out) { - lcd_put_wchar(' '); - if (t2 >= 10) lcd_put_wchar(' '); - if (t2 >= 100) lcd_put_wchar(' '); + lcd_put_lchar(' '); + if (t2 >= 10) lcd_put_lchar(' '); + if (t2 >= 100) lcd_put_lchar(' '); } else #endif lcd_put_u8str(i16tostr3left(t2)); if (prefix >= 0) { - lcd_put_wchar(LCD_STR_DEGREE[0]); - lcd_put_wchar(' '); - if (t2 < 10) lcd_put_wchar(' '); + lcd_put_lchar(LCD_STR_DEGREE[0]); + lcd_put_lchar(' '); + if (t2 < 10) lcd_put_lchar(' '); } } @@ -559,27 +560,27 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char pr FORCE_INLINE void _draw_cooler_status(const char prefix, const bool blink) { const celsius_t t2 = thermalManager.degTargetCooler(); - if (prefix >= 0) lcd_put_wchar(prefix); + if (prefix >= 0) lcd_put_lchar(prefix); lcd_put_u8str(i16tostr3rj(thermalManager.wholeDegCooler())); - lcd_put_wchar('/'); + lcd_put_lchar('/'); #if !HEATER_IDLE_HANDLER UNUSED(blink); #else if (!blink && thermalManager.heater_idle[thermalManager.idle_index_for_id(heater_id)].timed_out) { - lcd_put_wchar(' '); - if (t2 >= 10) lcd_put_wchar(' '); - if (t2 >= 100) lcd_put_wchar(' '); + lcd_put_lchar(' '); + if (t2 >= 10) lcd_put_lchar(' '); + if (t2 >= 100) lcd_put_lchar(' '); } else #endif lcd_put_u8str(i16tostr3left(t2)); if (prefix >= 0) { - lcd_put_wchar(LCD_STR_DEGREE[0]); - lcd_put_wchar(' '); - if (t2 < 10) lcd_put_wchar(' '); + lcd_put_lchar(LCD_STR_DEGREE[0]); + lcd_put_lchar(' '); + if (t2 < 10) lcd_put_lchar(' '); } } #endif @@ -588,7 +589,7 @@ FORCE_INLINE void _draw_cooler_status(const char prefix, const bool blink) { FORCE_INLINE void _draw_flowmeter_status() { lcd_put_u8str("~"); lcd_put_u8str(ftostr11ns(cooler.flowrate)); - lcd_put_wchar('L'); + lcd_put_lchar('L'); } #endif @@ -602,7 +603,7 @@ FORCE_INLINE void _draw_cooler_status(const char prefix, const bool blink) { } else { lcd_put_u8str(ftostr12ns(ammeter.current)); - lcd_put_wchar('A'); + lcd_put_lchar('A'); } } #endif @@ -620,7 +621,7 @@ FORCE_INLINE void _draw_bed_status(const bool blink) { lcd_put_u8str(ui8tostr3rj(progress)); else lcd_put_u8str(F("---")); - lcd_put_wchar('%'); + lcd_put_lchar('%'); } #endif @@ -667,7 +668,7 @@ void MarlinUI::draw_status_message(const bool blink) { lcd_put_u8str(ftostr12ns(filwidth.measured_mm)); lcd_put_u8str(F(" V")); lcd_put_u8str(i16tostr3rj(planner.volumetric_percent(parser.volumetric_enabled))); - lcd_put_wchar('%'); + lcd_put_lchar('%'); return; } @@ -686,7 +687,7 @@ void MarlinUI::draw_status_message(const bool blink) { lcd_put_u8str(status_message); // Fill the rest with spaces - while (slen < LCD_WIDTH) { lcd_put_wchar(' '); ++slen; } + while (slen < LCD_WIDTH) { lcd_put_lchar(' '); ++slen; } } else { // String is larger than the available space in screen. @@ -700,11 +701,11 @@ void MarlinUI::draw_status_message(const bool blink) { // If the remaining string doesn't completely fill the screen if (rlen < LCD_WIDTH) { uint8_t chars = LCD_WIDTH - rlen; // Amount of space left in characters - lcd_put_wchar(' '); // Always at 1+ spaces left, draw a space + lcd_put_lchar(' '); // Always at 1+ spaces left, draw a space if (--chars) { // Draw a second space if there's room - lcd_put_wchar(' '); + lcd_put_lchar(' '); if (--chars) { // Draw a third space if there's room - lcd_put_wchar(' '); + lcd_put_lchar(' '); if (--chars) lcd_put_u8str_max(status_message, chars); // Print a second copy of the message } @@ -726,7 +727,7 @@ void MarlinUI::draw_status_message(const bool blink) { // Fill the rest with spaces if there are missing spaces while (slen < LCD_WIDTH) { - lcd_put_wchar(' '); + lcd_put_lchar(' '); ++slen; } #endif @@ -778,7 +779,7 @@ inline uint8_t draw_elapsed_or_remaining_time(uint8_t timepos, const bool blink) duration_t remaining = (progress > 0) ? ((elapsed * 25600 / progress) >> 8) - elapsed : 0; #endif timepos -= remaining.toDigital(buffer); - lcd_put_wchar(timepos, 2, 'R'); + lcd_put_lchar(timepos, 2, 'R'); } #else constexpr bool show_remain = false; @@ -787,7 +788,7 @@ inline uint8_t draw_elapsed_or_remaining_time(uint8_t timepos, const bool blink) if (!show_remain) { duration_t elapsed = print_job_timer.duration(); timepos -= elapsed.toDigital(buffer); - lcd_put_wchar(timepos, 2, LCD_STR_CLOCK[0]); + lcd_put_lchar(timepos, 2, LCD_STR_CLOCK[0]); } lcd_put_u8str(buffer); return timepos; @@ -912,7 +913,7 @@ void MarlinUI::draw_status_screen() { else { const xy_pos_t lpos = current_position.asLogical(); _draw_axis_value(X_AXIS, ftostr4sign(lpos.x), blink); - lcd_put_wchar(' '); + lcd_put_lchar(' '); _draw_axis_value(Y_AXIS, ftostr4sign(lpos.y), blink); } @@ -926,7 +927,7 @@ void MarlinUI::draw_status_screen() { _draw_axis_value(Z_AXIS, ftostr52sp(LOGICAL_Z_POSITION(current_position.z)), blink); #if HAS_LEVELING && !HAS_HEATED_BED - lcd_put_wchar(planner.leveling_active || blink ? '_' : ' '); + lcd_put_lchar(planner.leveling_active || blink ? '_' : ' '); #endif #endif // LCD_HEIGHT > 2 @@ -935,9 +936,9 @@ void MarlinUI::draw_status_screen() { #if LCD_HEIGHT > 3 - lcd_put_wchar(0, 2, LCD_STR_FEEDRATE[0]); + lcd_put_lchar(0, 2, LCD_STR_FEEDRATE[0]); lcd_put_u8str(i16tostr3rj(feedrate_percentage)); - lcd_put_wchar('%'); + lcd_put_lchar('%'); const uint8_t timepos = draw_elapsed_or_remaining_time(LCD_WIDTH - 1, blink); @@ -969,9 +970,9 @@ void MarlinUI::draw_status_screen() { per = planner.flow_percentage[0]; #endif } - lcd_put_wchar(c); + lcd_put_lchar(c); lcd_put_u8str(i16tostr3rj(per)); - lcd_put_wchar('%'); + lcd_put_lchar('%'); #endif #endif @@ -993,7 +994,7 @@ void MarlinUI::draw_status_screen() { _draw_axis_value(Z_AXIS, ftostr52sp(LOGICAL_Z_POSITION(current_position.z)), blink); #if HAS_LEVELING && (HAS_MULTI_HOTEND || !HAS_HEATED_BED) - lcd_put_wchar(LCD_WIDTH - 1, 0, planner.leveling_active || blink ? '_' : ' '); + lcd_put_lchar(LCD_WIDTH - 1, 0, planner.leveling_active || blink ? '_' : ' '); #endif // ========== Line 2 ========== @@ -1008,9 +1009,9 @@ void MarlinUI::draw_status_screen() { _draw_bed_status(blink); #endif - lcd_put_wchar(LCD_WIDTH - 9, 1, LCD_STR_FEEDRATE[0]); + lcd_put_lchar(LCD_WIDTH - 9, 1, LCD_STR_FEEDRATE[0]); lcd_put_u8str(i16tostr3rj(feedrate_percentage)); - lcd_put_wchar('%'); + lcd_put_lchar('%'); // ========== Line 3 ========== @@ -1075,29 +1076,29 @@ void MarlinUI::draw_status_screen() { vlen = vstr ? utf8_strlen(vstr) : 0; if (style & SS_CENTER) { int8_t pad = (LCD_WIDTH - plen - vlen) / 2; - while (--pad >= 0) { lcd_put_wchar(' '); n--; } + while (--pad >= 0) { lcd_put_lchar(' '); n--; } } if (plen) n = lcd_put_u8str(fstr, itemIndex, itemStringC, itemStringF, n); if (vlen) n -= lcd_put_u8str_max(vstr, n); - for (; n > 0; --n) lcd_put_wchar(' '); + for (; n > 0; --n) lcd_put_lchar(' '); } // Draw a generic menu item with pre_char (if selected) and post_char void MenuItemBase::_draw(const bool sel, const uint8_t row, FSTR_P const ftpl, const char pre_char, const char post_char) { - lcd_put_wchar(0, row, sel ? pre_char : ' '); + lcd_put_lchar(0, row, sel ? pre_char : ' '); uint8_t n = lcd_put_u8str(ftpl, itemIndex, itemStringC, itemStringF, LCD_WIDTH - 2); - for (; n; --n) lcd_put_wchar(' '); - lcd_put_wchar(post_char); + for (; n; --n) lcd_put_lchar(' '); + lcd_put_lchar(post_char); } // Draw a menu item with a (potentially) editable value void MenuEditItemBase::draw(const bool sel, const uint8_t row, FSTR_P const ftpl, const char * const inStr, const bool pgm) { const uint8_t vlen = inStr ? (pgm ? utf8_strlen_P(inStr) : utf8_strlen(inStr)) : 0; - lcd_put_wchar(0, row, sel ? LCD_STR_ARROW_RIGHT[0] : ' '); + lcd_put_lchar(0, row, sel ? LCD_STR_ARROW_RIGHT[0] : ' '); uint8_t n = lcd_put_u8str(ftpl, itemIndex, itemStringC, itemStringF, LCD_WIDTH - 2 - vlen); if (vlen) { - lcd_put_wchar(':'); - for (; n; --n) lcd_put_wchar(' '); + lcd_put_lchar(':'); + for (; n; --n) lcd_put_lchar(' '); if (pgm) lcd_put_u8str_P(inStr); else lcd_put_u8str(inStr); } } @@ -1107,10 +1108,10 @@ void MarlinUI::draw_status_screen() { ui.encoder_direction_normal(); uint8_t n = lcd_put_u8str(0, 1, ftpl, itemIndex, itemStringC, itemStringF, LCD_WIDTH - 1); if (value) { - lcd_put_wchar(':'); n--; + lcd_put_lchar(':'); n--; const uint8_t len = utf8_strlen(value) + 1; // Plus one for a leading space const lcd_uint_t valrow = n < len ? 2 : 1; // Value on the next row if it won't fit - lcd_put_wchar(LCD_WIDTH - len, valrow, ' '); // Right-justified, padded, leading space + lcd_put_lchar(LCD_WIDTH - len, valrow, ' '); // Right-justified, padded, leading space lcd_put_u8str(value); } } @@ -1120,22 +1121,22 @@ void MarlinUI::draw_status_screen() { ui.draw_select_screen_prompt(pref, string, suff); if (no) { SETCURSOR(0, LCD_HEIGHT - 1); - lcd_put_wchar(yesno ? ' ' : '['); lcd_put_u8str(no); lcd_put_wchar(yesno ? ' ' : ']'); + lcd_put_lchar(yesno ? ' ' : '['); lcd_put_u8str(no); lcd_put_lchar(yesno ? ' ' : ']'); } if (yes) { SETCURSOR_RJ(utf8_strlen(yes) + 2, LCD_HEIGHT - 1); - lcd_put_wchar(yesno ? '[' : ' '); lcd_put_u8str(yes); lcd_put_wchar(yesno ? ']' : ' '); + lcd_put_lchar(yesno ? '[' : ' '); lcd_put_u8str(yes); lcd_put_lchar(yesno ? ']' : ' '); } } #if ENABLED(SDSUPPORT) void MenuItem_sdbase::draw(const bool sel, const uint8_t row, FSTR_P const, CardReader &theCard, const bool isDir) { - lcd_put_wchar(0, row, sel ? LCD_STR_ARROW_RIGHT[0] : ' '); + lcd_put_lchar(0, row, sel ? LCD_STR_ARROW_RIGHT[0] : ' '); constexpr uint8_t maxlen = LCD_WIDTH - 2; uint8_t n = maxlen - lcd_put_u8str_max(ui.scrolled_filename(theCard, maxlen, row, sel), maxlen); - for (; n; --n) lcd_put_wchar(' '); - lcd_put_wchar(isDir ? LCD_STR_FOLDER[0] : ' '); + for (; n; --n) lcd_put_lchar(' '); + lcd_put_lchar(isDir ? LCD_STR_FOLDER[0] : ' '); } #endif @@ -1253,7 +1254,7 @@ void MarlinUI::draw_status_screen() { void prep_and_put_map_char(custom_char &chrdata, const coordinate &ul, const coordinate &lr, const coordinate &brc, const uint8_t cl, const char c, const lcd_uint_t x, const lcd_uint_t y) { add_edges_to_custom_char(chrdata, ul, lr, brc, cl); lcd.createChar(c, (uint8_t*)&chrdata); - lcd_put_wchar(x, y, c); + lcd_put_lchar(x, y, c); } void MarlinUI::ubl_plot(const uint8_t x_plot, const uint8_t y_plot) { @@ -1270,7 +1271,7 @@ void MarlinUI::draw_status_screen() { #define _LCD_W_POS 8 #define _PLOT_X 0 #define _MAP_X 1 - #define _LABEL(X,Y,C) lcd_put_wchar(X, Y, C) + #define _LABEL(X,Y,C) lcd_put_lchar(X, Y, C) #define _XLABEL(X,Y) _LABEL('X',X,Y) #define _YLABEL(X,Y) _LABEL('Y',X,Y) #define _ZLABEL(X,Y) _LABEL('Z',X,Y) @@ -1333,13 +1334,13 @@ void MarlinUI::draw_status_screen() { n_cols = right_edge / (HD44780_CHAR_WIDTH) + 1; for (i = 0; i < n_cols; i++) { - lcd_put_wchar(i, 0, CHAR_LINE_TOP); // Box Top line - lcd_put_wchar(i, n_rows - 1, CHAR_LINE_BOT); // Box Bottom line + lcd_put_lchar(i, 0, CHAR_LINE_TOP); // Box Top line + lcd_put_lchar(i, n_rows - 1, CHAR_LINE_BOT); // Box Bottom line } for (j = 0; j < n_rows; j++) { - lcd_put_wchar(0, j, CHAR_EDGE_L); // Box Left edge - lcd_put_wchar(n_cols - 1, j, CHAR_EDGE_R); // Box Right edge + lcd_put_lchar(0, j, CHAR_EDGE_L); // Box Left edge + lcd_put_lchar(n_cols - 1, j, CHAR_EDGE_R); // Box Right edge } /** @@ -1349,8 +1350,8 @@ void MarlinUI::draw_status_screen() { k = pixels_per_y_mesh_pnt * (GRID_MAX_POINTS_Y) + 2; l = (HD44780_CHAR_HEIGHT) * n_rows; if (l > k && l - k >= (HD44780_CHAR_HEIGHT) / 2) { - lcd_put_wchar(0, n_rows - 1, ' '); // Box Left edge - lcd_put_wchar(n_cols - 1, n_rows - 1, ' '); // Box Right edge + lcd_put_lchar(0, n_rows - 1, ' '); // Box Left edge + lcd_put_lchar(n_cols - 1, n_rows - 1, ' '); // Box Right edge } clear_custom_char(&new_char); @@ -1464,11 +1465,11 @@ void MarlinUI::draw_status_screen() { /** * Print plot position */ - lcd_put_wchar(_LCD_W_POS, 0, '('); + lcd_put_lchar(_LCD_W_POS, 0, '('); lcd_put_u8str(ui8tostr3rj(x_plot)); - lcd_put_wchar(','); + lcd_put_lchar(','); lcd_put_u8str(ui8tostr3rj(y_plot)); - lcd_put_wchar(')'); + lcd_put_lchar(')'); #if LCD_HEIGHT <= 3 // 16x2 or 20x2 display diff --git a/Marlin/src/lcd/TFTGLCD/lcdprint_TFTGLCD.cpp b/Marlin/src/lcd/TFTGLCD/lcdprint_TFTGLCD.cpp index 7b15b78605..e681ff0a91 100644 --- a/Marlin/src/lcd/TFTGLCD/lcdprint_TFTGLCD.cpp +++ b/Marlin/src/lcd/TFTGLCD/lcdprint_TFTGLCD.cpp @@ -48,7 +48,7 @@ int lcd_glyph_height() { return 1; } typedef struct _TFTGLCD_charmap_t { - wchar_t uchar; // the unicode char + lchar_t uchar; // the unicode char uint8_t idx; // the glyph of the char in the ROM uint8_t idx2; // the char used to be combined with the idx to simulate a single char } TFTGLCD_charmap_t; @@ -991,7 +991,7 @@ void lcd_put_int(const int i) { // return < 0 on error // return the advanced cols -int lcd_put_wchar_max(const wchar_t c, const pixel_len_t max_length) { +int lcd_put_lchar_max(const lchar_t &c, const pixel_len_t max_length) { // find the HD44780 internal ROM first int ret; @@ -1049,10 +1049,10 @@ static int lcd_put_u8str_max_cb(const char * utf8_str, read_byte_cb_t cb_read_by pixel_len_t ret = 0; const uint8_t *p = (uint8_t *)utf8_str; while (ret < max_length) { - wchar_t ch = 0; - p = get_utf8_value_cb(p, cb_read_byte, &ch); - if (!ch) break; - ret += lcd_put_wchar_max(ch, max_length - ret); + lchar_t wc; + p = get_utf8_value_cb(p, cb_read_byte, wc); + if (!wc) break; + ret += lcd_put_lchar_max(wc, max_length - ret); } return (int)ret; } diff --git a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp index 46564bb1e6..f3d98ec555 100644 --- a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp +++ b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp @@ -524,16 +524,16 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const UNUSED(blink); #else if (!blink && thermalManager.heater_idle[thermalManager.idle_index_for_id(heater_id)].timed_out) { - lcd_put_wchar(' '); - if (t2 >= 10) lcd_put_wchar(' '); - if (t2 >= 100) lcd_put_wchar(' '); + lcd_put_lchar(' '); + if (t2 >= 10) lcd_put_lchar(' '); + if (t2 >= 100) lcd_put_lchar(' '); } else #endif lcd_put_u8str(i16tostr3left(t2)); - lcd_put_wchar(' '); - if (t2 < 10) lcd_put_wchar(' '); + lcd_put_lchar(' '); + if (t2 < 10) lcd_put_lchar(' '); if (t2) picBits |= ICON_TEMP1; else picBits &= ~ICON_TEMP1; @@ -545,7 +545,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const FORCE_INLINE void _draw_flowmeter_status() { lcd_moveto(5, 5); lcd_put_u8str(F("FLOW")); - lcd_moveto(7, 6); lcd_put_wchar('L'); + lcd_moveto(7, 6); lcd_put_lchar('L'); lcd_moveto(6, 7); lcd_put_u8str(ftostr11ns(cooler.flowrate)); if (cooler.flowrate) picBits |= ICON_FAN; @@ -564,7 +564,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const { lcd_put_u8str("mA"); lcd_moveto(10, 7); - lcd_put_wchar(' '); lcd_put_u8str(ui16tostr3rj(uint16_t(ammeter.current * 1000 + 0.5f))); + lcd_put_lchar(' '); lcd_put_u8str(ui16tostr3rj(uint16_t(ammeter.current * 1000 + 0.5f))); } else { lcd_put_u8str(" A"); @@ -585,9 +585,9 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const #if CUTTER_UNIT_IS(RPM) lcd_moveto(16, 6); lcd_put_u8str(F("RPM")); lcd_moveto(15, 7); lcd_put_u8str(ftostr31ns(float(cutter.unitPower) / 1000)); - lcd_put_wchar('K'); + lcd_put_lchar('K'); #elif CUTTER_UNIT_IS(PERCENT) - lcd_moveto(17, 6); lcd_put_wchar('%'); + lcd_moveto(17, 6); lcd_put_lchar('%'); lcd_moveto(18, 7); lcd_put_u8str(cutter_power2str(cutter.unitPower)); #else lcd_moveto(17, 7); lcd_put_u8str(cutter_power2str(cutter.unitPower)); diff --git a/Marlin/src/lcd/dogm/lcdprint_u8g.cpp b/Marlin/src/lcd/dogm/lcdprint_u8g.cpp index f5c13798f2..48b2e92a11 100644 --- a/Marlin/src/lcd/dogm/lcdprint_u8g.cpp +++ b/Marlin/src/lcd/dogm/lcdprint_u8g.cpp @@ -28,7 +28,7 @@ void lcd_put_int(const int i) { u8g.print(i); } // return < 0 on error // return the advanced pixels -int lcd_put_wchar_max(const wchar_t c, const pixel_len_t max_length) { +int lcd_put_lchar_max(const lchar_t &c, const pixel_len_t max_length) { if (c < 256) { u8g.print((char)c); return u8g_GetFontBBXWidth(u8g.getU8g()); diff --git a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp index 3c661a4429..e32715988d 100644 --- a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp +++ b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp @@ -371,11 +371,11 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop if (!PAGE_CONTAINS(y1 + 1, y2 + 2)) return; - lcd_put_wchar(LCD_PIXEL_WIDTH - 11 * (MENU_FONT_WIDTH), y2, 'E'); - lcd_put_wchar((char)('1' + extruder)); - lcd_put_wchar(' '); + lcd_put_lchar(LCD_PIXEL_WIDTH - 11 * (MENU_FONT_WIDTH), y2, 'E'); + lcd_put_lchar((char)('1' + extruder)); + lcd_put_lchar(' '); lcd_put_u8str(i16tostr3rj(thermalManager.wholeDegHotend(extruder))); - lcd_put_wchar('/'); + lcd_put_lchar('/'); if (get_blink() || !thermalManager.heater_idle[extruder].timed_out) lcd_put_u8str(i16tostr3rj(thermalManager.degTargetHotend(extruder))); @@ -421,12 +421,12 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop vlen = vstr ? utf8_strlen(vstr) : 0; if (style & SS_CENTER) { int pad = (LCD_PIXEL_WIDTH - plen - vlen * MENU_FONT_WIDTH) / MENU_FONT_WIDTH / 2; - while (--pad >= 0) n -= lcd_put_wchar(' '); + while (--pad >= 0) n -= lcd_put_lchar(' '); } if (plen) n = lcd_put_u8str(ftpl, itemIndex, itemStringC, itemStringF, n / (MENU_FONT_WIDTH)) * (MENU_FONT_WIDTH); if (vlen) n -= lcd_put_u8str_max(vstr, n); - while (n > MENU_FONT_WIDTH) n -= lcd_put_wchar(' '); + while (n > MENU_FONT_WIDTH) n -= lcd_put_lchar(' '); } } @@ -434,9 +434,9 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop void MenuItemBase::_draw(const bool sel, const uint8_t row, FSTR_P const ftpl, const char, const char post_char) { if (mark_as_selected(row, sel)) { pixel_len_t n = lcd_put_u8str(ftpl, itemIndex, itemStringC, itemStringF, LCD_WIDTH - 1) * (MENU_FONT_WIDTH); - while (n > MENU_FONT_WIDTH) n -= lcd_put_wchar(' '); - lcd_put_wchar(LCD_PIXEL_WIDTH - (MENU_FONT_WIDTH), row_y2, post_char); - lcd_put_wchar(' '); + while (n > MENU_FONT_WIDTH) n -= lcd_put_lchar(' '); + lcd_put_lchar(LCD_PIXEL_WIDTH - (MENU_FONT_WIDTH), row_y2, post_char); + lcd_put_lchar(' '); } } @@ -449,8 +449,8 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop pixel_len_t n = lcd_put_u8str(ftpl, itemIndex, itemStringC, itemStringF, LCD_WIDTH - 2 - vallen * prop) * (MENU_FONT_WIDTH); if (vallen) { - lcd_put_wchar(':'); - while (n > MENU_FONT_WIDTH) n -= lcd_put_wchar(' '); + lcd_put_lchar(':'); + while (n > MENU_FONT_WIDTH) n -= lcd_put_lchar(' '); lcd_moveto(LCD_PIXEL_WIDTH - _MAX((MENU_FONT_WIDTH) * vallen, pixelwidth + 2), row_y2); if (pgm) lcd_put_u8str_P(inStr); else lcd_put_u8str(inStr); } @@ -494,14 +494,14 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop // If a value is included, print a colon, then print the value right-justified if (value) { - lcd_put_wchar(':'); + lcd_put_lchar(':'); if (extra_row) { // Assume that value is numeric (with no descender) baseline += EDIT_FONT_ASCENT + 2; onpage = PAGE_CONTAINS(baseline - (EDIT_FONT_ASCENT - 1), baseline); } if (onpage) { - lcd_put_wchar(((lcd_chr_fit - 1) - (vallen * prop + 1)) * one_chr_width, baseline, ' '); // Right-justified, padded, add a leading space + lcd_put_lchar(((lcd_chr_fit - 1) - (vallen * prop + 1)) * one_chr_width, baseline, ' '); // Right-justified, padded, add a leading space lcd_put_u8str(value); } } @@ -533,10 +533,10 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop void MenuItem_sdbase::draw(const bool sel, const uint8_t row, FSTR_P const, CardReader &theCard, const bool isDir) { if (mark_as_selected(row, sel)) { const uint8_t maxlen = LCD_WIDTH - isDir; - if (isDir) lcd_put_wchar(LCD_STR_FOLDER[0]); + if (isDir) lcd_put_lchar(LCD_STR_FOLDER[0]); const pixel_len_t pixw = maxlen * (MENU_FONT_WIDTH); pixel_len_t n = pixw - lcd_put_u8str_max(ui.scrolled_filename(theCard, maxlen, row, sel), pixw); - while (n > MENU_FONT_WIDTH) n -= lcd_put_wchar(' '); + while (n > MENU_FONT_WIDTH) n -= lcd_put_lchar(' '); } } @@ -611,11 +611,11 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop // Print plot position if (PAGE_CONTAINS(LCD_PIXEL_HEIGHT - (INFO_FONT_HEIGHT - 1), LCD_PIXEL_HEIGHT)) { - lcd_put_wchar(5, LCD_PIXEL_HEIGHT, '('); + lcd_put_lchar(5, LCD_PIXEL_HEIGHT, '('); u8g.print(x_plot); - lcd_put_wchar(','); + lcd_put_lchar(','); u8g.print(y_plot); - lcd_put_wchar(')'); + lcd_put_lchar(')'); // Show the location value lcd_put_u8str_P(74, LCD_PIXEL_HEIGHT, Z_LBL); diff --git a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp index 010a1397f6..67039d52de 100644 --- a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp +++ b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp @@ -200,7 +200,7 @@ FORCE_INLINE void _draw_centered_temp(const celsius_t temp, const uint8_t tx, co const char *str = i16tostr3rj(temp); const uint8_t len = str[0] != ' ' ? 3 : str[1] != ' ' ? 2 : 1; lcd_put_u8str(tx - len * (INFO_FONT_WIDTH) / 2 + 1, ty, &str[3-len]); - lcd_put_wchar(LCD_STR_DEGREE[0]); + lcd_put_lchar(LCD_STR_DEGREE[0]); } } @@ -432,13 +432,13 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const const bool is_inch = parser.using_inch_units(); const AxisEnum a = TERN(LCD_SHOW_E_TOTAL, axis == E_AXIS ? X_AXIS : axis, axis); const uint8_t offs = a * (is_inch ? XYZ_SPACING_IN : XYZ_SPACING); - lcd_put_wchar((is_inch ? X_LABEL_POS_IN : X_LABEL_POS) + offs, XYZ_BASELINE, AXIS_CHAR(axis)); + lcd_put_lchar((is_inch ? X_LABEL_POS_IN : X_LABEL_POS) + offs, XYZ_BASELINE, AXIS_CHAR(axis)); lcd_moveto((is_inch ? X_VALUE_POS_IN : X_VALUE_POS) + offs, XYZ_BASELINE); if (blink) lcd_put_u8str(value); else if (axis_should_home(axis)) - while (const char c = *value++) lcd_put_wchar(c <= '.' ? c : '?'); + while (const char c = *value++) lcd_put_lchar(c <= '.' ? c : '?'); else if (NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) && !axis_is_trusted(axis)) lcd_put_u8str(axis == Z_AXIS ? F(" ") : F(" ")); else @@ -670,12 +670,12 @@ void MarlinUI::draw_status_screen() { // Laser / Spindle #if DO_DRAW_CUTTER - if (cutter.isReady && PAGE_CONTAINS(STATUS_CUTTER_TEXT_Y - INFO_FONT_ASCENT, STATUS_CUTTER_TEXT_Y - 1)) { + if (cutter.isReadyForUI && PAGE_CONTAINS(STATUS_CUTTER_TEXT_Y - INFO_FONT_ASCENT, STATUS_CUTTER_TEXT_Y - 1)) { #if CUTTER_UNIT_IS(PERCENT) lcd_put_u8str(STATUS_CUTTER_TEXT_X, STATUS_CUTTER_TEXT_Y, cutter_power2str(cutter.unitPower)); #elif CUTTER_UNIT_IS(RPM) lcd_put_u8str(STATUS_CUTTER_TEXT_X - 2, STATUS_CUTTER_TEXT_Y, ftostr61rj(float(cutter.unitPower) / 1000)); - lcd_put_wchar('K'); + lcd_put_lchar('K'); #else lcd_put_u8str(STATUS_CUTTER_TEXT_X, STATUS_CUTTER_TEXT_Y, cutter_power2str(cutter.unitPower)); #endif @@ -734,7 +734,7 @@ void MarlinUI::draw_status_screen() { } #endif lcd_put_u8str(STATUS_FAN_TEXT_X, STATUS_FAN_TEXT_Y, i16tostr3rj(thermalManager.pwmToPercent(spd))); - lcd_put_wchar(c); + lcd_put_lchar(c); } } #endif @@ -783,7 +783,7 @@ void MarlinUI::draw_status_screen() { if (progress_state == 0) { if (progress_string[0]) { lcd_put_u8str(progress_x_pos, EXTRAS_BASELINE, progress_string); - lcd_put_wchar('%'); + lcd_put_lchar('%'); } } else if (progress_state == 2 && estimation_string[0]) { @@ -804,7 +804,7 @@ void MarlinUI::draw_status_screen() { #if ENABLED(SHOW_SD_PERCENT) if (progress_string[0]) { lcd_put_u8str(55, EXTRAS_BASELINE, progress_string); // Percent complete - lcd_put_wchar('%'); + lcd_put_lchar('%'); } #endif @@ -814,7 +814,7 @@ void MarlinUI::draw_status_screen() { #if ENABLED(SHOW_REMAINING_TIME) if (blink && estimation_string[0]) { - lcd_put_wchar(estimation_x_pos, EXTRAS_BASELINE, 'R'); + lcd_put_lchar(estimation_x_pos, EXTRAS_BASELINE, 'R'); lcd_put_u8str(estimation_string); } else @@ -912,11 +912,11 @@ void MarlinUI::draw_status_screen() { if (PAGE_CONTAINS(EXTRAS_2_BASELINE - INFO_FONT_ASCENT, EXTRAS_2_BASELINE - 1)) { set_font(FONT_MENU); - lcd_put_wchar(3, EXTRAS_2_BASELINE, LCD_STR_FEEDRATE[0]); + lcd_put_lchar(3, EXTRAS_2_BASELINE, LCD_STR_FEEDRATE[0]); set_font(FONT_STATUSMENU); lcd_put_u8str(12, EXTRAS_2_BASELINE, i16tostr3rj(feedrate_percentage)); - lcd_put_wchar('%'); + lcd_put_lchar('%'); // // Filament sensor display if SD is disabled @@ -924,10 +924,10 @@ void MarlinUI::draw_status_screen() { #if ENABLED(FILAMENT_LCD_DISPLAY) && DISABLED(SDSUPPORT) lcd_put_u8str(56, EXTRAS_2_BASELINE, wstring); lcd_put_u8str(102, EXTRAS_2_BASELINE, mstring); - lcd_put_wchar('%'); + lcd_put_lchar('%'); set_font(FONT_MENU); - lcd_put_wchar(47, EXTRAS_2_BASELINE, LCD_STR_FILAM_DIA[0]); // lcd_put_u8str(F(LCD_STR_FILAM_DIA)); - lcd_put_wchar(93, EXTRAS_2_BASELINE, LCD_STR_FILAM_MUL[0]); + lcd_put_lchar(47, EXTRAS_2_BASELINE, LCD_STR_FILAM_DIA[0]); // lcd_put_u8str(F(LCD_STR_FILAM_DIA)); + lcd_put_lchar(93, EXTRAS_2_BASELINE, LCD_STR_FILAM_MUL[0]); #endif } @@ -941,12 +941,12 @@ void MarlinUI::draw_status_screen() { // Alternate Status message and Filament display if (ELAPSED(millis(), next_filament_display)) { lcd_put_u8str(F(LCD_STR_FILAM_DIA)); - lcd_put_wchar(':'); + lcd_put_lchar(':'); lcd_put_u8str(wstring); lcd_put_u8str(F(" " LCD_STR_FILAM_MUL)); - lcd_put_wchar(':'); + lcd_put_lchar(':'); lcd_put_u8str(mstring); - lcd_put_wchar('%'); + lcd_put_lchar('%'); return; } #endif @@ -979,7 +979,7 @@ void MarlinUI::draw_status_message(const bool blink) { if (slen <= lcd_width) { // The string fits within the line. Print with no scrolling lcd_put_u8str(status_message); - while (slen < lcd_width) { lcd_put_wchar(' '); ++slen; } + while (slen < lcd_width) { lcd_put_lchar(' '); ++slen; } } else { // String is longer than the available space @@ -997,14 +997,14 @@ void MarlinUI::draw_status_message(const bool blink) { // If the remaining string doesn't completely fill the screen if (rlen < lcd_width) { uint8_t chars = lcd_width - rlen; // Amount of space left in characters - lcd_put_wchar(' '); // Always at 1+ spaces left, draw a space + lcd_put_lchar(' '); // Always at 1+ spaces left, draw a space if (--chars) { // Draw a second space if there's room - lcd_put_wchar(' '); + lcd_put_lchar(' '); if (--chars) { // Draw a third space if there's room - lcd_put_wchar(' '); + lcd_put_lchar(' '); if (--chars) { // Print a second copy of the message lcd_put_u8str_max(status_message, pixel_width - (rlen + 2) * (MENU_FONT_WIDTH)); - lcd_put_wchar(' '); + lcd_put_lchar(' '); } } } @@ -1019,7 +1019,7 @@ void MarlinUI::draw_status_message(const bool blink) { lcd_put_u8str_max(status_message, pixel_width); // Fill the rest with spaces - for (; slen < lcd_width; ++slen) lcd_put_wchar(' '); + for (; slen < lcd_width; ++slen) lcd_put_lchar(' '); #endif // !STATUS_MESSAGE_SCROLLING diff --git a/Marlin/src/lcd/dogm/u8g_dev_st7565_64128n_HAL.cpp b/Marlin/src/lcd/dogm/u8g_dev_st7565_64128n_HAL.cpp index bfd44d08df..63e7b2e2b8 100644 --- a/Marlin/src/lcd/dogm/u8g_dev_st7565_64128n_HAL.cpp +++ b/Marlin/src/lcd/dogm/u8g_dev_st7565_64128n_HAL.cpp @@ -74,7 +74,6 @@ #define ST7565_ON(N) ((N) ? 0xAF : 0xAE) #define ST7565_OUT_MODE(N) ((N) ? 0xC8 : 0xC0) #define ST7565_POWER_CONTROL(N) (0x28 | (N)) -#define ST7565_V0_RATIO(N) (0x10 | ((N) & 0x7)) #define ST7565_V5_RATIO(N) (0x20 | ((N) & 0x7)) #define ST7565_CONTRAST(N) (0x81), (N) @@ -106,11 +105,14 @@ static const uint8_t u8g_dev_st7565_64128n_HAL_init_seq[] PROGMEM = { ST7565_POWER_CONTROL(0x7), // power control: turn on voltage follower U8G_ESC_DLY(50), // delay 50 ms - ST7565_V0_RATIO(0), // Set V0 voltage resistor ratio. Setting for controlling brightness of Displaytech 64128N + #ifdef ST7565_VOLTAGE_DIVIDER_VALUE + // Set V5 voltage resistor ratio. Affects brightness of Displaytech 64128N + ST7565_V5_RATIO(ST7565_VOLTAGE_DIVIDER_VALUE), + #endif ST7565_INVERTED(0), // display normal, bit val 0: LCD pixel off. - ST7565_CONTRAST(0x1E), // Contrast value. Setting for controlling brightness of Displaytech 64128N + ST7565_CONTRAST(0x1E), // Contrast value for Displaytech 64128N ST7565_ON(1), // display on diff --git a/Marlin/src/lcd/dogm/u8g_fontutf8.cpp b/Marlin/src/lcd/dogm/u8g_fontutf8.cpp index 8ba0e7d50a..d5e0e5baff 100644 --- a/Marlin/src/lcd/dogm/u8g_fontutf8.cpp +++ b/Marlin/src/lcd/dogm/u8g_fontutf8.cpp @@ -60,11 +60,11 @@ static int fontgroup_init(font_group_t * root, const uxg_fontinfo_t * fntinfo, i return 0; } -static const font_t* fontgroup_find(font_group_t * root, wchar_t val) { - uxg_fontinfo_t vcmp = {(uint16_t)(val / 128), (uint8_t)(val % 128 + 128), (uint8_t)(val % 128 + 128), 0, 0}; - size_t idx = 0; +static const font_t* fontgroup_find(font_group_t * root, const lchar_t &val) { + if (val <= 0xFF) return nullptr; - if (val < 256) return nullptr; + uxg_fontinfo_t vcmp = { uint16_t(val >> 7), uint8_t((val & 0x7F) + 0x80), uint8_t((val & 0x7F) + 0x80), 0, 0 }; + size_t idx = 0; if (pf_bsearch_r((void*)root->m_fntifo, root->m_fntinfo_num, pf_bsearch_cb_comp_fntifo_pgm, (void*)&vcmp, &idx) < 0) return nullptr; @@ -73,7 +73,7 @@ static const font_t* fontgroup_find(font_group_t * root, wchar_t val) { return vcmp.fntdata; } -static void fontgroup_drawwchar(font_group_t *group, const font_t *fnt_default, wchar_t val, void * userdata, fontgroup_cb_draw_t cb_draw_ram) { +static void fontgroup_drawwchar(font_group_t *group, const font_t *fnt_default, const lchar_t &val, void * userdata, fontgroup_cb_draw_t cb_draw_ram) { uint8_t buf[2] = {0, 0}; const font_t * fntpqm = (font_t*)fontgroup_find(group, val); if (!fntpqm) { @@ -106,10 +106,10 @@ static void fontgroup_drawwchar(font_group_t *group, const font_t *fnt_default, static void fontgroup_drawstring(font_group_t *group, const font_t *fnt_default, const char *utf8_msg, read_byte_cb_t cb_read_byte, void * userdata, fontgroup_cb_draw_t cb_draw_ram) { const uint8_t *p = (uint8_t*)utf8_msg; for (;;) { - wchar_t val = 0; - p = get_utf8_value_cb(p, cb_read_byte, &val); - if (!val) break; - fontgroup_drawwchar(group, fnt_default, val, userdata, cb_draw_ram); + lchar_t wc; + p = get_utf8_value_cb(p, cb_read_byte, wc); + if (!wc) break; + fontgroup_drawwchar(group, fnt_default, wc, userdata, cb_draw_ram); } } @@ -149,19 +149,19 @@ static int fontgroup_cb_draw_u8g(void *userdata, const font_t *fnt_current, cons } /** - * @brief Draw a wchar_t at the specified position + * @brief Draw a lchar_t at the specified position * * @param pu8g : U8G pointer * @param x : position x axis * @param y : position y axis - * @param ch : the wchar_t + * @param wc : the lchar_t * @param max_width : the pixel width of the string allowed * * @return number of pixels advanced * * Draw a UTF-8 string at the specified position */ -unsigned int uxg_DrawWchar(u8g_t *pu8g, unsigned int x, unsigned int y, wchar_t ch, pixel_len_t max_width) { +unsigned int uxg_DrawWchar(u8g_t *pu8g, unsigned int x, unsigned int y, const lchar_t &wc, pixel_len_t max_width) { struct _uxg_drawu8_data_t data; font_group_t *group = &g_fontgroup_root; const font_t *fnt_default = uxg_GetFont(pu8g); @@ -176,7 +176,7 @@ unsigned int uxg_DrawWchar(u8g_t *pu8g, unsigned int x, unsigned int y, wchar_t data.adv = 0; data.max_width = max_width; data.fnt_prev = nullptr; - fontgroup_drawwchar(group, fnt_default, ch, (void*)&data, fontgroup_cb_draw_u8g); + fontgroup_drawwchar(group, fnt_default, wc, (void*)&data, fontgroup_cb_draw_u8g); u8g_SetFont(pu8g, (const u8g_fntpgm_uint8_t*)fnt_default); return data.adv; diff --git a/Marlin/src/lcd/dogm/u8g_fontutf8.h b/Marlin/src/lcd/dogm/u8g_fontutf8.h index 5933f027cc..0109b6674c 100644 --- a/Marlin/src/lcd/dogm/u8g_fontutf8.h +++ b/Marlin/src/lcd/dogm/u8g_fontutf8.h @@ -26,7 +26,7 @@ typedef struct _uxg_fontinfo_t { int uxg_SetUtf8Fonts(const uxg_fontinfo_t * fntinfo, int number); // fntinfo is type of PROGMEM -unsigned int uxg_DrawWchar(u8g_t *pu8g, unsigned int x, unsigned int y, wchar_t ch, const pixel_len_t max_length); +unsigned int uxg_DrawWchar(u8g_t *pu8g, unsigned int x, unsigned int y, const lchar_t &ch, const pixel_len_t max_length); unsigned int uxg_DrawUtf8Str(u8g_t *pu8g, unsigned int x, unsigned int y, const char *utf8_msg, const pixel_len_t max_length); unsigned int uxg_DrawUtf8StrP(u8g_t *pu8g, unsigned int x, unsigned int y, PGM_P utf8_msg, const pixel_len_t max_length); diff --git a/Marlin/src/lcd/e3v2/common/dwin_font.h b/Marlin/src/lcd/e3v2/common/dwin_font.h index 5a4b1a61cf..10bb104d27 100644 --- a/Marlin/src/lcd/e3v2/common/dwin_font.h +++ b/Marlin/src/lcd/e3v2/common/dwin_font.h @@ -21,6 +21,8 @@ */ #pragma once +typedef uint8_t fontid_t; + /** * 3-.0:The font size, 0x00-0x09, corresponds to the font size below: * 0x00=6*12 0x01=8*16 0x02=10*20 0x03=12*24 0x04=14*28 diff --git a/Marlin/src/lcd/e3v2/common/encoder.cpp b/Marlin/src/lcd/e3v2/common/encoder.cpp index 9922b70b29..f14d63e7b5 100644 --- a/Marlin/src/lcd/e3v2/common/encoder.cpp +++ b/Marlin/src/lcd/e3v2/common/encoder.cpp @@ -36,7 +36,7 @@ #include "../../marlinui.h" #include "../../../HAL/shared/Delay.h" -#if HAS_BUZZER +#if HAS_SOUND #include "../../../libs/buzzer.h" #endif @@ -50,9 +50,7 @@ ENCODER_Rate EncoderRate; // TODO: Replace with ui.quick_feedback void Encoder_tick() { - #if PIN_EXISTS(BEEPER) - if (ui.sound_on) buzzer.click(10); - #endif + TERN_(HAS_BEEPER, if (ui.sound_on) buzzer.click(10)); } // Encoder initialization @@ -66,7 +64,7 @@ void Encoder_Configuration() { #if BUTTON_EXISTS(ENC) SET_INPUT_PULLUP(BTN_ENC); #endif - #if PIN_EXISTS(BEEPER) + #if HAS_BEEPER SET_OUTPUT(BEEPER_PIN); // TODO: Use buzzer.h which already inits this #endif } diff --git a/Marlin/src/lcd/e3v2/creality/dwin.cpp b/Marlin/src/lcd/e3v2/creality/dwin.cpp index 3ca7627db0..1232c8e0c9 100644 --- a/Marlin/src/lcd/e3v2/creality/dwin.cpp +++ b/Marlin/src/lcd/e3v2/creality/dwin.cpp @@ -2625,15 +2625,13 @@ void Draw_HomeOff_Menu() { #include "../../../libs/buzzer.h" void HMI_AudioFeedback(const bool success=true) { - #if HAS_BUZZER - if (success) { - buzzer.tone(100, 659); - buzzer.tone(10, 0); - buzzer.tone(100, 698); - } - else - buzzer.tone(40, 440); - #endif + if (success) { + BUZZ(100, 659); + BUZZ(10, 0); + BUZZ(100, 698); + } + else + BUZZ(40, 440); } // Prepare diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp index 5f1507feb3..285013d750 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp @@ -1202,7 +1202,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp) Popup_Handler(ETemp); else { - if (thermalManager.temp_hotend[0].celsius < thermalManager.temp_hotend[0].target - 2) { + if (thermalManager.temp_hotend[0].is_below_target(-2)) { Popup_Handler(Heating); thermalManager.wait_for_hotend(0); } @@ -1345,7 +1345,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ Popup_Handler(ETemp); } else { - if (thermalManager.temp_hotend[0].celsius < thermalManager.temp_hotend[0].target - 2) { + if (thermalManager.temp_hotend[0].is_below_target(-2)) { Popup_Handler(Heating); thermalManager.wait_for_hotend(0); Redraw_Menu(); @@ -1732,7 +1732,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp) Popup_Handler(ETemp); else { - if (thermalManager.temp_hotend[0].celsius < thermalManager.temp_hotend[0].target - 2) { + if (thermalManager.temp_hotend[0].is_below_target(-2)) { Popup_Handler(Heating); thermalManager.wait_for_hotend(0); } @@ -1751,7 +1751,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ Popup_Handler(ETemp); } else { - if (thermalManager.temp_hotend[0].celsius < thermalManager.temp_hotend[0].target - 2) { + if (thermalManager.temp_hotend[0].is_below_target(-2)) { Popup_Handler(Heating); thermalManager.wait_for_hotend(0); } @@ -1769,7 +1769,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp) Popup_Handler(ETemp); else { - if (thermalManager.temp_hotend[0].celsius < thermalManager.temp_hotend[0].target - 2) { + if (thermalManager.temp_hotend[0].is_below_target(-2)) { Popup_Handler(Heating); thermalManager.wait_for_hotend(0); } @@ -4404,7 +4404,7 @@ void CrealityDWINClass::Popup_Control() { if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp) Popup_Handler(ETemp); else { - if (thermalManager.temp_hotend[0].celsius < thermalManager.temp_hotend[0].target - 2) { + if (thermalManager.temp_hotend[0].is_below_target(-2)) { Popup_Handler(Heating); thermalManager.wait_for_hotend(0); } diff --git a/Marlin/src/lcd/e3v2/marlinui/dwin_string.cpp b/Marlin/src/lcd/e3v2/marlinui/dwin_string.cpp index 30e86270c7..38a8eafe23 100644 --- a/Marlin/src/lcd/e3v2/marlinui/dwin_string.cpp +++ b/Marlin/src/lcd/e3v2/marlinui/dwin_string.cpp @@ -50,12 +50,12 @@ uint8_t read_byte(const uint8_t *byte) { return *byte; } * @ displays an axis name such as XYZUVW, or E for an extruder */ void DWIN_String::add(const char *tpl, const int8_t index, const char *cstr/*=nullptr*/, FSTR_P const fstr/*=nullptr*/) { - wchar_t wchar; + lchar_t wc; while (*tpl) { - tpl = get_utf8_value_cb(tpl, read_byte, &wchar); - if (wchar > 255) wchar |= 0x0080; - const uint8_t ch = uint8_t(wchar & 0x00FF); + tpl = get_utf8_value_cb(tpl, read_byte, wc); + if (wc > 255) wc |= 0x0080; + const uint8_t ch = uint8_t(wc & 0x00FF); if (ch == '=' || ch == '~' || ch == '*') { if (index >= 0) { @@ -80,32 +80,32 @@ void DWIN_String::add(const char *tpl, const int8_t index, const char *cstr/*=nu } void DWIN_String::add(const char *cstr, uint8_t max_len/*=MAX_STRING_LENGTH*/) { - wchar_t wchar; + lchar_t wc; while (*cstr && max_len) { - cstr = get_utf8_value_cb(cstr, read_byte, &wchar); + cstr = get_utf8_value_cb(cstr, read_byte, wc); /* - if (wchar > 255) wchar |= 0x0080; - uint8_t ch = uint8_t(wchar & 0x00FF); + if (wc > 255) wc |= 0x0080; + const uint8_t ch = uint8_t(wc & 0x00FF); add_character(ch); */ - add(wchar); + add(wc); max_len--; } eol(); } -void DWIN_String::add(const wchar_t character) { +void DWIN_String::add(const lchar_t &wc) { int ret; size_t idx = 0; dwin_charmap_t pinval; dwin_charmap_t *copy_address = nullptr; - pinval.uchar = character; + pinval.uchar = wc; pinval.idx = -1; // For 8-bit ASCII just print the single character char str[] = { '?', 0 }; - if (character < 255) { - str[0] = (char)character; + if (wc < 255) { + str[0] = (char)wc; } else { copy_address = nullptr; diff --git a/Marlin/src/lcd/e3v2/marlinui/dwin_string.h b/Marlin/src/lcd/e3v2/marlinui/dwin_string.h index c29777ae7b..686b1aa2b1 100644 --- a/Marlin/src/lcd/e3v2/marlinui/dwin_string.h +++ b/Marlin/src/lcd/e3v2/marlinui/dwin_string.h @@ -29,7 +29,7 @@ #include typedef struct _dwin_charmap_t { - wchar_t uchar; // the unicode char + lchar_t uchar; // the unicode char uint8_t idx; // the glyph of the char in the ROM uint8_t idx2; // the char used to be combined with the idx to simulate a single char } dwin_charmap_t; @@ -69,10 +69,10 @@ class DWIN_String { /** * @brief Append a UTF-8 character * - * @param character The UTF-8 character + * @param wc The UTF-8 character */ - static void add(wchar_t character); - static void set(wchar_t character) { set(); add(character); } + static void add(const lchar_t &wc); + static void set(const lchar_t &wc) { set(); add(wc); } /** * @brief Append / Set C-string diff --git a/Marlin/src/lcd/e3v2/marlinui/lcdprint_dwin.cpp b/Marlin/src/lcd/e3v2/marlinui/lcdprint_dwin.cpp index 278f17fac9..e603882e0c 100644 --- a/Marlin/src/lcd/e3v2/marlinui/lcdprint_dwin.cpp +++ b/Marlin/src/lcd/e3v2/marlinui/lcdprint_dwin.cpp @@ -63,7 +63,7 @@ int lcd_put_dwin_string() { // return < 0 on error // return the advanced cols -int lcd_put_wchar_max(const wchar_t c, const pixel_len_t max_length) { +int lcd_put_lchar_max(const lchar_t &c, const pixel_len_t max_length) { dwin_string.set(c); dwin_string.truncate(max_length); // Draw the char(s) at the cursor and advance the cursor @@ -87,10 +87,10 @@ static int lcd_put_u8str_max_cb(const char * utf8_str, read_byte_cb_t cb_read_by const uint8_t *p = (uint8_t *)utf8_str; dwin_string.set(); while (dwin_string.length < max_length) { - wchar_t ch = 0; - p = get_utf8_value_cb(p, cb_read_byte, &ch); - if (!ch) break; - dwin_string.add(ch); + lchar_t wc; + p = get_utf8_value_cb(p, cb_read_byte, wc); + if (!wc) break; + dwin_string.add(wc); } DWIN_Draw_String(dwin_font.solid, dwin_font.index, dwin_font.fg, dwin_font.bg, cursor.x, cursor.y, dwin_string.string()); lcd_advance_cursor(dwin_string.length); diff --git a/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp b/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp index 0727ab0b70..ab21c7be4a 100644 --- a/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp +++ b/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp @@ -213,7 +213,7 @@ void MarlinUI::draw_status_message(const bool blink) { lcd_put_u8str(status_message); // Fill the rest with spaces - while (slen < max_status_chars) { lcd_put_wchar(' '); ++slen; } + while (slen < max_status_chars) { lcd_put_lchar(' '); ++slen; } } } else { @@ -227,10 +227,10 @@ void MarlinUI::draw_status_message(const bool blink) { // If the string doesn't completely fill the line... if (rlen < max_status_chars) { - lcd_put_wchar('.'); // Always at 1+ spaces left, draw a dot + lcd_put_lchar('.'); // Always at 1+ spaces left, draw a dot uint8_t chars = max_status_chars - rlen; // Amount of space left in characters if (--chars) { // Draw a second dot if there's space - lcd_put_wchar('.'); + lcd_put_lchar('.'); if (--chars) lcd_put_u8str_max(status_message, chars); // Print a second copy of the message } @@ -254,7 +254,7 @@ void MarlinUI::draw_status_message(const bool blink) { lcd_put_u8str_max(status_message, max_status_chars); // Fill the rest with spaces if there are missing spaces - while (slen < max_status_chars) { lcd_put_wchar(' '); ++slen; } + while (slen < max_status_chars) { lcd_put_lchar(' '); ++slen; } } #endif @@ -565,7 +565,7 @@ void MarlinUI::draw_status_message(const bool blink) { #endif // AUTO_BED_LEVELING_UBL - #if ANY(BABYSTEP_ZPROBE_GFX_OVERLAY, MESH_EDIT_GFX_OVERLAY) + #if EITHER(BABYSTEP_ZPROBE_GFX_OVERLAY, MESH_EDIT_GFX_OVERLAY) void MarlinUI::zoffset_overlay(const int8_t dir) { const int rot_up = TERN(OVERLAY_GFX_REVERSE, ICON_RotateCCW, ICON_RotateCW), diff --git a/Marlin/src/lcd/e3v2/proui/ubl_tools.cpp b/Marlin/src/lcd/e3v2/proui/bedlevel_tools.cpp similarity index 78% rename from Marlin/src/lcd/e3v2/proui/ubl_tools.cpp rename to Marlin/src/lcd/e3v2/proui/bedlevel_tools.cpp index 87909d2dd2..e967c26198 100644 --- a/Marlin/src/lcd/e3v2/proui/ubl_tools.cpp +++ b/Marlin/src/lcd/e3v2/proui/bedlevel_tools.cpp @@ -21,19 +21,20 @@ */ /** - * UBL Tools and Mesh Viewer for Pro UI - * Version: 1.0.0 - * Date: 2022/04/13 + * Bed Level Tools for Pro UI + * Extended by: Miguel A. Risco-Castillo (MRISCOC) + * Version: 2.0.0 + * Date: 2022/05/23 * - * Original Author: Henri-J-Norden - * Original Source: https://github.com/Jyers/Marlin/pull/126 + * Based on the original work of: Henri-J-Norden + * https://github.com/Jyers/Marlin/pull/126 */ #include "../../../inc/MarlinConfigPre.h" +#include "bedlevel_tools.h" -#if BOTH(DWIN_LCD_PROUI, AUTO_BED_LEVELING_UBL) +#if BOTH(DWIN_LCD_PROUI, HAS_LEVELING) -#include "ubl_tools.h" #include "../../marlinui.h" #include "../../../core/types.h" #include "dwin.h" @@ -47,27 +48,29 @@ #include "../../../libs/least_squares_fit.h" #include "../../../libs/vector_3.h" -UBLMeshToolsClass ubl_tools; +BedLevelToolsClass BedLevelTools; -#if ENABLED(USE_UBL_VIEWER) - bool UBLMeshToolsClass::viewer_asymmetric_range = false; - bool UBLMeshToolsClass::viewer_print_value = false; +#if USE_UBL_VIEWER + bool BedLevelToolsClass::viewer_asymmetric_range = false; + bool BedLevelToolsClass::viewer_print_value = false; #endif -bool UBLMeshToolsClass::goto_mesh_value = false; -uint8_t UBLMeshToolsClass::tilt_grid = 1; +bool BedLevelToolsClass::goto_mesh_value = false; +uint8_t BedLevelToolsClass::mesh_x = 0; +uint8_t BedLevelToolsClass::mesh_y = 0; +uint8_t BedLevelToolsClass::tilt_grid = 1; bool drawing_mesh = false; char cmd[MAX_CMD_SIZE+16], str_1[16], str_2[16], str_3[16]; #if ENABLED(AUTO_BED_LEVELING_UBL) - void UBLMeshToolsClass::manual_value_update(const uint8_t mesh_x, const uint8_t mesh_y, bool undefined/*=false*/) { + void BedLevelToolsClass::manual_value_update(const uint8_t mesh_x, const uint8_t mesh_y, bool undefined/*=false*/) { sprintf_P(cmd, PSTR("M421 I%i J%i Z%s %s"), mesh_x, mesh_y, dtostrf(current_position.z, 1, 3, str_1), undefined ? "N" : ""); gcode.process_subcommands_now(cmd); planner.synchronize(); } - bool UBLMeshToolsClass::create_plane_from_mesh() { + bool BedLevelToolsClass::create_plane_from_mesh() { struct linear_fit_data lsf_results; incremental_LSF_reset(&lsf_results); GRID_LOOP(x, y) { @@ -119,7 +122,7 @@ char cmd[MAX_CMD_SIZE+16], str_1[16], str_2[16], str_3[16]; #else - void UBLMeshToolsClass::manual_value_update(const uint8_t mesh_x, const uint8_t mesh_y) { + void BedLevelToolsClass::manual_value_update(const uint8_t mesh_x, const uint8_t mesh_y) { sprintf_P(cmd, PSTR("G29 I%i J%i Z%s"), mesh_x, mesh_y, dtostrf(current_position.z, 1, 3, str_1)); gcode.process_subcommands_now(cmd); planner.synchronize(); @@ -127,7 +130,8 @@ char cmd[MAX_CMD_SIZE+16], str_1[16], str_2[16], str_3[16]; #endif -void UBLMeshToolsClass::manual_move(const uint8_t mesh_x, const uint8_t mesh_y, bool zmove/*=false*/) { +void BedLevelToolsClass::manual_move(const uint8_t mesh_x, const uint8_t mesh_y, bool zmove/*=false*/) { + gcode.process_subcommands_now(F("G28O")); if (zmove) { planner.synchronize(); current_position.z = goto_mesh_value ? bedlevel.z_values[mesh_x][mesh_y] : Z_CLEARANCE_BETWEEN_PROBES; @@ -149,8 +153,28 @@ void UBLMeshToolsClass::manual_move(const uint8_t mesh_x, const uint8_t mesh_y, } } -float UBLMeshToolsClass::get_max_value() { - float max = __FLT_MIN__; +void BedLevelToolsClass::MoveToXYZ() { + BedLevelTools.goto_mesh_value = true; + BedLevelTools.manual_move(BedLevelTools.mesh_x, BedLevelTools.mesh_y, false); +} +void BedLevelToolsClass::MoveToXY() { + BedLevelTools.goto_mesh_value = false; + BedLevelTools.manual_move(BedLevelTools.mesh_x, BedLevelTools.mesh_y, false); +} +void BedLevelToolsClass::MoveToZ() { + BedLevelTools.goto_mesh_value = true; + BedLevelTools.manual_move(BedLevelTools.mesh_x, BedLevelTools.mesh_y, true); +} +void BedLevelToolsClass::ProbeXY() { + sprintf_P(cmd, PSTR("G30X%sY%s"), + dtostrf(bedlevel.get_mesh_x(BedLevelTools.mesh_x), 1, 2, str_1), + dtostrf(bedlevel.get_mesh_y(BedLevelTools.mesh_y), 1, 2, str_2) + ); + gcode.process_subcommands_now(cmd); +} + +float BedLevelToolsClass::get_max_value() { + float max = __FLT_MAX__ * -1; GRID_LOOP(x, y) { if (!isnan(bedlevel.z_values[x][y]) && bedlevel.z_values[x][y] > max) max = bedlevel.z_values[x][y]; @@ -158,7 +182,7 @@ float UBLMeshToolsClass::get_max_value() { return max; } -float UBLMeshToolsClass::get_min_value() { +float BedLevelToolsClass::get_min_value() { float min = __FLT_MAX__; GRID_LOOP(x, y) { if (!isnan(bedlevel.z_values[x][y]) && bedlevel.z_values[x][y] < min) @@ -167,19 +191,20 @@ float UBLMeshToolsClass::get_min_value() { return min; } -bool UBLMeshToolsClass::validate() { - float min = __FLT_MAX__, max = __FLT_MIN__; +bool BedLevelToolsClass::meshvalidate() { + float min = __FLT_MAX__, max = __FLT_MAX__ * -1; GRID_LOOP(x, y) { if (isnan(bedlevel.z_values[x][y])) return false; if (bedlevel.z_values[x][y] < min) min = bedlevel.z_values[x][y]; if (bedlevel.z_values[x][y] > max) max = bedlevel.z_values[x][y]; } - return max <= UBL_Z_OFFSET_MAX && min >= UBL_Z_OFFSET_MIN; + return WITHIN(max, MESH_Z_OFFSET_MIN, MESH_Z_OFFSET_MAX); } -#if ENABLED(USE_UBL_VIEWER) - void UBLMeshToolsClass::Draw_Bed_Mesh(int16_t selected /*= -1*/, uint8_t gridline_width /*= 1*/, uint16_t padding_x /*= 8*/, uint16_t padding_y_top /*= 40 + 53 - 7*/) { +#if USE_UBL_VIEWER + + void BedLevelToolsClass::Draw_Bed_Mesh(int16_t selected /*= -1*/, uint8_t gridline_width /*= 1*/, uint16_t padding_x /*= 8*/, uint16_t padding_y_top /*= 40 + 53 - 7*/) { drawing_mesh = true; const uint16_t total_width_px = DWIN_WIDTH - padding_x - padding_x; const uint16_t cell_width_px = total_width_px / (GRID_MAX_POINTS_X); @@ -237,7 +262,7 @@ bool UBLMeshToolsClass::validate() { } } - void UBLMeshToolsClass::Set_Mesh_Viewer_Status() { // TODO: draw gradient with values as a legend instead + void BedLevelToolsClass::Set_Mesh_Viewer_Status() { // TODO: draw gradient with values as a legend instead float v_max = abs(get_max_value()), v_min = abs(get_min_value()), range = _MAX(v_min, v_max); if (v_min > 3e+10F) v_min = 0.0000001; if (v_max > 3e+10F) v_max = 0.0000001; @@ -255,6 +280,7 @@ bool UBLMeshToolsClass::validate() { ui.set_status(msg); drawing_mesh = false; } -#endif -#endif // DWIN_LCD_PROUI && AUTO_BED_LEVELING_UBL +#endif // USE_UBL_VIEWER + +#endif // DWIN_LCD_PROUI && HAS_LEVELING diff --git a/Marlin/src/lcd/e3v2/proui/ubl_tools.h b/Marlin/src/lcd/e3v2/proui/bedlevel_tools.h similarity index 64% rename from Marlin/src/lcd/e3v2/proui/ubl_tools.h rename to Marlin/src/lcd/e3v2/proui/bedlevel_tools.h index 563794a463..9373d593f9 100644 --- a/Marlin/src/lcd/e3v2/proui/ubl_tools.h +++ b/Marlin/src/lcd/e3v2/proui/bedlevel_tools.h @@ -1,10 +1,9 @@ -/** - * UBL Tools and Mesh Viewer for Pro UI - * Version: 1.0.0 - * Date: 2022/04/13 +/* + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] * - * Original Author: Henri-J-Norden (https://github.com/Henri-J-Norden) - * Original Source: https://github.com/Jyers/Marlin/pull/135 + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,22 +19,37 @@ * along with this program. If not, see . * */ + +/** + * Bed Level Tools for Pro UI + * Extended by: Miguel A. Risco-Castillo (MRISCOC) + * Version: 2.0.0 + * Date: 2022/05/23 + * + * Based on the original work of: Henri-J-Norden + * https://github.com/Jyers/Marlin/pull/126 + */ + #pragma once #include "../../../inc/MarlinConfigPre.h" -//#define USE_UBL_VIEWER 1 +#if ENABLED(AUTO_BED_LEVELING_UBL) + //#define USE_UBL_VIEWER 1 +#endif -#define UBL_Z_OFFSET_MIN -3.0 -#define UBL_Z_OFFSET_MAX 3.0 +#define MESH_Z_OFFSET_MIN -3.0 +#define MESH_Z_OFFSET_MAX 3.0 -class UBLMeshToolsClass { +class BedLevelToolsClass { public: - #if ENABLED(USE_UBL_VIEWER) + #if USE_UBL_VIEWER static bool viewer_asymmetric_range; static bool viewer_print_value; #endif static bool goto_mesh_value; + static uint8_t mesh_x; + static uint8_t mesh_y; static uint8_t tilt_grid; #if ENABLED(AUTO_BED_LEVELING_UBL) @@ -45,15 +59,19 @@ class UBLMeshToolsClass { static void manual_value_update(const uint8_t mesh_x, const uint8_t mesh_y); #endif static void manual_move(const uint8_t mesh_x, const uint8_t mesh_y, bool zmove=false); + static void MoveToXYZ(); + static void MoveToXY(); + static void MoveToZ(); + static void ProbeXY(); static float get_max_value(); static float get_min_value(); - static bool validate(); - #if ENABLED(USE_UBL_VIEWER) + static bool meshvalidate(); + #if USE_UBL_VIEWER static void Draw_Bed_Mesh(int16_t selected = -1, uint8_t gridline_width = 1, uint16_t padding_x = 8, uint16_t padding_y_top = 40 + 53 - 7); static void Set_Mesh_Viewer_Status(); #endif }; -extern UBLMeshToolsClass ubl_tools; +extern BedLevelToolsClass BedLevelTools; void Goto_MeshViewer(); diff --git a/Marlin/src/lcd/e3v2/proui/dwin.cpp b/Marlin/src/lcd/e3v2/proui/dwin.cpp index 07b134471b..f51da4cf5a 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin.cpp @@ -99,19 +99,20 @@ #define HAS_ONESTEP_LEVELING 1 #endif -#if HAS_MESH || HAS_ONESTEP_LEVELING +#if HAS_MESH || (HAS_LEVELING && HAS_ZOFFSET_ITEM) #include "../../../feature/bedlevel/bedlevel.h" + #include "bedlevel_tools.h" #endif #if HAS_BED_PROBE #include "../../../module/probe.h" #endif -#ifdef BLTOUCH_HS_MODE +#if ENABLED(BLTOUCH) #include "../../../feature/bltouch.h" #endif -#if ANY(BABYSTEPPING, HAS_BED_PROBE, HAS_WORKSPACE_OFFSET) +#if EITHER(BABYSTEPPING, HAS_BED_PROBE) #define HAS_ZOFFSET_ITEM 1 #if ENABLED(BABYSTEPPING) #include "../../../feature/babystep.h" @@ -141,10 +142,6 @@ #include "meshviewer.h" #endif -#if ENABLED(AUTO_BED_LEVELING_UBL) - #include "ubl_tools.h" -#endif - #if ENABLED(PRINTCOUNTER) #include "printstats.h" #endif @@ -157,16 +154,14 @@ #include "../../../feature/leds/leds.h" #endif -#include -#include -#include +#if HAS_LOCKSCREEN + #include "lockscreen.h" +#endif #ifndef MACHINE_SIZE #define MACHINE_SIZE STRINGIFY(X_BED_SIZE) "x" STRINGIFY(Y_BED_SIZE) "x" STRINGIFY(Z_MAX_POS) #endif -#include "lockscreen.h" - #define PAUSE_HEAT #define MENU_CHAR_LIMIT 24 @@ -251,6 +246,7 @@ constexpr float max_feedrate_edit_values[] = { 1000, 1000, 10, 50 } #endif ; + constexpr float max_acceleration_edit_values[] = #ifdef MAX_ACCEL_EDIT_VALUES MAX_ACCEL_EDIT_VALUES @@ -258,6 +254,7 @@ constexpr float max_acceleration_edit_values[] = { 1000, 1000, 200, 2000 } #endif ; + #if HAS_CLASSIC_JERK constexpr float max_jerk_edit_values[] = #ifdef MAX_JERK_EDIT_VALUES @@ -305,7 +302,9 @@ MenuClass *FilamentMenu = nullptr; MenuClass *TemperatureMenu = nullptr; MenuClass *MaxSpeedMenu = nullptr; MenuClass *MaxAccelMenu = nullptr; -MenuClass *MaxJerkMenu = nullptr; +#if HAS_CLASSIC_JERK + MenuClass *MaxJerkMenu = nullptr; +#endif MenuClass *StepsMenu = nullptr; MenuClass *HotendPIDMenu = nullptr; MenuClass *BedPIDMenu = nullptr; @@ -552,14 +551,9 @@ void Popup_window_PauseOrStop() { #endif // Draw status line -void DWIN_DrawStatusLine(const char *text) { +void DWIN_DrawStatusLine() { DWIN_Draw_Rectangle(1, HMI_data.StatusBg_Color, 0, STATUS_Y, DWIN_WIDTH, STATUS_Y + 20); - if (text) DWINUI::Draw_CenteredString(HMI_data.StatusTxt_Color, STATUS_Y + 2, text); -} - -void DWIN_DrawStatusLine(FSTR_P fstr) { - DWIN_Draw_Rectangle(1, HMI_data.StatusBg_Color, 0, STATUS_Y, DWIN_WIDTH, STATUS_Y + 20); - if (fstr) DWINUI::Draw_CenteredString(HMI_data.StatusTxt_Color, STATUS_Y + 2, fstr); + DWINUI::Draw_CenteredString(HMI_data.StatusTxt_Color, STATUS_Y + 2, ui.status_message); } // Clear & reset status line @@ -588,7 +582,7 @@ void DWIN_DrawStatusMessage() { // If the string fits the status line do not scroll it if (slen <= LCD_WIDTH) { if (hash_changed) { - DWIN_DrawStatusLine(ui.status_message); + DWIN_DrawStatusLine(); hash_changed = false; } } @@ -620,7 +614,7 @@ void DWIN_DrawStatusMessage() { if (hash_changed) { ui.status_message[LCD_WIDTH] = 0; - DWIN_DrawStatusLine(ui.status_message); + DWIN_DrawStatusLine(); hash_changed = false; } @@ -663,7 +657,7 @@ void ICON_ResumeOrPause() { } // Update filename on print -void DWIN_Print_Header(const char *text = nullptr) { +void DWIN_Print_Header(const char *text=nullptr) { static char headertxt[31] = ""; // Print header text if (text) { const int8_t size = _MIN(30U, strlen_P(text)); @@ -1099,7 +1093,7 @@ void DWIN_Draw_Dashboard() { DWINUI::Draw_Int(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 3, 195 + 2 * STAT_CHR_W, 384, thermalManager.fan_speed[0]); #endif - #if BOTH(BABYSTEPPING, HAS_BED_PROBE) + #if HAS_ZOFFSET_ITEM DWINUI::Draw_Icon(planner.leveling_active ? ICON_SetZOffset : ICON_Zoffset, 187, 416); #endif @@ -1370,13 +1364,15 @@ void Draw_Main_Area() { case ESDiagProcess: Draw_EndStopDiag(); break; #endif case Popup: popupDraw(); break; - case Locked: lockScreen.draw(); break; + #if HAS_LOCKSCREEN + case Locked: lockScreen.draw(); break; + #endif case Menu: case SetInt: case SetPInt: case SetIntNoDraw: case SetFloat: - case SetPFloat: ReDrawMenu(); break; + case SetPFloat: ReDrawMenu(true); break; default: break; } } @@ -1567,7 +1563,9 @@ void DWIN_HandleScreen() { case PrintProcess: HMI_Printing(); break; case Popup: HMI_Popup(); break; case Leveling: break; - case Locked: HMI_LockScreen(); break; + #if HAS_LOCKSCREEN + case Locked: HMI_LockScreen(); break; + #endif case PrintDone: TERN_(HAS_ESDIAG, case ESDiagProcess:) case WaitResponse: HMI_WaitForUser(); break; @@ -1769,7 +1767,7 @@ void DWIN_Print_Aborted() { Goto_PrintDone(); } -// Progress Bar update +// Progress and remaining time update void DWIN_M73() { if (parser.seenval('P')) { _percent_done = parser.value_byte(); @@ -1827,7 +1825,7 @@ void DWIN_SetDataDefaults() { #endif TERN_(BAUD_RATE_GCODE, SetBaud250K()); #if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS) - leds.set_default(); + TERN_(LED_COLOR_PRESETS, leds.set_default()); ApplyLEDColor(); #endif } @@ -1843,17 +1841,12 @@ void DWIN_CopySettingsFrom(const char * const buff) { TERN_(PREVENT_COLD_EXTRUSION, ApplyExtMinT()); feedrate_percentage = 100; TERN_(BAUD_RATE_GCODE, HMI_SetBaudRate()); - #if BOTH(CASE_LIGHT_MENU, CASELIGHT_USES_BRIGHTNESS) - // Apply Case light brightness - caselight.brightness = HMI_data.CaseLight_Brightness; - caselight.update_brightness(); - #endif #if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS) leds.set_color( - (HMI_data.LED_Color >> 16) & 0xFF, - (HMI_data.LED_Color >> 8) & 0xFF, - (HMI_data.LED_Color >> 0) & 0xFF - OPTARG(HAS_WHITE_LED, (HMI_data.LED_Color >> 24) & 0xFF) + HMI_data.Led_Color.r, + HMI_data.Led_Color.g, + HMI_data.Led_Color.b + OPTARG(HAS_WHITE_LED, HMI_data.Led_Color.w) ); leds.update(); #endif @@ -1880,7 +1873,7 @@ void DWIN_InitScreen() { index_file = MROWS; hash_changed = true; last_E = 0; - DWIN_DrawStatusLine(FSTR_P(nullptr)); + DWIN_DrawStatusLine(); DWIN_Draw_Dashboard(); Goto_Main_Menu(); } @@ -1935,7 +1928,7 @@ void DWIN_RedrawScreen() { case PAUSE_MESSAGE_PARKING: DWIN_Popup_Pause(GET_TEXT_F(MSG_PAUSE_PRINT_PARKING)); break; // M125 case PAUSE_MESSAGE_CHANGING: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_INIT)); break; // pause_print (M125, M600) case PAUSE_MESSAGE_WAITING: DWIN_Popup_Pause(GET_TEXT_F(MSG_ADVANCED_PAUSE_WAITING), BTN_Continue); break; - case PAUSE_MESSAGE_INSERT: DWIN_Popup_Continue(ICON_BLTouch, GET_TEXT_F(MSG_ADVANCED_PAUSE), GET_TEXT_F(MSG_FILAMENT_CHANGE_INSERT)); break; + case PAUSE_MESSAGE_INSERT: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_INSERT), BTN_Continue); break; case PAUSE_MESSAGE_LOAD: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_LOAD)); break; case PAUSE_MESSAGE_UNLOAD: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_UNLOAD)); break; // Unload of pause and Unload of M702 case PAUSE_MESSAGE_PURGE: @@ -1988,28 +1981,32 @@ void DWIN_RedrawScreen() { } #endif // HAS_MESH -void DWIN_LockScreen() { - if (checkkey != Locked) { - lockScreen.rprocess = checkkey; - checkkey = Locked; - lockScreen.init(); + +#if HAS_LOCKSCREEN + + void DWIN_LockScreen() { + if (checkkey != Locked) { + lockScreen.rprocess = checkkey; + checkkey = Locked; + lockScreen.init(); + } } -} -void DWIN_UnLockScreen() { - if (checkkey == Locked) { - checkkey = lockScreen.rprocess; - Draw_Main_Area(); + void DWIN_UnLockScreen() { + if (checkkey == Locked) { + checkkey = lockScreen.rprocess; + Draw_Main_Area(); + } } -} -void HMI_LockScreen() { - EncoderState encoder_diffState = get_encoder_state(); - if (encoder_diffState == ENCODER_DIFF_NO) return; - lockScreen.onEncoder(encoder_diffState); - if (lockScreen.isUnlocked()) DWIN_UnLockScreen(); -} + void HMI_LockScreen() { + EncoderState encoder_diffState = get_encoder_state(); + if (encoder_diffState == ENCODER_DIFF_NO) return; + lockScreen.onEncoder(encoder_diffState); + if (lockScreen.isUnlocked()) DWIN_UnLockScreen(); + } +#endif // HAS_LOCKSCREEN #if HAS_GCODE_PREVIEW @@ -2051,7 +2048,8 @@ void HMI_LockScreen() { #if ENABLED(EEPROM_SETTINGS) void WriteEeprom() { - DWIN_DrawStatusLine(GET_TEXT_F(MSG_STORE_EEPROM)); + ui.set_status(GET_TEXT_F(MSG_STORE_EEPROM)); + DWIN_DrawStatusLine(); DWIN_UpdateLCD(); DONE_BUZZ(settings.save()); } @@ -2106,11 +2104,13 @@ void HomeX() { queue.inject(F("G28X")); } void HomeY() { queue.inject(F("G28Y")); } void HomeZ() { queue.inject(F("G28Z")); } -void SetHome() { +#if HAS_HOME_OFFSET // Apply workspace offset, making the current position 0,0,0 + void SetHome() { queue.inject(F("G92X0Y0Z0")); DONE_BUZZ(true); -} + } +#endif #if HAS_ZOFFSET_ITEM @@ -2132,22 +2132,25 @@ void SetHome() { void SetMoveZto0() { #if ENABLED(Z_SAFE_HOMING) char cmd[54], str_1[5], str_2[5]; - sprintf_P(cmd, PSTR("G28XYO\nG28Z\nG0X%sY%sF5000\nM420S0\nG0Z0F300\nM400"), + sprintf_P(cmd, PSTR("G28XYO\nG28Z\nG0X%sY%sF5000\nG0Z0F300\nM400"), dtostrf(Z_SAFE_HOMING_X_POINT, 1, 1, str_1), dtostrf(Z_SAFE_HOMING_Y_POINT, 1, 1, str_2) ); gcode.process_subcommands_now(cmd); #else - gcode.process_subcommands_now(F("G28O\nM420S0\nG0Z0F300\nM400")); + TERN_(HAS_LEVELING, set_bed_leveling_enabled(false)); + gcode.process_subcommands_now(F("G28O\nG0Z0F300\nM400")); #endif ui.reset_status(); DONE_BUZZ(true); } - void HomeZandDisable() { - SetMoveZto0(); - DisableMotors(); - } + #if !HAS_BED_PROBE + void HomeZandDisable() { + SetMoveZto0(); + DisableMotors(); + } + #endif #endif // HAS_ZOFFSET_ITEM @@ -2223,10 +2226,9 @@ void SetPID(celsius_t t, heater_id_t h) { #endif #if ENABLED(BAUD_RATE_GCODE) - void HMI_SetBaudRate() { - if (HMI_data.Baud115K) SetBaud115K(); else SetBaud250K(); - } + void HMI_SetBaudRate() { HMI_data.Baud115K ? SetBaud115K() : SetBaud250K(); } void SetBaudRate() { + HMI_data.Baud115K ^= true; HMI_SetBaudRate(); Draw_Chkb_Line(CurrentMenu->line(), HMI_data.Baud115K); DWIN_UpdateLCD(); @@ -2264,7 +2266,9 @@ void SetPID(celsius_t t, heater_id_t h) { } #endif #if HAS_COLOR_LEDS - void ApplyLEDColor() { HMI_data.LED_Color = TERN0(HAS_WHITE_LED, (leds.color.w << 24)) | (leds.color.r << 16) | (leds.color.g << 8) | leds.color.b; } + void ApplyLEDColor() { + HMI_data.Led_Color = LEDColor( {leds.color.r, leds.color.g, leds.color.b OPTARG(HAS_WHITE_LED, HMI_data.Led_Color.w) } ); + } void LiveLEDColor(uint8_t *color) { *color = MenuData.Value; leds.update(); } void LiveLEDColorR() { LiveLEDColor(&leds.color.r); } void LiveLEDColorG() { LiveLEDColor(&leds.color.g); } @@ -2840,9 +2844,6 @@ void onDrawGetColorItem(MenuItemClass* menuitem, int8_t line) { DWIN_Draw_HLine(HMI_data.SplitLine_Color, 16, MYPOS(line + 1), 240); } -#if HAS_FILAMENT_SENSOR - void onDrawRunoutEnable(MenuItemClass* menuitem, int8_t line) { onDrawChkbMenu(menuitem, line, runout.enabled); } -#endif void onDrawPIDi(MenuItemClass* menuitem, int8_t line) { onDrawFloatMenu(menuitem, line, 2, unscalePID_i(*(float*)static_cast(menuitem)->value)); } void onDrawPIDd(MenuItemClass* menuitem, int8_t line) { onDrawFloatMenu(menuitem, line, 2, unscalePID_d(*(float*)static_cast(menuitem)->value)); } @@ -3249,7 +3250,9 @@ void Draw_AdvancedSettings_Menu() { MENU_ITEM_F(ICON_PrintStats, MSG_INFO_STATS_MENU, onDrawSubMenu, Goto_PrintStats); MENU_ITEM_F(ICON_PrintStatsReset, MSG_INFO_PRINT_COUNT_RESET, onDrawSubMenu, PrintStats.Reset); #endif - MENU_ITEM_F(ICON_Lock, MSG_LOCKSCREEN, onDrawMenuItem, DWIN_LockScreen); + #if HAS_LOCKSCREEN + MENU_ITEM_F(ICON_Lock, MSG_LOCKSCREEN, onDrawMenuItem, DWIN_LockScreen); + #endif } ui.reset_status(true); UpdateMenu(AdvancedSettings); @@ -3295,12 +3298,15 @@ void Draw_Move_Menu() { EDIT_ITEM_F(ICON_ProbeOffsetX, MSG_ZPROBE_XOFFSET, onDrawPFloatMenu, SetProbeOffsetX, &probe.offset.x); EDIT_ITEM_F(ICON_ProbeOffsetY, MSG_ZPROBE_YOFFSET, onDrawPFloatMenu, SetProbeOffsetY, &probe.offset.y); EDIT_ITEM_F(ICON_ProbeOffsetZ, MSG_ZPROBE_ZOFFSET, onDrawPFloat2Menu, SetProbeOffsetZ, &probe.offset.z); - #ifdef BLTOUCH_HS_MODE - EDIT_ITEM_F(ICON_HSMode, MSG_ENABLE_HS_MODE, onDrawChkbMenu, SetHSMode, &bltouch.high_speed_mode); + #if ENABLED(BLTOUCH) + MENU_ITEM_F(ICON_ProbeStow, MSG_MANUAL_STOW, onDrawMenuItem, ProbeStow); + MENU_ITEM_F(ICON_ProbeDeploy, MSG_MANUAL_DEPLOY, onDrawMenuItem, ProbeDeploy); + MENU_ITEM_F(ICON_BltouchReset, MSG_BLTOUCH_RESET, onDrawMenuItem, bltouch._reset); + #ifdef BLTOUCH_HS_MODE + EDIT_ITEM_F(ICON_HSMode, MSG_ENABLE_HS_MODE, onDrawChkbMenu, SetHSMode, &bltouch.high_speed_mode); + #endif #endif MENU_ITEM_F(ICON_ProbeTest, MSG_M48_TEST, onDrawMenuItem, ProbeTest); - MENU_ITEM_F(ICON_ProbeStow, MSG_MANUAL_STOW, onDrawMenuItem, ProbeStow); - MENU_ITEM_F(ICON_ProbeDeploy, MSG_MANUAL_DEPLOY, onDrawMenuItem, ProbeDeploy); } UpdateMenu(ProbeSetMenu); } @@ -3384,24 +3390,35 @@ void Draw_GetColor_Menu() { #endif #if ENABLED(LED_CONTROL_MENU) - void Draw_LedControl_Menu() { - checkkey = Menu; - if (SetMenu(LedControlMenu, GET_TEXT_F(MSG_LED_CONTROL), 6)) { - BACK_ITEM(Draw_Control_Menu); - #if !BOTH(CASE_LIGHT_MENU, CASE_LIGHT_USE_NEOPIXEL) - EDIT_ITEM_F(ICON_LedControl, MSG_LEDS, onDrawChkbMenu, SetLedStatus, &leds.lights_on); - #endif - #if HAS_COLOR_LEDS + void Draw_LedControl_Menu() { + checkkey = Menu; + if (SetMenu(LedControlMenu, GET_TEXT_F(MSG_LED_CONTROL), 6)) { + BACK_ITEM(Draw_Control_Menu); + #if !BOTH(CASE_LIGHT_MENU, CASE_LIGHT_USE_NEOPIXEL) + EDIT_ITEM_F(ICON_LedControl, MSG_LEDS, onDrawChkbMenu, SetLedStatus, &leds.lights_on); + #endif + #if HAS_COLOR_LEDS + #if ENABLED(LED_COLOR_PRESETS) + MENU_ITEM_F(ICON_LedControl, MSG_SET_LEDS_WHITE, onDrawMenuItem, leds.set_white); + MENU_ITEM_F(ICON_LedControl, MSG_SET_LEDS_RED, onDrawMenuItem, leds.set_red); + MENU_ITEM_F(ICON_LedControl, MSG_SET_LEDS_ORANGE, onDrawMenuItem, leds.set_orange); + MENU_ITEM_F(ICON_LedControl, MSG_SET_LEDS_YELLOW, onDrawMenuItem, leds.set_yellow); + MENU_ITEM_F(ICON_LedControl, MSG_SET_LEDS_GREEN, onDrawMenuItem, leds.set_green); + MENU_ITEM_F(ICON_LedControl, MSG_SET_LEDS_BLUE, onDrawMenuItem, leds.set_blue); + MENU_ITEM_F(ICON_LedControl, MSG_SET_LEDS_INDIGO, onDrawMenuItem, leds.set_indigo); + MENU_ITEM_F(ICON_LedControl, MSG_SET_LEDS_VIOLET, onDrawMenuItem, leds.set_violet); + #else EDIT_ITEM_F(ICON_LedControl, MSG_COLORS_RED, onDrawPInt8Menu, SetLEDColorR, &leds.color.r); EDIT_ITEM_F(ICON_LedControl, MSG_COLORS_GREEN, onDrawPInt8Menu, SetLEDColorG, &leds.color.g); EDIT_ITEM_F(ICON_LedControl, MSG_COLORS_BLUE, onDrawPInt8Menu, SetLEDColorB, &leds.color.b); #if ENABLED(HAS_WHITE_LED) - EDIT_ITEM_F(ICON_LedControl, MSG_COLORS_WHITE, onDrawPInt8Menu, SetLedColorW, &leds.color.w); + EDIT_ITEM_F(ICON_LedControl, MSG_COLORS_WHITE, onDrawPInt8Menu, SetLEDColorW, &leds.color.w); #endif #endif - } - UpdateMenu(LedControlMenu); + #endif } + UpdateMenu(LedControlMenu); + } #endif void Draw_Tune_Menu() { @@ -3432,7 +3449,9 @@ void Draw_Tune_Menu() { #if ENABLED(FWRETRACT) MENU_ITEM_F(ICON_FWRetract, MSG_FWRETRACT, onDrawSubMenu, Draw_FWRetract_Menu); #endif - MENU_ITEM_F(ICON_Lock, MSG_LOCKSCREEN, onDrawMenuItem, DWIN_LockScreen); + #if HAS_LOCKSCREEN + MENU_ITEM_F(ICON_Lock, MSG_LOCKSCREEN, onDrawMenuItem, DWIN_LockScreen); + #endif #if HAS_LCD_BRIGHTNESS EDIT_ITEM_F(ICON_Brightness, MSG_BRIGHTNESS, onDrawPInt8Menu, SetBrightness, &ui.brightness); MENU_ITEM_F(ICON_Brightness, MSG_BRIGHTNESS_OFF, onDrawMenuItem, TurnOffBacklight); @@ -3750,15 +3769,14 @@ void Draw_Steps_Menu() { #endif #if ENABLED(MESH_EDIT_MENU) - uint8_t mesh_x = 0, mesh_y = 0; #define Z_OFFSET_MIN -3 #define Z_OFFSET_MAX 3 - void LiveEditMesh() { ((MenuItemPtrClass*)EditZValueItem)->value = &bedlevel.z_values[HMI_value.Select ? mesh_x : MenuData.Value][HMI_value.Select ? MenuData.Value : mesh_y]; EditZValueItem->redraw(); } - void ApplyEditMeshX() { mesh_x = MenuData.Value; } - void SetEditMeshX() { HMI_value.Select = 0; SetIntOnClick(0, GRID_MAX_POINTS_X - 1, mesh_x, ApplyEditMeshX, LiveEditMesh); } - void ApplyEditMeshY() { mesh_y = MenuData.Value; } - void SetEditMeshY() { HMI_value.Select = 1; SetIntOnClick(0, GRID_MAX_POINTS_Y - 1, mesh_y, ApplyEditMeshY, LiveEditMesh); } + void LiveEditMesh() { ((MenuItemPtrClass*)EditZValueItem)->value = &bedlevel.z_values[HMI_value.Select ? BedLevelTools.mesh_x : MenuData.Value][HMI_value.Select ? MenuData.Value : BedLevelTools.mesh_y]; EditZValueItem->redraw(); } + void ApplyEditMeshX() { BedLevelTools.mesh_x = MenuData.Value; } + void SetEditMeshX() { HMI_value.Select = 0; SetIntOnClick(0, GRID_MAX_POINTS_X - 1, BedLevelTools.mesh_x, ApplyEditMeshX, LiveEditMesh); } + void ApplyEditMeshY() { BedLevelTools.mesh_y = MenuData.Value; } + void SetEditMeshY() { HMI_value.Select = 1; SetIntOnClick(0, GRID_MAX_POINTS_Y - 1, BedLevelTools.mesh_y, ApplyEditMeshY, LiveEditMesh); } void SetEditZValue() { SetPFloatOnClick(Z_OFFSET_MIN, Z_OFFSET_MAX, 3); } #endif #endif @@ -3772,14 +3790,14 @@ void Draw_Steps_Menu() { onDrawIntMenu(menuitem, line, bedlevel.storage_slot); } - void ApplyUBLTiltGrid() { ubl_tools.tilt_grid = MenuData.Value; } - void SetUBLTiltGrid() { SetIntOnClick(1, 3, ubl_tools.tilt_grid, ApplyUBLTiltGrid); } + void ApplyUBLTiltGrid() { BedLevelTools.tilt_grid = MenuData.Value; } + void SetUBLTiltGrid() { SetIntOnClick(1, 3, BedLevelTools.tilt_grid, ApplyUBLTiltGrid); } void UBLTiltMesh() { if (bedlevel.storage_slot < 0) bedlevel.storage_slot = 0; char buf[15]; - if (ubl_tools.tilt_grid > 1) { - sprintf_P(buf, PSTR("G28O\nG29 J%i"), ubl_tools.tilt_grid); + if (BedLevelTools.tilt_grid > 1) { + sprintf_P(buf, PSTR("G28O\nG29 J%i"), BedLevelTools.tilt_grid); gcode.process_subcommands_now(buf); } else @@ -3788,16 +3806,10 @@ void Draw_Steps_Menu() { } void UBLSmartFillMesh() { - bedlevel.smart_fill_mesh(); + LOOP_L_N(x, GRID_MAX_POINTS_Y) bedlevel.smart_fill_mesh(); LCD_MESSAGE(MSG_UBL_MESH_FILLED); } - bool UBLValidMesh() { - const bool valid = ubl_tools.validate(); - if (!valid) bedlevel.invalidate(); - return valid; - } - void UBLSaveMesh() { if (bedlevel.storage_slot < 0) bedlevel.storage_slot = 0; settings.store_mesh(bedlevel.storage_slot); @@ -3808,19 +3820,12 @@ void Draw_Steps_Menu() { void UBLLoadMesh() { if (bedlevel.storage_slot < 0) bedlevel.storage_slot = 0; settings.load_mesh(bedlevel.storage_slot); - if (UBLValidMesh()) { - ui.status_printf(0, GET_TEXT_F(MSG_MESH_LOADED), bedlevel.storage_slot); - DONE_BUZZ(true); - } - else { - LCD_MESSAGE_F("Invalid Mesh Loaded"); - DONE_BUZZ(false); - } } #endif // AUTO_BED_LEVELING_UBL #if HAS_MESH + void Draw_MeshSet_Menu() { checkkey = Menu; if (SetMenu(MeshMenu, GET_TEXT_F(MSG_MESH_LEVELING), 15)) { @@ -3837,7 +3842,7 @@ void Draw_Steps_Menu() { EDIT_ITEM_F(ICON_UBLActive, MSG_UBL_STORAGE_SLOT, onDrawUBLSlot, SetUBLSlot, &bedlevel.storage_slot); MENU_ITEM_F(ICON_UBLActive, MSG_UBL_SAVE_MESH, onDrawMenuItem, UBLSaveMesh); MENU_ITEM_F(ICON_UBLActive, MSG_UBL_LOAD_MESH, onDrawMenuItem, UBLLoadMesh); - EDIT_ITEM_F(ICON_UBLActive, MSG_UBL_TILTING_GRID, onDrawPInt8Menu, SetUBLTiltGrid, &ubl_tools.tilt_grid); + EDIT_ITEM_F(ICON_UBLActive, MSG_UBL_TILTING_GRID, onDrawPInt8Menu, SetUBLTiltGrid, &BedLevelTools.tilt_grid); MENU_ITEM_F(ICON_UBLActive, MSG_UBL_TILT_MESH, onDrawMenuItem, UBLTiltMesh); MENU_ITEM_F(ICON_UBLActive, MSG_UBL_SMART_FILLIN, onDrawMenuItem, UBLSmartFillMesh); #endif @@ -3851,13 +3856,15 @@ void Draw_Steps_Menu() { #if ENABLED(MESH_EDIT_MENU) void Draw_EditMesh_Menu() { + if (!leveling_is_valid()) { LCD_MESSAGE(MSG_UBL_MESH_INVALID); return; } + set_bed_leveling_enabled(false); checkkey = Menu; if (SetMenu(EditMeshMenu, GET_TEXT_F(MSG_EDIT_MESH), 4)) { - mesh_x = mesh_y = 0; + BedLevelTools.mesh_x = BedLevelTools.mesh_y = 0; BACK_ITEM(Draw_MeshSet_Menu); - EDIT_ITEM_F(ICON_UBLActive, MSG_MESH_X, onDrawPInt8Menu, SetEditMeshX, &mesh_x); - EDIT_ITEM_F(ICON_UBLActive, MSG_MESH_Y, onDrawPInt8Menu, SetEditMeshY, &mesh_y); - EditZValueItem = EDIT_ITEM_F(ICON_UBLActive, MSG_MESH_EDIT_Z, onDrawPFloat3Menu, SetEditZValue, &bedlevel.z_values[mesh_x][mesh_y]); + EDIT_ITEM_F(ICON_UBLActive, MSG_MESH_X, onDrawPInt8Menu, SetEditMeshX,&BedLevelTools.mesh_x); + EDIT_ITEM_F(ICON_UBLActive, MSG_MESH_Y, onDrawPInt8Menu, SetEditMeshY,&BedLevelTools.mesh_y); + EditZValueItem = EDIT_ITEM_F(ICON_UBLActive, MSG_MESH_EDIT_Z, onDrawPFloat3Menu, SetEditZValue, &bedlevel.z_values[BedLevelTools.mesh_x][BedLevelTools.mesh_y]); } UpdateMenu(EditMeshMenu); } diff --git a/Marlin/src/lcd/e3v2/proui/dwin.h b/Marlin/src/lcd/e3v2/proui/dwin.h index 4f992b3a78..6d36cca92a 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin.h +++ b/Marlin/src/lcd/e3v2/proui/dwin.h @@ -160,8 +160,7 @@ void Goto_PowerLossRecovery(); void Goto_ConfirmToPrint(); void DWIN_Draw_Dashboard(const bool with_update); // Status Area void Draw_Main_Area(); // Redraw main area -void DWIN_DrawStatusLine(const char *text); // Draw simple status text -void DWIN_DrawStatusLine(FSTR_P fstr); +void DWIN_DrawStatusLine(); // Draw simple status text void DWIN_RedrawDash(); // Redraw Dash and Status line void DWIN_RedrawScreen(); // Redraw all screen elements void HMI_MainMenu(); // Main process screen @@ -210,9 +209,11 @@ void DWIN_RebootScreen(); #endif // Utility and extensions -void DWIN_LockScreen(); -void DWIN_UnLockScreen(); -void HMI_LockScreen(); +#if HAS_LOCKSCREEN + void DWIN_LockScreen(); + void DWIN_UnLockScreen(); + void HMI_LockScreen(); +#endif #if HAS_MESH void DWIN_MeshViewer(); #endif diff --git a/Marlin/src/lcd/e3v2/proui/dwin_defines.h b/Marlin/src/lcd/e3v2/proui/dwin_defines.h index 1517acd238..dffc26478d 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin_defines.h +++ b/Marlin/src/lcd/e3v2/proui/dwin_defines.h @@ -28,24 +28,24 @@ * Date: 2022/02/28 */ +#define HAS_GCODE_PREVIEW 1 +#define HAS_PIDPLOT 1 +#define HAS_ESDIAG 1 +#define HAS_LOCKSCREEN 1 //#define DEBUG_DWIN 1 //#define NEED_HEX_PRINT 1 #include "../../../inc/MarlinConfigPre.h" +#include "../common/dwin_color.h" +#if ENABLED(LED_CONTROL_MENU) + #include "../../../feature/leds/leds.h" +#endif #include -#define HAS_ESDIAG 1 -#define HAS_PIDPLOT 1 -#define HAS_GCODE_PREVIEW 1 #if defined(__STM32F1__) || defined(STM32F1) #define DASH_REDRAW 1 #endif -#include "../common/dwin_color.h" -#if ENABLED(LED_CONTROL_MENU) - #include "../../../feature/leds/leds.h" -#endif - #define Def_Background_Color RGB( 1, 12, 8) #define Def_Cursor_color RGB(20, 49, 31) #define Def_TitleBg_color RGB( 0, 23, 16) @@ -65,14 +65,8 @@ #define Def_Indicator_Color Color_White #define Def_Coordinate_Color Color_White #define Def_Button_Color RGB( 0, 23, 16) - -#define HAS_ESDIAG 1 - #if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS) - #define Def_Leds_Color 0xFFFFFFFF -#endif -#if ENABLED(CASELIGHT_USES_BRIGHTNESS) - #define Def_CaseLight_Brightness 255 + #define Def_Leds_Color LEDColorWhite() #endif typedef struct { @@ -115,12 +109,12 @@ typedef struct { bool Baud115K = false; #endif bool FullManualTramming = false; - // Led #if ENABLED(MESH_BED_LEVELING) float ManualZOffset = 0; #endif + // Led #if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS) - uint32_t LED_Color = Def_Leds_Color; + LEDColor Led_Color = Def_Leds_Color; #endif } HMI_data_t; diff --git a/Marlin/src/lcd/e3v2/proui/dwinui.cpp b/Marlin/src/lcd/e3v2/proui/dwinui.cpp index ecb4754a0f..5ed36e7dac 100644 --- a/Marlin/src/lcd/e3v2/proui/dwinui.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwinui.cpp @@ -23,8 +23,8 @@ /** * DWIN Enhanced implementation for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 3.17.1 - * Date: 2022/04/12 + * Version: 3.18.1 + * Date: 2022/07/05 */ #include "../../../inc/MarlinConfigPre.h" @@ -44,7 +44,7 @@ uint16_t DWINUI::pencolor = Color_White; uint16_t DWINUI::textcolor = Def_Text_Color; uint16_t DWINUI::backcolor = Def_Background_Color; uint16_t DWINUI::buttoncolor = Def_Button_Color; -uint8_t DWINUI::font = font8x16; +uint8_t DWINUI::fontid = font8x16; FSTR_P const DWINUI::Author = F(STRING_CONFIG_H_AUTHOR); void (*DWINUI::onTitleDraw)(TitleClass* title) = nullptr; @@ -62,17 +62,15 @@ void DWINUI::init() { textcolor = Def_Text_Color; backcolor = Def_Background_Color; buttoncolor = Def_Button_Color; - font = font8x16; + fontid = font8x16; } // Set text/number font -void DWINUI::setFont(uint8_t cfont) { - font = cfont; -} +void DWINUI::setFont(fontid_t fid) { fontid = fid; } // Get font character width -uint8_t DWINUI::fontWidth(uint8_t cfont) { - switch (cfont) { +uint8_t DWINUI::fontWidth(fontid_t fid) { + switch (fid) { case font6x12 : return 6; case font8x16 : return 8; case font10x20: return 10; @@ -88,8 +86,8 @@ uint8_t DWINUI::fontWidth(uint8_t cfont) { } // Get font character height -uint8_t DWINUI::fontHeight(uint8_t cfont) { - switch (cfont) { +uint8_t DWINUI::fontHeight(fontid_t fid) { + switch (fid) { case font6x12 : return 12; case font8x16 : return 16; case font10x20: return 20; @@ -105,14 +103,10 @@ uint8_t DWINUI::fontHeight(uint8_t cfont) { } // Get screen x coordinates from text column -uint16_t DWINUI::ColToX(uint8_t col) { - return col * fontWidth(font); -} +uint16_t DWINUI::ColToX(uint8_t col) { return col * fontWidth(fontid); } // Get screen y coordinates from text row -uint16_t DWINUI::RowToY(uint8_t row) { - return row * fontHeight(font); -} +uint16_t DWINUI::RowToY(uint8_t row) { return row * fontHeight(fontid); } // Set text/number color void DWINUI::SetColors(uint16_t fgcolor, uint16_t bgcolor, uint16_t alcolor) { @@ -152,9 +146,9 @@ void DWINUI::MoveBy(xy_int_t point) { } // Draw a Centered string using arbitrary x1 and x2 margins -void DWINUI::Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x1, uint16_t x2, uint16_t y, const char * const string) { - const uint16_t x = _MAX(0U, x2 + x1 - strlen_P(string) * fontWidth(size)) / 2 - 1; - DWIN_Draw_String(bShow, size, color, bColor, x, y, string); +void DWINUI::Draw_CenteredString(bool bShow, fontid_t fid, uint16_t color, uint16_t bColor, uint16_t x1, uint16_t x2, uint16_t y, const char * const string) { + const uint16_t x = _MAX(0U, x2 + x1 - strlen_P(string) * fontWidth(fid)) / 2 - 1; + DWIN_Draw_String(bShow, fid, color, bColor, x, y, string); } // Draw a char @@ -164,13 +158,13 @@ void DWINUI::Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint1 // c: ASCII code of char void DWINUI::Draw_Char(uint16_t color, uint16_t x, uint16_t y, const char c) { const char string[2] = { c, 0}; - DWIN_Draw_String(false, font, color, backcolor, x, y, string, 1); + DWIN_Draw_String(false, fontid, color, backcolor, x, y, string, 1); } // Draw a char at cursor position and increment cursor void DWINUI::Draw_Char(uint16_t color, const char c) { Draw_Char(color, cursor.x, cursor.y, c); - MoveBy(fontWidth(font), 0); + MoveBy(fontWidth(fontid), 0); } // Draw a string at cursor position @@ -178,49 +172,49 @@ void DWINUI::Draw_Char(uint16_t color, const char c) { // *string: The string // rlimit: For draw less chars than string length use rlimit void DWINUI::Draw_String(const char * const string, uint16_t rlimit) { - DWIN_Draw_String(false, font, textcolor, backcolor, cursor.x, cursor.y, string, rlimit); - MoveBy(strlen(string) * fontWidth(font), 0); + DWIN_Draw_String(false, fontid, textcolor, backcolor, cursor.x, cursor.y, string, rlimit); + MoveBy(strlen(string) * fontWidth(fontid), 0); } void DWINUI::Draw_String(uint16_t color, const char * const string, uint16_t rlimit) { - DWIN_Draw_String(false, font, color, backcolor, cursor.x, cursor.y, string, rlimit); - MoveBy(strlen(string) * fontWidth(font), 0); + DWIN_Draw_String(false, fontid, color, backcolor, cursor.x, cursor.y, string, rlimit); + MoveBy(strlen(string) * fontWidth(fontid), 0); } // Draw a numeric integer value // bShow: true=display background color; false=don't display background color // signedMode: 1=signed; 0=unsigned -// size: Font size +// fid: Font ID // color: Character color // bColor: Background color // iNum: Number of digits // x/y: Upper-left coordinate // value: Integer value -void DWINUI::Draw_Int(uint8_t bShow, bool signedMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, int32_t value) { +void DWINUI::Draw_Int(uint8_t bShow, bool signedMode, fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, int32_t value) { char nstr[10]; sprintf_P(nstr, PSTR("%*li"), (signedMode ? iNum + 1 : iNum), value); - DWIN_Draw_String(bShow, size, color, bColor, x, y, nstr); + DWIN_Draw_String(bShow, fid, color, bColor, x, y, nstr); } // Draw a numeric float value // bShow: true=display background color; false=don't display background color // signedMode: 1=signed; 0=unsigned -// size: Font size +// fid: Font ID // color: Character color // bColor: Background color // iNum: Number of digits // fNum: Number of decimal digits // x/y: Upper-left coordinate // value: float value -void DWINUI::Draw_Float(uint8_t bShow, bool signedMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { +void DWINUI::Draw_Float(uint8_t bShow, bool signedMode, fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { char nstr[10]; - DWIN_Draw_String(bShow, size, color, bColor, x, y, dtostrf(value, iNum + (signedMode ? 2:1) + fNum, fNum, nstr)); + DWIN_Draw_String(bShow, fid, color, bColor, x, y, dtostrf(value, iNum + (signedMode ? 2:1) + fNum, fNum, nstr)); } // ------------------------- Buttons ------------------------------// void DWINUI::Draw_Button(uint16_t color, uint16_t bcolor, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, const char * const caption) { DWIN_Draw_Rectangle(1, bcolor, x1, y1, x2, y2); - Draw_CenteredString(0, font, color, bcolor, x1, x2, (y2 + y1 - fontHeight())/2, caption); + Draw_CenteredString(0, fontid, color, bcolor, x1, x2, (y2 + y1 - fontHeight())/2, caption); } void DWINUI::Draw_Button(uint8_t id, uint16_t x, uint16_t y) { diff --git a/Marlin/src/lcd/e3v2/proui/dwinui.h b/Marlin/src/lcd/e3v2/proui/dwinui.h index f8ff091769..a544471831 100644 --- a/Marlin/src/lcd/e3v2/proui/dwinui.h +++ b/Marlin/src/lcd/e3v2/proui/dwinui.h @@ -24,8 +24,8 @@ /** * DWIN Enhanced implementation for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 3.17.1 - * Date: 2022/04/12 + * Version: 3.18.1 + * Date: 2022/07/05 */ #include "dwin_lcd.h" @@ -39,6 +39,7 @@ #define ICON_BedSizeY ICON_PrintSize #define ICON_BedTramming ICON_SetHome #define ICON_Binary ICON_Contact +#define ICON_BltouchReset ICON_StockConfiguration #define ICON_Brightness ICON_Motion #define ICON_Cancel ICON_StockConfiguration #define ICON_CustomPreheat ICON_SetEndTemp @@ -145,7 +146,7 @@ #define DWIN_FONT_HEAD font10x20 #define DWIN_FONT_ALERT font10x20 #define STATUS_Y 354 -#define LCD_WIDTH (DWIN_WIDTH / 8) // only if the default font is font8x16 +#define LCD_WIDTH (DWIN_WIDTH / 8) // only if the default fontid is font8x16 // Minimum unit (0.1) : multiple (10) #define UNITFDIGITS 1 @@ -156,7 +157,7 @@ constexpr uint8_t TITLE_HEIGHT = 30, // Title bar heig TROWS = (STATUS_Y - TITLE_HEIGHT) / MLINE, // Total rows MROWS = TROWS - 1, // Other-than-Back ICOX = 26, // Menu item icon X position - LBLX = 60, // Menu item label X position + LBLX = 55, // Menu item label X position VALX = 210, // Menu item value X position MENU_CHR_W = 8, MENU_CHR_H = 16, // Menu font 8x16 STAT_CHR_W = 10; @@ -196,7 +197,7 @@ namespace DWINUI { extern uint16_t textcolor; extern uint16_t backcolor; extern uint16_t buttoncolor; - extern uint8_t font; + extern fontid_t fontid; extern FSTR_P const Author; extern void (*onTitleDraw)(TitleClass* title); @@ -205,15 +206,15 @@ namespace DWINUI { void init(); // Set text/number font - void setFont(uint8_t cfont); + void setFont(fontid_t cfont); // Get font character width - uint8_t fontWidth(uint8_t cfont); - inline uint8_t fontWidth() { return fontWidth(font); }; + uint8_t fontWidth(fontid_t cfont); + inline uint8_t fontWidth() { return fontWidth(fontid); }; // Get font character height - uint8_t fontHeight(uint8_t cfont); - inline uint8_t fontHeight() { return fontHeight(font); }; + uint8_t fontHeight(fontid_t cfont); + inline uint8_t fontHeight() { return fontHeight(fontid); }; // Get screen x coordinates from text column uint16_t ColToX(uint8_t col); @@ -278,108 +279,108 @@ namespace DWINUI { // Draw a numeric integer value // bShow: true=display background color; false=don't display background color // signedMode: 1=signed; 0=unsigned - // size: Font size + // fid: Font ID // color: Character color // bColor: Background color // iNum: Number of digits // x/y: Upper-left coordinate // value: Integer value - void Draw_Int(uint8_t bShow, bool signedMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, int32_t value); + void Draw_Int(uint8_t bShow, bool signedMode, fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, int32_t value); // Draw a positive integer - inline void Draw_Int(uint8_t bShow, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { - Draw_Int(bShow, 0, size, color, bColor, iNum, x, y, value); + inline void Draw_Int(uint8_t bShow, fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { + Draw_Int(bShow, 0, fid, color, bColor, iNum, x, y, value); } inline void Draw_Int(uint8_t iNum, long value) { - Draw_Int(false, 0, font, textcolor, backcolor, iNum, cursor.x, cursor.y, value); - MoveBy(iNum * fontWidth(font), 0); + Draw_Int(false, 0, fontid, textcolor, backcolor, iNum, cursor.x, cursor.y, value); + MoveBy(iNum * fontWidth(fontid), 0); } inline void Draw_Int(uint8_t iNum, uint16_t x, uint16_t y, long value) { - Draw_Int(false, 0, font, textcolor, backcolor, iNum, x, y, value); + Draw_Int(false, 0, fontid, textcolor, backcolor, iNum, x, y, value); } inline void Draw_Int(uint16_t color, uint8_t iNum, uint16_t x, uint16_t y, long value) { - Draw_Int(false, 0, font, color, backcolor, iNum, x, y, value); + Draw_Int(false, 0, fontid, color, backcolor, iNum, x, y, value); } inline void Draw_Int(uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { - Draw_Int(true, 0, font, color, bColor, iNum, x, y, value); + Draw_Int(true, 0, fontid, color, bColor, iNum, x, y, value); } - inline void Draw_Int(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { - Draw_Int(true, 0, size, color, bColor, iNum, x, y, value); + inline void Draw_Int(fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { + Draw_Int(true, 0, fid, color, bColor, iNum, x, y, value); } // Draw a signed integer - inline void Draw_Signed_Int(uint8_t bShow, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { - Draw_Int(bShow, 1, size, color, bColor, iNum, x, y, value); + inline void Draw_Signed_Int(uint8_t bShow, fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { + Draw_Int(bShow, 1, fid, color, bColor, iNum, x, y, value); } inline void Draw_Signed_Int(uint8_t iNum, long value) { - Draw_Int(false, 1, font, textcolor, backcolor, iNum, cursor.x, cursor.y, value); - MoveBy(iNum * fontWidth(font), 0); + Draw_Int(false, 1, fontid, textcolor, backcolor, iNum, cursor.x, cursor.y, value); + MoveBy(iNum * fontWidth(fontid), 0); } inline void Draw_Signed_Int(uint8_t iNum, uint16_t x, uint16_t y, long value) { - Draw_Int(false, 1, font, textcolor, backcolor, iNum, x, y, value); + Draw_Int(false, 1, fontid, textcolor, backcolor, iNum, x, y, value); } inline void Draw_Signed_Int(uint16_t color, uint8_t iNum, uint16_t x, uint16_t y, long value) { - Draw_Int(false, 1, font, color, backcolor, iNum, x, y, value); + Draw_Int(false, 1, fontid, color, backcolor, iNum, x, y, value); } inline void Draw_Signed_Int(uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { - Draw_Int(true, 1, font, color, bColor, iNum, x, y, value); + Draw_Int(true, 1, fontid, color, bColor, iNum, x, y, value); } - inline void Draw_Signed_Int(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { - Draw_Int(true, 1, size, color, bColor, iNum, x, y, value); + inline void Draw_Signed_Int(fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { + Draw_Int(true, 1, fid, color, bColor, iNum, x, y, value); } // Draw a numeric float value // bShow: true=display background color; false=don't display background color // signedMode: 1=signed; 0=unsigned - // size: Font size + // fid: Font ID // color: Character color // bColor: Background color // iNum: Number of digits // fNum: Number of decimal digits // x/y: Upper-left coordinate // value: float value - void Draw_Float(uint8_t bShow, bool signedMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value); + void Draw_Float(uint8_t bShow, bool signedMode, fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value); // Draw a positive floating point number - inline void Draw_Float(uint8_t bShow, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Float(bShow, 0, size, color, bColor, iNum, fNum, x, y, value); + inline void Draw_Float(uint8_t bShow, fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + Draw_Float(bShow, 0, fid, color, bColor, iNum, fNum, x, y, value); } inline void Draw_Float(uint8_t iNum, uint8_t fNum, float value) { - Draw_Float(false, 0, font, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value); - MoveBy((iNum + fNum + 1) * fontWidth(font), 0); + Draw_Float(false, 0, fontid, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value); + MoveBy((iNum + fNum + 1) * fontWidth(fontid), 0); } inline void Draw_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Float(false, 0, font, textcolor, backcolor, iNum, fNum, x, y, value); + Draw_Float(false, 0, fontid, textcolor, backcolor, iNum, fNum, x, y, value); } - inline void Draw_Float(uint8_t size, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Float(false, 0, size, textcolor, backcolor, iNum, fNum, x, y, value); + inline void Draw_Float(fontid_t fid, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + Draw_Float(false, 0, fid, textcolor, backcolor, iNum, fNum, x, y, value); } inline void Draw_Float(uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Float(true, 0, font, color, bColor, iNum, fNum, x, y, value); + Draw_Float(true, 0, fontid, color, bColor, iNum, fNum, x, y, value); } - inline void Draw_Float(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Float(true, 0, size, color, bColor, iNum, fNum, x, y, value); + inline void Draw_Float(fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + Draw_Float(true, 0, fid, color, bColor, iNum, fNum, x, y, value); } // Draw a signed floating point number - inline void Draw_Signed_Float(uint8_t bShow, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Float(bShow, 1, size, color, bColor, iNum, fNum, x, y, value); + inline void Draw_Signed_Float(uint8_t bShow, fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + Draw_Float(bShow, 1, fid, color, bColor, iNum, fNum, x, y, value); } inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, float value) { - Draw_Float(false, 1, font, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value); - MoveBy((iNum + fNum + 1) * fontWidth(font), 0); + Draw_Float(false, 1, fontid, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value); + MoveBy((iNum + fNum + 1) * fontWidth(fontid), 0); } inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Float(false, 1, font, textcolor, backcolor, iNum, fNum, x, y, value); + Draw_Float(false, 1, fontid, textcolor, backcolor, iNum, fNum, x, y, value); } - inline void Draw_Signed_Float(uint8_t size, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Float(false, 1, size, textcolor, backcolor, iNum, fNum, x, y, value); + inline void Draw_Signed_Float(fontid_t fid, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + Draw_Float(false, 1, fid, textcolor, backcolor, iNum, fNum, x, y, value); } inline void Draw_Signed_Float(uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Float(true, 1, font, color, bColor, iNum, fNum, x, y, value); + Draw_Float(true, 1, fontid, color, bColor, iNum, fNum, x, y, value); } - inline void Draw_Signed_Float(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Float(true, 1, size, color, bColor, iNum, fNum, x, y, value); + inline void Draw_Signed_Float(fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + Draw_Float(true, 1, fid, color, bColor, iNum, fNum, x, y, value); } // Draw a char @@ -407,70 +408,70 @@ namespace DWINUI { } // Draw a string - // size: Font size + // fid: Font ID // color: Character color // bColor: Background color // x/y: Upper-left coordinate of the string // *string: The string inline void Draw_String(uint16_t x, uint16_t y, const char * const string) { - DWIN_Draw_String(false, font, textcolor, backcolor, x, y, string); + DWIN_Draw_String(false, fontid, textcolor, backcolor, x, y, string); } inline void Draw_String(uint16_t x, uint16_t y, FSTR_P title) { - DWIN_Draw_String(false, font, textcolor, backcolor, x, y, FTOP(title)); + DWIN_Draw_String(false, fontid, textcolor, backcolor, x, y, FTOP(title)); } inline void Draw_String(uint16_t color, uint16_t x, uint16_t y, const char * const string) { - DWIN_Draw_String(false, font, color, backcolor, x, y, string); + DWIN_Draw_String(false, fontid, color, backcolor, x, y, string); } inline void Draw_String(uint16_t color, uint16_t x, uint16_t y, FSTR_P title) { - DWIN_Draw_String(false, font, color, backcolor, x, y, title); + DWIN_Draw_String(false, fontid, color, backcolor, x, y, title); } inline void Draw_String(uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, const char * const string) { - DWIN_Draw_String(true, font, color, bgcolor, x, y, string); + DWIN_Draw_String(true, fontid, color, bgcolor, x, y, string); } inline void Draw_String(uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, FSTR_P title) { - DWIN_Draw_String(true, font, color, bgcolor, x, y, title); + DWIN_Draw_String(true, fontid, color, bgcolor, x, y, title); } - inline void Draw_String(uint8_t size, uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, const char * const string) { - DWIN_Draw_String(true, size, color, bgcolor, x, y, string); + inline void Draw_String(fontid_t fid, uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, const char * const string) { + DWIN_Draw_String(true, fid, color, bgcolor, x, y, string); } - inline void Draw_String(uint8_t size, uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, FSTR_P title) { - DWIN_Draw_String(true, size, color, bgcolor, x, y, title); + inline void Draw_String(fontid_t fid, uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, FSTR_P title) { + DWIN_Draw_String(true, fid, color, bgcolor, x, y, title); } // Draw a centered string using DWIN_WIDTH // bShow: true=display background color; false=don't display background color - // size: Font size + // fid: Font ID // color: Character color // bColor: Background color // y: Upper coordinate of the string // *string: The string - void Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x1, uint16_t x2, uint16_t y, const char * const string); - inline void Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t y, const char * const string) { - Draw_CenteredString(bShow, size, color, bColor, 0, DWIN_WIDTH, y, string); + void Draw_CenteredString(bool bShow, fontid_t fid, uint16_t color, uint16_t bColor, uint16_t x1, uint16_t x2, uint16_t y, const char * const string); + inline void Draw_CenteredString(bool bShow, fontid_t fid, uint16_t color, uint16_t bColor, uint16_t y, const char * const string) { + Draw_CenteredString(bShow, fid, color, bColor, 0, DWIN_WIDTH, y, string); } - inline void Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t y, FSTR_P string) { - Draw_CenteredString(bShow, size, color, bColor, y, FTOP(string)); + inline void Draw_CenteredString(bool bShow, fontid_t fid, uint16_t color, uint16_t bColor, uint16_t y, FSTR_P string) { + Draw_CenteredString(bShow, fid, color, bColor, y, FTOP(string)); } inline void Draw_CenteredString(uint16_t color, uint16_t bcolor, uint16_t y, const char * const string) { - Draw_CenteredString(true, font, color, bcolor, y, string); + Draw_CenteredString(true, fontid, color, bcolor, y, string); } - inline void Draw_CenteredString(uint8_t size, uint16_t color, uint16_t y, const char * const string) { - Draw_CenteredString(false, size, color, backcolor, y, string); + inline void Draw_CenteredString(fontid_t fid, uint16_t color, uint16_t y, const char * const string) { + Draw_CenteredString(false, fid, color, backcolor, y, string); } - inline void Draw_CenteredString(uint8_t size, uint16_t color, uint16_t y, FSTR_P title) { - Draw_CenteredString(false, size, color, backcolor, y, title); + inline void Draw_CenteredString(fontid_t fid, uint16_t color, uint16_t y, FSTR_P title) { + Draw_CenteredString(false, fid, color, backcolor, y, title); } inline void Draw_CenteredString(uint16_t color, uint16_t y, const char * const string) { - Draw_CenteredString(false, font, color, backcolor, y, string); + Draw_CenteredString(false, fontid, color, backcolor, y, string); } inline void Draw_CenteredString(uint16_t color, uint16_t y, FSTR_P title) { - Draw_CenteredString(false, font, color, backcolor, y, title); + Draw_CenteredString(false, fontid, color, backcolor, y, title); } inline void Draw_CenteredString(uint16_t y, const char * const string) { - Draw_CenteredString(false, font, textcolor, backcolor, y, string); + Draw_CenteredString(false, fontid, textcolor, backcolor, y, string); } inline void Draw_CenteredString(uint16_t y, FSTR_P title) { - Draw_CenteredString(false, font, textcolor, backcolor, y, title); + Draw_CenteredString(false, fontid, textcolor, backcolor, y, title); } // Draw a box diff --git a/Marlin/src/lcd/e3v2/proui/lockscreen.cpp b/Marlin/src/lcd/e3v2/proui/lockscreen.cpp index 44b595096a..86c2095294 100644 --- a/Marlin/src/lcd/e3v2/proui/lockscreen.cpp +++ b/Marlin/src/lcd/e3v2/proui/lockscreen.cpp @@ -31,8 +31,10 @@ #if ENABLED(DWIN_LCD_PROUI) -#include "../../../core/types.h" -#include "dwin_lcd.h" +#include "dwin_defines.h" + +#if HAS_LOCKSCREEN + #include "dwinui.h" #include "dwin.h" #include "lockscreen.h" @@ -73,4 +75,6 @@ void LockScreenClass::onEncoder(EncoderState encoder_diffState) { DWIN_UpdateLCD(); } +#endif // HAS_LOCKSCREEN + #endif // DWIN_LCD_PROUI diff --git a/Marlin/src/lcd/e3v2/proui/menus.cpp b/Marlin/src/lcd/e3v2/proui/menus.cpp index 6438545cb2..85594fecdb 100644 --- a/Marlin/src/lcd/e3v2/proui/menus.cpp +++ b/Marlin/src/lcd/e3v2/proui/menus.cpp @@ -23,8 +23,8 @@ /** * Menu functions for ProUI * Author: Miguel A. Risco-Castillo - * Version: 1.4.1 - * Date: 2022/04/14 + * Version: 1.5.1 + * Date: 2022/05/23 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -166,6 +166,17 @@ void onDrawChkbMenu(MenuItemClass* menuitem, int8_t line) { onDrawChkbMenu(menuitem, line, val); } +void DrawItemEdit() { + switch (checkkey) { + case SetIntNoDraw: if (MenuData.LiveUpdate) MenuData.LiveUpdate(); break; + case SetInt: + case SetPInt: DWINUI::Draw_Signed_Int(HMI_data.Text_Color, HMI_data.Selected_Color, 4 , VALX, MBASE(CurrentMenu->line()) - 1, MenuData.Value); break; + case SetFloat: + case SetPFloat: DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Selected_Color, 3, MenuData.dp, VALX - MenuData.dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), MenuData.Value / POW(10, MenuData.dp)); break; + default: break; + } +} + //----------------------------------------------------------------------------- // On click functions //----------------------------------------------------------------------------- @@ -307,7 +318,7 @@ int8_t HMI_GetInt(const int32_t lo, const int32_t hi) { return 2; } LIMIT(MenuData.Value, lo, hi); - DWINUI::Draw_Signed_Int(HMI_data.Text_Color, HMI_data.Selected_Color, 4 , VALX, MBASE(CurrentMenu->line()) - 1, MenuData.Value); + DrawItemEdit(); return 1; } return 0; @@ -361,7 +372,7 @@ int8_t HMI_GetFloat(uint8_t dp, int32_t lo, int32_t hi) { return 2; } LIMIT(MenuData.Value, lo, hi); - DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Selected_Color, 3, dp, VALX - dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), MenuData.Value / POW(10, dp)); + DrawItemEdit(); return 1; } return 0; @@ -469,7 +480,7 @@ void MenuItemClass::SetFrame(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, } void MenuItemClass::draw(int8_t line) { - if (line < 0 || line >= TROWS) return; + if (!WITHIN(line, 0, TROWS - 1)) return; if (onDraw != nullptr) (*onDraw)(this, line); }; @@ -547,6 +558,9 @@ void UpdateMenu(MenuClass* &menu) { menu->draw(); } -void ReDrawMenu() { if (CurrentMenu && checkkey==Menu) CurrentMenu->draw(); } +void ReDrawMenu(const bool force/*=false*/) { + if (CurrentMenu && (force || checkkey == Menu)) CurrentMenu->draw(); + if (force) DrawItemEdit(); +} #endif // DWIN_LCD_PROUI diff --git a/Marlin/src/lcd/e3v2/proui/menus.h b/Marlin/src/lcd/e3v2/proui/menus.h index d4514d1732..6a5f8786ca 100644 --- a/Marlin/src/lcd/e3v2/proui/menus.h +++ b/Marlin/src/lcd/e3v2/proui/menus.h @@ -23,8 +23,8 @@ /** * Menu functions for ProUI * Author: Miguel A. Risco-Castillo - * Version: 1.4.1 - * Date: 2022/04/14 + * Version: 1.5.1 + * Date: 2022/05/23 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -168,7 +168,7 @@ bool SetMenu(MenuClass* &menu, FSTR_P title, int8_t totalitems); void UpdateMenu(MenuClass* &menu); //Redraw the current Menu if it is valid -void ReDrawMenu(); +void ReDrawMenu(const bool force=false); // Clear MenuItems array and free MenuItems elements void MenuItemsClear(); diff --git a/Marlin/src/lcd/e3v2/proui/meshviewer.cpp b/Marlin/src/lcd/e3v2/proui/meshviewer.cpp index c2d01a07eb..2511d33ff1 100644 --- a/Marlin/src/lcd/e3v2/proui/meshviewer.cpp +++ b/Marlin/src/lcd/e3v2/proui/meshviewer.cpp @@ -31,8 +31,6 @@ #if BOTH(DWIN_LCD_PROUI, HAS_MESH) -#include "meshviewer.h" - #include "../../../core/types.h" #include "../../marlinui.h" #include "dwin_lcd.h" @@ -40,9 +38,10 @@ #include "dwin.h" #include "dwin_popup.h" #include "../../../feature/bedlevel/bedlevel.h" +#include "meshviewer.h" #if ENABLED(AUTO_BED_LEVELING_UBL) - #include "ubl_tools.h" + #include "bedlevel_tools.h" #endif MeshViewerClass MeshViewer; @@ -112,10 +111,10 @@ void MeshViewerClass::DrawMesh(bed_mesh_t zval, const uint8_t sizex, const uint8 void MeshViewerClass::Draw(bool withsave /*= false*/) { Title.ShowCaption(GET_TEXT_F(MSG_MESH_VIEWER)); - #if ENABLED(USE_UBL_VIEWER) + #if USE_UBL_VIEWER DWINUI::ClearMainArea(); - ubl_tools.viewer_print_value = true; - ubl_tools.Draw_Bed_Mesh(-1, 1, 8, 10 + TITLE_HEIGHT); + BedLevelTools.viewer_print_value = true; + BedLevelTools.Draw_Bed_Mesh(-1, 1, 8, 10 + TITLE_HEIGHT); #else DrawMesh(bedlevel.z_values, GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y); #endif @@ -127,8 +126,8 @@ void MeshViewerClass::Draw(bool withsave /*= false*/) { else DWINUI::Draw_Button(BTN_Continue, 86, 305); - #if ENABLED(USE_UBL_VIEWER) - ubl_tools.Set_Mesh_Viewer_Status(); + #if USE_UBL_VIEWER + BedLevelTools.Set_Mesh_Viewer_Status(); #else char str_1[6], str_2[6] = ""; ui.status_printf(0, F("Mesh minZ: %s, maxZ: %s"), diff --git a/Marlin/src/lcd/e3v2/proui/meshviewer.h b/Marlin/src/lcd/e3v2/proui/meshviewer.h index 1e78ff2657..3aafe16984 100644 --- a/Marlin/src/lcd/e3v2/proui/meshviewer.h +++ b/Marlin/src/lcd/e3v2/proui/meshviewer.h @@ -21,9 +21,6 @@ */ #pragma once -#include "../../../core/types.h" -#include "../../../feature/bedlevel/bedlevel.h" - /** * Mesh Viewer for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) diff --git a/Marlin/src/lcd/e3v2/proui/plot.cpp b/Marlin/src/lcd/e3v2/proui/plot.cpp index ebc685fa24..cb1f6c2dda 100644 --- a/Marlin/src/lcd/e3v2/proui/plot.cpp +++ b/Marlin/src/lcd/e3v2/proui/plot.cpp @@ -46,13 +46,16 @@ #ifdef DWIN_LCD_PROUI +#include "dwin_defines.h" + +#if HAS_PIDPLOT + #include "plot.h" #include "../../../core/types.h" #include "../../marlinui.h" #include "dwin_lcd.h" #include "dwinui.h" -#include "dwin_popup.h" #include "dwin.h" #define Plot_Bg_Color RGB( 1, 12, 8) @@ -71,7 +74,7 @@ void PlotClass::Draw(const frame_rect_t frame, const float max, const float ref) y2 = frame.y + frame.h - 1; r = round((y2) - ref * scale); DWINUI::Draw_Box(1, Plot_Bg_Color, frame); - for (uint8_t i = 1; i < 4; i++) if (i*50 < frame.w) DWIN_Draw_VLine(Line_Color, i*50 + frame.x, frame.y, frame.h); + for (uint8_t i = 1; i < 4; i++) if (i * 50 < frame.w) DWIN_Draw_VLine(Line_Color, i * 50 + frame.x, frame.y, frame.h); DWINUI::Draw_Box(0, Color_White, DWINUI::ExtendFrame(frame, 1)); DWIN_Draw_HLine(Color_Red, frame.x, r, frame.w); } @@ -91,4 +94,6 @@ void PlotClass::Update(const float value) { grphpoints++; } +#endif // HAS_PIDPLOT + #endif // DWIN_LCD_PROUI diff --git a/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp index 88326466c0..0f34d76cfa 100644 --- a/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp @@ -606,9 +606,11 @@ void DGUSScreenHandler::HandleHeaterControl(DGUS_VP_Variable &var, void *val_ptr break; #endif - case VP_BED_CONTROL: - preheat_temp = PREHEAT_1_TEMP_BED; - break; + #if HAS_HEATED_BED + case VP_BED_CONTROL: + preheat_temp = PREHEAT_1_TEMP_BED; + break; + #endif } *(int16_t*)var.memadr = *(int16_t*)var.memadr > 0 ? 0 : preheat_temp; diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/basic/commands.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/basic/commands.cpp index a796c8edcf..662753a154 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/basic/commands.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/basic/commands.cpp @@ -1208,7 +1208,7 @@ void CLCD::default_display_orientation() { + ENABLED(TOUCH_UI_INVERTED) * 1 ); cmd.execute(); - #elif ANY(TOUCH_UI_PORTRAIT, TOUCH_UI_MIRRORED) + #elif EITHER(TOUCH_UI_PORTRAIT, TOUCH_UI_MIRRORED) #error "PORTRAIT or MIRRORED orientation not supported on the FT800." #elif ENABLED(TOUCH_UI_INVERTED) mem_write_32(REG::ROTATE, 1); diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/svg2cpp.py b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/svg2cpp.py index cfc2625453..f6e4a3e39a 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/svg2cpp.py +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/svg2cpp.py @@ -112,10 +112,10 @@ def from_svg_view_box(self, svg): if s: m = re.search('viewBox="([0-9-.]+) ([0-9-.]+) ([0-9-.]+) ([0-9-.]+)"', svg) if m: - self.x_min = float(m.group(1)) - self.y_min = float(m.group(2)) - self.x_max = float(m.group(3)) - self.y_max = float(m.group(4)) + self.x_min = float(m[1]) + self.y_min = float(m[2]) + self.x_max = float(m[3]) + self.y_max = float(m[4]) return True return False @@ -205,18 +205,18 @@ def process_svg_path_data(self, id, d): pass # Just eat the spaces elif self.eat_token('([LMHVZlmhvz])'): - cmd = self.m.group(1) + cmd = self.m[1] # The following commands take no arguments if cmd == "Z" or cmd == "z": self.process_svg_path_data_cmd(id, cmd, 0, 0) elif self.eat_token('([CScsQqTtAa])'): - print("Unsupported path data command:", self.m.group(1), "in path", id, "\n", file=sys.stderr) + print("Unsupported path data command:", self.m[1], "in path", id, "\n", file=sys.stderr) quit() elif self.eat_token('([ ,]*[-0-9e.]+)+'): # Process list of coordinates following command - coords = re.split('[ ,]+', self.m.group(0)) + coords = re.split('[ ,]+', self.m[0]) # The following commands take two arguments if cmd == "L" or cmd == "l": while coords: @@ -245,7 +245,7 @@ def process_svg_paths(self, svg): id = "" m = re.search(' id="(.*)"', path) if m: - id = m.group(1) + id = m[1] m = re.search(' transform="(.*)"', path) if m: @@ -254,7 +254,7 @@ def process_svg_paths(self, svg): m = re.search(' d="(.*)"', path) if m: - self.process_svg_path_data(id, m.group(1)) + self.process_svg_path_data(id, m[1]) self.op.path_finished(id) self.reset() diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/change_filament_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/change_filament_screen.cpp index fa0748c17b..17ec975692 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/change_filament_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/change_filament_screen.cpp @@ -171,9 +171,9 @@ void ChangeFilamentScreen::onRedraw(draw_mode_t what) { const bool t_ok = getActualTemp_celsius(e) > getSoftenTemp() - 10; - if (mydata.t_tag && !t_ok) { + if (mydata.t_tag && !t_ok) cmd.text(HEATING_LBL_POS, GET_TEXT_F(MSG_HEATING)); - } else if (getActualTemp_celsius(e) > 100) { + else if (getActualTemp_celsius(e) > 100) { cmd.cmd(COLOR_RGB(0xFF0000)) .text(CAUTION_LBL_POS, GET_TEXT_F(MSG_CAUTION)) .colors(normal_btn) diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/files_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/files_screen.cpp index 00768dbaf7..290c20f43e 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/files_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/files_screen.cpp @@ -111,16 +111,17 @@ void FilesScreen::drawFileButton(int x, int y, int w, int h, const char *filenam cmd.cmd(COLOR_RGB(is_highlighted ? fg_action : bg_color)); cmd.font(font_medium).rectangle(bx, by, bw, bh); cmd.cmd(COLOR_RGB(is_highlighted ? normal_btn.rgb : bg_text_enabled)); - #if ENABLED(SCROLL_LONG_FILENAMES) - if (is_highlighted) { + if (TERN0(SCROLL_LONG_FILENAMES, is_highlighted)) { + #if ENABLED(SCROLL_LONG_FILENAMES) cmd.cmd(SAVE_CONTEXT()); cmd.cmd(SCISSOR_XY(x,y)); cmd.cmd(SCISSOR_SIZE(w,h)); cmd.cmd(MACRO(0)); cmd.text(bx, by, bw, bh, filename, OPT_CENTERY | OPT_NOFIT); - } else - #endif - draw_text_with_ellipsis(cmd, bx,by, bw - (is_dir ? 20 : 0), bh, filename, OPT_CENTERY, font_medium); + #endif + } + else + draw_text_with_ellipsis(cmd, bx,by, bw - (is_dir ? 20 : 0), bh, filename, OPT_CENTERY, font_medium); if (is_dir && !is_highlighted) cmd.text(bx, by, bw, bh, F("> "), OPT_CENTERY | OPT_RIGHTX); #if ENABLED(SCROLL_LONG_FILENAMES) if (is_highlighted) cmd.cmd(RESTORE_CONTEXT()); diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/colors.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/colors.h index 995379fcda..70c2be4ec2 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/colors.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/colors.h @@ -37,14 +37,14 @@ namespace Theme { #else // Use linear accent colors - #if ANY(TOUCH_UI_ROYAL_THEME, TOUCH_UI_FROZEN_THEME) - // Dark blue accent colors - constexpr int accent_hue = 216; - constexpr float accent_sat = 0.7; + #if EITHER(TOUCH_UI_ROYAL_THEME, TOUCH_UI_FROZEN_THEME) + // Dark blue accent colors + constexpr int accent_hue = 216; + constexpr float accent_sat = 0.7; #else - // Green accent colors - constexpr int accent_hue = 68; - constexpr float accent_sat = 0.68; + // Green accent colors + constexpr int accent_hue = 68; + constexpr float accent_sat = 0.68; #endif // Shades of accent color @@ -88,7 +88,7 @@ namespace Theme { constexpr uint32_t bed_mesh_lines_rgb = 0xFFFFFF; constexpr uint32_t bed_mesh_shadow_rgb = 0x444444; - #elif ANY(TOUCH_UI_COCOA_THEME, TOUCH_UI_FROZEN_THEME) + #elif EITHER(TOUCH_UI_COCOA_THEME, TOUCH_UI_FROZEN_THEME) constexpr uint32_t theme_darkest = accent_color_1; constexpr uint32_t theme_dark = accent_color_4; diff --git a/Marlin/src/lcd/extui/mks_ui/draw_ui.h b/Marlin/src/lcd/extui/mks_ui/draw_ui.h index 798e662220..9bc583d3ad 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_ui.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_ui.h @@ -236,9 +236,9 @@ typedef struct UI_Config_Struct { eStepMax = 10; // Extruder speed (mm/s) uint8_t extruSpeed; - static constexpr uint8_t eSpeedH = 1, + static constexpr uint8_t eSpeedH = 20, eSpeedN = 10, - eSpeedL = 20; + eSpeedL = 1; uint8_t print_state; uint8_t stepPrintSpeed; uint8_t waitEndMoves; diff --git a/Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32.cpp b/Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32.cpp index 6607e7531f..0e55b3448b 100644 --- a/Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32.cpp +++ b/Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32.cpp @@ -53,42 +53,45 @@ void WifiSerial::init(PinName _rx, PinName _tx) { WifiSerial::WifiSerial(void *peripheral) { // If PIN_SERIALy_RX is not defined assume half-duplex _serial.pin_rx = NC; + if (false) { + // for else if / else below... + } // If Serial is defined in variant set // the Rx/Tx pins for com port if defined #if defined(Serial) && defined(PIN_SERIAL_TX) - if ((void *)this == (void *)&Serial) { + else if ((void *)this == (void *)&Serial) { #ifdef PIN_SERIAL_RX setRx(PIN_SERIAL_RX); #endif setTx(PIN_SERIAL_TX); - } else + } #endif #if defined(PIN_SERIAL1_TX) && defined(USART1_BASE) - if (peripheral == USART1) { + else if (peripheral == USART1) { #ifdef PIN_SERIAL1_RX setRx(PIN_SERIAL1_RX); #endif setTx(PIN_SERIAL1_TX); - } else + } #endif #if defined(PIN_SERIAL2_TX) && defined(USART2_BASE) - if (peripheral == USART2) { + else if (peripheral == USART2) { #ifdef PIN_SERIAL2_RX setRx(PIN_SERIAL2_RX); #endif setTx(PIN_SERIAL2_TX); - } else + } #endif #if defined(PIN_SERIAL3_TX) && defined(USART3_BASE) - if (peripheral == USART3) { + else if (peripheral == USART3) { #ifdef PIN_SERIAL3_RX setRx(PIN_SERIAL3_RX); #endif setTx(PIN_SERIAL3_TX); - } else + } #endif #ifdef PIN_SERIAL4_TX - if (false + else if (false #ifdef USART4_BASE || peripheral == USART4 #elif defined(UART4_BASE) @@ -99,10 +102,10 @@ WifiSerial::WifiSerial(void *peripheral) { setRx(PIN_SERIAL4_RX); #endif setTx(PIN_SERIAL4_TX); - } else + } #endif #ifdef PIN_SERIAL5_TX - if (false + else if (false #ifdef USART5_BASE || peripheral == USART5 #elif defined(UART5_BASE) @@ -113,18 +116,18 @@ WifiSerial::WifiSerial(void *peripheral) { setRx(PIN_SERIAL5_RX); #endif setTx(PIN_SERIAL5_TX); - } else + } #endif #if defined(PIN_SERIAL6_TX) && defined(USART6_BASE) - if (peripheral == USART6) { + else if (peripheral == USART6) { #ifdef PIN_SERIAL6_RX setRx(PIN_SERIAL6_RX); #endif setTx(PIN_SERIAL6_TX); - } else + } #endif #ifdef PIN_SERIAL7_TX - if (false + else if (false #ifdef USART7_BASE || peripheral == USART7 #elif defined(UART7_BASE) @@ -135,10 +138,10 @@ WifiSerial::WifiSerial(void *peripheral) { setRx(PIN_SERIAL7_RX); #endif setTx(PIN_SERIAL7_TX); - } else + } #endif #ifdef PIN_SERIAL8_TX - if (false + else if (false #ifdef USART8_BASE || peripheral == USART8 #elif defined(UART8_BASE) @@ -149,18 +152,18 @@ WifiSerial::WifiSerial(void *peripheral) { setRx(PIN_SERIAL8_RX); #endif setTx(PIN_SERIAL8_TX); - } else + } #endif #if defined(PIN_SERIAL9_TX) && defined(UART9_BASE) - if (peripheral == UART9) { + else if (peripheral == UART9) { #ifdef PIN_SERIAL9_RX setRx(PIN_SERIAL9_RX); #endif setTx(PIN_SERIAL9_TX); - } else + } #endif #ifdef PIN_SERIAL10_TX - if (false + else if (false #ifdef USART10_BASE || peripheral == USART10 #elif defined(UART10_BASE) @@ -171,18 +174,18 @@ WifiSerial::WifiSerial(void *peripheral) { setRx(PIN_SERIAL10_RX); #endif setTx(PIN_SERIAL10_TX); - } else + } #endif #if defined(PIN_SERIALLP1_TX) && defined(LPUART1_BASE) - if (peripheral == LPUART1) { + else if (peripheral == LPUART1) { #ifdef PIN_SERIALLP1_RX setRx(PIN_SERIALLP1_RX); #endif setTx(PIN_SERIALLP1_TX); - } else + } #endif // else get the pins of the first peripheral occurrence in PinMap - { + else { _serial.pin_rx = pinmap_pin(peripheral, PinMap_UART_RX); _serial.pin_tx = pinmap_pin(peripheral, PinMap_UART_TX); } diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index 2c77dc9083..49baeb6f95 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -180,7 +180,7 @@ namespace ExtUI { } void yield() { - if (!flags.printer_killed) thermalManager.manage_heater(); + if (!flags.printer_killed) thermalManager.task(); } void enableHeater(const extruder_t extruder) { @@ -353,6 +353,7 @@ namespace ExtUI { line_to_current_position(feedrate ?: manual_feedrate_mm_s[axis]); } + // @advi3++ void setMultipleAxisPosition_mm(size_t nb_axis, float *positions, const axis_t *axis, const feedRate_t feedrate) { for(size_t i = 0; i < nb_axis; ++i) { @@ -952,6 +953,10 @@ namespace ExtUI { bool getLevelingActive() { return planner.leveling_active; } void setLevelingActive(const bool state) { set_bed_leveling_enabled(state); } bool getMeshValid() { return leveling_is_valid(); } + #if ENABLED(BLTOUCH) + bool isLevelingHighSpeed() { return bltouch.high_speed_mode; } // @advi3++ + void setLevelingHighSpeed(bool set) { bltouch.high_speed_mode = set; } // @advi3++ + #endif #if HAS_MESH @@ -1114,10 +1119,12 @@ namespace ExtUI { void coolDown() { thermalManager.cooldown(); } bool awaitingUserConfirm() { - return TERN0(HAS_RESUME_CONTINUE, wait_for_user) || getHostKeepaliveIsPaused(); + return TERN0(HAS_RESUME_CONTINUE, wait_for_user) || TERN0(HOST_KEEPALIVE_FEATURE, getHostKeepaliveIsPaused()); } void setUserConfirmed() { TERN_(HAS_RESUME_CONTINUE, wait_for_user = false); } + void cancelLeveling() { ::g29_cancel = true; } // @advi3++ + #if M600_PURGE_MORE_RESUMABLE void setPauseMenuResponse(PauseMenuResponse response) { pause_menu_response = response; } PauseMessage pauseModeStatus = PAUSE_MESSAGE_STATUS; @@ -1144,6 +1151,8 @@ namespace ExtUI { bool isMediaInserted() { return TERN0(SDSUPPORT, IS_SD_INSERTED()); } void mountMedia() { card.mount(); } // @advi3++ + void releaseMedia() { card.release(); } // @advi3++ + bool isMediaMounted() { return card.flag.mounted; } // @advi3++ void pausePrint() { ui.pause_print(); } void resumePrint() { ui.resume_print(); } @@ -1226,7 +1235,7 @@ namespace ExtUI { #endif } - // @advi3++ PR candidates + // @advi3++ void setAllAxisUnhomed() { ::set_all_unhomed(); @@ -1340,23 +1349,8 @@ void watchdogReset() hal.watchdog_refresh(); } -bool extrudeFilament(float purge_length) -{ - return extrude_filament(purge_length); -} - -#if ENABLED(BLTOUCH) -bool bltouchDeploy() { - return bltouch.deploy(); -} - -bool bltouchStow() { - return bltouch.stow(); -} -#endif - void stopMove() { - quickstop_stepper();; + quickstop_stepper(); } void setAbsoluteZAxisPosition_mm(const_float_t position) { @@ -1390,11 +1384,11 @@ void MarlinUI::init_lcd() { ExtUI::onStartup(); } void MarlinUI::update() { ExtUI::onIdle(); } -void MarlinUI::kill_screen(float temp, FSTR_P const error, FSTR_P const component) { +void MarlinUI::kill_screen(float temp, FSTR_P const error, FSTR_P const component) { // @advi3++ using namespace ExtUI; if (!flags.printer_killed) { flags.printer_killed = true; - onPrinterKilled(temp, error, component); + onPrinterKilled(temp, error, component); // @advi3++ } } diff --git a/Marlin/src/lcd/extui/ui_api.h b/Marlin/src/lcd/extui/ui_api.h index a7193c9932..1863ea010d 100644 --- a/Marlin/src/lcd/extui/ui_api.h +++ b/Marlin/src/lcd/extui/ui_api.h @@ -170,13 +170,22 @@ namespace ExtUI { bool getLevelingActive(); void setLevelingActive(const bool); bool getMeshValid(); + #if ENABLED(BLTOUCH) + bool isLevelingHighSpeed(); // @advi3++ + void setLevelingHighSpeed(bool set = true); // @advi3++ + #else + inline bool isLevelingHighSpeed() { return false; } // @advi3++ + inline void setLevelingHighSpeed(bool set = true) {} // @advi3++ + #endif #if HAS_MESH bed_mesh_t& getMeshArray(); float getMeshPoint(const xy_uint8_t &pos); void setMeshPoint(const xy_uint8_t &pos, const_float_t zval); void moveToMeshPoint(const xy_uint8_t &pos, const_float_t z); void onLevelingStart(); - void onLevelingDone(); + void onLevelingDone(bool success); // @advi3++ + void onLevelingProgress(const int8_t index, const int8_t xpos, const int8_t ypos); // @advi3++ + void cancelLeveling(); // @advi3++ void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval); inline void onMeshUpdate(const xy_int8_t &pos, const_float_t zval) { onMeshUpdate(pos.x, pos.y, zval); } @@ -385,7 +394,9 @@ namespace ExtUI { * Should be used by the EXTENSIBLE_UI to operate on files */ void mountMedia(); // @advi3++ + void releaseMedia(); // @advi3++ bool isMediaInserted(); + bool isMediaMounted(); // @advi3++ bool isPrintingFromMediaPaused(); bool isPrintingFromMedia(); bool isPrinting(); @@ -395,7 +406,6 @@ namespace ExtUI { void stopPrint(); void pausePrint(); void resumePrint(); - bool extrudeFilament(float purge_length); // @advi3++ class FileList { private: @@ -463,17 +473,6 @@ namespace ExtUI { uint16_t getSizeofSettings(); #endif - // @advi3++ - #if HAS_LEVELING - void onAutomaticLevelingFinished(bool success); - #endif - - // @advi3++ - #if ENABLED(BLTOUCH) - bool bltouchDeploy(); - bool bltouchStow(); - #endif - // @advi3++ #if ENABLED(SKEW_CORRECTION) #if ENABLED(SKEW_CORRECTION_FOR_Z) diff --git a/Marlin/src/lcd/fontutils.cpp b/Marlin/src/lcd/fontutils.cpp index a97e63ac4d..46329fd4be 100644 --- a/Marlin/src/lcd/fontutils.cpp +++ b/Marlin/src/lcd/fontutils.cpp @@ -31,8 +31,6 @@ #include "../inc/MarlinConfig.h" -#define MAX_UTF8_CHAR_SIZE 4 - #if HAS_WIRED_LCD #include "marlinui.h" #include "../MarlinCore.h" @@ -99,7 +97,7 @@ static inline bool utf8_is_start_byte_of_char(const uint8_t b) { /* This function gets the character at the pstart position, interpreting UTF8 multibyte sequences and returns the pointer to the next character */ -const uint8_t* get_utf8_value_cb(const uint8_t *pstart, read_byte_cb_t cb_read_byte, wchar_t *pval) { +const uint8_t* get_utf8_value_cb(const uint8_t *pstart, read_byte_cb_t cb_read_byte, lchar_t &pval) { uint32_t val = 0; const uint8_t *p = pstart; @@ -158,7 +156,7 @@ const uint8_t* get_utf8_value_cb(const uint8_t *pstart, read_byte_cb_t cb_read_b else for (; 0xFC < (0xFE & valcur); ) { p++; valcur = cb_read_byte(p); } - if (pval) *pval = val; + pval = val; return p; } diff --git a/Marlin/src/lcd/fontutils.h b/Marlin/src/lcd/fontutils.h index e01962d7ad..69edf1a0c8 100644 --- a/Marlin/src/lcd/fontutils.h +++ b/Marlin/src/lcd/fontutils.h @@ -31,36 +31,41 @@ #pragma once #include -#include // wchar_t #include // uint32_t #include "../HAL/shared/Marduino.h" #include "../core/macros.h" +#define MAX_UTF8_CHAR_SIZE 4 + +// Use a longer character type (if needed) because wchar_t is only 16 bits wide +#ifdef MAX_UTF8_CHAR_SIZE + #if MAX_UTF8_CHAR_SIZE > 2 + typedef uint32_t lchar_t; + #else + typedef wchar_t lchar_t; + #endif +#else + #define wchar_t uint32_t +#endif + // read a byte from ROM or RAM typedef uint8_t (*read_byte_cb_t)(const uint8_t * str); uint8_t read_byte_ram(const uint8_t *str); uint8_t read_byte_rom(const uint8_t *str); -// there's overflow of the wchar_t due to the 2-byte size in Arduino -// sizeof(wchar_t)=2; sizeof(size_t)=2; sizeof(uint32_t)=4; -// sizeof(int)=2; sizeof(long)=4; sizeof(unsigned)=2; -//#undef wchar_t -#define wchar_t uint32_t -//typedef uint32_t wchar_t; - typedef uint16_t pixel_len_t; #define PIXEL_LEN_NOLIMIT ((pixel_len_t)(-1)) /* Perform binary search */ -typedef int (* pf_bsearch_cb_comp_t)(void *userdata, size_t idx, void * data_pin); /*"data_list[idx] - *data_pin"*/ +typedef int (* pf_bsearch_cb_comp_t)(void *userdata, size_t idx, void * data_pin); int pf_bsearch_r(void *userdata, size_t num_data, pf_bsearch_cb_comp_t cb_comp, void *data_pinpoint, size_t *ret_idx); /* Get the character, decoding multibyte UTF8 characters and returning a pointer to the start of the next UTF8 character */ -const uint8_t* get_utf8_value_cb(const uint8_t *pstart, read_byte_cb_t cb_read_byte, wchar_t *pval); +const uint8_t* get_utf8_value_cb(const uint8_t *pstart, read_byte_cb_t cb_read_byte, lchar_t &pval); -inline const char* get_utf8_value_cb(const char *pstart, read_byte_cb_t cb_read_byte, wchar_t *pval) { +inline const char* get_utf8_value_cb(const char *pstart, read_byte_cb_t cb_read_byte, lchar_t &pval) { return (const char *)get_utf8_value_cb((const uint8_t *)pstart, cb_read_byte, pval); } diff --git a/Marlin/src/lcd/language/language_an.h b/Marlin/src/lcd/language/language_an.h index 98f3d4ed97..37c90c34da 100644 --- a/Marlin/src/lcd/language/language_an.h +++ b/Marlin/src/lcd/language/language_an.h @@ -83,6 +83,7 @@ namespace Language_an { LSTR MSG_MOVE_X = _UxGT("Mover X"); LSTR MSG_MOVE_Y = _UxGT("Mover Y"); LSTR MSG_MOVE_Z = _UxGT("Mover Z"); + LSTR MSG_MOVE_N = _UxGT("Mover @"); LSTR MSG_MOVE_E = _UxGT("Extrusor"); LSTR MSG_MOVE_EN = _UxGT("Extrusor *"); LSTR MSG_MOVE_N_MM = _UxGT("Mover $mm"); diff --git a/Marlin/src/lcd/language/language_bg.h b/Marlin/src/lcd/language/language_bg.h index 2596d62564..038df3eccb 100644 --- a/Marlin/src/lcd/language/language_bg.h +++ b/Marlin/src/lcd/language/language_bg.h @@ -72,6 +72,7 @@ namespace Language_bg { LSTR MSG_MOVE_X = _UxGT("Движение по X"); LSTR MSG_MOVE_Y = _UxGT("Движение по Y"); LSTR MSG_MOVE_Z = _UxGT("Движение по Z"); + LSTR MSG_MOVE_N = _UxGT("Движение по @"); LSTR MSG_MOVE_E = _UxGT("Екструдер"); LSTR MSG_MOVE_EN = _UxGT("Екструдер *"); LSTR MSG_MOVE_N_MM = _UxGT("Премести с $mm"); diff --git a/Marlin/src/lcd/language/language_ca.h b/Marlin/src/lcd/language/language_ca.h index fd46bcc28f..54b968ede2 100644 --- a/Marlin/src/lcd/language/language_ca.h +++ b/Marlin/src/lcd/language/language_ca.h @@ -83,6 +83,7 @@ namespace Language_ca { LSTR MSG_MOVE_X = _UxGT("Mou X"); LSTR MSG_MOVE_Y = _UxGT("Mou Y"); LSTR MSG_MOVE_Z = _UxGT("Mou Z"); + LSTR MSG_MOVE_N = _UxGT("Mou @"); LSTR MSG_MOVE_E = _UxGT("Extrusor"); LSTR MSG_MOVE_EN = _UxGT("Extrusor *"); LSTR MSG_MOVE_N_MM = _UxGT("Mou $mm"); diff --git a/Marlin/src/lcd/language/language_cz.h b/Marlin/src/lcd/language/language_cz.h index 555fec1d20..9c5bafc96e 100644 --- a/Marlin/src/lcd/language/language_cz.h +++ b/Marlin/src/lcd/language/language_cz.h @@ -232,6 +232,7 @@ namespace Language_cz { LSTR MSG_MOVE_X = _UxGT("Posunout X"); LSTR MSG_MOVE_Y = _UxGT("Posunout Y"); LSTR MSG_MOVE_Z = _UxGT("Posunout Z"); + LSTR MSG_MOVE_N = _UxGT("Posunout @"); LSTR MSG_MOVE_E = _UxGT("Extrudér"); LSTR MSG_MOVE_EN = _UxGT("Extrudér *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Hotend je studený"); diff --git a/Marlin/src/lcd/language/language_da.h b/Marlin/src/lcd/language/language_da.h index 05474744d0..b4afca9d99 100644 --- a/Marlin/src/lcd/language/language_da.h +++ b/Marlin/src/lcd/language/language_da.h @@ -74,6 +74,9 @@ namespace Language_da { LSTR MSG_MOVE_X = _UxGT("Flyt X"); LSTR MSG_MOVE_Y = _UxGT("Flyt Y"); LSTR MSG_MOVE_Z = _UxGT("Flyt Z"); + LSTR MSG_MOVE_N = _UxGT("Flyt @"); + LSTR MSG_MOVE_E = _UxGT("Flyt E"); + LSTR MSG_MOVE_EN = _UxGT("Flyt *"); LSTR MSG_MOVE_N_MM = _UxGT("Flyt $mm"); LSTR MSG_MOVE_01MM = _UxGT("Flyt 0.1mm"); LSTR MSG_MOVE_1MM = _UxGT("Flyt 1mm"); diff --git a/Marlin/src/lcd/language/language_de.h b/Marlin/src/lcd/language/language_de.h index a9fa16c77c..5708221e9c 100644 --- a/Marlin/src/lcd/language/language_de.h +++ b/Marlin/src/lcd/language/language_de.h @@ -37,7 +37,10 @@ namespace Language_de { LSTR WELCOME_MSG = MACHINE_NAME _UxGT(" bereit"); LSTR MSG_YES = _UxGT("JA"); LSTR MSG_NO = _UxGT("NEIN"); + LSTR MSG_HIGH = _UxGT("HOCH"); + LSTR MSG_LOW = _UxGT("RUNTER"); LSTR MSG_BACK = _UxGT("Zurück"); + LSTR MSG_ERROR = _UxGT("Fehler"); LSTR MSG_MEDIA_ABORTING = _UxGT("Abbruch..."); LSTR MSG_MEDIA_INSERTED = _UxGT("Medium erkannt"); LSTR MSG_MEDIA_REMOVED = _UxGT("Medium entfernt"); @@ -51,6 +54,8 @@ namespace Language_de { LSTR MSG_LCD_SOFT_ENDSTOPS = _UxGT("Software-Endstopp"); LSTR MSG_MAIN = _UxGT("Hauptmenü"); LSTR MSG_ADVANCED_SETTINGS = _UxGT("Erw. Einstellungen"); + LSTR MSG_TOOLBAR_SETUP = _UxGT("Toolbar Einstellung"); + LSTR MSG_OPTION_DISABLED = _UxGT("Option Deaktiviert"); LSTR MSG_CONFIGURATION = _UxGT("Konfiguration"); LSTR MSG_RUN_AUTO_FILES = _UxGT("Autostart"); LSTR MSG_DISABLE_STEPPERS = _UxGT("Motoren deaktivieren"); // M84 :: Max length 19 characters @@ -64,6 +69,7 @@ namespace Language_de { LSTR MSG_AUTO_HOME_Z = _UxGT("Home Z"); LSTR MSG_FILAMENT_SET = _UxGT("Fila. Einstellungen"); LSTR MSG_FILAMENT_MAN = _UxGT("Filament Management"); + LSTR MSG_MANUAL_LEVELING = _UxGT("Manuell Nivellierung"); LSTR MSG_LEVBED_FL = _UxGT("Vorne Links"); LSTR MSG_LEVBED_FR = _UxGT("Vorne Rechts"); LSTR MSG_LEVBED_C = _UxGT("Mitte"); @@ -96,7 +102,14 @@ namespace Language_de { LSTR MSG_PREHEAT_1_ALL = PREHEAT_1_LABEL _UxGT(" Alles Vorwärmen"); LSTR MSG_PREHEAT_1_BEDONLY = PREHEAT_1_LABEL _UxGT(" Bett Vorwärmen"); LSTR MSG_PREHEAT_1_SETTINGS = PREHEAT_1_LABEL _UxGT(" Einstellungen"); - + #ifdef PREHEAT_2_LABEL + LSTR MSG_PREHEAT_2 = PREHEAT_2_LABEL _UxGT(" Vorwärmen"); + LSTR MSG_PREHEAT_2_SETTINGS = PREHEAT_2_LABEL _UxGT(" Vorwärmen Konf"); + #endif + #ifdef PREHEAT_3_LABEL + LSTR MSG_PREHEAT_3 = PREHEAT_3_LABEL _UxGT(" Vorwärmen"); + LSTR MSG_PREHEAT_3_SETTINGS = PREHEAT_3_LABEL _UxGT(" Vorwärmen Konf"); + #endif LSTR MSG_PREHEAT_M = _UxGT("$ Vorwärmen"); LSTR MSG_PREHEAT_M_H = _UxGT("$ Vorwärmen") " ~"; LSTR MSG_PREHEAT_M_END = _UxGT("$ Extr. Vorwärmen"); @@ -143,10 +156,19 @@ namespace Language_de { LSTR MSG_MESH_VIEW = _UxGT("Netz ansehen"); LSTR MSG_EDITING_STOPPED = _UxGT("Netzbearb. angeh."); LSTR MSG_NO_VALID_MESH = _UxGT("Kein gültiges Netz"); + LSTR MSG_ACTIVATE_MESH = _UxGT("Nivellierung aktiv."); LSTR MSG_PROBING_POINT = _UxGT("Messpunkt"); LSTR MSG_MESH_X = _UxGT("Index X"); LSTR MSG_MESH_Y = _UxGT("Index Y"); + LSTR MSG_MESH_INSET = _UxGT("Mesh-Einsatz"); + LSTR MSG_MESH_MIN_X = _UxGT("Mesh X Minimum"); + LSTR MSG_MESH_MAX_X = _UxGT("Mesh X Maximum"); + LSTR MSG_MESH_MIN_Y = _UxGT("Mesh Y Minimum"); + LSTR MSG_MESH_MAX_Y = _UxGT("Mesh Y Maximum"); + LSTR MSG_MESH_AMAX = _UxGT("Bereich maximieren"); + LSTR MSG_MESH_CENTER = _UxGT("Center Area"); LSTR MSG_MESH_EDIT_Z = _UxGT("Z-Wert"); + LSTR MSG_MESH_CANCEL = _UxGT("Mesh abgebrochen"); LSTR MSG_CUSTOM_COMMANDS = _UxGT("Benutzer-Menü"); LSTR MSG_M48_TEST = _UxGT("M48 Sondentest"); LSTR MSG_M48_POINT = _UxGT("M48 Punkt"); @@ -165,6 +187,9 @@ namespace Language_de { LSTR MSG_UBL_TOOLS = _UxGT("UBL-Werkzeuge"); LSTR MSG_UBL_LEVEL_BED = _UxGT("Unified Bed Leveling"); LSTR MSG_LCD_TILTING_MESH = _UxGT("Berührungspunkt"); + LSTR MSG_UBL_TILT_MESH = _UxGT("Tilt Mesh"); + LSTR MSG_UBL_TILTING_GRID = _UxGT("Tilting Grid Size"); + LSTR MSG_UBL_MESH_TILTED = _UxGT("Mesh Tilted"); LSTR MSG_UBL_MANUAL_MESH = _UxGT("Netz manuell erst."); LSTR MSG_UBL_MESH_WIZARD = _UxGT("UBL Netz Assistent"); LSTR MSG_UBL_BC_INSERT = _UxGT("Unterlegen & messen"); @@ -183,14 +208,12 @@ namespace Language_de { LSTR MSG_UBL_DONE_EDITING_MESH = _UxGT("Bearbeitung beendet"); LSTR MSG_UBL_BUILD_CUSTOM_MESH = _UxGT("Eigenes Netz erst."); LSTR MSG_UBL_BUILD_MESH_MENU = _UxGT("Netz erstellen"); - #if HAS_PREHEAT - LSTR MSG_UBL_BUILD_MESH_M = _UxGT("$ Netz erstellen"); - LSTR MSG_UBL_VALIDATE_MESH_M = _UxGT("$ Netz validieren"); - #endif + LSTR MSG_UBL_BUILD_MESH_M = _UxGT("$ Netz erstellen"); LSTR MSG_UBL_BUILD_COLD_MESH = _UxGT("Netz erstellen kalt"); LSTR MSG_UBL_MESH_HEIGHT_ADJUST = _UxGT("Netzhöhe einst."); LSTR MSG_UBL_MESH_HEIGHT_AMOUNT = _UxGT("Höhe"); LSTR MSG_UBL_VALIDATE_MESH_MENU = _UxGT("Netz validieren"); + LSTR MSG_UBL_VALIDATE_MESH_M = _UxGT("$ Netz validieren"); LSTR MSG_UBL_VALIDATE_CUSTOM_MESH = _UxGT("Eig. Netz validieren"); LSTR MSG_G26_HEATING_BED = _UxGT("G26 heizt Bett"); LSTR MSG_G26_HEATING_NOZZLE = _UxGT("G26 Düse aufheizen"); @@ -215,6 +238,8 @@ namespace Language_de { LSTR MSG_UBL_MANUAL_FILLIN = _UxGT("Manuelles Füllen"); LSTR MSG_UBL_SMART_FILLIN = _UxGT("Cleveres Füllen"); LSTR MSG_UBL_FILLIN_MESH = _UxGT("Netz Füllen"); + LSTR MSG_UBL_MESH_FILLED = _UxGT("Fehlende Punkte erg."); + LSTR MSG_UBL_MESH_INVALID = _UxGT("Ungültiges Netz"); LSTR MSG_UBL_INVALIDATE_ALL = _UxGT("Alles annullieren"); LSTR MSG_UBL_INVALIDATE_CLOSEST = _UxGT("Nächstlieg. ann."); LSTR MSG_UBL_FINE_TUNE_ALL = _UxGT("Feineinst. Alles"); @@ -223,6 +248,7 @@ namespace Language_de { LSTR MSG_UBL_STORAGE_SLOT = _UxGT("Speicherort"); LSTR MSG_UBL_LOAD_MESH = _UxGT("Bettnetz laden"); LSTR MSG_UBL_SAVE_MESH = _UxGT("Bettnetz speichern"); + LSTR MSG_UBL_INVALID_SLOT = _UxGT("Wähle einen Mesh-Slot"); LSTR MSG_MESH_LOADED = _UxGT("Netz %i geladen"); LSTR MSG_MESH_SAVED = _UxGT("Netz %i gespeichert"); LSTR MSG_UBL_NO_STORAGE = _UxGT("Kein Speicher"); @@ -231,12 +257,12 @@ namespace Language_de { LSTR MSG_UBL_Z_OFFSET = _UxGT("Z-Versatz: "); LSTR MSG_UBL_Z_OFFSET_STOPPED = _UxGT("Z-Versatz angehalten"); LSTR MSG_UBL_STEP_BY_STEP_MENU = _UxGT("Schrittweises UBL"); - LSTR MSG_UBL_1_BUILD_COLD_MESH = _UxGT("1.Netz erstellen kalt"); - LSTR MSG_UBL_2_SMART_FILLIN = _UxGT("2.Cleveres Füllen"); + LSTR MSG_UBL_1_BUILD_COLD_MESH = _UxGT("1.Netz kalt erstellen"); + LSTR MSG_UBL_2_SMART_FILLIN = _UxGT("2.Intelligent Füllen"); LSTR MSG_UBL_3_VALIDATE_MESH_MENU = _UxGT("3.Netz validieren"); - LSTR MSG_UBL_4_FINE_TUNE_ALL = _UxGT("4.Feineinst. Alles"); + LSTR MSG_UBL_4_FINE_TUNE_ALL = _UxGT("4.Alles Feineinst."); LSTR MSG_UBL_5_VALIDATE_MESH_MENU = _UxGT("5.Netz validieren"); - LSTR MSG_UBL_6_FINE_TUNE_ALL = _UxGT("6.Feineinst. Alles"); + LSTR MSG_UBL_6_FINE_TUNE_ALL = _UxGT("6.Alles Feineinst."); LSTR MSG_UBL_7_SAVE_MESH = _UxGT("7.Bettnetz speichern"); LSTR MSG_LED_CONTROL = _UxGT("Licht-Steuerung"); @@ -315,7 +341,11 @@ namespace Language_de { LSTR MSG_PID_AUTOTUNE_E = _UxGT("PID Autotune *"); LSTR MSG_PID_CYCLE = _UxGT("PID Zyklus"); LSTR MSG_PID_AUTOTUNE_DONE = _UxGT("PID Tuning fertig"); - LSTR MSG_PID_BAD_EXTRUDER_NUM = _UxGT("Autotune fehlge.! Falscher Extruder"); + LSTR MSG_PID_AUTOTUNE_FAILED = _UxGT("PID Autotune fehlge.!"); + LSTR MSG_BAD_EXTRUDER_NUM = _UxGT("ungültiger Extruder."); + LSTR MSG_TEMP_TOO_HIGH = _UxGT("Temperatur zu hoch."); + LSTR MSG_TIMEOUT = _UxGT("Timeout."); + LSTR MSG_PID_BAD_EXTRUDER_NUM = _UxGT("Autotune fehlge.! Ungültiger Extruder"); LSTR MSG_PID_TEMP_TOO_HIGH = _UxGT("Autotune fehlge.! Temperatur zu hoch."); LSTR MSG_PID_TIMEOUT = _UxGT("Autotune fehlge.! Timeout."); LSTR MSG_MPC_MEASURING_AMBIENT = _UxGT("teste Wärmeverlust"); @@ -334,14 +364,14 @@ namespace Language_de { LSTR MSG_VB_JERK = _UxGT("Max ") STR_B _UxGT(" Jerk"); LSTR MSG_VC_JERK = _UxGT("Max ") STR_C _UxGT(" Jerk"); LSTR MSG_VN_JERK = _UxGT("Max @ Jerk"); - LSTR MSG_VE_JERK = _UxGT("Max E Jerk"); + LSTR MSG_VE_JERK = _UxGT("Max ") STR_E _UxGT(" Jerk"); LSTR MSG_JUNCTION_DEVIATION = _UxGT("Junction Dev"); LSTR MSG_MAX_SPEED = _UxGT("Max Geschw. (mm/s)"); LSTR MSG_VMAX_A = _UxGT("V max ") STR_A; LSTR MSG_VMAX_B = _UxGT("V max ") STR_B; LSTR MSG_VMAX_C = _UxGT("V max ") STR_C; LSTR MSG_VMAX_N = _UxGT("V max @"); - LSTR MSG_VMAX_E = _UxGT("V max E"); + LSTR MSG_VMAX_E = _UxGT("V max ") STR_E; LSTR MSG_VMAX_EN = _UxGT("V max *"); LSTR MSG_VMIN = _UxGT("V min "); LSTR MSG_VTRAV_MIN = _UxGT("V min Leerfahrt"); @@ -350,7 +380,7 @@ namespace Language_de { LSTR MSG_AMAX_B = _UxGT("A max ") STR_B; LSTR MSG_AMAX_C = _UxGT("A max ") STR_C; LSTR MSG_AMAX_N = _UxGT("A max @"); - LSTR MSG_AMAX_E = _UxGT("A max E"); + LSTR MSG_AMAX_E = _UxGT("A max ") STR_E; LSTR MSG_AMAX_EN = _UxGT("A max *"); LSTR MSG_A_RETRACT = _UxGT("A Einzug"); LSTR MSG_A_TRAVEL = _UxGT("A Leerfahrt"); @@ -378,6 +408,7 @@ namespace Language_de { LSTR MSG_CONTRAST = _UxGT("LCD-Kontrast"); LSTR MSG_BRIGHTNESS = _UxGT("LCD-Helligkeit"); LSTR MSG_LCD_TIMEOUT_SEC = _UxGT("LCD-Ruhezustand (s)"); + LSTR MSG_SCREEN_TIMEOUT = _UxGT("LCD Timeout (m)"); LSTR MSG_BRIGHTNESS_OFF = _UxGT("LCD ausschalten"); LSTR MSG_STORE_EEPROM = _UxGT("Konfig. speichern"); LSTR MSG_LOAD_EEPROM = _UxGT("Konfig. laden"); @@ -391,6 +422,10 @@ namespace Language_de { LSTR MSG_RESET_PRINTER = _UxGT("Drucker neustarten"); LSTR MSG_REFRESH = LCD_STR_REFRESH _UxGT("Aktualisieren"); LSTR MSG_INFO_SCREEN = _UxGT("Info"); + LSTR MSG_INFO_MACHINENAME = _UxGT("Machine Name"); + LSTR MSG_INFO_SIZE = _UxGT("Größe"); + LSTR MSG_INFO_FWVERSION = _UxGT("Firmware Version"); + LSTR MSG_INFO_BUILD = _UxGT("Build Datum"); LSTR MSG_PREPARE = _UxGT("Vorbereitung"); LSTR MSG_TUNE = _UxGT("Justierung"); LSTR MSG_POWER_MONITOR = _UxGT("Power Monitor"); @@ -417,6 +452,7 @@ namespace Language_de { LSTR MSG_BUTTON_RESUME = _UxGT("Fortsetzen"); LSTR MSG_BUTTON_ADVANCED = _UxGT("Erweitert"); LSTR MSG_BUTTON_SAVE = _UxGT("Speichern"); + LSTR MSG_BUTTON_PURGE = _UxGT("Reinigen"); LSTR MSG_PAUSING = _UxGT("Pause..."); LSTR MSG_PAUSE_PRINT = _UxGT("SD-Druck pausieren"); LSTR MSG_ADVANCED_PAUSE = _UxGT("Erweiterte Pause"); @@ -439,9 +475,12 @@ namespace Language_de { LSTR MSG_REMAINING_TIME = _UxGT("Verbleiben"); LSTR MSG_PRINT_ABORTED = _UxGT("Druck abgebrochen"); LSTR MSG_PRINT_DONE = _UxGT("Druck fertig"); + LSTR MSG_PRINTER_KILLED = _UxGT("Drucker killed!"); + LSTR MSG_TURN_OFF = _UxGT("Drucker ausschalten"); LSTR MSG_NO_MOVE = _UxGT("Motoren angeschaltet"); LSTR MSG_KILLED = _UxGT("ABGEBROCHEN"); LSTR MSG_STOPPED = _UxGT("ANGEHALTEN"); + LSTR MSG_FWRETRACT = _UxGT("Firmware Retract"); LSTR MSG_CONTROL_RETRACT = _UxGT("Einzug mm"); LSTR MSG_CONTROL_RETRACT_SWAP = _UxGT("Wechs. Einzug mm"); LSTR MSG_CONTROL_RETRACTF = _UxGT("V Einzug"); @@ -507,6 +546,9 @@ namespace Language_de { LSTR MSG_ZPROBE_XOFFSET = _UxGT("Sondenversatz X"); LSTR MSG_ZPROBE_YOFFSET = _UxGT("Sondenversatz Y"); LSTR MSG_ZPROBE_ZOFFSET = _UxGT("Sondenversatz Z"); + LSTR MSG_ZPROBE_MARGIN = _UxGT("Sondenrand"); + LSTR MSG_Z_FEED_RATE = _UxGT("Z-Vorschub"); + LSTR MSG_ENABLE_HS_MODE = _UxGT("HS-Modus aktivieren"); LSTR MSG_MOVE_NOZZLE_TO_BED = _UxGT("Bewege Düse zum Bett"); LSTR MSG_BABYSTEP_X = _UxGT("Babystep X"); LSTR MSG_BABYSTEP_Y = _UxGT("Babystep Y"); @@ -570,33 +612,37 @@ namespace Language_de { LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Helligkeit"); LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("Falscher Drucker"); + LSTR MSG_COLORS_GET = _UxGT("Farbe"); + LSTR MSG_COLORS_SELECT = _UxGT("Farben auswählen"); + LSTR MSG_COLORS_APPLIED = _UxGT("Farben verwenden"); + LSTR MSG_COLORS_RED = _UxGT("Rot"); + LSTR MSG_COLORS_GREEN = _UxGT("Grün"); + LSTR MSG_COLORS_BLUE = _UxGT("Blau"); + LSTR MSG_COLORS_WHITE = _UxGT("Weiß"); + LSTR MSG_UI_LANGUAGE = _UxGT("UI Sprache"); + LSTR MSG_SOUND_ENABLE = _UxGT("Ton aktivieren"); + LSTR MSG_LOCKSCREEN = _UxGT("Bildschirm sperren"); + LSTR MSG_LOCKSCREEN_LOCKED = _UxGT("Drucker ist gesperrt,"); + LSTR MSG_LOCKSCREEN_UNLOCK = _UxGT("Scrollen zum Entsper."); + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_MEDIA_NOT_INSERTED = _UxGT("Kein Medium eingelegt."); - LSTR MSG_PLEASE_WAIT_REBOOT = _UxGT("Bitte auf Neustart warten. "); - LSTR MSG_PLEASE_PREHEAT = _UxGT("Bitte das Hot-End vorheizen."); + LSTR MSG_PLEASE_WAIT_REBOOT = _UxGT("Bitte auf Neustart warten."); + LSTR MSG_PLEASE_PREHEAT = _UxGT("Bitte das Hotend vorheizen."); LSTR MSG_INFO_PRINT_COUNT_RESET = _UxGT("Druckzähler zurücksetzen"); LSTR MSG_INFO_PRINT_COUNT = _UxGT("Gesamte Drucke"); LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Komplette Drucke"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Gesamte Druckzeit"); LSTR MSG_INFO_PRINT_LONGEST = _UxGT("Längste Druckzeit"); LSTR MSG_INFO_PRINT_FILAMENT = _UxGT("Gesamt Extrudiert"); - LSTR MSG_COLORS_GET = _UxGT("Farbe"); - LSTR MSG_COLORS_SELECT = _UxGT("Farben auswählen"); - LSTR MSG_COLORS_APPLIED = _UxGT("Farben verwenden"); - LSTR MSG_COLORS_RED = _UxGT("Rot"); - LSTR MSG_COLORS_GREEN = _UxGT("Grün"); - LSTR MSG_COLORS_BLUE = _UxGT("Blau"); - LSTR MSG_COLORS_WHITE = _UxGT("Weiß"); - LSTR MSG_UI_LANGUAGE = _UxGT("UI Sprache"); - LSTR MSG_SOUND_ENABLE = _UxGT("Ton aktivieren"); - LSTR MSG_LOCKSCREEN = _UxGT("Bildschirm sperren"); #else + LSTR MSG_PLEASE_WAIT_REBOOT = _UxGT("Auf Neustart warten"); + LSTR MSG_PLEASE_PREHEAT = _UxGT("Bitte vorheizen"); LSTR MSG_INFO_PRINT_COUNT = _UxGT("Drucke"); LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Komplette"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Gesamte"); LSTR MSG_INFO_PRINT_LONGEST = _UxGT("Längste"); LSTR MSG_INFO_PRINT_FILAMENT = _UxGT("Extrud."); - LSTR MSG_PLEASE_PREHEAT = _UxGT("Bitte vorheizen"); #endif LSTR MSG_INFO_MIN_TEMP = _UxGT("Min Temp"); @@ -613,10 +659,14 @@ namespace Language_de { LSTR MSG_FILAMENT_CHANGE_OPTION_HEADER = _UxGT("FORTS. OPTIONEN:"); LSTR MSG_FILAMENT_CHANGE_OPTION_PURGE = _UxGT("Mehr entladen"); LSTR MSG_FILAMENT_CHANGE_OPTION_RESUME = _UxGT("Druck weiter"); + LSTR MSG_FILAMENT_CHANGE_PURGE_CONTINUE = _UxGT("Löschen o. fortfah.?"); LSTR MSG_FILAMENT_CHANGE_NOZZLE = _UxGT(" Düse: "); LSTR MSG_RUNOUT_SENSOR = _UxGT("Runout-Sensor"); LSTR MSG_RUNOUT_DISTANCE_MM = _UxGT("Runout-Weg mm"); LSTR MSG_RUNOUT_ENABLE = _UxGT("Runout aktivieren"); + LSTR MSG_RUNOUT_ACTIVE = _UxGT("Runout aktiv"); + LSTR MSG_INVERT_EXTRUDER = _UxGT("Invert Extruder"); + LSTR MSG_EXTRUDER_MIN_TEMP = _UxGT("Extruder Min Temp."); LSTR MSG_FANCHECK = _UxGT("Lüftergeschw. prüfen"); LSTR MSG_KILL_HOMING_FAILED = _UxGT("Homing gescheitert"); LSTR MSG_LCD_PROBING_FAILED = _UxGT("Probing gescheitert"); @@ -660,6 +710,7 @@ namespace Language_de { LSTR MSG_VTOOLS_RESET = _UxGT("V-Tools ist resetet"); LSTR MSG_START_Z = _UxGT("Z Start:"); LSTR MSG_END_Z = _UxGT("Z Ende:"); + LSTR MSG_GAMES = _UxGT("Spiele"); LSTR MSG_BRICKOUT = _UxGT("Brickout"); LSTR MSG_INVADERS = _UxGT("Invaders"); @@ -683,6 +734,7 @@ namespace Language_de { // // Die Filament-Change-Bildschirme können bis zu 3 Zeilen auf einem 4-Zeilen-Display anzeigen // ...oder 2 Zeilen auf einem 3-Zeilen-Display. + #if LCD_HEIGHT >= 4 LSTR MSG_ADVANCED_PAUSE_WAITING = _UxGT(MSG_2_LINE("Knopf drücken um", "Druck fortzusetzen")); LSTR MSG_PAUSE_PRINT_PARKING = _UxGT(MSG_2_LINE("Druck ist", "pausiert...")); @@ -720,10 +772,11 @@ namespace Language_de { LSTR MSG_BACKLASH = _UxGT("Spiel"); LSTR MSG_BACKLASH_CORRECTION = _UxGT("Korrektur"); LSTR MSG_BACKLASH_SMOOTHING = _UxGT("Glätten"); + LSTR MSG_LEVEL_X_AXIS = _UxGT("X Achse leveln"); LSTR MSG_AUTO_CALIBRATE = _UxGT("Auto. Kalibiren"); #if ENABLED(TOUCH_UI_FTDI_EVE) - LSTR MSG_HEATER_TIMEOUT = _UxGT("Idle Timeout, Temperatur fällt. Drücke Okay, um erneut aufzuheizen und fortzufahren."); + LSTR MSG_HEATER_TIMEOUT = _UxGT("Idle Timeout, Temperatur gefallen. Drücke Okay, um erneut aufzuheizen und fortzufahren."); #else LSTR MSG_HEATER_TIMEOUT = _UxGT("Heizungs Timeout"); #endif diff --git a/Marlin/src/lcd/language/language_el.h b/Marlin/src/lcd/language/language_el.h index 47d6a5b2da..41b73ddc57 100644 --- a/Marlin/src/lcd/language/language_el.h +++ b/Marlin/src/lcd/language/language_el.h @@ -92,6 +92,7 @@ namespace Language_el { LSTR MSG_MOVE_X = _UxGT("Μετακίνηση X"); LSTR MSG_MOVE_Y = _UxGT("Μετακίνηση Y"); LSTR MSG_MOVE_Z = _UxGT("Μετακίνηση Z"); + LSTR MSG_MOVE_N = _UxGT("Μετακίνηση @"); LSTR MSG_MOVE_E = _UxGT("Εξωθητής"); LSTR MSG_MOVE_EN = _UxGT("Εξωθητής *"); LSTR MSG_MOVE_N_MM = _UxGT("Μετακίνηση %s μμ"); diff --git a/Marlin/src/lcd/language/language_el_gr.h b/Marlin/src/lcd/language/language_el_gr.h index bd2e7d595d..7306aab123 100644 --- a/Marlin/src/lcd/language/language_el_gr.h +++ b/Marlin/src/lcd/language/language_el_gr.h @@ -81,6 +81,7 @@ namespace Language_el_gr { LSTR MSG_MOVE_X = _UxGT("Μετακίνηση X"); LSTR MSG_MOVE_Y = _UxGT("Μετακίνηση Y"); LSTR MSG_MOVE_Z = _UxGT("Μετακίνηση Z"); + LSTR MSG_MOVE_N = _UxGT("Μετακίνηση @"); LSTR MSG_MOVE_E = _UxGT("Εξωθητήρας"); LSTR MSG_MOVE_EN = _UxGT("Εξωθητήρας *"); LSTR MSG_MOVE_N_MM = _UxGT("Μετακίνηση %s μμ"); diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index 49aea79e24..3b9b1d90c8 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -254,6 +254,7 @@ namespace Language_en { LSTR MSG_UBL_SMART_FILLIN = _UxGT("Smart Fill-in"); LSTR MSG_UBL_FILLIN_MESH = _UxGT("Fill-in Mesh"); LSTR MSG_UBL_MESH_FILLED = _UxGT("Missing Points Filled"); + LSTR MSG_UBL_MESH_INVALID = _UxGT("Invalid Mesh"); LSTR MSG_UBL_INVALIDATE_ALL = _UxGT("Invalidate All"); LSTR MSG_UBL_INVALIDATE_CLOSEST = _UxGT("Invalidate Closest"); LSTR MSG_UBL_FINE_TUNE_ALL = _UxGT("Fine Tune All"); diff --git a/Marlin/src/lcd/language/language_es.h b/Marlin/src/lcd/language/language_es.h index 9cb86c5c32..5f88f8426d 100644 --- a/Marlin/src/lcd/language/language_es.h +++ b/Marlin/src/lcd/language/language_es.h @@ -226,6 +226,7 @@ namespace Language_es { LSTR MSG_MOVE_X = _UxGT("Mover X"); LSTR MSG_MOVE_Y = _UxGT("Mover Y"); LSTR MSG_MOVE_Z = _UxGT("Mover Z"); + LSTR MSG_MOVE_N = _UxGT("Mover @"); LSTR MSG_MOVE_E = _UxGT("Extrusor"); LSTR MSG_MOVE_EN = _UxGT("Extrusor *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Hotend muy frio"); diff --git a/Marlin/src/lcd/language/language_eu.h b/Marlin/src/lcd/language/language_eu.h index 5504d4da94..210fdbdc16 100644 --- a/Marlin/src/lcd/language/language_eu.h +++ b/Marlin/src/lcd/language/language_eu.h @@ -136,6 +136,7 @@ namespace Language_eu { LSTR MSG_MOVE_X = _UxGT("Mugitu X"); LSTR MSG_MOVE_Y = _UxGT("Mugitu Y"); LSTR MSG_MOVE_Z = _UxGT("Mugitu Z"); + LSTR MSG_MOVE_N = _UxGT("Mugitu @"); LSTR MSG_MOVE_E = _UxGT("Estrusorea"); LSTR MSG_MOVE_EN = _UxGT("Estrusorea *"); LSTR MSG_MOVE_N_MM = _UxGT("Mugitu $mm"); diff --git a/Marlin/src/lcd/language/language_fi.h b/Marlin/src/lcd/language/language_fi.h index 8fd53a79e3..ff1c23eee7 100644 --- a/Marlin/src/lcd/language/language_fi.h +++ b/Marlin/src/lcd/language/language_fi.h @@ -69,6 +69,7 @@ namespace Language_fi { LSTR MSG_MOVE_X = _UxGT("Liikuta X"); LSTR MSG_MOVE_Y = _UxGT("Liikuta Y"); LSTR MSG_MOVE_Z = _UxGT("Liikuta Z"); + LSTR MSG_MOVE_N = _UxGT("Liikuta @"); LSTR MSG_MOVE_E = _UxGT("Extruder"); LSTR MSG_MOVE_EN = _UxGT("Extruder *"); LSTR MSG_MOVE_N_MM = _UxGT("Liikuta $mm"); diff --git a/Marlin/src/lcd/language/language_gl.h b/Marlin/src/lcd/language/language_gl.h index 827130de6c..9ae64f0809 100644 --- a/Marlin/src/lcd/language/language_gl.h +++ b/Marlin/src/lcd/language/language_gl.h @@ -223,6 +223,7 @@ namespace Language_gl { LSTR MSG_MOVE_X = _UxGT("Mover X"); LSTR MSG_MOVE_Y = _UxGT("Mover Y"); LSTR MSG_MOVE_Z = _UxGT("Mover Z"); + LSTR MSG_MOVE_N = _UxGT("Mover @"); LSTR MSG_MOVE_E = _UxGT("Extrusor"); LSTR MSG_MOVE_EN = _UxGT("Extrusor *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Bico moi frío"); diff --git a/Marlin/src/lcd/language/language_hr.h b/Marlin/src/lcd/language/language_hr.h index 10f11f616f..08ff6cc38c 100644 --- a/Marlin/src/lcd/language/language_hr.h +++ b/Marlin/src/lcd/language/language_hr.h @@ -78,6 +78,10 @@ namespace Language_hr { LSTR MSG_LEVEL_BED = _UxGT("Niveliraj bed"); LSTR MSG_MOVE_X = _UxGT("Miči X"); LSTR MSG_MOVE_Y = _UxGT("Miči Y"); + LSTR MSG_MOVE_Z = _UxGT("Miči Z"); + LSTR MSG_MOVE_N = _UxGT("Miči @"); + LSTR MSG_MOVE_E = _UxGT("Miči E"); + LSTR MSG_MOVE_EN = _UxGT("Miči *"); LSTR MSG_MOVE_N_MM = _UxGT("Miči $mm"); LSTR MSG_MOVE_01MM = _UxGT("Miči 0.1mm"); LSTR MSG_MOVE_1MM = _UxGT("Miči 1mm"); diff --git a/Marlin/src/lcd/language/language_jp_kana.h b/Marlin/src/lcd/language/language_jp_kana.h index 0a53ee50d2..bc8c9ba40e 100644 --- a/Marlin/src/lcd/language/language_jp_kana.h +++ b/Marlin/src/lcd/language/language_jp_kana.h @@ -92,7 +92,9 @@ namespace Language_jp_kana { LSTR MSG_MOVE_X = _UxGT("Xジク イドウ"); // "Move X" LSTR MSG_MOVE_Y = _UxGT("Yジク イドウ"); // "Move Y" LSTR MSG_MOVE_Z = _UxGT("Zジク イドウ"); // "Move Z" + LSTR MSG_MOVE_N = _UxGT("@ジク イドウ"); // "Move @" LSTR MSG_MOVE_E = _UxGT("エクストルーダー"); // "Extruder" + LSTR MSG_MOVE_EN = _UxGT("* エクストルーダー"); // "En" LSTR MSG_MOVE_N_MM = _UxGT("$mm イドウ"); // "Move 0.025mm" LSTR MSG_MOVE_01MM = _UxGT("0.1mm イドウ"); // "Move 0.1mm" LSTR MSG_MOVE_1MM = _UxGT(" 1mm イドウ"); // "Move 1mm" diff --git a/Marlin/src/lcd/language/language_nl.h b/Marlin/src/lcd/language/language_nl.h index ca51198034..8aa74d7e9f 100644 --- a/Marlin/src/lcd/language/language_nl.h +++ b/Marlin/src/lcd/language/language_nl.h @@ -84,6 +84,7 @@ namespace Language_nl { LSTR MSG_MOVE_X = _UxGT("Verplaats X"); LSTR MSG_MOVE_Y = _UxGT("Verplaats Y"); LSTR MSG_MOVE_Z = _UxGT("Verplaats Z"); + LSTR MSG_MOVE_N = _UxGT("Verplaats @"); LSTR MSG_MOVE_E = _UxGT("Extruder"); LSTR MSG_MOVE_EN = _UxGT("Extruder *"); LSTR MSG_MOVE_N_MM = _UxGT("Verplaats $mm"); diff --git a/Marlin/src/lcd/language/language_pl.h b/Marlin/src/lcd/language/language_pl.h index 34155f87fe..635866baf1 100644 --- a/Marlin/src/lcd/language/language_pl.h +++ b/Marlin/src/lcd/language/language_pl.h @@ -235,6 +235,7 @@ namespace Language_pl { LSTR MSG_MOVE_X = _UxGT("Przesuń w X"); LSTR MSG_MOVE_Y = _UxGT("Przesuń w Y"); LSTR MSG_MOVE_Z = _UxGT("Przesuń w Z"); + LSTR MSG_MOVE_N = _UxGT("Przesuń w @"); LSTR MSG_MOVE_E = _UxGT("Ekstruzja (os E)"); LSTR MSG_MOVE_EN = _UxGT("Ekstruzja (os E) *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Dysza za zimna"); diff --git a/Marlin/src/lcd/language/language_pt.h b/Marlin/src/lcd/language/language_pt.h index 69df8bdf54..55d9c1d7c5 100644 --- a/Marlin/src/lcd/language/language_pt.h +++ b/Marlin/src/lcd/language/language_pt.h @@ -78,6 +78,7 @@ namespace Language_pt { LSTR MSG_MOVE_X = _UxGT("Mover X"); LSTR MSG_MOVE_Y = _UxGT("Mover Y"); LSTR MSG_MOVE_Z = _UxGT("Mover Z"); + LSTR MSG_MOVE_N = _UxGT("Mover @"); LSTR MSG_MOVE_E = _UxGT("Mover Extrusor"); LSTR MSG_MOVE_EN = _UxGT("Mover Extrusor *"); LSTR MSG_MOVE_N_MM = _UxGT("Mover $mm"); diff --git a/Marlin/src/lcd/language/language_pt_br.h b/Marlin/src/lcd/language/language_pt_br.h index 0f0f8c5287..1d07b2b94f 100644 --- a/Marlin/src/lcd/language/language_pt_br.h +++ b/Marlin/src/lcd/language/language_pt_br.h @@ -209,6 +209,7 @@ namespace Language_pt_br { LSTR MSG_MOVE_X = _UxGT("Mover X"); LSTR MSG_MOVE_Y = _UxGT("Mover Y"); LSTR MSG_MOVE_Z = _UxGT("Mover Z"); + LSTR MSG_MOVE_N = _UxGT("Mover @"); LSTR MSG_MOVE_E = _UxGT("Mover Extrusor"); LSTR MSG_MOVE_EN = _UxGT("Mover Extrusor *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Extrus. mto fria"); diff --git a/Marlin/src/lcd/language/language_ro.h b/Marlin/src/lcd/language/language_ro.h index 3bd15f18a4..2cf6fff263 100644 --- a/Marlin/src/lcd/language/language_ro.h +++ b/Marlin/src/lcd/language/language_ro.h @@ -222,6 +222,7 @@ namespace Language_ro { LSTR MSG_MOVE_X = _UxGT("Move X"); LSTR MSG_MOVE_Y = _UxGT("Move Y"); LSTR MSG_MOVE_Z = _UxGT("Move Z"); + LSTR MSG_MOVE_N = _UxGT("Move @"); LSTR MSG_MOVE_E = _UxGT("Extruder"); LSTR MSG_MOVE_EN = _UxGT("Extruder *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Capat Prea Rece"); diff --git a/Marlin/src/lcd/language/language_sv.h b/Marlin/src/lcd/language/language_sv.h index 6bfb7100f4..1342ccaad7 100644 --- a/Marlin/src/lcd/language/language_sv.h +++ b/Marlin/src/lcd/language/language_sv.h @@ -249,6 +249,7 @@ namespace Language_sv { LSTR MSG_MOVE_X = _UxGT("Flytta X"); LSTR MSG_MOVE_Y = _UxGT("Flytta Y"); LSTR MSG_MOVE_Z = _UxGT("Flytta Z"); + LSTR MSG_MOVE_N = _UxGT("Flytta @"); LSTR MSG_MOVE_E = _UxGT("Extruder"); LSTR MSG_MOVE_EN = _UxGT("Extruder *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Hetände för kall"); diff --git a/Marlin/src/lcd/language/language_tr.h b/Marlin/src/lcd/language/language_tr.h index c9967f72ec..cb2766306c 100644 --- a/Marlin/src/lcd/language/language_tr.h +++ b/Marlin/src/lcd/language/language_tr.h @@ -225,6 +225,7 @@ namespace Language_tr { LSTR MSG_MOVE_X = _UxGT("X Hareketi"); LSTR MSG_MOVE_Y = _UxGT("Y Hareketi"); LSTR MSG_MOVE_Z = _UxGT("Z Hareketi"); + LSTR MSG_MOVE_N = _UxGT("@ Hareketi"); LSTR MSG_MOVE_E = _UxGT("Ekstruder"); LSTR MSG_MOVE_EN = _UxGT("Ekstruder *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Nozul Çok Soğuk"); diff --git a/Marlin/src/lcd/language/language_vi.h b/Marlin/src/lcd/language/language_vi.h index 989a201d4d..27c6ee1181 100644 --- a/Marlin/src/lcd/language/language_vi.h +++ b/Marlin/src/lcd/language/language_vi.h @@ -198,6 +198,7 @@ namespace Language_vi { LSTR MSG_MOVE_X = _UxGT("Di chuyển X"); // Move X LSTR MSG_MOVE_Y = _UxGT("Di chuyển Y"); LSTR MSG_MOVE_Z = _UxGT("Di chuyển Z"); + LSTR MSG_MOVE_N = _UxGT("Di chuyển @"); LSTR MSG_MOVE_E = _UxGT("Máy đùn"); // Extruder LSTR MSG_MOVE_EN = _UxGT("Máy đùn *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Đầu nóng quá lạnh"); // Hotend too cold diff --git a/Marlin/src/lcd/language/language_zh_CN.h b/Marlin/src/lcd/language/language_zh_CN.h index fc61b020ff..4c5a94edcd 100644 --- a/Marlin/src/lcd/language/language_zh_CN.h +++ b/Marlin/src/lcd/language/language_zh_CN.h @@ -222,6 +222,7 @@ namespace Language_zh_CN { LSTR MSG_MOVE_X = _UxGT("移动X"); // "Move X" LSTR MSG_MOVE_Y = _UxGT("移动Y"); // "Move Y" LSTR MSG_MOVE_Z = _UxGT("移动Z"); // "Move Z" + LSTR MSG_MOVE_N = _UxGT("移动@"); // "Move @" LSTR MSG_MOVE_E = _UxGT("挤出机"); // "Extruder" LSTR MSG_MOVE_EN = _UxGT("挤出机 *"); // "Extruder" LSTR MSG_HOTEND_TOO_COLD = _UxGT("热端太冷"); diff --git a/Marlin/src/lcd/language/language_zh_TW.h b/Marlin/src/lcd/language/language_zh_TW.h index b35a486e4f..4eba832c4f 100644 --- a/Marlin/src/lcd/language/language_zh_TW.h +++ b/Marlin/src/lcd/language/language_zh_TW.h @@ -218,6 +218,7 @@ namespace Language_zh_TW { LSTR MSG_MOVE_X = _UxGT("移動X"); // "Move X" LSTR MSG_MOVE_Y = _UxGT("移動Y"); // "Move Y" LSTR MSG_MOVE_Z = _UxGT("移動Z"); // "Move Z" + LSTR MSG_MOVE_N = _UxGT("移動Q"); // "Move @" LSTR MSG_MOVE_E = _UxGT("擠出機"); // "Extruder" LSTR MSG_MOVE_EN = _UxGT("擠出機 *"); // "Extruder *" LSTR MSG_HOTEND_TOO_COLD = _UxGT("噴嘴溫度不夠"); // "Hotend too cold" diff --git a/Marlin/src/lcd/lcdprint.cpp b/Marlin/src/lcd/lcdprint.cpp index deec2b1778..7757379ac9 100644 --- a/Marlin/src/lcd/lcdprint.cpp +++ b/Marlin/src/lcd/lcdprint.cpp @@ -47,19 +47,19 @@ lcd_uint_t lcd_put_u8str_P(PGM_P const ptpl, const int8_t ind, const char *cstr/ const uint8_t *p = (uint8_t*)ptpl; int8_t n = maxlen; while (n > 0) { - wchar_t ch; - p = get_utf8_value_cb(p, read_byte_rom, &ch); - if (!ch) break; - if (ch == '=' || ch == '~' || ch == '*') { + lchar_t wc; + p = get_utf8_value_cb(p, read_byte_rom, wc); + if (!wc) break; + if (wc == '=' || wc == '~' || wc == '*') { if (ind >= 0) { - if (ch == '*') { lcd_put_wchar('E'); n--; } + if (wc == '*') { lcd_put_lchar('E'); n--; } if (n) { - int8_t inum = ind + ((ch == '=') ? 0 : LCD_FIRST_TOOL); + int8_t inum = ind + ((wc == '=') ? 0 : LCD_FIRST_TOOL); if (inum >= 10) { - lcd_put_wchar('0' + (inum / 10)); n--; + lcd_put_lchar('0' + (inum / 10)); n--; inum %= 10; } - if (n) { lcd_put_wchar('0' + inum); n--; } + if (n) { lcd_put_lchar('0' + inum); n--; } } } else { @@ -71,19 +71,19 @@ lcd_uint_t lcd_put_u8str_P(PGM_P const ptpl, const int8_t ind, const char *cstr/ break; } } - else if (ch == '$' && fstr) { + else if (wc == '$' && fstr) { n -= lcd_put_u8str_max_P(FTOP(fstr), n * (MENU_FONT_WIDTH)) / (MENU_FONT_WIDTH); } - else if (ch == '$' && cstr) { + else if (wc == '$' && cstr) { n -= lcd_put_u8str_max(cstr, n * (MENU_FONT_WIDTH)) / (MENU_FONT_WIDTH); } - else if (ch == '@') { - lcd_put_wchar(AXIS_CHAR(ind)); + else if (wc == '@') { + lcd_put_lchar(AXIS_CHAR(ind)); n--; } else { - lcd_put_wchar(ch); - n -= ch > 255 ? prop : 1; + lcd_put_lchar(wc); + n -= wc > 255 ? prop : 1; } } return n; @@ -97,10 +97,10 @@ int calculateWidth(PGM_P const pstr) { int n = 0; do { - wchar_t ch; - p = get_utf8_value_cb(p, read_byte_rom, &ch); - if (!ch) break; - n += (ch > 255) ? prop : 1; + lchar_t wc; + p = get_utf8_value_cb(p, read_byte_rom, wc); + if (!wc) break; + n += (wc > 255) ? prop : 1; } while (1); return n * MENU_FONT_WIDTH; diff --git a/Marlin/src/lcd/lcdprint.h b/Marlin/src/lcd/lcdprint.h index 2eb47c534b..bcf85cb693 100644 --- a/Marlin/src/lcd/lcdprint.h +++ b/Marlin/src/lcd/lcdprint.h @@ -138,7 +138,7 @@ int lcd_glyph_height(); * * @return the output width (in pixels on GLCD) */ -int lcd_put_wchar_max(const wchar_t c, const pixel_len_t max_length); +int lcd_put_lchar_max(const lchar_t &c, const pixel_len_t max_length); /** * @brief Draw a SRAM UTF-8 string @@ -267,17 +267,17 @@ inline int lcd_put_u8str(const lcd_uint_t col, const lcd_uint_t row, const char /** * @brief Draw a UTF-8 character with no width limit * - * @param c The wchar to draw + * @param c The lchar to draw * @return the output width (in pixels on GLCD) */ -inline int lcd_put_wchar(const wchar_t c) { return lcd_put_wchar_max(c, PIXEL_LEN_NOLIMIT); } +inline int lcd_put_lchar(const lchar_t &c) { return lcd_put_lchar_max(c, PIXEL_LEN_NOLIMIT); } /** * @param col * @param row */ -inline int lcd_put_wchar(const lcd_uint_t col, const lcd_uint_t row, const wchar_t c) { +inline int lcd_put_lchar(const lcd_uint_t col, const lcd_uint_t row, const lchar_t &c) { lcd_moveto(col, row); - return lcd_put_wchar(c); + return lcd_put_lchar(c); } /** diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 669d77e45f..aefce404cb 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -121,17 +121,9 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; bool MarlinUI::sound_on = ENABLED(SOUND_ON_DEFAULT); #endif -#if EITHER(PCA9632_BUZZER, HAS_BEEPER) - #if ENABLED(PCA9632_BUZZER) - #include "../feature/leds/pca9632.h" - #endif +#if ENABLED(PCA9632_BUZZER) void MarlinUI::buzz(const long duration, const uint16_t freq) { - if (!sound_on) return; - #if ENABLED(PCA9632_BUZZER) - PCA9632_buzz(duration, freq); - #elif HAS_BEEPER - buzzer.tone(duration, freq); - #endif + if (sound_on) PCA9632_buzz(duration, freq); } #endif @@ -424,26 +416,26 @@ void MarlinUI::init() { }; const uint8_t *p = (uint8_t*)string; - wchar_t ch; + lchar_t wc; if (wordwrap) { const uint8_t *wrd = nullptr; uint8_t c = 0; // find the end of the part for (;;) { if (!wrd) wrd = p; // Get word start /before/ advancing - p = get_utf8_value_cb(p, cb_read_byte, &ch); - const bool eol = !ch; // zero ends the string + p = get_utf8_value_cb(p, cb_read_byte, wc); + const bool eol = !wc; // zero ends the string // End or a break between phrases? - if (eol || ch == ' ' || ch == '-' || ch == '+' || ch == '.') { - if (!c && ch == ' ') { if (wrd) wrd++; continue; } // collapse extra spaces + if (eol || wc == ' ' || wc == '-' || wc == '+' || wc == '.') { + if (!c && wc == ' ') { if (wrd) wrd++; continue; } // collapse extra spaces // Past the right and the word is not too long? if (col + c > LCD_WIDTH && col >= (LCD_WIDTH) / 4) _newline(); // should it wrap? c += !eol; // +1 so the space will be printed col += c; // advance col to new position while (c) { // character countdown --c; // count down to zero - wrd = get_utf8_value_cb(wrd, cb_read_byte, &ch); // get characters again - lcd_put_wchar(ch); // character to the LCD + wrd = get_utf8_value_cb(wrd, cb_read_byte, wc); // get characters again + lcd_put_lchar(wc); // character to the LCD } if (eol) break; // all done! wrd = nullptr; // set up for next word @@ -453,9 +445,9 @@ void MarlinUI::init() { } else { for (;;) { - p = get_utf8_value_cb(p, cb_read_byte, &ch); - if (!ch) break; - lcd_put_wchar(ch); + p = get_utf8_value_cb(p, cb_read_byte, wc); + if (!wc) break; + lcd_put_lchar(wc); col++; if (col >= LCD_WIDTH) _newline(); } @@ -692,7 +684,7 @@ void MarlinUI::init() { if (old_frm != new_frm) { feedrate_percentage = new_frm; encoderPosition = 0; - #if BOTH(HAS_BUZZER, BEEP_ON_FEEDRATE_CHANGE) + #if BOTH(HAS_SOUND, BEEP_ON_FEEDRATE_CHANGE) static millis_t next_beep; #ifndef GOT_MS const millis_t ms = millis(); @@ -750,11 +742,12 @@ void MarlinUI::init() { UNUSED(clear_buttons); #endif - #if HAS_CHIRP - chirp(); // Buzz and wait. Is the delay needed for buttons to settle? - #if BOTH(HAS_MARLINUI_MENU, HAS_BEEPER) + chirp(); // Buzz and wait. Is the delay needed for buttons to settle? + + #if HAS_CHIRP && HAS_MARLINUI_MENU + #if HAS_BEEPER for (int8_t i = 5; i--;) { buzzer.tick(); delay(2); } - #elif HAS_MARLINUI_MENU + #else delay(10); #endif #endif @@ -1478,7 +1471,9 @@ void MarlinUI::init() { else if (print_job_timer.needsService(3)) msg = FPSTR(service3); #endif - else if (!no_welcome) msg = GET_TEXT_F(WELCOME_MSG); + // @advi3++ will detect the empty string and clear and pending wait screen + // else if (!no_welcome) msg = GET_TEXT_F(WELCOME_MSG); + else if (!no_welcome) msg = F(""); else if (ENABLED(DWIN_LCD_PROUI)) msg = F(""); diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index 63615b379f..3d6a7f61d0 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -28,30 +28,10 @@ #include "buttons.h" -#include "../inc/MarlinConfig.h" - -// @advi3++ -#ifdef O //ADVi3PP_UI -#include "../advi3pp/inc/advi3pp_marlin_ui.h" -#include "extui/ui_api.h" -#else - -#if HAS_BUZZER - #include "../libs/buzzer.h" -#endif - -#if ENABLED(SDSUPPORT) - #include "../sd/cardreader.h" -#endif - #if ENABLED(TOUCH_SCREEN_CALIBRATION) #include "tft_io/touch_calibration.h" #endif -#if ANY(HAS_MARLINUI_MENU, ULTIPANEL_FEEDMULTIPLY, SOFT_RESET_ON_KILL) - #define HAS_ENCODER_ACTION 1 -#endif - #if E_MANUAL > 1 #define MULTI_E_MANUAL 1 #endif @@ -198,6 +178,8 @@ typedef bool (*statusResetFunc_t)(); static void soon(const AxisEnum axis OPTARG(MULTI_E_MANUAL, const int8_t eindex=active_extruder)); }; + void lcd_move_axis(const AxisEnum); + #endif //////////////////////////////////////////// @@ -245,13 +227,13 @@ class MarlinUI { static constexpr bool sound_on = true; #endif - #if HAS_BUZZER + #if USE_MARLINUI_BUZZER static void buzz(const long duration, const uint16_t freq); static void buzz_m300(const long duration, const uint16_t freq); // @advi3++ #endif - FORCE_INLINE static void chirp() { - TERN_(HAS_CHIRP, TERN(HAS_BUZZER, buzz, BUZZ)(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ)); + static void chirp() { + TERN_(HAS_CHIRP, TERN(USE_MARLINUI_BUZZER, buzz, BUZZ)(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ)); } #if ENABLED(LCD_HAS_STATUS_INDICATORS) @@ -290,8 +272,8 @@ class MarlinUI { #endif #if LCD_BACKLIGHT_TIMEOUT - #define LCD_BKL_TIMEOUT_MIN 1 - #define LCD_BKL_TIMEOUT_MAX (60*60*18) // 18 hours max within uint16_t + #define LCD_BKL_TIMEOUT_MIN 1u + #define LCD_BKL_TIMEOUT_MAX UINT16_MAX // Slightly more than 18 hours static uint16_t lcd_backlight_timeout; static millis_t backlight_off_ms; static void refresh_backlight_timeout(); @@ -476,7 +458,7 @@ class MarlinUI { #endif static void quick_feedback(const bool clear_buttons=true); - #if HAS_BUZZER + #if HAS_SOUND static void completion_feedback(const bool good=true); #else static void completion_feedback(const bool=true) { TERN_(HAS_TOUCH_SLEEP, wakeup_screen()); } @@ -512,7 +494,7 @@ class MarlinUI { #endif static void draw_kill_screen(); - static void kill_screen(float temp, FSTR_P const lcd_error, FSTR_P const lcd_component); + static void kill_screen(float temp, FSTR_P const lcd_error, FSTR_P const lcd_component); // @advi3++ #if DISABLED(LIGHTWEIGHT_UI) static void draw_status_message(const bool blink); #endif @@ -715,11 +697,7 @@ class MarlinUI { static void update_buttons(); - #if HAS_ENCODER_NOISE - #ifndef ENCODER_SAMPLES - #define ENCODER_SAMPLES 10 - #endif - + #if ENABLED(ENCODER_NOISE_FILTER) /** * Some printers may have issues with EMI noise especially using a motherboard with 3.3V logic levels * it may cause the logical LOW to float into the undefined region and register as a logical HIGH @@ -810,5 +788,3 @@ class MarlinUI { #define LCD_MESSAGE(M) ui.set_status(GET_TEXT_F(M)) #define LCD_ALERTMESSAGE_F(S) ui.set_alert_status(F(S)) #define LCD_ALERTMESSAGE(M) ui.set_alert_status(GET_TEXT_F(M)) - -#endif // @advi3++ diff --git a/Marlin/src/lcd/menu/game/game.h b/Marlin/src/lcd/menu/game/game.h index 999aa78100..ba123cb98b 100644 --- a/Marlin/src/lcd/menu/game/game.h +++ b/Marlin/src/lcd/menu/game/game.h @@ -28,7 +28,7 @@ //#define MUTE_GAMES -#if ENABLED(MUTE_GAMES) || !HAS_BUZZER +#if ENABLED(MUTE_GAMES) || !HAS_SOUND #define _BUZZ(D,F) NOOP #else #define _BUZZ(D,F) BUZZ(D,F) diff --git a/Marlin/src/lcd/menu/menu.cpp b/Marlin/src/lcd/menu/menu.cpp index a1e2beaf72..9dd74988f3 100644 --- a/Marlin/src/lcd/menu/menu.cpp +++ b/Marlin/src/lcd/menu/menu.cpp @@ -31,7 +31,7 @@ #include "../../module/temperature.h" #include "../../gcode/queue.h" -#if HAS_BUZZER +#if HAS_SOUND #include "../../libs/buzzer.h" #endif @@ -191,7 +191,7 @@ void MarlinUI::goto_screen(screenFunc_t screen, const uint16_t encoder/*=0*/, co else { #if ENABLED(MOVE_Z_WHEN_IDLE) ui.manual_move.menu_scale = MOVE_Z_IDLE_MULTIPLICATOR; - screen = lcd_move_z; + screen = []{ lcd_move_axis(Z_AXIS); }; #endif } } @@ -272,7 +272,7 @@ void scroll_screen(const uint8_t limit, const bool is_menu) { encoderTopLine = encoderLine; } -#if HAS_BUZZER +#if HAS_SOUND void MarlinUI::completion_feedback(const bool good/*=true*/) { TERN_(HAS_TOUCH_SLEEP, wakeup_screen()); // Wake up on rotary encoder click... if (good) OKAY_BUZZ(); else ERR_BUZZ(); diff --git a/Marlin/src/lcd/menu/menu.h b/Marlin/src/lcd/menu/menu.h index 6f5a9efb15..befffe5f72 100644 --- a/Marlin/src/lcd/menu/menu.h +++ b/Marlin/src/lcd/menu/menu.h @@ -214,8 +214,6 @@ void menu_move(); //////// Menu Item Helper Functions //////// //////////////////////////////////////////// -void lcd_move_axis(const AxisEnum); -void lcd_move_z(); void _lcd_draw_homing(); #define HAS_LINE_TO_Z ANY(DELTA, PROBE_MANUALLY, MESH_BED_LEVELING, LCD_BED_TRAMMING) diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index 5d86b97b5d..f9f4116bc3 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -483,7 +483,7 @@ void menu_backlash(); // M204 T Travel Acceleration EDIT_ITEM_FAST(float5_25, MSG_A_TRAVEL, &planner.settings.travel_acceleration, 25, max_accel); - #define EDIT_AMAX(Q,L) EDIT_ITEM_FAST_N(long5_25, _AXIS(Q), MSG_AMAX_N, &planner.settings.max_acceleration_mm_per_s2[_AXIS(Q)], L, max_accel_edit_scaled[_AXIS(Q)], []{ planner.reset_acceleration_rates(); }) + #define EDIT_AMAX(Q,L) EDIT_ITEM_FAST_N(long5_25, _AXIS(Q), MSG_AMAX_N, &planner.settings.max_acceleration_mm_per_s2[_AXIS(Q)], L, max_accel_edit_scaled[_AXIS(Q)], []{ planner.refresh_acceleration_rates(); }) NUM_AXIS_CODE( EDIT_AMAX(A, 100), EDIT_AMAX(B, 100), EDIT_AMAX(C, 10), EDIT_AMAX(I, 10), EDIT_AMAX(J, 10), EDIT_AMAX(K, 10), @@ -491,14 +491,14 @@ void menu_backlash(); ); #if ENABLED(DISTINCT_E_FACTORS) - EDIT_ITEM_FAST(long5_25, MSG_AMAX_E, &planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(active_extruder)], 100, max_accel_edit_scaled.e, []{ planner.reset_acceleration_rates(); }); + EDIT_ITEM_FAST(long5_25, MSG_AMAX_E, &planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(active_extruder)], 100, max_accel_edit_scaled.e, []{ planner.refresh_acceleration_rates(); }); LOOP_L_N(n, E_STEPPERS) EDIT_ITEM_FAST_N(long5_25, n, MSG_AMAX_EN, &planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(n)], 100, max_accel_edit_scaled.e, []{ if (MenuItemBase::itemIndex == active_extruder) - planner.reset_acceleration_rates(); + planner.refresh_acceleration_rates(); }); #elif E_STEPPERS - EDIT_ITEM_FAST(long5_25, MSG_AMAX_E, &planner.settings.max_acceleration_mm_per_s2[E_AXIS], 100, max_accel_edit_scaled.e, []{ planner.reset_acceleration_rates(); }); + EDIT_ITEM_FAST(long5_25, MSG_AMAX_E, &planner.settings.max_acceleration_mm_per_s2[E_AXIS], 100, max_accel_edit_scaled.e, []{ planner.refresh_acceleration_rates(); }); #endif #ifdef XY_FREQUENCY_LIMIT diff --git a/Marlin/src/lcd/menu/menu_bed_corners.cpp b/Marlin/src/lcd/menu/menu_bed_corners.cpp index 3fe0c582cb..c4a63dafc6 100644 --- a/Marlin/src/lcd/menu/menu_bed_corners.cpp +++ b/Marlin/src/lcd/menu/menu_bed_corners.cpp @@ -178,7 +178,7 @@ static void _lcd_level_bed_corners_get_next_position() { lcd_put_u8str(GET_TEXT_F(MSG_BED_TRAMMING_GOOD_POINTS)); IF_ENABLED(TFT_COLOR_UI, lcd_moveto(12, cy)); lcd_put_u8str(GOOD_POINTS_TO_STR(good_points)); - lcd_put_wchar('/'); + lcd_put_lchar('/'); lcd_put_u8str(GOOD_POINTS_TO_STR(nr_edge_points)); } diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index 8b6af33fd1..1f2257a77f 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -79,7 +79,7 @@ void menu_advanced_settings(); LIMIT(bar_percent, 0, 100); ui.encoderPosition = 0; MenuItem_static::draw(0, GET_TEXT_F(MSG_PROGRESS_BAR_TEST), SS_DEFAULT|SS_INVERT); - lcd_put_int((LCD_WIDTH) / 2 - 2, LCD_HEIGHT - 2, bar_percent); lcd_put_wchar('%'); + lcd_put_int((LCD_WIDTH) / 2 - 2, LCD_HEIGHT - 2, bar_percent); lcd_put_lchar('%'); lcd_moveto(0, LCD_HEIGHT - 1); ui.draw_progress_bar(bar_percent); } diff --git a/Marlin/src/lcd/menu/menu_delta_calibrate.cpp b/Marlin/src/lcd/menu/menu_delta_calibrate.cpp index b86f101258..ae935e53c4 100644 --- a/Marlin/src/lcd/menu/menu_delta_calibrate.cpp +++ b/Marlin/src/lcd/menu/menu_delta_calibrate.cpp @@ -52,7 +52,7 @@ void _man_probe_pt(const xy_pos_t &xy) { ui.wait_for_move = false; ui.synchronize(); ui.manual_move.menu_scale = _MAX(PROBE_MANUALLY_STEP, MIN_STEPS_PER_SEGMENT / planner.settings.axis_steps_per_mm[0]); // Use first axis as for delta XYZ should always match - ui.goto_screen(lcd_move_z); + ui.goto_screen([]{ lcd_move_axis(Z_AXIS); }); } } diff --git a/Marlin/src/lcd/menu/menu_filament.cpp b/Marlin/src/lcd/menu/menu_filament.cpp index 5902a2f63f..122f0c4050 100644 --- a/Marlin/src/lcd/menu/menu_filament.cpp +++ b/Marlin/src/lcd/menu/menu_filament.cpp @@ -65,9 +65,11 @@ static void _change_filament_with_temp(const uint16_t celsius) { queue.inject(cmd); } -static void _change_filament_with_preset() { - _change_filament_with_temp(ui.material_preset[MenuItemBase::itemIndex].hotend_temp); -} +#if HAS_PREHEAT + static void _change_filament_with_preset() { + _change_filament_with_temp(ui.material_preset[MenuItemBase::itemIndex].hotend_temp); + } +#endif static void _change_filament_with_custom() { _change_filament_with_temp(thermalManager.degTargetHotend(MenuItemBase::itemIndex)); diff --git a/Marlin/src/lcd/menu/menu_item.h b/Marlin/src/lcd/menu/menu_item.h index 77e6bcab7b..b0eab65c64 100644 --- a/Marlin/src/lcd/menu/menu_item.h +++ b/Marlin/src/lcd/menu/menu_item.h @@ -27,7 +27,9 @@ #include "../../inc/MarlinConfigPre.h" -void lcd_move_z(); +#if ENABLED(LASER_SYNCHRONOUS_M106_M107) + #include "../../module/planner.h" +#endif //////////////////////////////////////////// ///////////// Base Menu Items ////////////// @@ -538,6 +540,7 @@ class MenuItem_bool : public MenuEditItemBase { inline void on_fan_update() { thermalManager.set_fan_speed(MenuItemBase::itemIndex, editable.uint8); + TERN_(LASER_SYNCHRONOUS_M106_M107, planner.buffer_sync_block(BLOCK_BIT_SYNC_FANS)); } #if ENABLED(EXTRA_FAN_SPEED) diff --git a/Marlin/src/lcd/menu/menu_motion.cpp b/Marlin/src/lcd/menu/menu_motion.cpp index e6d3b8f451..d5c2424429 100644 --- a/Marlin/src/lcd/menu/menu_motion.cpp +++ b/Marlin/src/lcd/menu/menu_motion.cpp @@ -74,6 +74,7 @@ void lcd_move_axis(const AxisEnum axis) { } ui.encoderPosition = 0; if (ui.should_draw()) { + MenuEditItemBase::itemIndex = axis; const float pos = ui.manual_move.axis_value(axis); if (parser.using_inch_units()) { const float imp_pos = LINEAR_UNIT(pos); @@ -84,9 +85,6 @@ void lcd_move_axis(const AxisEnum axis) { } } -// Move Z easy accessor -void lcd_move_z() { lcd_move_axis(Z_AXIS); } - #if E_MANUAL static void lcd_move_e(TERN_(MULTI_E_MANUAL, const int8_t eindex=active_extruder)) { @@ -118,7 +116,7 @@ void lcd_move_z() { lcd_move_axis(Z_AXIS); } void _goto_manual_move_z(const_float_t scale) { ui.manual_move.menu_scale = scale; - ui.goto_screen(lcd_move_z); + ui.goto_screen([]{ lcd_move_axis(Z_AXIS); }); } #endif @@ -281,7 +279,7 @@ void menu_move() { END_MENU(); } -#define _HOME_ITEM(N) GCODES_ITEM_N(N##_AXIS, MSG_AUTO_HOME_A, F("G28X" STR_##N)); +#define _HOME_ITEM(N) GCODES_ITEM_N(N##_AXIS, MSG_AUTO_HOME_A, F("G28" STR_##N)); #if ENABLED(INDIVIDUAL_AXIS_HOMING_SUBMENU) // @@ -348,6 +346,14 @@ void menu_motion() { GCODES_ITEM(MSG_AUTO_Z_ALIGN, F("G34")); #endif + // + // Probe Deploy/Stow + // + #if ENABLED(PROBE_DEPLOY_STOW_MENU) + GCODES_ITEM(MSG_MANUAL_DEPLOY, F("M401")); + GCODES_ITEM(MSG_MANUAL_STOW, F("M402")); + #endif + // // Assisted Bed Tramming // diff --git a/Marlin/src/lcd/menu/menu_password.cpp b/Marlin/src/lcd/menu/menu_password.cpp index 89ea42d704..d29b77311f 100644 --- a/Marlin/src/lcd/menu/menu_password.cpp +++ b/Marlin/src/lcd/menu/menu_password.cpp @@ -61,10 +61,10 @@ void Password::menu_password_entry() { FSTR_P const label = GET_TEXT_F(MSG_ENTER_DIGIT); EDIT_ITEM_F(uint8, label, &editable.uint8, 0, 9, digit_entered); MENU_ITEM_ADDON_START(utf8_strlen(label) + 1); - lcd_put_wchar(' '); - lcd_put_wchar('1' + digit_no); + lcd_put_lchar(' '); + lcd_put_lchar('1' + digit_no); SETCURSOR_X(LCD_WIDTH - 2); - lcd_put_wchar('>'); + lcd_put_lchar('>'); MENU_ITEM_ADDON_END(); ACTION_ITEM(MSG_START_OVER, start_over); diff --git a/Marlin/src/lcd/menu/menu_spindle_laser.cpp b/Marlin/src/lcd/menu/menu_spindle_laser.cpp index 9efd68ca00..a6f99546f6 100644 --- a/Marlin/src/lcd/menu/menu_spindle_laser.cpp +++ b/Marlin/src/lcd/menu/menu_spindle_laser.cpp @@ -33,7 +33,7 @@ #include "../../feature/spindle_laser.h" void menu_spindle_laser() { - bool is_enabled = cutter.enabled() && cutter.isReady; + bool is_enabled = cutter.enabled(); #if ENABLED(SPINDLE_CHANGE_DIR) bool is_rev = cutter.is_reverse(); #endif @@ -48,8 +48,14 @@ cutter.mpower_min(), cutter.mpower_max(), cutter.update_from_mpower); #endif - editable.state = is_enabled; - EDIT_ITEM(bool, MSG_CUTTER(TOGGLE), &is_enabled, []{ if (editable.state) cutter.disable(); else cutter.enable_same_dir(); }); + editable.state = is_enabled; // State before toggle + EDIT_ITEM(bool, MSG_CUTTER(TOGGLE), &is_enabled, []{ + #if ENABLED(SPINDLE_FEATURE) + if (editable.state) cutter.disable(); else cutter.enable_same_dir(); + #else + cutter.menu_set_enabled(!editable.state); + #endif + }); #if ENABLED(AIR_EVACUATION) bool evac_state = cutter.air_evac_state(); @@ -72,12 +78,10 @@ // Setup and fire a test pulse using the current PWM power level for for a duration of test_pulse_min to test_pulse_max ms. EDIT_ITEM_FAST(CUTTER_MENU_PULSE_TYPE, MSG_LASER_PULSE_MS, &cutter.testPulse, LASER_TEST_PULSE_MIN, LASER_TEST_PULSE_MAX); ACTION_ITEM(MSG_LASER_FIRE_PULSE, cutter.test_fire_pulse); + #if ENABLED(HAL_CAN_SET_PWM_FREQ) && SPINDLE_LASER_FREQUENCY + EDIT_ITEM_FAST(CUTTER_MENU_FREQUENCY_TYPE, MSG_CUTTER_FREQUENCY, &cutter.frequency, 2000, 80000, cutter.refresh_frequency); + #endif #endif - - #if BOTH(MARLIN_DEV_MODE, HAL_CAN_SET_PWM_FREQ) && SPINDLE_LASER_FREQUENCY - EDIT_ITEM_FAST(CUTTER_MENU_FREQUENCY_TYPE, MSG_CUTTER_FREQUENCY, &cutter.frequency, 2000, 80000, cutter.refresh_frequency); - #endif - END_MENU(); } diff --git a/Marlin/src/lcd/menu/menu_temperature.cpp b/Marlin/src/lcd/menu/menu_temperature.cpp index e493972a97..2e5b8f1e54 100644 --- a/Marlin/src/lcd/menu/menu_temperature.cpp +++ b/Marlin/src/lcd/menu/menu_temperature.cpp @@ -47,30 +47,30 @@ // "Temperature" submenu items // -void Temperature::lcd_preheat(const uint8_t e, const int8_t indh, const int8_t indb) { - UNUSED(e); UNUSED(indh); UNUSED(indb); - #if HAS_HOTEND - if (indh >= 0 && ui.material_preset[indh].hotend_temp > 0) - setTargetHotend(_MIN(thermalManager.hotend_max_target(e), ui.material_preset[indh].hotend_temp), e); - #endif - #if HAS_HEATED_BED - if (indb >= 0 && ui.material_preset[indb].bed_temp > 0) setTargetBed(ui.material_preset[indb].bed_temp); - #endif - #if HAS_FAN - if (indh >= 0) { - const uint8_t fan_index = active_extruder < (FAN_COUNT) ? active_extruder : 0; - if (true - #if REDUNDANT_PART_COOLING_FAN - && fan_index != REDUNDANT_PART_COOLING_FAN - #endif - ) set_fan_speed(fan_index, ui.material_preset[indh].fan_speed); - } - #endif - ui.return_to_status(); -} - #if HAS_PREHEAT + void Temperature::lcd_preheat(const uint8_t e, const int8_t indh, const int8_t indb) { + UNUSED(e); UNUSED(indh); UNUSED(indb); + #if HAS_HOTEND + if (indh >= 0 && ui.material_preset[indh].hotend_temp > 0) + setTargetHotend(_MIN(thermalManager.hotend_max_target(e), ui.material_preset[indh].hotend_temp), e); + #endif + #if HAS_HEATED_BED + if (indb >= 0 && ui.material_preset[indb].bed_temp > 0) setTargetBed(ui.material_preset[indb].bed_temp); + #endif + #if HAS_FAN + if (indh >= 0) { + const uint8_t fan_index = active_extruder < (FAN_COUNT) ? active_extruder : 0; + if (true + #if REDUNDANT_PART_COOLING_FAN + && fan_index != REDUNDANT_PART_COOLING_FAN + #endif + ) set_fan_speed(fan_index, ui.material_preset[indh].fan_speed); + } + #endif + ui.return_to_status(); + } + #if HAS_TEMP_HOTEND inline void _preheat_end(const uint8_t m, const uint8_t e) { thermalManager.lcd_preheat(e, m, -1); } void do_preheat_end_m() { _preheat_end(editable.int8, 0); } diff --git a/Marlin/src/lcd/menu/menu_tune.cpp b/Marlin/src/lcd/menu/menu_tune.cpp index b13c55f80a..bc52001967 100644 --- a/Marlin/src/lcd/menu/menu_tune.cpp +++ b/Marlin/src/lcd/menu/menu_tune.cpp @@ -76,12 +76,12 @@ #if ENABLED(TFT_COLOR_UI) lcd_moveto(4, 3); lcd_put_u8str(GET_TEXT_F(MSG_BABYSTEP_TOTAL)); - lcd_put_wchar(':'); + lcd_put_lchar(':'); lcd_moveto(10, 3); #else lcd_moveto(0, TERN(HAS_MARLINUI_U8GLIB, LCD_PIXEL_HEIGHT - MENU_FONT_DESCENT, LCD_HEIGHT - 1)); lcd_put_u8str(GET_TEXT_F(MSG_BABYSTEP_TOTAL)); - lcd_put_wchar(':'); + lcd_put_lchar(':'); #endif lcd_put_u8str(BABYSTEP_TO_STR(mps * babystep.axis_total[BS_TOTAL_IND(axis)])); } diff --git a/Marlin/src/lcd/tft/tft_image.h b/Marlin/src/lcd/tft/tft_image.h index de046fb0c4..aeb1ca2bf5 100644 --- a/Marlin/src/lcd/tft/tft_image.h +++ b/Marlin/src/lcd/tft/tft_image.h @@ -114,7 +114,13 @@ enum colorMode_t : uint8_t { typedef colorMode_t ColorMode; -typedef struct __attribute__((__packed__)) { +#ifdef __AVR__ + #define IMG_PACKED __attribute__((__packed__)) +#else + #define IMG_PACKED +#endif + +typedef struct IMG_PACKED { void *data; uint16_t width; uint16_t height; diff --git a/Marlin/src/lcd/tft/tft_string.cpp b/Marlin/src/lcd/tft/tft_string.cpp index d8c419d1a0..d589b0465b 100644 --- a/Marlin/src/lcd/tft/tft_string.cpp +++ b/Marlin/src/lcd/tft/tft_string.cpp @@ -94,12 +94,12 @@ void TFT_String::set() { * @ displays an axis name such as XYZUVW, or E for an extruder */ void TFT_String::add(const char *tpl, const int8_t index, const char *cstr/*=nullptr*/, FSTR_P const fstr/*=nullptr*/) { - wchar_t wchar; + lchar_t wc; while (*tpl) { - tpl = get_utf8_value_cb(tpl, read_byte_ram, &wchar); - if (wchar > 255) wchar |= 0x0080; - const uint8_t ch = uint8_t(wchar & 0x00FF); + tpl = get_utf8_value_cb(tpl, read_byte_ram, wc); + if (wc > 255) wc |= 0x0080; + const uint8_t ch = uint8_t(wc & 0x00FF); if (ch == '=' || ch == '~' || ch == '*') { if (index >= 0) { @@ -124,11 +124,11 @@ void TFT_String::add(const char *tpl, const int8_t index, const char *cstr/*=nul } void TFT_String::add(const char *cstr, uint8_t max_len/*=MAX_STRING_LENGTH*/) { - wchar_t wchar; + lchar_t wc; while (*cstr && max_len) { - cstr = get_utf8_value_cb(cstr, read_byte_ram, &wchar); - if (wchar > 255) wchar |= 0x0080; - const uint8_t ch = uint8_t(wchar & 0x00FF); + cstr = get_utf8_value_cb(cstr, read_byte_ram, wc); + if (wc > 255) wc |= 0x0080; + const uint8_t ch = uint8_t(wc & 0x00FF); add_character(ch); max_len--; } diff --git a/Marlin/src/lcd/tft/tft_string.h b/Marlin/src/lcd/tft/tft_string.h index 5940a48ac9..d43e0b0df2 100644 --- a/Marlin/src/lcd/tft/tft_string.h +++ b/Marlin/src/lcd/tft/tft_string.h @@ -25,6 +25,8 @@ #include +#include "../fontutils.h" + extern const uint8_t ISO10646_1_5x7[]; extern const uint8_t font10x20[]; @@ -97,7 +99,7 @@ class TFT_String { * @param character The ASCII character */ static void add(const char character) { add_character(character); eol(); } - static void set(wchar_t character) { set(); add(character); } + static void set(const lchar_t &character) { set(); add(character); } /** * @brief Append / Set C-string diff --git a/Marlin/src/lcd/tft/ui_1024x600.cpp b/Marlin/src/lcd/tft/ui_1024x600.cpp index ad9f811181..2cce95c8df 100644 --- a/Marlin/src/lcd/tft/ui_1024x600.cpp +++ b/Marlin/src/lcd/tft/ui_1024x600.cpp @@ -791,7 +791,7 @@ static void z_minus() { moveAxis(Z_AXIS, -1); } } #endif -#if HAS_BED_PROBE +#if BOTH(HAS_BED_PROBE, TOUCH_SCREEN) static void z_select() { motionAxisState.z_selection *= -1; quick_feedback(); diff --git a/Marlin/src/lcd/tft/ui_320x240.cpp b/Marlin/src/lcd/tft/ui_320x240.cpp index 56887478f0..19cc4590aa 100644 --- a/Marlin/src/lcd/tft/ui_320x240.cpp +++ b/Marlin/src/lcd/tft/ui_320x240.cpp @@ -771,7 +771,7 @@ static void z_minus() { moveAxis(Z_AXIS, -1); } } #endif -#if HAS_BED_PROBE +#if BOTH(HAS_BED_PROBE, TOUCH_SCREEN) static void z_select() { motionAxisState.z_selection *= -1; quick_feedback(); diff --git a/Marlin/src/lcd/tft/ui_480x320.cpp b/Marlin/src/lcd/tft/ui_480x320.cpp index d4a04d6900..04a121a0e0 100644 --- a/Marlin/src/lcd/tft/ui_480x320.cpp +++ b/Marlin/src/lcd/tft/ui_480x320.cpp @@ -772,7 +772,7 @@ static void z_minus() { moveAxis(Z_AXIS, -1); } } #endif -#if HAS_BED_PROBE +#if BOTH(HAS_BED_PROBE, TOUCH_SCREEN) static void z_select() { motionAxisState.z_selection *= -1; quick_feedback(); diff --git a/Marlin/src/lcd/tft/ui_common.cpp b/Marlin/src/lcd/tft/ui_common.cpp index c9e069dbbd..bb05785766 100644 --- a/Marlin/src/lcd/tft/ui_common.cpp +++ b/Marlin/src/lcd/tft/ui_common.cpp @@ -96,7 +96,7 @@ void lcd_moveto(const lcd_uint_t col, const lcd_uint_t row) { lcd_gotopixel(int(col) * (TFT_COL_WIDTH), int(row) * MENU_LINE_HEIGHT); } -int lcd_put_wchar_max(const wchar_t c, const pixel_len_t max_length) { +int lcd_put_lchar_max(const lchar_t &c, const pixel_len_t max_length) { if (max_length < 1) return 0; tft_string.set(c); tft.add_text(MENU_TEXT_X_OFFSET, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string); diff --git a/Marlin/src/libs/L64XX/L64XX_Marlin.cpp b/Marlin/src/libs/L64XX/L64XX_Marlin.cpp deleted file mode 100644 index 1d69434067..0000000000 --- a/Marlin/src/libs/L64XX/L64XX_Marlin.cpp +++ /dev/null @@ -1,998 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * - * Based on Sprinter and grbl. - * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm - * - * This program 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. - * - * This program 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 this program. If not, see . - * - */ - -/** - * The monitor_driver routines are a close copy of the TMC code - */ - -#include "../../inc/MarlinConfig.h" - -#if HAS_L64XX - -#include "L64XX_Marlin.h" - -L64XX_Marlin L64xxManager; - -#include "../../module/stepper/indirection.h" -#include "../../gcode/gcode.h" -#include "../../module/planner.h" -#include "../../HAL/shared/Delay.h" - -static const char NUM_AXIS_LIST( - str_X[] PROGMEM = "X ", str_Y[] PROGMEM = "Y ", str_Z[] PROGMEM = "Z ", - str_I[] PROGMEM = STR_I " ", str_J[] PROGMEM = STR_J " ", str_K[] PROGMEM = STR_K " " - ), - str_X2[] PROGMEM = "X2", str_Y2[] PROGMEM = "Y2", - str_Z2[] PROGMEM = "Z2", str_Z3[] PROGMEM = "Z3", str_Z4[] PROGMEM = "Z4", - LIST_N(EXTRUDERS, - str_E0[] PROGMEM = "E0", str_E1[] PROGMEM = "E1", - str_E2[] PROGMEM = "E2", str_E3[] PROGMEM = "E3", - str_E4[] PROGMEM = "E4", str_E5[] PROGMEM = "E5", - str_E6[] PROGMEM = "E6", str_E7[] PROGMEM = "E7" - ) - ; - -#define _EN_ITEM(N) , str_E##N -PGM_P const L64XX_Marlin::index_to_axis[] PROGMEM = { - NUM_AXIS_LIST(str_X, str_Y, str_Z, str_I, str_J, str_K), - str_X2, str_Y2, str_Z2, str_Z3, str_Z4 - REPEAT(E_STEPPERS, _EN_ITEM) -}; -#undef _EN_ITEM - -#define DEBUG_OUT ENABLED(L6470_CHITCHAT) -#include "../../core/debug_out.h" - -void echo_yes_no(const bool yes) { DEBUG_ECHOPGM_P(yes ? PSTR(" YES") : PSTR(" NO ")); UNUSED(yes); } - -uint8_t L64XX_Marlin::dir_commands[MAX_L64XX]; // array to hold direction command for each driver - -#define _EN_ITEM(N) , ENABLED(INVERT_E##N##_DIR) -const uint8_t L64XX_Marlin::index_to_dir[MAX_L64XX] = { - NUM_AXIS_LIST(ENABLED(INVERT_X_DIR), ENABLED(INVERT_Y_DIR), ENABLED(INVERT_Z_DIR), ENABLED(INVERT_I_DIR), ENABLED(INVERT_J_DIR), ENABLED(INVERT_K_DIR), ENABLED(INVERT_U_DIR), ENABLED(INVERT_V_DIR), ENABLED(INVERT_W_DIR)) - , ENABLED(INVERT_X_DIR) ^ BOTH(HAS_DUAL_X_STEPPERS, INVERT_X2_VS_X_DIR) // X2 - , ENABLED(INVERT_Y_DIR) ^ BOTH(HAS_DUAL_Y_STEPPERS, INVERT_Y2_VS_Y_DIR) // Y2 - , ENABLED(INVERT_Z_DIR) ^ ENABLED(INVERT_Z2_VS_Z_DIR) // Z2 - , ENABLED(INVERT_Z_DIR) ^ ENABLED(INVERT_Z3_VS_Z_DIR) // Z3 - , ENABLED(INVERT_Z_DIR) ^ ENABLED(INVERT_Z4_VS_Z_DIR) // Z4 - REPEAT(E_STEPPERS, _EN_ITEM) -}; -#undef _EN_ITEM - -volatile uint8_t L64XX_Marlin::spi_abort = false; -uint8_t L64XX_Marlin::spi_active = false; - -L64XX_Marlin::L64XX_shadow_t L64XX_Marlin::shadow; - -//uint32_t UVLO_ADC = 0x0400; // ADC undervoltage event - -void L6470_populate_chain_array() { - - #define _L6470_INIT_SPI(Q) do{ stepper##Q.set_chain_info(Q, Q##_CHAIN_POS); }while(0) - - #if AXIS_IS_L64XX(X) - _L6470_INIT_SPI(X); - #endif - #if AXIS_IS_L64XX(X2) - _L6470_INIT_SPI(X2); - #endif - #if AXIS_IS_L64XX(Y) - _L6470_INIT_SPI(Y); - #endif - #if AXIS_IS_L64XX(Y2) - _L6470_INIT_SPI(Y2); - #endif - #if AXIS_IS_L64XX(Z) - _L6470_INIT_SPI(Z); - #endif - #if AXIS_IS_L64XX(Z2) - _L6470_INIT_SPI(Z2); - #endif - #if AXIS_IS_L64XX(Z3) - _L6470_INIT_SPI(Z3); - #endif - #if AXIS_IS_L64XX(Z4) - _L6470_INIT_SPI(Z4); - #endif - #if AXIS_IS_L64XX(E0) - _L6470_INIT_SPI(E0); - #endif - #if AXIS_IS_L64XX(E1) - _L6470_INIT_SPI(E1); - #endif - #if AXIS_IS_L64XX(E2) - _L6470_INIT_SPI(E2); - #endif - #if AXIS_IS_L64XX(E3) - _L6470_INIT_SPI(E3); - #endif - #if AXIS_IS_L64XX(E4) - _L6470_INIT_SPI(E4); - #endif - #if AXIS_IS_L64XX(E5) - _L6470_INIT_SPI(E5); - #endif - #if AXIS_IS_L64XX(E6) - _L6470_INIT_SPI(E6); - #endif - #if AXIS_IS_L64XX(E7) - _L6470_INIT_SPI(E7); - #endif -} - - -/** - * Some status bit positions & definitions differ per driver. - * Copy info to known locations to simplfy check/display logic. - * 1. Copy stepper status - * 2. Copy status bit definitions - * 3. Copy status layout - * 4. Make all error bits active low (as needed) - */ -uint16_t L64XX_Marlin::get_stepper_status(L64XX &st) { - shadow.STATUS_AXIS_RAW = st.getStatus(); - shadow.STATUS_AXIS = shadow.STATUS_AXIS_RAW; - shadow.STATUS_AXIS_LAYOUT = st.L6470_status_layout; - shadow.AXIS_OCD_TH_MAX = st.OCD_TH_MAX; - shadow.AXIS_STALL_TH_MAX = st.STALL_TH_MAX; - shadow.AXIS_OCD_CURRENT_CONSTANT_INV = st.OCD_CURRENT_CONSTANT_INV; - shadow.AXIS_STALL_CURRENT_CONSTANT_INV = st.STALL_CURRENT_CONSTANT_INV; - shadow.L6470_AXIS_CONFIG = st.L64XX_CONFIG; - shadow.L6470_AXIS_STATUS = st.L64XX_STATUS; - shadow.STATUS_AXIS_OCD = st.STATUS_OCD; - shadow.STATUS_AXIS_SCK_MOD = st.STATUS_SCK_MOD; - shadow.STATUS_AXIS_STEP_LOSS_A = st.STATUS_STEP_LOSS_A; - shadow.STATUS_AXIS_STEP_LOSS_B = st.STATUS_STEP_LOSS_B; - shadow.STATUS_AXIS_TH_SD = st.STATUS_TH_SD; - shadow.STATUS_AXIS_TH_WRN = st.STATUS_TH_WRN; - shadow.STATUS_AXIS_UVLO = st.STATUS_UVLO; - shadow.STATUS_AXIS_WRONG_CMD = st.STATUS_WRONG_CMD; - shadow.STATUS_AXIS_CMD_ERR = st.STATUS_CMD_ERR; - shadow.STATUS_AXIS_NOTPERF_CMD = st.STATUS_NOTPERF_CMD; - - switch (shadow.STATUS_AXIS_LAYOUT) { - case L6470_STATUS_LAYOUT: { // L6470 - shadow.L6470_ERROR_MASK = shadow.STATUS_AXIS_UVLO | shadow.STATUS_AXIS_TH_WRN | shadow.STATUS_AXIS_TH_SD | shadow.STATUS_AXIS_OCD | shadow.STATUS_AXIS_STEP_LOSS_A | shadow.STATUS_AXIS_STEP_LOSS_B; - shadow.STATUS_AXIS ^= (shadow.STATUS_AXIS_WRONG_CMD | shadow.STATUS_AXIS_NOTPERF_CMD); // invert just error bits that are active high - break; - } - case L6474_STATUS_LAYOUT: { // L6474 - shadow.L6470_ERROR_MASK = shadow.STATUS_AXIS_UVLO | shadow.STATUS_AXIS_TH_WRN | shadow.STATUS_AXIS_TH_SD | shadow.STATUS_AXIS_OCD ; - shadow.STATUS_AXIS ^= (shadow.STATUS_AXIS_WRONG_CMD | shadow.STATUS_AXIS_NOTPERF_CMD); // invert just error bits that are active high - break; - } - case L6480_STATUS_LAYOUT: { // L6480 & powerSTEP01 - shadow.L6470_ERROR_MASK = shadow.STATUS_AXIS_UVLO | shadow.STATUS_AXIS_TH_WRN | shadow.STATUS_AXIS_TH_SD | shadow.STATUS_AXIS_OCD | shadow.STATUS_AXIS_STEP_LOSS_A | shadow.STATUS_AXIS_STEP_LOSS_B; - shadow.STATUS_AXIS ^= (shadow.STATUS_AXIS_CMD_ERR | shadow.STATUS_AXIS_TH_WRN | shadow.STATUS_AXIS_TH_SD); // invert just error bits that are active high - break; - } - } - return shadow.STATUS_AXIS; -} - - -void L64XX_Marlin::init() { // Set up SPI and then init chips - ENABLE_RESET_L64XX_CHIPS(LOW); // hardware reset of drivers - DELAY_US(100); - ENABLE_RESET_L64XX_CHIPS(HIGH); - DELAY_US(1000); // need about 650µs for the chip(s) to fully start up - L6470_populate_chain_array(); // Set up array to control where in the SPI transfer sequence a particular stepper's data goes - - spi_init(); // Since L64XX SPI pins are unset we must init SPI here - - init_to_defaults(); // init the chips -} - -uint16_t L64XX_Marlin::get_status(const L64XX_axis_t axis) { - - #define STATUS_L6470(Q) get_stepper_status(stepper##Q) - - switch (axis) { - default: break; - #if AXIS_IS_L64XX(X) - case X : return STATUS_L6470(X); - #endif - #if AXIS_IS_L64XX(Y) - case Y : return STATUS_L6470(Y); - #endif - #if AXIS_IS_L64XX(Z) - case Z : return STATUS_L6470(Z); - #endif - #if AXIS_IS_L64XX(X2) - case X2: return STATUS_L6470(X2); - #endif - #if AXIS_IS_L64XX(Y2) - case Y2: return STATUS_L6470(Y2); - #endif - #if AXIS_IS_L64XX(Z2) - case Z2: return STATUS_L6470(Z2); - #endif - #if AXIS_IS_L64XX(Z3) - case Z3: return STATUS_L6470(Z3); - #endif - #if AXIS_IS_L64XX(Z4) - case Z4: return STATUS_L6470(Z4); - #endif - #if AXIS_IS_L64XX(E0) - case E0: return STATUS_L6470(E0); - #endif - #if AXIS_IS_L64XX(E1) - case E1: return STATUS_L6470(E1); - #endif - #if AXIS_IS_L64XX(E2) - case E2: return STATUS_L6470(E2); - #endif - #if AXIS_IS_L64XX(E3) - case E3: return STATUS_L6470(E3); - #endif - #if AXIS_IS_L64XX(E4) - case E4: return STATUS_L6470(E4); - #endif - #if AXIS_IS_L64XX(E5) - case E5: return STATUS_L6470(E5); - #endif - #if AXIS_IS_L64XX(E6) - case E6: return STATUS_L6470(E6); - #endif - #if AXIS_IS_L64XX(E7) - case E7: return STATUS_L6470(E7); - #endif - } - - return 0; // Not needed but kills a compiler warning -} - -uint32_t L64XX_Marlin::get_param(const L64XX_axis_t axis, const uint8_t param) { - - #define GET_L6470_PARAM(Q) L6470_GETPARAM(param, Q) - - switch (axis) { - default: break; - #if AXIS_IS_L64XX(X) - case X : return GET_L6470_PARAM(X); - #endif - #if AXIS_IS_L64XX(Y) - case Y : return GET_L6470_PARAM(Y); - #endif - #if AXIS_IS_L64XX(Z) - case Z : return GET_L6470_PARAM(Z); - #endif - #if AXIS_IS_L64XX(X2) - case X2: return GET_L6470_PARAM(X2); - #endif - #if AXIS_IS_L64XX(Y2) - case Y2: return GET_L6470_PARAM(Y2); - #endif - #if AXIS_IS_L64XX(Z2) - case Z2: return GET_L6470_PARAM(Z2); - #endif - #if AXIS_IS_L64XX(Z3) - case Z3: return GET_L6470_PARAM(Z3); - #endif - #if AXIS_IS_L64XX(Z4) - case Z4: return GET_L6470_PARAM(Z4); - #endif - #if AXIS_IS_L64XX(E0) - case E0: return GET_L6470_PARAM(E0); - #endif - #if AXIS_IS_L64XX(E1) - case E1: return GET_L6470_PARAM(E1); - #endif - #if AXIS_IS_L64XX(E2) - case E2: return GET_L6470_PARAM(E2); - #endif - #if AXIS_IS_L64XX(E3) - case E3: return GET_L6470_PARAM(E3); - #endif - #if AXIS_IS_L64XX(E4) - case E4: return GET_L6470_PARAM(E4); - #endif - #if AXIS_IS_L64XX(E5) - case E5: return GET_L6470_PARAM(E5); - #endif - #if AXIS_IS_L64XX(E6) - case E6: return GET_L6470_PARAM(E6); - #endif - #if AXIS_IS_L64XX(E7) - case E7: return GET_L6470_PARAM(E7); - #endif - } - - return 0; // not needed but kills a compiler warning -} - -void L64XX_Marlin::set_param(const L64XX_axis_t axis, const uint8_t param, const uint32_t value) { - - #define SET_L6470_PARAM(Q) stepper##Q.SetParam(param, value) - - switch (axis) { - default: break; - #if AXIS_IS_L64XX(X) - case X : SET_L6470_PARAM(X); break; - #endif - #if AXIS_IS_L64XX(Y) - case Y : SET_L6470_PARAM(Y); break; - #endif - #if AXIS_IS_L64XX(Z) - case Z : SET_L6470_PARAM(Z); break; - #endif - #if AXIS_IS_L64XX(I) - case I : SET_L6470_PARAM(I); break; - #endif - #if AXIS_IS_L64XX(J) - case J : SET_L6470_PARAM(J); break; - #endif - #if AXIS_IS_L64XX(K) - case K : SET_L6470_PARAM(K); break; - #endif - #if AXIS_IS_L64XX(X2) - case X2: SET_L6470_PARAM(X2); break; - #endif - #if AXIS_IS_L64XX(Y2) - case Y2: SET_L6470_PARAM(Y2); break; - #endif - #if AXIS_IS_L64XX(Z2) - case Z2: SET_L6470_PARAM(Z2); break; - #endif - #if AXIS_IS_L64XX(Z3) - case Z3: SET_L6470_PARAM(Z3); break; - #endif - #if AXIS_IS_L64XX(Z4) - case Z4: SET_L6470_PARAM(Z4); break; - #endif - #if AXIS_IS_L64XX(E0) - case E0: SET_L6470_PARAM(E0); break; - #endif - #if AXIS_IS_L64XX(E1) - case E1: SET_L6470_PARAM(E1); break; - #endif - #if AXIS_IS_L64XX(E2) - case E2: SET_L6470_PARAM(E2); break; - #endif - #if AXIS_IS_L64XX(E3) - case E3: SET_L6470_PARAM(E3); break; - #endif - #if AXIS_IS_L64XX(E4) - case E4: SET_L6470_PARAM(E4); break; - #endif - #if AXIS_IS_L64XX(E5) - case E5: SET_L6470_PARAM(E5); break; - #endif - #if AXIS_IS_L64XX(E6) - case E6: SET_L6470_PARAM(E6); break; - #endif - #if AXIS_IS_L64XX(E7) - case E7: SET_L6470_PARAM(E7); break; - #endif - } -} - -inline void echo_min_max(const char a, const_float_t min, const_float_t max) { - DEBUG_CHAR(' '); DEBUG_CHAR(a); - DEBUG_ECHOLNPGM(" min = ", min, " max = ", max); -} -inline void echo_oct_used(const_float_t oct, const uint8_t stall) { - DEBUG_ECHOPGM("over_current_threshold used : ", oct); - DEBUG_ECHOPGM_P(stall ? PSTR(" (Stall") : PSTR(" (OCD")); - DEBUG_ECHOLNPGM(" threshold)"); -} -inline void err_out_of_bounds() { DEBUG_ECHOLNPGM("Test aborted - motion out of bounds"); } - -uint8_t L64XX_Marlin::get_user_input(uint8_t &driver_count, L64XX_axis_t axis_index[3], char axis_mon[3][3], - float &position_max, float &position_min, float &final_feedrate, uint8_t &kval_hold, - uint8_t over_current_flag, uint8_t &OCD_TH_val, uint8_t &STALL_TH_val, uint16_t &over_current_threshold -) { - // Return TRUE if the calling routine needs to abort/kill - - uint16_t displacement = 0; // " = 0" to eliminate compiler warning - uint8_t j; // general purpose counter - - if (!all_axes_homed()) { - DEBUG_ECHOLNPGM("Test aborted - home all before running this command"); - return true; - } - - uint8_t found_displacement = false; - LOOP_LOGICAL_AXES(i) if (uint16_t _displacement = parser.intval(AXIS_CHAR(i))) { - found_displacement = true; - displacement = _displacement; - const uint8_t axis_offset = parser.byteval('J'); - axis_mon[0][0] = AXIS_CHAR(i); // Axis first character, one of XYZ...E - const bool single_or_e = axis_offset >= 2 || axis_mon[0][0] == 'E', - one_or_more = !single_or_e && axis_offset == 0; - uint8_t driver_count_local = 0; // Can't use "driver_count" directly as a subscript because it's passed by reference - if (single_or_e) // Single axis, E0, or E1 - axis_mon[0][1] = axis_offset + '0'; // Index given by 'J' parameter - - if (single_or_e || one_or_more) { - for (j = 0; j < MAX_L64XX; j++) { // Count up the drivers on this axis - PGM_P str = (PGM_P)pgm_read_ptr(&index_to_axis[j]); // Get a PGM_P from progmem - const char c = pgm_read_byte(str); // Get a char from progmem - if (axis_mon[0][0] == c) { // For each stepper on this axis... - char *mon = axis_mon[driver_count_local]; - *mon++ = c; // Copy the 3 letter axis name - *mon++ = pgm_read_byte(&str[1]); // to the axis_mon array - *mon = pgm_read_byte(&str[2]); - axis_index[driver_count_local] = (L64XX_axis_t)j; // And store the L64XX axis index - driver_count_local++; - } - } - if (one_or_more) driver_count = driver_count_local; - } - break; // only take first axis found - } - - if (!found_displacement) { - DEBUG_ECHOLNPGM("Test aborted - AXIS with displacement is required"); - return true; - } - - // - // Position calcs & checks - // - - const float LOGICAL_AXIS_LIST( - E_center = current_position.e, - X_center = LOGICAL_X_POSITION(current_position.x), - Y_center = LOGICAL_Y_POSITION(current_position.y), - Z_center = LOGICAL_Z_POSITION(current_position.z), - I_center = LOGICAL_I_POSITION(current_position.i), - J_center = LOGICAL_J_POSITION(current_position.j), - K_center = LOGICAL_K_POSITION(current_position.k) - ); - - switch (axis_mon[0][0]) { - default: position_max = position_min = 0; break; - - case 'X': { - position_min = X_center - displacement; - position_max = X_center + displacement; - echo_min_max('X', position_min, position_max); - if (TERN0(HAS_ENDSTOPS, position_min < (X_MIN_POS) || position_max > (X_MAX_POS))) { - err_out_of_bounds(); - return true; - } - } break; - - #if HAS_Y_AXIS - case 'Y': { - position_min = Y_center - displacement; - position_max = Y_center + displacement; - echo_min_max('Y', position_min, position_max); - if (TERN0(HAS_ENDSTOPS, position_min < (Y_MIN_POS) || position_max > (Y_MAX_POS))) { - err_out_of_bounds(); - return true; - } - } break; - #endif - - #if HAS_Z_AXIS - case 'Z': { - position_min = Z_center - displacement; - position_max = Z_center + displacement; - echo_min_max('Z', position_min, position_max); - if (TERN0(HAS_ENDSTOPS, position_min < (Z_MIN_POS) || position_max > (Z_MAX_POS))) { - err_out_of_bounds(); - return true; - } - } break; - #endif - - #if HAS_I_AXIS - case AXIS4_NAME: { - position_min = I_center - displacement; - position_max = I_center + displacement; - echo_min_max(AXIS4_NAME, position_min, position_max); - if (TERN0(HAS_ENDSTOPS, position_min < (I_MIN_POS) || position_max > (I_MAX_POS))) { - err_out_of_bounds(); - return true; - } - } break; - #endif - - #if HAS_J_AXIS - case AXIS5_NAME: { - position_min = J_center - displacement; - position_max = J_center + displacement; - echo_min_max(AXIS5_NAME, position_min, position_max); - if (TERN1(HAS_ENDSTOPS, position_min < (J_MIN_POS) || position_max > (J_MAX_POS))) { - err_out_of_bounds(); - return true; - } - } break; - #endif - - #if HAS_K_AXIS - case AXIS6_NAME: { - position_min = K_center - displacement; - position_max = K_center + displacement; - echo_min_max(AXIS6_NAME, position_min, position_max); - if (TERN2(HAS_ENDSTOPS, position_min < (K_MIN_POS) || position_max > (K_MAX_POS))) { - err_out_of_bounds(); - return true; - } - } break; - #endif - - #if HAS_EXTRUDERS - case 'E': { - position_min = E_center - displacement; - position_max = E_center + displacement; - echo_min_max('E', position_min, position_max); - } break; - #endif - } - - // - // Work on the drivers - // - - LOOP_L_N(k, driver_count) { - uint8_t not_found = true; - for (j = 1; j <= L64XX::chain[0]; j++) { - PGM_P const str = (PGM_P)pgm_read_ptr(&index_to_axis[L64XX::chain[j]]); - if (pgm_read_byte(&str[0]) == axis_mon[k][0] && pgm_read_byte(&str[1]) == axis_mon[k][1]) { // See if a L6470 driver - not_found = false; - break; - } - } - if (not_found) { - driver_count = k; - axis_mon[k][0] = ' '; // mark this entry invalid - break; - } - } - - if (driver_count == 0) { - DEBUG_ECHOLNPGM("Test aborted - not a L6470 axis"); - return true; - } - - DEBUG_ECHOPGM("Monitoring:"); - for (j = 0; j < driver_count; j++) DEBUG_ECHOPGM(" ", axis_mon[j]); - DEBUG_EOL(); - - // now have a list of driver(s) to monitor - - // - // TVAL & kVAL_HOLD checks & settings - // - const L64XX_shadow_t &sh = shadow; - get_status(axis_index[0]); // populate shadow array - - if (sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT) { // L6474 - use TVAL - uint16_t TVAL_current = parser.ushortval('T'); - if (TVAL_current) { - uint8_t TVAL_count = (TVAL_current / sh.AXIS_STALL_CURRENT_CONSTANT_INV) - 1; - LIMIT(TVAL_count, 0, sh.AXIS_STALL_TH_MAX); - for (j = 0; j < driver_count; j++) - set_param(axis_index[j], L6474_TVAL, TVAL_count); - } - // only print the tval from one of the drivers - kval_hold = get_param(axis_index[0], L6474_TVAL); - DEBUG_ECHOLNPGM("TVAL current (mA) = ", (kval_hold + 1) * sh.AXIS_STALL_CURRENT_CONSTANT_INV); - } - else { - kval_hold = parser.byteval('K'); - if (kval_hold) { - DEBUG_ECHOLNPGM("kval_hold = ", kval_hold); - for (j = 0; j < driver_count; j++) - set_param(axis_index[j], L6470_KVAL_HOLD, kval_hold); - } - else { - // only print the KVAL_HOLD from one of the drivers - kval_hold = get_param(axis_index[0], L6470_KVAL_HOLD); - DEBUG_ECHOLNPGM("KVAL_HOLD = ", kval_hold); - } - } - - // - // Overcurrent checks & settings - // - - if (over_current_flag) { - - uint8_t OCD_TH_val_local = 0, // compiler thinks OCD_TH_val is unused if use it directly - STALL_TH_val_local = 0; // just in case ... - - over_current_threshold = parser.intval('I'); - - if (over_current_threshold) { - - OCD_TH_val_local = over_current_threshold/375; - LIMIT(OCD_TH_val_local, 0, 15); - STALL_TH_val_local = over_current_threshold/31.25; - LIMIT(STALL_TH_val_local, 0, 127); - uint16_t OCD_TH_actual = (OCD_TH_val_local + 1) * 375, - STALL_TH_actual = (STALL_TH_val_local + 1) * 31.25; - if (OCD_TH_actual < STALL_TH_actual) { - OCD_TH_val_local++; - OCD_TH_actual = (OCD_TH_val_local + 1) * 375; - } - - DEBUG_ECHOLNPGM("over_current_threshold specified: ", over_current_threshold); - if (!(sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT)) echo_oct_used((STALL_TH_val_local + 1) * 31.25, true); - echo_oct_used((OCD_TH_val_local + 1) * 375, false); - - #define SET_OVER_CURRENT(Q) do { stepper##Q.SetParam(L6470_STALL_TH, STALL_TH_val_local); stepper##Q.SetParam(L6470_OCD_TH, OCD_TH_val_local);} while (0) - - for (j = 0; j < driver_count; j++) { - set_param(axis_index[j], L6470_STALL_TH, STALL_TH_val_local); - set_param(axis_index[j], L6470_OCD_TH, OCD_TH_val_local); - } - } - else { - // only get & print the OVER_CURRENT values from one of the drivers - STALL_TH_val_local = get_param(axis_index[0], L6470_STALL_TH); - OCD_TH_val_local = get_param(axis_index[0], L6470_OCD_TH); - - if (!(sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT)) echo_oct_used((STALL_TH_val_local + 1) * 31.25, true); - echo_oct_used((OCD_TH_val_local + 1) * 375, false); - } // over_current_threshold - - for (j = 0; j < driver_count; j++) { // set all drivers on axis the same - set_param(axis_index[j], L6470_STALL_TH, STALL_TH_val_local); - set_param(axis_index[j], L6470_OCD_TH, OCD_TH_val_local); - } - - OCD_TH_val = OCD_TH_val_local; // force compiler to update the main routine's copy - STALL_TH_val = STALL_TH_val_local; // force compiler to update the main routine's copy - } // end of overcurrent - - // - // Feedrate - // - - final_feedrate = parser.floatval('F'); - if (final_feedrate == 0) { - static constexpr float default_max_feedrate[] = DEFAULT_MAX_FEEDRATE; - const uint8_t num_feedrates = COUNT(default_max_feedrate); - for (j = 0; j < num_feedrates; j++) { - if (AXIS_CHAR(j) == axis_mon[0][0]) { - final_feedrate = default_max_feedrate[j]; - break; - } - } - if (j == 3 && num_feedrates > 4) { // have more than one extruder feedrate - uint8_t extruder_num = axis_mon[0][1] - '0'; - if (j <= num_feedrates - extruder_num) // have a feedrate specifically for this extruder - final_feedrate = default_max_feedrate[j + extruder_num]; - else - final_feedrate = default_max_feedrate[3]; // use E0 feedrate for this extruder - } - final_feedrate *= 60; // convert to mm/minute - } // end of feedrate - - return false; // FALSE indicates no user input problems -} - -void L64XX_Marlin::say_axis(const L64XX_axis_t axis, const uint8_t label/*=true*/) { - if (label) SERIAL_ECHOPGM("AXIS:"); - const char * const str = L64xxManager.index_to_axis[axis]; - SERIAL_CHAR(' ', str[0], str[1], ' '); -} - -#if ENABLED(L6470_CHITCHAT) - - // Assumes status bits have been inverted - void L64XX_Marlin::error_status_decode(const uint16_t status, const L64XX_axis_t axis, - const uint16_t _status_axis_th_sd, const uint16_t _status_axis_th_wrn, - const uint16_t _status_axis_step_loss_a, const uint16_t _status_axis_step_loss_b, - const uint16_t _status_axis_ocd, const uint8_t _status_axis_layout - ) { - say_axis(axis); - DEBUG_ECHOPGM(" THERMAL: "); - DEBUG_ECHOPGM_P((status & _status_axis_th_sd) ? PSTR("SHUTDOWN") : (status & _status_axis_th_wrn) ? PSTR("WARNING ") : PSTR("OK ")); - DEBUG_ECHOPGM(" OVERCURRENT: "); - echo_yes_no((status & _status_axis_ocd) != 0); - if (!(_status_axis_layout == L6474_STATUS_LAYOUT)) { // L6474 doesn't have these bits - DEBUG_ECHOPGM(" STALL: "); - echo_yes_no((status & (_status_axis_step_loss_a | _status_axis_step_loss_b)) != 0); - } - DEBUG_EOL(); - } - -#endif - -////////////////////////////////////////////////////////////////////////////////////////////////// -//// -//// MONITOR_L6470_DRIVER_STATUS routines -//// -////////////////////////////////////////////////////////////////////////////////////////////////// - -#if ENABLED(MONITOR_L6470_DRIVER_STATUS) - - bool L64XX_Marlin::monitor_paused = false; // Flag to skip monitor during M122, M906, M916, M917, M918, etc. - - struct L6470_driver_data { - L64XX_axis_t driver_index; - uint32_t driver_status; - uint8_t is_otw; - uint8_t otw_counter; - uint8_t is_ot; - uint8_t is_hi_Z; - uint8_t com_counter; - }; - - L6470_driver_data driver_L6470_data[] = { - #if AXIS_IS_L64XX(X) - { X, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(Y) - { Y, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(Z) - { Z, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(I) - { I, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(J) - { J, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(K) - { K, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(X2) - { X2, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(Y2) - { Y2, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(Z2) - { Z2, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(Z3) - { Z3, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(Z4) - { Z4, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(E0) - { E0, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(E1) - { E1, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(E2) - { E2, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(E3) - { E3, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(E4) - { E4, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(E5) - { E5, 0, 0, 0, 0, 0, 0 } - #endif - #if AXIS_IS_L64XX(E6) - { E6, 0, 0, 0, 0, 0, 0 } - #endif - #if AXIS_IS_L64XX(E7) - { E7, 0, 0, 0, 0, 0, 0 } - #endif - }; - - void L64XX_Marlin::append_stepper_err(char* &p, const uint8_t stepper_index, const char * const err/*=nullptr*/) { - PGM_P const str = (PGM_P)pgm_read_ptr(&index_to_axis[stepper_index]); - p += sprintf_P(p, PSTR("Stepper %c%c "), pgm_read_byte(&str[0]), pgm_read_byte(&str[1])); - if (err) p += sprintf_P(p, err); - } - - void L64XX_Marlin::monitor_update(L64XX_axis_t stepper_index) { - if (spi_abort) return; // don't do anything if set_directions() has occurred - const L64XX_shadow_t &sh = shadow; - get_status(stepper_index); // get stepper status and details - uint16_t status = sh.STATUS_AXIS; - uint8_t kval_hold, tval; - char temp_buf[120], *p = temp_buf; - uint8_t j; - for (j = 0; j < L64XX::chain[0]; j++) // find the table for this stepper - if (driver_L6470_data[j].driver_index == stepper_index) break; - - driver_L6470_data[j].driver_status = status; - uint16_t _status = ~status; // all error bits are active low - - if (status == 0 || status == 0xFFFF) { // com problem - if (driver_L6470_data[j].com_counter == 0) { // warn user when it first happens - driver_L6470_data[j].com_counter++; - append_stepper_err(p, stepper_index, PSTR(" - communications lost\n")); - DEBUG_ECHO(temp_buf); - } - else { - driver_L6470_data[j].com_counter++; - if (driver_L6470_data[j].com_counter > 240) { // remind of com problem about every 2 minutes - driver_L6470_data[j].com_counter = 1; - append_stepper_err(p, stepper_index, PSTR(" - still no communications\n")); - DEBUG_ECHO(temp_buf); - } - } - } - else { - if (driver_L6470_data[j].com_counter) { // comms re-established - driver_L6470_data[j].com_counter = 0; - append_stepper_err(p, stepper_index, PSTR(" - communications re-established\n.. setting all drivers to default values\n")); - DEBUG_ECHO(temp_buf); - init_to_defaults(); - } - else { - // no com problems - do the usual checks - if (_status & sh.L6470_ERROR_MASK) { - append_stepper_err(p, stepper_index); - - if (status & STATUS_HIZ) { // The driver has shut down. HiZ is active high - driver_L6470_data[j].is_hi_Z = true; - p += sprintf_P(p, PSTR("%cIS SHUT DOWN"), ' '); - //if (_status & sh.STATUS_AXIS_TH_SD) { // strange - TH_SD never seems to go active, must be implied by the HiZ and TH_WRN - if (_status & sh.STATUS_AXIS_TH_WRN) { // over current shutdown - p += sprintf_P(p, PSTR("%cdue to over temperature"), ' '); - driver_L6470_data[j].is_ot = true; - if (sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT) { // L6474 - tval = get_param(stepper_index, L6474_TVAL) - 2 * KVAL_HOLD_STEP_DOWN; - set_param(stepper_index, L6474_TVAL, tval); // reduce TVAL - p += sprintf_P(p, PSTR(" - TVAL reduced by %d to %d mA"), uint16_t (2 * KVAL_HOLD_STEP_DOWN * sh.AXIS_STALL_CURRENT_CONSTANT_INV), uint16_t ((tval + 1) * sh.AXIS_STALL_CURRENT_CONSTANT_INV)); // let user know - } - else { - kval_hold = get_param(stepper_index, L6470_KVAL_HOLD) - 2 * KVAL_HOLD_STEP_DOWN; - set_param(stepper_index, L6470_KVAL_HOLD, kval_hold); // reduce KVAL_HOLD - p += sprintf_P(p, PSTR(" - KVAL_HOLD reduced by %d to %d"), 2 * KVAL_HOLD_STEP_DOWN, kval_hold); // let user know - } - } - else - driver_L6470_data[j].is_ot = false; - } - else { - driver_L6470_data[j].is_hi_Z = false; - - if (_status & sh.STATUS_AXIS_TH_WRN) { // have an over temperature warning - driver_L6470_data[j].is_otw = true; - driver_L6470_data[j].otw_counter++; - kval_hold = get_param(stepper_index, L6470_KVAL_HOLD); - if (driver_L6470_data[j].otw_counter > 4) { // otw present for 2 - 2.5 seconds, reduce KVAL_HOLD - driver_L6470_data[j].otw_counter = 0; - driver_L6470_data[j].is_otw = true; - if (sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT) { // L6474 - tval = get_param(stepper_index, L6474_TVAL) - KVAL_HOLD_STEP_DOWN; - set_param(stepper_index, L6474_TVAL, tval); // reduce TVAL - p += sprintf_P(p, PSTR(" - TVAL reduced by %d to %d mA"), uint16_t (KVAL_HOLD_STEP_DOWN * sh.AXIS_STALL_CURRENT_CONSTANT_INV), uint16_t ((tval + 1) * sh.AXIS_STALL_CURRENT_CONSTANT_INV)); // let user know - } - else { - kval_hold = get_param(stepper_index, L6470_KVAL_HOLD) - KVAL_HOLD_STEP_DOWN; - set_param(stepper_index, L6470_KVAL_HOLD, kval_hold); // reduce KVAL_HOLD - p += sprintf_P(p, PSTR(" - KVAL_HOLD reduced by %d to %d"), KVAL_HOLD_STEP_DOWN, kval_hold); // let user know - } - } - else if (driver_L6470_data[j].otw_counter) - p += sprintf_P(p, PSTR("%c- thermal warning"), ' '); // warn user - } - } - - #if ENABLED(L6470_STOP_ON_ERROR) - if (_status & (sh.STATUS_AXIS_UVLO | sh.STATUS_AXIS_TH_WRN | sh.STATUS_AXIS_TH_SD)) - kill(temp_buf); - #endif - - #if ENABLED(L6470_CHITCHAT) - if (_status & sh.STATUS_AXIS_OCD) - p += sprintf_P(p, PSTR("%c over current"), ' '); - - if (_status & (sh.STATUS_AXIS_STEP_LOSS_A | sh.STATUS_AXIS_STEP_LOSS_B)) - p += sprintf_P(p, PSTR("%c stall"), ' '); - - if (_status & sh.STATUS_AXIS_UVLO) - p += sprintf_P(p, PSTR("%c under voltage lock out"), ' '); - - p += sprintf_P(p, PSTR("%c\n"), ' '); - #endif - - DEBUG_ECHOLN(temp_buf); // print the error message - } - else { - driver_L6470_data[j].is_ot = false; - driver_L6470_data[j].otw_counter = 0; //clear out warning indicators - driver_L6470_data[j].is_otw = false; - } // end usual checks - - } // comms established but have errors - } // comms re-established - } // end monitor_update() - - - void L64XX_Marlin::monitor_driver() { - static millis_t next_cOT = 0; - if (ELAPSED(millis(), next_cOT)) { - next_cOT = millis() + 500; - - if (!monitor_paused) { // Skip during M122, M906, M916, M917 or M918 (could steal status result from test) - - spi_active = true; // Tell set_directions() a series of SPI transfers is underway - - #if AXIS_IS_L64XX(X) - monitor_update(X); - #endif - #if AXIS_IS_L64XX(Y) - monitor_update(Y); - #endif - #if AXIS_IS_L64XX(Z) - monitor_update(Z); - #endif - #if AXIS_IS_L64XX(I) - monitor_update(I); - #endif - #if AXIS_IS_L64XX(J) - monitor_update(J); - #endif - #if AXIS_IS_L64XX(K) - monitor_update(K); - #endif - #if AXIS_IS_L64XX(X2) - monitor_update(X2); - #endif - #if AXIS_IS_L64XX(Y2) - monitor_update(Y2); - #endif - #if AXIS_IS_L64XX(Z2) - monitor_update(Z2); - #endif - #if AXIS_IS_L64XX(Z3) - monitor_update(Z3); - #endif - #if AXIS_IS_L64XX(Z4) - monitor_update(Z4); - #endif - #if AXIS_IS_L64XX(E0) - monitor_update(E0); - #endif - #if AXIS_IS_L64XX(E1) - monitor_update(E1); - #endif - #if AXIS_IS_L64XX(E2) - monitor_update(E2); - #endif - #if AXIS_IS_L64XX(E3) - monitor_update(E3); - #endif - #if AXIS_IS_L64XX(E4) - monitor_update(E4); - #endif - #if AXIS_IS_L64XX(E5) - monitor_update(E5); - #endif - #if AXIS_IS_L64XX(E6) - monitor_update(E6); - #endif - #if AXIS_IS_L64XX(E7) - monitor_update(E7); - #endif - - if (TERN0(L6470_DEBUG, report_L6470_status)) DEBUG_EOL(); - - spi_active = false; // done with all SPI transfers - clear handshake flags - spi_abort = false; - } - } - } - -#endif // MONITOR_L6470_DRIVER_STATUS - -#endif // HAS_L64XX diff --git a/Marlin/src/libs/L64XX/L64XX_Marlin.h b/Marlin/src/libs/L64XX/L64XX_Marlin.h deleted file mode 100644 index e8d8498ac7..0000000000 --- a/Marlin/src/libs/L64XX/L64XX_Marlin.h +++ /dev/null @@ -1,141 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * - * Based on Sprinter and grbl. - * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm - * - * This program 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. - * - * This program 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 this program. If not, see . - * - */ -#pragma once - -#include "../../inc/MarlinConfig.h" - -#include -#if !(L6470_LIBRARY_VERSION >= 0x000800) - #error 'L6470_LIBRARY_VERSION 0x000800 or later required' -#endif - -#define L6470_GETPARAM(P,Q) stepper##Q.GetParam(P) - -#define dSPIN_STEP_CLOCK 0x58 -#define dSPIN_STEP_CLOCK_FWD dSPIN_STEP_CLOCK -#define dSPIN_STEP_CLOCK_REV dSPIN_STEP_CLOCK+1 -#define HAS_L64XX_EXTRUDER (AXIS_IS_L64XX(E0) || AXIS_IS_L64XX(E1) || AXIS_IS_L64XX(E2) || AXIS_IS_L64XX(E3) || AXIS_IS_L64XX(E4) || AXIS_IS_L64XX(E5) || AXIS_IS_L64XX(E6) || AXIS_IS_L64XX(E7)) - -#define _EN_ITEM(N) , E##N -enum L64XX_axis_t : uint8_t { MAIN_AXIS_NAMES, X2, Y2, Z2, Z3, Z4 REPEAT(E_STEPPERS, _EN_ITEM), MAX_L64XX }; -#undef _EN_ITEM - -class L64XX_Marlin : public L64XXHelper { -public: - static PGM_P const index_to_axis[MAX_L64XX]; - - static const uint8_t index_to_dir[MAX_L64XX]; - - static uint8_t dir_commands[MAX_L64XX]; - - // Flags to guarantee graceful switch if stepper interrupts L6470 SPI transfer - static volatile uint8_t spi_abort; - static uint8_t spi_active; - - L64XX_Marlin() {} - - static void init(); - static void init_to_defaults(); - - static uint16_t get_stepper_status(L64XX &st); - - static uint16_t get_status(const L64XX_axis_t axis); - - static uint32_t get_param(const L64XX_axis_t axis, const uint8_t param); - - static void set_param(const L64XX_axis_t axis, const uint8_t param, const uint32_t value); - - //static void send_command(const L64XX_axis_t axis, uint8_t command); - - static uint8_t get_user_input(uint8_t &driver_count, L64XX_axis_t axis_index[3], char axis_mon[3][3], - float &position_max, float &position_min, float &final_feedrate, uint8_t &kval_hold, - uint8_t over_current_flag, uint8_t &OCD_TH_val, uint8_t &STALL_TH_val, uint16_t &over_current_threshold); - - static void transfer(uint8_t L6470_buf[], const uint8_t length); - - static void say_axis(const L64XX_axis_t axis, const uint8_t label=true); - #if ENABLED(L6470_CHITCHAT) - static void error_status_decode( - const uint16_t status, const L64XX_axis_t axis, - const uint16_t _status_axis_th_sd, const uint16_t _status_axis_th_wrn, - const uint16_t _status_axis_step_loss_a, const uint16_t _status_axis_step_loss_b, - const uint16_t _status_axis_ocd, const uint8_t _status_axis_layout - ); - #else - FORCE_INLINE static void error_status_decode( - const uint16_t, const L64XX_axis_t, - const uint16_t, const uint16_t, - const uint16_t, const uint16_t, - const uint16_t, const uint8_t - ){} - #endif - - // ~40 bytes SRAM to simplify status decode routines - typedef struct { - uint8_t STATUS_AXIS_LAYOUT; // Copy of L6470_status_layout - uint8_t AXIS_OCD_TH_MAX; // Size of OCD_TH field - uint8_t AXIS_STALL_TH_MAX; // Size of STALL_TH field - float AXIS_OCD_CURRENT_CONSTANT_INV; // mA per count - float AXIS_STALL_CURRENT_CONSTANT_INV; // mA per count - uint8_t L6470_AXIS_CONFIG, // Address of the CONFIG register - L6470_AXIS_STATUS; // Address of the STATUS register - uint16_t L6470_ERROR_MASK, // STATUS_UVLO | STATUS_TH_WRN | STATUS_TH_SD | STATUS_OCD | STATUS_STEP_LOSS_A | STATUS_STEP_LOSS_B - L6474_ERROR_MASK, // STATUS_UVLO | STATUS_TH_WRN | STATUS_TH_SD | STATUS_OCD - STATUS_AXIS_RAW, // Copy of status register contents - STATUS_AXIS, // Copy of status register contents but with all error bits active low - STATUS_AXIS_OCD, // Overcurrent detected bit position - STATUS_AXIS_SCK_MOD, // Step clock mode is active bit position - STATUS_AXIS_STEP_LOSS_A, // Stall detected on A bridge bit position - STATUS_AXIS_STEP_LOSS_B, // Stall detected on B bridge bit position - STATUS_AXIS_TH_SD, // Thermal shutdown bit position - STATUS_AXIS_TH_WRN, // Thermal warning bit position - STATUS_AXIS_UVLO, // Undervoltage lockout is active bit position - STATUS_AXIS_WRONG_CMD, // Last command not valid bit position - STATUS_AXIS_CMD_ERR, // Command error bit position - STATUS_AXIS_NOTPERF_CMD; // Last command not performed bit position - } L64XX_shadow_t; - - static L64XX_shadow_t shadow; - - #if ENABLED(MONITOR_L6470_DRIVER_STATUS) - static bool monitor_paused; - static void pause_monitor(const bool p) { monitor_paused = p; } - static void monitor_update(L64XX_axis_t stepper_index); - static void monitor_driver(); - #else - static void pause_monitor(const bool) {} - #endif - -//protected: - // L64XXHelper methods - static void spi_init(); - static uint8_t transfer_single(uint8_t data, int16_t ss_pin); - static uint8_t transfer_chain(uint8_t data, int16_t ss_pin, uint8_t chain_position); - -private: - static void append_stepper_err(char* &p, const uint8_t stepper_index, const char * const err=nullptr); - -}; - -void echo_yes_no(const bool yes); - -extern L64XX_Marlin L64xxManager; diff --git a/Marlin/src/libs/L64XX/README.md b/Marlin/src/libs/L64XX/README.md deleted file mode 100644 index d28bec5e67..0000000000 --- a/Marlin/src/libs/L64XX/README.md +++ /dev/null @@ -1,98 +0,0 @@ -### L64XX Stepper Driver - -*Arduino-L6470* library revision 0.8.0 or above is required. - -This software can be used with the L6470, L6474, L6480 and the powerSTEP01 (collectively referred to as "L64xx" from now on). Different drivers can be mixed within a system. - -These devices use voltage PWMs to drive the stepper phases. On the L6474 the phase current is controlled by the `TVAL` register. On all the other drivers the phase current is indirectly controlled via the `KVAL_HOLD` register which scales the PWM duty cycle. - -This software assumes that all drivers are in one SPI daisy chain. - -### Hardware Setup - -- MOSI from controller tied to SDI on the first device - -- SDO of the first device is tied to SDI of the next device - -- SDO of the last device is tied to MISO of the controller - -- All devices share the same `SCK_PIN` and `SS_PIN` pins. The user must supply a macro to control the `RESET_PIN`(s). - -- Each L6470 passes the data it saw on its SDI to its neighbor on the **NEXT** SPI cycle (8 bit delay). - -- Each L6470 acts on the **last** SPI data it saw when the `SS_PIN` **goes high**. - -The L6474 uses the standard STEP DIR interface. Phase currents are changed in response to step pulses. The direction is set by the DIR pin. Instead of an ENA pin, stepper power is controlled with SPI commands. - -The other drivers operate in `STEP_CLOCK` mode. In this mode the Direction / Enable functions are done with SPI commands and the phase currents are changed in response to STEP pulses. - -### Hardware / Software Interaction - -Except for the L6474, powering up a stepper and setting the direction are done by the same command. You can't do one without the other. - -**All** directions are set **every time** a new block is popped off the queue by the stepper ISR. - -When setting direction, SPI transfers are minimized by using arrays and a specialized SPI method. *Arduino-L6470* library calls are not used. For N L64xx drivers, this results in N bytes transferred. If library calls were used then N2 bytes would be sent. - -### Power-up (Reset) Sequence - -- Stepper objects are instantiated before the `setup()` entry point is reached. - -- In `setup()` (before stepper drivers are initialized) the `L6470_init()` method is called to do the following: - - - If present, pulse the hardware reset pin. - - - Populate the `L6470_chain` array, which maps positions in the SPI stream to commands/data for L64XX stepper drivers. - - - Initialize the L64XX Software SPI pin states. - - - Initialize L64XX drivers. They may be reset later by a call to `L6470_init_to_defaults()`. - -The steppers are **NOT** powered up (enabled) during this sequence. - -### `L6470_chain` array - -This array is used by all routines that transmit SPI data. For a chain with N devices, the array contains: - -Index|Value ------|----- -0|Number of drivers in chain -1|Axis index of the first device in the chain (closest to MOSI) -...| -N|Axis index of the last device chain (closest to MISO) - -### Set Direction and Enable - -The `DIR_WRITE` macros for the L64xx drivers are written so that the standard X, Y, Z and extruder logic used by the `set_directions()` routine is not altered. These macros write the correct forward/reverse command to the corresponding location in the array `L6470_dir_commands`. On the L6474 the array the command used just enables the stepper because direction is set by the DIR pin. - -At the end of the `set_directions()` routine, the array `L6470_chain` is used to grab the corresponding direction/enable commands out of the array `L6470_dir_commands` and put them in the correct sequence in the array `L6470_buf`. Array `L6470_buf` is then passed to the **`void`** `L6470_Transfer` function which actually sends the data to the devices. - -### Utilities, etc. - -The **absolute position** registers should accurately reflect Marlin’s stepper position counts. They are set to zero during initialization. `G28` sets them to the Marlin counts for the corresponding axis after homing. NOTE: These registers are often the negative of the Marlin counts. This is because the Marlin counts reflect the logical direction while the registers reflect the stepper direction. The register contents are displayed via the `M114 D` command. - -The `L6470_monitor` feature reads the status of each device every half second. It will report if there are any error conditions present or if communications has been lost/restored. The `KVAL_HOLD` value is reduced every 2 – 2.5 seconds if the thermal warning or thermal shutdown conditions are present. - -**M122** displays the settings of most of the bits in the status register plus a couple of other items. - -**M906** can be used to set the `KVAL_HOLD` register (`TVAL` on L6474) one driver at a time. If a setting is not included with the command then the contents of the registers that affect the phase current/voltage are displayed. - -**M916, M917 & M918** - -These utilities are used to tune the system. They can get you in the ballpark for acceptable jerk, acceleration, top speed and `KVAL_HOLD` settings (`TVAL` on L6474). In general they seem to provide an overly optimistic `KVAL_HOLD` (`TVAL`) setting because of the lag between setting `KVAL_HOLD` (`TVAL`) and the driver reaching final temperature. Enabling the `L6470_monitor` feature during prints will provide the **final useful setting**. - -The amount of power needed to move the stepper without skipping steps increases as jerk, acceleration, top speed, and micro-steps increase. The power dissipated by the driver increases as the power to the stepper increases. The net result is a balancing act between jerk, acceleration, top speed, micro-steps, and power dissipated by the driver. - -**M916** - Increases `KVAL_HOLD` (`TVAL`) while moving one axis until a thermal warning is generated. This routine is also useful for determining the approximate `KVAL_HOLD` (`TVAL`) where the stepper stops losing steps. The sound will get noticeably quieter as it stops losing steps. - -**M917** - Find minimum current thresholds. This is accomplished by doing the following steps while moving an axis: - -1. Decrease OCD current until overcurrent error. - -2. Increase OCD until overcurrent error goes away. - -3. Decrease stall threshold until stall error (not available on the L6474). - -4. Increase stall until stall error goes away (not available on the L6474). - -**M918** - Increase speed until error or max feedrate achieved. diff --git a/Marlin/src/libs/MAX31865.cpp b/Marlin/src/libs/MAX31865.cpp index c042504cf8..3fe0694644 100644 --- a/Marlin/src/libs/MAX31865.cpp +++ b/Marlin/src/libs/MAX31865.cpp @@ -133,13 +133,13 @@ SPISettings MAX31865::spiConfig = SPISettings( /** * Initialize the SPI interface and set the number of RTD wires used * - * @param wires The number of wires in enum format. Can be MAX31865_2WIRE, MAX31865_3WIRE, or MAX31865_4WIRE. - * @param zero The resistance of the RTD at 0 degC, in ohms. - * @param ref The resistance of the reference resistor, in ohms. - * @param wire The resistance of the wire connecting the sensor to the RTD, in ohms. + * @param wires The number of wires as an enum: MAX31865_2WIRE, MAX31865_3WIRE, or MAX31865_4WIRE. + * @param zero_res The resistance of the RTD at 0°C, in ohms. + * @param ref_res The resistance of the reference resistor, in ohms. + * @param wire_res The resistance of the wire connecting the sensor to the RTD, in ohms. */ -void MAX31865::begin(max31865_numwires_t wires, float zero_res, float ref_res, float wire_res) { - zeroRes = zero_res; +void MAX31865::begin(max31865_numwires_t wires, const_float_t zero_res, const_float_t ref_res, const_float_t wire_res) { + resNormalizer = 100.0f / zero_res; // reciprocal of resistance, scaled by 100 refRes = ref_res; wireRes = wire_res; @@ -437,42 +437,61 @@ float MAX31865::temperature() { * * @return Temperature in C */ -float MAX31865::temperature(uint16_t adc_val) { +float MAX31865::temperature(const uint16_t adc_val) { return temperature(((adc_val) * RECIPROCAL(32768.0f)) * refRes - wireRes); } /** * Calculate the temperature in C from the RTD resistance. - * Uses the technique outlined in this PDF: - * http://www.analog.com/media/en/technical-documentation/application-notes/AN709_0.pdf * * @param rtd_res the resistance value in ohms - * @return the temperature in degC + * @return the temperature in °C */ float MAX31865::temperature(float rtd_res) { + + rtd_res *= resNormalizer; // normalize to 100 ohm + + // Constants for calculating temperature from the measured RTD resistance. + // http://www.analog.com/media/en/technical-documentation/application-notes/AN709_0.pdf + constexpr float RTD_Z1 = -0.0039083, + RTD_Z2 = +1.758480889e-5, + RTD_Z3 = -2.31e-8, + RTD_Z4 = -1.155e-6; + + // Callender-Van Dusen equation float temp = (RTD_Z1 + sqrt(RTD_Z2 + (RTD_Z3 * rtd_res))) * RECIPROCAL(RTD_Z4); - // From the PDF... // // The previous equation is valid only for temperatures of 0°C and above. // The equation for RRTD(t) that defines negative temperature behavior is a // fourth-order polynomial (after expanding the third term) and is quite // impractical to solve for a single expression of temperature as a function - // of resistance. + // of resistance. So here we use a Linear Approximation instead. // if (temp < 0) { - rtd_res = (rtd_res / zeroRes) * 100; // normalize to 100 ohm - float rpoly = rtd_res; + #ifndef MAX31865_APPROX + #define MAX31865_APPROX 5 + #endif + + constexpr float RTD_C[] = { + #if MAX31865_APPROX == 5 + -242.02, +2.2228, +2.5859e-3, -4.8260e-6, -2.8183e-8, +1.5243e-10 + #elif MAX31865_APPROX == 4 + -241.96, +2.2163, +2.8541e-3, -9.9121e-6, -1.7152e-8 + #elif MAX31865_APPROX == 3 + -242.09, +2.2276, +2.5178e-3, -5.8620e-6 + #else + -242.97, +2.2838, +1.4727e-3 + #endif + }; - temp = -242.02 + (2.2228 * rpoly); - rpoly *= rtd_res; // square - temp += 2.5859e-3 * rpoly; - rpoly *= rtd_res; // ^3 - temp -= 4.8260e-6 * rpoly; - rpoly *= rtd_res; // ^4 - temp -= 2.8183e-8 * rpoly; - rpoly *= rtd_res; // ^5 - temp += 1.5243e-10 * rpoly; + float rpoly = rtd_res; + temp = RTD_C[0]; + temp += rpoly * RTD_C[1]; + rpoly *= rtd_res; temp += rpoly * RTD_C[2]; + if (MAX31865_APPROX >= 3) { rpoly *= rtd_res; temp += rpoly * RTD_C[3]; } + if (MAX31865_APPROX >= 4) { rpoly *= rtd_res; temp += rpoly * RTD_C[4]; } + if (MAX31865_APPROX >= 5) { rpoly *= rtd_res; temp += rpoly * RTD_C[5]; } } return temp; diff --git a/Marlin/src/libs/MAX31865.h b/Marlin/src/libs/MAX31865.h index baea455485..95bde756ce 100644 --- a/Marlin/src/libs/MAX31865.h +++ b/Marlin/src/libs/MAX31865.h @@ -73,13 +73,6 @@ #define MAX31865_FAULT_RTDINLOW 0x08 // D3 #define MAX31865_FAULT_OVUV 0x04 // D2 -// http://www.analog.com/media/en/technical-documentation/application-notes/AN709_0.pdf -// constants for calculating temperature from the measured RTD resistance. -#define RTD_Z1 -0.0039083 -#define RTD_Z2 0.00001758480889 -#define RTD_Z3 -0.0000000231 -#define RTD_Z4 -0.000001155 - typedef enum max31865_numwires { MAX31865_2WIRE = 0, MAX31865_3WIRE = 1, @@ -103,7 +96,7 @@ class MAX31865 { uint16_t spiDelay; - float zeroRes, refRes, wireRes; + float resNormalizer, refRes, wireRes; #if ENABLED(MAX31865_USE_READ_ERROR_DETECTION) millis_t lastReadStamp = 0; @@ -160,7 +153,7 @@ class MAX31865 { int8_t spi_clk); #endif - void begin(max31865_numwires_t wires, float zero_res, float ref_res, float wire_res); + void begin(max31865_numwires_t wires, const_float_t zero_res, const_float_t ref_res, const_float_t wire_res); uint8_t readFault(); void clearFault(); @@ -168,6 +161,6 @@ class MAX31865 { uint16_t readRaw(); float readResistance(); float temperature(); - float temperature(uint16_t adc_val); + float temperature(const uint16_t adc_val); float temperature(float rtd_res); }; diff --git a/Marlin/src/libs/buzzer.cpp b/Marlin/src/libs/buzzer.cpp index a3c838ebc0..1e2f23c5fd 100644 --- a/Marlin/src/libs/buzzer.cpp +++ b/Marlin/src/libs/buzzer.cpp @@ -48,7 +48,7 @@ void Buzzer::tone(const uint16_t duration, const uint16_t frequency/*=0*/) { if (!ui.sound_on) return; while (buffer.isFull()) { tick(); - thermalManager.manage_heater(); + thermalManager.task(); } tone_t tone = { duration, frequency }; buffer.enqueue(tone); diff --git a/Marlin/src/libs/buzzer.h b/Marlin/src/libs/buzzer.h index 1e30eb1c44..35185e3bdc 100644 --- a/Marlin/src/libs/buzzer.h +++ b/Marlin/src/libs/buzzer.h @@ -117,12 +117,12 @@ // Buzz directly via the BEEPER pin tone queue #define BUZZ(d,f) buzzer.tone(d, f) -#elif HAS_BUZZER +#elif USE_MARLINUI_BUZZER - // Buzz indirectly via the MarlinUI instance + // Use MarlinUI for a buzzer on the LCD + #include "../lcd/marlinui.h" #define BUZZ(d,f) ui.buzz(d,f) #define BUZZ_M300(d, f) ui.buzz_m300(d,f) // @advi3++ - #include "../lcd/marlinui.h" #else diff --git a/Marlin/src/libs/nozzle.cpp b/Marlin/src/libs/nozzle.cpp index 4ca8fa2cae..575e74a814 100644 --- a/Marlin/src/libs/nozzle.cpp +++ b/Marlin/src/libs/nozzle.cpp @@ -161,7 +161,7 @@ Nozzle nozzle; void Nozzle::clean(const uint8_t &pattern, const uint8_t &strokes, const_float_t radius, const uint8_t &objects, const uint8_t cleans) { xyz_pos_t start[HOTENDS] = NOZZLE_CLEAN_START_POINT, end[HOTENDS] = NOZZLE_CLEAN_END_POINT, middle[HOTENDS] = NOZZLE_CLEAN_CIRCLE_MIDDLE; - const uint8_t arrPos = ANY(SINGLENOZZLE, MIXING_EXTRUDER) ? 0 : active_extruder; + const uint8_t arrPos = EITHER(SINGLENOZZLE, MIXING_EXTRUDER) ? 0 : active_extruder; #if NOZZLE_CLEAN_MIN_TEMP > 20 if (thermalManager.degTargetHotend(arrPos) < NOZZLE_CLEAN_MIN_TEMP) { diff --git a/Marlin/src/module/delta.cpp b/Marlin/src/module/delta.cpp index 8207dacaf7..ce2a6f4ada 100644 --- a/Marlin/src/module/delta.cpp +++ b/Marlin/src/module/delta.cpp @@ -60,10 +60,6 @@ xy_float_t delta_tower[ABC]; abc_float_t delta_diagonal_rod_2_tower; float delta_clip_start_height = Z_MAX_POS; abc_float_t delta_diagonal_rod_trim; -#if HAS_DELTA_SENSORLESS_PROBING - abc_float_t offset_sensorless_adj{0}; - float largest_sensorless_adj = 0; -#endif float delta_safe_distance_from_top(); diff --git a/Marlin/src/module/delta.h b/Marlin/src/module/delta.h index f7067ef9c7..0a0c6124ee 100644 --- a/Marlin/src/module/delta.h +++ b/Marlin/src/module/delta.h @@ -38,10 +38,6 @@ extern xy_float_t delta_tower[ABC]; extern abc_float_t delta_diagonal_rod_2_tower; extern float delta_clip_start_height; extern abc_float_t delta_diagonal_rod_trim; -#if HAS_DELTA_SENSORLESS_PROBING - extern abc_float_t offset_sensorless_adj; - extern float largest_sensorless_adj; -#endif /** * Recalculate factors used for delta kinematics whenever diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index 2234f40890..7d92bc1027 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -68,6 +68,13 @@ bool Endstops::enabled, Endstops::enabled_globally; // Initialized by settings.l volatile Endstops::endstop_mask_t Endstops::hit_state; Endstops::endstop_mask_t Endstops::live_state = 0; +#if ENABLED(BD_SENSOR) + bool Endstops::bdp_state; // = false + #define READ_ENDSTOP(P) ((P == Z_MIN_PIN) ? bdp_state : READ(P)) +#else + #define READ_ENDSTOP(P) READ(P) +#endif + #if ENDSTOP_NOISE_THRESHOLD Endstops::endstop_mask_t Endstops::validated_live_state; uint8_t Endstops::endstop_poll_count; @@ -549,6 +556,10 @@ void Endstops::event_handler() { card.abortFilePrintNow(); quickstop_stepper(); thermalManager.disable_all_heaters(); + #ifdef SD_ABORT_ON_ENDSTOP_HIT_GCODE + queue.clear(); + queue.inject(F(SD_ABORT_ON_ENDSTOP_HIT_GCODE)); + #endif print_job_timer.stop(); } #endif @@ -571,7 +582,7 @@ static void print_es_state(const bool is_hit, FSTR_P const flabel=nullptr) { void __O2 Endstops::report_states() { TERN_(BLTOUCH, bltouch._set_SW_mode()); SERIAL_ECHOLNPGM(STR_M119_REPORT); - #define ES_REPORT(S) print_es_state(READ(S##_PIN) != S##_ENDSTOP_INVERTING, F(STR_##S)) + #define ES_REPORT(S) print_es_state(READ_ENDSTOP(S##_PIN) != S##_ENDSTOP_INVERTING, F(STR_##S)) #if HAS_X_MIN ES_REPORT(X_MIN); #endif @@ -708,7 +719,7 @@ void Endstops::update() { #endif // Macros to update / copy the live_state - #define UPDATE_ENDSTOP_BIT(AXIS, MINMAX) SET_BIT_TO(live_state, _ENDSTOP(AXIS, MINMAX), (READ(_ENDSTOP_PIN(AXIS, MINMAX)) != _ENDSTOP_INVERTING(AXIS, MINMAX))) + #define UPDATE_ENDSTOP_BIT(AXIS, MINMAX) SET_BIT_TO(live_state, _ENDSTOP(AXIS, MINMAX), (READ_ENDSTOP(_ENDSTOP_PIN(AXIS, MINMAX)) != _ENDSTOP_INVERTING(AXIS, MINMAX))) #define COPY_LIVE_STATE(SRC_BIT, DST_BIT) SET_BIT_TO(live_state, DST_BIT, TEST(live_state, SRC_BIT)) #if ENABLED(G38_PROBE_TARGET) && NONE(CORE_IS_XY, CORE_IS_XZ, MARKFORGED_XY, MARKFORGED_YX) @@ -1439,7 +1450,7 @@ void Endstops::update() { static uint8_t local_LED_status = 0; uint16_t live_state_local = 0; - #define ES_GET_STATE(S) if (READ(S##_PIN)) SBI(live_state_local, S) + #define ES_GET_STATE(S) if (READ_ENDSTOP(S##_PIN)) SBI(live_state_local, S) #if HAS_X_MIN ES_GET_STATE(X_MIN); diff --git a/Marlin/src/module/endstops.h b/Marlin/src/module/endstops.h index 9e411adbda..bffa7fdc39 100644 --- a/Marlin/src/module/endstops.h +++ b/Marlin/src/module/endstops.h @@ -166,6 +166,11 @@ class Endstops { */ static void update(); + #if ENABLED(BD_SENSOR) + static bool bdp_state; + static void bdp_state_update(const bool z_state) { bdp_state = z_state; } + #endif + /** * Get Endstop hit state. */ diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index d07e57d102..b44b5506e2 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -300,6 +300,73 @@ void report_current_position_projected() { #endif +#if IS_KINEMATIC + + bool position_is_reachable(const_float_t rx, const_float_t ry, const float inset/*=0*/) { + + bool can_reach; + + #if ENABLED(DELTA) + + can_reach = HYPOT2(rx, ry) <= sq(DELTA_PRINTABLE_RADIUS - inset + fslop); + + #elif ENABLED(AXEL_TPARA) + + const float R2 = HYPOT2(rx - TPARA_OFFSET_X, ry - TPARA_OFFSET_Y); + can_reach = ( + R2 <= sq(L1 + L2) - inset + #if MIDDLE_DEAD_ZONE_R > 0 + && R2 >= sq(float(MIDDLE_DEAD_ZONE_R)) + #endif + ); + + #elif IS_SCARA + + const float R2 = HYPOT2(rx - SCARA_OFFSET_X, ry - SCARA_OFFSET_Y); + can_reach = ( + R2 <= sq(L1 + L2) - inset + #if MIDDLE_DEAD_ZONE_R > 0 + && R2 >= sq(float(MIDDLE_DEAD_ZONE_R)) + #endif + ); + + #elif ENABLED(POLARGRAPH) + + const float d1 = rx - (draw_area_min.x), + d2 = (draw_area_max.x) - rx, + y = ry - (draw_area_max.y), + a = HYPOT(d1, y), + b = HYPOT(d2, y); + + can_reach = ( + a < polargraph_max_belt_len + 1 + && b < polargraph_max_belt_len + 1 + && (a + b) > _MIN(draw_area_size.x, draw_area_size.y) + ); + + #endif + + return can_reach; + } + +#else // CARTESIAN + + // Return true if the given position is within the machine bounds. + bool position_is_reachable(const_float_t rx, const_float_t ry) { + if (!COORDINATE_OKAY(ry, Y_MIN_POS - fslop, Y_MAX_POS + fslop)) return false; + #if ENABLED(DUAL_X_CARRIAGE) + if (active_extruder) + return COORDINATE_OKAY(rx, X2_MIN_POS - fslop, X2_MAX_POS + fslop); + else + return COORDINATE_OKAY(rx, X1_MIN_POS - fslop, X1_MAX_POS + fslop); + #else + return COORDINATE_OKAY(rx, X_MIN_POS - fslop, X_MAX_POS + fslop); + #endif + } + +#endif // CARTESIAN + + void home_if_needed(const bool keeplev/*=false*/) { if (!all_axes_trusted()) gcode.home_all_axes(keeplev); } @@ -966,7 +1033,7 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { next_idle_ms = ms + 200UL; return idle(); } - thermalManager.manage_heater(); // Returns immediately on most calls + thermalManager.task(); // Returns immediately on most calls } #if IS_KINEMATIC @@ -1017,7 +1084,7 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { if (!position_is_reachable(destination)) return true; // Get the linear distance in XYZ - float cartesian_mm = diff.magnitude(); + float cartesian_mm = xyz_float_t(diff).magnitude(); // If the move is very short, check the E move distance TERN_(HAS_EXTRUDERS, if (UNEAR_ZERO(cartesian_mm)) cartesian_mm = ABS(diff.e)); @@ -1041,19 +1108,18 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { NOLESS(segments, 1U); // The approximate length of each segment - const float inv_segments = 1.0f / float(segments), - cartesian_segment_mm = cartesian_mm * inv_segments; + const float inv_segments = 1.0f / float(segments); const xyze_float_t segment_distance = diff * inv_segments; - #if ENABLED(SCARA_FEEDRATE_SCALING) - const float inv_duration = scaled_fr_mm_s / cartesian_segment_mm; - #endif + // Add hints to help optimize the move + PlannerHints hints(cartesian_mm * inv_segments); + TERN_(SCARA_FEEDRATE_SCALING, hints.inv_duration = scaled_fr_mm_s / hints.millimeters); /* SERIAL_ECHOPGM("mm=", cartesian_mm); SERIAL_ECHOPGM(" seconds=", seconds); SERIAL_ECHOPGM(" segments=", segments); - SERIAL_ECHOPGM(" segment_mm=", cartesian_segment_mm); + SERIAL_ECHOPGM(" segment_mm=", hints.millimeters); SERIAL_EOL(); //*/ @@ -1065,11 +1131,12 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { while (--segments) { segment_idle(next_idle_ms); raw += segment_distance; - if (!planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, cartesian_segment_mm OPTARG(SCARA_FEEDRATE_SCALING, inv_duration))) break; + if (!planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, hints)) + break; } // Ensure last segment arrives at target location. - planner.buffer_line(destination, scaled_fr_mm_s, active_extruder, cartesian_segment_mm OPTARG(SCARA_FEEDRATE_SCALING, inv_duration)); + planner.buffer_line(destination, scaled_fr_mm_s, active_extruder, hints); return false; // caller will update current_position } @@ -1108,17 +1175,16 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { NOLESS(segments, 1U); // The approximate length of each segment - const float inv_segments = 1.0f / float(segments), - cartesian_segment_mm = cartesian_mm * inv_segments; + const float inv_segments = 1.0f / float(segments); const xyze_float_t segment_distance = diff * inv_segments; - #if ENABLED(SCARA_FEEDRATE_SCALING) - const float inv_duration = scaled_fr_mm_s / cartesian_segment_mm; - #endif + // Add hints to help optimize the move + PlannerHints hints(cartesian_mm * inv_segments); + TERN_(SCARA_FEEDRATE_SCALING, hints.inv_duration = scaled_fr_mm_s / hints.millimeters); //SERIAL_ECHOPGM("mm=", cartesian_mm); //SERIAL_ECHOLNPGM(" segments=", segments); - //SERIAL_ECHOLNPGM(" segment_mm=", cartesian_segment_mm); + //SERIAL_ECHOLNPGM(" segment_mm=", hints.millimeters); // Get the raw current position as starting point xyze_pos_t raw = current_position; @@ -1128,12 +1194,13 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { while (--segments) { segment_idle(next_idle_ms); raw += segment_distance; - if (!planner.buffer_line(raw, fr_mm_s, active_extruder, cartesian_segment_mm OPTARG(SCARA_FEEDRATE_SCALING, inv_duration))) break; + if (!planner.buffer_line(raw, fr_mm_s, active_extruder, hints)) + break; } // Since segment_distance is only approximate, // the final move must be to the exact destination. - planner.buffer_line(destination, fr_mm_s, active_extruder, cartesian_segment_mm OPTARG(SCARA_FEEDRATE_SCALING, inv_duration)); + planner.buffer_line(destination, fr_mm_s, active_extruder, hints); } #endif // SEGMENT_LEVELED_MOVES && !AUTO_BED_LEVELING_UBL diff --git a/Marlin/src/module/motion.h b/Marlin/src/module/motion.h index ec47818877..ce90947657 100644 --- a/Marlin/src/module/motion.h +++ b/Marlin/src/module/motion.h @@ -549,63 +549,21 @@ void home_if_needed(const bool keeplev=false); #endif // Return true if the given point is within the printable area - inline bool position_is_reachable(const_float_t rx, const_float_t ry, const float inset=0) { - #if ENABLED(DELTA) - - return HYPOT2(rx, ry) <= sq(DELTA_PRINTABLE_RADIUS - inset + fslop); - - #elif ENABLED(POLARGRAPH) - - const float x1 = rx - (X_MIN_POS), x2 = (X_MAX_POS) - rx, y = ry - (Y_MAX_POS), - a = HYPOT(x1, y), b = HYPOT(x2, y); - return a < (POLARGRAPH_MAX_BELT_LEN) + 1 - && b < (POLARGRAPH_MAX_BELT_LEN) + 1 - && (a + b) > _MIN(X_BED_SIZE, Y_BED_SIZE); - - #elif ENABLED(AXEL_TPARA) - - const float R2 = HYPOT2(rx - TPARA_OFFSET_X, ry - TPARA_OFFSET_Y); - return ( - R2 <= sq(L1 + L2) - inset - #if MIDDLE_DEAD_ZONE_R > 0 - && R2 >= sq(float(MIDDLE_DEAD_ZONE_R)) - #endif - ); - - #elif IS_SCARA - - const float R2 = HYPOT2(rx - SCARA_OFFSET_X, ry - SCARA_OFFSET_Y); - return ( - R2 <= sq(L1 + L2) - inset - #if MIDDLE_DEAD_ZONE_R > 0 - && R2 >= sq(float(MIDDLE_DEAD_ZONE_R)) - #endif - ); - - #endif - } + bool position_is_reachable(const_float_t rx, const_float_t ry, const float inset=0); inline bool position_is_reachable(const xy_pos_t &pos, const float inset=0) { return position_is_reachable(pos.x, pos.y, inset); } -#else // CARTESIAN +#else // Return true if the given position is within the machine bounds. - inline bool position_is_reachable(const_float_t rx, const_float_t ry) { - if (!COORDINATE_OKAY(ry, Y_MIN_POS - fslop, Y_MAX_POS + fslop)) return false; - #if ENABLED(DUAL_X_CARRIAGE) - if (active_extruder) - return COORDINATE_OKAY(rx, X2_MIN_POS - fslop, X2_MAX_POS + fslop); - else - return COORDINATE_OKAY(rx, X1_MIN_POS - fslop, X1_MAX_POS + fslop); - #else - return COORDINATE_OKAY(rx, X_MIN_POS - fslop, X_MAX_POS + fslop); - #endif + bool position_is_reachable(const_float_t rx, const_float_t ry); + inline bool position_is_reachable(const xy_pos_t &pos) { + return position_is_reachable(pos.x, pos.y); } - inline bool position_is_reachable(const xy_pos_t &pos) { return position_is_reachable(pos.x, pos.y); } -#endif // CARTESIAN +#endif /** * Duplication mode diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 950f11f862..1c9601632d 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -28,12 +28,14 @@ * Derived from Grbl * Copyright (c) 2009-2011 Simen Svale Skogsrud * - * The ring buffer implementation gleaned from the wiring_serial library by David A. Mellis. + * Ring buffer gleaned from wiring_serial library by David A. Mellis. * + * Fast inverse function needed for Bézier interpolation for AVR + * was designed, written and tested by Eduardo José Tagle, April 2018. * - * Reasoning behind the mathematics in this module (in the key of 'Mathematica'): + * Planner mathematics (Mathematica-style): * - * s == speed, a == acceleration, t == time, d == distance + * Where: s == speed, a == acceleration, t == time, d == distance * * Basic definitions: * Speed[s_, a_, t_] := s + (a*t) @@ -41,7 +43,7 @@ * * 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() + * d -> (m^2 - s^2) / (2 a) * * Speed after a given distance of travel with constant acceleration: * Solve[{Speed[s, a, t] == m, Travel[s, a, t] == d}, m, t] @@ -49,17 +51,18 @@ * * DestinationSpeed[s_, a_, d_] := Sqrt[2 a d + s^2] * - * When to start braking (di) to reach a specified destination speed (s2) after accelerating - * from initial speed s1 without ever stopping at a plateau: + * When to start braking (di) to reach a specified destination speed (s2) after + * acceleration from initial speed s1 without ever reaching 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() + * di -> (2 a d - s1^2 + s2^2)/(4 a) * - * IntersectionDistance[s1_, s2_, a_, d_] := (2 a d - s1^2 + s2^2)/(4 a) + * We note, as an optimization, that if we have already calculated an + * acceleration distance d1 from s1 to m and a deceration distance d2 + * from m to s2 then * - * -- - * - * The fast inverse function needed for Bézier interpolation for AVR - * was designed, written and tested by Eduardo José Tagle on April/2018 + * d1 -> (m^2 - s1^2) / (2 a) + * d2 -> (m^2 - s2^2) / (2 a) + * di -> (d + d1 - d2) / 2 */ #include "planner.h" @@ -128,8 +131,13 @@ uint8_t Planner::delay_before_delivering; // This counter delays delivery planner_settings_t Planner::settings; // Initialized by settings.load() -#if ENABLED(LASER_POWER_INLINE) +/** + * Set up inline block variables + * Set laser_power_floor based on SPEED_POWER_MIN to pevent a zero power output state with LASER_POWER_TRAP + */ +#if ENABLED(LASER_FEATURE) laser_state_t Planner::laser_inline; // Current state for blocks + const uint8_t laser_power_floor = cutter.pct_to_ocr(SPEED_POWER_MIN); #endif uint32_t Planner::max_acceleration_steps_per_s2[DISTINCT_AXES]; // (steps/s^2) Derived from mm_per_s2 @@ -206,7 +214,7 @@ xyze_long_t Planner::position{0}; uint32_t Planner::acceleration_long_cutoff; xyze_float_t Planner::previous_speed; -float Planner::previous_nominal_speed_sqr; +float Planner::previous_nominal_speed; #if ENABLED(DISABLE_INACTIVE_EXTRUDER) last_move_t Planner::g_uc_extruder_last_move[E_STEPPERS] = { 0 }; @@ -215,7 +223,7 @@ float Planner::previous_nominal_speed_sqr; #ifdef XY_FREQUENCY_LIMIT int8_t Planner::xy_freq_limit_hz = XY_FREQUENCY_LIMIT; float Planner::xy_freq_min_speed_factor = (XY_FREQUENCY_MIN_PERCENT) * 0.01f; - int32_t Planner::xy_freq_min_interval_us = LROUND(1000000.0 / (XY_FREQUENCY_LIMIT)); + int32_t Planner::xy_freq_min_interval_us = LROUND(1000000.0f / (XY_FREQUENCY_LIMIT)); #endif #if ENABLED(LIN_ADVANCE) @@ -245,7 +253,7 @@ void Planner::init() { TERN_(HAS_POSITION_FLOAT, position_float.reset()); TERN_(IS_KINEMATIC, position_cart.reset()); previous_speed.reset(); - previous_nominal_speed_sqr = 0; + previous_nominal_speed = 0; TERN_(ABL_PLANAR, bed_level_matrix.set_to_identity()); clear_block_buffer(); delay_before_delivering = 0; @@ -739,7 +747,7 @@ block_t* Planner::get_current_block() { block_t * const block = &block_buffer[block_buffer_tail]; // No trapezoid calculated? Don't execute yet. - if (TEST(block->flag, BLOCK_BIT_RECALCULATE)) return nullptr; + if (block->flag.recalculate) return nullptr; // We can't be sure how long an active block will take, so don't count it. TERN_(HAS_WIRED_LCD, block_buffer_runtime_us -= block->segment_time_us); @@ -780,41 +788,49 @@ void Planner::calculate_trapezoid_for_block(block_t * const block, const_float_t NOLESS(initial_rate, uint32_t(MINIMAL_STEP_RATE)); NOLESS(final_rate, uint32_t(MINIMAL_STEP_RATE)); - #if ENABLED(S_CURVE_ACCELERATION) - uint32_t cruise_rate = initial_rate; + #if EITHER(S_CURVE_ACCELERATION, LIN_ADVANCE) + // If we have some plateau time, the cruise rate will be the nominal rate + uint32_t cruise_rate = block->nominal_rate; #endif const int32_t accel = block->acceleration_steps_per_s2; - // Steps required for acceleration, deceleration to/from nominal rate - uint32_t accelerate_steps = CEIL(estimate_acceleration_distance(initial_rate, block->nominal_rate, accel)), - decelerate_steps = FLOOR(estimate_acceleration_distance(block->nominal_rate, final_rate, -accel)); - // Steps between acceleration and deceleration, if any - int32_t plateau_steps = block->step_event_count - accelerate_steps - decelerate_steps; - - // Does accelerate_steps + decelerate_steps exceed step_event_count? - // Then we can't possibly reach the nominal rate, there will be no cruising. - // Use intersection_distance() to calculate accel / braking time in order to - // reach the final_rate exactly at the end of this block. - if (plateau_steps < 0) { - const float accelerate_steps_float = CEIL(intersection_distance(initial_rate, final_rate, accel, block->step_event_count)); - accelerate_steps = _MIN(uint32_t(_MAX(accelerate_steps_float, 0)), block->step_event_count); - plateau_steps = 0; - - #if ENABLED(S_CURVE_ACCELERATION) - // We won't reach the cruising rate. Let's calculate the speed we will reach - cruise_rate = final_speed(initial_rate, accel, accelerate_steps); - #endif + // Steps for acceleration, plateau and deceleration + int32_t plateau_steps = block->step_event_count; + uint32_t accelerate_steps = 0, + decelerate_steps = 0; + + if (accel != 0) { + // Steps required for acceleration, deceleration to/from nominal rate + const float nominal_rate_sq = sq(float(block->nominal_rate)); + float accelerate_steps_float = (nominal_rate_sq - sq(float(initial_rate))) * (0.5f / accel); + accelerate_steps = CEIL(accelerate_steps_float); + const float decelerate_steps_float = (nominal_rate_sq - sq(float(final_rate))) * (0.5f / accel); + decelerate_steps = FLOOR(decelerate_steps_float); + + // Steps between acceleration and deceleration, if any + plateau_steps -= accelerate_steps + decelerate_steps; + + // Does accelerate_steps + decelerate_steps exceed step_event_count? + // Then we can't possibly reach the nominal rate, there will be no cruising. + // Calculate accel / braking time in order to reach the final_rate exactly + // at the end of this block. + if (plateau_steps < 0) { + accelerate_steps_float = CEIL((block->step_event_count + accelerate_steps_float - decelerate_steps_float) * 0.5f); + accelerate_steps = _MIN(uint32_t(_MAX(accelerate_steps_float, 0)), block->step_event_count); + decelerate_steps = block->step_event_count - accelerate_steps; + + #if EITHER(S_CURVE_ACCELERATION, LIN_ADVANCE) + // We won't reach the cruising rate. Let's calculate the speed we will reach + cruise_rate = final_speed(initial_rate, accel, accelerate_steps); + #endif + } } - #if ENABLED(S_CURVE_ACCELERATION) - else // We have some plateau time, so the cruise rate will be the nominal rate - cruise_rate = block->nominal_rate; - #endif #if ENABLED(S_CURVE_ACCELERATION) // Jerk controlled speed requires to express speed versus time, NOT steps - uint32_t acceleration_time = ((float)(cruise_rate - initial_rate) / accel) * (STEPPER_TIMER_RATE), - deceleration_time = ((float)(cruise_rate - final_rate) / accel) * (STEPPER_TIMER_RATE), + uint32_t acceleration_time = (float(cruise_rate - initial_rate) / accel) * (STEPPER_TIMER_RATE), + deceleration_time = (float(cruise_rate - final_rate) / accel) * (STEPPER_TIMER_RATE), // And to offload calculations from the ISR, we also calculate the inverse of those times here acceleration_time_inverse = get_period_inverse(acceleration_time), deceleration_time_inverse = get_period_inverse(deceleration_time); @@ -822,7 +838,7 @@ void Planner::calculate_trapezoid_for_block(block_t * const block, const_float_t // Store new block parameters block->accelerate_until = accelerate_steps; - block->decelerate_after = accelerate_steps + plateau_steps; + block->decelerate_after = block->step_event_count - decelerate_steps; block->initial_rate = initial_rate; #if ENABLED(S_CURVE_ACCELERATION) block->acceleration_time = acceleration_time; @@ -833,112 +849,139 @@ void Planner::calculate_trapezoid_for_block(block_t * const block, const_float_t #endif block->final_rate = final_rate; - /** - * Laser trapezoid calculations - * - * Approximate the trapezoid with the laser, incrementing the power every `entry_per` while accelerating - * and decrementing it every `exit_power_per` while decelerating, thus ensuring power is related to feedrate. - * - * LASER_POWER_INLINE_TRAPEZOID_CONT doesn't need this as it continuously approximates - * - * Note this may behave unreliably when running with S_CURVE_ACCELERATION - */ - #if ENABLED(LASER_POWER_INLINE_TRAPEZOID) - if (block->laser.power > 0) { // No need to care if power == 0 - const uint8_t entry_power = block->laser.power * entry_factor; // Power on block entry - #if DISABLED(LASER_POWER_INLINE_TRAPEZOID_CONT) - // Speedup power - const uint8_t entry_power_diff = block->laser.power - entry_power; - if (entry_power_diff) { - block->laser.entry_per = accelerate_steps / entry_power_diff; - block->laser.power_entry = entry_power; - } - else { - block->laser.entry_per = 0; - block->laser.power_entry = block->laser.power; - } - // Slowdown power - const uint8_t exit_power = block->laser.power * exit_factor, // Power on block entry - exit_power_diff = block->laser.power - exit_power; - if (exit_power_diff) { - block->laser.exit_per = (block->step_event_count - block->decelerate_after) / exit_power_diff; - block->laser.power_exit = exit_power; + #if ENABLED(LIN_ADVANCE) + if (block->la_advance_rate) { + const float comp = extruder_advance_K[block->extruder] * block->steps.e / block->step_event_count; + block->max_adv_steps = cruise_rate * comp; + block->final_adv_steps = final_rate * comp; + } + #endif + + #if ENABLED(LASER_POWER_TRAP) + /** + * Laser Trapezoid Calculations + * + * Approximate the trapezoid with the laser, incrementing the power every `trap_ramp_entry_incr` + * steps while accelerating, and decrementing the power every `trap_ramp_exit_decr` while decelerating, + * to keep power proportional to feedrate. Laser power trap will reduce the initial power to no less + * than the laser_power_floor value. Based on the number of calculated accel/decel steps the power is + * distributed over the trapezoid entry- and exit-ramp steps. + * + * trap_ramp_active_pwr - The active power is initially set at a reduced level factor of initial + * power / accel steps and will be additively incremented using a trap_ramp_entry_incr value for each + * accel step processed later in the stepper code. The trap_ramp_exit_decr value is calculated as + * power / decel steps and is also adjusted to no less than the power floor. + * + * If the power == 0 the inline mode variables need to be set to zero to prevent stepper processing. + * The method allows for simpler non-powered moves like G0 or G28. + * + * Laser Trap Power works for all Jerk and Curve modes; however Arc-based moves will have issues since + * the segments are usually too small. + */ + if (cutter.cutter_mode == CUTTER_MODE_CONTINUOUS) { + if (planner.laser_inline.status.isPowered && planner.laser_inline.status.isEnabled) { + if (block->laser.power > 0) { + NOLESS(block->laser.power, laser_power_floor); + block->laser.trap_ramp_active_pwr = (block->laser.power - laser_power_floor) * (initial_rate / float(block->nominal_rate)) + laser_power_floor; + block->laser.trap_ramp_entry_incr = (block->laser.power - block->laser.trap_ramp_active_pwr) / accelerate_steps; + float laser_pwr = block->laser.power * (final_rate / float(block->nominal_rate)); + NOLESS(laser_pwr, laser_power_floor); + block->laser.trap_ramp_exit_decr = (block->laser.power - laser_pwr) / decelerate_steps; + #if ENABLED(DEBUG_LASER_TRAP) + SERIAL_ECHO_MSG("lp:",block->laser.power); + SERIAL_ECHO_MSG("as:",accelerate_steps); + SERIAL_ECHO_MSG("ds:",decelerate_steps); + SERIAL_ECHO_MSG("p.trap:",block->laser.trap_ramp_active_pwr); + SERIAL_ECHO_MSG("p.incr:",block->laser.trap_ramp_entry_incr); + SERIAL_ECHO_MSG("p.decr:",block->laser.trap_ramp_exit_decr); + #endif } else { - block->laser.exit_per = 0; - block->laser.power_exit = block->laser.power; + block->laser.trap_ramp_active_pwr = 0; + block->laser.trap_ramp_entry_incr = 0; + block->laser.trap_ramp_exit_decr = 0; } - #else - block->laser.power_entry = entry_power; - #endif + + } } - #endif + #endif // LASER_POWER_TRAP } -/* PLANNER SPEED DEFINITION - +--------+ <- current->nominal_speed - / \ - current->entry_speed -> + \ - | + <- next->entry_speed (aka exit speed) - +-------------+ - time --> - - Recalculates the motion plan according to the following basic guidelines: - - 1. Go over every feasible block sequentially in reverse order and calculate the junction speeds - (i.e. current->entry_speed) such that: - a. No junction speed exceeds the pre-computed maximum junction speed limit or nominal speeds of - neighboring blocks. - b. A block entry speed cannot exceed one reverse-computed from its exit speed (next->entry_speed) - with a maximum allowable deceleration over the block travel distance. - c. The last (or newest appended) block is planned from a complete stop (an exit speed of zero). - 2. Go over every block in chronological (forward) order and dial down junction speed values if - a. The exit speed exceeds the one forward-computed from its entry speed with the maximum allowable - acceleration over the block travel distance. - - When these stages are complete, the planner will have maximized the velocity profiles throughout the all - of the planner blocks, where every block is operating at its maximum allowable acceleration limits. In - other words, for all of the blocks in the planner, the plan is optimal and no further speed improvements - are possible. If a new block is added to the buffer, the plan is recomputed according to the said - guidelines for a new optimal plan. - - To increase computational efficiency of these guidelines, a set of planner block pointers have been - created to indicate stop-compute points for when the planner guidelines cannot logically make any further - changes or improvements to the plan when in normal operation and new blocks are streamed and added to the - planner buffer. For example, if a subset of sequential blocks in the planner have been planned and are - bracketed by junction velocities at their maximums (or by the first planner block as well), no new block - added to the planner buffer will alter the velocity profiles within them. So we no longer have to compute - them. Or, if a set of sequential blocks from the first block in the planner (or a optimal stop-compute - point) are all accelerating, they are all optimal and can not be altered by a new block added to the - planner buffer, as this will only further increase the plan speed to chronological blocks until a maximum - junction velocity is reached. However, if the operational conditions of the plan changes from infrequently - used feed holds or feedrate overrides, the stop-compute pointers will be reset and the entire plan is - recomputed as stated in the general guidelines. - - Planner buffer index mapping: - - block_buffer_tail: Points to the beginning of the planner buffer. First to be executed or being executed. - - block_buffer_head: Points to the buffer block after the last block in the buffer. Used to indicate whether - the buffer is full or empty. As described for standard ring buffers, this block is always empty. - - block_buffer_planned: Points to the first buffer block after the last optimally planned block for normal - streaming operating conditions. Use for planning optimizations by avoiding recomputing parts of the - planner buffer that don't change with the addition of a new block, as describe above. In addition, - this block can never be less than block_buffer_tail and will always be pushed forward and maintain - this requirement when encountered by the Planner::release_current_block() routine during a cycle. - - NOTE: Since the planner only computes on what's in the planner buffer, some motions with lots of short - line segments, like G2/3 arcs or complex curves, may seem to move slow. This is because there simply isn't - enough combined distance traveled in the entire buffer to accelerate up to the nominal speed and then - decelerate to a complete stop at the end of the buffer, as stated by the guidelines. If this happens and - becomes an annoyance, there are a few simple solutions: (1) Maximize the machine acceleration. The planner - will be able to compute higher velocity profiles within the same combined distance. (2) Maximize line - motion(s) distance per block to a desired tolerance. The more combined distance the planner has to use, - the faster it can go. (3) Maximize the planner buffer size. This also will increase the combined distance - for the planner to compute over. It also increases the number of computations the planner has to perform - to compute an optimal plan, so select carefully. -*/ +/** + * PLANNER SPEED DEFINITION + * +--------+ <- current->nominal_speed + * / \ + * current->entry_speed -> + \ + * | + <- next->entry_speed (aka exit speed) + * +-------------+ + * time --> + * + * Recalculates the motion plan according to the following basic guidelines: + * + * 1. Go over every feasible block sequentially in reverse order and calculate the junction speeds + * (i.e. current->entry_speed) such that: + * a. No junction speed exceeds the pre-computed maximum junction speed limit or nominal speeds of + * neighboring blocks. + * b. A block entry speed cannot exceed one reverse-computed from its exit speed (next->entry_speed) + * with a maximum allowable deceleration over the block travel distance. + * c. The last (or newest appended) block is planned from a complete stop (an exit speed of zero). + * 2. Go over every block in chronological (forward) order and dial down junction speed values if + * a. The exit speed exceeds the one forward-computed from its entry speed with the maximum allowable + * acceleration over the block travel distance. + * + * When these stages are complete, the planner will have maximized the velocity profiles throughout the all + * of the planner blocks, where every block is operating at its maximum allowable acceleration limits. In + * other words, for all of the blocks in the planner, the plan is optimal and no further speed improvements + * are possible. If a new block is added to the buffer, the plan is recomputed according to the said + * guidelines for a new optimal plan. + * + * To increase computational efficiency of these guidelines, a set of planner block pointers have been + * created to indicate stop-compute points for when the planner guidelines cannot logically make any further + * changes or improvements to the plan when in normal operation and new blocks are streamed and added to the + * planner buffer. For example, if a subset of sequential blocks in the planner have been planned and are + * bracketed by junction velocities at their maximums (or by the first planner block as well), no new block + * added to the planner buffer will alter the velocity profiles within them. So we no longer have to compute + * them. Or, if a set of sequential blocks from the first block in the planner (or a optimal stop-compute + * point) are all accelerating, they are all optimal and can not be altered by a new block added to the + * planner buffer, as this will only further increase the plan speed to chronological blocks until a maximum + * junction velocity is reached. However, if the operational conditions of the plan changes from infrequently + * used feed holds or feedrate overrides, the stop-compute pointers will be reset and the entire plan is + * recomputed as stated in the general guidelines. + * + * Planner buffer index mapping: + * - block_buffer_tail: Points to the beginning of the planner buffer. First to be executed or being executed. + * - block_buffer_head: Points to the buffer block after the last block in the buffer. Used to indicate whether + * the buffer is full or empty. As described for standard ring buffers, this block is always empty. + * - block_buffer_planned: Points to the first buffer block after the last optimally planned block for normal + * streaming operating conditions. Use for planning optimizations by avoiding recomputing parts of the + * planner buffer that don't change with the addition of a new block, as describe above. In addition, + * this block can never be less than block_buffer_tail and will always be pushed forward and maintain + * this requirement when encountered by the Planner::release_current_block() routine during a cycle. + * + * NOTE: Since the planner only computes on what's in the planner buffer, some motions with many short + * segments (e.g., complex curves) may seem to move slowly. This is because there simply isn't + * enough combined distance traveled in the entire buffer to accelerate up to the nominal speed and + * then decelerate to a complete stop at the end of the buffer, as stated by the guidelines. If this + * happens and becomes an annoyance, there are a few simple solutions: + * + * - Maximize the machine acceleration. The planner will be able to compute higher velocity profiles + * within the same combined distance. + * + * - Maximize line motion(s) distance per block to a desired tolerance. The more combined distance the + * planner has to use, the faster it can go. + * + * - Maximize the planner buffer size. This also will increase the combined distance for the planner to + * compute over. It also increases the number of computations the planner has to perform to compute an + * optimal plan, so select carefully. + * + * - Use G2/G3 arcs instead of many short segments. Arcs inform the planner of a safe exit speed at the + * end of the last segment, which alleviates this problem. + */ // The kernel called by recalculate() when scanning the plan from last to first entry. -void Planner::reverse_pass_kernel(block_t * const current, const block_t * const next) { +void Planner::reverse_pass_kernel(block_t * const current, const block_t * const next + OPTARG(HINTS_SAFE_EXIT_SPEED, const_float_t safe_exit_speed_sqr) +) { if (current) { // If entry speed is already at the maximum entry speed, and there was no change of speed // in the next block, there is no need to recheck. Block is cruising and there is no need to @@ -948,7 +991,7 @@ void Planner::reverse_pass_kernel(block_t * const current, const block_t * const // Compute maximum entry speed decelerating over the current block from its exit speed. // If not at the maximum entry speed, or the previous block entry speed changed - if (current->entry_speed_sqr != max_entry_speed_sqr || (next && TEST(next->flag, BLOCK_BIT_RECALCULATE))) { + if (current->entry_speed_sqr != max_entry_speed_sqr || (next && next->flag.recalculate)) { // If nominal length true, max junction speed is guaranteed to be reached. // If a block can de/ac-celerate from nominal speed to zero within the length of the block, then @@ -958,14 +1001,15 @@ void Planner::reverse_pass_kernel(block_t * const current, const block_t * const // the reverse and forward planners, the corresponding block junction speed will always be at the // the maximum junction speed and may always be ignored for any speed reduction checks. - const float new_entry_speed_sqr = TEST(current->flag, BLOCK_BIT_NOMINAL_LENGTH) - ? max_entry_speed_sqr - : _MIN(max_entry_speed_sqr, max_allowable_speed_sqr(-current->acceleration, next ? next->entry_speed_sqr : sq(float(MINIMUM_PLANNER_SPEED)), current->millimeters)); + const float next_entry_speed_sqr = next ? next->entry_speed_sqr : _MAX(TERN0(HINTS_SAFE_EXIT_SPEED, safe_exit_speed_sqr), sq(float(MINIMUM_PLANNER_SPEED))), + new_entry_speed_sqr = current->flag.nominal_length + ? max_entry_speed_sqr + : _MIN(max_entry_speed_sqr, max_allowable_speed_sqr(-current->acceleration, next_entry_speed_sqr, current->millimeters)); if (current->entry_speed_sqr != new_entry_speed_sqr) { // Need to recalculate the block speed - Mark it now, so the stepper // ISR does not consume the block before being recalculated - SBI(current->flag, BLOCK_BIT_RECALCULATE); + current->flag.recalculate = true; // But there is an inherent race condition here, as the block may have // become BUSY just before being marked RECALCULATE, so check for that! @@ -973,7 +1017,7 @@ void Planner::reverse_pass_kernel(block_t * const current, const block_t * const // Block became busy. Clear the RECALCULATE flag (no point in // recalculating BUSY blocks). And don't set its speed, as it can't // be updated at this time. - CBI(current->flag, BLOCK_BIT_RECALCULATE); + current->flag.recalculate = false; } else { // Block is not BUSY so this is ahead of the Stepper ISR: @@ -989,7 +1033,7 @@ void Planner::reverse_pass_kernel(block_t * const current, const block_t * const * recalculate() needs to go over the current plan twice. * Once in reverse and once forward. This implements the reverse pass. */ -void Planner::reverse_pass() { +void Planner::reverse_pass(TERN_(HINTS_SAFE_EXIT_SPEED, const_float_t safe_exit_speed_sqr)) { // Initialize block index to the last block in the planner buffer. uint8_t block_index = prev_block_index(block_buffer_head); @@ -1011,9 +1055,9 @@ void Planner::reverse_pass() { // Perform the reverse pass block_t *current = &block_buffer[block_index]; - // Only consider non sync-and-page blocks - if (!(current->flag & BLOCK_MASK_SYNC) && !IS_PAGE(current)) { - reverse_pass_kernel(current, next); + // Only process movement blocks + if (current->is_move()) { + reverse_pass_kernel(current, next OPTARG(HINTS_SAFE_EXIT_SPEED, safe_exit_speed_sqr)); next = current; } @@ -1041,8 +1085,7 @@ void Planner::forward_pass_kernel(const block_t * const previous, block_t * cons // change, adjust the entry speed accordingly. Entry speeds have already been reset, // maximized, and reverse-planned. If nominal length is set, max junction speed is // guaranteed to be reached. No need to recheck. - if (!TEST(previous->flag, BLOCK_BIT_NOMINAL_LENGTH) && - previous->entry_speed_sqr < current->entry_speed_sqr) { + if (!previous->flag.nominal_length && previous->entry_speed_sqr < current->entry_speed_sqr) { // Compute the maximum allowable speed const float new_entry_speed_sqr = max_allowable_speed_sqr(-previous->acceleration, previous->entry_speed_sqr, previous->millimeters); @@ -1052,7 +1095,7 @@ void Planner::forward_pass_kernel(const block_t * const previous, block_t * cons // Mark we need to recompute the trapezoidal shape, and do it now, // so the stepper ISR does not consume the block before being recalculated - SBI(current->flag, BLOCK_BIT_RECALCULATE); + current->flag.recalculate = true; // But there is an inherent race condition here, as the block maybe // became BUSY, just before it was marked as RECALCULATE, so check @@ -1061,7 +1104,7 @@ void Planner::forward_pass_kernel(const block_t * const previous, block_t * cons // Block became busy. Clear the RECALCULATE flag (no point in // recalculating BUSY blocks and don't set its speed, as it can't // be updated at this time. - CBI(current->flag, BLOCK_BIT_RECALCULATE); + current->flag.recalculate = false; } else { // Block is not BUSY, we won the race against the Stepper ISR: @@ -1106,8 +1149,8 @@ void Planner::forward_pass() { // Perform the forward pass block = &block_buffer[block_index]; - // Skip SYNC and page blocks - if (!(block->flag & BLOCK_MASK_SYNC) && !IS_PAGE(block)) { + // Only process movement blocks + if (block->is_move()) { // If there's no previous block or the previous block is not // BUSY (thus, modifiable) run the forward_pass_kernel. Otherwise, // the previous block became BUSY, so assume the current block's @@ -1127,7 +1170,7 @@ void Planner::forward_pass() { * according to the entry_factor for each junction. Must be called by * recalculate() after updating the blocks. */ -void Planner::recalculate_trapezoids() { +void Planner::recalculate_trapezoids(TERN_(HINTS_SAFE_EXIT_SPEED, const_float_t safe_exit_speed_sqr)) { // The tail may be changed by the ISR so get a local copy. uint8_t block_index = block_buffer_tail, head_block_index = block_buffer_head; @@ -1142,8 +1185,8 @@ void Planner::recalculate_trapezoids() { // Get the pointer to the block block_t *prev = &block_buffer[prev_index]; - // If not dealing with a sync block, we are done. The last block is not a SYNC block - if (!(prev->flag & BLOCK_MASK_SYNC)) break; + // It the block is a move, we're done with this loop + if (prev->is_move()) break; // Examine the previous block. This and all following are SYNC blocks head_block_index = prev_index; @@ -1151,23 +1194,22 @@ void Planner::recalculate_trapezoids() { // Go from the tail (currently executed block) to the first block, without including it) block_t *block = nullptr, *next = nullptr; - float current_entry_speed = 0.0, next_entry_speed = 0.0; + float current_entry_speed = 0.0f, next_entry_speed = 0.0f; while (block_index != head_block_index) { next = &block_buffer[block_index]; - // Skip sync and page blocks - if (!(next->flag & BLOCK_MASK_SYNC) && !IS_PAGE(next)) { + // Only process movement blocks + if (next->is_move()) { next_entry_speed = SQRT(next->entry_speed_sqr); if (block) { - // Recalculate if current block entry or exit junction speed has changed. - if (TEST(block->flag, BLOCK_BIT_RECALCULATE) || TEST(next->flag, BLOCK_BIT_RECALCULATE)) { - // Mark the current block as RECALCULATE, to protect it from the Stepper ISR running it. - // Note that due to the above condition, there's a chance the current block isn't marked as - // RECALCULATE yet, but the next one is. That's the reason for the following line. - SBI(block->flag, BLOCK_BIT_RECALCULATE); + // If the next block is marked to RECALCULATE, also mark the previously-fetched one + if (next->flag.recalculate) block->flag.recalculate = true; + + // Recalculate if current block entry or exit junction speed has changed. + if (block->flag.recalculate) { // But there is an inherent race condition here, as the block maybe // became BUSY, just before it was marked as RECALCULATE, so check @@ -1176,21 +1218,13 @@ void Planner::recalculate_trapezoids() { // Block is not BUSY, we won the race against the Stepper ISR: // NOTE: Entry and exit factors always > 0 by all previous logic operations. - const float current_nominal_speed = SQRT(block->nominal_speed_sqr), - nomr = 1.0f / current_nominal_speed; + const float nomr = 1.0f / block->nominal_speed; calculate_trapezoid_for_block(block, current_entry_speed * nomr, next_entry_speed * nomr); - #if ENABLED(LIN_ADVANCE) - if (block->use_advance_lead) { - const float comp = block->e_D_ratio * extruder_advance_K[active_extruder] * settings.axis_steps_per_mm[E_AXIS]; - block->max_adv_steps = current_nominal_speed * comp; - block->final_adv_steps = next_entry_speed * comp; - } - #endif } // Reset current only to ensure next trapezoid is computed - The // stepper is free to use the block from now on. - CBI(block->flag, BLOCK_BIT_RECALCULATE); + block->flag.recalculate = false; } } @@ -1201,13 +1235,15 @@ void Planner::recalculate_trapezoids() { block_index = next_block_index(block_index); } - // Last/newest block in buffer. Exit speed is set with MINIMUM_PLANNER_SPEED. Always recalculated. - if (next) { + // Last/newest block in buffer. Always recalculated. + if (block) { + // Exit speed is set with MINIMUM_PLANNER_SPEED unless some code higher up knows better. + next_entry_speed = _MAX(TERN0(HINTS_SAFE_EXIT_SPEED, SQRT(safe_exit_speed_sqr)), float(MINIMUM_PLANNER_SPEED)); // Mark the next(last) block as RECALCULATE, to prevent the Stepper ISR running it. // As the last block is always recalculated here, there is a chance the block isn't // marked as RECALCULATE yet. That's the reason for the following line. - SBI(next->flag, BLOCK_BIT_RECALCULATE); + block->flag.recalculate = true; // But there is an inherent race condition here, as the block maybe // became BUSY, just before it was marked as RECALCULATE, so check @@ -1215,33 +1251,25 @@ void Planner::recalculate_trapezoids() { if (!stepper.is_block_busy(block)) { // Block is not BUSY, we won the race against the Stepper ISR: - const float next_nominal_speed = SQRT(next->nominal_speed_sqr), - nomr = 1.0f / next_nominal_speed; - calculate_trapezoid_for_block(next, next_entry_speed * nomr, float(MINIMUM_PLANNER_SPEED) * nomr); - #if ENABLED(LIN_ADVANCE) - if (next->use_advance_lead) { - const float comp = next->e_D_ratio * extruder_advance_K[active_extruder] * settings.axis_steps_per_mm[E_AXIS]; - next->max_adv_steps = next_nominal_speed * comp; - next->final_adv_steps = (MINIMUM_PLANNER_SPEED) * comp; - } - #endif + const float nomr = 1.0f / block->nominal_speed; + calculate_trapezoid_for_block(block, current_entry_speed * nomr, next_entry_speed * nomr); } - // Reset next only to ensure its trapezoid is computed - The stepper is free to use + // Reset block to ensure its trapezoid is computed - The stepper is free to use // the block from now on. - CBI(next->flag, BLOCK_BIT_RECALCULATE); + block->flag.recalculate = false; } } -void Planner::recalculate() { +void Planner::recalculate(TERN_(HINTS_SAFE_EXIT_SPEED, const_float_t safe_exit_speed_sqr)) { // Initialize block index to the last block in the planner buffer. const uint8_t block_index = prev_block_index(block_buffer_head); // If there is just one block, no planning can be done. Avoid it! if (block_index != block_buffer_planned) { - reverse_pass(); + reverse_pass(TERN_(HINTS_SAFE_EXIT_SPEED, safe_exit_speed_sqr)); forward_pass(); } - recalculate_trapezoids(); + recalculate_trapezoids(TERN_(HINTS_SAFE_EXIT_SPEED, safe_exit_speed_sqr)); } /** @@ -1265,14 +1293,10 @@ void Planner::recalculate() { #define FAN_SET(F) do{ kickstart_fan(fan_speed, ms, F); _FAN_SET(F); }while(0) const millis_t ms = millis(); - TERN_(HAS_FAN0, FAN_SET(0)); - TERN_(HAS_FAN1, FAN_SET(1)); - TERN_(HAS_FAN2, FAN_SET(2)); - TERN_(HAS_FAN3, FAN_SET(3)); - TERN_(HAS_FAN4, FAN_SET(4)); - TERN_(HAS_FAN5, FAN_SET(5)); - TERN_(HAS_FAN6, FAN_SET(6)); - TERN_(HAS_FAN7, FAN_SET(7)); + TERN_(HAS_FAN0, FAN_SET(0)); TERN_(HAS_FAN1, FAN_SET(1)); + TERN_(HAS_FAN2, FAN_SET(2)); TERN_(HAS_FAN3, FAN_SET(3)); + TERN_(HAS_FAN4, FAN_SET(4)); TERN_(HAS_FAN5, FAN_SET(5)); + TERN_(HAS_FAN6, FAN_SET(6)); TERN_(HAS_FAN7, FAN_SET(7)); } #if FAN_KICKSTART_TIME @@ -1296,7 +1320,7 @@ void Planner::recalculate() { #endif // HAS_FAN /** - * Maintain fans, paste extruder pressure, + * Maintain fans, paste extruder pressure, spindle/laser power */ void Planner::check_axes_activity() { @@ -1360,7 +1384,7 @@ void Planner::check_axes_activity() { } else { - TERN_(HAS_CUTTER, cutter.refresh()); + TERN_(HAS_CUTTER, if (cutter.cutter_mode == CUTTER_MODE_STANDARD) cutter.refresh()); #if HAS_TAIL_FAN_SPEED FANS_LOOP(i) { @@ -1460,7 +1484,7 @@ void Planner::check_axes_activity() { for (uint8_t b = block_buffer_tail; b != block_buffer_head; b = next_block_index(b)) { const block_t * const block = &block_buffer[b]; if (NUM_AXIS_GANG(block->steps.x, || block->steps.y, || block->steps.z, || block->steps.i, || block->steps.j, || block->steps.k, || block->steps.u, || block->steps.v, || block->steps.w)) { - const float se = (float)block->steps.e / block->step_event_count * SQRT(block->nominal_speed_sqr); // mm/sec; + const float se = float(block->steps.e) / block->step_event_count * block->nominal_speed; // mm/sec NOLESS(high, se); } } @@ -1558,7 +1582,7 @@ void Planner::check_axes_activity() { TERN_(DELTA, settings.max_acceleration_mm_per_s2[Z_AXIS] = saved_motion_state.acceleration.z); TERN_(HAS_CLASSIC_JERK, max_jerk = saved_motion_state.jerk_state); } - reset_acceleration_rates(); + refresh_acceleration_rates(); } #endif @@ -1767,22 +1791,21 @@ float Planner::get_axis_position_mm(const AxisEnum axis) { void Planner::synchronize() { while (busy()) idle(); } /** - * Planner::_buffer_steps + * @brief Add a new linear movement to the planner queue (in terms of steps). * - * Add a new linear movement to the planner queue (in terms of steps). + * @param target Target position in steps units + * @param target_float Target position in direct (mm, degrees) units. + * @param cart_dist_mm The pre-calculated move lengths for all axes, in mm + * @param fr_mm_s (target) speed of the move + * @param extruder target extruder + * @param hints parameters to aid planner calculations * - * target - target position in steps units - * target_float - target position in direct (mm, degrees) units. optional - * fr_mm_s - (target) speed of the move - * extruder - target extruder - * millimeters - the length of the movement, if known - * - * Returns true if movement was properly queued, false otherwise (if cleaning) + * @return true if movement was properly queued, false otherwise (if cleaning) */ bool Planner::_buffer_steps(const xyze_long_t &target OPTARG(HAS_POSITION_FLOAT, const xyze_pos_t &target_float) OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm) - , feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters + , feedRate_t fr_mm_s, const uint8_t extruder, const PlannerHints &hints ) { // Wait for the next available block @@ -1795,11 +1818,12 @@ bool Planner::_buffer_steps(const xyze_long_t &target if (cleaning_buffer_counter) return false; // Fill the block with the specified movement - if (!_populate_block(block, false, target - OPTARG(HAS_POSITION_FLOAT, target_float) - OPTARG(HAS_DIST_MM_ARG, cart_dist_mm) - , fr_mm_s, extruder, millimeters - )) { + if (!_populate_block(block, target + OPTARG(HAS_POSITION_FLOAT, target_float) + OPTARG(HAS_DIST_MM_ARG, cart_dist_mm) + , fr_mm_s, extruder, hints + ) + ) { // Movement was not queued, probably because it was too short. // Simply accept that as movement queued and done return true; @@ -1819,28 +1843,34 @@ bool Planner::_buffer_steps(const xyze_long_t &target block_buffer_head = next_buffer_head; // Recalculate and optimize trapezoidal speed profiles - recalculate(); + recalculate(TERN_(HINTS_SAFE_EXIT_SPEED, hints.safe_exit_speed_sqr)); // Movement successfully queued! return true; } /** - * Planner::_populate_block - * - * Fills a new linear movement in the block (in terms of steps). + * @brief Populate a block in preparation for insertion + * @details Populate the fields of a new linear movement block + * that will be added to the queue and processed soon + * by the Stepper ISR. * - * target - target position in steps units - * fr_mm_s - (target) speed of the move - * extruder - target extruder + * @param block A block to populate + * @param target Target position in steps units + * @param target_float Target position in native mm + * @param cart_dist_mm The pre-calculated move lengths for all axes, in mm + * @param fr_mm_s (target) speed of the move + * @param extruder target extruder + * @param hints parameters to aid planner calculations * - * Returns true if movement is acceptable, false otherwise + * @return true if movement is acceptable, false otherwise */ -bool Planner::_populate_block(block_t * const block, bool split_move, +bool Planner::_populate_block( + block_t * const block, const abce_long_t &target OPTARG(HAS_POSITION_FLOAT, const xyze_pos_t &target_float) OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm) - , feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters/*=0.0*/ + , feedRate_t fr_mm_s, const uint8_t extruder, const PlannerHints &hints ) { int32_t LOGICAL_AXIS_LIST( de = target.e - position.e, @@ -1905,7 +1935,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, #if ENABLED(MIXING_EXTRUDER) bool ignore_e = false; float collector[MIXING_STEPPERS]; - mixer.refresh_collector(1.0, mixer.get_current_vtool(), collector); + mixer.refresh_collector(1.0f, mixer.get_current_vtool(), collector); MIXER_STEPPER_LOOP(e) if (e_steps * collector[e] > max_e_steps) { ignore_e = true; break; } #else @@ -1978,16 +2008,39 @@ bool Planner::_populate_block(block_t * const block, bool split_move, #endif // Clear all flags, including the "busy" bit - block->flag = 0x00; + block->flag.clear(); // Set direction bits block->direction_bits = dm; - // Update block laser power - #if ENABLED(LASER_POWER_INLINE) - laser_inline.status.isPlanned = true; - block->laser.status = laser_inline.status; - block->laser.power = laser_inline.power; + /** + * Update block laser power + * For standard mode get the cutter.power value for processing, since it's + * only set by apply_power(). + */ + #if HAS_CUTTER + switch (cutter.cutter_mode) { + default: break; + + case CUTTER_MODE_STANDARD: block->cutter_power = cutter.power; break; + + #if ENABLED(LASER_FEATURE) + /** + * For inline mode get the laser_inline variables, including power and status. + * Dynamic mode only needs to update if the feedrate has changed, since it's + * calculated from the current feedrate and power level. + */ + case CUTTER_MODE_CONTINUOUS: + block->laser.power = laser_inline.power; + block->laser.status = laser_inline.status; + break; + + case CUTTER_MODE_DYNAMIC: + if (cutter.laser_feedrate_changed()) // Only process changes in rate + block->laser.power = laser_inline.power = cutter.calc_dynamic_power(); + break; + #endif + } #endif // Number of steps for each axis @@ -2049,9 +2102,9 @@ bool Planner::_populate_block(block_t * const block, bool split_move, #endif #elif ENABLED(MARKFORGED_XY) steps_dist_mm.a = (da - db) * mm_per_step[A_AXIS]; - steps_dist_mm.b = db * mm_per_step[B_AXIS]; + steps_dist_mm.b = db * mm_per_step[B_AXIS]; #elif ENABLED(MARKFORGED_YX) - steps_dist_mm.a = da * mm_per_step[A_AXIS]; + steps_dist_mm.a = da * mm_per_step[A_AXIS]; steps_dist_mm.b = (db - da) * mm_per_step[B_AXIS]; #else XYZ_CODE( @@ -2093,25 +2146,16 @@ bool Planner::_populate_block(block_t * const block, bool split_move, block->millimeters = TERN0(HAS_EXTRUDERS, ABS(steps_dist_mm.e)); } else { - if (millimeters) - block->millimeters = millimeters; + if (hints.millimeters) + block->millimeters = hints.millimeters; else { /** - * Distance for interpretation of feedrate in accordance with LinuxCNC (the successor of - * NIST RS274NGC interpreter - version 3) and its default CANON_XYZ feed reference mode. - * - * Assume: - * - X, Y, Z are the primary linear axes; - * - U, V, W are secondary linear axes; - * - A, B, C are rotational axes. - * - * Then: - * - dX, dY, dZ are the displacements of the primary linear axes; - * - dU, dV, dW are the displacements of linear axes; - * - dA, dB, dC are the displacements of rotational axes. - * - * The time it takes to execute move command with feedrate F is t = D/F, - * where D is the total distance, calculated as follows: + * Distance for interpretation of feedrate in accordance with LinuxCNC (the successor of NIST + * RS274NGC interpreter - version 3) and its default CANON_XYZ feed reference mode. + * Assume that X, Y, Z are the primary linear axes and U, V, W are secondary linear axes and A, B, C are + * rotational axes. Then dX, dY, dZ are the displacements of the primary linear axes and dU, dV, dW are the displacements of linear axes and + * dA, dB, dC are the displacements of rotational axes. + * The time it takes to execute move command with feedrate F is t = D/F, where D is the total distance, calculated as follows: * D^2 = dX^2 + dY^2 + dZ^2 * if D^2 == 0 (none of XYZ move but any secondary linear axes move, whether other axes are moved or not): * D^2 = dU^2 + dV^2 + dW^2 @@ -2120,9 +2164,8 @@ bool Planner::_populate_block(block_t * const block, bool split_move, */ float distance_sqr = ( #if ENABLED(ARTICULATED_ROBOT_ARM) - // For articulated robots, interpreting feedrate like LinuxCNC would require inverse kinematics. As a workaround, - // assume that motors sit on a mutually-orthogonal axes and we can think of distance as magnitude of an n-vector - // in an n-dimensional Euclidian space. + // For articulated robots, interpreting feedrate like LinuxCNC would require inverse kinematics. As a workaround, pretend that motors sit on n mutually orthogonal + // axes and assume that we could think of distance as magnitude of an n-vector in an n-dimensional Euclidian space. NUM_AXIS_GANG( sq(steps_dist_mm.x), + sq(steps_dist_mm.y), + sq(steps_dist_mm.z), + sq(steps_dist_mm.i), + sq(steps_dist_mm.j), + sq(steps_dist_mm.k), @@ -2142,14 +2185,14 @@ bool Planner::_populate_block(block_t * const block, bool split_move, #elif CORE_IS_YZ XYZ_GANG(sq(steps_dist_mm.x), + sq(steps_dist_mm.head.y), + sq(steps_dist_mm.head.z)) #else - XYZ_GANG(sq(steps_dist_mm.x), + sq(steps_dist_mm.y), + sq(steps_dist_mm.z)) + XYZ_GANG(sq(steps_dist_mm.x), + sq(steps_dist_mm.y), + sq(steps_dist_mm.z)) #endif ); #if SECONDARY_LINEAR_AXES >= 1 && NONE(FOAMCUTTER_XYUV, ARTICULATED_ROBOT_ARM) - if (NEAR_ZERO(distance_sqr)) { + if (UNEAR_ZERO(distance_sqr)) { // Move does not involve any primary linear axes (xyz) but might involve secondary linear axes - distance_sqr = (0.0 + distance_sqr = (0.0f SECONDARY_AXIS_GANG( IF_DISABLED(AXIS4_ROTATES, + sq(steps_dist_mm.i)), IF_DISABLED(AXIS5_ROTATES, + sq(steps_dist_mm.j)), @@ -2163,7 +2206,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, #endif #if HAS_ROTATIONAL_AXES && NONE(FOAMCUTTER_XYUV, ARTICULATED_ROBOT_ARM) - if (NEAR_ZERO(distance_sqr)) { + if (UNEAR_ZERO(distance_sqr)) { // Move involves only rotational axes. Calculate angular distance in accordance with LinuxCNC TERN_(INCH_MODE_SUPPORT, cartesian_move = false); distance_sqr = ROTATIONAL_AXIS_GANG(sq(steps_dist_mm.i), + sq(steps_dist_mm.j), + sq(steps_dist_mm.k), + sq(steps_dist_mm.u), + sq(steps_dist_mm.v), + sq(steps_dist_mm.w)); @@ -2175,9 +2218,9 @@ bool Planner::_populate_block(block_t * const block, bool split_move, /** * At this point at least one of the axes has more steps than - * MIN_STEPS_PER_SEGMENT, ensuring the segment won't get dropped - * as zero-length. It's important to not apply corrections to blocks - * that would get dropped! + * MIN_STEPS_PER_SEGMENT, ensuring the segment won't get dropped as + * zero-length. It's important to not apply corrections + * to blocks that would get dropped! * * A correction function is permitted to add steps to an axis, it * should *never* remove steps! @@ -2198,7 +2241,6 @@ bool Planner::_populate_block(block_t * const block, bool split_move, TERN_(MIXING_EXTRUDER, mixer.populate_block(block->b_color)); - TERN_(HAS_CUTTER, block->cutter_power = cutter.power); #if HAS_FAN FANS_LOOP(i) block->fan_speed[i] = thermalManager.fan_speed[i]; @@ -2353,7 +2395,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, if (was_enabled) stepper.wake_up(); #endif - block->nominal_speed_sqr = sq(block->millimeters * inverse_secs); // (mm/sec)^2 Always > 0 + block->nominal_speed = block->millimeters * inverse_secs; // (mm/sec) Always > 0 block->nominal_rate = CEIL(block->step_event_count * inverse_secs); // (step/sec) Always > 0 #if ENABLED(FILAMENT_WIDTH_SENSOR) @@ -2449,19 +2491,21 @@ bool Planner::_populate_block(block_t * const block, bool split_move, if (speed_factor < 1.0f) { current_speed *= speed_factor; block->nominal_rate *= speed_factor; - block->nominal_speed_sqr = block->nominal_speed_sqr * sq(speed_factor); + block->nominal_speed *= speed_factor; } // Compute and limit the acceleration rate for the trapezoid generator. const float steps_per_mm = block->step_event_count * inverse_millimeters; uint32_t accel; + #if ENABLED(LIN_ADVANCE) + bool use_advance_lead = false; + #endif if (NUM_AXIS_GANG( !block->steps.a, && !block->steps.b, && !block->steps.c, && !block->steps.i, && !block->steps.j, && !block->steps.k, && !block->steps.u, && !block->steps.v, && !block->steps.w) ) { // Is this a retract / recover move? accel = CEIL(settings.retract_acceleration * steps_per_mm); // Convert to: acceleration steps/sec^2 - TERN_(LIN_ADVANCE, block->use_advance_lead = false); // No linear advance for simple retract/recover } else { #define LIMIT_ACCEL_LONG(AXIS,INDX) do{ \ @@ -2488,33 +2532,29 @@ bool Planner::_populate_block(block_t * const block, bool split_move, /** * Use LIN_ADVANCE for blocks if all these are true: * - * esteps : This is a print move, because we checked for A, B, C steps before. + * esteps : This is a print move, because we checked for A, B, C steps before. * - * extruder_advance_K[active_extruder] : There is an advance factor set for this extruder. + * extruder_advance_K[extruder] : There is an advance factor set for this extruder. * - * de > 0 : Extruder is running forward (e.g., for "Wipe while retracting" (Slic3r) or "Combing" (Cura) moves) + * de > 0 : Extruder is running forward (e.g., for "Wipe while retracting" (Slic3r) or "Combing" (Cura) moves) */ - block->use_advance_lead = esteps - && extruder_advance_K[active_extruder] - && de > 0; - - if (block->use_advance_lead) { - block->e_D_ratio = (target_float.e - position_float.e) / - #if IS_KINEMATIC - block->millimeters - #else + use_advance_lead = esteps && extruder_advance_K[extruder] && de > 0; + + if (use_advance_lead) { + float e_D_ratio = (target_float.e - position_float.e) / + TERN(IS_KINEMATIC, block->millimeters, SQRT(sq(target_float.x - position_float.x) + sq(target_float.y - position_float.y) + sq(target_float.z - position_float.z)) - #endif - ; + ); // Check for unusual high e_D ratio to detect if a retract move was combined with the last print move due to min. steps per segment. Never execute this with advance! // This assumes no one will use a retract length of 0mm < retr_length < ~0.2mm and no one will print 100mm wide lines using 3mm filament or 35mm wide lines using 1.75mm filament. - if (block->e_D_ratio > 3.0f) - block->use_advance_lead = false; + if (e_D_ratio > 3.0f) + use_advance_lead = false; else { - const uint32_t max_accel_steps_per_s2 = MAX_E_JERK(extruder) / (extruder_advance_K[active_extruder] * block->e_D_ratio) * steps_per_mm; + // Scale E acceleration so that it will be possible to jump to the advance speed. + const uint32_t max_accel_steps_per_s2 = MAX_E_JERK(extruder) / (extruder_advance_K[extruder] * e_D_ratio) * steps_per_mm; if (TERN0(LA_DEBUG, accel > max_accel_steps_per_s2)) SERIAL_ECHOLNPGM("Acceleration limited."); NOMORE(accel, max_accel_steps_per_s2); @@ -2526,29 +2566,17 @@ bool Planner::_populate_block(block_t * const block, bool split_move, if (block->step_event_count <= acceleration_long_cutoff) { LOGICAL_AXIS_CODE( LIMIT_ACCEL_LONG(E_AXIS, E_INDEX_N(extruder)), - LIMIT_ACCEL_LONG(A_AXIS, 0), - LIMIT_ACCEL_LONG(B_AXIS, 0), - LIMIT_ACCEL_LONG(C_AXIS, 0), - LIMIT_ACCEL_LONG(I_AXIS, 0), - LIMIT_ACCEL_LONG(J_AXIS, 0), - LIMIT_ACCEL_LONG(K_AXIS, 0), - LIMIT_ACCEL_LONG(U_AXIS, 0), - LIMIT_ACCEL_LONG(V_AXIS, 0), - LIMIT_ACCEL_LONG(W_AXIS, 0) + LIMIT_ACCEL_LONG(A_AXIS, 0), LIMIT_ACCEL_LONG(B_AXIS, 0), LIMIT_ACCEL_LONG(C_AXIS, 0), + LIMIT_ACCEL_LONG(I_AXIS, 0), LIMIT_ACCEL_LONG(J_AXIS, 0), LIMIT_ACCEL_LONG(K_AXIS, 0), + LIMIT_ACCEL_LONG(U_AXIS, 0), LIMIT_ACCEL_LONG(V_AXIS, 0), LIMIT_ACCEL_LONG(W_AXIS, 0) ); } else { LOGICAL_AXIS_CODE( LIMIT_ACCEL_FLOAT(E_AXIS, E_INDEX_N(extruder)), - LIMIT_ACCEL_FLOAT(A_AXIS, 0), - LIMIT_ACCEL_FLOAT(B_AXIS, 0), - LIMIT_ACCEL_FLOAT(C_AXIS, 0), - LIMIT_ACCEL_FLOAT(I_AXIS, 0), - LIMIT_ACCEL_FLOAT(J_AXIS, 0), - LIMIT_ACCEL_FLOAT(K_AXIS, 0), - LIMIT_ACCEL_FLOAT(U_AXIS, 0), - LIMIT_ACCEL_FLOAT(V_AXIS, 0), - LIMIT_ACCEL_FLOAT(W_AXIS, 0) + LIMIT_ACCEL_FLOAT(A_AXIS, 0), LIMIT_ACCEL_FLOAT(B_AXIS, 0), LIMIT_ACCEL_FLOAT(C_AXIS, 0), + LIMIT_ACCEL_FLOAT(I_AXIS, 0), LIMIT_ACCEL_FLOAT(J_AXIS, 0), LIMIT_ACCEL_FLOAT(K_AXIS, 0), + LIMIT_ACCEL_FLOAT(U_AXIS, 0), LIMIT_ACCEL_FLOAT(V_AXIS, 0), LIMIT_ACCEL_FLOAT(W_AXIS, 0) ); } } @@ -2558,13 +2586,21 @@ bool Planner::_populate_block(block_t * const block, bool split_move, block->acceleration_rate = (uint32_t)(accel * (float(1UL << 24) / (STEPPER_TIMER_RATE))); #endif #if ENABLED(LIN_ADVANCE) - if (block->use_advance_lead) { - block->advance_speed = (STEPPER_TIMER_RATE) / (extruder_advance_K[active_extruder] * block->e_D_ratio * block->acceleration * settings.axis_steps_per_mm[E_AXIS_N(extruder)]); + block->la_advance_rate = 0; + block->la_scaling = 0; + + if (use_advance_lead) { + // the Bresenham algorithm will convert this step rate into extruder steps + block->la_advance_rate = extruder_advance_K[extruder] * block->acceleration_steps_per_s2; + + // reduce LA ISR frequency by calling it only often enough to ensure that there will + // never be more than four extruder steps per call + for (uint32_t dividend = block->steps.e << 1; dividend <= (block->step_event_count >> 2); dividend <<= 1) + block->la_scaling++; + #if ENABLED(LA_DEBUG) - if (extruder_advance_K[active_extruder] * block->e_D_ratio * block->acceleration * 2 < SQRT(block->nominal_speed_sqr) * block->e_D_ratio) - SERIAL_ECHOLNPGM("More than 2 steps per eISR loop executed."); - if (block->advance_speed < 200) - SERIAL_ECHOLNPGM("eISR running at > 10kHz."); + if (block->la_advance_rate >> block->la_scaling > 10000) + SERIAL_ECHOLNPGM("eISR running at > 10kHz: ", block->la_advance_rate); #endif } #endif @@ -2613,7 +2649,10 @@ bool Planner::_populate_block(block_t * const block, bool split_move, #if HAS_DIST_MM_ARG cart_dist_mm #else - LOGICAL_AXIS_ARRAY(steps_dist_mm.e, steps_dist_mm.x, steps_dist_mm.y, steps_dist_mm.z, steps_dist_mm.i, steps_dist_mm.j, steps_dist_mm.k, steps_dist_mm.u, steps_dist_mm.v, steps_dist_mm.w) + LOGICAL_AXIS_ARRAY(steps_dist_mm.e, + steps_dist_mm.x, steps_dist_mm.y, steps_dist_mm.z, + steps_dist_mm.i, steps_dist_mm.j, steps_dist_mm.k, + steps_dist_mm.u, steps_dist_mm.v, steps_dist_mm.w) #endif ; @@ -2629,12 +2668,12 @@ bool Planner::_populate_block(block_t * const block, bool split_move, unit_vec *= inverse_millimeters; // Use pre-calculated (1 / SQRT(x^2 + y^2 + z^2)) // Skip first block or when previous_nominal_speed is used as a flag for homing and offset cycles. - if (moves_queued && !UNEAR_ZERO(previous_nominal_speed_sqr)) { + if (moves_queued && !UNEAR_ZERO(previous_nominal_speed)) { // Compute cosine of angle between previous and current path. (prev_unit_vec is negative) // NOTE: Max junction velocity is computed without sin() or acos() by trig half angle identity. float junction_cos_theta = LOGICAL_AXIS_GANG( + (-prev_unit_vec.e * unit_vec.e), - (-prev_unit_vec.x * unit_vec.x), + + (-prev_unit_vec.x * unit_vec.x), + (-prev_unit_vec.y * unit_vec.y), + (-prev_unit_vec.z * unit_vec.z), + (-prev_unit_vec.i * unit_vec.i), @@ -2651,108 +2690,114 @@ bool Planner::_populate_block(block_t * const block, bool split_move, vmax_junction_sqr = sq(float(MINIMUM_PLANNER_SPEED)); } else { - NOLESS(junction_cos_theta, -0.999999f); // Check for numerical round-off to avoid divide by zero. - // Convert delta vector to unit vector xyze_float_t junction_unit_vec = unit_vec - prev_unit_vec; normalize_junction_vector(junction_unit_vec); - const float junction_acceleration = limit_value_by_axis_maximum(block->acceleration, junction_unit_vec), - sin_theta_d2 = SQRT(0.5f * (1.0f - junction_cos_theta)); // Trig half angle identity. Always positive. - - vmax_junction_sqr = junction_acceleration * junction_deviation_mm * sin_theta_d2 / (1.0f - sin_theta_d2); - - #if ENABLED(JD_HANDLE_SMALL_SEGMENTS) - - // For small moves with >135° junction (octagon) find speed for approximate arc - if (block->millimeters < 1 && junction_cos_theta < -0.7071067812f) { - - #if ENABLED(JD_USE_MATH_ACOS) - - #error "TODO: Inline maths with the MCU / FPU." - - #elif ENABLED(JD_USE_LOOKUP_TABLE) - - // Fast acos approximation (max. error +-0.01 rads) - // Based on LUT table and linear interpolation - - /** - * // Generate the JD Lookup Table - * constexpr float c = 1.00751495f; // Correction factor to center error around 0 - * for (int i = 0; i < jd_lut_count - 1; ++i) { - * const float x0 = (sq(i) - 1) / sq(i), - * y0 = acos(x0) * (i == 0 ? 1 : c), - * x1 = i < jd_lut_count - 1 ? 0.5 * x0 + 0.5 : 0.999999f, - * y1 = acos(x1) * (i < jd_lut_count - 1 ? c : 1); - * jd_lut_k[i] = (y0 - y1) / (x0 - x1); - * jd_lut_b[i] = (y1 * x0 - y0 * x1) / (x0 - x1); - * } - * - * // Compute correction factor (Set c to 1.0f first!) - * float min = INFINITY, max = -min; - * for (float t = 0; t <= 1; t += 0.0003f) { - * const float e = acos(t) / approx(t); - * if (isfinite(e)) { - * if (e < min) min = e; - * if (e > max) max = e; - * } - * } - * fprintf(stderr, "%.9gf, ", (min + max) / 2); - */ - static constexpr int16_t jd_lut_count = 16; - static constexpr uint16_t jd_lut_tll = _BV(jd_lut_count - 1); - static constexpr int16_t jd_lut_tll0 = __builtin_clz(jd_lut_tll) + 1; // i.e., 16 - jd_lut_count + 1 - static constexpr float jd_lut_k[jd_lut_count] PROGMEM = { - -1.03145837f, -1.30760646f, -1.75205851f, -2.41705704f, - -3.37769222f, -4.74888992f, -6.69649887f, -9.45661736f, - -13.3640480f, -18.8928222f, -26.7136841f, -37.7754593f, - -53.4201813f, -75.5458374f, -106.836761f, -218.532821f }; - static constexpr float jd_lut_b[jd_lut_count] PROGMEM = { - 1.57079637f, 1.70887053f, 2.04220939f, 2.62408352f, - 3.52467871f, 4.85302639f, 6.77020454f, 9.50875854f, - 13.4009285f, 18.9188995f, 26.7321243f, 37.7885055f, - 53.4293975f, 75.5523529f, 106.841369f, 218.534011f }; - - const float neg = junction_cos_theta < 0 ? -1 : 1, - t = neg * junction_cos_theta; - - const int16_t idx = (t < 0.00000003f) ? 0 : __builtin_clz(uint16_t((1.0f - t) * jd_lut_tll)) - jd_lut_tll0; - - float junction_theta = t * pgm_read_float(&jd_lut_k[idx]) + pgm_read_float(&jd_lut_b[idx]); - if (neg > 0) junction_theta = RADIANS(180) - junction_theta; // acos(-t) - - #else - - // Fast acos(-t) approximation (max. error +-0.033rad = 1.89°) - // Based on MinMax polynomial published by W. Randolph Franklin, see - // https://wrf.ecse.rpi.edu/Research/Short_Notes/arcsin/onlyelem.html - // acos( t) = pi / 2 - asin(x) - // acos(-t) = pi - acos(t) ... pi / 2 + asin(x) - - const float neg = junction_cos_theta < 0 ? -1 : 1, - t = neg * junction_cos_theta, - asinx = 0.032843707f - + t * (-1.451838349f - + t * ( 29.66153956f - + t * (-131.1123477f - + t * ( 262.8130562f - + t * (-242.7199627f - + t * ( 84.31466202f ) ))))), - junction_theta = RADIANS(90) + neg * asinx; // acos(-t) - - // NOTE: junction_theta bottoms out at 0.033 which avoids divide by 0. - - #endif - - const float limit_sqr = (block->millimeters * junction_acceleration) / junction_theta; - NOMORE(vmax_junction_sqr, limit_sqr); - } + const float junction_acceleration = limit_value_by_axis_maximum(block->acceleration, junction_unit_vec); - #endif // JD_HANDLE_SMALL_SEGMENTS + if (TERN0(HINTS_CURVE_RADIUS, hints.curve_radius)) { + TERN_(HINTS_CURVE_RADIUS, vmax_junction_sqr = junction_acceleration * hints.curve_radius); + } + else { + NOLESS(junction_cos_theta, -0.999999f); // Check for numerical round-off to avoid divide by zero. + + const float sin_theta_d2 = SQRT(0.5f * (1.0f - junction_cos_theta)); // Trig half angle identity. Always positive. + + vmax_junction_sqr = junction_acceleration * junction_deviation_mm * sin_theta_d2 / (1.0f - sin_theta_d2); + + #if ENABLED(JD_HANDLE_SMALL_SEGMENTS) + + // For small moves with >135° junction (octagon) find speed for approximate arc + if (block->millimeters < 1 && junction_cos_theta < -0.7071067812f) { + + #if ENABLED(JD_USE_MATH_ACOS) + + #error "TODO: Inline maths with the MCU / FPU." + + #elif ENABLED(JD_USE_LOOKUP_TABLE) + + // Fast acos approximation (max. error +-0.01 rads) + // Based on LUT table and linear interpolation + + /** + * // Generate the JD Lookup Table + * constexpr float c = 1.00751495f; // Correction factor to center error around 0 + * for (int i = 0; i < jd_lut_count - 1; ++i) { + * const float x0 = (sq(i) - 1) / sq(i), + * y0 = acos(x0) * (i == 0 ? 1 : c), + * x1 = i < jd_lut_count - 1 ? 0.5 * x0 + 0.5 : 0.999999f, + * y1 = acos(x1) * (i < jd_lut_count - 1 ? c : 1); + * jd_lut_k[i] = (y0 - y1) / (x0 - x1); + * jd_lut_b[i] = (y1 * x0 - y0 * x1) / (x0 - x1); + * } + * + * // Compute correction factor (Set c to 1.0f first!) + * float min = INFINITY, max = -min; + * for (float t = 0; t <= 1; t += 0.0003f) { + * const float e = acos(t) / approx(t); + * if (isfinite(e)) { + * if (e < min) min = e; + * if (e > max) max = e; + * } + * } + * fprintf(stderr, "%.9gf, ", (min + max) / 2); + */ + static constexpr int16_t jd_lut_count = 16; + static constexpr uint16_t jd_lut_tll = _BV(jd_lut_count - 1); + static constexpr int16_t jd_lut_tll0 = __builtin_clz(jd_lut_tll) + 1; // i.e., 16 - jd_lut_count + 1 + static constexpr float jd_lut_k[jd_lut_count] PROGMEM = { + -1.03145837f, -1.30760646f, -1.75205851f, -2.41705704f, + -3.37769222f, -4.74888992f, -6.69649887f, -9.45661736f, + -13.3640480f, -18.8928222f, -26.7136841f, -37.7754593f, + -53.4201813f, -75.5458374f, -106.836761f, -218.532821f }; + static constexpr float jd_lut_b[jd_lut_count] PROGMEM = { + 1.57079637f, 1.70887053f, 2.04220939f, 2.62408352f, + 3.52467871f, 4.85302639f, 6.77020454f, 9.50875854f, + 13.4009285f, 18.9188995f, 26.7321243f, 37.7885055f, + 53.4293975f, 75.5523529f, 106.841369f, 218.534011f }; + + const float neg = junction_cos_theta < 0 ? -1 : 1, + t = neg * junction_cos_theta; + + const int16_t idx = (t < 0.00000003f) ? 0 : __builtin_clz(uint16_t((1.0f - t) * jd_lut_tll)) - jd_lut_tll0; + + float junction_theta = t * pgm_read_float(&jd_lut_k[idx]) + pgm_read_float(&jd_lut_b[idx]); + if (neg > 0) junction_theta = RADIANS(180) - junction_theta; // acos(-t) + + #else + + // Fast acos(-t) approximation (max. error +-0.033rad = 1.89°) + // Based on MinMax polynomial published by W. Randolph Franklin, see + // https://wrf.ecse.rpi.edu/Research/Short_Notes/arcsin/onlyelem.html + // acos( t) = pi / 2 - asin(x) + // acos(-t) = pi - acos(t) ... pi / 2 + asin(x) + + const float neg = junction_cos_theta < 0 ? -1 : 1, + t = neg * junction_cos_theta, + asinx = 0.032843707f + + t * (-1.451838349f + + t * ( 29.66153956f + + t * (-131.1123477f + + t * ( 262.8130562f + + t * (-242.7199627f + + t * ( 84.31466202f ) ))))), + junction_theta = RADIANS(90) + neg * asinx; // acos(-t) + + // NOTE: junction_theta bottoms out at 0.033 which avoids divide by 0. + + #endif + + const float limit_sqr = (block->millimeters * junction_acceleration) / junction_theta; + NOMORE(vmax_junction_sqr, limit_sqr); + } + + #endif // JD_HANDLE_SMALL_SEGMENTS + } } // Get the lowest speed - vmax_junction_sqr = _MIN(vmax_junction_sqr, block->nominal_speed_sqr, previous_nominal_speed_sqr); + vmax_junction_sqr = _MIN(vmax_junction_sqr, sq(block->nominal_speed), sq(previous_nominal_speed)); } else // Init entry speed to zero. Assume it starts from rest. Planner will correct this later. vmax_junction_sqr = 0; @@ -2761,27 +2806,17 @@ bool Planner::_populate_block(block_t * const block, bool split_move, #endif - #ifdef USE_CACHED_SQRT - #define CACHED_SQRT(N, V) \ - static float saved_V, N; \ - if (V != saved_V) { N = SQRT(V); saved_V = V; } - #else - #define CACHED_SQRT(N, V) const float N = SQRT(V) - #endif - #if HAS_CLASSIC_JERK /** * Adapted from Průša MKS firmware * https://github.com/prusa3d/Prusa-Firmware */ - CACHED_SQRT(nominal_speed, block->nominal_speed_sqr); - // Exit speed limited by a jerk to full halt of a previous last segment static float previous_safe_speed; // Start with a safe speed (from which the machine may halt to stop immediately). - float safe_speed = nominal_speed; + float safe_speed = block->nominal_speed; #ifndef TRAVEL_EXTRA_XYJERK #define TRAVEL_EXTRA_XYJERK 0 @@ -2794,7 +2829,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, maxj = (max_jerk[i] + (i == X_AXIS || i == Y_AXIS ? extra_xyjerk : 0.0f)); // mj : The max jerk setting for this axis if (jerk > maxj) { // cs > mj : New current speed too fast? if (limited) { // limited already? - const float mjerk = nominal_speed * maxj; // ns*mj + const float mjerk = block->nominal_speed * maxj; // ns*mj if (jerk * safe_speed > mjerk) safe_speed = mjerk / jerk; // ns*mj/cs } else { @@ -2805,7 +2840,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, } float vmax_junction; - if (moves_queued && !UNEAR_ZERO(previous_nominal_speed_sqr)) { + if (moves_queued && !UNEAR_ZERO(previous_nominal_speed)) { // Estimate a maximum velocity allowed at a joint of two successive segments. // If this maximum velocity allowed is lower than the minimum of the entry / exit safe velocities, // then the machine is not coasting anymore and the safe entry / exit velocities shall be used. @@ -2816,11 +2851,9 @@ bool Planner::_populate_block(block_t * const block, bool split_move, // The junction velocity will be shared between successive segments. Limit the junction velocity to their minimum. // Pick the smaller of the nominal speeds. Higher speed shall not be achieved at the junction during coasting. - CACHED_SQRT(previous_nominal_speed, previous_nominal_speed_sqr); - float smaller_speed_factor = 1.0f; - if (nominal_speed < previous_nominal_speed) { - vmax_junction = nominal_speed; + if (block->nominal_speed < previous_nominal_speed) { + vmax_junction = block->nominal_speed; smaller_speed_factor = vmax_junction / previous_nominal_speed; } else @@ -2876,9 +2909,8 @@ bool Planner::_populate_block(block_t * const block, bool split_move, // Initialize block entry speed. Compute based on deceleration to user-defined MINIMUM_PLANNER_SPEED. const float v_allowable_sqr = max_allowable_speed_sqr(-block->acceleration, sq(float(MINIMUM_PLANNER_SPEED)), block->millimeters); - // If we are trying to add a split block, start with the - // max. allowed speed to avoid an interrupted first move. - block->entry_speed_sqr = !split_move ? sq(float(MINIMUM_PLANNER_SPEED)) : _MIN(vmax_junction_sqr, v_allowable_sqr); + // Start with the minimum allowed speed + block->entry_speed_sqr = sq(float(MINIMUM_PLANNER_SPEED)); // Initialize planner efficiency flags // Set flag if block will always reach maximum junction speed regardless of entry/exit speeds. @@ -2888,11 +2920,11 @@ bool Planner::_populate_block(block_t * const block, bool split_move, // block nominal speed limits both the current and next maximum junction speeds. Hence, in both // the reverse and forward planners, the corresponding block junction speed will always be at the // the maximum junction speed and may always be ignored for any speed reduction checks. - block->flag |= block->nominal_speed_sqr <= v_allowable_sqr ? BLOCK_FLAG_RECALCULATE | BLOCK_FLAG_NOMINAL_LENGTH : BLOCK_FLAG_RECALCULATE; + block->flag.set_nominal(sq(block->nominal_speed) <= v_allowable_sqr); // Update previous path unit_vector and nominal speed previous_speed = current_speed; - previous_nominal_speed_sqr = block->nominal_speed_sqr; + previous_nominal_speed = block->nominal_speed; position = target; // Update the position @@ -2909,33 +2941,35 @@ bool Planner::_populate_block(block_t * const block, bool split_move, } // _populate_block() /** - * Planner::buffer_sync_block - * Add a block to the buffer that just updates the position, - * or in case of LASER_SYNCHRONOUS_M106_M107 the fan PWM + * @brief Add a block to the buffer that just updates the position + * Supports LASER_SYNCHRONOUS_M106_M107 and LASER_POWER_SYNC power sync block buffer queueing. + * + * @param sync_flag The sync flag to set, determining the type of sync the block will do */ -void Planner::buffer_sync_block(TERN_(LASER_SYNCHRONOUS_M106_M107, uint8_t sync_flag)) { - #if DISABLED(LASER_SYNCHRONOUS_M106_M107) - constexpr uint8_t sync_flag = BLOCK_FLAG_SYNC_POSITION; - #endif +void Planner::buffer_sync_block(const BlockFlagBit sync_flag/*=BLOCK_BIT_SYNC_POSITION*/) { // Wait for the next available block uint8_t next_buffer_head; block_t * const block = get_next_free_block(next_buffer_head); // Clear block - memset(block, 0, sizeof(block_t)); - - block->flag = sync_flag; + block->reset(); + block->flag.apply(sync_flag); block->position = position; #if ENABLED(BACKLASH_COMPENSATION) LOOP_NUM_AXES(axis) block->position[axis] += backlash.get_applied_steps((AxisEnum)axis); #endif - #if BOTH(HAS_FAN, LASER_SYNCHRONOUS_M106_M107) FANS_LOOP(i) block->fan_speed[i] = thermalManager.fan_speed[i]; #endif + /** + * M3-based power setting can be processed inline with a laser power sync block. + * During active moves cutter.power is processed immediately, otherwise on the next move. + */ + TERN_(LASER_POWER_SYNC, block->laser.power = cutter.power); + // If this is the first added movement, reload the delay, otherwise, cancel it. if (block_buffer_head == block_buffer_tail) { // If it was the first queued block, restart the 1st block delivery delay, to @@ -2952,22 +2986,24 @@ void Planner::buffer_sync_block(TERN_(LASER_SYNCHRONOUS_M106_M107, uint8_t sync_ } // buffer_sync_block() /** - * Planner::buffer_segment - * - * Add a new linear movement to the buffer in axis units. + * @brief Add a single linear movement * - * Leveling and kinematics should be applied ahead of calling this. + * @description Add a new linear movement to the buffer in axis units. + * Leveling and kinematics should be applied before calling this. * - * a,b,c,e - target positions in mm and/or degrees - * fr_mm_s - (target) speed of the move - * extruder - target extruder - * millimeters - the length of the movement, if known + * @param abce Target position in mm and/or degrees + * @param cart_dist_mm The pre-calculated move lengths for all axes, in mm + * @param fr_mm_s (target) speed of the move + * @param extruder optional target extruder (otherwise active_extruder) + * @param hints optional parameters to aid planner calculations * - * Return 'false' if no segment was queued due to cleaning, cold extrusion, full queue, etc. + * @return false if no segment was queued due to cleaning, cold extrusion, full queue, etc. */ bool Planner::buffer_segment(const abce_pos_t &abce OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm) - , const_feedRate_t fr_mm_s, const uint8_t extruder/*=active_extruder*/, const_float_t millimeters/*=0.0*/ + , const_feedRate_t fr_mm_s + , const uint8_t extruder/*=active_extruder*/ + , const PlannerHints &hints/*=PlannerHints()*/ ) { // If we are cleaning, do not accept queuing of movements @@ -3073,8 +3109,8 @@ bool Planner::buffer_segment(const abce_pos_t &abce if (!_buffer_steps(target OPTARG(HAS_POSITION_FLOAT, target_float) OPTARG(HAS_DIST_MM_ARG, cart_dist_mm) - , fr_mm_s, extruder, millimeters) - ) return false; + , fr_mm_s, extruder, hints + )) return false; stepper.wake_up(); return true; @@ -3087,12 +3123,12 @@ bool Planner::buffer_segment(const abce_pos_t &abce * * cart - target position in mm or degrees * fr_mm_s - (target) speed of the move (mm/s) - * extruder - target extruder - * millimeters - the length of the movement, if known - * inv_duration - the reciprocal if the duration of the movement, if known (kinematic only if feeedrate scaling is enabled) + * extruder - optional target extruder (otherwise active_extruder) + * hints - optional parameters to aid planner calculations */ -bool Planner::buffer_line(const xyze_pos_t &cart, const_feedRate_t fr_mm_s, const uint8_t extruder/*=active_extruder*/, const float millimeters/*=0.0*/ - OPTARG(SCARA_FEEDRATE_SCALING, const_float_t inv_duration/*=0.0*/) +bool Planner::buffer_line(const xyze_pos_t &cart, const_feedRate_t fr_mm_s + , const uint8_t extruder/*=active_extruder*/ + , const PlannerHints &hints/*=PlannerHints()*/ ) { xyze_pos_t machine = cart; TERN_(HAS_POSITION_MODIFIERS, apply_modifiers(machine)); @@ -3114,28 +3150,32 @@ bool Planner::buffer_line(const xyze_pos_t &cart, const_feedRate_t fr_mm_s, cons ); #endif - const float mm = millimeters ?: (cart_dist_mm.x || cart_dist_mm.y) ? cart_dist_mm.magnitude() : TERN0(HAS_Z_AXIS, ABS(cart_dist_mm.z)); - // Cartesian XYZ to kinematic ABC, stored in global 'delta' inverse_kinematics(machine); + PlannerHints ph = hints; + if (!hints.millimeters) + ph.millimeters = (cart_dist_mm.x || cart_dist_mm.y) + ? xyz_pos_t(cart_dist_mm).magnitude() + : TERN0(HAS_Z_AXIS, ABS(cart_dist_mm.z)); + #if ENABLED(SCARA_FEEDRATE_SCALING) - // For SCARA scale the feed rate from mm/s to degrees/s + // For SCARA scale the feedrate from mm/s to degrees/s // i.e., Complete the angular vector in the given time. - const float duration_recip = inv_duration ?: fr_mm_s / mm; + const float duration_recip = hints.inv_duration ?: fr_mm_s / ph.millimeters; const xyz_pos_t diff = delta - position_float; const feedRate_t feedrate = diff.magnitude() * duration_recip; #else const feedRate_t feedrate = fr_mm_s; #endif TERN_(HAS_EXTRUDERS, delta.e = machine.e); - if (buffer_segment(delta OPTARG(HAS_DIST_MM_ARG, cart_dist_mm), feedrate, extruder, mm)) { + if (buffer_segment(delta OPTARG(HAS_DIST_MM_ARG, cart_dist_mm), feedrate, extruder, ph)) { position_cart = cart; return true; } return false; #else - return buffer_segment(machine, fr_mm_s, extruder, millimeters); + return buffer_segment(machine, fr_mm_s, extruder, hints); #endif } // buffer_line() @@ -3150,7 +3190,7 @@ bool Planner::buffer_line(const xyze_pos_t &cart, const_feedRate_t fr_mm_s, cons uint8_t next_buffer_head; block_t * const block = get_next_free_block(next_buffer_head); - block->flag = BLOCK_FLAG_IS_PAGE; + block->flag.reset(BLOCK_BIT_PAGE); #if HAS_FAN FANS_LOOP(i) block->fan_speed[i] = thermalManager.fan_speed[i]; @@ -3223,9 +3263,9 @@ void Planner::set_machine_position_mm(const abce_pos_t &abce) { ); if (has_blocks_queued()) { - //previous_nominal_speed_sqr = 0.0; // Reset planner junction speeds. Assume start from rest. + //previous_nominal_speed = 0.0f; // Reset planner junction speeds. Assume start from rest. //previous_speed.reset(); - buffer_sync_block(); + buffer_sync_block(BLOCK_BIT_SYNC_POSITION); } else { #if ENABLED(BACKLASH_COMPENSATION) @@ -3266,7 +3306,7 @@ void Planner::set_position_mm(const xyze_pos_t &xyze) { TERN_(IS_KINEMATIC, TERN_(HAS_EXTRUDERS, position_cart.e = e)); if (has_blocks_queued()) - buffer_sync_block(); + buffer_sync_block(BLOCK_BIT_SYNC_POSITION); else stepper.set_axis_position(E_AXIS, position.e); } @@ -3274,7 +3314,7 @@ void Planner::set_position_mm(const xyze_pos_t &xyze) { #endif // Recalculate the steps/s^2 acceleration rates, based on the mm/s^2 -void Planner::reset_acceleration_rates() { +void Planner::refresh_acceleration_rates() { uint32_t highest_rate = 1; LOOP_DISTINCT_AXES(i) { max_acceleration_steps_per_s2[i] = settings.max_acceleration_mm_per_s2[i] * settings.axis_steps_per_mm[i]; @@ -3292,14 +3332,14 @@ void Planner::reset_acceleration_rates() { void Planner::refresh_positioning() { LOOP_DISTINCT_AXES(i) mm_per_step[i] = 1.0f / settings.axis_steps_per_mm[i]; set_position_mm(current_position); - reset_acceleration_rates(); + refresh_acceleration_rates(); } // Apply limits to a variable and give a warning if the value was out of range inline void limit_and_warn(float &val, const AxisEnum axis, PGM_P const setting_name, const xyze_float_t &max_limit) { const uint8_t lim_axis = TERN_(HAS_EXTRUDERS, axis > E_AXIS ? E_AXIS :) axis; const float before = val; - LIMIT(val, 0.1, max_limit[lim_axis]); + LIMIT(val, 0.1f, max_limit[lim_axis]); if (before != val) { SERIAL_CHAR(AXIS_CHAR(lim_axis)); SERIAL_ECHOPGM(" Max "); @@ -3311,7 +3351,7 @@ inline void limit_and_warn(float &val, const AxisEnum axis, PGM_P const setting_ /** * For the specified 'axis' set the Maximum Acceleration to the given value (mm/s^2) * The value may be limited with warning feedback, if configured. - * Calls reset_acceleration_rates to precalculate planner terms in steps. + * Calls refresh_acceleration_rates to precalculate planner terms in steps. * * This hard limit is applied as a block is being added to the planner queue. */ @@ -3329,7 +3369,7 @@ void Planner::set_max_acceleration(const AxisEnum axis, float inMaxAccelMMS2) { settings.max_acceleration_mm_per_s2[axis] = inMaxAccelMMS2; // Update steps per s2 to agree with the units per s2 (since they are used in the planner) - reset_acceleration_rates(); + refresh_acceleration_rates(); } /** diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index bef381b5c7..09afee7db1 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -70,9 +70,6 @@ #if ENABLED(DIRECT_STEPPING) #include "../feature/direct_stepping.h" - #define IS_PAGE(B) TEST(B->flag, BLOCK_BIT_IS_PAGE) -#else - #define IS_PAGE(B) false #endif #if ENABLED(EXTERNAL_CLOSED_LOOP_CONTROLLER) @@ -92,7 +89,10 @@ #define HAS_DIST_MM_ARG 1 #endif -enum BlockFlagBit : char { +/** + * Planner block flags as boolean bit fields + */ +enum BlockFlagBit { // Recalculate trapezoids on entry junction. For optimization. BLOCK_BIT_RECALCULATE, @@ -108,50 +108,72 @@ enum BlockFlagBit : char { BLOCK_BIT_SYNC_POSITION // Direct stepping page - #if ENABLED(DIRECT_STEPPING) - , BLOCK_BIT_IS_PAGE - #endif + OPTARG(DIRECT_STEPPING, BLOCK_BIT_PAGE) + // Sync the fan speeds from the block - #if ENABLED(LASER_SYNCHRONOUS_M106_M107) - , BLOCK_BIT_SYNC_FANS - #endif -}; + OPTARG(LASER_SYNCHRONOUS_M106_M107, BLOCK_BIT_SYNC_FANS) -enum BlockFlag : char { - BLOCK_FLAG_RECALCULATE = _BV(BLOCK_BIT_RECALCULATE) - , BLOCK_FLAG_NOMINAL_LENGTH = _BV(BLOCK_BIT_NOMINAL_LENGTH) - , BLOCK_FLAG_CONTINUED = _BV(BLOCK_BIT_CONTINUED) - , BLOCK_FLAG_SYNC_POSITION = _BV(BLOCK_BIT_SYNC_POSITION) - #if ENABLED(DIRECT_STEPPING) - , BLOCK_FLAG_IS_PAGE = _BV(BLOCK_BIT_IS_PAGE) - #endif - #if ENABLED(LASER_SYNCHRONOUS_M106_M107) - , BLOCK_FLAG_SYNC_FANS = _BV(BLOCK_BIT_SYNC_FANS) - #endif + // Sync laser power from a queued block + OPTARG(LASER_POWER_SYNC, BLOCK_BIT_LASER_PWR) }; -#define BLOCK_MASK_SYNC ( BLOCK_FLAG_SYNC_POSITION | TERN0(LASER_SYNCHRONOUS_M106_M107, BLOCK_FLAG_SYNC_FANS) ) +/** + * Planner block flags as boolean bit fields + */ +typedef struct { + union { + uint8_t bits; + + struct { + bool recalculate:1; + + bool nominal_length:1; + + bool continued:1; + + bool sync_position:1; + + #if ENABLED(DIRECT_STEPPING) + bool page:1; + #endif + + #if ENABLED(LASER_SYNCHRONOUS_M106_M107) + bool sync_fans:1; + #endif + + #if ENABLED(LASER_POWER_SYNC) + bool sync_laser_pwr:1; + #endif + }; + }; -#if ENABLED(LASER_POWER_INLINE) + void clear() volatile { bits = 0; } + void apply(const uint8_t f) volatile { bits |= f; } + void apply(const BlockFlagBit b) volatile { SBI(bits, b); } + void reset(const BlockFlagBit b) volatile { bits = _BV(b); } + void set_nominal(const bool n) volatile { recalculate = true; if (n) nominal_length = true; } + +} block_flags_t; + +#if ENABLED(LASER_FEATURE) typedef struct { - bool isPlanned:1; - bool isEnabled:1; + bool isEnabled:1; // Set to engage the inline laser power output. bool dir:1; - bool Reserved:6; + bool isPowered:1; // Set on any parsed G1, G2, G3, or G5 powered move, cleared on G0 and G28. + bool isSyncPower:1; // Set on a M3 sync based set laser power, used to determine active trap power + bool Reserved:4; } power_status_t; typedef struct { - power_status_t status; // See planner settings for meaning - uint8_t power; // Ditto; When in trapezoid mode this is nominal power - #if ENABLED(LASER_POWER_INLINE_TRAPEZOID) - uint8_t power_entry; // Entry power for the laser - #if DISABLED(LASER_POWER_INLINE_TRAPEZOID_CONT) - uint8_t power_exit; // Exit power for the laser - uint32_t entry_per, // Steps per power increment (to avoid floats in stepper calcs) - exit_per; // Steps per power decrement - #endif + power_status_t status; // See planner settings for meaning + uint8_t power; // Ditto; When in trapezoid mode this is nominal power + + #if ENABLED(LASER_POWER_TRAP) + float trap_ramp_active_pwr; // Laser power level during active trapezoid smoothing + float trap_ramp_entry_incr; // Acceleration per step laser power increment (trap entry) + float trap_ramp_exit_decr; // Deceleration per step laser power decrement (trap exit) #endif } block_laser_t; @@ -166,12 +188,18 @@ enum BlockFlag : char { * The "nominal" values are as-specified by G-code, and * may never actually be reached due to acceleration limits. */ -typedef struct block_t { +typedef struct PlannerBlock { + + volatile block_flags_t flag; // Block flags - volatile uint8_t flag; // Block flags (See BlockFlag enum above) - Modified by ISR and main thread! + volatile bool is_fan_sync() { return TERN0(LASER_SYNCHRONOUS_M106_M107, flag.sync_fans); } + volatile bool is_pwr_sync() { return TERN0(LASER_POWER_SYNC, flag.sync_laser_pwr); } + volatile bool is_sync() { return flag.sync_position || is_fan_sync() || is_pwr_sync(); } + volatile bool is_page() { return TERN0(DIRECT_STEPPING, flag.page); } + volatile bool is_move() { return !(is_sync() || is_page()); } // Fields used by the motion planner to manage acceleration - float nominal_speed_sqr, // The nominal speed for this block in (mm/sec)^2 + float nominal_speed, // The nominal speed for this block in (mm/sec) entry_speed_sqr, // Entry speed at previous-current junction in (mm/sec)^2 max_entry_speed_sqr, // Maximum allowable junction entry speed in (mm/sec)^2 millimeters, // The total travel of this block in mm @@ -211,11 +239,10 @@ typedef struct block_t { // Advance extrusion #if ENABLED(LIN_ADVANCE) - bool use_advance_lead; - uint16_t advance_speed, // STEP timer value for extruder speed offset ISR - max_adv_steps, // max. advance steps to get cruising speed pressure (not always nominal_speed!) - final_adv_steps; // advance steps due to exit speed - float e_D_ratio; + uint32_t la_advance_rate; // The rate at which steps are added whilst accelerating + uint8_t la_scaling; // Scale ISR frequency down and step frequency up by 2 ^ la_scaling + uint16_t max_adv_steps, // Max advance steps to get cruising speed pressure + final_adv_steps; // Advance steps for exit speed pressure #endif uint32_t nominal_rate, // The nominal step rate for this block in step_events/sec @@ -248,10 +275,12 @@ typedef struct block_t { xyze_pos_t start_position; #endif - #if ENABLED(LASER_POWER_INLINE) + #if ENABLED(LASER_FEATURE) block_laser_t laser; #endif + void reset() { memset((char*)this, 0, sizeof(*this)); } + } block_t; #if ANY(LIN_ADVANCE, SCARA_FEEDRATE_SCALING, GRADIENT_MIX, LCD_SHOW_E_TOTAL, POWER_LOSS_RECOVERY) @@ -260,7 +289,7 @@ typedef struct block_t { #define BLOCK_MOD(n) ((n)&(BLOCK_BUFFER_SIZE-1)) -#if ENABLED(LASER_POWER_INLINE) +#if ENABLED(LASER_FEATURE) typedef struct { /** * Laser status flags @@ -269,11 +298,10 @@ typedef struct block_t { /** * Laser power: 0 or 255 in case of PWM-less laser, * or the OCR (oscillator count register) value; - * * Using OCR instead of raw power, because it avoids * floating point operations during the move loop. */ - uint8_t power; + volatile uint8_t power; } laser_state_t; #endif @@ -322,6 +350,30 @@ typedef struct { typedef IF<(BLOCK_BUFFER_SIZE > 64), uint16_t, uint8_t>::type last_move_t; #endif +#if ENABLED(ARC_SUPPORT) + #define HINTS_CURVE_RADIUS + #define HINTS_SAFE_EXIT_SPEED +#endif + +struct PlannerHints { + float millimeters = 0.0; // Move Length, if known, else 0. + #if ENABLED(SCARA_FEEDRATE_SCALING) + float inv_duration = 0.0; // Reciprocal of the move duration, if known + #endif + #if ENABLED(HINTS_CURVE_RADIUS) + float curve_radius = 0.0; // Radius of curvature of the motion path - to calculate cornering speed + #else + static constexpr float curve_radius = 0.0; + #endif + #if ENABLED(HINTS_SAFE_EXIT_SPEED) + float safe_exit_speed_sqr = 0.0; // Square of the speed considered "safe" at the end of the segment + // i.e., at or below the exit speed of the segment that the planner + // would calculate if it knew the as-yet-unbuffered path + #endif + + PlannerHints(const_float_t mm=0.0f) : millimeters(mm) {} +}; + class Planner { public: @@ -375,7 +427,7 @@ class Planner { static planner_settings_t settings; - #if ENABLED(LASER_POWER_INLINE) + #if ENABLED(LASER_FEATURE) static laser_state_t laser_inline; #endif @@ -457,7 +509,7 @@ class Planner { /** * Nominal speed of previous path line segment (mm/s)^2 */ - static float previous_nominal_speed_sqr; + static float previous_nominal_speed; /** * Limit where 64bit math is necessary for acceleration calculation @@ -492,7 +544,7 @@ class Planner { */ // Recalculate steps/s^2 accelerations based on mm/s^2 settings - static void reset_acceleration_rates(); + static void refresh_acceleration_rates(); /** * Recalculate 'position' and 'mm_per_step'. @@ -725,42 +777,45 @@ class Planner { * target - target position in steps units * fr_mm_s - (target) speed of the move * extruder - target extruder - * millimeters - the length of the movement, if known + * hints - parameters to aid planner calculations * * Returns true if movement was buffered, false otherwise */ static bool _buffer_steps(const xyze_long_t &target OPTARG(HAS_POSITION_FLOAT, const xyze_pos_t &target_float) OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm) - , feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters=0.0 + , feedRate_t fr_mm_s, const uint8_t extruder, const PlannerHints &hints ); /** - * Planner::_populate_block - * - * Fills a new linear movement in the block (in terms of steps). + * @brief Populate a block in preparation for insertion + * @details Populate the fields of a new linear movement block + * that will be added to the queue and processed soon + * by the Stepper ISR. * - * target - target position in steps units - * fr_mm_s - (target) speed of the move - * extruder - target extruder - * millimeters - the length of the movement, if known + * @param block A block to populate + * @param target Target position in steps units + * @param target_float Target position in native mm + * @param cart_dist_mm The pre-calculated move lengths for all axes, in mm + * @param fr_mm_s (target) speed of the move + * @param extruder target extruder + * @param hints parameters to aid planner calculations * - * Returns true is movement is acceptable, false otherwise + * @return true if movement is acceptable, false otherwise */ - static bool _populate_block(block_t * const block, bool split_move, const xyze_long_t &target + static bool _populate_block(block_t * const block, const xyze_long_t &target OPTARG(HAS_POSITION_FLOAT, const xyze_pos_t &target_float) OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm) - , feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters=0.0 + , feedRate_t fr_mm_s, const uint8_t extruder, const PlannerHints &hints ); /** * Planner::buffer_sync_block - * Add a block to the buffer that just updates the position or in - * case of LASER_SYNCHRONOUS_M106_M107 the fan pwm + * Add a block to the buffer that just updates the position + * @param sync_flag sets a condition bit to process additional items + * such as sync fan pwm or sync M3/M4 laser power into a queued block */ - static void buffer_sync_block( - TERN_(LASER_SYNCHRONOUS_M106_M107, uint8_t sync_flag=BLOCK_FLAG_SYNC_POSITION) - ); + static void buffer_sync_block(const BlockFlagBit flag=BLOCK_BIT_SYNC_POSITION); #if IS_KINEMATIC private: @@ -778,12 +833,14 @@ class Planner { * * a,b,c,e - target positions in mm and/or degrees * fr_mm_s - (target) speed of the move - * extruder - target extruder - * millimeters - the length of the movement, if known + * extruder - optional target extruder (otherwise active_extruder) + * hints - optional parameters to aid planner calculations */ static bool buffer_segment(const abce_pos_t &abce OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm) - , const_feedRate_t fr_mm_s, const uint8_t extruder=active_extruder, const_float_t millimeters=0.0 + , const_feedRate_t fr_mm_s + , const uint8_t extruder=active_extruder + , const PlannerHints &hints=PlannerHints() ); public: @@ -795,12 +852,12 @@ class Planner { * * cart - target position in mm or degrees * fr_mm_s - (target) speed of the move (mm/s) - * extruder - target extruder - * millimeters - the length of the movement, if known - * inv_duration - the reciprocal if the duration of the movement, if known (kinematic only if feeedrate scaling is enabled) + * extruder - optional target extruder (otherwise active_extruder) + * hints - optional parameters to aid planner calculations */ - static bool buffer_line(const xyze_pos_t &cart, const_feedRate_t fr_mm_s, const uint8_t extruder=active_extruder, const float millimeters=0.0 - OPTARG(SCARA_FEEDRATE_SCALING, const_float_t inv_duration=0.0) + static bool buffer_line(const xyze_pos_t &cart, const_feedRate_t fr_mm_s + , const uint8_t extruder=active_extruder + , const PlannerHints &hints=PlannerHints() ); #if ENABLED(DIRECT_STEPPING) @@ -951,28 +1008,6 @@ class Planner { static constexpr uint8_t next_block_index(const uint8_t block_index) { return BLOCK_MOD(block_index + 1); } static constexpr uint8_t prev_block_index(const uint8_t block_index) { return BLOCK_MOD(block_index - 1); } - /** - * Calculate the distance (not time) it takes to accelerate - * from initial_rate to target_rate using the given acceleration: - */ - static float estimate_acceleration_distance(const_float_t initial_rate, const_float_t target_rate, const_float_t accel) { - if (accel == 0) return 0; // accel was 0, set acceleration distance to 0 - return (sq(target_rate) - sq(initial_rate)) / (accel * 2); - } - - /** - * Return the point at which you must start braking (at the rate of -'accel') if - * you start at 'initial_rate', accelerate (until reaching the point), and want to end at - * 'final_rate' after traveling 'distance'. - * - * This is used to compute the intersection point between acceleration and deceleration - * in cases where the "trapezoid" has no plateau (i.e., never reaches maximum speed) - */ - static float intersection_distance(const_float_t initial_rate, const_float_t final_rate, const_float_t accel, const_float_t distance) { - if (accel == 0) return 0; // accel was 0, set intersection distance to 0 - return (accel * 2 * distance - sq(initial_rate) + sq(final_rate)) / (accel * 4); - } - /** * Calculate the maximum allowable speed squared at this point, in order * to reach 'target_velocity_sqr' using 'acceleration' within a given @@ -982,7 +1017,7 @@ class Planner { return target_velocity_sqr - 2 * accel * distance; } - #if ENABLED(S_CURVE_ACCELERATION) + #if EITHER(S_CURVE_ACCELERATION, LIN_ADVANCE) /** * Calculate the speed reached given initial speed, acceleration and distance */ @@ -993,15 +1028,15 @@ class Planner { static void calculate_trapezoid_for_block(block_t * const block, const_float_t entry_factor, const_float_t exit_factor); - static void reverse_pass_kernel(block_t * const current, const block_t * const next); + static void reverse_pass_kernel(block_t * const current, const block_t * const next OPTARG(ARC_SUPPORT, const_float_t safe_exit_speed_sqr)); static void forward_pass_kernel(const block_t * const previous, block_t * const current, uint8_t block_index); - static void reverse_pass(); + static void reverse_pass(TERN_(ARC_SUPPORT, const_float_t safe_exit_speed_sqr)); static void forward_pass(); - static void recalculate_trapezoids(); + static void recalculate_trapezoids(TERN_(ARC_SUPPORT, const_float_t safe_exit_speed_sqr)); - static void recalculate(); + static void recalculate(TERN_(ARC_SUPPORT, const_float_t safe_exit_speed_sqr)); #if HAS_JUNCTION_DEVIATION diff --git a/Marlin/src/module/planner_bezier.cpp b/Marlin/src/module/planner_bezier.cpp index fa7e16a387..a3f98435d0 100644 --- a/Marlin/src/module/planner_bezier.cpp +++ b/Marlin/src/module/planner_bezier.cpp @@ -121,9 +121,12 @@ void cubic_b_spline( millis_t next_idle_ms = millis() + 200UL; + // Hints to help optimize the move + PlannerHints hints; + for (float t = 0; t < 1;) { - thermalManager.manage_heater(); + thermalManager.task(); millis_t now = millis(); if (ELAPSED(now, next_idle_ms)) { next_idle_ms = now + 200UL; @@ -177,7 +180,7 @@ void cubic_b_spline( } */ - step = new_t - t; + hints.millimeters = new_t - t; t = new_t; // Compute and send new position @@ -203,7 +206,7 @@ void cubic_b_spline( const xyze_pos_t &pos = bez_target; #endif - if (!planner.buffer_line(pos, scaled_fr_mm_s, active_extruder, step)) + if (!planner.buffer_line(pos, scaled_fr_mm_s, active_extruder, hints)) break; } } diff --git a/Marlin/src/module/polargraph.cpp b/Marlin/src/module/polargraph.cpp index b7eeeee8af..42f99304d7 100644 --- a/Marlin/src/module/polargraph.cpp +++ b/Marlin/src/module/polargraph.cpp @@ -39,8 +39,15 @@ float segments_per_second; // Initialized by settings.load() +xy_pos_t draw_area_min = { X_MIN_POS, Y_MIN_POS }, + draw_area_max = { X_MAX_POS, Y_MAX_POS }; + +xy_float_t draw_area_size = { X_MAX_POS - X_MIN_POS, Y_MAX_POS - Y_MIN_POS }; + +float polargraph_max_belt_len = HYPOT(draw_area_size.x, draw_area_size.y); + void inverse_kinematics(const xyz_pos_t &raw) { - const float x1 = raw.x - (X_MIN_POS), x2 = (X_MAX_POS) - raw.x, y = raw.y - (Y_MAX_POS); + const float x1 = raw.x - (draw_area_min.x), x2 = (draw_area_max.x) - raw.x, y = raw.y - (draw_area_max.y); delta.set(HYPOT(x1, y), HYPOT(x2, y), raw.z); } diff --git a/Marlin/src/module/polargraph.h b/Marlin/src/module/polargraph.h index 0406034253..b465de3287 100644 --- a/Marlin/src/module/polargraph.h +++ b/Marlin/src/module/polargraph.h @@ -29,5 +29,8 @@ #include "../core/macros.h" extern float segments_per_second; +extern xy_pos_t draw_area_min, draw_area_max; +extern xy_float_t draw_area_size; +extern float polargraph_max_belt_len; void inverse_kinematics(const xyz_pos_t &raw); diff --git a/Marlin/src/module/printcounter.cpp b/Marlin/src/module/printcounter.cpp index 619fbc137c..ad6f4eff68 100644 --- a/Marlin/src/module/printcounter.cpp +++ b/Marlin/src/module/printcounter.cpp @@ -37,7 +37,7 @@ Stopwatch print_job_timer; // Global Print Job Timer instance #include "../MarlinCore.h" #include "../HAL/shared/eeprom_api.h" -#if HAS_BUZZER && SERVICE_WARNING_BUZZES > 0 +#if HAS_SOUND && SERVICE_WARNING_BUZZES > 0 #include "../libs/buzzer.h" #endif @@ -156,7 +156,7 @@ void PrintCounter::loadStats() { #if SERVICE_INTERVAL_3 > 0 if (data.nextService3 == 0) doBuzz = _service_warn(PSTR(" " SERVICE_NAME_3)); #endif - #if HAS_BUZZER && SERVICE_WARNING_BUZZES > 0 + #if HAS_SOUND && SERVICE_WARNING_BUZZES > 0 if (doBuzz) for (int i = 0; i < SERVICE_WARNING_BUZZES; i++) { BUZZ(200, 404); BUZZ(10, 0); } #else UNUSED(doBuzz); diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index 924d3dbaef..c3d241e589 100755 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -44,11 +44,20 @@ #include "../feature/bedlevel/bedlevel.h" #endif +#if ENABLED(BD_SENSOR) + #include "../feature/bedlevel/bdl/bdl.h" +#endif + #if ENABLED(DELTA) #include "delta.h" #endif -#if ANY(HAS_QUIET_PROBING, USE_SENSORLESS) +#if ENABLED(SENSORLESS_PROBING) + abc_float_t offset_sensorless_adj{0}; + float largest_sensorless_adj = 0; +#endif + +#if EITHER(HAS_QUIET_PROBING, USE_SENSORLESS) #include "stepper/indirection.h" #if BOTH(HAS_QUIET_PROBING, PROBING_ESTEPPERS_OFF) #include "stepper.h" @@ -259,7 +268,57 @@ xyz_pos_t Probe::offset; // Initialized by settings.load() #endif } -#endif // Z_PROBE_ALLEN_KEY +#elif ENABLED(MAG_MOUNTED_PROBE) + + typedef struct { float fr_mm_min; xyz_pos_t where; } mag_probe_move_t; + + inline void run_deploy_moves_script() { + #ifdef MAG_MOUNTED_DEPLOY_1 + constexpr mag_probe_move_t deploy_1 = MAG_MOUNTED_DEPLOY_1; + do_blocking_move_to(deploy_1.where, MMM_TO_MMS(deploy_1.fr_mm_min)); + #endif + #ifdef MAG_MOUNTED_DEPLOY_2 + constexpr mag_probe_move_t deploy_2 = MAG_MOUNTED_DEPLOY_2; + do_blocking_move_to(deploy_2.where, MMM_TO_MMS(deploy_2.fr_mm_min)); + #endif + #ifdef MAG_MOUNTED_DEPLOY_3 + constexpr mag_probe_move_t deploy_3 = MAG_MOUNTED_DEPLOY_3; + do_blocking_move_to(deploy_3.where, MMM_TO_MMS(deploy_3.fr_mm_min)); + #endif + #ifdef MAG_MOUNTED_DEPLOY_4 + constexpr mag_probe_move_t deploy_4 = MAG_MOUNTED_DEPLOY_4; + do_blocking_move_to(deploy_4.where, MMM_TO_MMS(deploy_4.fr_mm_min)); + #endif + #ifdef MAG_MOUNTED_DEPLOY_5 + constexpr mag_probe_move_t deploy_5 = MAG_MOUNTED_DEPLOY_5; + do_blocking_move_to(deploy_5.where, MMM_TO_MMS(deploy_5.fr_mm_min)); + #endif + } + + inline void run_stow_moves_script() { + #ifdef MAG_MOUNTED_STOW_1 + constexpr mag_probe_move_t stow_1 = MAG_MOUNTED_STOW_1; + do_blocking_move_to(stow_1.where, MMM_TO_MMS(stow_1.fr_mm_min)); + #endif + #ifdef MAG_MOUNTED_STOW_2 + constexpr mag_probe_move_t stow_2 = MAG_MOUNTED_STOW_2; + do_blocking_move_to(stow_2.where, MMM_TO_MMS(stow_2.fr_mm_min)); + #endif + #ifdef MAG_MOUNTED_STOW_3 + constexpr mag_probe_move_t stow_3 = MAG_MOUNTED_STOW_3; + do_blocking_move_to(stow_3.where, MMM_TO_MMS(stow_3.fr_mm_min)); + #endif + #ifdef MAG_MOUNTED_STOW_4 + constexpr mag_probe_move_t stow_4 = MAG_MOUNTED_STOW_4; + do_blocking_move_to(stow_4.where, MMM_TO_MMS(stow_4.fr_mm_min)); + #endif + #ifdef MAG_MOUNTED_STOW_5 + constexpr mag_probe_move_t stow_5 = MAG_MOUNTED_STOW_5; + do_blocking_move_to(stow_5.where, MMM_TO_MMS(stow_5.fr_mm_min)); + #endif + } + +#endif // MAG_MOUNTED_PROBE #if HAS_QUIET_PROBING @@ -345,7 +404,7 @@ FORCE_INLINE void probe_specific_action(const bool deploy) { servo[Z_PROBE_SERVO_NR].move(servo_angles[Z_PROBE_SERVO_NR][deploy ? 0 : 1]); - #elif EITHER(TOUCH_MI_PROBE, Z_PROBE_ALLEN_KEY) + #elif ANY(TOUCH_MI_PROBE, Z_PROBE_ALLEN_KEY, MAG_MOUNTED_PROBE) deploy ? run_deploy_moves_script() : run_stow_moves_script(); @@ -833,6 +892,8 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai // Move the probe to the starting XYZ do_blocking_move_to(npos, feedRate_t(XY_PROBE_FEEDRATE_MM_S)); + TERN_(BD_SENSOR, return bdl.read()); + float measured_z = NAN; if (!deploy()) { measured_z = run_z_probe(sanity_check) + offset.z; @@ -882,76 +943,38 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai #endif // HAS_Z_SERVO_PROBE -#if USE_SENSORLESS - - sensorless_t stealth_states { false }; - - /** - * Disable stealthChop if used. Enable diag1 pin on driver. - */ - void Probe::enable_stallguard_diag1() { - #if ENABLED(SENSORLESS_PROBING) - #if HAS_DELTA_SENSORLESS_PROBING - stealth_states.x = tmc_enable_stallguard(stepperX); - stealth_states.y = tmc_enable_stallguard(stepperY); - #endif - stealth_states.z = tmc_enable_stallguard(stepperZ); - endstops.enable(true); - #endif - } - - /** - * Re-enable stealthChop if used. Disable diag1 pin on driver. - */ - void Probe::disable_stallguard_diag1() { - #if ENABLED(SENSORLESS_PROBING) - endstops.not_homing(); - #if HAS_DELTA_SENSORLESS_PROBING - tmc_disable_stallguard(stepperX, stealth_states.x); - tmc_disable_stallguard(stepperY, stealth_states.y); - #endif - tmc_disable_stallguard(stepperZ, stealth_states.z); - #endif - } +#if HAS_DELTA_SENSORLESS_PROBING /** * Set the sensorless Z offset */ void Probe::set_offset_sensorless_adj(const_float_t sz) { - #if ENABLED(SENSORLESS_PROBING) - DEBUG_SECTION(pso, "Probe::set_offset_sensorless_adj", true); - #if HAS_DELTA_SENSORLESS_PROBING - if (test_sensitivity.x) offset_sensorless_adj.a = sz; - if (test_sensitivity.y) offset_sensorless_adj.b = sz; - #endif - if (test_sensitivity.z) offset_sensorless_adj.c = sz; - #endif + DEBUG_SECTION(pso, "Probe::set_offset_sensorless_adj", true); + if (test_sensitivity.x) offset_sensorless_adj.a = sz; + if (test_sensitivity.y) offset_sensorless_adj.b = sz; + if (test_sensitivity.z) offset_sensorless_adj.c = sz; } /** * Refresh largest_sensorless_adj based on triggered endstops */ void Probe::refresh_largest_sensorless_adj() { - #if ENABLED(SENSORLESS_PROBING) - DEBUG_SECTION(rso, "Probe::refresh_largest_sensorless_adj", true); - largest_sensorless_adj = -3; // A reference away from any real probe height - #if HAS_DELTA_SENSORLESS_PROBING - if (TEST(endstops.state(), X_MAX)) { - NOLESS(largest_sensorless_adj, offset_sensorless_adj.a); - DEBUG_ECHOLNPGM("Endstop_X: ", largest_sensorless_adj, " TowerX"); - } - if (TEST(endstops.state(), Y_MAX)) { - NOLESS(largest_sensorless_adj, offset_sensorless_adj.b); - DEBUG_ECHOLNPGM("Endstop_Y: ", largest_sensorless_adj, " TowerY"); - } - #endif - if (TEST(endstops.state(), Z_MAX)) { - NOLESS(largest_sensorless_adj, offset_sensorless_adj.c); - DEBUG_ECHOLNPGM("Endstop_Z: ", largest_sensorless_adj, " TowerZ"); - } - #endif + DEBUG_SECTION(rso, "Probe::refresh_largest_sensorless_adj", true); + largest_sensorless_adj = -3; // A reference away from any real probe height + if (TEST(endstops.state(), X_MAX)) { + NOLESS(largest_sensorless_adj, offset_sensorless_adj.a); + DEBUG_ECHOLNPGM("Endstop_X: ", largest_sensorless_adj, " TowerX"); + } + if (TEST(endstops.state(), Y_MAX)) { + NOLESS(largest_sensorless_adj, offset_sensorless_adj.b); + DEBUG_ECHOLNPGM("Endstop_Y: ", largest_sensorless_adj, " TowerY"); + } + if (TEST(endstops.state(), Z_MAX)) { + NOLESS(largest_sensorless_adj, offset_sensorless_adj.c); + DEBUG_ECHOLNPGM("Endstop_Z: ", largest_sensorless_adj, " TowerZ"); + } } -#endif // SENSORLESS_PROBING || SENSORLESS_HOMING +#endif #endif // HAS_BED_PROBE diff --git a/Marlin/src/module/probe.h b/Marlin/src/module/probe.h index ca596e8969..1bcbc65642 100644 --- a/Marlin/src/module/probe.h +++ b/Marlin/src/module/probe.h @@ -62,16 +62,16 @@ #endif #endif +#if ENABLED(SENSORLESS_PROBING) + extern abc_float_t offset_sensorless_adj; +#endif + class Probe { public: #if ENABLED(SENSORLESS_PROBING) typedef struct { - #if HAS_DELTA_SENSORLESS_PROBING bool x:1, y:1, z:1; - #else - bool z; - #endif } sense_bool_t; static sense_bool_t test_sensitivity; #endif @@ -302,9 +302,7 @@ class Probe { #endif // Basic functions for Sensorless Homing and Probing - #if USE_SENSORLESS - static void enable_stallguard_diag1(); - static void disable_stallguard_diag1(); + #if HAS_DELTA_SENSORLESS_PROBING static void set_offset_sensorless_adj(const_float_t sz); static void refresh_largest_sensorless_adj(); #endif diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index cc4ed0ebc7..f563d79da0 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -79,6 +79,7 @@ #include "../lcd/extui/ui_api.h" #elif ENABLED(DWIN_LCD_PROUI) #include "../lcd/e3v2/proui/dwin.h" + #include "../lcd/e3v2/proui/bedlevel_tools.h" #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) #include "../lcd/e3v2/jyersui/dwin.h" #endif @@ -596,7 +597,7 @@ void MarlinSettings::postprocess() { xyze_pos_t oldpos = current_position; // steps per s2 needs to be updated to agree with units per s2 - planner.reset_acceleration_rates(); + planner.refresh_acceleration_rates(); // Make sure delta kinematics are updated before refreshing the // planner position so the stepper counts will be set correctly. @@ -1156,7 +1157,7 @@ void MarlinSettings::postprocess() { // { _FIELD_TEST(lcd_brightness); - const uint8_t lcd_brightness = TERN(HAS_LCD_BRIGHTNESS, ui.brightness, 255); // @advi3++ + const uint8_t lcd_brightness = TERN(HAS_LCD_BRIGHTNESS, ui.brightness, 255); EEPROM_WRITE(lcd_brightness); } @@ -2788,7 +2789,7 @@ void MarlinSettings::postprocess() { #endif persistentStore.access_start(); - const uint16_t status = persistentStore.read_data(pos, dest, MESH_STORE_SIZE, &crc); + uint16_t status = persistentStore.read_data(pos, dest, MESH_STORE_SIZE, &crc); persistentStore.access_finish(); #if ENABLED(OPTIMIZED_MESH_STORAGE) @@ -2801,6 +2802,16 @@ void MarlinSettings::postprocess() { bedlevel.set_mesh_from_store(z_mesh_store, bedlevel.z_values); #endif + #if ENABLED(DWIN_LCD_PROUI) + status = !BedLevelTools.meshvalidate(); + if (status) { + bedlevel.invalidate(); + LCD_MESSAGE(MSG_UBL_MESH_INVALID); + } + else + ui.status_printf(0, GET_TEXT_F(MSG_MESH_LOADED), bedlevel.storage_slot); + #endif + if (status) SERIAL_ECHOLNPGM("?Unable to load mesh data."); else DEBUG_ECHOLNPGM("Mesh loaded from slot ", slot); diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 40cf7d02ea..beea674ced 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -97,6 +97,10 @@ Stepper stepper; // Singleton #include "../MarlinCore.h" #include "../HAL/shared/Delay.h" +#if ENABLED(BD_SENSOR) + #include "../feature/bedlevel/bdl/bdl.h" +#endif + #if ENABLED(INTEGRATED_BABYSTEPPING) #include "../feature/babystep.h" #endif @@ -117,12 +121,6 @@ Stepper stepper; // Singleton #include "../feature/runout.h" #endif -#if HAS_L64XX - #include "../libs/L64XX/L64XX_Marlin.h" - uint8_t L6470_buf[MAX_L64XX + 1]; // chip command sequence - element 0 not used - bool L64XX_OK_to_power_up = false; // flag to keep L64xx steppers powered down after a reset or power up -#endif - #if ENABLED(AUTO_POWER_CONTROL) #include "../feature/power.h" #endif @@ -223,18 +221,12 @@ uint32_t Stepper::advance_divisor = 0, #endif #if ENABLED(LIN_ADVANCE) - uint32_t Stepper::nextAdvanceISR = LA_ADV_NEVER, - Stepper::LA_isr_rate = LA_ADV_NEVER; - uint16_t Stepper::LA_current_adv_steps = 0, - Stepper::LA_final_adv_steps, - Stepper::LA_max_adv_steps; - - int8_t Stepper::LA_steps = 0; - - bool Stepper::LA_use_advance_lead; - -#endif // LIN_ADVANCE + Stepper::la_interval = LA_ADV_NEVER; + int32_t Stepper::la_delta_error = 0, + Stepper::la_dividend = 0, + Stepper::la_advance_steps = 0; +#endif #if ENABLED(INTEGRATED_BABYSTEPPING) uint32_t Stepper::nextBabystepISR = BABYSTEP_NEVER; @@ -253,20 +245,6 @@ xyz_long_t Stepper::endstops_trigsteps; xyze_long_t Stepper::count_position{0}; xyze_int8_t Stepper::count_direction{0}; -#if ENABLED(LASER_POWER_INLINE_TRAPEZOID) - Stepper::stepper_laser_t Stepper::laser_trap = { - .enabled = false, - .cur_power = 0, - .cruise_set = false, - #if DISABLED(LASER_POWER_INLINE_TRAPEZOID_CONT) - .last_step_count = 0, - .acc_step_count = 0 - #else - .till_update = 0 - #endif - }; -#endif - #define MINDIR(A) (count_direction[_AXIS(A)] < 0) #define MAXDIR(A) (count_direction[_AXIS(A)] > 0) @@ -608,48 +586,25 @@ void Stepper::set_directions() { TERN_(HAS_V_DIR, SET_STEP_DIR(V)); TERN_(HAS_W_DIR, SET_STEP_DIR(W)); - #if DISABLED(LIN_ADVANCE) - #if ENABLED(MIXING_EXTRUDER) - // Because this is valid for the whole block we don't know - // what E steppers will step. Likely all. Set all. - if (motor_direction(E_AXIS)) { - MIXER_STEPPER_LOOP(j) REV_E_DIR(j); - count_direction.e = -1; - } - else { - MIXER_STEPPER_LOOP(j) NORM_E_DIR(j); - count_direction.e = 1; - } - #elif HAS_EXTRUDERS - if (motor_direction(E_AXIS)) { - REV_E_DIR(stepper_extruder); - count_direction.e = -1; - } - else { - NORM_E_DIR(stepper_extruder); - count_direction.e = 1; - } - #endif - #endif // !LIN_ADVANCE - - #if HAS_L64XX - if (L64XX_OK_to_power_up) { // OK to send the direction commands (which powers up the L64XX steppers) - if (L64xxManager.spi_active) { - L64xxManager.spi_abort = true; // Interrupted SPI transfer needs to shut down gracefully - for (uint8_t j = 1; j <= L64XX::chain[0]; j++) - L6470_buf[j] = dSPIN_NOP; // Fill buffer with NOOPs - L64xxManager.transfer(L6470_buf, L64XX::chain[0]); // Send enough NOOPs to complete any command - L64xxManager.transfer(L6470_buf, L64XX::chain[0]); - L64xxManager.transfer(L6470_buf, L64XX::chain[0]); - } - - // L64xxManager.dir_commands[] is an array that holds direction command for each stepper - - // Scan command array, copy matches into L64xxManager.transfer - for (uint8_t j = 1; j <= L64XX::chain[0]; j++) - L6470_buf[j] = L64xxManager.dir_commands[L64XX::chain[j]]; - - L64xxManager.transfer(L6470_buf, L64XX::chain[0]); // send the command stream to the drivers + #if ENABLED(MIXING_EXTRUDER) + // Because this is valid for the whole block we don't know + // what E steppers will step. Likely all. Set all. + if (motor_direction(E_AXIS)) { + MIXER_STEPPER_LOOP(j) REV_E_DIR(j); + count_direction.e = -1; + } + else { + MIXER_STEPPER_LOOP(j) NORM_E_DIR(j); + count_direction.e = 1; + } + #elif HAS_EXTRUDERS + if (motor_direction(E_AXIS)) { + REV_E_DIR(stepper_extruder); + count_direction.e = -1; + } + else { + NORM_E_DIR(stepper_extruder); + count_direction.e = 1; } #endif @@ -1394,7 +1349,7 @@ void Stepper::set_directions() { } FORCE_INLINE int32_t Stepper::_eval_bezier_curve(const uint32_t curr_step) { - #if (defined(__arm__) || defined(__thumb__)) && !defined(STM32G0B1xx) // TODO: Test define STM32G0xx versus STM32G0B1xx + #if (defined(__arm__) || defined(__thumb__)) && __ARM_ARCH >= 6 && !defined(STM32G0B1xx) // TODO: Test define STM32G0xx versus STM32G0B1xx // For ARM Cortex M3/M4 CPUs, we have the optimized assembler version, that takes 43 cycles to execute uint32_t flo = 0; @@ -1508,14 +1463,19 @@ void Stepper::isr() { // Enable ISRs to reduce USART processing latency hal.isr_on(); - if (!nextMainISR) pulse_phase_isr(); // 0 = Do coordinated axes Stepper pulses + if (!nextMainISR) pulse_phase_isr(); // 0 = Do coordinated axes Stepper pulses #if ENABLED(LIN_ADVANCE) - if (!nextAdvanceISR) nextAdvanceISR = advance_isr(); // 0 = Do Linear Advance E Stepper pulses + if (!nextAdvanceISR) { // 0 = Do Linear Advance E Stepper pulses + advance_isr(); + nextAdvanceISR = la_interval; + } + else if (nextAdvanceISR == LA_ADV_NEVER) // Start LA steps if necessary + nextAdvanceISR = la_interval; #endif #if ENABLED(INTEGRATED_BABYSTEPPING) - const bool is_babystep = (nextBabystepISR == 0); // 0 = Do Babystepping (XY)Z pulses + const bool is_babystep = (nextBabystepISR == 0); // 0 = Do Babystepping (XY)Z pulses if (is_babystep) nextBabystepISR = babystepping_isr(); #endif @@ -1699,7 +1659,7 @@ void Stepper::pulse_phase_isr() { }while(0) // Direct Stepping page? - const bool is_page = IS_PAGE(current_block); + const bool is_page = current_block->is_page(); #if ENABLED(DIRECT_STEPPING) // Direct stepping is currently not ready for HAS_I_AXIS @@ -1837,20 +1797,18 @@ void Stepper::pulse_phase_isr() { PULSE_PREP(W); #endif - #if EITHER(LIN_ADVANCE, MIXING_EXTRUDER) - delta_error.e += advance_dividend.e; - if (delta_error.e >= 0) { - #if ENABLED(LIN_ADVANCE) - delta_error.e -= advance_divisor; - // Don't step E here - But remember the number of steps to perform - motor_direction(E_AXIS) ? --LA_steps : ++LA_steps; - #else - count_position.e += count_direction.e; - step_needed.e = true; - #endif - } - #elif HAS_E0_STEP + #if EITHER(HAS_E0_STEP, MIXING_EXTRUDER) PULSE_PREP(E); + + #if ENABLED(LIN_ADVANCE) + if (step_needed.e && current_block->la_advance_rate) { + // don't actually step here, but do subtract movements steps + // from the linear advance step count + step_needed.e = false; + count_position.e -= count_direction.e; + la_advance_steps--; + } + #endif #endif } @@ -1890,12 +1848,10 @@ void Stepper::pulse_phase_isr() { PULSE_START(W); #endif - #if DISABLED(LIN_ADVANCE) - #if ENABLED(MIXING_EXTRUDER) - if (step_needed.e) E_STEP_WRITE(mixer.get_next_stepper(), !INVERT_E_STEP_PIN); - #elif HAS_E0_STEP - PULSE_START(E); - #endif + #if ENABLED(MIXING_EXTRUDER) + if (step_needed.e) E_STEP_WRITE(mixer.get_next_stepper(), !INVERT_E_STEP_PIN); + #elif HAS_E0_STEP + PULSE_START(E); #endif TERN_(I2S_STEPPER_STREAM, i2s_push_sample()); @@ -1935,15 +1891,10 @@ void Stepper::pulse_phase_isr() { PULSE_STOP(W); #endif - #if DISABLED(LIN_ADVANCE) - #if ENABLED(MIXING_EXTRUDER) - if (delta_error.e >= 0) { - delta_error.e -= advance_divisor; - E_STEP_WRITE(mixer.get_stepper(), INVERT_E_STEP_PIN); - } - #elif HAS_E0_STEP - PULSE_STOP(E); - #endif + #if ENABLED(MIXING_EXTRUDER) + if (step_needed.e) E_STEP_WRITE(mixer.get_stepper(), INVERT_E_STEP_PIN); + #elif HAS_E0_STEP + PULSE_STOP(E); #endif #if ISR_MULTI_STEPS @@ -1953,6 +1904,69 @@ void Stepper::pulse_phase_isr() { } while (--events_to_do); } +// Calculate timer interval, with all limits applied. +uint32_t Stepper::calc_timer_interval(uint32_t step_rate) { + #ifdef CPU_32_BIT + // In case of high-performance processor, it is able to calculate in real-time + return uint32_t(STEPPER_TIMER_RATE) / step_rate; + #else + // AVR is able to keep up at 30khz Stepping ISR rate. + constexpr uint32_t min_step_rate = (F_CPU) / 500000U; + if (step_rate <= min_step_rate) { + step_rate = 0; + uintptr_t table_address = (uintptr_t)&speed_lookuptable_slow[0][0]; + return uint16_t(pgm_read_word(table_address)); + } + else { + step_rate -= min_step_rate; // Correct for minimal speed + if (step_rate >= 0x0800) { // higher step rate + const uint8_t rate_mod_256 = (step_rate & 0x00FF); + const uintptr_t table_address = uintptr_t(&speed_lookuptable_fast[uint8_t(step_rate >> 8)][0]), + gain = uint16_t(pgm_read_word(table_address + 2)); + return uint16_t(pgm_read_word(table_address)) - MultiU16X8toH16(rate_mod_256, gain); + } + else { // lower step rates + uintptr_t table_address = uintptr_t(&speed_lookuptable_slow[0][0]); + table_address += (step_rate >> 1) & 0xFFFC; + return uint16_t(pgm_read_word(table_address)) + - ((uint16_t(pgm_read_word(table_address + 2)) * uint8_t(step_rate & 0x0007)) >> 3); + } + } + #endif +} + +// Get the timer interval and the number of loops to perform per tick +uint32_t Stepper::calc_timer_interval(uint32_t step_rate, uint8_t &loops) { + uint8_t multistep = 1; + #if DISABLED(DISABLE_MULTI_STEPPING) + + // The stepping frequency limits for each multistepping rate + static const uint32_t limit[] PROGMEM = { + ( MAX_STEP_ISR_FREQUENCY_1X ), + ( MAX_STEP_ISR_FREQUENCY_2X >> 1), + ( MAX_STEP_ISR_FREQUENCY_4X >> 2), + ( MAX_STEP_ISR_FREQUENCY_8X >> 3), + ( MAX_STEP_ISR_FREQUENCY_16X >> 4), + ( MAX_STEP_ISR_FREQUENCY_32X >> 5), + ( MAX_STEP_ISR_FREQUENCY_64X >> 6), + (MAX_STEP_ISR_FREQUENCY_128X >> 7) + }; + + // Select the proper multistepping + uint8_t idx = 0; + while (idx < 7 && step_rate > (uint32_t)pgm_read_dword(&limit[idx])) { + step_rate >>= 1; + multistep <<= 1; + ++idx; + }; + #else + NOMORE(step_rate, uint32_t(MAX_STEP_ISR_FREQUENCY_1X)); + #endif + loops = multistep; + + return calc_timer_interval(step_rate); +} + // This is the last half of the stepper interrupt: This one processes and // properly schedules blocks from the planner. This is executed after creating // the step pulses, so it is not time critical, as pulses are already done. @@ -1964,7 +1978,6 @@ uint32_t Stepper::block_phase_isr() { // If there is a current block if (current_block) { - // If current block is finished, reset pointer and finalize state if (step_events_completed >= step_event_count) { #if ENABLED(DIRECT_STEPPING) @@ -1977,7 +1990,7 @@ uint32_t Stepper::block_phase_isr() { count_position[_AXIS(AXIS)] += page_step_state.bd[_AXIS(AXIS)] * count_direction[_AXIS(AXIS)]; #endif - if (IS_PAGE(current_block)) { + if (current_block->is_page()) { PAGE_SEGMENT_UPDATE_POS(X); PAGE_SEGMENT_UPDATE_POS(Y); PAGE_SEGMENT_UPDATE_POS(Z); @@ -2006,43 +2019,39 @@ uint32_t Stepper::block_phase_isr() { // acc_step_rate is in steps/second // step_rate to timer interval and steps per stepper isr - interval = calc_timer_interval(acc_step_rate, &steps_per_isr); + interval = calc_timer_interval(acc_step_rate << oversampling_factor, steps_per_isr); acceleration_time += interval; #if ENABLED(LIN_ADVANCE) - if (LA_use_advance_lead) { - // Fire ISR if final adv_rate is reached - if (LA_steps && LA_isr_rate != current_block->advance_speed) nextAdvanceISR = 0; + if (current_block->la_advance_rate) { + const uint32_t la_step_rate = la_advance_steps < current_block->max_adv_steps ? current_block->la_advance_rate : 0; + la_interval = calc_timer_interval(acc_step_rate + la_step_rate) << current_block->la_scaling; } - else if (LA_steps) nextAdvanceISR = 0; #endif - // Update laser - Accelerating - #if ENABLED(LASER_POWER_INLINE_TRAPEZOID) - if (laser_trap.enabled) { - #if DISABLED(LASER_POWER_INLINE_TRAPEZOID_CONT) - if (current_block->laser.entry_per) { - laser_trap.acc_step_count -= step_events_completed - laser_trap.last_step_count; - laser_trap.last_step_count = step_events_completed; - - // Should be faster than a divide, since this should trip just once - if (laser_trap.acc_step_count < 0) { - while (laser_trap.acc_step_count < 0) { - laser_trap.acc_step_count += current_block->laser.entry_per; - if (laser_trap.cur_power < current_block->laser.power) laser_trap.cur_power++; - } - cutter.ocr_set_power(laser_trap.cur_power); - } - } - #else - if (laser_trap.till_update) - laser_trap.till_update--; - else { - laser_trap.till_update = LASER_POWER_INLINE_TRAPEZOID_CONT_PER; - laser_trap.cur_power = (current_block->laser.power * acc_step_rate) / current_block->nominal_rate; - cutter.ocr_set_power(laser_trap.cur_power); // Cycle efficiency is irrelevant it the last line was many cycles + /** + * Adjust Laser Power - Accelerating + * + * isPowered - True when a move is powered. + * isEnabled - laser power is active. + * + * Laser power variables are calulated and stored in this block by the planner code. + * trap_ramp_active_pwr - the active power in this block across accel or decel trap steps. + * trap_ramp_entry_incr - holds the precalculated value to increase the current power per accel step. + * + * Apply the starting active power and then increase power per step by the trap_ramp_entry_incr value if positive. + */ + + #if ENABLED(LASER_POWER_TRAP) + if (cutter.cutter_mode == CUTTER_MODE_CONTINUOUS) { + if (planner.laser_inline.status.isPowered && planner.laser_inline.status.isEnabled) { + if (current_block->laser.trap_ramp_entry_incr > 0) { + cutter.apply_power(current_block->laser.trap_ramp_active_pwr); + current_block->laser.trap_ramp_active_pwr += current_block->laser.trap_ramp_entry_incr; } - #endif + } + // Not a powered move. + else cutter.apply_power(0); } #endif } @@ -2051,6 +2060,7 @@ uint32_t Stepper::block_phase_isr() { uint32_t step_rate; #if ENABLED(S_CURVE_ACCELERATION) + // If this is the 1st time we process the 2nd half of the trapezoid... if (!bezier_2nd_half) { // Initialize the Bézier speed curve @@ -2065,8 +2075,8 @@ uint32_t Stepper::block_phase_isr() { ? _eval_bezier_curve(deceleration_time) : current_block->final_rate; } - #else + #else // Using the old trapezoidal control step_rate = STEP_MULTIPLY(deceleration_time, current_block->acceleration_rate); if (step_rate < acc_step_rate) { // Still decelerating? @@ -2075,88 +2085,123 @@ uint32_t Stepper::block_phase_isr() { } else step_rate = current_block->final_rate; - #endif - // step_rate is in steps/second + #endif // step_rate to timer interval and steps per stepper isr - interval = calc_timer_interval(step_rate, &steps_per_isr); + interval = calc_timer_interval(step_rate << oversampling_factor, steps_per_isr); deceleration_time += interval; #if ENABLED(LIN_ADVANCE) - if (LA_use_advance_lead) { - // Wake up eISR on first deceleration loop and fire ISR if final adv_rate is reached - if (step_events_completed <= decelerate_after + steps_per_isr || (LA_steps && LA_isr_rate != current_block->advance_speed)) { - initiateLA(); - LA_isr_rate = current_block->advance_speed; + if (current_block->la_advance_rate) { + const uint32_t la_step_rate = la_advance_steps > current_block->final_adv_steps ? current_block->la_advance_rate : 0; + if (la_step_rate != step_rate) { + bool reverse_e = la_step_rate > step_rate; + la_interval = calc_timer_interval(reverse_e ? la_step_rate - step_rate : step_rate - la_step_rate) << current_block->la_scaling; + + if (reverse_e != motor_direction(E_AXIS)) { + TBI(last_direction_bits, E_AXIS); + count_direction.e = -count_direction.e; + + DIR_WAIT_BEFORE(); + + if (reverse_e) { + #if ENABLED(MIXING_EXTRUDER) + MIXER_STEPPER_LOOP(j) REV_E_DIR(j); + #else + REV_E_DIR(stepper_extruder); + #endif + } + else { + #if ENABLED(MIXING_EXTRUDER) + MIXER_STEPPER_LOOP(j) NORM_E_DIR(j); + #else + NORM_E_DIR(stepper_extruder); + #endif + } + + DIR_WAIT_AFTER(); + } } } - else if (LA_steps) nextAdvanceISR = 0; #endif // LIN_ADVANCE - // Update laser - Decelerating - #if ENABLED(LASER_POWER_INLINE_TRAPEZOID) - if (laser_trap.enabled) { - #if DISABLED(LASER_POWER_INLINE_TRAPEZOID_CONT) - if (current_block->laser.exit_per) { - laser_trap.acc_step_count -= step_events_completed - laser_trap.last_step_count; - laser_trap.last_step_count = step_events_completed; - - // Should be faster than a divide, since this should trip just once - if (laser_trap.acc_step_count < 0) { - while (laser_trap.acc_step_count < 0) { - laser_trap.acc_step_count += current_block->laser.exit_per; - if (laser_trap.cur_power > current_block->laser.power_exit) laser_trap.cur_power--; - } - cutter.ocr_set_power(laser_trap.cur_power); - } - } - #else - if (laser_trap.till_update) - laser_trap.till_update--; - else { - laser_trap.till_update = LASER_POWER_INLINE_TRAPEZOID_CONT_PER; - laser_trap.cur_power = (current_block->laser.power * step_rate) / current_block->nominal_rate; - cutter.ocr_set_power(laser_trap.cur_power); // Cycle efficiency isn't relevant when the last line was many cycles + /* + * Adjust Laser Power - Decelerating + * trap_ramp_entry_decr - holds the precalculated value to decrease the current power per decel step. + */ + #if ENABLED(LASER_POWER_TRAP) + if (cutter.cutter_mode == CUTTER_MODE_CONTINUOUS) { + if (planner.laser_inline.status.isPowered && planner.laser_inline.status.isEnabled) { + if (current_block->laser.trap_ramp_exit_decr > 0) { + current_block->laser.trap_ramp_active_pwr -= current_block->laser.trap_ramp_exit_decr; + cutter.apply_power(current_block->laser.trap_ramp_active_pwr); } - #endif + // Not a powered move. + else cutter.apply_power(0); + } } #endif - } - // Must be in cruise phase otherwise - else { - #if ENABLED(LIN_ADVANCE) - // If there are any esteps, fire the next advance_isr "now" - if (LA_steps && LA_isr_rate != current_block->advance_speed) initiateLA(); - #endif + } + else { // Must be in cruise phase otherwise // Calculate the ticks_nominal for this nominal speed, if not done yet if (ticks_nominal < 0) { // step_rate to timer interval and loops for the nominal speed - ticks_nominal = calc_timer_interval(current_block->nominal_rate, &steps_per_isr); + ticks_nominal = calc_timer_interval(current_block->nominal_rate << oversampling_factor, steps_per_isr); + + #if ENABLED(LIN_ADVANCE) + if (current_block->la_advance_rate) + la_interval = calc_timer_interval(current_block->nominal_rate) << current_block->la_scaling; + #endif } // The timer interval is just the nominal value for the nominal speed interval = ticks_nominal; + } - // Update laser - Cruising - #if ENABLED(LASER_POWER_INLINE_TRAPEZOID) - if (laser_trap.enabled) { - if (!laser_trap.cruise_set) { - laser_trap.cur_power = current_block->laser.power; - cutter.ocr_set_power(laser_trap.cur_power); - laser_trap.cruise_set = true; + /** + * Adjust Laser Power - Cruise + * power - direct or floor adjusted active laser power. + */ + #if ENABLED(LASER_POWER_TRAP) + if (cutter.cutter_mode == CUTTER_MODE_CONTINUOUS) { + if (step_events_completed + 1 == accelerate_until) { + if (planner.laser_inline.status.isPowered && planner.laser_inline.status.isEnabled) { + if (current_block->laser.trap_ramp_entry_incr > 0) { + current_block->laser.trap_ramp_active_pwr = current_block->laser.power; + cutter.apply_power(current_block->laser.power); + } } - #if ENABLED(LASER_POWER_INLINE_TRAPEZOID_CONT) - laser_trap.till_update = LASER_POWER_INLINE_TRAPEZOID_CONT_PER; - #else - laser_trap.last_step_count = step_events_completed; - #endif + // Not a powered move. + else cutter.apply_power(0); } - #endif - } + } + #endif } + + #if ENABLED(LASER_FEATURE) + /** + * CUTTER_MODE_DYNAMIC is experimental and developing. + * Super-fast method to dynamically adjust the laser power OCR value based on the input feedrate in mm-per-minute. + * TODO: Set up Min/Max OCR offsets to allow tuning and scaling of various lasers. + * TODO: Integrate accel/decel +-rate into the dynamic laser power calc. + */ + if (cutter.cutter_mode == CUTTER_MODE_DYNAMIC + && planner.laser_inline.status.isPowered // isPowered flag set on any parsed G1, G2, G3, or G5 move; cleared on any others. + && cutter.last_block_power != current_block->laser.power // Prevent constant update without change + ) { + cutter.apply_power(current_block->laser.power); + cutter.last_block_power = current_block->laser.power; + } + #endif + } + else { // !current_block + #if ENABLED(LASER_FEATURE) + if (cutter.cutter_mode == CUTTER_MODE_DYNAMIC) + cutter.apply_power(0); // No movement in dynamic mode so turn Laser off + #endif } // If there is no current block at this point, attempt to pop one from the buffer @@ -2167,16 +2212,20 @@ uint32_t Stepper::block_phase_isr() { if ((current_block = planner.get_current_block())) { // Sync block? Sync the stepper counts or fan speeds and return - while (current_block->flag & BLOCK_MASK_SYNC) { + while (current_block->is_sync()) { - #if ENABLED(LASER_SYNCHRONOUS_M106_M107) - const bool is_sync_fans = TEST(current_block->flag, BLOCK_BIT_SYNC_FANS); - if (is_sync_fans) planner.sync_fan_speeds(current_block->fan_speed); - #else - constexpr bool is_sync_fans = false; + #if ENABLED(LASER_POWER_SYNC) + if (cutter.cutter_mode == CUTTER_MODE_CONTINUOUS) { + if (current_block->is_pwr_sync()) { + planner.laser_inline.status.isSyncPower = true; + cutter.apply_power(current_block->laser.power); + } + } #endif - if (!is_sync_fans) _set_position(current_block->position); + TERN_(LASER_SYNCHRONOUS_M106_M107, if (current_block->is_fan_sync()) planner.sync_fan_speeds(current_block->fan_speed)); + + if (!(current_block->is_fan_sync() || current_block->is_pwr_sync())) _set_position(current_block->position); discard_current_block(); @@ -2186,8 +2235,10 @@ uint32_t Stepper::block_phase_isr() { } // For non-inline cutter, grossly apply power - #if ENABLED(LASER_FEATURE) && DISABLED(LASER_POWER_INLINE) - cutter.apply_power(current_block->cutter_power); + #if HAS_CUTTER + if (cutter.cutter_mode == CUTTER_MODE_STANDARD) { + cutter.apply_power(current_block->cutter_power); + } #endif #if ENABLED(POWER_LOSS_RECOVERY) @@ -2196,7 +2247,7 @@ uint32_t Stepper::block_phase_isr() { #endif #if ENABLED(DIRECT_STEPPING) - if (IS_PAGE(current_block)) { + if (current_block->is_page()) { page_step_state.segment_steps = 0; page_step_state.segment_idx = 0; page_step_state.page = page_manager.get_page(current_block->page_idx); @@ -2317,7 +2368,7 @@ uint32_t Stepper::block_phase_isr() { step_event_count = current_block->step_event_count << oversampling; // Initialize Bresenham delta errors to 1/2 - delta_error = -int32_t(step_event_count); + delta_error = TERN_(LIN_ADVANCE, la_delta_error =) -int32_t(step_event_count); // Calculate Bresenham dividends and divisors advance_dividend = current_block->steps << 1; @@ -2338,58 +2389,38 @@ uint32_t Stepper::block_phase_isr() { #if ENABLED(LIN_ADVANCE) #if DISABLED(MIXING_EXTRUDER) && E_STEPPERS > 1 // If the now active extruder wasn't in use during the last move, its pressure is most likely gone. - if (stepper_extruder != last_moved_extruder) LA_current_adv_steps = 0; + if (stepper_extruder != last_moved_extruder) la_advance_steps = 0; #endif - - if ((LA_use_advance_lead = current_block->use_advance_lead)) { - LA_final_adv_steps = current_block->final_adv_steps; - LA_max_adv_steps = current_block->max_adv_steps; - initiateLA(); // Start the ISR - LA_isr_rate = current_block->advance_speed; + if (current_block->la_advance_rate) { + // apply LA scaling and discount the effect of frequency scaling + la_dividend = (advance_dividend.e << current_block->la_scaling) << oversampling; } - else LA_isr_rate = LA_ADV_NEVER; #endif - if ( ENABLED(HAS_L64XX) // Always set direction for L64xx (Also enables the chips) - || ENABLED(DUAL_X_CARRIAGE) // TODO: Find out why this fixes "jittery" small circles + if ( ENABLED(DUAL_X_CARRIAGE) // TODO: Find out why this fixes "jittery" small circles || current_block->direction_bits != last_direction_bits || TERN(MIXING_EXTRUDER, false, stepper_extruder != last_moved_extruder) ) { E_TERN_(last_moved_extruder = stepper_extruder); - TERN_(HAS_L64XX, L64XX_OK_to_power_up = true); set_directions(current_block->direction_bits); } - #if ENABLED(LASER_POWER_INLINE) - const power_status_t stat = current_block->laser.status; - #if ENABLED(LASER_POWER_INLINE_TRAPEZOID) - laser_trap.enabled = stat.isPlanned && stat.isEnabled; - laser_trap.cur_power = current_block->laser.power_entry; // RESET STATE - laser_trap.cruise_set = false; - #if DISABLED(LASER_POWER_INLINE_TRAPEZOID_CONT) - laser_trap.last_step_count = 0; - laser_trap.acc_step_count = current_block->laser.entry_per / 2; - #else - laser_trap.till_update = 0; - #endif - // Always have PWM in this case - if (stat.isPlanned) { // Planner controls the laser - cutter.ocr_set_power( - stat.isEnabled ? laser_trap.cur_power : 0 // ON with power or OFF - ); - } - #else - if (stat.isPlanned) { // Planner controls the laser - #if ENABLED(SPINDLE_LASER_USE_PWM) - cutter.ocr_set_power( - stat.isEnabled ? current_block->laser.power : 0 // ON with power or OFF - ); + #if ENABLED(LASER_FEATURE) + if (cutter.cutter_mode == CUTTER_MODE_CONTINUOUS) { // Planner controls the laser + if (planner.laser_inline.status.isSyncPower) + // If the previous block was a M3 sync power then skip the trap power init otherwise it will 0 the sync power. + planner.laser_inline.status.isSyncPower = false; // Clear the flag to process subsequent trap calc's. + else if (current_block->laser.status.isEnabled) { + #if ENABLED(LASER_POWER_TRAP) + TERN_(DEBUG_LASER_TRAP, SERIAL_ECHO_MSG("InitTrapPwr:",current_block->laser.trap_ramp_active_pwr)); + cutter.apply_power(current_block->laser.status.isPowered ? current_block->laser.trap_ramp_active_pwr : 0); #else - cutter.set_enabled(stat.isEnabled); + TERN_(DEBUG_CUTTER_POWER, SERIAL_ECHO_MSG("InlinePwr:",current_block->laser.power)); + cutter.apply_power(current_block->laser.status.isPowered ? current_block->laser.power : 0); #endif } - #endif - #endif // LASER_POWER_INLINE + } + #endif // LASER_FEATURE // If the endstop is already pressed, endstop interrupts won't invoke // endstop_triggered and the move will grind. So check here for a @@ -2417,23 +2448,16 @@ uint32_t Stepper::block_phase_isr() { #endif // Calculate the initial timer interval - interval = calc_timer_interval(current_block->initial_rate, &steps_per_isr); - } - #if ENABLED(LASER_POWER_INLINE_CONTINUOUS) - else { // No new block found; so apply inline laser parameters - // This should mean ending file with 'M5 I' will stop the laser; thus the inline flag isn't needed - const power_status_t stat = planner.laser_inline.status; - if (stat.isPlanned) { // Planner controls the laser - #if ENABLED(SPINDLE_LASER_USE_PWM) - cutter.ocr_set_power( - stat.isEnabled ? planner.laser_inline.power : 0 // ON with power or OFF - ); - #else - cutter.set_enabled(stat.isEnabled); - #endif + interval = calc_timer_interval(current_block->initial_rate << oversampling_factor, steps_per_isr); + acceleration_time += interval; + + #if ENABLED(LIN_ADVANCE) + if (current_block->la_advance_rate) { + const uint32_t la_step_rate = la_advance_steps < current_block->max_adv_steps ? current_block->la_advance_rate : 0; + la_interval = calc_timer_interval(current_block->initial_rate + la_step_rate) << current_block->la_scaling; } - } - #endif + #endif + } } // Return the interval to wait @@ -2443,71 +2467,15 @@ uint32_t Stepper::block_phase_isr() { #if ENABLED(LIN_ADVANCE) // Timer interrupt for E. LA_steps is set in the main routine - uint32_t Stepper::advance_isr() { - uint32_t interval; - - if (LA_use_advance_lead) { - if (step_events_completed > decelerate_after && LA_current_adv_steps > LA_final_adv_steps) { - LA_steps--; - LA_current_adv_steps--; - interval = LA_isr_rate; - } - else if (step_events_completed < decelerate_after && LA_current_adv_steps < LA_max_adv_steps) { - LA_steps++; - LA_current_adv_steps++; - interval = LA_isr_rate; - } - else - interval = LA_isr_rate = LA_ADV_NEVER; - } - else - interval = LA_ADV_NEVER; - - if (!LA_steps) return interval; // Leave pins alone if there are no steps! - - DIR_WAIT_BEFORE(); - - #if ENABLED(MIXING_EXTRUDER) - // We don't know which steppers will be stepped because LA loop follows, - // with potentially multiple steps. Set all. - if (LA_steps > 0) { - MIXER_STEPPER_LOOP(j) NORM_E_DIR(j); - count_direction.e = 1; - } - else if (LA_steps < 0) { - MIXER_STEPPER_LOOP(j) REV_E_DIR(j); - count_direction.e = -1; - } - #else - if (LA_steps > 0) { - NORM_E_DIR(stepper_extruder); - count_direction.e = 1; - } - else if (LA_steps < 0) { - REV_E_DIR(stepper_extruder); - count_direction.e = -1; - } - #endif - - DIR_WAIT_AFTER(); - - //const hal_timer_t added_step_ticks = hal_timer_t(ADDED_STEP_TICKS); - - // Step E stepper if we have steps - #if ISR_MULTI_STEPS - bool firstStep = true; - USING_TIMED_PULSE(); - #endif - - while (LA_steps) { - #if ISR_MULTI_STEPS - if (firstStep) - firstStep = false; - else - AWAIT_LOW_PULSE(); - #endif - + void Stepper::advance_isr() { + // Apply Bresenham algorithm so that linear advance can piggy back on + // the acceleration and speed values calculated in block_phase_isr(). + // This helps keep LA in sync with, for example, S_CURVE_ACCELERATION. + la_delta_error += la_dividend; + if (la_delta_error >= 0) { count_position.e += count_direction.e; + la_advance_steps += count_direction.e; + la_delta_error -= advance_divisor; // Set the STEP pulse ON #if ENABLED(MIXING_EXTRUDER) @@ -2518,12 +2486,8 @@ uint32_t Stepper::block_phase_isr() { // Enforce a minimum duration for STEP pulse ON #if ISR_PULSE_CONTROL + USING_TIMED_PULSE(); START_HIGH_PULSE(); - #endif - - LA_steps < 0 ? ++LA_steps : --LA_steps; - - #if ISR_PULSE_CONTROL AWAIT_HIGH_PULSE(); #endif @@ -2533,15 +2497,7 @@ uint32_t Stepper::block_phase_isr() { #else E_STEP_WRITE(stepper_extruder, INVERT_E_STEP_PIN); #endif - - // For minimum pulse time wait before looping - // Just wait for the requested pulse duration - #if ISR_PULSE_CONTROL - if (LA_steps) START_LOW_PULSE(); - #endif - } // LA_steps - - return interval; + } } #endif // LIN_ADVANCE diff --git a/Marlin/src/module/stepper.h b/Marlin/src/module/stepper.h index 3b899e93e2..ccf342b573 100644 --- a/Marlin/src/module/stepper.h +++ b/Marlin/src/module/stepper.h @@ -316,6 +316,8 @@ constexpr ena_mask_t enable_overlap[] = { // Stepper class definition // class Stepper { + friend class KinematicSystem; + friend class DeltaKinematicSystem; public: @@ -415,10 +417,11 @@ class Stepper { #if ENABLED(LIN_ADVANCE) static constexpr uint32_t LA_ADV_NEVER = 0xFFFFFFFF; - static uint32_t nextAdvanceISR, LA_isr_rate; - static uint16_t LA_current_adv_steps, LA_final_adv_steps, LA_max_adv_steps; // Copy from current executed block. Needed because current_block is set to NULL "too early". - static int8_t LA_steps; - static bool LA_use_advance_lead; + static uint32_t nextAdvanceISR, + la_interval; // Interval between ISR calls for LA + static int32_t la_delta_error, // Analogue of delta_error.e for E steps in LA ISR + la_dividend, // Analogue of advance_dividend.e for E steps in LA ISR + la_advance_steps; // Count of steps added to increase nozzle pressure #endif #if ENABLED(INTEGRATED_BABYSTEPPING) @@ -444,25 +447,6 @@ class Stepper { // Current stepper motor directions (+1 or -1) static xyze_int8_t count_direction; - #if ENABLED(LASER_POWER_INLINE_TRAPEZOID) - - typedef struct { - bool enabled; // Trapezoid needed flag (i.e., laser on, planner in control) - uint8_t cur_power; // Current laser power - bool cruise_set; // Power set up for cruising? - - #if ENABLED(LASER_POWER_INLINE_TRAPEZOID_CONT) - uint16_t till_update; // Countdown to the next update - #else - uint32_t last_step_count, // Step count from the last update - acc_step_count; // Bresenham counter for laser accel/decel - #endif - } stepper_laser_t; - - static stepper_laser_t laser_trap; - - #endif - public: // Initialize stepper hardware static void init(); @@ -492,8 +476,7 @@ class Stepper { #if ENABLED(LIN_ADVANCE) // The Linear advance ISR phase - static uint32_t advance_isr(); - FORCE_INLINE static void initiateLA() { nextAdvanceISR = 0; } + static void advance_isr(); #endif #if ENABLED(INTEGRATED_BABYSTEPPING) @@ -524,12 +507,12 @@ class Stepper { // Discard current block and free any resources FORCE_INLINE static void discard_current_block() { #if ENABLED(DIRECT_STEPPING) - if (IS_PAGE(current_block)) - page_manager.free_page(current_block->page_idx); + if (current_block->is_page()) page_manager.free_page(current_block->page_idx); #endif current_block = nullptr; axis_did_move = 0; planner.release_current_block(); + TERN_(LIN_ADVANCE, la_interval = nextAdvanceISR = LA_ADV_NEVER); } // Quickly stop all steppers @@ -649,65 +632,9 @@ class Stepper { // Set the current position in steps static void _set_position(const abce_long_t &spos); - FORCE_INLINE static uint32_t calc_timer_interval(uint32_t step_rate, uint8_t *loops) { - uint32_t timer; - - // Scale the frequency, as requested by the caller - step_rate <<= oversampling_factor; - - uint8_t multistep = 1; - #if DISABLED(DISABLE_MULTI_STEPPING) - - // The stepping frequency limits for each multistepping rate - static const uint32_t limit[] PROGMEM = { - ( MAX_STEP_ISR_FREQUENCY_1X ), - ( MAX_STEP_ISR_FREQUENCY_2X >> 1), - ( MAX_STEP_ISR_FREQUENCY_4X >> 2), - ( MAX_STEP_ISR_FREQUENCY_8X >> 3), - ( MAX_STEP_ISR_FREQUENCY_16X >> 4), - ( MAX_STEP_ISR_FREQUENCY_32X >> 5), - ( MAX_STEP_ISR_FREQUENCY_64X >> 6), - (MAX_STEP_ISR_FREQUENCY_128X >> 7) - }; - - // Select the proper multistepping - uint8_t idx = 0; - while (idx < 7 && step_rate > (uint32_t)pgm_read_dword(&limit[idx])) { - step_rate >>= 1; - multistep <<= 1; - ++idx; - }; - #else - NOMORE(step_rate, uint32_t(MAX_STEP_ISR_FREQUENCY_1X)); - #endif - *loops = multistep; - - #ifdef CPU_32_BIT - // In case of high-performance processor, it is able to calculate in real-time - timer = uint32_t(STEPPER_TIMER_RATE) / step_rate; - #else - constexpr uint32_t min_step_rate = (F_CPU) / 500000U; - NOLESS(step_rate, min_step_rate); - step_rate -= min_step_rate; // Correct for minimal speed - if (step_rate >= (8 * 256)) { // higher step rate - const uint8_t tmp_step_rate = (step_rate & 0x00FF); - const uint16_t table_address = (uint16_t)&speed_lookuptable_fast[(uint8_t)(step_rate >> 8)][0], - gain = (uint16_t)pgm_read_word(table_address + 2); - timer = MultiU16X8toH16(tmp_step_rate, gain); - timer = (uint16_t)pgm_read_word(table_address) - timer; - } - else { // lower step rates - uint16_t table_address = (uint16_t)&speed_lookuptable_slow[0][0]; - table_address += ((step_rate) >> 1) & 0xFFFC; - timer = (uint16_t)pgm_read_word(table_address) - - (((uint16_t)pgm_read_word(table_address + 2) * (uint8_t)(step_rate & 0x0007)) >> 3); - } - // (there is no need to limit the timer value here. All limits have been - // applied above, and AVR is able to keep up at 30khz Stepping ISR rate) - #endif - - return timer; - } + // Calculate timing interval for the given step rate + static uint32_t calc_timer_interval(uint32_t step_rate); + static uint32_t calc_timer_interval(uint32_t step_rate, uint8_t &loops); #if ENABLED(S_CURVE_ACCELERATION) static void _calc_bezier_curve_coeffs(const int32_t v0, const int32_t v1, const uint32_t av); diff --git a/Marlin/src/module/stepper/L64xx.cpp b/Marlin/src/module/stepper/L64xx.cpp deleted file mode 100644 index 5b60746396..0000000000 --- a/Marlin/src/module/stepper/L64xx.cpp +++ /dev/null @@ -1,264 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * - * Based on Sprinter and grbl. - * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm - * - * This program 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. - * - * This program 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 this program. If not, see . - * - */ - -/** - * stepper/L64xx.cpp - * Stepper driver indirection for L64XX drivers - */ - -#include "../../inc/MarlinConfig.h" - -#if HAS_L64XX - -#include "L64xx.h" - -#if AXIS_IS_L64XX(X) - L64XX_CLASS(X) stepperX(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(X2) - L64XX_CLASS(X2) stepperX2(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(Y) - L64XX_CLASS(Y) stepperY(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(Y2) - L64XX_CLASS(Y2) stepperY2(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(Z) - L64XX_CLASS(Z) stepperZ(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(Z2) - L64XX_CLASS(Z2) stepperZ2(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(Z3) - L64XX_CLASS(Z3) stepperZ3(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(Z4) - L64XX_CLASS(Z4) stepperZ4(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(I) - L64XX_CLASS(I) stepperI(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(J) - L64XX_CLASS(J) stepperJ(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(K) - L64XX_CLASS(K) stepperK(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(U) - L64XX_CLASS(u) stepperU(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(V) - L64XX_CLASS(v) stepperV(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(W) - L64XX_CLASS(w) stepperW(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(E0) - L64XX_CLASS(E0) stepperE0(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(E1) - L64XX_CLASS(E1) stepperE1(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(E2) - L64XX_CLASS(E2) stepperE2(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(E3) - L64XX_CLASS(E3) stepperE3(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(E4) - L64XX_CLASS(E4) stepperE4(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(E5) - L64XX_CLASS(E5) stepperE5(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(E6) - L64XX_CLASS(E6) stepperE6(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(E7) - L64XX_CLASS(E7) stepperE7(L6470_CHAIN_SS_PIN); -#endif - -// Not using L64XX class init method because it -// briefly sends power to the steppers - -inline void L6470_init_chip(L64XX &st, const int ms, const int oc, const int sc, const int mv, const int slew_rate) { - st.set_handlers(L64xxManager.spi_init, L64xxManager.transfer_single, L64xxManager.transfer_chain); // specify which external SPI routines to use - switch (st.L6470_status_layout) { - case L6470_STATUS_LAYOUT: { - st.resetDev(); - st.softFree(); - st.SetParam(st.L64XX_CONFIG, CONFIG_PWM_DIV_1 | CONFIG_PWM_MUL_2 | CONFIG_OC_SD_DISABLE | CONFIG_VS_COMP_DISABLE | CONFIG_SW_HARD_STOP | CONFIG_INT_16MHZ); - st.SetParam(L6470_KVAL_RUN, 0xFF); - st.SetParam(L6470_KVAL_ACC, 0xFF); - st.SetParam(L6470_KVAL_DEC, 0xFF); - st.setMicroSteps(ms); - st.setOverCurrent(oc); - st.setStallCurrent(sc); - st.SetParam(L6470_KVAL_HOLD, mv); - st.SetParam(L6470_ABS_POS, 0); - uint32_t config_temp = st.GetParam(st.L64XX_CONFIG); - config_temp &= ~CONFIG_POW_SR; - switch (slew_rate) { - case 0: st.SetParam(st.L64XX_CONFIG, config_temp | CONFIG_SR_75V_us); break; - default: - case 1: st.SetParam(st.L64XX_CONFIG, config_temp | CONFIG_SR_110V_us); break; - case 3: - case 2: st.SetParam(st.L64XX_CONFIG, config_temp | CONFIG_SR_260V_us); break; - } - st.getStatus(); - st.getStatus(); - break; - } - - case L6474_STATUS_LAYOUT: { - st.free(); - //st.SetParam(st.L64XX_CONFIG, CONFIG_PWM_DIV_1 | CONFIG_PWM_MUL_2 | CONFIG_OC_SD_DISABLE | CONFIG_VS_COMP_DISABLE | CONFIG_SW_HARD_STOP | CONFIG_INT_16MHZ); - //st.SetParam(L6474_TVAL, 0xFF); - st.setMicroSteps(ms); - st.setOverCurrent(oc); - st.setTVALCurrent(sc); - st.SetParam(L6470_ABS_POS, 0); - uint32_t config_temp = st.GetParam(st.L64XX_CONFIG); - config_temp &= ~CONFIG_POW_SR & ~CONFIG_EN_TQREG; // clear out slew rate and set current to be controlled by TVAL register - switch (slew_rate) { - case 0: st.SetParam(st.L64XX_CONFIG, config_temp | CONFIG_SR_75V_us); break; - default: - case 1: st.SetParam(st.L64XX_CONFIG, config_temp | CONFIG_SR_110V_us); break; - case 3: - case 2: st.SetParam(st.L64XX_CONFIG, config_temp | CONFIG_SR_260V_us); break; - //case 0: st.SetParam(st.L64XX_CONFIG, 0x2E88 | CONFIG_EN_TQREG | CONFIG_SR_75V_us); break; - //default: - //case 1: st.SetParam(st.L64XX_CONFIG, 0x2E88 | CONFIG_EN_TQREG | CONFIG_SR_110V_us); break; - //case 3: - //case 2: st.SetParam(st.L64XX_CONFIG, 0x2E88 | CONFIG_EN_TQREG | CONFIG_SR_260V_us); break; - - //case 0: st.SetParam(st.L64XX_CONFIG, 0x2E88 ); break; - //default: - //case 1: st.SetParam(st.L64XX_CONFIG, 0x2E88 ); break; - //case 3: - //case 2: st.SetParam(st.L64XX_CONFIG, 0x2E88 ); break; - } - st.getStatus(); - st.getStatus(); - break; - } - - case L6480_STATUS_LAYOUT: { - st.resetDev(); - st.softFree(); - st.SetParam(st.L64XX_CONFIG, CONFIG_PWM_DIV_1 | CONFIG_PWM_MUL_2 | CONFIG_OC_SD_DISABLE | CONFIG_VS_COMP_DISABLE | CONFIG_SW_HARD_STOP | CONFIG_INT_16MHZ); - st.SetParam(L6470_KVAL_RUN, 0xFF); - st.SetParam(L6470_KVAL_ACC, 0xFF); - st.SetParam(L6470_KVAL_DEC, 0xFF); - st.setMicroSteps(ms); - st.setOverCurrent(oc); - st.setStallCurrent(sc); - st.SetParam(+-L6470_KVAL_HOLD, mv); - st.SetParam(L6470_ABS_POS, 0); - st.SetParam(st.L64XX_CONFIG,(st.GetParam(st.L64XX_CONFIG) | PWR_VCC_7_5V)); - st.getStatus(); // must clear out status bits before can set slew rate - st.getStatus(); - switch (slew_rate) { - case 0: st.SetParam(L6470_GATECFG1, CONFIG1_SR_220V_us); st.SetParam(L6470_GATECFG2, CONFIG2_SR_220V_us); break; - default: - case 1: st.SetParam(L6470_GATECFG1, CONFIG1_SR_400V_us); st.SetParam(L6470_GATECFG2, CONFIG2_SR_400V_us); break; - case 2: st.SetParam(L6470_GATECFG1, CONFIG1_SR_520V_us); st.SetParam(L6470_GATECFG2, CONFIG2_SR_520V_us); break; - case 3: st.SetParam(L6470_GATECFG1, CONFIG1_SR_980V_us); st.SetParam(L6470_GATECFG2, CONFIG2_SR_980V_us); break; - } - break; - } - } -} - -#define L6470_INIT_CHIP(Q) L6470_init_chip(stepper##Q, Q##_MICROSTEPS, Q##_OVERCURRENT, Q##_STALLCURRENT, Q##_MAX_VOLTAGE, Q##_SLEW_RATE) - -void L64XX_Marlin::init_to_defaults() { - #if AXIS_IS_L64XX(X) - L6470_INIT_CHIP(X); - #endif - #if AXIS_IS_L64XX(X2) - L6470_INIT_CHIP(X2); - #endif - #if AXIS_IS_L64XX(Y) - L6470_INIT_CHIP(Y); - #endif - #if AXIS_IS_L64XX(Y2) - L6470_INIT_CHIP(Y2); - #endif - #if AXIS_IS_L64XX(Z) - L6470_INIT_CHIP(Z); - #endif - #if AXIS_IS_L64XX(Z2) - L6470_INIT_CHIP(Z2); - #endif - #if AXIS_IS_L64XX(Z3) - L6470_INIT_CHIP(Z3); - #endif - #if AXIS_IS_L64XX(Z4) - L6470_INIT_CHIP(Z4); - #endif - #if AXIS_IS_L64XX(I) - L6470_INIT_CHIP(I); - #endif - #if AXIS_IS_L64XX(J) - L6470_INIT_CHIP(J); - #endif - #if AXIS_IS_L64XX(K) - L6470_INIT_CHIP(K); - #endif - #if AXIS_IS_L64XX(U) - L6470_INIT_CHIP(U); - #endif - #if AXIS_IS_L64XX(V) - L6470_INIT_CHIP(V); - #endif - #if AXIS_IS_L64XX(W) - L6470_INIT_CHIP(W); - #endif - #if AXIS_IS_L64XX(E0) - L6470_INIT_CHIP(E0); - #endif - #if AXIS_IS_L64XX(E1) - L6470_INIT_CHIP(E1); - #endif - #if AXIS_IS_L64XX(E2) - L6470_INIT_CHIP(E2); - #endif - #if AXIS_IS_L64XX(E3) - L6470_INIT_CHIP(E3); - #endif - #if AXIS_IS_L64XX(E4) - L6470_INIT_CHIP(E4); - #endif - #if AXIS_IS_L64XX(E5) - L6470_INIT_CHIP(E5); - #endif - #if AXIS_IS_L64XX(E6) - L6470_INIT_CHIP(E6); - #endif - #if AXIS_IS_L64XX(E7) - L6470_INIT_CHIP(E7); - #endif -} - -#endif // HAS_L64XX diff --git a/Marlin/src/module/stepper/L64xx.h b/Marlin/src/module/stepper/L64xx.h deleted file mode 100644 index 870b0414f8..0000000000 --- a/Marlin/src/module/stepper/L64xx.h +++ /dev/null @@ -1,490 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * - * Based on Sprinter and grbl. - * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm - * - * This program 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. - * - * This program 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 this program. If not, see . - * - */ -#pragma once - -/** - * stepper/L64xx.h - * Stepper driver indirection for L64XX drivers - */ - -#include "../../inc/MarlinConfig.h" -#include "../../libs/L64XX/L64XX_Marlin.h" - -// Convert option names to L64XX classes -#define CLASS_L6470 L6470 -#define CLASS_L6474 L6474 -#define CLASS_POWERSTEP01 powerSTEP01 - -#define __L64XX_CLASS(TYPE) CLASS_##TYPE -#define _L64XX_CLASS(TYPE) __L64XX_CLASS(TYPE) -#define L64XX_CLASS(ST) _L64XX_CLASS(ST##_DRIVER_TYPE) - -#define L6474_DIR_WRITE(A,STATE) do{ L64xxManager.dir_commands[A] = dSPIN_L6474_ENABLE; WRITE(A##_DIR_PIN, STATE); }while(0) -#define L64XX_DIR_WRITE(A,STATE) do{ L64xxManager.dir_commands[A] = (STATE) ? dSPIN_STEP_CLOCK_REV : dSPIN_STEP_CLOCK_FWD; }while(0) - -// X Stepper -#if AXIS_IS_L64XX(X) - extern L64XX_CLASS(X) stepperX; - #define X_ENABLE_INIT() NOOP - #define X_ENABLE_WRITE(STATE) (STATE ? stepperX.hardStop() : stepperX.free()) - #define X_ENABLE_READ() (stepperX.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_X(L6474) - #define X_DIR_INIT() SET_OUTPUT(X_DIR_PIN) - #define X_DIR_WRITE(STATE) L6474_DIR_WRITE(X, STATE) - #define X_DIR_READ() READ(X_DIR_PIN) - #else - #define X_DIR_INIT() NOOP - #define X_DIR_WRITE(STATE) L64XX_DIR_WRITE(X, STATE) - #define X_DIR_READ() (stepper##X.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_X(L6470) - #define DISABLE_STEPPER_X() stepperX.free() - #endif - #endif -#endif - -// Y Stepper -#if AXIS_IS_L64XX(Y) - extern L64XX_CLASS(Y) stepperY; - #define Y_ENABLE_INIT() NOOP - #define Y_ENABLE_WRITE(STATE) (STATE ? stepperY.hardStop() : stepperY.free()) - #define Y_ENABLE_READ() (stepperY.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_Y(L6474) - #define Y_DIR_INIT() SET_OUTPUT(Y_DIR_PIN) - #define Y_DIR_WRITE(STATE) L6474_DIR_WRITE(Y, STATE) - #define Y_DIR_READ() READ(Y_DIR_PIN) - #else - #define Y_DIR_INIT() NOOP - #define Y_DIR_WRITE(STATE) L64XX_DIR_WRITE(Y, STATE) - #define Y_DIR_READ() (stepper##Y.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_Y(L6470) - #define DISABLE_STEPPER_Y() stepperY.free() - #endif - #endif -#endif - -// Z Stepper -#if AXIS_IS_L64XX(Z) - extern L64XX_CLASS(Z) stepperZ; - #define Z_ENABLE_INIT() NOOP - #define Z_ENABLE_WRITE(STATE) (STATE ? stepperZ.hardStop() : stepperZ.free()) - #define Z_ENABLE_READ() (stepperZ.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_Z(L6474) - #define Z_DIR_INIT() SET_OUTPUT(Z_DIR_PIN) - #define Z_DIR_WRITE(STATE) L6474_DIR_WRITE(Z, STATE) - #define Z_DIR_READ() READ(Z_DIR_PIN) - #else - #define Z_DIR_INIT() NOOP - #define Z_DIR_WRITE(STATE) L64XX_DIR_WRITE(Z, STATE) - #define Z_DIR_READ() (stepper##Z.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_Z(L6470) - #define DISABLE_STEPPER_Z() stepperZ.free() - #endif - #endif -#endif - -// X2 Stepper -#if HAS_X2_ENABLE && AXIS_IS_L64XX(X2) - extern L64XX_CLASS(X2) stepperX2; - #define X2_ENABLE_INIT() NOOP - #define X2_ENABLE_WRITE(STATE) (STATE ? stepperX2.hardStop() : stepperX2.free()) - #define X2_ENABLE_READ() (stepperX2.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_X2(L6474) - #define X2_DIR_INIT() SET_OUTPUT(X2_DIR_PIN) - #define X2_DIR_WRITE(STATE) L6474_DIR_WRITE(X2, STATE) - #define X2_DIR_READ() READ(X2_DIR_PIN) - #else - #define X2_DIR_INIT() NOOP - #define X2_DIR_WRITE(STATE) L64XX_DIR_WRITE(X2, STATE) - #define X2_DIR_READ() (stepper##X2.getStatus() & STATUS_DIR); - #endif -#endif - -#if AXIS_DRIVER_TYPE_X2(L6470) - #define DISABLE_STEPPER_X2() stepperX2.free() -#endif - -// Y2 Stepper -#if HAS_Y2_ENABLE && AXIS_IS_L64XX(Y2) - extern L64XX_CLASS(Y2) stepperY2; - #define Y2_ENABLE_INIT() NOOP - #define Y2_ENABLE_WRITE(STATE) (STATE ? stepperY2.hardStop() : stepperY2.free()) - #define Y2_ENABLE_READ() (stepperY2.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_Y2(L6474) - #define Y2_DIR_INIT() SET_OUTPUT(Y2_DIR_PIN) - #define Y2_DIR_WRITE(STATE) L6474_DIR_WRITE(Y2, STATE) - #define Y2_DIR_READ() READ(Y2_DIR_PIN) - #else - #define Y2_DIR_INIT() NOOP - #define Y2_DIR_WRITE(STATE) L64XX_DIR_WRITE(Y2, STATE) - #define Y2_DIR_READ() (stepper##Y2.getStatus() & STATUS_DIR); - #endif -#endif - -#if AXIS_DRIVER_TYPE_Y2(L6470) - #define DISABLE_STEPPER_Y2() stepperY2.free() -#endif - -// Z2 Stepper -#if HAS_Z2_ENABLE && AXIS_IS_L64XX(Z2) - extern L64XX_CLASS(Z2) stepperZ2; - #define Z2_ENABLE_INIT() NOOP - #define Z2_ENABLE_WRITE(STATE) (STATE ? stepperZ2.hardStop() : stepperZ2.free()) - #define Z2_ENABLE_READ() (stepperZ2.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_Z2(L6474) - #define Z2_DIR_INIT() SET_OUTPUT(Z2_DIR_PIN) - #define Z2_DIR_WRITE(STATE) L6474_DIR_WRITE(Z2, STATE) - #define Z2_DIR_READ() READ(Z2_DIR_PIN) - #else - #define Z2_DIR_INIT() NOOP - #define Z2_DIR_WRITE(STATE) L64XX_DIR_WRITE(Z2, STATE) - #define Z2_DIR_READ() (stepper##Z2.getStatus() & STATUS_DIR); - #endif -#endif - -#if AXIS_DRIVER_TYPE_Z2(L6470) - #define DISABLE_STEPPER_Z2() stepperZ2.free() -#endif - -// Z3 Stepper -#if HAS_Z3_ENABLE && AXIS_IS_L64XX(Z3) - extern L64XX_CLASS(Z3) stepperZ3; - #define Z3_ENABLE_INIT() NOOP - #define Z3_ENABLE_WRITE(STATE) (STATE ? stepperZ3.hardStop() : stepperZ3.free()) - #define Z3_ENABLE_READ() (stepperZ3.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_Z3(L6474) - #define Z3_DIR_INIT() SET_OUTPUT(Z3_DIR_PIN) - #define Z3_DIR_WRITE(STATE) L6474_DIR_WRITE(Z3, STATE) - #define Z3_DIR_READ() READ(Z3_DIR_PIN) - #else - #define Z3_DIR_INIT() NOOP - #define Z3_DIR_WRITE(STATE) L64XX_DIR_WRITE(Z3, STATE) - #define Z3_DIR_READ() (stepper##Z3.getStatus() & STATUS_DIR); - #endif -#endif - -#if AXIS_DRIVER_TYPE_Z3(L6470) - #define DISABLE_STEPPER_Z3() stepperZ3.free() -#endif - -// Z4 Stepper -#if HAS_Z4_ENABLE && AXIS_IS_L64XX(Z4) - extern L64XX_CLASS(Z4) stepperZ4; - #define Z4_ENABLE_INIT() NOOP - #define Z4_ENABLE_WRITE(STATE) (STATE ? stepperZ4.hardStop() : stepperZ4.free()) - #define Z4_ENABLE_READ() (stepperZ4.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_Z4(L6474) - #define Z4_DIR_INIT() SET_OUTPUT(Z4_DIR_PIN) - #define Z4_DIR_WRITE(STATE) L6474_DIR_WRITE(Z4, STATE) - #define Z4_DIR_READ() READ(Z4_DIR_PIN) - #else - #define Z4_DIR_INIT() NOOP - #define Z4_DIR_WRITE(STATE) L64XX_DIR_WRITE(Z4, STATE) - #define Z4_DIR_READ() (stepper##Z4.getStatus() & STATUS_DIR); - #endif -#endif - -#if AXIS_DRIVER_TYPE_Z4(L6470) - #define DISABLE_STEPPER_Z4() stepperZ4.free() -#endif - -// I Stepper -#if AXIS_IS_L64XX(I) - extern L64XX_CLASS(I) stepperI; - #define I_ENABLE_INIT() NOOP - #define I_ENABLE_WRITE(STATE) (STATE ? stepperI.hardStop() : stepperI.free()) - #define I_ENABLE_READ() (stepperI.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_I(L6474) - #define I_DIR_INIT() SET_OUTPUT(I_DIR_PIN) - #define I_DIR_WRITE(STATE) L6474_DIR_WRITE(I, STATE) - #define I_DIR_READ() READ(I_DIR_PIN) - #else - #define I_DIR_INIT() NOOP - #define I_DIR_WRITE(STATE) L64XX_DIR_WRITE(I, STATE) - #define I_DIR_READ() (stepper##I.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_I(L6470) - #define DISABLE_STEPPER_I() stepperI.free() - #endif - #endif -#endif - -// J Stepper -#if AXIS_IS_L64XX(J) - extern L64XX_CLASS(J) stepperJ; - #define J_ENABLE_INIT() NOOP - #define J_ENABLE_WRITE(STATE) (STATE ? stepperJ.hardStop() : stepperJ.free()) - #define J_ENABLE_READ() (stepperJ.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_J(L6474) - #define J_DIR_INIT() SET_OUTPUT(J_DIR_PIN) - #define J_DIR_WRITE(STATE) L6474_DIR_WRITE(J, STATE) - #define J_DIR_READ() READ(J_DIR_PIN) - #else - #define J_DIR_INIT() NOOP - #define J_DIR_WRITE(STATE) L64XX_DIR_WRITE(J, STATE) - #define J_DIR_READ() (stepper##J.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_J(L6470) - #define DISABLE_STEPPER_J() stepperJ.free() - #endif - #endif -#endif - -// K Stepper -#if AXIS_IS_L64XX(K) - extern L64XX_CLASS(K) stepperK; - #define K_ENABLE_INIT() NOOP - #define K_ENABLE_WRITE(STATE) (STATE ? stepperK.hardStop() : stepperK.free()) - #define K_ENABLE_READ() (stepperK.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_K(L6474) - #define K_DIR_INIT() SET_OUTPUT(K_DIR_PIN) - #define K_DIR_WRITE(STATE) L6474_DIR_WRITE(K, STATE) - #define K_DIR_READ() READ(K_DIR_PIN) - #else - #define K_DIR_INIT() NOOP - #define K_DIR_WRITE(STATE) L64XX_DIR_WRITE(K, STATE) - #define K_DIR_READ() (stepper##K.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_K(L6470) - #define DISABLE_STEPPER_K() stepperK.free() - #endif - #endif -#endif - -// U Stepper -#if HAS_U_AXIS - #if AXIS_IS_L64XX(U) - extern L64XX_CLASS(U) stepperU; - #define U_ENABLE_INIT() NOOP - #define U_ENABLE_WRITE(STATE) (STATE ? stepperU.hardStop() : stepperU.free()) - #define U_ENABLE_READ() (stepperU.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_U(L6474) - #define U_DIR_INIT() SET_OUTPUT(U_DIR_PIN) - #define U_DIR_WRITE(STATE) L6474_DIR_WRITE(U, STATE) - #define U_DIR_READ() READ(U_DIR_PIN) - #else - #define U_DIR_INIT() NOOP - #define U_DIR_WRITE(STATE) L64XX_DIR_WRITE(U, STATE) - #define U_DIR_READ() (stepper##U.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_U(L6470) - #define DISABLE_STEPPER_U() stepperU.free() - #endif - #endif - #endif -#endif - -// V Stepper -#if HAS_V_AXIS - #if AXIS_IS_L64XX(V) - extern L64XX_CLASS(V) stepperV; - #define V_ENABLE_INIT() NOOP - #define V_ENABLE_WRITE(STATE) (STATE ? stepperV.hardStop() : stepperV.free()) - #define V_ENABLE_READ() (stepperV.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_V(L6474) - #define V_DIR_INIT() SET_OUTPUT(V_DIR_PIN) - #define V_DIR_WRITE(STATE) L6474_DIR_WRITE(V, STATE) - #define V_DIR_READ() READ(V_DIR_PIN) - #else - #define V_DIR_INIT() NOOP - #define V_DIR_WRITE(STATE) L64XX_DIR_WRITE(V, STATE) - #define V_DIR_READ() (stepper##V.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_V(L6470) - #define DISABLE_STEPPER_V() stepperV.free() - #endif - #endif - #endif -#endif - -// W Stepper -#if HAS_W_AXIS - #if AXIS_IS_L64XX(W) - extern L64XX_CLASS(w) stepperW; - #define W_ENABLE_INIT() NOOP - #define W_ENABLE_WRITE(STATE) (STATE ? stepperW.hardStop() : stepperW.free()) - #define W_ENABLE_READ() (stepperW.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_W(L6474) - #define W_DIR_INIT() SET_OUTPUT(W_DIR_PIN) - #define W_DIR_WRITE(STATE) L6474_DIR_WRITE(W, STATE) - #define W_DIR_READ() READ(W_DIR_PIN) - #else - #define W_DIR_INIT() NOOP - #define W_DIR_WRITE(STATE) L64XX_DIR_WRITE(W, STATE) - #define W_DIR_READ() (stepper##W.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_W(L6470) - #define DISABLE_STEPPER_W() stepperW.free() - #endif - #endif - #endif -#endif - -// E0 Stepper -#if AXIS_IS_L64XX(E0) - extern L64XX_CLASS(E0) stepperE0; - #define E0_ENABLE_INIT() NOOP - #define E0_ENABLE_WRITE(STATE) (STATE ? stepperE0.hardStop() : stepperE0.free()) - #define E0_ENABLE_READ() (stepperE0.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_E0(L6474) - #define E0_DIR_INIT() SET_OUTPUT(E0_DIR_PIN) - #define E0_DIR_WRITE(STATE) L6474_DIR_WRITE(E0, STATE) - #define E0_DIR_READ() READ(E0_DIR_PIN) - #else - #define E0_DIR_INIT() NOOP - #define E0_DIR_WRITE(STATE) L64XX_DIR_WRITE(E0, STATE) - #define E0_DIR_READ() (stepper##E0.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_E0(L6470) - #define DISABLE_STEPPER_E0() do{ stepperE0.free(); }while(0) - #endif - #endif -#endif - -// E1 Stepper -#if AXIS_IS_L64XX(E1) - extern L64XX_CLASS(E1) stepperE1; - #define E1_ENABLE_INIT() NOOP - #define E1_ENABLE_WRITE(STATE) (STATE ? stepperE1.hardStop() : stepperE1.free()) - #define E1_ENABLE_READ() (stepperE1.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_E1(L6474) - #define E1_DIR_INIT() SET_OUTPUT(E1_DIR_PIN) - #define E1_DIR_WRITE(STATE) L6474_DIR_WRITE(E1, STATE) - #define E1_DIR_READ() READ(E1_DIR_PIN) - #else - #define E1_DIR_INIT() NOOP - #define E1_DIR_WRITE(STATE) L64XX_DIR_WRITE(E1, STATE) - #define E1_DIR_READ() (stepper##E1.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_E1(L6470) - #define DISABLE_STEPPER_E1() do{ stepperE1.free(); }while(0) - #endif - #endif -#endif - -// E2 Stepper -#if AXIS_IS_L64XX(E2) - extern L64XX_CLASS(E2) stepperE2; - #define E2_ENABLE_INIT() NOOP - #define E2_ENABLE_WRITE(STATE) (STATE ? stepperE2.hardStop() : stepperE2.free()) - #define E2_ENABLE_READ() (stepperE2.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_E2(L6474) - #define E2_DIR_INIT() SET_OUTPUT(E2_DIR_PIN) - #define E2_DIR_WRITE(STATE) L6474_DIR_WRITE(E2, STATE) - #define E2_DIR_READ() READ(E2_DIR_PIN) - #else - #define E2_DIR_INIT() NOOP - #define E2_DIR_WRITE(STATE) L64XX_DIR_WRITE(E2, STATE) - #define E2_DIR_READ() (stepper##E2.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_E2(L6470) - #define DISABLE_STEPPER_E2() do{ stepperE2.free(); }while(0) - #endif - #endif -#endif - -// E3 Stepper -#if AXIS_IS_L64XX(E3) - extern L64XX_CLASS(E3) stepperE3; - #define E3_ENABLE_INIT() NOOP - #define E3_ENABLE_WRITE(STATE) (STATE ? stepperE3.hardStop() : stepperE3.free()) - #define E3_ENABLE_READ() (stepperE3.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_E3(L6474) - #define E3_DIR_INIT() SET_OUTPUT(E3_DIR_PIN) - #define E3_DIR_WRITE(STATE) L6474_DIR_WRITE(E3, STATE) - #define E3_DIR_READ() READ(E3_DIR_PIN) - #else - #define E3_DIR_INIT() NOOP - #define E3_DIR_WRITE(STATE) L64XX_DIR_WRITE(E3, STATE) - #define E3_DIR_READ() (stepper##E3.getStatus() & STATUS_DIR); - #endif -#endif - -// E4 Stepper -#if AXIS_IS_L64XX(E4) - extern L64XX_CLASS(E4) stepperE4; - #define E4_ENABLE_INIT() NOOP - #define E4_ENABLE_WRITE(STATE) (STATE ? stepperE4.hardStop() : stepperE4.free()) - #define E4_ENABLE_READ() (stepperE4.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_E4(L6474) - #define E4_DIR_INIT() SET_OUTPUT(E4_DIR_PIN) - #define E4_DIR_WRITE(STATE) L6474_DIR_WRITE(E4, STATE) - #define E4_DIR_READ() READ(E4_DIR_PIN) - #else - #define E4_DIR_INIT() NOOP - #define E4_DIR_WRITE(STATE) L64XX_DIR_WRITE(E4, STATE) - #define E4_DIR_READ() (stepper##E4.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_E4(L6470) - #define DISABLE_STEPPER_E4() do{ stepperE4.free(); }while(0) - #endif - #endif -#endif - -// E5 Stepper -#if AXIS_IS_L64XX(E5) - extern L64XX_CLASS(E5) stepperE5; - #define E5_ENABLE_INIT() NOOP - #define E5_ENABLE_WRITE(STATE) (STATE ? stepperE5.hardStop() : stepperE5.free()) - #define E5_ENABLE_READ() (stepperE5.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_E5(L6474) - #define E5_DIR_INIT() SET_OUTPUT(E5_DIR_PIN) - #define E5_DIR_WRITE(STATE) L6474_DIR_WRITE(E5, STATE) - #define E5_DIR_READ() READ(E5_DIR_PIN) - #else - #define E5_DIR_INIT() NOOP - #define E5_DIR_WRITE(STATE) L64XX_DIR_WRITE(E5, STATE) - #define E5_DIR_READ() (stepper##E5.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_E5(L6470) - #define DISABLE_STEPPER_E5() do{ stepperE5.free(); }while(0) - #endif - #endif -#endif - -// E6 Stepper -#if AXIS_IS_L64XX(E6) - extern L64XX_CLASS(E6) stepperE6; - #define E6_ENABLE_INIT() NOOP - #define E6_ENABLE_WRITE(STATE) (STATE ? stepperE6.hardStop() : stepperE6.free()) - #define E6_ENABLE_READ() (stepperE6.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_E6(L6474) - #define E6_DIR_INIT() SET_OUTPUT(E6_DIR_PIN) - #define E6_DIR_WRITE(STATE) L6474_DIR_WRITE(E6, STATE) - #define E6_DIR_READ() READ(E6_DIR_PIN) - #else - #define E6_DIR_INIT() NOOP - #define E6_DIR_WRITE(STATE) L64XX_DIR_WRITE(E6, STATE) - #define E6_DIR_READ() (stepper##E6.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_E6(L6470) - #define DISABLE_STEPPER_E6() do{ stepperE6.free(); }while(0) - #endif - #endif -#endif - -// E7 Stepper -#if AXIS_IS_L64XX(E7) - extern L64XX_CLASS(E7) stepperE7; - #define E7_ENABLE_INIT() NOOP - #define E7_ENABLE_WRITE(STATE) (STATE ? stepperE7.hardStop() : stepperE7.free()) - #define E7_ENABLE_READ() (stepperE7.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_E7(L6474) - #define E7_DIR_INIT() SET_OUTPUT(E7_DIR_PIN) - #define E7_DIR_WRITE(STATE) L6474_DIR_WRITE(E7, STATE) - #define E7_DIR_READ() READ(E7_DIR_PIN) - #else - #define E7_DIR_INIT() NOOP - #define E7_DIR_WRITE(STATE) L64XX_DIR_WRITE(E7, STATE) - #define E7_DIR_READ() (stepper##E7.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_E7(L6470) - #define DISABLE_STEPPER_E7() do{ stepperE7.free(); }while(0) - #endif - #endif -#endif diff --git a/Marlin/src/module/stepper/indirection.cpp b/Marlin/src/module/stepper/indirection.cpp index e44496d022..427fd71cbe 100644 --- a/Marlin/src/module/stepper/indirection.cpp +++ b/Marlin/src/module/stepper/indirection.cpp @@ -38,7 +38,6 @@ void restore_stepper_drivers() { void reset_stepper_drivers() { TERN_(HAS_TMC26X, tmc26x_init_to_defaults()); - TERN_(HAS_L64XX, L64xxManager.init_to_defaults()); TERN_(HAS_TRINAMIC_CONFIG, reset_trinamic_drivers()); } diff --git a/Marlin/src/module/stepper/indirection.h b/Marlin/src/module/stepper/indirection.h index 687a0f2896..e9a9aa7de9 100644 --- a/Marlin/src/module/stepper/indirection.h +++ b/Marlin/src/module/stepper/indirection.h @@ -32,10 +32,6 @@ #include "../../inc/MarlinConfig.h" -#if HAS_L64XX - #include "L64xx.h" -#endif - #if HAS_TMC26X #include "TMC26X.h" #endif @@ -985,7 +981,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #if HAS_Z_AXIS #define ENABLE_AXIS_Z() if (SHOULD_ENABLE(z)) { ENABLE_STEPPER_Z(); ENABLE_STEPPER_Z2(); ENABLE_STEPPER_Z3(); ENABLE_STEPPER_Z4(); AFTER_CHANGE(z, true); } - #define DISABLE_AXIS_Z() if (SHOULD_DISABLE(z)) { DISABLE_STEPPER_Z(); DISABLE_STEPPER_Z2(); DISABLE_STEPPER_Z3(); DISABLE_STEPPER_Z4(); AFTER_CHANGE(z, false); set_axis_untrusted(Z_AXIS); Z_RESET(); } + #define DISABLE_AXIS_Z() if (SHOULD_DISABLE(z)) { DISABLE_STEPPER_Z(); DISABLE_STEPPER_Z2(); DISABLE_STEPPER_Z3(); DISABLE_STEPPER_Z4(); AFTER_CHANGE(z, false); set_axis_untrusted(Z_AXIS); Z_RESET(); TERN_(BD_SENSOR, bdl.config_state = 0); } #else #define ENABLE_AXIS_Z() NOOP #define DISABLE_AXIS_Z() NOOP diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 28a2de188e..34a8d0d17c 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -63,7 +63,7 @@ #include "../feature/host_actions.h" #endif -#if HAS_TEMP_SENSOR +#if EITHER(HAS_TEMP_SENSOR, LASER_FEATURE) #include "../gcode/gcode.h" #endif @@ -77,7 +77,7 @@ // MAX TC related macros #define TEMP_SENSOR_IS_MAX(n, M) (ENABLED(TEMP_SENSOR_##n##_IS_MAX##M) || (ENABLED(TEMP_SENSOR_REDUNDANT_IS_MAX##M) && REDUNDANT_TEMP_MATCH(SOURCE, E##n))) -#define TEMP_SENSOR_IS_ANY_MAX_TC(n) (ENABLED(TEMP_SENSOR_##n##_IS_MAX_TC) || (ENABLED(TEMP_SENSOR_REDUNDANT_IS_MAX_TC) && REDUNDANT_TEMP_MATCH(SOURCE, E##n))) +#define TEMP_SENSOR_IS_ANY_MAX_TC(n) (TEMP_SENSOR_IS_MAX_TC(n) || (TEMP_SENSOR_IS_MAX_TC(REDUNDANT) && REDUNDANT_TEMP_MATCH(SOURCE, E##n))) // LIB_MAX6675 can be added to the build_flags in platformio.ini to use a user-defined library // If LIB_MAX6675 is not on the build_flags then raw SPI reads will be used. @@ -912,7 +912,7 @@ volatile bool Temperature::raw_temps_ready = false; temp_hotend[active_extruder].target = 0.0f; temp_hotend[active_extruder].soft_pwm_amount = 0; #if HAS_FAN - set_fan_speed(ANY(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND) ? 0 : active_extruder, 0); + set_fan_speed(EITHER(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND) ? 0 : active_extruder, 0); planner.sync_fan_speeds(fan_speed); #endif @@ -926,13 +926,13 @@ volatile bool Temperature::raw_temps_ready = false; MPC_t &constants = hotend.constants; // Move to center of bed, just above bed height and cool with max fan + gcode.home_all_axes(true); disable_all_heaters(); #if HAS_FAN zero_fan_speeds(); - set_fan_speed(ANY(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND) ? 0 : active_extruder, 255); + set_fan_speed(EITHER(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND) ? 0 : active_extruder, 255); planner.sync_fan_speeds(fan_speed); #endif - gcode.home_all_axes(true); const xyz_pos_t tuningpos = MPC_TUNING_POS; do_blocking_move_to(tuningpos); @@ -957,7 +957,7 @@ volatile bool Temperature::raw_temps_ready = false; } #if HAS_FAN - set_fan_speed(ANY(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND) ? 0 : active_extruder, 0); + set_fan_speed(EITHER(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND) ? 0 : active_extruder, 0); planner.sync_fan_speeds(fan_speed); #endif @@ -1039,7 +1039,7 @@ volatile bool Temperature::raw_temps_ready = false; total_energy_fan0 += constants.heater_power * hotend.soft_pwm_amount / 127 * MPC_dT + (last_temp - current_temp) * constants.block_heat_capacity; #if HAS_FAN else if (ELAPSED(ms, test_end_ms) && !fan0_done) { - set_fan_speed(ANY(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND) ? 0 : active_extruder, 255); + set_fan_speed(EITHER(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND) ? 0 : active_extruder, 255); planner.sync_fan_speeds(fan_speed); settle_end_ms = ms + settle_time; test_end_ms = settle_end_ms + test_duration; @@ -1233,7 +1233,7 @@ int16_t Temperature::getHeaterPower(const heater_id_t heater_id) { // Temperature Error Handlers // -inline void loud_kill(FSTR_P const lcd_msg, const heater_id_t heater_id, float temp) { +inline void loud_kill(FSTR_P const lcd_msg, const heater_id_t heater_id, float temp) { // @advi3++ marlin_state = MF_KILLED; thermalManager.disable_all_heaters(); #if HAS_BEEPER @@ -1245,13 +1245,14 @@ inline void loud_kill(FSTR_P const lcd_msg, const heater_id_t heater_id, float t } buzzer.on(); #endif - #if ENABLED(NOZZLE_PARK_FEATURE) + // @advi3++ Don't park, the printer will reset before displaying the error + #if ENABLED(NOZZLE_PARK_ON_ERROR) if (!homing_needed_error()) { nozzle.park(0); planner.synchronize(); } #endif - kill(temp, lcd_msg, HEATER_FSTR(heater_id)); + kill(temp, lcd_msg, HEATER_FSTR(heater_id)); // @advi3++ } void Temperature::_temp_error(const heater_id_t heater_id, FSTR_P const serial_msg, FSTR_P const lcd_msg) { @@ -1326,111 +1327,107 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { _temp_error(heater_id, F(STR_T_MINTEMP), GET_TEXT_F(MSG_ERR_MINTEMP)); } -#if ANY(PID_DEBUG, PID_BED_DEBUG, PID_CHAMBER_DEBUG) - bool Temperature::pid_debug_flag; // = 0 +#if HAS_PID_DEBUG + bool Temperature::pid_debug_flag; // = false #endif -#if HAS_HOTEND +#if HAS_PID_HEATING - float Temperature::get_pid_output_hotend(const uint8_t E_NAME) { - const uint8_t ee = HOTEND_INDEX; - #if ENABLED(PIDTEMP) - #if DISABLED(PID_OPENLOOP) - static hotend_pid_t work_pid[HOTENDS]; - static float temp_iState[HOTENDS] = { 0 }, - temp_dState[HOTENDS] = { 0 }; - static Flags pid_reset; - const float pid_error = temp_hotend[ee].target - temp_hotend[ee].celsius; - - float pid_output; - - if (temp_hotend[ee].target == 0 - || pid_error < -(PID_FUNCTIONAL_RANGE) - || TERN0(HEATER_IDLE_HANDLER, heater_idle[ee].timed_out) - ) { - pid_output = 0; - pid_reset.set(ee); + template + class PIDRunner { + public: + TT &tempinfo; + __typeof__(TT::pid) work_pid{0}; + float temp_iState = 0, temp_dState = 0; + bool pid_reset = true; + + PIDRunner(TT &t) : tempinfo(t) { } + + float get_pid_output() { + + #if ENABLED(PID_OPENLOOP) + + return constrain(tempinfo.target, 0, MAX_POW); + + #else // !PID_OPENLOOP + + const float pid_error = tempinfo.target - tempinfo.celsius; + if (!tempinfo.target || pid_error < -(PID_FUNCTIONAL_RANGE)) { + pid_reset = true; + return 0; } else if (pid_error > PID_FUNCTIONAL_RANGE) { - pid_output = PID_MAX; - pid_reset.set(ee); + pid_reset = true; + return MAX_POW; } - else { - if (pid_reset[ee]) { - temp_iState[ee] = 0.0; - work_pid[ee].Kd = 0.0; - pid_reset.clear(ee); - } - work_pid[ee].Kd = work_pid[ee].Kd + PID_K2 * (PID_PARAM(Kd, ee) * (temp_dState[ee] - temp_hotend[ee].celsius) - work_pid[ee].Kd); - const float max_power_over_i_gain = float(PID_MAX) / PID_PARAM(Ki, ee) - float(MIN_POWER); - temp_iState[ee] = constrain(temp_iState[ee] + pid_error, 0, max_power_over_i_gain); - work_pid[ee].Kp = PID_PARAM(Kp, ee) * pid_error; - work_pid[ee].Ki = PID_PARAM(Ki, ee) * temp_iState[ee]; + if (pid_reset) { + pid_reset = false; + temp_iState = 0.0; + work_pid.Kd = 0.0; + } - pid_output = work_pid[ee].Kp + work_pid[ee].Ki + work_pid[ee].Kd + float(MIN_POWER); + const float max_power_over_i_gain = float(MAX_POW) / tempinfo.pid.Ki - float(MIN_POW); + temp_iState = constrain(temp_iState + pid_error, 0, max_power_over_i_gain); - #if ENABLED(PID_EXTRUSION_SCALING) - #if HOTENDS == 1 - constexpr bool this_hotend = true; - #else - const bool this_hotend = (ee == active_extruder); - #endif - work_pid[ee].Kc = 0; - if (this_hotend) { - const long e_position = stepper.position(E_AXIS); - if (e_position > pes_e_position) { - lpq[lpq_ptr] = e_position - pes_e_position; - pes_e_position = e_position; - } - else - lpq[lpq_ptr] = 0; + work_pid.Kp = tempinfo.pid.Kp * pid_error; + work_pid.Ki = tempinfo.pid.Ki * temp_iState; + work_pid.Kd = work_pid.Kd + PID_K2 * (tempinfo.pid.Kd * (temp_dState - tempinfo.celsius) - work_pid.Kd); - if (++lpq_ptr >= lpq_len) lpq_ptr = 0; - work_pid[ee].Kc = (lpq[lpq_ptr] * planner.mm_per_step[E_AXIS]) * PID_PARAM(Kc, ee); - pid_output += work_pid[ee].Kc; - } - #endif // PID_EXTRUSION_SCALING - #if ENABLED(PID_FAN_SCALING) - if (fan_speed[active_extruder] > PID_FAN_SCALING_MIN_SPEED) { - work_pid[ee].Kf = PID_PARAM(Kf, ee) + (PID_FAN_SCALING_LIN_FACTOR) * fan_speed[active_extruder]; - pid_output += work_pid[ee].Kf; - } - //pid_output -= work_pid[ee].Ki; - //pid_output += work_pid[ee].Ki * work_pid[ee].Kf - #endif // PID_FAN_SCALING - LIMIT(pid_output, 0, PID_MAX); - } - temp_dState[ee] = temp_hotend[ee].celsius; + temp_dState = tempinfo.celsius; - #else // PID_OPENLOOP + return constrain(work_pid.Kp + work_pid.Ki + work_pid.Kd + float(MIN_POW), 0, MAX_POW); - const float pid_output = constrain(temp_hotend[ee].target, 0, PID_MAX); + #endif // !PID_OPENLOOP + } - #endif // PID_OPENLOOP + FORCE_INLINE void debug(const_celsius_float_t c, const_float_t pid_out, FSTR_P const name=nullptr, const int8_t index=-1) { + if (TERN0(HAS_PID_DEBUG, thermalManager.pid_debug_flag)) { + SERIAL_ECHO_START(); + if (name) SERIAL_ECHOLNF(name); + if (index >= 0) SERIAL_ECHO(index); + SERIAL_ECHOLNPGM( + STR_PID_DEBUG_INPUT, c, + STR_PID_DEBUG_OUTPUT, pid_out + #if DISABLED(PID_OPENLOOP) + , "pTerm", work_pid.Kp, "iTerm", work_pid.Ki, "dTerm", work_pid.Kd + #endif + ); + } + } + }; + +#endif // HAS_PID_HEATING + +#if HAS_HOTEND + + float Temperature::get_pid_output_hotend(const uint8_t E_NAME) { + const uint8_t ee = HOTEND_INDEX; + + #if ENABLED(PIDTEMP) + + typedef PIDRunner PIDRunnerHotend; + + static PIDRunnerHotend hotend_pid[HOTENDS] = { + #define _HOTENDPID(E) temp_hotend[E], + REPEAT(HOTENDS, _HOTENDPID) + }; + + const float pid_output = hotend_pid[ee].get_pid_output(); #if ENABLED(PID_DEBUG) - if (ee == active_extruder && pid_debug_flag) { - SERIAL_ECHO_MSG(STR_PID_DEBUG, ee, STR_PID_DEBUG_INPUT, temp_hotend[ee].celsius, STR_PID_DEBUG_OUTPUT, pid_output - #if DISABLED(PID_OPENLOOP) - , STR_PID_DEBUG_PTERM, work_pid[ee].Kp - , STR_PID_DEBUG_ITERM, work_pid[ee].Ki - , STR_PID_DEBUG_DTERM, work_pid[ee].Kd - #if ENABLED(PID_EXTRUSION_SCALING) - , STR_PID_DEBUG_CTERM, work_pid[ee].Kc - #endif - #endif - ); - } + if (ee == active_extruder) + hotend_pid[ee].debug(temp_hotend[ee].celsius, pid_output, F("E"), ee); #endif #elif ENABLED(MPCTEMP) + MPCHeaterInfo &hotend = temp_hotend[ee]; MPC_t &constants = hotend.constants; // At startup, initialize modeled temperatures if (isnan(hotend.modeled_block_temp)) { - hotend.modeled_ambient_temp = min(30.0f, hotend.celsius); // Cap initial value at reasonable max room temperature of 30C + hotend.modeled_ambient_temp = _MIN(30.0f, hotend.celsius); // Cap initial value at reasonable max room temperature of 30C hotend.modeled_block_temp = hotend.modeled_sensor_temp = hotend.celsius; } @@ -1442,7 +1439,7 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { float ambient_xfer_coeff = constants.ambient_xfer_coeff_fan0; #if ENABLED(MPC_INCLUDE_FAN) - const uint8_t fan_index = ANY(MPC_FAN_0_ACTIVE_HOTEND, MPC_FAN_0_ALL_HOTENDS) ? 0 : ee; + const uint8_t fan_index = EITHER(MPC_FAN_0_ACTIVE_HOTEND, MPC_FAN_0_ALL_HOTENDS) ? 0 : ee; const float fan_fraction = TERN_(MPC_FAN_0_ACTIVE_HOTEND, !this_hotend ? 0.0f : ) fan_speed[fan_index] * RECIPROCAL(255); ambient_xfer_coeff += fan_fraction * constants.fan255_adjustment; #endif @@ -1476,7 +1473,7 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { // Only correct ambient when close to steady state (output power is not clipped or asymptotic temperature is reached) if (WITHIN(hotend.soft_pwm_amount, 1, 126) || fabs(blocktempdelta + delta_to_apply) < (MPC_STEADYSTATE * MPC_dT)) - hotend.modeled_ambient_temp += delta_to_apply > 0.f ? max(delta_to_apply, MPC_MIN_AMBIENT_CHANGE * MPC_dT) : min(delta_to_apply, -MPC_MIN_AMBIENT_CHANGE * MPC_dT); + hotend.modeled_ambient_temp += delta_to_apply > 0.f ? _MAX(delta_to_apply, MPC_MIN_AMBIENT_CHANGE * MPC_dT) : _MIN(delta_to_apply, -MPC_MIN_AMBIENT_CHANGE * MPC_dT); float power = 0.0; if (hotend.target != 0 && TERN1(HEATER_IDLE_HANDLER, !heater_idle[ee].timed_out)) { @@ -1506,7 +1503,7 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { #else // No PID or MPC enabled const bool is_idling = TERN0(HEATER_IDLE_HANDLER, heater_idle[ee].timed_out); - const float pid_output = (!is_idling && temp_hotend[ee].celsius < temp_hotend[ee].target) ? BANG_MAX : 0; + const float pid_output = (!is_idling && temp_hotend[ee].is_below_target()) ? BANG_MAX : 0; #endif @@ -1518,61 +1515,9 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { #if ENABLED(PIDTEMPBED) float Temperature::get_pid_output_bed() { - - #if DISABLED(PID_OPENLOOP) - - static PID_t work_pid{0}; - static float temp_iState = 0, temp_dState = 0; - static bool pid_reset = true; - float pid_output = 0; - const float max_power_over_i_gain = float(MAX_BED_POWER) / temp_bed.pid.Ki - float(MIN_BED_POWER), - pid_error = temp_bed.target - temp_bed.celsius; - - if (!temp_bed.target || pid_error < -(PID_FUNCTIONAL_RANGE)) { - pid_output = 0; - pid_reset = true; - } - else if (pid_error > PID_FUNCTIONAL_RANGE) { - pid_output = MAX_BED_POWER; - pid_reset = true; - } - else { - if (pid_reset) { - temp_iState = 0.0; - work_pid.Kd = 0.0; - pid_reset = false; - } - - temp_iState = constrain(temp_iState + pid_error, 0, max_power_over_i_gain); - - work_pid.Kp = temp_bed.pid.Kp * pid_error; - work_pid.Ki = temp_bed.pid.Ki * temp_iState; - work_pid.Kd = work_pid.Kd + PID_K2 * (temp_bed.pid.Kd * (temp_dState - temp_bed.celsius) - work_pid.Kd); - - temp_dState = temp_bed.celsius; - - pid_output = constrain(work_pid.Kp + work_pid.Ki + work_pid.Kd + float(MIN_BED_POWER), 0, MAX_BED_POWER); - } - - #else // PID_OPENLOOP - - const float pid_output = constrain(temp_bed.target, 0, MAX_BED_POWER); - - #endif // PID_OPENLOOP - - #if ENABLED(PID_BED_DEBUG) - if (pid_debug_flag) { - SERIAL_ECHO_MSG( - " PID_BED_DEBUG : Input ", temp_bed.celsius, " Output ", pid_output - #if DISABLED(PID_OPENLOOP) - , STR_PID_DEBUG_PTERM, work_pid.Kp - , STR_PID_DEBUG_ITERM, work_pid.Ki - , STR_PID_DEBUG_DTERM, work_pid.Kd - #endif - ); - } - #endif - + static PIDRunner bed_pid(temp_bed); + const float pid_output = bed_pid.get_pid_output(); + TERN_(PID_BED_DEBUG, bed_pid.debug(temp_bed.celsius, pid_output, F("(Bed)"))); return pid_output; } @@ -1581,114 +1526,17 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { #if ENABLED(PIDTEMPCHAMBER) float Temperature::get_pid_output_chamber() { - - #if DISABLED(PID_OPENLOOP) - - static PID_t work_pid{0}; - static float temp_iState = 0, temp_dState = 0; - static bool pid_reset = true; - float pid_output = 0; - const float max_power_over_i_gain = float(MAX_CHAMBER_POWER) / temp_chamber.pid.Ki - float(MIN_CHAMBER_POWER), - pid_error = temp_chamber.target - temp_chamber.celsius; - - if (!temp_chamber.target || pid_error < -(PID_FUNCTIONAL_RANGE)) { - pid_output = 0; - pid_reset = true; - } - else if (pid_error > PID_FUNCTIONAL_RANGE) { - pid_output = MAX_CHAMBER_POWER; - pid_reset = true; - } - else { - if (pid_reset) { - temp_iState = 0.0; - work_pid.Kd = 0.0; - pid_reset = false; - } - - temp_iState = constrain(temp_iState + pid_error, 0, max_power_over_i_gain); - - work_pid.Kp = temp_chamber.pid.Kp * pid_error; - work_pid.Ki = temp_chamber.pid.Ki * temp_iState; - work_pid.Kd = work_pid.Kd + PID_K2 * (temp_chamber.pid.Kd * (temp_dState - temp_chamber.celsius) - work_pid.Kd); - - temp_dState = temp_chamber.celsius; - - pid_output = constrain(work_pid.Kp + work_pid.Ki + work_pid.Kd + float(MIN_CHAMBER_POWER), 0, MAX_CHAMBER_POWER); - } - - #else // PID_OPENLOOP - - const float pid_output = constrain(temp_chamber.target, 0, MAX_CHAMBER_POWER); - - #endif // PID_OPENLOOP - - #if ENABLED(PID_CHAMBER_DEBUG) - { - SERIAL_ECHO_MSG( - " PID_CHAMBER_DEBUG : Input ", temp_chamber.celsius, " Output ", pid_output - #if DISABLED(PID_OPENLOOP) - , STR_PID_DEBUG_PTERM, work_pid.Kp - , STR_PID_DEBUG_ITERM, work_pid.Ki - , STR_PID_DEBUG_DTERM, work_pid.Kd - #endif - ); - } - #endif - + static PIDRunner chamber_pid(temp_chamber); + const float pid_output = chamber_pid.get_pid_output(); + TERN_(PID_CHAMBER_DEBUG, chamber_pid.debug(temp_chamber.celsius, pid_output, F("(Chamber)"))); return pid_output; } #endif // PIDTEMPCHAMBER -/** - * Manage heating activities for extruder hot-ends and a heated bed - * - Acquire updated temperature readings - * - Also resets the watchdog timer - * - Invoke thermal runaway protection - * - Manage extruder auto-fan - * - Apply filament width to the extrusion rate (may move) - * - Update the heated bed PID output value - */ -void Temperature::manage_heater() { - if (marlin_state == MF_INITIALIZING) return hal.watchdog_refresh(); // If Marlin isn't started, at least reset the watchdog! - - static bool no_reentry = false; // Prevent recursion - if (no_reentry) return; - REMEMBER(mh, no_reentry, true); - - #if ENABLED(EMERGENCY_PARSER) - if (emergency_parser.killed_by_M112) kill(NAN, FPSTR(M112_KILL_STR), nullptr, true); - - if (emergency_parser.quickstop_by_M410) { - emergency_parser.quickstop_by_M410 = false; // quickstop_stepper may call idle so clear this now! - quickstop_stepper(); - } - #endif - - if (!updateTemperaturesIfReady()) return; // Will also reset the watchdog if temperatures are ready - - #if DISABLED(IGNORE_THERMOCOUPLE_ERRORS) - #if TEMP_SENSOR_0_IS_MAX_TC - if (degHotend(0) > _MIN(HEATER_0_MAXTEMP, TEMP_SENSOR_0_MAX_TC_TMAX - 1.0)) max_temp_error(H_E0); - if (degHotend(0) < _MAX(HEATER_0_MINTEMP, TEMP_SENSOR_0_MAX_TC_TMIN + .01)) min_temp_error(H_E0); - #endif - #if TEMP_SENSOR_1_IS_MAX_TC - if (degHotend(1) > _MIN(HEATER_1_MAXTEMP, TEMP_SENSOR_1_MAX_TC_TMAX - 1.0)) max_temp_error(H_E1); - if (degHotend(1) < _MAX(HEATER_1_MINTEMP, TEMP_SENSOR_1_MAX_TC_TMIN + .01)) min_temp_error(H_E1); - #endif - #if TEMP_SENSOR_REDUNDANT_IS_MAX_TC - if (degRedundant() > TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX - 1.0) max_temp_error(H_REDUNDANT); - if (degRedundant() < TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN + .01) min_temp_error(H_REDUNDANT); - #endif - #else - #warning "Safety Alert! Disable IGNORE_THERMOCOUPLE_ERRORS for the final build!" - #endif - - millis_t ms = millis(); - - #if HAS_HOTEND +#if HAS_HOTEND + void Temperature::manage_hotends(const millis_t &ms) { HOTEND_LOOP() { #if ENABLED(THERMAL_PROTECTION_HOTENDS) if (degHotend(e) > temp_range[e].maxtemp) max_temp_error((heater_id_t)e); @@ -1716,25 +1564,13 @@ void Temperature::manage_heater() { #endif } // HOTEND_LOOP + } - #endif // HAS_HOTEND - - #if HAS_TEMP_REDUNDANT - // Make sure measured temperatures are close together - if (ABS(degRedundantTarget() - degRedundant()) > TEMP_SENSOR_REDUNDANT_MAX_DIFF) - _temp_error((heater_id_t)HEATER_ID(TEMP_SENSOR_REDUNDANT_TARGET), F(STR_REDUNDANCY), GET_TEXT_F(MSG_ERR_REDUNDANT_TEMP)); - #endif - - // Manage extruder auto fans and/or read fan tachometers - TERN_(HAS_FAN_LOGIC, manage_extruder_fans(ms)); +#endif // HAS_HOTEND - /** - * Dynamically set the volumetric multiplier based - * on the delayed Filament Width measurement. - */ - TERN_(FILAMENT_WIDTH_SENSOR, filwidth.update_volumetric()); +#if HAS_HEATED_BED - #if HAS_HEATED_BED + void Temperature::manage_heated_bed(const millis_t &ms) { #if ENABLED(THERMAL_PROTECTION_BED) if (degBed() > BED_MAXTEMP) max_temp_error(H_BED); @@ -1779,9 +1615,7 @@ void Temperature::manage_heater() { #if HEATER_IDLE_HANDLER if (heater_idle[IDLE_INDEX_BED].timed_out) { temp_bed.soft_pwm_amount = 0; - #if DISABLED(PIDTEMPBED) - WRITE_HEATER_BED(LOW); - #endif + if (DISABLED(PIDTEMPBED)) WRITE_HEATER_BED(LOW); } else #endif @@ -1794,10 +1628,10 @@ void Temperature::manage_heater() { #if ENABLED(BED_LIMIT_SWITCHING) if (temp_bed.celsius >= temp_bed.target + BED_HYSTERESIS) temp_bed.soft_pwm_amount = 0; - else if (temp_bed.celsius <= temp_bed.target - (BED_HYSTERESIS)) + else if (temp_bed.is_below_target(-(BED_HYSTERESIS) + 1)) temp_bed.soft_pwm_amount = MAX_BED_POWER >> 1; #else // !PIDTEMPBED && !BED_LIMIT_SWITCHING - temp_bed.soft_pwm_amount = temp_bed.celsius < temp_bed.target ? MAX_BED_POWER >> 1 : 0; + temp_bed.soft_pwm_amount = temp_bed.is_below_target() ? MAX_BED_POWER >> 1 : 0; #endif } else { @@ -1808,10 +1642,13 @@ void Temperature::manage_heater() { } } while (false); + } - #endif // HAS_HEATED_BED +#endif // HAS_HEATED_BED - #if HAS_HEATED_CHAMBER +#if HAS_HEATED_CHAMBER + + void Temperature::manage_heated_chamber(const millis_t &ms) { #ifndef CHAMBER_CHECK_INTERVAL #define CHAMBER_CHECK_INTERVAL 1000UL @@ -1906,17 +1743,17 @@ void Temperature::manage_heater() { if (flag_chamber_excess_heat) { temp_chamber.soft_pwm_amount = 0; #if ENABLED(CHAMBER_VENT) - if (!flag_chamber_off) servo[CHAMBER_VENT_SERVO_NR].move(temp_chamber.celsius <= temp_chamber.target ? 0 : 90); + if (!flag_chamber_off) servo[CHAMBER_VENT_SERVO_NR].move(temp_chamber.is_below_target() ? 0 : 90); #endif } else { #if ENABLED(CHAMBER_LIMIT_SWITCHING) if (temp_chamber.celsius >= temp_chamber.target + TEMP_CHAMBER_HYSTERESIS) temp_chamber.soft_pwm_amount = 0; - else if (temp_chamber.celsius <= temp_chamber.target - (TEMP_CHAMBER_HYSTERESIS)) + else if (temp_chamber.is_below_target(-(TEMP_CHAMBER_HYSTERESIS) + 1)) temp_chamber.soft_pwm_amount = (MAX_CHAMBER_POWER) >> 1; #else - temp_chamber.soft_pwm_amount = temp_chamber.celsius < temp_chamber.target ? (MAX_CHAMBER_POWER) >> 1 : 0; + temp_chamber.soft_pwm_amount = temp_chamber.is_below_target() ? (MAX_CHAMBER_POWER) >> 1 : 0; #endif #if ENABLED(CHAMBER_VENT) if (!flag_chamber_off) servo[CHAMBER_VENT_SERVO_NR].move(0); @@ -1932,10 +1769,13 @@ void Temperature::manage_heater() { tr_state_machine[RUNAWAY_IND_CHAMBER].run(temp_chamber.celsius, temp_chamber.target, H_CHAMBER, THERMAL_PROTECTION_CHAMBER_PERIOD, THERMAL_PROTECTION_CHAMBER_HYSTERESIS); #endif #endif + } - #endif // HAS_HEATED_CHAMBER +#endif // HAS_HEATED_CHAMBER - #if HAS_COOLER +#if HAS_COOLER + + void Temperature::manage_cooler(const millis_t &ms) { #ifndef COOLER_CHECK_INTERVAL #define COOLER_CHECK_INTERVAL 2000UL @@ -1993,15 +1833,90 @@ void Temperature::manage_heater() { #if ENABLED(THERMAL_PROTECTION_COOLER) tr_state_machine[RUNAWAY_IND_COOLER].run(temp_cooler.celsius, temp_cooler.target, H_COOLER, THERMAL_PROTECTION_COOLER_PERIOD, THERMAL_PROTECTION_COOLER_HYSTERESIS); #endif + } - #endif // HAS_COOLER +#endif // HAS_COOLER + +/** + * Manage heating activities for extruder hot-ends and a heated bed + * - Acquire updated temperature readings + * - Also resets the watchdog timer + * - Invoke thermal runaway protection + * - Manage extruder auto-fan + * - Apply filament width to the extrusion rate (may move) + * - Update the heated bed PID output value + */ +void Temperature::task() { + if (marlin_state == MF_INITIALIZING) return hal.watchdog_refresh(); // If Marlin isn't started, at least reset the watchdog! + + static bool no_reentry = false; // Prevent recursion + if (no_reentry) return; + REMEMBER(mh, no_reentry, true); + + #if ENABLED(EMERGENCY_PARSER) + if (emergency_parser.killed_by_M112) kill(FPSTR(M112_KILL_STR), nullptr, true); + + if (emergency_parser.quickstop_by_M410) { + emergency_parser.quickstop_by_M410 = false; // quickstop_stepper may call idle so clear this now! + quickstop_stepper(); + } + #endif + + if (!updateTemperaturesIfReady()) return; // Will also reset the watchdog if temperatures are ready + + #if DISABLED(IGNORE_THERMOCOUPLE_ERRORS) + #if TEMP_SENSOR_IS_MAX_TC(0) + if (degHotend(0) > _MIN(HEATER_0_MAXTEMP, TEMP_SENSOR_0_MAX_TC_TMAX - 1.0)) max_temp_error(H_E0); + if (degHotend(0) < _MAX(HEATER_0_MINTEMP, TEMP_SENSOR_0_MAX_TC_TMIN + .01)) min_temp_error(H_E0); + #endif + #if TEMP_SENSOR_IS_MAX_TC(1) + if (degHotend(1) > _MIN(HEATER_1_MAXTEMP, TEMP_SENSOR_1_MAX_TC_TMAX - 1.0)) max_temp_error(H_E1); + if (degHotend(1) < _MAX(HEATER_1_MINTEMP, TEMP_SENSOR_1_MAX_TC_TMIN + .01)) min_temp_error(H_E1); + #endif + #if TEMP_SENSOR_IS_MAX_TC(REDUNDANT) + if (degRedundant() > TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX - 1.0) max_temp_error(H_REDUNDANT); + if (degRedundant() < TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN + .01) min_temp_error(H_REDUNDANT); + #endif + #else + #warning "Safety Alert! Disable IGNORE_THERMOCOUPLE_ERRORS for the final build!" + #endif + + const millis_t ms = millis(); + + // Handle Hotend Temp Errors, Heating Watch, etc. + TERN_(HAS_HOTEND, manage_hotends(ms)); + + #if HAS_TEMP_REDUNDANT + // Make sure measured temperatures are close together + if (ABS(degRedundantTarget() - degRedundant()) > TEMP_SENSOR_REDUNDANT_MAX_DIFF) + _temp_error((heater_id_t)HEATER_ID(TEMP_SENSOR_REDUNDANT_TARGET), F(STR_REDUNDANCY), GET_TEXT_F(MSG_ERR_REDUNDANT_TEMP)); + #endif + + // Manage extruder auto fans and/or read fan tachometers + TERN_(HAS_FAN_LOGIC, manage_extruder_fans(ms)); + + /** + * Dynamically set the volumetric multiplier based + * on the delayed Filament Width measurement. + */ + TERN_(FILAMENT_WIDTH_SENSOR, filwidth.update_volumetric()); + + // Handle Bed Temp Errors, Heating Watch, etc. + TERN_(HAS_HEATED_BED, manage_heated_bed(ms)); + + // Handle Heated Chamber Temp Errors, Heating Watch, etc. + TERN_(HAS_HEATED_CHAMBER, manage_heated_chamber(ms)); + + // Handle Cooler Temp Errors, Cooling Watch, etc. + TERN_(HAS_COOLER, manage_cooler(ms)); #if ENABLED(LASER_COOLANT_FLOW_METER) cooler.flowmeter_task(ms); #if ENABLED(FLOWMETER_SAFETY) - if (cutter.enabled() && cooler.check_flow_too_low()) { + if (cooler.check_flow_too_low()) { + TERN_(HAS_DISPLAY, if (cutter.enabled()) ui.flow_fault()); cutter.disable(); - TERN_(HAS_DISPLAY, ui.flow_fault()); + cutter.cutter_mode = CUTTER_MODE_ERROR; // Immediately kill stepper inline power output } #endif #endif @@ -2041,46 +1956,46 @@ void Temperature::manage_heater() { void Temperature::reset_user_thermistors() { user_thermistor_t default_user_thermistor[USER_THERMISTORS] = { #if TEMP_SENSOR_0_IS_CUSTOM - { true, 0, 0, HOTEND0_PULLUP_RESISTOR_OHMS, HOTEND0_RESISTANCE_25C_OHMS, 0, 0, HOTEND0_BETA, 0 }, + { true, HOTEND0_SH_C_COEFF, 0, HOTEND0_PULLUP_RESISTOR_OHMS, HOTEND0_RESISTANCE_25C_OHMS, 0, 0, HOTEND0_BETA, 0 }, #endif #if TEMP_SENSOR_1_IS_CUSTOM - { true, 0, 0, HOTEND1_PULLUP_RESISTOR_OHMS, HOTEND1_RESISTANCE_25C_OHMS, 0, 0, HOTEND1_BETA, 0 }, + { true, HOTEND1_SH_C_COEFF, 0, HOTEND1_PULLUP_RESISTOR_OHMS, HOTEND1_RESISTANCE_25C_OHMS, 0, 0, HOTEND1_BETA, 0 }, #endif #if TEMP_SENSOR_2_IS_CUSTOM - { true, 0, 0, HOTEND2_PULLUP_RESISTOR_OHMS, HOTEND2_RESISTANCE_25C_OHMS, 0, 0, HOTEND2_BETA, 0 }, + { true, HOTEND2_SH_C_COEFF, 0, HOTEND2_PULLUP_RESISTOR_OHMS, HOTEND2_RESISTANCE_25C_OHMS, 0, 0, HOTEND2_BETA, 0 }, #endif #if TEMP_SENSOR_3_IS_CUSTOM - { true, 0, 0, HOTEND3_PULLUP_RESISTOR_OHMS, HOTEND3_RESISTANCE_25C_OHMS, 0, 0, HOTEND3_BETA, 0 }, + { true, HOTEND3_SH_C_COEFF, 0, HOTEND3_PULLUP_RESISTOR_OHMS, HOTEND3_RESISTANCE_25C_OHMS, 0, 0, HOTEND3_BETA, 0 }, #endif #if TEMP_SENSOR_4_IS_CUSTOM - { true, 0, 0, HOTEND4_PULLUP_RESISTOR_OHMS, HOTEND4_RESISTANCE_25C_OHMS, 0, 0, HOTEND4_BETA, 0 }, + { true, HOTEND4_SH_C_COEFF, 0, HOTEND4_PULLUP_RESISTOR_OHMS, HOTEND4_RESISTANCE_25C_OHMS, 0, 0, HOTEND4_BETA, 0 }, #endif #if TEMP_SENSOR_5_IS_CUSTOM - { true, 0, 0, HOTEND5_PULLUP_RESISTOR_OHMS, HOTEND5_RESISTANCE_25C_OHMS, 0, 0, HOTEND5_BETA, 0 }, + { true, HOTEND5_SH_C_COEFF, 0, HOTEND5_PULLUP_RESISTOR_OHMS, HOTEND5_RESISTANCE_25C_OHMS, 0, 0, HOTEND5_BETA, 0 }, #endif #if TEMP_SENSOR_6_IS_CUSTOM - { true, 0, 0, HOTEND6_PULLUP_RESISTOR_OHMS, HOTEND6_RESISTANCE_25C_OHMS, 0, 0, HOTEND6_BETA, 0 }, + { true, HOTEND6_SH_C_COEFF, 0, HOTEND6_PULLUP_RESISTOR_OHMS, HOTEND6_RESISTANCE_25C_OHMS, 0, 0, HOTEND6_BETA, 0 }, #endif #if TEMP_SENSOR_7_IS_CUSTOM - { true, 0, 0, HOTEND7_PULLUP_RESISTOR_OHMS, HOTEND7_RESISTANCE_25C_OHMS, 0, 0, HOTEND7_BETA, 0 }, + { true, HOTEND7_SH_C_COEFF, 0, HOTEND7_PULLUP_RESISTOR_OHMS, HOTEND7_RESISTANCE_25C_OHMS, 0, 0, HOTEND7_BETA, 0 }, #endif #if TEMP_SENSOR_BED_IS_CUSTOM - { true, 0, 0, BED_PULLUP_RESISTOR_OHMS, BED_RESISTANCE_25C_OHMS, 0, 0, BED_BETA, 0 }, + { true, BED_SH_C_COEFF, 0, BED_PULLUP_RESISTOR_OHMS, BED_RESISTANCE_25C_OHMS, 0, 0, BED_BETA, 0 }, #endif #if TEMP_SENSOR_CHAMBER_IS_CUSTOM - { true, 0, 0, CHAMBER_PULLUP_RESISTOR_OHMS, CHAMBER_RESISTANCE_25C_OHMS, 0, 0, CHAMBER_BETA, 0 }, + { true, CHAMBER_SH_C_COEFF, 0, CHAMBER_PULLUP_RESISTOR_OHMS, CHAMBER_RESISTANCE_25C_OHMS, 0, 0, CHAMBER_BETA, 0 }, #endif #if TEMP_SENSOR_COOLER_IS_CUSTOM - { true, 0, 0, COOLER_PULLUP_RESISTOR_OHMS, COOLER_RESISTANCE_25C_OHMS, 0, 0, COOLER_BETA, 0 }, + { true, COOLER_SH_C_COEFF, 0, COOLER_PULLUP_RESISTOR_OHMS, COOLER_RESISTANCE_25C_OHMS, 0, 0, COOLER_BETA, 0 }, #endif #if TEMP_SENSOR_PROBE_IS_CUSTOM - { true, 0, 0, PROBE_PULLUP_RESISTOR_OHMS, PROBE_RESISTANCE_25C_OHMS, 0, 0, PROBE_BETA, 0 }, + { true, PROBE_SH_C_COEFF, 0, PROBE_PULLUP_RESISTOR_OHMS, PROBE_RESISTANCE_25C_OHMS, 0, 0, PROBE_BETA, 0 }, #endif #if TEMP_SENSOR_BOARD_IS_CUSTOM - { true, 0, 0, BOARD_PULLUP_RESISTOR_OHMS, BOARD_RESISTANCE_25C_OHMS, 0, 0, BOARD_BETA, 0 }, + { true, BOARD_SH_C_COEFF, 0, BOARD_PULLUP_RESISTOR_OHMS, BOARD_RESISTANCE_25C_OHMS, 0, 0, BOARD_BETA, 0 }, #endif #if TEMP_SENSOR_REDUNDANT_IS_CUSTOM - { true, 0, 0, REDUNDANT_PULLUP_RESISTOR_OHMS, REDUNDANT_RESISTANCE_25C_OHMS, 0, 0, REDUNDANT_BETA, 0 }, + { true, REDUNDANT_SH_C_COEFF, 0, REDUNDANT_PULLUP_RESISTOR_OHMS, REDUNDANT_RESISTANCE_25C_OHMS, 0, 0, REDUNDANT_BETA, 0 }, #endif }; COPY(user_thermistor, default_user_thermistor); @@ -2166,7 +2081,7 @@ void Temperature::manage_heater() { case 0: #if TEMP_SENSOR_0_IS_CUSTOM return user_thermistor_to_deg_c(CTI_HOTEND_0, raw); - #elif TEMP_SENSOR_0_IS_MAX_TC + #elif TEMP_SENSOR_IS_MAX_TC(0) #if TEMP_SENSOR_0_IS_MAX31865 return TERN(LIB_INTERNAL_MAX31865, max31865_0.temperature(raw), @@ -2185,7 +2100,7 @@ void Temperature::manage_heater() { case 1: #if TEMP_SENSOR_1_IS_CUSTOM return user_thermistor_to_deg_c(CTI_HOTEND_1, raw); - #elif TEMP_SENSOR_1_IS_MAX_TC + #elif TEMP_SENSOR_IS_MAX_TC(1) #if TEMP_SENSOR_0_IS_MAX31865 return TERN(LIB_INTERNAL_MAX31865, max31865_1.temperature(raw), @@ -2369,9 +2284,9 @@ void Temperature::manage_heater() { celsius_float_t Temperature::analog_to_celsius_redundant(const raw_adc_t raw) { #if TEMP_SENSOR_REDUNDANT_IS_CUSTOM return user_thermistor_to_deg_c(CTI_REDUNDANT, raw); - #elif TEMP_SENSOR_REDUNDANT_IS_MAX_TC && REDUNDANT_TEMP_MATCH(SOURCE, E0) + #elif TEMP_SENSOR_IS_MAX_TC(REDUNDANT) && REDUNDANT_TEMP_MATCH(SOURCE, E0) return TERN(TEMP_SENSOR_REDUNDANT_IS_MAX31865, max31865_0.temperature(raw), (int16_t)raw * 0.25); - #elif TEMP_SENSOR_REDUNDANT_IS_MAX_TC && REDUNDANT_TEMP_MATCH(SOURCE, E1) + #elif TEMP_SENSOR_IS_MAX_TC(REDUNDANT) && REDUNDANT_TEMP_MATCH(SOURCE, E1) return TERN(TEMP_SENSOR_REDUNDANT_IS_MAX31865, max31865_1.temperature(raw), (int16_t)raw * 0.25); #elif TEMP_SENSOR_REDUNDANT_IS_THERMISTOR SCAN_THERMISTOR_TABLE(TEMPTABLE_REDUNDANT, TEMPTABLE_REDUNDANT_LEN); @@ -2402,9 +2317,15 @@ void Temperature::updateTemperaturesFromRawValues() { hal.watchdog_refresh(); // Reset because raw_temps_ready was set by the interrupt - TERN_(TEMP_SENSOR_0_IS_MAX_TC, temp_hotend[0].setraw(READ_MAX_TC(0))); - TERN_(TEMP_SENSOR_1_IS_MAX_TC, temp_hotend[1].setraw(READ_MAX_TC(1))); - TERN_(TEMP_SENSOR_REDUNDANT_IS_MAX_TC, temp_redundant.setraw(READ_MAX_TC(HEATER_ID(TEMP_SENSOR_REDUNDANT_SOURCE)))); + #if TEMP_SENSOR_IS_MAX_TC(0) + temp_hotend[0].setraw(READ_MAX_TC(0)); + #endif + #if TEMP_SENSOR_IS_MAX_TC(1) + temp_hotend[1].setraw(READ_MAX_TC(1)); + #endif + #if TEMP_SENSOR_IS_MAX_TC(REDUNDANT) + temp_redundant.setraw(READ_MAX_TC(HEATER_ID(TEMP_SENSOR_REDUNDANT_SOURCE))); + #endif #if HAS_HOTEND HOTEND_LOOP() temp_hotend[e].celsius = analog_to_celsius_hotend(temp_hotend[e].getraw(), e); @@ -2488,7 +2409,7 @@ void Temperature::updateTemperaturesFromRawValues() { /** * Initialize the temperature manager * - * The manager is implemented by periodic calls to manage_heater() + * The manager is implemented by periodic calls to task() * * - Init (and disable) SPI thermocouples like MAX6675 and MAX31865 * - Disable RUMBA JTAG to accommodate a thermocouple extension @@ -3120,7 +3041,7 @@ void Temperature::disable_all_heaters() { static millis_t next_max_tc_ms[MAX_TC_COUNT] = { 0 }; // Return last-read value between readings - millis_t ms = millis(); + const millis_t ms = millis(); if (PENDING(ms, next_max_tc_ms[hindex])) return THERMO_TEMP(hindex); @@ -3233,15 +3154,15 @@ void Temperature::disable_all_heaters() { void Temperature::update_raw_temperatures() { // TODO: can this be collapsed into a HOTEND_LOOP()? - #if HAS_TEMP_ADC_0 && !TEMP_SENSOR_0_IS_MAX_TC + #if HAS_TEMP_ADC_0 && !TEMP_SENSOR_IS_MAX_TC(0) temp_hotend[0].update(); #endif - #if HAS_TEMP_ADC_1 && !TEMP_SENSOR_1_IS_MAX_TC + #if HAS_TEMP_ADC_1 && !TEMP_SENSOR_IS_MAX_TC(1) temp_hotend[1].update(); #endif - #if HAS_TEMP_ADC_REDUNDANT && !TEMP_SENSOR_REDUNDANT_IS_MAX_TC + #if HAS_TEMP_ADC_REDUNDANT && !TEMP_SENSOR_IS_MAX_TC(REDUNDANT) temp_redundant.update(); #endif @@ -3428,16 +3349,18 @@ void Temperature::isr() { _PWM_MOD(COOLER, soft_pwm_cooler, temp_cooler); #endif - #if BOTH(USE_CONTROLLER_FAN, FAN_SOFT_PWM) - WRITE(CONTROLLER_FAN_PIN, soft_pwm_controller.add(pwm_mask, soft_pwm_controller_speed)); - #endif - #if ENABLED(FAN_SOFT_PWM) + + #if ENABLED(USE_CONTROLLER_FAN) + WRITE(CONTROLLER_FAN_PIN, soft_pwm_controller.add(pwm_mask, soft_pwm_controller_speed)); + #endif + #define _FAN_PWM(N) do{ \ uint8_t &spcf = soft_pwm_count_fan[N]; \ spcf = (spcf & pwm_mask) + (soft_pwm_amount_fan[N] >> 1); \ WRITE_FAN(N, spcf > pwm_mask ? HIGH : LOW); \ }while(0) + #if HAS_FAN0 _FAN_PWM(0); #endif diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index c11c9d76de..f6cf81b8a9 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -232,6 +232,7 @@ typedef struct TempInfo { typedef struct HeaterInfo : public TempInfo { celsius_t target; uint8_t soft_pwm_amount; + bool is_below_target(const celsius_t offs=0) const { return (celsius < (target + offs)); } } heater_info_t; // A heater with PID stabilization @@ -715,9 +716,9 @@ class Temperature { static void readings_ready(); /** - * Call periodically to manage heaters + * Call periodically to manage heaters and keep the watchdog fed */ - static void manage_heater() __O2; // __O2 added to work around a compiler error + static void task(); /** * Preheating hotends @@ -807,6 +808,8 @@ class Temperature { #endif } + static void manage_hotends(const millis_t &ms); + #endif // HAS_HOTEND #if HAS_HEATED_BED @@ -819,6 +822,9 @@ class Temperature { static celsius_t degTargetBed() { return temp_bed.target; } static bool isHeatingBed() { return temp_bed.target > temp_bed.celsius; } static bool isCoolingBed() { return temp_bed.target < temp_bed.celsius; } + static bool degBedNear(const celsius_t temp) { + return ABS(wholeDegBed() - temp) < (TEMP_BED_HYSTERESIS); + } // Start watching the Bed to make sure it's really heating up static void start_watching_bed() { TERN_(WATCH_BED, watch_bed.restart(degBed(), degTargetBed())); } @@ -835,9 +841,7 @@ class Temperature { static void wait_for_bed_heating(); - static bool degBedNear(const celsius_t temp) { - return ABS(wholeDegBed() - temp) < (TEMP_BED_HYSTERESIS); - } + static void manage_heated_bed(const millis_t &ms); #endif // HAS_HEATED_BED @@ -863,6 +867,7 @@ class Temperature { static bool isHeatingChamber() { return temp_chamber.target > temp_chamber.celsius; } static bool isCoolingChamber() { return temp_chamber.target < temp_chamber.celsius; } static bool wait_for_chamber(const bool no_wait_for_cooling=true); + static void manage_heated_chamber(const millis_t &ms); #endif #endif @@ -886,6 +891,7 @@ class Temperature { static bool isLaserHeating() { return temp_cooler.target > temp_cooler.celsius; } static bool isLaserCooling() { return temp_cooler.target < temp_cooler.celsius; } static bool wait_for_cooler(const bool no_wait_for_cooling=true); + static void manage_cooler(const millis_t &ms); #endif #endif @@ -947,7 +953,7 @@ class Temperature { */ #if HAS_PID_HEATING - #if ANY(PID_DEBUG, PID_BED_DEBUG, PID_CHAMBER_DEBUG) + #if HAS_PID_DEBUG static bool pid_debug_flag; #endif @@ -1010,7 +1016,7 @@ class Temperature { static void set_heating_message(const uint8_t, const bool=false) {} #endif - #if HAS_MARLINUI_MENU && HAS_TEMPERATURE + #if HAS_MARLINUI_MENU && HAS_TEMPERATURE && HAS_PREHEAT static void lcd_preheat(const uint8_t e, const int8_t indh, const int8_t indb); #endif @@ -1029,7 +1035,7 @@ class Temperature { // MAX Thermocouples #if HAS_MAX_TC - #define MAX_TC_COUNT COUNT_ENABLED(TEMP_SENSOR_0_IS_MAX_TC, TEMP_SENSOR_1_IS_MAX_TC, TEMP_SENSOR_REDUNDANT_IS_MAX_TC) + #define MAX_TC_COUNT TEMP_SENSOR_IS_MAX_TC(0) + TEMP_SENSOR_IS_MAX_TC(1) + TEMP_SENSOR_IS_MAX_TC(REDUNDANT) #if MAX_TC_COUNT > 1 #define HAS_MULTI_MAX_TC 1 #define READ_MAX_TC(N) read_max_tc(N) diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 4b292c92f9..dbd95121dc 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -132,7 +132,7 @@ constexpr int16_t sns_angles[2] = SWITCHING_NOZZLE_SERVO_ANGLES; planner.synchronize(); servo[sns_index[e]].move(sns_angles[angle_index]); - safe_delay(500); + safe_delay(SWITCHING_NOZZLE_SERVO_DWELL); } void lower_nozzle(const uint8_t e) { _move_nozzle_servo(e, 0); } @@ -143,7 +143,7 @@ void move_nozzle_servo(const uint8_t angle_index) { planner.synchronize(); servo[SWITCHING_NOZZLE_SERVO_NR].move(servo_angles[SWITCHING_NOZZLE_SERVO_NR][angle_index]); - safe_delay(500); + safe_delay(SWITCHING_NOZZLE_SERVO_DWELL); } #endif diff --git a/Marlin/src/pins/advi3pp/pins_ADVI3PP.h b/Marlin/src/pins/advi3pp/pins_ADVI3PP.h index bba6fa0ba4..14215bf5bc 100644 --- a/Marlin/src/pins/advi3pp/pins_ADVI3PP.h +++ b/Marlin/src/pins/advi3pp/pins_ADVI3PP.h @@ -96,17 +96,27 @@ #define FAN_PIN 5 // PE3 / PWM5 +// +// Filament Runout sensor +// #define FIL_RUNOUT_PIN 36 // PC1 / A9 // -// Misc. Functions +// SD card // -#define SDSS 53 // PB0 / SS -#define LED_PIN 13 // PB7 / PWM13 - +#define SD_DETECT_PIN 49 // PL0 #define SD_MISO_PIN 50 // PB3 #define SD_MOSI_PIN 51 // PB2 #define SD_SCK_PIN 52 // PB1 +#define SD_SS_PIN 53 // PB0 / SS +#define SDSS SD_SS_PIN + +// +// Misc. Functions +// +#define LED_PIN 13 // PB7 / PWM13 + + /** diff --git a/Marlin/src/pins/esp32/pins_MKS_TINYBEE.h b/Marlin/src/pins/esp32/pins_MKS_TINYBEE.h index 3d5e3964f4..04210bb234 100644 --- a/Marlin/src/pins/esp32/pins_MKS_TINYBEE.h +++ b/Marlin/src/pins/esp32/pins_MKS_TINYBEE.h @@ -115,76 +115,76 @@ // // ADC Reference Voltage // -#define ADC_REFERENCE_VOLTAGE 2.5 // 2.5V reference VDDA +#define ADC_REFERENCE_VOLTAGE 2.565 // 2.5V reference VDDA /** * ------ ------ - * (BEEPER) 149 |10 9 | 13 (BTN_ENC) (SPI MISO) 19 |10 9 | 18 (SPI SCK) - * (LCD_EN) 21 | 8 7 | 4 (LCD_RS) (BTN_EN1) 14 | 8 7 | 5 (SPI CS) - * (LCD_D4) 0 6 5 | 16 (LCD_D5) (BTN_EN2) 12 6 5 | 23 (SPI MOSI) - * (LCD_D6) 15 | 4 3 | 17 (LCD_D7) (SPI_DET) 34 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | 3.3V + * (BEEPER) 149 | 1 2 | 13 (BTN_ENC) (SPI MISO) 19 | 1 2 | 18 (SPI SCK) + * (LCD_EN) 21 | 3 4 | 4 (LCD_RS) (BTN_EN1) 14 | 3 4 | 5 (SPI CS) + * (LCD_D4) 0 5 6 | 16 (LCD_D5) (BTN_EN2) 12 5 6 | 23 (SPI MOSI) + * (LCD_D6) 15 | 7 8 | 17 (LCD_D7) (SPI_DET) 34 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | 3.3V * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN 17 -#define EXP1_04_PIN 15 -#define EXP1_05_PIN 16 -#define EXP1_06_PIN 0 -#define EXP1_07_PIN 4 -#define EXP1_08_PIN 21 -#define EXP1_09_PIN 13 -#define EXP1_10_PIN 149 - -#define EXP2_03_PIN -1 // RESET -#define EXP2_04_PIN 34 -#define EXP2_05_PIN 23 -#define EXP2_06_PIN 12 -#define EXP2_07_PIN 5 -#define EXP2_08_PIN 14 -#define EXP2_09_PIN 18 -#define EXP2_10_PIN 19 +#define EXP1_01_PIN 149 +#define EXP1_02_PIN 13 +#define EXP1_03_PIN 21 +#define EXP1_04_PIN 4 +#define EXP1_05_PIN 0 +#define EXP1_06_PIN 16 +#define EXP1_07_PIN 15 +#define EXP1_08_PIN 17 + +#define EXP2_01_PIN 19 +#define EXP2_02_PIN 18 +#define EXP2_03_PIN 14 +#define EXP2_04_PIN 5 +#define EXP2_05_PIN 12 +#define EXP2_06_PIN 23 +#define EXP2_07_PIN 34 +#define EXP2_08_PIN -1 // RESET // // MicroSD card // -//#define SD_MOSI_PIN EXP2_05_PIN // uses esp32 default 23 -//#define SD_MISO_PIN EXP2_10_PIN // uses esp32 default 19 -//#define SD_SCK_PIN EXP2_09_PIN // uses esp32 default 18 -#define SDSS EXP2_07_PIN -#define SD_DETECT_PIN EXP2_04_PIN // IO34 default is SD_DET signal (Jump to SDDET) +//#define SD_MOSI_PIN EXP2_06_PIN // uses esp32 default 23 +//#define SD_MISO_PIN EXP2_01_PIN // uses esp32 default 19 +//#define SD_SCK_PIN EXP2_02_PIN // uses esp32 default 18 +#define SDSS EXP2_04_PIN +#define SD_DETECT_PIN EXP2_07_PIN // IO34 default is SD_DET signal (Jump to SDDET) #define USES_SHARED_SPI // SPI is shared by SD card with TMC SPI drivers #if HAS_WIRED_LCD - #define BEEPER_PIN EXP1_10_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_RS EXP1_07_PIN - #define BTN_ENC EXP1_09_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define BEEPER_PIN EXP1_01_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_RS EXP1_04_PIN + #define BTN_ENC EXP1_02_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN #define LCD_BACKLIGHT_PIN -1 #if ENABLED(MKS_MINI_12864) // MKS MINI12864 and MKS LCD12864B; If using MKS LCD12864A (Need to remove RPK2 resistor) - #define DOGLCD_CS EXP1_05_PIN - #define DOGLCD_A0 EXP1_04_PIN + #define DOGLCD_CS EXP1_06_PIN + #define DOGLCD_A0 EXP1_07_PIN #define LCD_RESET_PIN -1 #elif ENABLED(FYSETC_MINI_12864_2_1) // MKS_MINI_12864_V3, BTT_MINI_12864_V1, FYSETC_MINI_12864_2_1 - #define DOGLCD_CS EXP1_08_PIN - #define DOGLCD_A0 EXP1_07_PIN - #define LCD_RESET_PIN EXP1_06_PIN - #define NEOPIXEL_PIN EXP1_05_PIN + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN + #define LCD_RESET_PIN EXP1_05_PIN + #define NEOPIXEL_PIN EXP1_06_PIN #if SD_CONNECTION_IS(ONBOARD) #define FORCE_SOFT_SPI #endif #else - #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_D4 EXP1_05_PIN #if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN #endif #define BOARD_ST7920_DELAY_1 96 #define BOARD_ST7920_DELAY_2 48 diff --git a/Marlin/src/pins/esp32/pins_PANDA_common.h b/Marlin/src/pins/esp32/pins_PANDA_common.h index 7deeca3f62..afc9a78aec 100644 --- a/Marlin/src/pins/esp32/pins_PANDA_common.h +++ b/Marlin/src/pins/esp32/pins_PANDA_common.h @@ -82,47 +82,47 @@ #endif /** ------ ------ - * (MISO 19?) |10 9 | (18 SCK?) (BEEPER) 129 |10 9 | 12 (^ENC) - * (EN1) 33 | 8 7 | (5 SDSS?) (EN) 26 | 8 7 | 27 (RS) - * (EN2) 32 6 5 | (23 MOSI?) (D4) 14 | 6 5 -- - * (SDDET 2?) | 4 3 | (RESET) -- | 4 3 | -- - * -- | 2 1 | -- (GND) | 2 1 | (5V) + * (MISO 19?) | 1 2 | (18 SCK?) (BEEPER) 129 | 1 2 | 12 (^ENC) + * (EN1) 33 | 3 4 | (5 SDSS?) (EN) 26 | 3 4 | 27 (RS) + * (EN2) 32 5 6 | (23 MOSI?) (D4) 14 | 5 6 -- + * (SDDET 2?) | 7 8 | (RESET) -- | 7 8 | -- + * -- | 9 10 | -- (GND) | 9 10 | (5V) * ------ ------ * EXP2 EXP1 */ -#define EXP1_06_PIN 14 -#define EXP1_07_PIN 27 -#define EXP1_08_PIN 26 -#define EXP1_09_PIN 12 -#define EXP1_10_PIN 129 - -#define EXP2_04_PIN 2 // ? -#define EXP2_05_PIN 23 // ? -#define EXP2_06_PIN 32 -#define EXP2_07_PIN 5 // ? -#define EXP2_08_PIN 33 -#define EXP2_09_PIN 18 // ? -#define EXP2_10_PIN 19 // ? +#define EXP1_01_PIN 129 +#define EXP1_02_PIN 12 +#define EXP1_03_PIN 26 +#define EXP1_04_PIN 27 +#define EXP1_05_PIN 14 + +#define EXP2_01_PIN 19 // ? +#define EXP2_02_PIN 18 // ? +#define EXP2_03_PIN 33 +#define EXP2_04_PIN 5 // ? +#define EXP2_05_PIN 32 +#define EXP2_06_PIN 23 // ? +#define EXP2_07_PIN 2 // ? // // SD Card // #if ENABLED(SDSUPPORT) - #define SD_MOSI_PIN EXP2_05_PIN - #define SD_MISO_PIN EXP2_10_PIN - #define SD_SCK_PIN EXP2_09_PIN - #define SDSS EXP2_07_PIN - #define SD_DETECT_PIN EXP2_04_PIN + #define SD_MOSI_PIN EXP2_06_PIN + #define SD_MISO_PIN EXP2_01_PIN + #define SD_SCK_PIN EXP2_02_PIN + #define SDSS EXP2_04_PIN + #define SD_DETECT_PIN EXP2_07_PIN #endif #if HAS_WIRED_LCD - #define BEEPER_PIN EXP1_10_PIN + #define BEEPER_PIN EXP1_01_PIN - #define BTN_ENC EXP1_09_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define BTN_ENC EXP1_02_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN - #define LCD_PINS_RS EXP1_07_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN #endif diff --git a/Marlin/src/pins/linux/pins_RAMPS_LINUX.h b/Marlin/src/pins/linux/pins_RAMPS_LINUX.h index 7953f678fa..9e2eedd68e 100644 --- a/Marlin/src/pins/linux/pins_RAMPS_LINUX.h +++ b/Marlin/src/pins/linux/pins_RAMPS_LINUX.h @@ -582,7 +582,7 @@ #define LCD_SDSS SDSS #define SD_DETECT_PIN 49 - #elif ANY(VIKI2, miniVIKI) + #elif EITHER(VIKI2, miniVIKI) #define DOGLCD_CS 45 #define DOGLCD_A0 44 diff --git a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_1.h b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_1.h index f0f57c63ee..d11224315b 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_1.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_1.h @@ -58,31 +58,31 @@ /** ------ ------ - * 1.30 |10 9 | 2.11 0.17 |10 9 | 0.15 - * 0.18 | 8 7 | 0.16 3.26 | 8 7 | 1.23 - * 0.15 6 5 | -- 3.25 6 5 | 0.18 - * -- | 4 3 | -- 1.31 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | -- + * 1.30 | 1 2 | 2.11 0.17 | 1 2 | 0.15 + * 0.18 | 3 4 | 0.16 3.26 | 3 4 | 1.23 + * 0.15 5 6 | -- 3.25 5 6 | 0.18 + * -- | 7 8 | -- 1.31 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN -1 // NC -#define EXP1_04_PIN -1 // NC -#define EXP1_05_PIN -1 // NC -#define EXP1_06_PIN P0_15 -#define EXP1_07_PIN P0_16 -#define EXP1_08_PIN P0_18 -#define EXP1_09_PIN P2_11 -#define EXP1_10_PIN P1_30 - -#define EXP2_03_PIN -1 // RESET -#define EXP2_04_PIN P1_31 -#define EXP2_05_PIN P0_18 -#define EXP2_06_PIN P3_25 -#define EXP2_07_PIN P1_23 -#define EXP2_08_PIN P3_26 -#define EXP2_09_PIN P0_15 -#define EXP2_10_PIN P0_17 +#define EXP1_01_PIN P1_30 +#define EXP1_02_PIN P2_11 +#define EXP1_03_PIN P0_18 +#define EXP1_04_PIN P0_16 +#define EXP1_05_PIN P0_15 +#define EXP1_06_PIN -1 // NC +#define EXP1_07_PIN -1 // NC +#define EXP1_08_PIN -1 // NC + +#define EXP2_01_PIN P0_17 +#define EXP2_02_PIN P0_15 +#define EXP2_03_PIN P3_26 +#define EXP2_04_PIN P1_23 +#define EXP2_05_PIN P3_25 +#define EXP2_06_PIN P0_18 +#define EXP2_07_PIN P1_31 +#define EXP2_08_PIN -1 // RESET /** * LCD / Controller @@ -100,23 +100,23 @@ #if IS_TFTGLCD_PANEL #if ENABLED(TFTGLCD_PANEL_SPI) - #define TFTGLCD_CS EXP2_08_PIN + #define TFTGLCD_CS EXP2_03_PIN #endif #elif HAS_WIRED_LCD - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN - #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + #define BTN_ENC EXP1_02_PIN - #define LCD_SDSS EXP2_07_PIN - #define LCD_PINS_RS EXP1_07_PIN - #define LCD_PINS_ENABLE EXP2_05_PIN - #define LCD_PINS_D4 EXP2_09_PIN + #define LCD_SDSS EXP2_04_PIN + #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_ENABLE EXP2_06_PIN + #define LCD_PINS_D4 EXP2_02_PIN #if ENABLED(MKS_MINI_12864) #define DOGLCD_CS P2_06 - #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_A0 EXP1_04_PIN #endif #endif // HAS_WIRED_LCD @@ -165,10 +165,10 @@ // When using any TMC SPI-based drivers, software SPI is used // because pins may be shared with the display or SD card. #define TMC_USE_SW_SPI - #define TMC_SW_MOSI EXP2_05_PIN - #define TMC_SW_MISO EXP2_10_PIN + #define TMC_SW_MOSI EXP2_06_PIN + #define TMC_SW_MISO EXP2_01_PIN // To minimize pin usage use the same clock pin as the display/SD card reader. (May generate LCD noise.) - #define TMC_SW_SCK EXP2_09_PIN + #define TMC_SW_SCK EXP2_02_PIN // If pin 2_06 is unused, it can be used for the clock to avoid the LCD noise. //#define TMC_SW_SCK P2_06 @@ -211,11 +211,11 @@ // SDCARD_CONNECTION must not be 'LCD'. Nothing should be connected to EXP1/EXP2. //#define SKR_USE_LCD_PINS_FOR_CS #if ENABLED(SKR_USE_LCD_PINS_FOR_CS) - #define X_CS_PIN EXP2_07_PIN - #define Y_CS_PIN EXP2_08_PIN - #define Z_CS_PIN EXP1_09_PIN - #define E0_CS_PIN EXP2_06_PIN - #define E1_CS_PIN EXP2_04_PIN + #define X_CS_PIN EXP2_04_PIN + #define Y_CS_PIN EXP2_03_PIN + #define Z_CS_PIN EXP1_02_PIN + #define E0_CS_PIN EXP2_05_PIN + #define E1_CS_PIN EXP2_07_PIN #endif // Example 2: A REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER @@ -228,11 +228,11 @@ #define Z_CS_PIN P2_06 // We use SD_DETECT_PIN for E0 #undef SD_DETECT_PIN - #define E0_CS_PIN EXP2_04_PIN + #define E0_CS_PIN EXP2_07_PIN // We use LCD_SDSS pin for E1 #undef LCD_SDSS #define LCD_SDSS -1 - #define E1_CS_PIN EXP2_07_PIN + #define E1_CS_PIN EXP2_04_PIN #endif // Example 3: Use the driver enable pins for chip-select. diff --git a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h index 4ab5b10937..031a42f798 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h @@ -191,31 +191,31 @@ /** * ------ ------ - * (BEEPER) 1.30 |10 9 | 0.28 (BTN_ENC) (MISO) 0.17 |10 9 | 0.15 (SCK) - * (LCD_EN) 1.18 | 8 7 | 1.19 (LCD_RS) (BTN_EN1) 3.26 | 8 7 | 0.16 (SD_SS) - * (LCD_D4) 1.20 6 5 | 1.21 (LCD_D5) (BTN_EN2) 3.25 6 5 | 0.18 (MOSI) - * (LCD_D6) 1.22 | 4 3 | 1.23 (LCD_D7) (SD_DETECT) 1.31 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | -- + * (BEEPER) 1.30 | 1 2 | 0.28 (BTN_ENC) (MISO) 0.17 | 1 2 | 0.15 (SCK) + * (LCD_EN) 1.18 | 3 4 | 1.19 (LCD_RS) (BTN_EN1) 3.26 | 3 4 | 0.16 (SD_SS) + * (LCD_D4) 1.20 5 6 | 1.21 (LCD_D5) (BTN_EN2) 3.25 5 6 | 0.18 (MOSI) + * (LCD_D6) 1.22 | 7 8 | 1.23 (LCD_D7) (SD_DETECT) 1.31 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN P1_23 -#define EXP1_04_PIN P1_22 -#define EXP1_05_PIN P1_21 -#define EXP1_06_PIN P1_20 -#define EXP1_07_PIN P1_19 -#define EXP1_08_PIN P1_18 -#define EXP1_09_PIN P0_28 -#define EXP1_10_PIN P1_30 - -#define EXP2_03_PIN -1 -#define EXP2_04_PIN P1_31 -#define EXP2_05_PIN P0_18 -#define EXP2_06_PIN P3_25 -#define EXP2_07_PIN P0_16 -#define EXP2_08_PIN P3_26 -#define EXP2_09_PIN P0_15 -#define EXP2_10_PIN P0_17 +#define EXP1_01_PIN P1_30 +#define EXP1_02_PIN P0_28 +#define EXP1_03_PIN P1_18 +#define EXP1_04_PIN P1_19 +#define EXP1_05_PIN P1_20 +#define EXP1_06_PIN P1_21 +#define EXP1_07_PIN P1_22 +#define EXP1_08_PIN P1_23 + +#define EXP2_01_PIN P0_17 +#define EXP2_02_PIN P0_15 +#define EXP2_03_PIN P3_26 +#define EXP2_04_PIN P0_16 +#define EXP2_05_PIN P3_25 +#define EXP2_06_PIN P0_18 +#define EXP2_07_PIN P1_31 +#define EXP2_08_PIN -1 #if HAS_WIRED_LCD #if ENABLED(ANET_FULL_GRAPHICS_LCD_ALT_WIRING) @@ -239,23 +239,23 @@ * * BEFORE AFTER * ------ ------ - * (CLK) |10 9 | (BEEPER) (BEEPER) |10 9 | -- - * -- | 8 7 | (BTN_ENC) (BTN_ENC) | 8 7 | (CLK) - * (SID) 6 5 | (BTN_EN1) (BTN_EN1) 6 5 | (SID) - * (CS) | 4 3 | (BTN_EN2) (BTN_EN2) | 4 3 | (CS) - * GND | 2 1 | 5V GND | 2 1 | 5V + * (CLK) | 1 2 | (BEEPER) (BEEPER) |10 9 | -- + * -- | 3 4 | (BTN_ENC) (BTN_ENC) | 8 7 | (CLK) + * (SID) 5 6 | (BTN_EN1) (BTN_EN1) 6 5 | (SID) + * (CS) | 7 8 | (BTN_EN2) (BTN_EN2) | 4 3 | (CS) + * GND | 9 10 | 5V GND | 2 1 | 5V * ------ ------ * LCD LCD */ - #define LCD_PINS_RS EXP1_03_PIN + #define LCD_PINS_RS EXP1_08_PIN - #define BTN_EN1 EXP1_06_PIN - #define BTN_EN2 EXP1_04_PIN - #define BTN_ENC EXP1_08_PIN + #define BTN_EN1 EXP1_05_PIN + #define BTN_EN2 EXP1_07_PIN + #define BTN_ENC EXP1_03_PIN - #define LCD_PINS_ENABLE EXP1_05_PIN - #define LCD_PINS_D4 EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_06_PIN + #define LCD_PINS_D4 EXP1_04_PIN #elif ENABLED(WYH_L12864) @@ -274,33 +274,33 @@ * * BEFORE AFTER * ______ ______ - * |10 9 | (MOSI) (MOSI) |10 9 | -- - * (BTN_ENC) | 8 7 | (SCK) (BTN_ENC) | 8 7 | (SCK) - * (BTN_EN1) 6 5 | (SID) (BTN_EN1) 6 5 | (SID) - * (BTN_EN2) | 4 3 | (CS) (BTN_EN2) | 4 3 | (CS) - * 5V | 2 1 | GND GND | 2 1 | 5V + * | 1 2 | (MOSI) (MOSI) |10 9 | -- + * (BTN_ENC) | 3 4 | (SCK) (BTN_ENC) | 8 7 | (SCK) + * (BTN_EN1) 5 6 | (SID) (BTN_EN1) 6 5 | (SID) + * (BTN_EN2) | 7 8 | (CS) (BTN_EN2) | 4 3 | (CS) + * 5V | 9 10 | GND GND | 2 1 | 5V * ------ ------ * LCD LCD */ - #define BTN_EN1 EXP1_06_PIN - #define BTN_EN2 EXP1_04_PIN - #define BTN_ENC EXP1_08_PIN - #define DOGLCD_CS EXP1_03_PIN - #define DOGLCD_A0 EXP1_05_PIN - #define DOGLCD_SCK EXP1_07_PIN - #define DOGLCD_MOSI EXP1_10_PIN + #define BTN_EN1 EXP1_05_PIN + #define BTN_EN2 EXP1_07_PIN + #define BTN_ENC EXP1_03_PIN + #define DOGLCD_CS EXP1_08_PIN + #define DOGLCD_A0 EXP1_06_PIN + #define DOGLCD_SCK EXP1_04_PIN + #define DOGLCD_MOSI EXP1_01_PIN #define LCD_BACKLIGHT_PIN -1 #elif ENABLED(CR10_STOCKDISPLAY) - #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_RS EXP1_07_PIN - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_PIN - #define BTN_ENC EXP1_09_PIN // (58) open-drain + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + #define BTN_ENC EXP1_02_PIN // (58) open-drain - #define LCD_PINS_ENABLE EXP1_03_PIN - #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN #elif HAS_ADC_BUTTONS @@ -308,20 +308,20 @@ #elif HAS_SPI_TFT // Config for Classic UI (emulated DOGM) and Color UI - #define TFT_A0_PIN EXP1_03_PIN - #define TFT_DC_PIN EXP1_03_PIN - #define TFT_CS_PIN EXP1_04_PIN - #define TFT_RESET_PIN EXP1_07_PIN - #define TFT_BACKLIGHT_PIN EXP1_08_PIN + #define TFT_A0_PIN EXP1_08_PIN + #define TFT_DC_PIN EXP1_08_PIN + #define TFT_CS_PIN EXP1_07_PIN + #define TFT_RESET_PIN EXP1_04_PIN + #define TFT_BACKLIGHT_PIN EXP1_03_PIN - //#define TFT_RST_PIN EXP2_04_PIN - #define TFT_MOSI_PIN EXP2_05_PIN - #define TFT_SCK_PIN EXP2_09_PIN - #define TFT_MISO_PIN EXP2_10_PIN + //#define TFT_RST_PIN EXP2_07_PIN + #define TFT_MOSI_PIN EXP2_06_PIN + #define TFT_SCK_PIN EXP2_02_PIN + #define TFT_MISO_PIN EXP2_01_PIN - #define BTN_EN2 EXP2_06_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_ENC EXP1_09_PIN + #define BTN_EN2 EXP2_05_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_ENC EXP1_02_PIN #define TOUCH_BUTTONS_HW_SPI #define TOUCH_BUTTONS_HW_SPI_DEVICE 1 @@ -369,90 +369,90 @@ #elif IS_TFTGLCD_PANEL #if ENABLED(TFTGLCD_PANEL_SPI) - #define TFTGLCD_CS EXP2_08_PIN + #define TFTGLCD_CS EXP2_03_PIN #endif - #define SD_DETECT_PIN EXP2_04_PIN + #define SD_DETECT_PIN EXP2_07_PIN #else // !CR10_STOCKDISPLAY - #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_RS EXP1_04_PIN - #define BTN_EN1 EXP2_08_PIN // (31) J3-2 & AUX-4 - #define BTN_EN2 EXP2_06_PIN // (33) J3-4 & AUX-4 - #define BTN_ENC EXP1_09_PIN // (58) open-drain + #define BTN_EN1 EXP2_03_PIN // (31) J3-2 & AUX-4 + #define BTN_EN2 EXP2_05_PIN // (33) J3-4 & AUX-4 + #define BTN_ENC EXP1_02_PIN // (58) open-drain - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN - #define LCD_SDSS EXP2_07_PIN // (16) J3-7 & AUX-4 - #define SD_DETECT_PIN EXP2_04_PIN // (49) (NOT 5V tolerant) + #define LCD_SDSS EXP2_04_PIN // (16) J3-7 & AUX-4 + #define SD_DETECT_PIN EXP2_07_PIN // (49) (NOT 5V tolerant) #if ENABLED(FYSETC_MINI_12864) - #define DOGLCD_CS EXP1_08_PIN - #define DOGLCD_A0 EXP1_07_PIN - #define DOGLCD_SCK EXP2_09_PIN - #define DOGLCD_MOSI EXP2_05_PIN + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN + #define DOGLCD_SCK EXP2_02_PIN + #define DOGLCD_MOSI EXP2_06_PIN #define LCD_BACKLIGHT_PIN -1 #define FORCE_SOFT_SPI // Use this if default of hardware SPI causes display problems // results in LCD soft SPI mode 3, SD soft SPI mode 0 - #define LCD_RESET_PIN EXP1_06_PIN // Must be high or open for LCD to operate normally. + #define LCD_RESET_PIN EXP1_05_PIN // Must be high or open for LCD to operate normally. #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) #ifndef RGB_LED_R_PIN - #define RGB_LED_R_PIN EXP1_05_PIN + #define RGB_LED_R_PIN EXP1_06_PIN #endif #ifndef RGB_LED_G_PIN - #define RGB_LED_G_PIN EXP1_04_PIN + #define RGB_LED_G_PIN EXP1_07_PIN #endif #ifndef RGB_LED_B_PIN - #define RGB_LED_B_PIN EXP1_03_PIN + #define RGB_LED_B_PIN EXP1_08_PIN #endif #elif ENABLED(FYSETC_MINI_12864_2_1) - #define NEOPIXEL_PIN EXP1_05_PIN + #define NEOPIXEL_PIN EXP1_06_PIN #endif #else // !FYSETC_MINI_12864 #if ENABLED(MKS_MINI_12864) - #define DOGLCD_CS EXP1_05_PIN - #define DOGLCD_A0 EXP1_04_PIN - #define DOGLCD_SCK EXP2_09_PIN - #define DOGLCD_MOSI EXP2_05_PIN + #define DOGLCD_CS EXP1_06_PIN + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_SCK EXP2_02_PIN + #define DOGLCD_MOSI EXP2_06_PIN #elif ENABLED(ENDER2_STOCKDISPLAY) /** * Creality Ender-2 display pinout * ------ - * (SCK) P1_30 |10 9 | P0_28 (BTN_ENC) - * (BTN_EN1) P1_18 | 8 7 | P1_19 (RESET) - * (BTN_EN2) P1_20 6 5 | P1_21 (LCD_A0) - * (LCD_CS) P1_22 | 4 3 | P1_23 (MOSI) - * GND | 2 1 | 5V + * (SCK) P1_30 | 1 2 | P0_28 (BTN_ENC) + * (BTN_EN1) P1_18 | 3 4 | P1_19 (RESET) + * (BTN_EN2) P1_20 5 6 | P1_21 (LCD_A0) + * (LCD_CS) P1_22 | 7 8 | P1_23 (MOSI) + * GND | 9 10 | 5V * ------ * EXP1 */ - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_PIN - #define BTN_ENC EXP1_09_PIN - #define DOGLCD_CS EXP1_04_PIN - #define DOGLCD_A0 EXP1_05_PIN - #define DOGLCD_SCK EXP1_10_PIN - #define DOGLCD_MOSI EXP1_03_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + #define BTN_ENC EXP1_02_PIN + #define DOGLCD_CS EXP1_07_PIN + #define DOGLCD_A0 EXP1_06_PIN + #define DOGLCD_SCK EXP1_01_PIN + #define DOGLCD_MOSI EXP1_08_PIN #define FORCE_SOFT_SPI #define LCD_BACKLIGHT_PIN -1 #endif #if IS_ULTIPANEL - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder @@ -467,11 +467,11 @@ #endif // HAS_WIRED_LCD #if NEED_TOUCH_PINS - #define TOUCH_CS_PIN EXP1_06_PIN - #define TOUCH_SCK_PIN EXP2_09_PIN - #define TOUCH_MOSI_PIN EXP2_05_PIN - #define TOUCH_MISO_PIN EXP2_10_PIN - #define TOUCH_INT_PIN EXP1_05_PIN + #define TOUCH_CS_PIN EXP1_05_PIN + #define TOUCH_SCK_PIN EXP2_02_PIN + #define TOUCH_MOSI_PIN EXP2_06_PIN + #define TOUCH_MISO_PIN EXP2_01_PIN + #define TOUCH_INT_PIN EXP1_06_PIN #endif /** diff --git a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h index b50e8e5780..209529cbe1 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h @@ -246,41 +246,41 @@ #endif /** ------ ------ - * 1.30 |10 9 | 0.28 0.17 |10 9 | 0.15 - * 1.18 | 8 7 | 1.19 3.26 | 8 7 | 0.16 - * 1.20 6 5 | 1.21 3.25 6 5 | 0.18 - * 1.22 | 4 3 | 1.23 1.31 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | -- + * 1.30 | 1 2 | 0.28 0.17 | 1 2 | 0.15 + * 1.18 | 3 4 | 1.19 3.26 | 3 4 | 0.16 + * 1.20 5 6 | 1.21 3.25 5 6 | 0.18 + * 1.22 | 7 8 | 1.23 1.31 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN P1_23 -#define EXP1_04_PIN P1_22 -#define EXP1_05_PIN P1_21 -#define EXP1_06_PIN P1_20 -#define EXP1_07_PIN P1_19 -#define EXP1_08_PIN P1_18 -#define EXP1_09_PIN P0_28 -#define EXP1_10_PIN P1_30 - -#define EXP2_03_PIN -1 // RESET -#define EXP2_04_PIN P1_31 -#define EXP2_05_PIN P0_18 -#define EXP2_06_PIN P3_25 -#define EXP2_07_PIN P0_16 -#define EXP2_08_PIN P3_26 -#define EXP2_09_PIN P0_15 -#define EXP2_10_PIN P0_17 +#define EXP1_01_PIN P1_30 +#define EXP1_02_PIN P0_28 +#define EXP1_03_PIN P1_18 +#define EXP1_04_PIN P1_19 +#define EXP1_05_PIN P1_20 +#define EXP1_06_PIN P1_21 +#define EXP1_07_PIN P1_22 +#define EXP1_08_PIN P1_23 + +#define EXP2_01_PIN P0_17 +#define EXP2_02_PIN P0_15 +#define EXP2_03_PIN P3_26 +#define EXP2_04_PIN P0_16 +#define EXP2_05_PIN P3_25 +#define EXP2_06_PIN P0_18 +#define EXP2_07_PIN P1_31 +#define EXP2_08_PIN -1 // RESET #if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI // RET6 DWIN ENCODER LCD - #define BTN_ENC EXP1_06_PIN - #define BTN_EN1 EXP1_03_PIN - #define BTN_EN2 EXP1_04_PIN + #define BTN_ENC EXP1_05_PIN + #define BTN_EN1 EXP1_08_PIN + #define BTN_EN2 EXP1_07_PIN #ifndef BEEPER_PIN - #define BEEPER_PIN EXP1_05_PIN + #define BEEPER_PIN EXP1_06_PIN #endif #elif HAS_WIRED_LCD @@ -300,24 +300,24 @@ * * BEFORE AFTER * ------ ------ - * (BEEPER) | 10 9 | (CLK) (BEEPER) | 10 9 | (CLK) - * (BTN_ENC) | 8 7 | -- (BTN_ENC) | 8 7 | -- - * (BTN_EN1) 6 5 | (SID) (BTN_EN1) 6 5 | (SID) - * (BTN_EN2) | 4 3 | (CS) (BTN_EN2) | 4 3 | (CS) - * 5V | 2 1 | GND GND | 2 1 | 5V + * (BEEPER) | 1 2 | (CLK) (BEEPER) |10 9 | (CLK) + * (BTN_ENC) | 3 4 | -- (BTN_ENC) | 8 7 | -- + * (BTN_EN1) 5 6 | (SID) (BTN_EN1) 6 5 | (SID) + * (BTN_EN2) | 7 8 | (CS) (BTN_EN2) | 4 3 | (CS) + * 5V | 9 10 | GND GND | 2 1 | 5V * ------ ------ * LCD LCD */ - #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_RS EXP1_04_PIN - #define BTN_EN1 EXP1_05_PIN - #define BTN_EN2 EXP1_04_PIN - #define BTN_ENC EXP1_10_PIN + #define BTN_EN1 EXP1_06_PIN + #define BTN_EN2 EXP1_07_PIN + #define BTN_ENC EXP1_01_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN - #define BEEPER_PIN EXP1_03_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN + #define BEEPER_PIN EXP1_08_PIN #elif ENABLED(ANET_FULL_GRAPHICS_LCD) #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING @@ -336,147 +336,147 @@ * * BEFORE AFTER * ------ ------ - * (BEEPER) |10 9 | (CLK) (BEEPER) |10 9 | -- - * (BTN_ENC) | 8 7 | -- (BTN_ENC) | 8 7 | (CLK) - * (BTN_EN1) 6 5 | (SID) (BTN_EN1) 6 5 | (SID) - * (BTN_EN2) | 4 3 | (CS) (BTN_EN2) | 4 3 | (CS) - * 5V | 2 1 | GND GND | 2 1 | 5V + * (BEEPER) | 1 2 | (CLK) (BEEPER) |10 9 | -- + * (BTN_ENC) | 3 4 | -- (BTN_ENC) | 8 7 | (CLK) + * (BTN_EN1) 5 6 | (SID) (BTN_EN1) 6 5 | (SID) + * (BTN_EN2) | 7 8 | (CS) (BTN_EN2) | 4 3 | (CS) + * 5V | 9 10 | GND GND | 2 1 | 5V * ------ ------ * LCD LCD */ - #define LCD_PINS_RS EXP1_03_PIN + #define LCD_PINS_RS EXP1_08_PIN - #define BTN_EN1 EXP1_06_PIN - #define BTN_EN2 EXP1_04_PIN - #define BTN_ENC EXP1_08_PIN + #define BTN_EN1 EXP1_05_PIN + #define BTN_EN2 EXP1_07_PIN + #define BTN_ENC EXP1_03_PIN - #define LCD_PINS_ENABLE EXP1_05_PIN - #define LCD_PINS_D4 EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_06_PIN + #define LCD_PINS_D4 EXP1_04_PIN - #define BEEPER_PIN EXP1_10_PIN + #define BEEPER_PIN EXP1_01_PIN #elif ENABLED(CR10_STOCKDISPLAY) - #define BTN_ENC EXP1_09_PIN // (58) open-drain - #define LCD_PINS_RS EXP1_04_PIN + #define BTN_ENC EXP1_02_PIN // (58) open-drain + #define LCD_PINS_RS EXP1_07_PIN - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN - #define LCD_PINS_ENABLE EXP1_03_PIN - #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN #elif ENABLED(ENDER2_STOCKDISPLAY) /** Creality Ender-2 display pinout * ------ - * (SCK) 1.30 |10 9 | 0.28 (BTN_ENC) - * (BTN_EN1) 1.18 | 8 7 | 1.19 (RESET) - * (BTN_EN2) 1.20 6 5 | 1.21 (LCD_A0) - * (LCD_RS) 1.22 | 4 3 | 1.23 (MOSI) - * GND | 2 1 | 5V + * (SCK) 1.30 | 1 2 | 0.28 (BTN_ENC) + * (BTN_EN1) 1.18 | 3 4 | 1.19 (RESET) + * (BTN_EN2) 1.20 5 6 | 1.21 (LCD_A0) + * (LCD_RS) 1.22 | 7 8 | 1.23 (MOSI) + * GND | 9 10 | 5V * ------ * EXP1 */ - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_PIN - #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + #define BTN_ENC EXP1_02_PIN - #define DOGLCD_CS EXP1_04_PIN - #define DOGLCD_A0 EXP1_05_PIN - #define DOGLCD_SCK EXP1_10_PIN - #define DOGLCD_MOSI EXP1_03_PIN + #define DOGLCD_CS EXP1_07_PIN + #define DOGLCD_A0 EXP1_06_PIN + #define DOGLCD_SCK EXP1_01_PIN + #define DOGLCD_MOSI EXP1_08_PIN #define FORCE_SOFT_SPI #define LCD_BACKLIGHT_PIN -1 #elif HAS_SPI_TFT // Config for Classic UI (emulated DOGM) and Color UI - #define TFT_CS_PIN EXP1_04_PIN - #define TFT_A0_PIN EXP1_03_PIN - #define TFT_DC_PIN EXP1_03_PIN - #define TFT_MISO_PIN EXP2_10_PIN - #define TFT_BACKLIGHT_PIN EXP1_08_PIN - #define TFT_RESET_PIN EXP1_07_PIN + #define TFT_CS_PIN EXP1_07_PIN + #define TFT_A0_PIN EXP1_08_PIN + #define TFT_DC_PIN EXP1_08_PIN + #define TFT_MISO_PIN EXP2_01_PIN + #define TFT_BACKLIGHT_PIN EXP1_03_PIN + #define TFT_RESET_PIN EXP1_04_PIN #define LCD_USE_DMA_SPI - #define TOUCH_INT_PIN EXP1_05_PIN - #define TOUCH_CS_PIN EXP1_06_PIN + #define TOUCH_INT_PIN EXP1_06_PIN + #define TOUCH_CS_PIN EXP1_05_PIN #define TOUCH_BUTTONS_HW_SPI #define TOUCH_BUTTONS_HW_SPI_DEVICE 1 // SPI 1 - #define SD_SCK_PIN EXP2_09_PIN - #define SD_MISO_PIN EXP2_10_PIN - #define SD_MOSI_PIN EXP2_05_PIN + #define SD_SCK_PIN EXP2_02_PIN + #define SD_MISO_PIN EXP2_01_PIN + #define SD_MOSI_PIN EXP2_06_PIN #define TFT_BUFFER_SIZE 2400 #elif IS_TFTGLCD_PANEL #if ENABLED(TFTGLCD_PANEL_SPI) - #define TFTGLCD_CS EXP2_08_PIN + #define TFTGLCD_CS EXP2_03_PIN #endif - #define SD_DETECT_PIN EXP2_04_PIN + #define SD_DETECT_PIN EXP2_07_PIN #else - #define BTN_ENC EXP1_09_PIN // (58) open-drain - #define LCD_PINS_RS EXP1_07_PIN + #define BTN_ENC EXP1_02_PIN // (58) open-drain + #define LCD_PINS_RS EXP1_04_PIN - #define BTN_EN1 EXP2_08_PIN // (31) J3-2 & AUX-4 - #define BTN_EN2 EXP2_06_PIN // (33) J3-4 & AUX-4 + #define BTN_EN1 EXP2_03_PIN // (31) J3-2 & AUX-4 + #define BTN_EN2 EXP2_05_PIN // (33) J3-4 & AUX-4 - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN - #define LCD_SDSS EXP2_07_PIN // (16) J3-7 & AUX-4 + #define LCD_SDSS EXP2_04_PIN // (16) J3-7 & AUX-4 #if ENABLED(FYSETC_MINI_12864) - #define DOGLCD_CS EXP1_08_PIN - #define DOGLCD_A0 EXP1_07_PIN - #define DOGLCD_SCK EXP2_09_PIN - #define DOGLCD_MOSI EXP2_05_PIN + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN + #define DOGLCD_SCK EXP2_02_PIN + #define DOGLCD_MOSI EXP2_06_PIN #define LCD_BACKLIGHT_PIN -1 #define FORCE_SOFT_SPI // Use this if default of hardware SPI causes display problems // results in LCD soft SPI mode 3, SD soft SPI mode 0 - #define LCD_RESET_PIN EXP1_06_PIN // Must be high or open for LCD to operate normally. + #define LCD_RESET_PIN EXP1_05_PIN // Must be high or open for LCD to operate normally. #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) #ifndef RGB_LED_R_PIN - #define RGB_LED_R_PIN EXP1_05_PIN + #define RGB_LED_R_PIN EXP1_06_PIN #endif #ifndef RGB_LED_G_PIN - #define RGB_LED_G_PIN EXP1_04_PIN + #define RGB_LED_G_PIN EXP1_07_PIN #endif #ifndef RGB_LED_B_PIN - #define RGB_LED_B_PIN EXP1_03_PIN + #define RGB_LED_B_PIN EXP1_08_PIN #endif #elif ENABLED(FYSETC_MINI_12864_2_1) - #define NEOPIXEL_PIN EXP1_05_PIN + #define NEOPIXEL_PIN EXP1_06_PIN #endif #else // !FYSETC_MINI_12864 #if ENABLED(MKS_MINI_12864) - #define DOGLCD_CS EXP1_05_PIN - #define DOGLCD_A0 EXP1_04_PIN - #define DOGLCD_SCK EXP2_09_PIN - #define DOGLCD_MOSI EXP2_05_PIN + #define DOGLCD_CS EXP1_06_PIN + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_SCK EXP2_02_PIN + #define DOGLCD_MOSI EXP2_06_PIN #define FORCE_SOFT_SPI #endif #if IS_ULTIPANEL - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) - #define BTN_ENC_EN EXP1_03_PIN // Detect the presence of the encoder + #define BTN_ENC_EN EXP1_08_PIN // Detect the presence of the encoder #endif #endif diff --git a/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h b/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h index 37d0cb7fb1..ec74cc640e 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h @@ -134,8 +134,8 @@ #define SD_SCK_PIN P0_15 #define SD_MISO_PIN P0_17 #define SD_MOSI_PIN P0_18 - #define SD_SS_PIN EXP2_07_PIN - #define SD_DETECT_PIN EXP2_04_PIN + #define SD_SS_PIN EXP2_04_PIN + #define SD_DETECT_PIN EXP2_07_PIN #elif SD_CONNECTION_IS(ONBOARD) #undef SD_DETECT_PIN @@ -152,11 +152,11 @@ #if ENABLED(BTT_MOTOR_EXPANSION) /** * ------ ------ - * (M3STP) |10 9 | (M3DIR) (M3DIAG) |10 9 | (M3RX) - * (M2STP) | 8 7 | (M2DIR) (M2DIAG) | 8 7 | (M2RX) - * (M1DIR) 6 5 | (M1STP) (M1DIAG) 6 5 | (M1RX) - * (M1EN) | 4 3 | -- (M3EN) | 4 3 | (M2EN) - * GND | 2 1 | -- GND | 2 1 | -- + * (M3STP) | 1 2 | (M3DIR) (M3DIAG) | 1 2 | (M3RX) + * (M2STP) | 3 4 | (M2DIR) (M2DIAG) | 3 4 | (M2RX) + * (M1DIR) 5 6 | (M1STP) (M1DIAG) 5 6 | (M1RX) + * (M1EN) | 7 8 | -- (M3EN) | 7 8 | (M2EN) + * GND | 9 10 | -- GND | 9 10 | -- * ------ ------ * EXP2 EXP1 * @@ -164,46 +164,46 @@ */ // M1 on Driver Expansion Module - #define E2_STEP_PIN EXP2_05_PIN - #define E2_DIR_PIN EXP2_06_PIN - #define E2_ENABLE_PIN EXP2_04_PIN + #define E2_STEP_PIN EXP2_06_PIN + #define E2_DIR_PIN EXP2_05_PIN + #define E2_ENABLE_PIN EXP2_07_PIN #if !EXP_MOT_USE_EXP2_ONLY - #define E2_DIAG_PIN EXP1_06_PIN - #define E2_CS_PIN EXP1_05_PIN + #define E2_DIAG_PIN EXP1_05_PIN + #define E2_CS_PIN EXP1_06_PIN #if HAS_TMC_UART - #define E2_SERIAL_TX_PIN EXP1_05_PIN + #define E2_SERIAL_TX_PIN EXP1_06_PIN #define E2_SERIAL_RX_PIN E2_SERIAL_TX_PIN #endif #endif // M2 on Driver Expansion Module - #define E3_STEP_PIN EXP2_08_PIN - #define E3_DIR_PIN EXP2_07_PIN + #define E3_STEP_PIN EXP2_03_PIN + #define E3_DIR_PIN EXP2_04_PIN #if !EXP_MOT_USE_EXP2_ONLY - #define E3_ENABLE_PIN EXP1_03_PIN - #define E3_DIAG_PIN EXP1_08_PIN - #define E3_CS_PIN EXP1_07_PIN + #define E3_ENABLE_PIN EXP1_08_PIN + #define E3_DIAG_PIN EXP1_03_PIN + #define E3_CS_PIN EXP1_04_PIN #if HAS_TMC_UART - #define E3_SERIAL_TX_PIN EXP1_07_PIN + #define E3_SERIAL_TX_PIN EXP1_04_PIN #define E3_SERIAL_RX_PIN E3_SERIAL_TX_PIN #endif #else - #define E3_ENABLE_PIN EXP2_04_PIN + #define E3_ENABLE_PIN EXP2_07_PIN #endif // M3 on Driver Expansion Module - #define E4_STEP_PIN EXP2_10_PIN - #define E4_DIR_PIN EXP2_09_PIN + #define E4_STEP_PIN EXP2_01_PIN + #define E4_DIR_PIN EXP2_02_PIN #if !EXP_MOT_USE_EXP2_ONLY - #define E4_ENABLE_PIN EXP1_04_PIN - #define E4_DIAG_PIN EXP1_10_PIN - #define E4_CS_PIN EXP1_09_PIN + #define E4_ENABLE_PIN EXP1_07_PIN + #define E4_DIAG_PIN EXP1_01_PIN + #define E4_CS_PIN EXP1_02_PIN #if HAS_TMC_UART - #define E4_SERIAL_TX_PIN EXP1_09_PIN + #define E4_SERIAL_TX_PIN EXP1_02_PIN #define E4_SERIAL_RX_PIN E4_SERIAL_TX_PIN #endif #else - #define E4_ENABLE_PIN EXP2_04_PIN + #define E4_ENABLE_PIN EXP2_07_PIN #endif #endif // BTT_MOTOR_EXPANSION diff --git a/Marlin/src/pins/lpc1768/pins_EMOTRONIC.h b/Marlin/src/pins/lpc1768/pins_EMOTRONIC.h new file mode 100644 index 0000000000..6e1ea403b1 --- /dev/null +++ b/Marlin/src/pins/lpc1768/pins_EMOTRONIC.h @@ -0,0 +1,149 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program 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. + * + * This program 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 this program. If not, see . + * + */ +#pragma once + +/** + * eMotion-Tech eMotronic pin assignments + * + * Board pins<->features assignments are based on the + * Micro-Delta Rework printer default connections. + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "eMotronic" +#define BOARD_WEBSITE_URL "www.reprap-france.com/article/lemotronic-quesaco" + +// +// Limit Switches +// +#define X_STOP_PIN P1_22 // S0 +#define Y_STOP_PIN P1_23 // S1 +#define Z_STOP_PIN P1_24 // S2 +#define I_STOP_PIN P1_25 // S3 + +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN P0_26 // S4 (opto) +#endif + +// +// Steppers +// +#define X_STEP_PIN P2_02 // M3 +#define X_DIR_PIN P4_28 +#define X_ENABLE_PIN P4_29 + +#define Y_STEP_PIN P2_01 // M2 +#define Y_DIR_PIN P0_22 +#define Y_ENABLE_PIN P0_21 + +#define Z_STEP_PIN P2_00 // M1 +#define Z_DIR_PIN P3_26 +#define Z_ENABLE_PIN P3_25 + +#define E0_STEP_PIN P2_03 // M4 +#define E0_DIR_PIN P0_04 +#define E0_ENABLE_PIN P0_05 // Correct! + +#define E1_STEP_PIN P2_08 // M5 +#define E1_DIR_PIN P0_20 +#define E1_ENABLE_PIN P0_19 + +// +// Temperature Sensors +// 3.3V max when defined as an analog input +// +#define TEMP_0_PIN P0_24_A1 // A1 (TH1) +#define TEMP_1_PIN P0_23_A0 // A0 (TH0) +#define TEMP_BED_PIN P0_25_A2 // A2 (TH2) + +// +// Heaters / Fans +// +#define _H0_PIN P2_04 // (H0: 15A) + +#define HEATER_BED_PIN P2_05 // (H1: 10A shared) +#define HEATER_0_PIN P2_06 // (H2: 10A shared) +#define HEATER_1_PIN P2_07 // (H3: 10A shared) + +#define FAN_PIN P2_11 // (FAN0: 1A) +#define FAN1_PIN P2_13 // (FAN1: 1A) + +// +// Extension ports +// +#define EXP1_01_PIN P0_03 // RX0 +#define EXP1_02_PIN P0_02 // TX0 +#define EXP1_03_PIN P1_30 +#define EXP1_04_PIN P1_31 +#define EXP1_05_PIN P0_17 // MISO0 +#define EXP1_06_PIN P0_18 // MOSI0 +#define EXP1_07_PIN P0_15 // SCK0 +#define EXP1_08_PIN P0_16 // SSEL0 +#define EXP1_09_PIN P0_27 // SDA0 +#define EXP1_10_PIN P0_28 // SCL0 + +#define EXP2_01_PIN P0_10 +#define EXP2_02_PIN P0_11 +#define EXP2_03_PIN P0_00 // SDA1 +#define EXP2_04_PIN P0_01 // SCL1 +#define EXP2_05_PIN P1_28 +#define EXP2_06_PIN P1_29 +#define EXP2_07_PIN P1_26 +#define EXP2_08_PIN P1_27 + +// +// SD Support +// +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#if SD_CONNECTION_IS(ONBOARD) + #define SD_SCK_PIN P0_07 + #define SD_MISO_PIN P0_08 + #define SD_MOSI_PIN P0_09 + #define SD_SS_PIN P0_06 +#elif SD_CONNECTION_IS(LCD) + #define SD_SCK_PIN EXP1_07_PIN + #define SD_MISO_PIN EXP1_05_PIN + #define SD_MOSI_PIN EXP1_06_PIN + #define SD_SS_PIN EXP1_08_PIN + #define SD_DETECT_PIN EXP1_04_PIN +#elif SD_CONNECTION_IS(CUSTOM_CABLE) + #error "No custom SD drive cable defined for this board." +#endif + +// +// LCD / Controller +// +#if ENABLED(EMOTION_TECH_LCD) + #define BEEPER_PIN EXP2_01_PIN + #define DOGLCD_A0 EXP2_06_PIN + #define DOGLCD_CS EXP2_04_PIN + #define DOGLCD_SCK EXP1_07_PIN + #define DOGLCD_MOSI EXP1_06_PIN + + #define BTN_EN1 EXP2_07_PIN + #define BTN_EN2 EXP2_05_PIN + #define BTN_ENC EXP2_02_PIN +#endif diff --git a/Marlin/src/pins/lpc1768/pins_MKS_SBASE.h b/Marlin/src/pins/lpc1768/pins_MKS_SBASE.h index 7f9e530f3c..cf12a98aef 100644 --- a/Marlin/src/pins/lpc1768/pins_MKS_SBASE.h +++ b/Marlin/src/pins/lpc1768/pins_MKS_SBASE.h @@ -238,7 +238,7 @@ #define LCD_SDSS P0_28 // EXP2.4 #define LCD_PINS_ENABLE P0_18 // EXP1.3 #define LCD_PINS_D4 P0_15 // EXP1.5 - #if ANY(VIKI2, miniVIKI) + #if EITHER(VIKI2, miniVIKI) #define DOGLCD_SCK SD_SCK_PIN #define DOGLCD_MOSI SD_MOSI_PIN #endif diff --git a/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h b/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h index 95bbe17b9b..4e9f98c852 100644 --- a/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h +++ b/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h @@ -231,46 +231,46 @@ #define LED4_PIN P1_21 /** ------ ------ - * (BEEPER) 1.31 |10 9 | 1.30 (BTN_ENC) (MISO) 0.8 |10 9 | 0.7 (SD_SCK) - * (LCD_EN) 0.18 | 8 7 | 0.16 (LCD_RS) (BTN_EN1) 3.25 | 8 7 | 0.28 (SD_CS2) - * (LCD_D4) 0.15 6 5 | 0.17 (LCD_D5) (BTN_EN2) 3.26 6 5 | 0.9 (SD_MOSI) - * (LCD_D6) 1.0 | 4 3 | 1.22 (LCD_D7) (SD_DETECT) 0.27 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | -- + * (BEEPER) 1.31 | 1 2 | 1.30 (BTN_ENC) (MISO) 0.8 | 1 2 | 0.7 (SD_SCK) + * (LCD_EN) 0.18 | 3 4 | 0.16 (LCD_RS) (BTN_EN1) 3.25 | 3 4 | 0.28 (SD_CS2) + * (LCD_D4) 0.15 5 6 | 0.17 (LCD_D5) (BTN_EN2) 3.26 5 6 | 0.9 (SD_MOSI) + * (LCD_D6) 1.0 | 7 8 | 1.22 (LCD_D7) (SD_DETECT) 0.27 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN P1_22 -#define EXP1_04_PIN P1_00 -#define EXP1_05_PIN P0_17 -#define EXP1_06_PIN P0_15 -#define EXP1_07_PIN P0_16 -#define EXP1_08_PIN P0_18 -#define EXP1_09_PIN P1_30 -#define EXP1_10_PIN P1_31 - -#define EXP2_03_PIN -1 // RESET -#define EXP2_04_PIN P0_27 -#define EXP2_05_PIN P0_09 -#define EXP2_06_PIN P3_26 -#define EXP2_07_PIN P0_28 -#define EXP2_08_PIN P3_25 -#define EXP2_09_PIN P0_07 -#define EXP2_10_PIN P0_08 +#define EXP1_01_PIN P1_31 +#define EXP1_02_PIN P1_30 +#define EXP1_03_PIN P0_18 +#define EXP1_04_PIN P0_16 +#define EXP1_05_PIN P0_15 +#define EXP1_06_PIN P0_17 +#define EXP1_07_PIN P1_00 +#define EXP1_08_PIN P1_22 + +#define EXP2_01_PIN P0_08 +#define EXP2_02_PIN P0_07 +#define EXP2_03_PIN P3_25 +#define EXP2_04_PIN P0_28 +#define EXP2_05_PIN P3_26 +#define EXP2_06_PIN P0_09 +#define EXP2_07_PIN P0_27 +#define EXP2_08_PIN -1 // RESET #ifndef SDCARD_CONNECTION #define SDCARD_CONNECTION ONBOARD #endif #if SD_CONNECTION_IS(LCD) || SD_CONNECTION_IS(ONBOARD) - #define SD_DETECT_PIN EXP2_04_PIN - #define SD_SCK_PIN EXP2_09_PIN - #define SD_MISO_PIN EXP2_10_PIN - #define SD_MOSI_PIN EXP2_05_PIN + #define SD_DETECT_PIN EXP2_07_PIN + #define SD_SCK_PIN EXP2_02_PIN + #define SD_MISO_PIN EXP2_01_PIN + #define SD_MOSI_PIN EXP2_06_PIN #if SD_CONNECTION_IS(ONBOARD) #define ONBOARD_SD_CS_PIN P0_06 // Chip select for "System" SD card #define SD_SS_PIN ONBOARD_SD_CS_PIN #else - #define SD_SS_PIN EXP2_07_PIN + #define SD_SS_PIN EXP2_04_PIN #endif #elif SD_CONNECTION_IS(CUSTOM_CABLE) #error "No custom SD drive cable defined for this board." @@ -278,30 +278,30 @@ #if HAS_WIRED_LCD - #define BEEPER_PIN EXP1_10_PIN - #define BTN_ENC EXP1_09_PIN + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN #if ENABLED(CR10_STOCKDISPLAY) - #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_RS EXP1_07_PIN - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN - #define LCD_PINS_ENABLE EXP1_03_PIN - #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN #elif HAS_SPI_TFT // Config for Classic UI (emulated DOGM) and Color UI - #define TFT_CS_PIN EXP1_04_PIN - #define TFT_A0_PIN EXP1_03_PIN - #define TFT_DC_PIN EXP1_03_PIN - #define TFT_MISO_PIN EXP2_10_PIN - #define TFT_BACKLIGHT_PIN EXP1_08_PIN - #define TFT_RESET_PIN EXP1_07_PIN + #define TFT_CS_PIN EXP1_07_PIN + #define TFT_A0_PIN EXP1_08_PIN + #define TFT_DC_PIN EXP1_08_PIN + #define TFT_MISO_PIN EXP2_01_PIN + #define TFT_BACKLIGHT_PIN EXP1_03_PIN + #define TFT_RESET_PIN EXP1_04_PIN #define LCD_USE_DMA_SPI - #define TOUCH_INT_PIN EXP1_05_PIN - #define TOUCH_CS_PIN EXP1_06_PIN + #define TOUCH_INT_PIN EXP1_06_PIN + #define TOUCH_CS_PIN EXP1_05_PIN #define TOUCH_BUTTONS_HW_SPI #define TOUCH_BUTTONS_HW_SPI_DEVICE 2 @@ -316,8 +316,8 @@ #define TFT_QUEUE_SIZE 6144 #endif - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN #elif IS_TFTGLCD_PANEL @@ -325,74 +325,74 @@ #undef BTN_ENC #if ENABLED(TFTGLCD_PANEL_SPI) - #define TFTGLCD_CS EXP2_08_PIN + #define TFTGLCD_CS EXP2_03_PIN #endif #else - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN - #define LCD_SDSS EXP2_07_PIN + #define LCD_SDSS EXP2_04_PIN #if ENABLED(MKS_12864OLED_SSD1306) - #define LCD_PINS_DC EXP1_05_PIN - #define DOGLCD_CS EXP1_07_PIN + #define LCD_PINS_DC EXP1_06_PIN + #define DOGLCD_CS EXP1_04_PIN #define DOGLCD_A0 LCD_PINS_DC - #define DOGLCD_SCK EXP1_06_PIN - #define DOGLCD_MOSI EXP1_08_PIN + #define DOGLCD_SCK EXP1_05_PIN + #define DOGLCD_MOSI EXP1_03_PIN - #define LCD_PINS_RS EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN #define KILL_PIN -1 // NC #else // !MKS_12864OLED_SSD1306 - #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_RS EXP1_04_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN #if ENABLED(FYSETC_MINI_12864) - #define DOGLCD_CS EXP1_08_PIN - #define DOGLCD_A0 EXP1_07_PIN - #define DOGLCD_SCK EXP2_09_PIN - #define DOGLCD_MOSI EXP2_05_PIN + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN + #define DOGLCD_SCK EXP2_02_PIN + #define DOGLCD_MOSI EXP2_06_PIN #define LCD_BACKLIGHT_PIN -1 #define FORCE_SOFT_SPI // Use this if default of hardware SPI causes display problems // results in LCD soft SPI mode 3, SD soft SPI mode 0 - #define LCD_RESET_PIN EXP1_06_PIN // Must be high or open for LCD to operate normally. + #define LCD_RESET_PIN EXP1_05_PIN // Must be high or open for LCD to operate normally. #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) #ifndef RGB_LED_R_PIN - #define RGB_LED_R_PIN EXP1_05_PIN + #define RGB_LED_R_PIN EXP1_06_PIN #endif #ifndef RGB_LED_G_PIN - #define RGB_LED_G_PIN EXP1_04_PIN + #define RGB_LED_G_PIN EXP1_07_PIN #endif #ifndef RGB_LED_B_PIN - #define RGB_LED_B_PIN EXP1_03_PIN + #define RGB_LED_B_PIN EXP1_08_PIN #endif #elif ENABLED(FYSETC_MINI_12864_2_1) - #define NEOPIXEL_PIN EXP1_05_PIN + #define NEOPIXEL_PIN EXP1_06_PIN #endif #else // !FYSETC_MINI_12864 #if ENABLED(MKS_MINI_12864) - #define DOGLCD_CS EXP1_05_PIN - #define DOGLCD_A0 EXP1_04_PIN + #define DOGLCD_CS EXP1_06_PIN + #define DOGLCD_A0 EXP1_07_PIN #endif #if IS_ULTIPANEL - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder diff --git a/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h b/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h index 56d75a748c..fe424c800a 100644 --- a/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h +++ b/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h @@ -351,7 +351,7 @@ //#define SHIFT_EN_PIN P1_22 // (41) J5-4 & AUX-4 #endif - #if ANY(VIKI2, miniVIKI) + #if EITHER(VIKI2, miniVIKI) #define DOGLCD_CS P0_16 // (16) #define DOGLCD_A0 P2_06 // (59) J3-8 & AUX-2 #define DOGLCD_SCK SD_SCK_PIN diff --git a/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_GT.h b/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_GT.h index 7ce78ad283..bc7cada8da 100644 --- a/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_GT.h +++ b/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_GT.h @@ -107,7 +107,7 @@ // Display // -#if ANY(VIKI2, miniVIKI) +#if EITHER(VIKI2, miniVIKI) #define BEEPER_PIN P1_31 #define DOGLCD_A0 P2_06 #define DOGLCD_CS P0_16 diff --git a/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h b/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h index 4fbc19eed8..c33fe6e28f 100644 --- a/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h +++ b/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h @@ -154,7 +154,7 @@ //#define SHIFT_EN_PIN P1_22 // (41) J5-4 & AUX-4 #endif - #if ANY(VIKI2, miniVIKI) + #if EITHER(VIKI2, miniVIKI) #define BEEPER_PIN P1_30 // (37) may change if cable changes #define DOGLCD_CS P0_26 // (63) J5-3 & AUX-2 #define DOGLCD_SCK SD_SCK_PIN diff --git a/Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h b/Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h index 090a2e4051..dbaafb89cc 100644 --- a/Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h +++ b/Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h @@ -186,22 +186,22 @@ /** * ------ - * (BEEPER) P2_08 |10 9 | P0_16 (BTN_ENC) - * (BTN_EN1) P0_19 | 8 7 | RESET - * (BTN_EN2) P0_20 6 5 | P0_15 (LCD_D4) - * (LCD_RS) P0_17 | 4 3 | P0_18 (LCD_EN) - * GND | 2 1 | 5V + * (BEEPER) P2_08 | 1 2 | P0_16 (BTN_ENC) + * (BTN_EN1) P0_19 | 3 4 | RESET + * (BTN_EN2) P0_20 5 6 | P0_15 (LCD_D4) + * (LCD_RS) P0_17 | 7 8 | P0_18 (LCD_EN) + * GND | 9 10 | 5V * ------ * EXP */ -#define EXP1_03_PIN P0_18 -#define EXP1_04_PIN P0_17 -#define EXP1_05_PIN P0_15 -#define EXP1_06_PIN P0_20 -#define EXP1_07_PIN -1 -#define EXP1_08_PIN P0_19 -#define EXP1_09_PIN P0_16 -#define EXP1_10_PIN P2_08 +#define EXP1_01_PIN P2_08 +#define EXP1_02_PIN P0_16 +#define EXP1_03_PIN P0_19 +#define EXP1_04_PIN -1 +#define EXP1_05_PIN P0_20 +#define EXP1_06_PIN P0_15 +#define EXP1_07_PIN P0_17 +#define EXP1_08_PIN P0_18 #if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING @@ -210,33 +210,33 @@ /** * Ender 3 V2 display SKR E3 Turbo (EXP1) Ender 3 V2 display --> SKR E3 Turbo - * ------ ------ RX 8 --> 5 P0_15 - * -- |10 9 | -- (BEEPER) P2_08 |10 9 | P0_16 (BTN_ENC) TX 7 --> 9 P0_16 - * (SKR_TX1) RX | 8 7 | TX (SKR_RX1) (BTN_EN1) P0_19 | 8 7 | RESET BEEPER 5 --> 10 P2_08 - * (BTN_ENC) ENT 6 5 | BEEPER (BTN_EN2) P0_20 6 5 | P0_15 (LCD_D4) - * (BTN_E2) B | 4 3 | A (BTN_E1) (LCD_RS) P0_17 | 4 3 | P0_18 (LCD_EN) - * GND | 2 1 | 5V GND | 2 1 | 5V + * ------ ------ RX 3 --> 5 P0_15 + * -- | 1 2 | -- (BEEPER) P2_08 |10 9 | P0_16 (BTN_ENC) TX 4 --> 9 P0_16 + * (SKR_TX1) RX | 3 4 | TX (SKR_RX1) (BTN_EN1) P0_19 | 8 7 | RESET BEEPER 6 --> 10 P2_08 + * (BTN_ENC) ENT 5 6 | BEEPER (BTN_EN2) P0_20 6 5 | P0_15 (LCD_D4) + * (BTN_E2) B | 7 8 | A (BTN_E1) (LCD_RS) P0_17 | 4 3 | P0_18 (LCD_EN) + * GND | 9 10 | 5V GND | 2 1 | 5V * ------ ------ */ - #define BEEPER_PIN EXP1_10_PIN - #define BTN_EN1 EXP1_03_PIN - #define BTN_EN2 EXP1_04_PIN - #define BTN_ENC EXP1_06_PIN + #define BEEPER_PIN EXP1_01_PIN + #define BTN_EN1 EXP1_08_PIN + #define BTN_EN2 EXP1_07_PIN + #define BTN_ENC EXP1_05_PIN #elif HAS_WIRED_LCD #if ENABLED(CR10_STOCKDISPLAY) - #define BEEPER_PIN EXP1_10_PIN + #define BEEPER_PIN EXP1_01_PIN - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_PIN - #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + #define BTN_ENC EXP1_02_PIN - #define LCD_PINS_RS EXP1_04_PIN - #define LCD_PINS_ENABLE EXP1_03_PIN - #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN #elif ENABLED(ZONESTAR_LCD) // ANET A8 LCD Controller - Must convert to 3.3V - CONNECTING TO 5V WILL DAMAGE THE BOARD! @@ -244,24 +244,24 @@ #error "CAUTION! ZONESTAR_LCD requires wiring modifications. See 'pins_BTT_SKR_E3_TURBO.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" #endif - #define LCD_PINS_RS EXP1_05_PIN - #define LCD_PINS_ENABLE EXP1_09_PIN - #define LCD_PINS_D4 EXP1_04_PIN - #define LCD_PINS_D5 EXP1_06_PIN - #define LCD_PINS_D6 EXP1_08_PIN - #define LCD_PINS_D7 EXP1_10_PIN + #define LCD_PINS_RS EXP1_06_PIN + #define LCD_PINS_ENABLE EXP1_02_PIN + #define LCD_PINS_D4 EXP1_07_PIN + #define LCD_PINS_D5 EXP1_05_PIN + #define LCD_PINS_D6 EXP1_03_PIN + #define LCD_PINS_D7 EXP1_01_PIN #define ADC_KEYPAD_PIN P1_23 // Repurpose servo pin for ADC - CONNECTING TO 5V WILL DAMAGE THE BOARD! #elif EITHER(MKS_MINI_12864, ENDER2_STOCKDISPLAY) - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_PIN - #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + #define BTN_ENC EXP1_02_PIN - #define DOGLCD_CS EXP1_04_PIN - #define DOGLCD_A0 EXP1_05_PIN - #define DOGLCD_SCK EXP1_10_PIN - #define DOGLCD_MOSI EXP1_03_PIN + #define DOGLCD_CS EXP1_07_PIN + #define DOGLCD_A0 EXP1_06_PIN + #define DOGLCD_SCK EXP1_01_PIN + #define DOGLCD_MOSI EXP1_08_PIN #define FORCE_SOFT_SPI #define LCD_BACKLIGHT_PIN -1 diff --git a/Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h b/Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h index 4cff5d59e1..2f25d8b5fd 100644 --- a/Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h +++ b/Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h @@ -270,87 +270,87 @@ #endif /** ------ ------ - * (BEEPER) 1.31 |10 9 | 1.30 (BTN_ENC) (MISO) 0.8 |10 9 | 0.7 (SD_SCK) - * (LCD_EN) 0.18 | 8 7 | 0.16 (LCD_RS) (BTN_EN1) 3.25 | 8 7 | 0.28 (SD_CS2) - * (LCD_D4) 0.15 6 5 | 0.17 (LCD_D5) (BTN_EN2) 3.26 6 5 | 0.9 (SD_MOSI) - * (LCD_D6) 1.0 | 4 3 | 1.22 (LCD_D7) (SD_DETECT) 0.27 | 4 3 | RST - * GND | 2 1 | 5V GND | 2 1 | -- + * (BEEPER) 1.31 | 1 2 | 1.30 (BTN_ENC) (MISO) 0.8 | 1 2 | 0.7 (SD_SCK) + * (LCD_EN) 0.18 | 3 4 | 0.16 (LCD_RS) (BTN_EN1) 3.25 | 3 4 | 0.28 (SD_CS2) + * (LCD_D4) 0.15 5 6 | 0.17 (LCD_D5) (BTN_EN2) 3.26 5 6 | 0.9 (SD_MOSI) + * (LCD_D6) 1.0 | 7 8 | 1.22 (LCD_D7) (SD_DETECT) 0.27 | 7 8 | RST + * GND | 9 10 | 5V GND | 9 10 | -- * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN P1_22 -#define EXP1_04_PIN P1_00 -#define EXP1_05_PIN P0_17 -#define EXP1_06_PIN P0_15 -#define EXP1_07_PIN P0_16 -#define EXP1_08_PIN P0_18 -#define EXP1_09_PIN P1_30 -#define EXP1_10_PIN P1_31 - -#define EXP2_03_PIN -1 // RESET -#define EXP2_04_PIN P0_27 -#define EXP2_05_PIN P0_09 -#define EXP2_06_PIN P3_26 -#define EXP2_07_PIN P0_28 -#define EXP2_08_PIN P3_25 -#define EXP2_09_PIN P0_07 -#define EXP2_10_PIN P0_08 +#define EXP1_01_PIN P1_31 +#define EXP1_02_PIN P1_30 +#define EXP1_03_PIN P0_18 +#define EXP1_04_PIN P0_16 +#define EXP1_05_PIN P0_15 +#define EXP1_06_PIN P0_17 +#define EXP1_07_PIN P1_00 +#define EXP1_08_PIN P1_22 + +#define EXP2_01_PIN P0_08 +#define EXP2_02_PIN P0_07 +#define EXP2_03_PIN P3_25 +#define EXP2_04_PIN P0_28 +#define EXP2_05_PIN P3_26 +#define EXP2_06_PIN P0_09 +#define EXP2_07_PIN P0_27 +#define EXP2_08_PIN -1 // RESET #if IS_TFTGLCD_PANEL #if ENABLED(TFTGLCD_PANEL_SPI) - #define TFTGLCD_CS EXP2_08_PIN + #define TFTGLCD_CS EXP2_03_PIN #endif - #define SD_DETECT_PIN EXP2_04_PIN + #define SD_DETECT_PIN EXP2_07_PIN #elif HAS_WIRED_LCD - #define BEEPER_PIN EXP1_10_PIN - #define BTN_ENC EXP1_09_PIN + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN #if ENABLED(CR10_STOCKDISPLAY) - #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_RS EXP1_07_PIN - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN - #define LCD_PINS_ENABLE EXP1_03_PIN - #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN #else - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN - #define LCD_SDSS EXP2_07_PIN + #define LCD_SDSS EXP2_04_PIN #if ENABLED(MKS_12864OLED_SSD1306) - #define LCD_PINS_DC EXP1_05_PIN - #define DOGLCD_CS EXP1_07_PIN + #define LCD_PINS_DC EXP1_06_PIN + #define DOGLCD_CS EXP1_04_PIN #define DOGLCD_A0 LCD_PINS_DC - #define DOGLCD_SCK EXP1_06_PIN - #define DOGLCD_MOSI EXP1_08_PIN + #define DOGLCD_SCK EXP1_05_PIN + #define DOGLCD_MOSI EXP1_03_PIN - #define LCD_PINS_RS EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN #define KILL_PIN -1 // NC #elif HAS_SPI_TFT // Config for Classic UI (emulated DOGM) and Color UI - #define TFT_CS_PIN EXP1_04_PIN - #define TFT_DC_PIN EXP1_03_PIN + #define TFT_CS_PIN EXP1_07_PIN + #define TFT_DC_PIN EXP1_08_PIN #define TFT_A0_PIN TFT_DC_PIN - #define TFT_MISO_PIN EXP2_10_PIN - #define TFT_BACKLIGHT_PIN EXP1_08_PIN - #define TFT_RESET_PIN EXP1_07_PIN + #define TFT_MISO_PIN EXP2_01_PIN + #define TFT_BACKLIGHT_PIN EXP1_03_PIN + #define TFT_RESET_PIN EXP1_04_PIN #define LCD_USE_DMA_SPI - #define TOUCH_INT_PIN EXP1_05_PIN - #define TOUCH_CS_PIN EXP1_06_PIN + #define TOUCH_INT_PIN EXP1_06_PIN + #define TOUCH_CS_PIN EXP1_05_PIN #define TOUCH_BUTTONS_HW_SPI #define TOUCH_BUTTONS_HW_SPI_DEVICE 2 @@ -367,50 +367,50 @@ #else // !MKS_12864OLED_SSD1306 - #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_RS EXP1_04_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN #if ENABLED(FYSETC_MINI_12864) - #define DOGLCD_CS EXP1_08_PIN - #define DOGLCD_A0 EXP1_07_PIN - #define DOGLCD_SCK EXP2_09_PIN - #define DOGLCD_MOSI EXP2_05_PIN + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN + #define DOGLCD_SCK EXP2_02_PIN + #define DOGLCD_MOSI EXP2_06_PIN #define LCD_BACKLIGHT_PIN -1 #define FORCE_SOFT_SPI // Use this if default of hardware SPI causes display problems // results in LCD soft SPI mode 3, SD soft SPI mode 0 - #define LCD_RESET_PIN EXP1_06_PIN // Must be high or open for LCD to operate normally. + #define LCD_RESET_PIN EXP1_05_PIN // Must be high or open for LCD to operate normally. #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) #ifndef RGB_LED_R_PIN - #define RGB_LED_R_PIN EXP1_05_PIN + #define RGB_LED_R_PIN EXP1_06_PIN #endif #ifndef RGB_LED_G_PIN - #define RGB_LED_G_PIN EXP1_04_PIN + #define RGB_LED_G_PIN EXP1_07_PIN #endif #ifndef RGB_LED_B_PIN - #define RGB_LED_B_PIN EXP1_03_PIN + #define RGB_LED_B_PIN EXP1_08_PIN #endif #elif ENABLED(FYSETC_MINI_12864_2_1) - #define NEOPIXEL_PIN EXP1_05_PIN + #define NEOPIXEL_PIN EXP1_06_PIN #endif #else // !FYSETC_MINI_12864 #if ENABLED(MKS_MINI_12864) - #define DOGLCD_CS EXP1_05_PIN - #define DOGLCD_A0 EXP1_04_PIN + #define DOGLCD_CS EXP1_06_PIN + #define DOGLCD_A0 EXP1_07_PIN #endif #if IS_ULTIPANEL - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder @@ -431,15 +431,15 @@ #endif #if SD_CONNECTION_IS(LCD) || SD_CONNECTION_IS(ONBOARD) - #define SD_DETECT_PIN EXP2_04_PIN - #define SD_SCK_PIN EXP2_09_PIN - #define SD_MISO_PIN EXP2_10_PIN - #define SD_MOSI_PIN EXP2_05_PIN + #define SD_DETECT_PIN EXP2_07_PIN + #define SD_SCK_PIN EXP2_02_PIN + #define SD_MISO_PIN EXP2_01_PIN + #define SD_MOSI_PIN EXP2_06_PIN #if SD_CONNECTION_IS(ONBOARD) #define ONBOARD_SD_CS_PIN P0_06 // Chip select for "System" SD card #define SD_SS_PIN ONBOARD_SD_CS_PIN #else - #define SD_SS_PIN EXP2_07_PIN + #define SD_SS_PIN EXP2_04_PIN #endif #elif SD_CONNECTION_IS(CUSTOM_CABLE) #error "No custom SD drive cable defined for this board." diff --git a/Marlin/src/pins/lpc1769/pins_SMOOTHIEBOARD.h b/Marlin/src/pins/lpc1769/pins_SMOOTHIEBOARD.h index e80116efd0..cfaca164f8 100644 --- a/Marlin/src/pins/lpc1769/pins_SMOOTHIEBOARD.h +++ b/Marlin/src/pins/lpc1769/pins_SMOOTHIEBOARD.h @@ -91,7 +91,7 @@ // // LCD / Controller // -#if ANY(VIKI2, miniVIKI) +#if EITHER(VIKI2, miniVIKI) #define BEEPER_PIN P1_31 #define DOGLCD_A0 P2_11 diff --git a/Marlin/src/pins/lpc1769/pins_TH3D_EZBOARD.h b/Marlin/src/pins/lpc1769/pins_TH3D_EZBOARD.h index 81c7dc9403..f794e178f9 100644 --- a/Marlin/src/pins/lpc1769/pins_TH3D_EZBOARD.h +++ b/Marlin/src/pins/lpc1769/pins_TH3D_EZBOARD.h @@ -157,11 +157,11 @@ /** * ------ - * P1_31 |10 9 | P1_30 - * P3_26 | 8 7 | P2_11 - * P3_25 6 5 | P0_15 - * P0_16 | 4 3 | P0_18 - * GND | 2 1 | 5V + * P1_31 | 1 2 | P1_30 + * P3_26 | 3 4 | P2_11 + * P3_25 5 6 | P0_15 + * P0_16 | 7 8 | P0_18 + * GND | 9 10 | 5V * ------ * EXP1 * @@ -171,43 +171,43 @@ * A remote SD card is currently not supported because the pins routed to the EXP2 * connector are shared with the onboard SD card. */ -#define EXP1_03_PIN P0_18 -#define EXP1_04_PIN P0_16 -#define EXP1_05_PIN P0_15 -#define EXP1_06_PIN P3_25 -#define EXP1_07_PIN P2_11 -#define EXP1_08_PIN P3_26 -#define EXP1_09_PIN P1_30 -#define EXP1_10_PIN P1_31 +#define EXP1_01_PIN P1_31 +#define EXP1_02_PIN P1_30 +#define EXP1_03_PIN P3_26 +#define EXP1_04_PIN P2_11 +#define EXP1_05_PIN P3_25 +#define EXP1_06_PIN P0_15 +#define EXP1_07_PIN P0_16 +#define EXP1_08_PIN P0_18 #if ENABLED(CR10_STOCKDISPLAY) /** ------ - * BEEPER |10 9 | ENC - * EN1 | 8 7 | KILL - * EN2 6 5 | LCD_D4 - * LCD_RS | 4 3 | LCD_EN - * GND | 2 1 | 5V + * BEEPER | 1 2 | ENC + * EN1 | 3 4 | KILL + * EN2 5 6 | LCD_D4 + * LCD_RS | 7 8 | LCD_EN + * GND | 9 10 | 5V * ------ */ - #define BEEPER_PIN EXP1_10_PIN - #define LCD_PINS_RS EXP1_04_PIN - #define LCD_PINS_ENABLE EXP1_03_PIN - #define LCD_PINS_D4 EXP1_05_PIN - #define KILL_PIN EXP1_07_PIN + #define BEEPER_PIN EXP1_01_PIN + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN + #define KILL_PIN EXP1_04_PIN #elif ENABLED(MKS_MINI_12864) /** ------ - * SCK |10 9 | ENC - * EN1 | 8 7 | -- - * EN2 6 5 | A0 - * CS | 4 3 | MOSI - * GND | 2 1 | 5V + * SCK | 1 2 | ENC + * EN1 | 3 4 | -- + * EN2 5 6 | A0 + * CS | 7 8 | MOSI + * GND | 9 10 | 5V * ------ */ - #define DOGLCD_CS EXP1_04_PIN - #define DOGLCD_A0 EXP1_05_PIN - #define DOGLCD_SCK EXP1_10_PIN - #define DOGLCD_MOSI EXP1_03_PIN + #define DOGLCD_CS EXP1_07_PIN + #define DOGLCD_A0 EXP1_06_PIN + #define DOGLCD_SCK EXP1_01_PIN + #define DOGLCD_MOSI EXP1_08_PIN #define LCD_CONTRAST_INIT 160 #define LCD_CONTRAST_MIN 120 #define LCD_CONTRAST_MAX 180 @@ -221,7 +221,7 @@ #endif #if EITHER(CR10_STOCKDISPLAY, MKS_MINI_12864) - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_PIN - #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + #define BTN_ENC EXP1_02_PIN #endif diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index 78cccb44ec..7983124fbf 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -295,7 +295,7 @@ // #elif MB(ADVI3PP_I3_PLUS_51) - #include "advi3pp/pins_ADVI3PP.h" // ATmega2560 env:advi3pp_51 env:advi3pp_51_bltouch env:advi3pp_51_bltouch_debug + #include "advi3pp/pins_ADVI3PP.h" // ATmega2560 env:advi3pp_51 env:advi3pp_51_bltouch env:advi3pp_51_bltouch_debug env:advi3pp_simulator #elif MB(ADVI3PP_I3_PLUS_52C) #include "advi3pp/pins_ADVI3PP.h" // ATmega2560 env:advi3pp_52c env:advi3pp_52c_bltouch #elif MB(ADVI3PP_I3_PLUS_54) @@ -413,6 +413,8 @@ #include "lpc1768/pins_BTT_SKR_V1_3.h" // LPC1768 env:LPC1768 #elif MB(BTT_SKR_V1_4) #include "lpc1768/pins_BTT_SKR_V1_4.h" // LPC1768 env:LPC1768 +#elif MB(EMOTRONIC) + #include "lpc1768/pins_EMOTRONIC.h" // LPC1768 env:LPC1768 // // LPC1769 ARM Cortex M3 @@ -578,6 +580,8 @@ #include "stm32f1/pins_CREALITY_V4.h" // STM32F1 env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer env:STM32F103RE_creality_maple #elif MB(CREALITY_V4210) #include "stm32f1/pins_CREALITY_V4210.h" // STM32F1 env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer env:STM32F103RE_creality_maple +#elif MB(CREALITY_V425) + #include "stm32f1/pins_CREALITY_V425.h" // STM32F1 env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer env:STM32F103RE_creality_maple #elif MB(CREALITY_V422) #include "stm32f1/pins_CREALITY_V422.h" // STM32F1 env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer env:STM32F103RE_creality_maple #elif MB(CREALITY_V423) @@ -597,7 +601,7 @@ #elif MB(CREALITY_V25S1) #include "stm32f1/pins_CREALITY_V25S1.h" // STM32F1 env:STM32F103RE_creality_smartPro env:STM32F103RE_creality_smartPro_maple #elif MB(TRIGORILLA_PRO) - #include "stm32f1/pins_TRIGORILLA_PRO.h" // STM32F1 env:trigorilla_pro env:trigorilla_pro_maple + #include "stm32f1/pins_TRIGORILLA_PRO.h" // STM32F1 env:trigorilla_pro env:trigorilla_pro_maple env:trigorilla_pro_disk #elif MB(FLY_MINI) #include "stm32f1/pins_FLY_MINI.h" // STM32F1 env:FLY_MINI env:FLY_MINI_maple #elif MB(FLSUN_HISPEED) @@ -640,8 +644,6 @@ #include "stm32f4/pins_RUMBA32_BTT.h" // STM32F4 env:rumba32 #elif MB(BLACK_STM32F407VE) #include "stm32f4/pins_BLACK_STM32F407VE.h" // STM32F4 env:STM32F407VE_black -#elif MB(STEVAL_3DP001V1) - #include "stm32f4/pins_STEVAL_3DP001V1.h" // STM32F4 env:STM32F401VE_STEVAL #elif MB(BTT_SKR_PRO_V1_1) #include "stm32f4/pins_BTT_SKR_PRO_V1_1.h" // STM32F4 env:BIGTREE_SKR_PRO env:BIGTREE_SKR_PRO_usb_flash_drive #elif MB(BTT_SKR_PRO_V1_2) @@ -689,17 +691,19 @@ #elif MB(MKS_ROBIN_NANO_V3_1) #include "stm32f4/pins_MKS_ROBIN_NANO_V3.h" // STM32F4 env:mks_robin_nano_v3_1 env:mks_robin_nano_v3_1_usb_flash_drive env:mks_robin_nano_v3_1_usb_flash_drive_msc #elif MB(ANET_ET4) - #include "stm32f4/pins_ANET_ET4.h" // STM32F4 env:Anet_ET4_OpenBLT + #include "stm32f4/pins_ANET_ET4.h" // STM32F4 env:Anet_ET4_no_bootloader env:Anet_ET4_OpenBLT #elif MB(ANET_ET4P) - #include "stm32f4/pins_ANET_ET4P.h" // STM32F4 env:Anet_ET4_OpenBLT + #include "stm32f4/pins_ANET_ET4P.h" // STM32F4 env:Anet_ET4_no_bootloader env:Anet_ET4_OpenBLT #elif MB(FYSETC_CHEETAH_V20) #include "stm32f4/pins_FYSETC_CHEETAH_V20.h" // STM32F4 env:FYSETC_CHEETAH_V20 -#elif MB(MKS_MONSTER8) - #include "stm32f4/pins_MKS_MONSTER8.h" // STM32F4 env:mks_monster8 env:mks_monster8_usb_flash_drive env:mks_monster8_usb_flash_drive_msc +#elif MB(MKS_MONSTER8_V1) + #include "stm32f4/pins_MKS_MONSTER8_V1.h" // STM32F4 env:mks_monster8 env:mks_monster8_usb_flash_drive env:mks_monster8_usb_flash_drive_msc +#elif MB(MKS_MONSTER8_V2) + #include "stm32f4/pins_MKS_MONSTER8_V2.h" // STM32F4 env:mks_monster8 env:mks_monster8_usb_flash_drive env:mks_monster8_usb_flash_drive_msc #elif MB(TH3D_EZBOARD_V2) - #include "stm32f4/pins_TH3D_EZBOARD_V2.h" // STM32F4 env:TH3D_EZBoard_V2 -#elif MB(INDEX_REV03) - #include "stm32f4/pins_INDEX_REV03.h" // STM32F4 env:Index_Mobo_Rev03 + #include "stm32f4/pins_TH3D_EZBOARD_V2.h" // STM32F4 env:TH3D_EZBoard_V2_no_bootloader env:TH3D_EZBoard_V2_OpenBLT +#elif MB(OPULO_LUMEN_REV3) + #include "stm32f4/pins_OPULO_LUMEN_REV3.h" // STM32F4 env:Opulo_Lumen_REV3 #elif MB(MKS_ROBIN_NANO_V1_3_F4) #include "stm32f4/pins_MKS_ROBIN_NANO_V1_3_F4.h" // STM32F4 env:mks_robin_nano_v1_3_f4 #elif MB(MKS_EAGLE) @@ -717,8 +721,10 @@ #include "stm32f7/pins_REMRAM_V1.h" // STM32F7 env:REMRAM_V1 #elif MB(NUCLEO_F767ZI) #include "stm32f7/pins_NUCLEO_F767ZI.h" // STM32F7 env:NUCLEO_F767ZI -#elif MB(BTT_SKR_SE_BX) - #include "stm32h7/pins_BTT_SKR_SE_BX.h" // STM32H7 env:BTT_SKR_SE_BX +#elif MB(BTT_SKR_SE_BX_V2) + #include "stm32h7/pins_BTT_SKR_SE_BX_V2.h" // STM32H7 env:BTT_SKR_SE_BX +#elif MB(BTT_SKR_SE_BX_V3) + #include "stm32h7/pins_BTT_SKR_SE_BX_V3.h" // STM32H7 env:BTT_SKR_SE_BX #elif MB(BTT_SKR_V3_0) #include "stm32h7/pins_BTT_SKR_V3_0.h" // STM32H7 env:STM32H743Vx_btt #elif MB(BTT_SKR_V3_0_EZ) @@ -793,6 +799,7 @@ #define BOARD_STM32F103R 99906 #define BOARD_ESP32 99907 #define BOARD_STEVAL 99908 + #define BOARD_STEVAL_3DP001V1 99908 #define BOARD_BIGTREE_SKR_V1_1 99909 #define BOARD_BIGTREE_SKR_V1_3 99910 #define BOARD_BIGTREE_SKR_V1_4 99911 @@ -808,6 +815,8 @@ #define BOARD_RAMPS_LONGER3D_LK4PRO 99921 #define BOARD_BTT_SKR_V2_0 99922 #define BOARD_TH3D_EZBOARD_LITE_V2 99923 + #define BOARD_BTT_SKR_SE_BX 99924 + #define BOARD_MKS_MONSTER8 99925 #if MB(MKS_13) #error "BOARD_MKS_13 has been renamed BOARD_MKS_GEN_13. Please update your configuration." @@ -846,7 +855,7 @@ #elif MOTHERBOARD == BOARD_ESP32 #error "BOARD_ESP32 has been renamed BOARD_ESPRESSIF_ESP32. Please update your configuration." #elif MB(STEVAL) - #error "BOARD_STEVAL has been renamed BOARD_STEVAL_3DP001V1. Please update your configuration." + #error "BOARD_STEVAL_3DP001V1 (BOARD_STEVAL) is no longer supported in Marlin." #elif MB(RUMBA32) #error "BOARD_RUMBA32 is now BOARD_RUMBA32_MKS or BOARD_RUMBA32_V1_0. Please update your configuration." #elif MB(RUMBA32_AUS3D) @@ -859,6 +868,10 @@ #error "BOARD_BTT_SKR_V2_0 is now BOARD_BTT_SKR_V2_0_REV_A or BOARD_BTT_SKR_V2_0_REV_B. See https://bit.ly/3t5d9JQ for more information. Please update your configuration." #elif MB(TH3D_EZBOARD_LITE_V2) #error "BOARD_TH3D_EZBOARD_LITE_V2 is now BOARD_TH3D_EZBOARD_V2. Please update your configuration." + #elif MB(BTT_SKR_SE_BX) + #error "BOARD_BTT_SKR_SE_BX is now BOARD_BTT_SKR_SE_BX_V2 or BOARD_BTT_SKR_SE_BX_V3. Please update your configuration." + #elif MB(MKS_MONSTER8) + #error "BOARD_MKS_MONSTER8 is now BOARD_MKS_MONSTER8_V1 or BOARD_MKS_MONSTER8_V2. Please update your configuration." #elif defined(MOTHERBOARD) #error "Unknown MOTHERBOARD value set in Configuration.h." #else @@ -874,7 +887,7 @@ #undef BOARD_STM32F103R #undef BOARD_ESP32 #undef BOARD_STEVAL - #undef BOARD_BIGTREE_SKR_MINI_E3 + #undef BOARD_STEVAL_3DP001V1 #undef BOARD_BIGTREE_SKR_V1_1 #undef BOARD_BIGTREE_SKR_V1_3 #undef BOARD_BIGTREE_SKR_V1_4 @@ -882,6 +895,7 @@ #undef BOARD_BIGTREE_BTT002_V1_0 #undef BOARD_BIGTREE_SKR_PRO_V1_1 #undef BOARD_BIGTREE_SKR_MINI_V1_1 + #undef BOARD_BIGTREE_SKR_MINI_E3 #undef BOARD_BIGTREE_SKR_E3_DIP #undef BOARD_RUMBA32 #undef BOARD_RUMBA32_AUS3D @@ -889,6 +903,8 @@ #undef BOARD_RAMPS_LONGER3D_LK4PRO #undef BOARD_BTT_SKR_V2_0 #undef BOARD_TH3D_EZBOARD_LITE_V2 + #undef BOARD_BTT_SKR_SE_BX + #undef BOARD_MKS_MONSTER8 #endif diff --git a/Marlin/src/pins/pinsDebug_list.h b/Marlin/src/pins/pinsDebug_list.h index 8969997e9a..034e4adf1b 100644 --- a/Marlin/src/pins/pinsDebug_list.h +++ b/Marlin/src/pins/pinsDebug_list.h @@ -1826,21 +1826,6 @@ #if PIN_EXISTS(K_SERIAL_RX) REPORT_NAME_DIGITAL(__LINE__, K_SERIAL_RX_PIN) #endif -#if PIN_EXISTS(L6470_CHAIN_SCK) - REPORT_NAME_DIGITAL(__LINE__, L6470_CHAIN_SCK_PIN) -#endif -#if PIN_EXISTS(L6470_CHAIN_MISO) - REPORT_NAME_DIGITAL(__LINE__, L6470_CHAIN_MISO_PIN) -#endif -#if PIN_EXISTS(L6470_CHAIN_MOSI) - REPORT_NAME_DIGITAL(__LINE__, L6470_CHAIN_MOSI_PIN) -#endif -#if PIN_EXISTS(L6470_CHAIN_SS) - REPORT_NAME_DIGITAL(__LINE__, L6470_CHAIN_SS_PIN) -#endif -#if PIN_EXISTS(L6470_RESET_CHAIN) - REPORT_NAME_DIGITAL(__LINE__, L6470_RESET_CHAIN_PIN) -#endif #if PIN_EXISTS(FET_SAFETY) REPORT_NAME_DIGITAL(__LINE__, FET_SAFETY_PIN) #endif diff --git a/Marlin/src/pins/rambo/pins_RAMBO.h b/Marlin/src/pins/rambo/pins_RAMBO.h index 5484b193b9..cb7a059134 100644 --- a/Marlin/src/pins/rambo/pins_RAMBO.h +++ b/Marlin/src/pins/rambo/pins_RAMBO.h @@ -208,7 +208,7 @@ #define LCD_PINS_D6 74 #define LCD_PINS_D7 75 - #if ANY(VIKI2, miniVIKI) + #if EITHER(VIKI2, miniVIKI) #define BEEPER_PIN 44 // NB: Panucatt's Viki 2.0 wiring diagram (v1.2) indicates that the // beeper/buzzer is connected to pin 33; however, the pin used in the diff --git a/Marlin/src/pins/rambo/pins_SCOOVO_X9H.h b/Marlin/src/pins/rambo/pins_SCOOVO_X9H.h index 4c2645e64b..533284a4bf 100644 --- a/Marlin/src/pins/rambo/pins_SCOOVO_X9H.h +++ b/Marlin/src/pins/rambo/pins_SCOOVO_X9H.h @@ -143,7 +143,7 @@ #define HOME_PIN BTN_HOME -#if ANY(VIKI2, miniVIKI) +#if EITHER(VIKI2, miniVIKI) #define BEEPER_PIN 44 // Pins for DOGM SPI LCD Support #define DOGLCD_A0 70 diff --git a/Marlin/src/pins/ramps/pins_AZTEEG_X3.h b/Marlin/src/pins/ramps/pins_AZTEEG_X3.h index 44d8341c11..31adea4270 100644 --- a/Marlin/src/pins/ramps/pins_AZTEEG_X3.h +++ b/Marlin/src/pins/ramps/pins_AZTEEG_X3.h @@ -51,7 +51,7 @@ #undef STAT_LED_RED_PIN #undef STAT_LED_BLUE_PIN -#if ANY(VIKI2, miniVIKI) +#if EITHER(VIKI2, miniVIKI) #undef DOGLCD_A0 #undef DOGLCD_CS diff --git a/Marlin/src/pins/ramps/pins_AZTEEG_X3_PRO.h b/Marlin/src/pins/ramps/pins_AZTEEG_X3_PRO.h index 5dc191cd20..24266bb9d2 100644 --- a/Marlin/src/pins/ramps/pins_AZTEEG_X3_PRO.h +++ b/Marlin/src/pins/ramps/pins_AZTEEG_X3_PRO.h @@ -142,7 +142,7 @@ #undef BEEPER_PIN #define BEEPER_PIN 33 -#if ANY(VIKI2, miniVIKI) +#if EITHER(VIKI2, miniVIKI) #undef SD_DETECT_PIN #define SD_DETECT_PIN 49 // For easy adapter board #undef BEEPER_PIN @@ -169,7 +169,7 @@ #undef SPINDLE_DIR_PIN #if HAS_CUTTER // EXP2 header - #if ANY(VIKI2, miniVIKI) + #if EITHER(VIKI2, miniVIKI) #define BTN_EN2 31 // Pin 7 needed for Spindle PWM #endif #define SPINDLE_LASER_PWM_PIN 7 // Hardware PWM diff --git a/Marlin/src/pins/ramps/pins_MKS_GEN_13.h b/Marlin/src/pins/ramps/pins_MKS_GEN_13.h index bb7b55893e..7a8c99e3af 100644 --- a/Marlin/src/pins/ramps/pins_MKS_GEN_13.h +++ b/Marlin/src/pins/ramps/pins_MKS_GEN_13.h @@ -54,13 +54,13 @@ #include "pins_RAMPS.h" -#undef EXP2_03_PIN -#define EXP2_03_PIN -1 // RESET +#undef EXP2_08_PIN +#define EXP2_08_PIN -1 // RESET // // LCD / Controller // -#if ANY(VIKI2, miniVIKI) +#if EITHER(VIKI2, miniVIKI) /** * VIKI2 Has two groups of wires with... * @@ -85,11 +85,11 @@ * This configuration uses the following arrangement: * * ------ ------ - * ENCB |10 9 | ENCA MISO |10 9 | SCK - * BLUE_LED | 8 7 | RED_LED ENCBTN | 8 7 | SDCS - * KILL 6 5 | BEEPER 6 5 | MOSI - * A0 | 4 3 | LCD_CS SDCD | 4 3 | - * GND | 2 1 | 5V GND | 2 1 | -- + * ENCB | 1 2 | ENCA MISO | 1 2 | SCK + * BLUE_LED | 3 4 | RED_LED ENCBTN | 3 4 | SDCS + * KILL 5 6 | BEEPER 5 6 | MOSI + * A0 | 7 8 | LCD_CS SDCD | 7 8 | + * GND | 9 10 | 5V GND | 9 10 | -- * ------ ------ * EXP1 EXP2 */ @@ -107,24 +107,24 @@ // // VIKI2 12-wire lead // - #define SD_DETECT_PIN EXP2_04_PIN // SDCD orange/white - #define BTN_EN1 EXP1_09_PIN // ENCA white - #define BTN_EN2 EXP1_10_PIN // ENCB green - #define BTN_ENC EXP2_08_PIN // ENCBTN purple - #define DOGLCD_A0 EXP1_04_PIN // A0 brown - #define DOGLCD_CS EXP1_03_PIN // LCS green/white + #define SD_DETECT_PIN EXP2_07_PIN // SDCD orange/white + #define BTN_EN1 EXP1_02_PIN // ENCA white + #define BTN_EN2 EXP1_01_PIN // ENCB green + #define BTN_ENC EXP2_03_PIN // ENCBTN purple + #define DOGLCD_A0 EXP1_07_PIN // A0 brown + #define DOGLCD_CS EXP1_08_PIN // LCS green/white - // EXP2_10_PIN gray MISO - // EXP2_05_PIN yellow MOSI - // EXP2_09_PIN orange SCK + // EXP2_01_PIN gray MISO + // EXP2_06_PIN yellow MOSI + // EXP2_02_PIN orange SCK - //#define SDSS EXP2_07_PIN // SDCS blue + //#define SDSS EXP2_04_PIN // SDCS blue // // VIKI2 4-wire lead // - #define KILL_PIN EXP1_06_PIN // BTN blue - #define BEEPER_PIN EXP1_05_PIN // BUZZER green - #define STAT_LED_RED_PIN EXP1_07_PIN // RED-LED yellow - #define STAT_LED_BLUE_PIN EXP1_08_PIN // BLUE-LED white + #define KILL_PIN EXP1_05_PIN // BTN blue + #define BEEPER_PIN EXP1_06_PIN // BUZZER green + #define STAT_LED_RED_PIN EXP1_04_PIN // RED-LED yellow + #define STAT_LED_BLUE_PIN EXP1_03_PIN // BLUE-LED white #endif diff --git a/Marlin/src/pins/ramps/pins_RAMPS.h b/Marlin/src/pins/ramps/pins_RAMPS.h index d779372b1b..a0edb01a2a 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS.h +++ b/Marlin/src/pins/ramps/pins_RAMPS.h @@ -513,62 +513,62 @@ * LCD adapters come in different variants. The socket keys can be * on either side, and may be backwards on some boards / displays. */ -#ifndef EXP1_03_PIN +#ifndef EXP1_08_PIN - #define EXP1_03_PIN AUX4_13_PIN - #define EXP1_04_PIN AUX4_14_PIN - #define EXP1_05_PIN AUX4_15_PIN - #define EXP1_06_PIN AUX4_16_PIN - #define EXP1_07_PIN AUX4_18_PIN - #define EXP1_08_PIN AUX4_17_PIN + #define EXP1_03_PIN AUX4_17_PIN + #define EXP1_04_PIN AUX4_18_PIN + #define EXP1_05_PIN AUX4_16_PIN + #define EXP1_06_PIN AUX4_15_PIN + #define EXP1_07_PIN AUX4_14_PIN + #define EXP1_08_PIN AUX4_13_PIN - #define EXP2_04_PIN AUX3_02_PIN - #define EXP2_05_PIN AUX3_04_PIN - #define EXP2_07_PIN AUX3_06_PIN - #define EXP2_09_PIN AUX3_05_PIN - #define EXP2_10_PIN AUX3_03_PIN + #define EXP2_01_PIN AUX3_03_PIN + #define EXP2_02_PIN AUX3_05_PIN + #define EXP2_04_PIN AUX3_06_PIN + #define EXP2_06_PIN AUX3_04_PIN + #define EXP2_07_PIN AUX3_02_PIN #if ENABLED(G3D_PANEL) /** Gadgets3D Smart Adapter * ------ ------ - * 4-11 |10 9 | 4-12 (MISO) 3-03 |10 9 | 3-05 (SCK) - * 4-17 | 8 7 | 4-18 4-10 | 8 7 | 3-06 - * 4-16 6 5 | 4-15 4-09 6 5 | 3-04 (MOSI) - * 4-14 | 4 3 | 4-13 3-02 | 4 3 | 4-07 - * (GND) 4-02 | 2 1 | 4-01 (5V) -- | 2 1 | -- + * 4-11 | 1 2 | 4-12 (MISO) 3-03 | 1 2 | 3-05 (SCK) + * 4-17 | 3 4 | 4-18 4-10 | 3 4 | 3-06 + * 4-16 5 6 | 4-15 4-09 5 6 | 3-04 (MOSI) + * 4-14 | 7 8 | 4-13 3-02 | 7 8 | 4-07 + * (GND) 4-02 | 9 10 | 4-01 (5V) -- | 9 10 | -- * ------ ------ * EXP1 EXP2 */ - #define EXP1_09_PIN AUX4_12_PIN - #define EXP1_10_PIN AUX4_11_PIN + #define EXP1_01_PIN AUX4_11_PIN + #define EXP1_02_PIN AUX4_12_PIN - #define EXP2_03_PIN AUX4_07_PIN - #define EXP2_06_PIN AUX4_09_PIN - #define EXP2_08_PIN AUX4_10_PIN + #define EXP2_03_PIN AUX4_10_PIN + #define EXP2_05_PIN AUX4_09_PIN + #define EXP2_08_PIN AUX4_07_PIN #else /** Smart Adapter (c) RRD * ------ ------ - * 4-09 |10 9 | 4-10 (MISO) 3-03 |10 9 | 3-05 (SCK) - * 4-17 | 8 7 | 4-18 4-12 | 8 7 | 3-06 - * 4-16 6 5 | 4-15 4-11 6 5 | 3-04 (MOSI) - * 4-14 | 4 3 | 4-13 3-02 | 4 3 | 4-07 - * (GND) 3-07 | 2 1 | 3-01 (5V) (GND) 3-07 | 2 1 | -- + * 4-09 | 1 2 | 4-10 (MISO) 3-03 | 1 2 | 3-05 (SCK) + * 4-17 | 3 4 | 4-18 4-12 | 3 4 | 3-06 + * 4-16 5 6 | 4-15 4-11 5 6 | 3-04 (MOSI) + * 4-14 | 7 8 | 4-13 3-02 | 7 8 | 4-07 + * (GND) 3-07 | 9 10 | 3-01 (5V) (GND) 3-07 | 9 10 | -- * ------ ------ * EXP1 EXP2 */ - #define EXP1_09_PIN AUX4_10_PIN - #define EXP1_10_PIN AUX4_09_PIN + #define EXP1_01_PIN AUX4_09_PIN + #define EXP1_02_PIN AUX4_10_PIN #if BOTH(TOUCH_UI_FTDI_EVE, LCD_FYSETC_TFT81050) - #define EXP2_03_PIN -1 // RESET - #define EXP2_06_PIN AUX4_12_PIN - #define EXP2_08_PIN AUX4_11_PIN + #define EXP2_03_PIN AUX4_11_PIN + #define EXP2_05_PIN AUX4_12_PIN + #define EXP2_08_PIN -1 // RESET #else - #define EXP2_03_PIN AUX4_07_PIN - #define EXP2_06_PIN AUX4_11_PIN - #define EXP2_08_PIN AUX4_12_PIN + #define EXP2_03_PIN AUX4_12_PIN + #define EXP2_05_PIN AUX4_11_PIN + #define EXP2_08_PIN AUX4_07_PIN #endif #endif @@ -588,9 +588,9 @@ // #if ENABLED(REPRAPWORLD_GRAPHICAL_LCD) - #define LCD_PINS_RS EXP2_04_PIN // CS chip select /SS chip slave select - #define LCD_PINS_ENABLE EXP2_05_PIN // SID (MOSI) - #define LCD_PINS_D4 EXP2_09_PIN // SCK (CLK) clock + #define LCD_PINS_RS EXP2_07_PIN // CS chip select /SS chip slave select + #define LCD_PINS_ENABLE EXP2_06_PIN // SID (MOSI) + #define LCD_PINS_D4 EXP2_02_PIN // SCK (CLK) clock #elif BOTH(IS_NEWPANEL, PANEL_ONE) @@ -603,18 +603,18 @@ #elif ENABLED(TFTGLCD_PANEL_SPI) - #define TFTGLCD_CS EXP2_06_PIN + #define TFTGLCD_CS EXP2_05_PIN #else #if ENABLED(CR10_STOCKDISPLAY) - #define LCD_PINS_RS EXP1_04_PIN - #define LCD_PINS_ENABLE EXP1_03_PIN - #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN #if !IS_NEWPANEL - #define BEEPER_PIN EXP1_10_PIN + #define BEEPER_PIN EXP1_01_PIN #endif #elif ENABLED(ZONESTAR_LCD) @@ -637,25 +637,25 @@ #else #if EITHER(MKS_12864OLED, MKS_12864OLED_SSD1306) - #define LCD_PINS_DC EXP1_05_PIN // Set as output on init - #define LCD_PINS_RS EXP1_04_PIN // Pull low for 1s to init + #define LCD_PINS_DC EXP1_06_PIN // Set as output on init + #define LCD_PINS_RS EXP1_07_PIN // Pull low for 1s to init // DOGM SPI LCD Support #define DOGLCD_A0 LCD_PINS_DC - #define DOGLCD_CS EXP1_07_PIN - #define DOGLCD_MOSI EXP1_08_PIN - #define DOGLCD_SCK EXP1_06_PIN + #define DOGLCD_CS EXP1_04_PIN + #define DOGLCD_MOSI EXP1_03_PIN + #define DOGLCD_SCK EXP1_05_PIN #else - #define LCD_PINS_RS EXP1_07_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN + #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN #endif - #define LCD_PINS_D7 EXP1_03_PIN + #define LCD_PINS_D7 EXP1_08_PIN #if !IS_NEWPANEL - #define BEEPER_PIN EXP2_06_PIN + #define BEEPER_PIN EXP2_05_PIN #endif #endif @@ -666,7 +666,7 @@ //#define SHIFT_CLK_PIN 38 //#define SHIFT_LD_PIN AUX2_08_PIN //#define SHIFT_OUT_PIN AUX2_06_PIN - //#define SHIFT_EN_PIN EXP1_08_PIN + //#define SHIFT_EN_PIN EXP1_03_PIN #endif #endif @@ -682,22 +682,22 @@ #if IS_RRD_SC - #define BEEPER_PIN EXP1_10_PIN + #define BEEPER_PIN EXP1_01_PIN #if ENABLED(CR10_STOCKDISPLAY) - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN #else - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN #endif - #define BTN_ENC EXP1_09_PIN + #define BTN_ENC EXP1_02_PIN #ifndef SD_DETECT_PIN - #define SD_DETECT_PIN EXP2_04_PIN + #define SD_DETECT_PIN EXP2_07_PIN #endif #ifndef KILL_PIN - #define KILL_PIN EXP2_03_PIN + #define KILL_PIN EXP2_08_PIN #endif #if ENABLED(BQ_LCD_SMART_CONTROLLER) @@ -717,7 +717,7 @@ #define BTN_EN2 AUX4_06_PIN #define BTN_ENC AUX4_03_PIN #define LCD_SDSS SDSS - #define KILL_PIN EXP2_03_PIN + #define KILL_PIN EXP2_08_PIN #elif ENABLED(LCD_I2C_VIKI) @@ -726,91 +726,91 @@ #define BTN_ENC -1 #define LCD_SDSS SDSS - #define SD_DETECT_PIN EXP2_04_PIN + #define SD_DETECT_PIN EXP2_07_PIN - #elif ANY(VIKI2, miniVIKI) + #elif EITHER(VIKI2, miniVIKI) #define DOGLCD_CS AUX4_05_PIN #define DOGLCD_A0 AUX2_07_PIN #define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 - #define BEEPER_PIN EXP2_06_PIN + #define BEEPER_PIN EXP2_05_PIN #define STAT_LED_RED_PIN AUX4_03_PIN - #define STAT_LED_BLUE_PIN EXP1_09_PIN + #define STAT_LED_BLUE_PIN EXP1_02_PIN #define BTN_EN1 22 #define BTN_EN2 7 #define BTN_ENC AUX4_08_PIN #define SD_DETECT_PIN -1 // Pin 49 for display SD interface, 72 for easy adapter board - #define KILL_PIN EXP2_08_PIN + #define KILL_PIN EXP2_03_PIN #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) - #define DOGLCD_CS EXP1_03_PIN - #define DOGLCD_A0 EXP1_04_PIN + #define DOGLCD_CS EXP1_08_PIN + #define DOGLCD_A0 EXP1_07_PIN - #define BEEPER_PIN EXP1_06_PIN - #define LCD_BACKLIGHT_PIN EXP2_06_PIN + #define BEEPER_PIN EXP1_05_PIN + #define LCD_BACKLIGHT_PIN EXP2_05_PIN - #define BTN_EN1 EXP1_09_PIN - #define BTN_EN2 EXP1_10_PIN - #define BTN_ENC EXP2_08_PIN + #define BTN_EN1 EXP1_02_PIN + #define BTN_EN2 EXP1_01_PIN + #define BTN_ENC EXP2_03_PIN #define LCD_SDSS SDSS - #define SD_DETECT_PIN EXP2_04_PIN - #define KILL_PIN EXP2_03_PIN + #define SD_DETECT_PIN EXP2_07_PIN + #define KILL_PIN EXP2_08_PIN #elif EITHER(MKS_MINI_12864, FYSETC_MINI_12864) - #define BEEPER_PIN EXP1_10_PIN - #define BTN_ENC EXP1_09_PIN + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN #ifndef SD_DETECT_PIN - #define SD_DETECT_PIN EXP2_04_PIN + #define SD_DETECT_PIN EXP2_07_PIN #endif #ifndef KILL_PIN - #define KILL_PIN EXP2_03_PIN + #define KILL_PIN EXP2_08_PIN #endif #if ENABLED(MKS_MINI_12864) - #define DOGLCD_A0 EXP1_04_PIN - #define DOGLCD_CS EXP1_05_PIN + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_06_PIN // not connected to a pin #define LCD_BACKLIGHT_PIN -1 // 65 (MKS mini12864 can't adjust backlight by software!) - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN #elif ENABLED(FYSETC_MINI_12864) // From https://wiki.fysetc.com/Mini12864_Panel/ - #define DOGLCD_A0 EXP1_07_PIN - #define DOGLCD_CS EXP1_08_PIN + #define DOGLCD_A0 EXP1_04_PIN + #define DOGLCD_CS EXP1_03_PIN - #define BTN_EN1 EXP2_06_PIN - #define BTN_EN2 EXP2_08_PIN + #define BTN_EN1 EXP2_05_PIN + #define BTN_EN2 EXP2_03_PIN //#define FORCE_SOFT_SPI // Use this if default of hardware SPI causes display problems // results in LCD soft SPI mode 3, SD soft SPI mode 0 - #define LCD_RESET_PIN EXP1_06_PIN // Must be high or open for LCD to operate normally. + #define LCD_RESET_PIN EXP1_05_PIN // Must be high or open for LCD to operate normally. #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) #ifndef RGB_LED_R_PIN - #define RGB_LED_R_PIN EXP1_05_PIN + #define RGB_LED_R_PIN EXP1_06_PIN #endif #ifndef RGB_LED_G_PIN - #define RGB_LED_G_PIN EXP1_04_PIN + #define RGB_LED_G_PIN EXP1_07_PIN #endif #ifndef RGB_LED_B_PIN - #define RGB_LED_B_PIN EXP1_03_PIN + #define RGB_LED_B_PIN EXP1_08_PIN #endif #elif ENABLED(FYSETC_MINI_12864_2_1) - #define NEOPIXEL_PIN EXP1_05_PIN + #define NEOPIXEL_PIN EXP1_06_PIN #endif #endif @@ -840,31 +840,31 @@ #elif ENABLED(G3D_PANEL) - #define BEEPER_PIN EXP1_10_PIN + #define BEEPER_PIN EXP1_01_PIN - #define SD_DETECT_PIN EXP2_04_PIN - #define KILL_PIN EXP2_03_PIN + #define SD_DETECT_PIN EXP2_07_PIN + #define KILL_PIN EXP2_08_PIN - #define BTN_EN1 EXP2_06_PIN - #define BTN_EN2 EXP2_08_PIN - #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 EXP2_05_PIN + #define BTN_EN2 EXP2_03_PIN + #define BTN_ENC EXP1_02_PIN #elif IS_TFTGLCD_PANEL - #define SD_DETECT_PIN EXP2_04_PIN + #define SD_DETECT_PIN EXP2_07_PIN #else - #define BEEPER_PIN EXP2_06_PIN + #define BEEPER_PIN EXP2_05_PIN #if ENABLED(PANEL_ONE) // Buttons connect directly to AUX-2 #define BTN_EN1 AUX2_03_PIN #define BTN_EN2 AUX2_04_PIN #define BTN_ENC AUX3_02_PIN #else - #define BTN_EN1 EXP1_10_PIN - #define BTN_EN2 EXP1_09_PIN - #define BTN_ENC EXP2_08_PIN + #define BTN_EN1 EXP1_01_PIN + #define BTN_EN2 EXP1_02_PIN + #define BTN_ENC EXP2_03_PIN #endif #endif @@ -898,38 +898,38 @@ * * Board Display * ------ ------ - * (MISO) 50 |10 9 | 52 (SCK) 5V |10 9 | GND - * (BTN_EN2) 33 | 8 7 | 53 (SD_CS) RESET | 8 7 | (SD_DET) - * (BTN_EN1) 31 6 5 | 51 (MOSI) (MOSI) 6 5 | (LCD_CS) - * (SD_DET) 49 | 4 3 | RESET (SD_CS) | 4 3 | (MOD_RESET) - * GND | 2 1 | -- (SCK) | 2 1 | (MISO) + * (MISO) 50 | 1 2 | 52 (SCK) 5V |10 9 | GND + * (LCD_CS) 33 | 3 4 | 53 (SD_CS) RESET | 8 7 | (SD_DET) + * 31 5 6 | 51 (MOSI) (MOSI) 6 5 | (LCD_CS) + * (SD_DET) 49 | 7 8 | RESET (SD_CS) | 4 3 | (MOD_RESET) + * GND | 9 10 | -- (SCK) | 2 1 | (MISO) * ------ ------ - * EXP2 + * EXP2 EXP1 * * Needs custom cable: * * Board Adapter Display - * _________ - * EXP2-1 ----------- EXP1-10 - * EXP2-2 ----------- EXP1-9 - * EXP2-4 ----------- EXP1-8 - * EXP2-4 ----------- EXP1-7 - * EXP2-3 ----------- EXP1-6 - * EXP2-6 ----------- EXP1-5 - * EXP2-7 ----------- EXP1-4 - * EXP2-8 ----------- EXP1-3 - * EXP2-1 ----------- EXP1-2 - * EXP1-10 ---------- EXP1-1 + * ---------------------------------- + * EXP2-1 <--diode--- EXP1-1 MISO + * EXP2-2 ----------- EXP1-2 SCK + * EXP2-4 ----------- EXP1-3 MOD_RST + * EXP2-4 ----------- EXP1-4 SD_CS + * EXP2-3 ----------- EXP1-5 LCD_CS + * EXP2-6 ----------- EXP1-6 MOSI + * EXP2-7 ----------- EXP1-7 SD DET + * EXP2-8 ----------- EXP1-8 RESET + * EXP2-1 ----------- EXP1-9 MISO->GND + * EXP1-10 ---------- EXP1-10 5V * * NOTE: The MISO pin should not get a 5V signal. * To fix, insert a 1N4148 diode in the MISO line. */ - #define BEEPER_PIN EXP1_10_PIN + #define BEEPER_PIN EXP1_01_PIN - #define SD_DETECT_PIN EXP2_04_PIN + #define SD_DETECT_PIN EXP2_07_PIN - #define CLCD_MOD_RESET EXP2_06_PIN - #define CLCD_SPI_CS EXP2_08_PIN + #define CLCD_MOD_RESET EXP2_05_PIN + #define CLCD_SPI_CS EXP2_03_PIN #endif // TOUCH_UI_FTDI_EVE && LCD_FYSETC_TFT81050 diff --git a/Marlin/src/pins/ramps/pins_RAMPS_PLUS.h b/Marlin/src/pins/ramps/pins_RAMPS_PLUS.h index 0c554c353f..8ccb14c866 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS_PLUS.h +++ b/Marlin/src/pins/ramps/pins_RAMPS_PLUS.h @@ -65,30 +65,30 @@ /** 3DYMY Expansion Headers * ------ ------ - * 37 |10 9 | 35 (MISO) 50 |10 9 | 52 (SCK) - * 31 | 8 7 | 41 29 | 8 7 | 53 - * 33 6 5 | 23 25 6 5 | 51 (MOSI) - * 42 | 4 3 | 44 49 | 4 3 | 27 - * GND | 2 1 | 5V GND | 2 1 | -- + * 37 | 1 2 | 35 (MISO) 50 | 1 2 | 52 (SCK) + * 31 | 3 4 | 41 29 | 3 4 | 53 + * 33 5 6 | 23 25 5 6 | 51 (MOSI) + * 42 | 7 8 | 44 49 | 7 8 | 27 + * GND | 9 10 | 5V GND | 9 10 | -- * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN 44 -#define EXP1_04_PIN 42 -#define EXP1_05_PIN 23 -#define EXP1_06_PIN 33 -#define EXP1_07_PIN 41 -#define EXP1_08_PIN 31 -#define EXP1_09_PIN 35 -#define EXP1_10_PIN 37 +#define EXP1_01_PIN 37 +#define EXP1_02_PIN 35 +#define EXP1_03_PIN 31 +#define EXP1_04_PIN 41 +#define EXP1_05_PIN 33 +#define EXP1_06_PIN 23 +#define EXP1_07_PIN 42 +#define EXP1_08_PIN 44 -#define EXP2_03_PIN 27 -#define EXP2_04_PIN 49 -#define EXP2_05_PIN 51 -#define EXP2_06_PIN 25 -#define EXP2_07_PIN 53 -#define EXP2_08_PIN 29 -#define EXP2_09_PIN 52 -#define EXP2_10_PIN 50 +#define EXP2_01_PIN 50 +#define EXP2_02_PIN 52 +#define EXP2_03_PIN 29 +#define EXP2_04_PIN 53 +#define EXP2_05_PIN 25 +#define EXP2_06_PIN 51 +#define EXP2_07_PIN 49 +#define EXP2_08_PIN 27 #include "pins_RAMPS.h" diff --git a/Marlin/src/pins/ramps/pins_TRIGORILLA_14.h b/Marlin/src/pins/ramps/pins_TRIGORILLA_14.h index 994a54297f..b685ff0094 100644 --- a/Marlin/src/pins/ramps/pins_TRIGORILLA_14.h +++ b/Marlin/src/pins/ramps/pins_TRIGORILLA_14.h @@ -128,7 +128,7 @@ // LCD Display input pins #if IS_NEWPANEL - #if ANY(VIKI2, miniVIKI) + #if EITHER(VIKI2, miniVIKI) #undef DOGLCD_A0 #define DOGLCD_A0 23 #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) diff --git a/Marlin/src/pins/ramps/pins_ULTIMAKER_OLD.h b/Marlin/src/pins/ramps/pins_ULTIMAKER_OLD.h index 37060ab945..146c519ff9 100644 --- a/Marlin/src/pins/ramps/pins_ULTIMAKER_OLD.h +++ b/Marlin/src/pins/ramps/pins_ULTIMAKER_OLD.h @@ -163,7 +163,7 @@ // // LCD / Controller // -#if ANY(BOARD_REV_1_0, BOARD_REV_1_1_TO_1_3) +#if EITHER(BOARD_REV_1_0, BOARD_REV_1_1_TO_1_3) #define LCD_PINS_RS 24 #define LCD_PINS_ENABLE 22 diff --git a/Marlin/src/pins/ramps/pins_ZRIB_V53.h b/Marlin/src/pins/ramps/pins_ZRIB_V53.h index 48808d9601..cae71f7a8f 100644 --- a/Marlin/src/pins/ramps/pins_ZRIB_V53.h +++ b/Marlin/src/pins/ramps/pins_ZRIB_V53.h @@ -299,33 +299,33 @@ * LCD adapter. NOTE: These come in two variants. The socket keys can be * on either side, and may be backwards on some displays. * ------ ------ - * D37 |10 9 | D35 (MISO) D50 |10 9 | D52 (SCK) - * D17 | 8 7 | D16 D31 | 8 7 | D53 + * D37 | 1 2 | D35 (MISO) D50 | 1 2 | D52 (SCK) + * D17 | 3 4 | D16 D31 | 3 4 | D53 * D23 6 5 D25 D33 6 5 D51 (MOSI) - * D27 | 4 3 | D29 D49 | 4 3 | D41 - * GND | 2 1 | 5V GND | 2 1 | -- + * D27 | 7 8 | D29 D49 | 7 8 | D41 + * GND | 9 10 | 5V GND | 9 10 | -- * ------ ------ * EXP1 EXP2 */ -#ifndef EXP1_03_PIN - #define EXP1_03_PIN 29 - #define EXP1_04_PIN 27 - #define EXP1_05_PIN 25 - #define EXP1_06_PIN 23 - #define EXP1_07_PIN 16 - #define EXP1_08_PIN 17 - #define EXP1_09_PIN 35 - #define EXP1_10_PIN 37 - - #define EXP2_03_PIN 41 - #define EXP2_04_PIN 49 - #define EXP2_05_PIN XS6_05_PIN - #define EXP2_06_PIN 33 - #define EXP2_07_PIN 53 - #define EXP2_08_PIN 31 - #define EXP2_09_PIN XS6_03_PIN - #define EXP2_10_PIN XS6_07_PIN +#ifndef EXP1_08_PIN + #define EXP1_01_PIN 37 + #define EXP1_02_PIN 35 + #define EXP1_03_PIN 17 + #define EXP1_04_PIN 16 + #define EXP1_05_PIN 23 + #define EXP1_06_PIN 25 + #define EXP1_07_PIN 27 + #define EXP1_08_PIN 29 + + #define EXP2_01_PIN XS6_07_PIN + #define EXP2_02_PIN XS6_03_PIN + #define EXP2_03_PIN 31 + #define EXP2_04_PIN 53 + #define EXP2_05_PIN 33 + #define EXP2_06_PIN XS6_05_PIN + #define EXP2_07_PIN 49 + #define EXP2_08_PIN 41 #endif ////////////////////////// @@ -386,14 +386,14 @@ #if ENABLED(ZONESTAR_LCD) #define LCDSCREEN_NAME "LCD2004 ADCKEY" - #define LCD_PINS_RS EXP1_07_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN #define ADC_KEYPAD_PIN 10 // A10 for ADCKEY - #define BEEPER_PIN EXP1_10_PIN + #define BEEPER_PIN EXP1_01_PIN #endif /** diff --git a/Marlin/src/pins/sam/pins_ARCHIM2.h b/Marlin/src/pins/sam/pins_ARCHIM2.h index ecff888ff0..310dd8e2ac 100644 --- a/Marlin/src/pins/sam/pins_ARCHIM2.h +++ b/Marlin/src/pins/sam/pins_ARCHIM2.h @@ -245,8 +245,6 @@ #define LCD_PINS_D5 54 // D54 PA16_SCK1 #define LCD_PINS_D6 68 // D68 PA1_CANRX0 #define LCD_PINS_D7 34 // D34 PC2_PWML0 - - #define SD_DETECT_PIN 2 // D2 PB25_TIOA0 #endif #if ANY(IS_ULTIPANEL, TOUCH_UI_ULTIPANEL, TOUCH_UI_FTDI_EVE) @@ -255,3 +253,10 @@ #define BTN_EN2 13 // D13 PB27_TIOB0 #define BTN_ENC 16 // D16 PA13_TXD1 // the click #endif + +#if ANY(HAS_WIRED_LCD, TOUCH_UI_ULTIPANEL, TOUCH_UI_FTDI_EVE, USB_FLASH_DRIVE_SUPPORT) + #define SD_DETECT_PIN 2 // D2 PB25_TIOA0 + #if ENABLED(USB_FLASH_DRIVE_SUPPORT) + #define DISABLE_DUE_SD_MMC + #endif +#endif diff --git a/Marlin/src/pins/sam/pins_RAMPS_FD_V1.h b/Marlin/src/pins/sam/pins_RAMPS_FD_V1.h index 980a957a50..00eba994a8 100644 --- a/Marlin/src/pins/sam/pins_RAMPS_FD_V1.h +++ b/Marlin/src/pins/sam/pins_RAMPS_FD_V1.h @@ -135,31 +135,31 @@ #define LED_PIN 13 /** ------ ------ - * 37 |10 9 | 35 (MISO) 50 |10 9 | 76 (SCK) - * 29 | 8 7 | 27 (EN2) 31 | 8 7 | 4 (SD_SS) - * 25 6 5 | 23 (EN1) 33 6 5 | 75 (MOSI) - * 16 | 4 3 | 17 (SDD) 49 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | -- + * 37 | 1 2 | 35 (MISO) 50 | 1 2 | 76 (SCK) + * 29 | 3 4 | 27 (EN2) 31 | 3 4 | 4 (SD_SS) + * 25 5 6 | 23 (EN1) 33 5 6 | 75 (MOSI) + * 16 | 7 8 | 17 (SDD) 49 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN 17 -#define EXP1_04_PIN 16 -#define EXP1_05_PIN 23 -#define EXP1_06_PIN 25 -#define EXP1_07_PIN 27 -#define EXP1_08_PIN 29 -#define EXP1_09_PIN 35 -#define EXP1_10_PIN 37 - -#define EXP2_03_PIN -1 -#define EXP2_04_PIN 49 -#define EXP2_05_PIN 75 -#define EXP2_06_PIN 33 -#define EXP2_07_PIN 4 -#define EXP2_08_PIN 31 -#define EXP2_09_PIN 76 -#define EXP2_10_PIN 74 +#define EXP1_01_PIN 37 +#define EXP1_02_PIN 35 +#define EXP1_03_PIN 29 +#define EXP1_04_PIN 27 +#define EXP1_05_PIN 25 +#define EXP1_06_PIN 23 +#define EXP1_07_PIN 16 +#define EXP1_08_PIN 17 + +#define EXP2_01_PIN 74 +#define EXP2_02_PIN 76 +#define EXP2_03_PIN 31 +#define EXP2_04_PIN 4 +#define EXP2_05_PIN 33 +#define EXP2_06_PIN 75 +#define EXP2_07_PIN 49 +#define EXP2_08_PIN -1 // // LCD / Controller @@ -167,65 +167,65 @@ #if HAS_WIRED_LCD // ramps-fd lcd adaptor - #define BEEPER_PIN EXP1_10_PIN - #define BTN_EN1 EXP2_06_PIN - #define BTN_EN2 EXP2_08_PIN - #define BTN_ENC EXP1_09_PIN - #define SD_DETECT_PIN EXP2_04_PIN + #define BEEPER_PIN EXP1_01_PIN + #define BTN_EN1 EXP2_05_PIN + #define BTN_EN2 EXP2_03_PIN + #define BTN_ENC EXP1_02_PIN + #define SD_DETECT_PIN EXP2_07_PIN #if IS_NEWPANEL - #define LCD_PINS_RS EXP1_04_PIN - #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN #endif #if ENABLED(FYSETC_MINI_12864) #define DOGLCD_CS LCD_PINS_ENABLE #define DOGLCD_A0 LCD_PINS_RS - #define DOGLCD_SCK EXP2_09_PIN - #define DOGLCD_MOSI EXP2_05_PIN + #define DOGLCD_SCK EXP2_02_PIN + #define DOGLCD_MOSI EXP2_06_PIN //#define FORCE_SOFT_SPI // Use this if default of hardware SPI causes display problems // results in LCD soft SPI mode 3, SD soft SPI mode 0 - #define LCD_RESET_PIN EXP1_05_PIN // Must be high or open for LCD to operate normally. + #define LCD_RESET_PIN EXP1_06_PIN // Must be high or open for LCD to operate normally. #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) #ifndef RGB_LED_R_PIN - #define RGB_LED_R_PIN EXP1_06_PIN + #define RGB_LED_R_PIN EXP1_05_PIN #endif #ifndef RGB_LED_G_PIN - #define RGB_LED_G_PIN EXP1_07_PIN + #define RGB_LED_G_PIN EXP1_04_PIN #endif #ifndef RGB_LED_B_PIN - #define RGB_LED_B_PIN EXP1_08_PIN + #define RGB_LED_B_PIN EXP1_03_PIN #endif #elif ENABLED(FYSETC_MINI_12864_2_1) - #define NEOPIXEL_PIN EXP1_06_PIN + #define NEOPIXEL_PIN EXP1_05_PIN #endif #elif IS_NEWPANEL - #define LCD_PINS_D4 EXP1_05_PIN - #define LCD_PINS_D5 EXP1_06_PIN - #define LCD_PINS_D6 EXP1_07_PIN - #define LCD_PINS_D7 EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_D5 EXP1_05_PIN + #define LCD_PINS_D6 EXP1_04_PIN + #define LCD_PINS_D7 EXP1_03_PIN #if ENABLED(MINIPANEL) - #define DOGLCD_CS EXP1_06_PIN - #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_05_PIN + #define DOGLCD_A0 EXP1_04_PIN #endif #endif - #if ANY(VIKI2, miniVIKI) - #define DOGLCD_A0 EXP1_04_PIN + #if EITHER(VIKI2, miniVIKI) + #define DOGLCD_A0 EXP1_07_PIN #define KILL_PIN 51 - #define STAT_LED_BLUE_PIN EXP1_08_PIN - #define STAT_LED_RED_PIN EXP1_05_PIN - #define DOGLCD_CS EXP1_03_PIN - #define DOGLCD_SCK EXP2_09_PIN // SCK_PIN - Required for DUE Hardware SPI - #define DOGLCD_MOSI EXP2_05_PIN // MOSI_PIN - #define DOGLCD_MISO EXP2_10_PIN // MISO_PIN + #define STAT_LED_BLUE_PIN EXP1_03_PIN + #define STAT_LED_RED_PIN EXP1_06_PIN + #define DOGLCD_CS EXP1_08_PIN + #define DOGLCD_SCK EXP2_02_PIN // SCK_PIN - Required for DUE Hardware SPI + #define DOGLCD_MOSI EXP2_06_PIN // MOSI_PIN + #define DOGLCD_MISO EXP2_01_PIN // MISO_PIN #endif #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) diff --git a/Marlin/src/pins/sam/pins_RAMPS_SMART.h b/Marlin/src/pins/sam/pins_RAMPS_SMART.h index 2b8942c6ad..b02ddef166 100644 --- a/Marlin/src/pins/sam/pins_RAMPS_SMART.h +++ b/Marlin/src/pins/sam/pins_RAMPS_SMART.h @@ -110,31 +110,31 @@ #else /** ------ ------ - * 37 |10 9 | 35 (MISO) 50 |10 9 | 52 (SCK) - * 31 | 8 7 | 41 29 | 8 7 | 53 - * 33 6 5 | 23 25 6 5 | 51 (MOSI) - * 42 | 4 3 | 44 49 | 4 3 | 27 - * GND | 2 1 | 5V GND | 2 1 | -- + * 37 | 1 2 | 35 (MISO) 50 | 1 2 | 52 (SCK) + * 31 | 3 4 | 41 29 | 3 4 | 53 + * 33 5 6 | 23 25 5 6 | 51 (MOSI) + * 42 | 7 8 | 44 49 | 7 8 | 27 + * GND | 9 10 | 5V GND | 9 10 | -- * ------ ------ * EXP1 EXP2 */ - #define EXP1_03_PIN 44 - #define EXP1_04_PIN 42 - #define EXP1_05_PIN 23 - #define EXP1_06_PIN 33 - #define EXP1_07_PIN 41 - #define EXP1_08_PIN 31 - #define EXP1_09_PIN 35 - #define EXP1_10_PIN 37 + #define EXP1_01_PIN 37 + #define EXP1_02_PIN 35 + #define EXP1_03_PIN 31 + #define EXP1_04_PIN 41 + #define EXP1_05_PIN 33 + #define EXP1_06_PIN 23 + #define EXP1_07_PIN 42 + #define EXP1_08_PIN 44 - #define EXP2_03_PIN 27 - #define EXP2_04_PIN 49 - #define EXP2_05_PIN 51 - #define EXP2_06_PIN 25 - #define EXP2_07_PIN 53 - #define EXP2_08_PIN 29 - #define EXP2_09_PIN 52 - #define EXP2_10_PIN 50 + #define EXP2_01_PIN 50 + #define EXP2_02_PIN 52 + #define EXP2_03_PIN 29 + #define EXP2_04_PIN 53 + #define EXP2_05_PIN 25 + #define EXP2_06_PIN 51 + #define EXP2_07_PIN 49 + #define EXP2_08_PIN 27 #endif diff --git a/Marlin/src/pins/sam/pins_RURAMPS4D_11.h b/Marlin/src/pins/sam/pins_RURAMPS4D_11.h index 064ce2751a..f8ea65a369 100644 --- a/Marlin/src/pins/sam/pins_RURAMPS4D_11.h +++ b/Marlin/src/pins/sam/pins_RURAMPS4D_11.h @@ -146,7 +146,7 @@ // SPI for MAX Thermocouple /* #if DISABLED(SDSUPPORT) - #define TEMP_0_CS_PIN EXP1_03_PIN + #define TEMP_0_CS_PIN EXP1_08_PIN #else #define TEMP_0_CS_PIN 49 #endif @@ -185,31 +185,31 @@ /** * ------ ------ - * (BEEPER) 62 |10 9 | 40 (BTN_ENC) (MISO) 74 |10 9 | 76 (SCK) - * (LCD_EN) 64 | 8 7 | 63 (LCD_RS) (BTN_EN1) 44 | 8 7 | 10 (SD_SS) - * (LCD_D4) 48 | 6 5 50 (LCD_D5) (BTN_EN2) 42 | 6 5 75 (MOSI) - * (LCD_D6) 52 | 4 3 | 53 (LCD_D7) (SD_DETECT) 51 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | -- + * (BEEPER) 62 | 1 2 | 40 (BTN_ENC) (MISO) 74 | 1 2 | 76 (SCK) + * (LCD_EN) 64 | 3 4 | 63 (LCD_RS) (BTN_EN1) 44 | 3 4 | 10 (SD_SS) + * (LCD_D4) 48 | 5 6 50 (LCD_D5) (BTN_EN2) 42 | 5 6 75 (MOSI) + * (LCD_D6) 52 | 7 8 | 53 (LCD_D7) (SD_DETECT) 51 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN 53 -#define EXP1_04_PIN 52 -#define EXP1_05_PIN 50 -#define EXP1_06_PIN 48 -#define EXP1_07_PIN 63 -#define EXP1_08_PIN 64 -#define EXP1_09_PIN 40 -#define EXP1_10_PIN 62 - -#define EXP2_03_PIN -1 // RESET -#define EXP2_04_PIN 51 -#define EXP2_05_PIN 75 // MOSI -#define EXP2_06_PIN 42 -#define EXP2_07_PIN 10 -#define EXP2_08_PIN 44 -#define EXP2_09_PIN 76 // SCK -#define EXP2_10_PIN 74 // MISO +#define EXP1_01_PIN 62 +#define EXP1_02_PIN 40 +#define EXP1_03_PIN 64 +#define EXP1_04_PIN 63 +#define EXP1_05_PIN 48 +#define EXP1_06_PIN 50 +#define EXP1_07_PIN 52 +#define EXP1_08_PIN 53 + +#define EXP2_01_PIN 74 // MISO +#define EXP2_02_PIN 76 // SCK +#define EXP2_03_PIN 44 +#define EXP2_04_PIN 10 +#define EXP2_05_PIN 42 +#define EXP2_06_PIN 75 // MOSI +#define EXP2_07_PIN 51 +#define EXP2_08_PIN -1 // RESET // // LCD / Controller @@ -217,53 +217,53 @@ #if HAS_WIRED_LCD #if ANY(RADDS_DISPLAY, IS_RRD_SC, IS_RRD_FG_SC) - #define BEEPER_PIN EXP1_10_PIN - #define LCD_PINS_D4 EXP1_06_PIN - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN - #define SD_DETECT_PIN EXP2_04_PIN + #define BEEPER_PIN EXP1_01_PIN + #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN + #define SD_DETECT_PIN EXP2_07_PIN #endif #if EITHER(RADDS_DISPLAY, IS_RRD_SC) - #define LCD_PINS_RS EXP1_07_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN #elif IS_RRD_FG_SC - #define LCD_PINS_RS EXP1_04_PIN - #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN #elif HAS_U8GLIB_I2C_OLED - #define BEEPER_PIN EXP1_10_PIN - #define LCD_SDSS EXP2_07_PIN - #define SD_DETECT_PIN EXP2_04_PIN + #define BEEPER_PIN EXP1_01_PIN + #define LCD_SDSS EXP2_04_PIN + #define SD_DETECT_PIN EXP2_07_PIN #elif ENABLED(FYSETC_MINI_12864) - #define BEEPER_PIN EXP1_10_PIN - #define DOGLCD_CS EXP1_08_PIN - #define DOGLCD_A0 EXP1_07_PIN + #define BEEPER_PIN EXP1_01_PIN + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN //#define FORCE_SOFT_SPI // Use this if default of hardware SPI causes display problems // results in LCD soft SPI mode 3, SD soft SPI mode 0 - #define LCD_RESET_PIN EXP1_06_PIN // Must be high or open for LCD to operate normally. + #define LCD_RESET_PIN EXP1_05_PIN // Must be high or open for LCD to operate normally. #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) #ifndef RGB_LED_R_PIN - #define RGB_LED_R_PIN EXP1_05_PIN // D5 + #define RGB_LED_R_PIN EXP1_06_PIN // D5 #endif #ifndef RGB_LED_G_PIN - #define RGB_LED_G_PIN EXP1_04_PIN // D6 + #define RGB_LED_G_PIN EXP1_07_PIN // D6 #endif #ifndef RGB_LED_B_PIN - #define RGB_LED_B_PIN EXP1_03_PIN // D7 + #define RGB_LED_B_PIN EXP1_08_PIN // D7 #endif #elif ENABLED(FYSETC_MINI_12864_2_1) - #define NEOPIXEL_PIN EXP1_05_PIN // D5 + #define NEOPIXEL_PIN EXP1_06_PIN // D5 #endif #elif ENABLED(SPARK_FULL_GRAPHICS) @@ -280,9 +280,9 @@ #endif // SPARK_FULL_GRAPHICS #if IS_NEWPANEL - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN - #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + #define BTN_ENC EXP1_02_PIN #endif #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) diff --git a/Marlin/src/pins/sam/pins_RURAMPS4D_13.h b/Marlin/src/pins/sam/pins_RURAMPS4D_13.h index cc919d0a4f..58cb3f7a75 100644 --- a/Marlin/src/pins/sam/pins_RURAMPS4D_13.h +++ b/Marlin/src/pins/sam/pins_RURAMPS4D_13.h @@ -175,31 +175,31 @@ /** * ------ ------ - * (BEEPER) 62 |10 9 | 40 (BTN_ENC) (MISO) 74 |10 9 | 76 (SCK) - * (LCD_EN) 64 | 8 7 | 63 (LCD_RS) (BTN_EN1) 44 | 8 7 | 10 (SD_SS) - * (LCD_D4) 48 | 6 5 50 (LCD_D5) (BTN_EN2) 42 | 6 5 75 (MOSI) - * (LCD_D6) 52 | 4 3 | 53 (LCD_D7) (SD_DETECT) 51 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | -- + * (BEEPER) 62 | 1 2 | 40 (BTN_ENC) (MISO) 74 | 1 2 | 76 (SCK) + * (LCD_EN) 64 | 3 4 | 63 (LCD_RS) (BTN_EN1) 44 | 3 4 | 10 (SD_SS) + * (LCD_D4) 48 | 5 6 50 (LCD_D5) (BTN_EN2) 42 | 5 6 75 (MOSI) + * (LCD_D6) 52 | 7 8 | 53 (LCD_D7) (SD_DETECT) 51 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN 53 -#define EXP1_04_PIN 52 -#define EXP1_05_PIN 50 -#define EXP1_06_PIN 48 -#define EXP1_07_PIN 63 -#define EXP1_08_PIN 64 -#define EXP1_09_PIN 40 -#define EXP1_10_PIN 62 - -#define EXP2_03_PIN -1 // RESET -#define EXP2_04_PIN 51 -#define EXP2_05_PIN 75 // MOSI -#define EXP2_06_PIN 42 -#define EXP2_07_PIN 10 -#define EXP2_08_PIN 44 -#define EXP2_09_PIN 76 // SCK -#define EXP2_10_PIN 74 // MISO +#define EXP1_01_PIN 62 +#define EXP1_02_PIN 40 +#define EXP1_03_PIN 64 +#define EXP1_04_PIN 63 +#define EXP1_05_PIN 48 +#define EXP1_06_PIN 50 +#define EXP1_07_PIN 52 +#define EXP1_08_PIN 53 + +#define EXP2_01_PIN 74 // MISO +#define EXP2_02_PIN 76 // SCK +#define EXP2_03_PIN 44 +#define EXP2_04_PIN 10 +#define EXP2_05_PIN 42 +#define EXP2_06_PIN 75 // MOSI +#define EXP2_07_PIN 51 +#define EXP2_08_PIN -1 // RESET // // LCD / Controller @@ -207,67 +207,67 @@ #if HAS_WIRED_LCD #if ANY(RADDS_DISPLAY, IS_RRD_SC, IS_RRD_FG_SC) - #define BEEPER_PIN EXP1_10_PIN - #define LCD_PINS_D4 EXP1_06_PIN - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN - #define SD_DETECT_PIN EXP2_04_PIN + #define BEEPER_PIN EXP1_01_PIN + #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN + #define SD_DETECT_PIN EXP2_07_PIN #endif #if EITHER(RADDS_DISPLAY, IS_RRD_SC) - #define LCD_PINS_RS EXP1_07_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN #elif IS_RRD_FG_SC - #define LCD_PINS_RS EXP1_04_PIN - #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN #elif HAS_U8GLIB_I2C_OLED - #define BEEPER_PIN EXP1_10_PIN - #define LCD_SDSS EXP2_07_PIN - #define SD_DETECT_PIN EXP2_04_PIN + #define BEEPER_PIN EXP1_01_PIN + #define LCD_SDSS EXP2_04_PIN + #define SD_DETECT_PIN EXP2_07_PIN #elif ENABLED(FYSETC_MINI_12864) - #define BEEPER_PIN EXP1_10_PIN - #define DOGLCD_CS EXP1_08_PIN - #define DOGLCD_A0 EXP1_07_PIN + #define BEEPER_PIN EXP1_01_PIN + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN //#define FORCE_SOFT_SPI // Use this if default of hardware SPI causes display problems // results in LCD soft SPI mode 3, SD soft SPI mode 0 - #define LCD_RESET_PIN EXP1_06_PIN // Must be high or open for LCD to operate normally. + #define LCD_RESET_PIN EXP1_05_PIN // Must be high or open for LCD to operate normally. #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) #ifndef RGB_LED_R_PIN - #define RGB_LED_R_PIN EXP1_05_PIN // D5 + #define RGB_LED_R_PIN EXP1_06_PIN // D5 #endif #ifndef RGB_LED_G_PIN - #define RGB_LED_G_PIN EXP1_04_PIN // D6 + #define RGB_LED_G_PIN EXP1_07_PIN // D6 #endif #ifndef RGB_LED_B_PIN - #define RGB_LED_B_PIN EXP1_03_PIN // D7 + #define RGB_LED_B_PIN EXP1_08_PIN // D7 #endif #elif ENABLED(FYSETC_MINI_12864_2_1) - #define NEOPIXEL_PIN EXP1_05_PIN // D5 + #define NEOPIXEL_PIN EXP1_06_PIN // D5 #endif #elif ENABLED(MKS_MINI_12864) - #define DOGLCD_A0 EXP1_04_PIN - #define DOGLCD_CS EXP1_05_PIN + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_06_PIN - #define SD_DETECT_PIN EXP2_04_PIN + #define SD_DETECT_PIN EXP2_07_PIN #endif #if IS_NEWPANEL - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN - #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + #define BTN_ENC EXP1_02_PIN #endif #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) diff --git a/Marlin/src/pins/samd/pins_BRICOLEMON_LITE_V1_0.h b/Marlin/src/pins/samd/pins_BRICOLEMON_LITE_V1_0.h index 382c607d23..a3f98e388a 100644 --- a/Marlin/src/pins/samd/pins_BRICOLEMON_LITE_V1_0.h +++ b/Marlin/src/pins/samd/pins_BRICOLEMON_LITE_V1_0.h @@ -166,33 +166,33 @@ * BTN_ENCODER 40 KILL_PIN 49 */ -#define EXP1_03_PIN 39 -#define EXP1_04_PIN 38 -#define EXP1_05_PIN 37 -#define EXP1_06_PIN 36 -#define EXP1_07_PIN 34 -#define EXP1_08_PIN 35 -#define EXP1_09_PIN 40 -#define EXP1_10_PIN 41 - -#define EXP2_01_PIN 49 -#define EXP2_04_PIN 44 -#define EXP2_05_PIN 51 -#define EXP2_06_PIN 42 -#define EXP2_07_PIN 53 -#define EXP2_08_PIN 43 -#define EXP2_09_PIN 52 -#define EXP2_10_PIN 50 +#define EXP1_01_PIN 41 +#define EXP1_02_PIN 40 +#define EXP1_03_PIN 35 +#define EXP1_04_PIN 34 +#define EXP1_05_PIN 36 +#define EXP1_06_PIN 37 +#define EXP1_07_PIN 38 +#define EXP1_08_PIN 39 + +#define EXP2_01_PIN 50 +#define EXP2_02_PIN 52 +#define EXP2_03_PIN 43 +#define EXP2_04_PIN 53 +#define EXP2_05_PIN 42 +#define EXP2_06_PIN 51 +#define EXP2_07_PIN 44 +#define EXP2_10_PIN 49 #if ENABLED(CR10_STOCKDISPLAY) + #define EXP3_01_PIN EXP1_01_PIN + #define EXP3_02_PIN EXP1_02_PIN #define EXP3_03_PIN EXP1_03_PIN #define EXP3_04_PIN EXP1_04_PIN #define EXP3_05_PIN EXP1_05_PIN #define EXP3_06_PIN EXP1_06_PIN #define EXP3_07_PIN EXP1_07_PIN #define EXP3_08_PIN EXP1_08_PIN - #define EXP3_09_PIN EXP1_09_PIN - #define EXP3_10_PIN EXP1_10_PIN #endif /************************************/ @@ -222,30 +222,30 @@ #endif // DWIN Encoder - #define BTN_ENC EXP1_09_PIN - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_07_PIN + #define BTN_ENC EXP1_02_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_04_PIN #ifndef BEEPER_PIN - #define BEEPER_PIN EXP1_10_PIN + #define BEEPER_PIN EXP1_01_PIN #undef SPEAKER #endif #elif ENABLED(REPRAPWORLD_GRAPHICAL_LCD) // TO TEST - //#define LCD_PINS_RS EXP2_01_PIN // CS chip select /SS chip slave select - //#define LCD_PINS_ENABLE EXP2_05_PIN // SID (MOSI) - //#define LCD_PINS_D4 EXP2_09_PIN // SCK (CLK) clock + //#define LCD_PINS_RS EXP2_10_PIN // CS chip select /SS chip slave select + //#define LCD_PINS_ENABLE EXP2_06_PIN // SID (MOSI) + //#define LCD_PINS_D4 EXP2_02_PIN // SCK (CLK) clock #elif BOTH(IS_NEWPANEL, PANEL_ONE) // TO TEST - //#define LCD_PINS_RS EXP1_09_PIN - //#define LCD_PINS_ENABLE EXP2_06_PIN + //#define LCD_PINS_RS EXP1_02_PIN + //#define LCD_PINS_ENABLE EXP2_05_PIN //#define LCD_PINS_D4 57 // Mega/Due:65 - AGCM4:57 //#define LCD_PINS_D5 58 // Mega/Due:66 - AGCM4:58 - //#define LCD_PINS_D6 EXP2_04_PIN + //#define LCD_PINS_D6 EXP2_07_PIN //#define LCD_PINS_D7 56 // Mega/Due:64 - AGCM4:56 #else @@ -266,10 +266,10 @@ // TO TEST //#define LCD_PINS_RS 56 // Mega/Due:64 - AGCM4:56 - //#define LCD_PINS_ENABLE EXP2_04_PIN + //#define LCD_PINS_ENABLE EXP2_07_PIN //#define LCD_PINS_D4 55 // Mega/Due:63 - AGCM4:55 - //#define LCD_PINS_D5 EXP1_09_PIN - //#define LCD_PINS_D6 EXP2_06_PIN + //#define LCD_PINS_D5 EXP1_02_PIN + //#define LCD_PINS_D6 EXP2_05_PIN //#define LCD_PINS_D7 57 // Mega/Due:65 - AGCM4:57 #else @@ -287,17 +287,17 @@ #else // Definitions for any standard Display - #define LCD_PINS_RS EXP1_07_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN + #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN #endif - #define LCD_PINS_D7 EXP1_03_PIN + #define LCD_PINS_D7 EXP1_08_PIN #if !IS_NEWPANEL - #define BEEPER_PIN EXP1_10_PIN + #define BEEPER_PIN EXP1_01_PIN #endif #endif @@ -305,9 +305,9 @@ #if !IS_NEWPANEL // Buttons attached to a shift register // Not wired yet - //#define SHIFT_CLK_PIN EXP1_04_PIN - //#define SHIFT_LD_PIN EXP2_06_PIN - //#define SHIFT_OUT_PIN EXP1_09_PIN + //#define SHIFT_CLK_PIN EXP1_07_PIN + //#define SHIFT_LD_PIN EXP2_05_PIN + //#define SHIFT_OUT_PIN EXP1_02_PIN //#define SHIFT_EN_PIN 17 #endif @@ -320,7 +320,7 @@ #if IS_RRD_SC - #define BEEPER_PIN EXP1_10_PIN + #define BEEPER_PIN EXP1_01_PIN #if ENABLED(CR10_STOCKDISPLAY) // TO TEST @@ -329,21 +329,21 @@ #else // Definitions for any standard Display - #define BTN_EN1 EXP2_06_PIN - #define BTN_EN2 EXP2_08_PIN + #define BTN_EN1 EXP2_05_PIN + #define BTN_EN2 EXP2_03_PIN #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder #endif #endif - #define BTN_ENC EXP1_09_PIN + #define BTN_ENC EXP1_02_PIN #ifndef SD_DETECT_PIN - #define SD_DETECT_PIN EXP2_04_PIN + #define SD_DETECT_PIN EXP2_07_PIN #endif - #define KILL_PIN EXP2_01_PIN + #define KILL_PIN EXP2_10_PIN #if ENABLED(BQ_LCD_SMART_CONTROLLER) - //#define LCD_BACKLIGHT_PIN EXP1_03_PIN // TO TEST + //#define LCD_BACKLIGHT_PIN EXP1_08_PIN // TO TEST #endif #elif ENABLED(REPRAPWORLD_GRAPHICAL_LCD) @@ -352,41 +352,41 @@ //#define BTN_EN1 56 // Mega/Due:64 - AGCM4:56 //#define BTN_EN2 72 // Mega/Due:59 - AGCM4:72 //#define BTN_ENC 55 - //#define SD_DETECT_PIN EXP2_06_PIN + //#define SD_DETECT_PIN EXP2_05_PIN #elif ENABLED(LCD_I2C_PANELOLU2) // TO TEST //#define BTN_EN1 47 - //#define BTN_EN2 EXP2_08_PIN + //#define BTN_EN2 EXP2_03_PIN //#define BTN_ENC 32 //#define LCD_SDSS SDSS - //#define KILL_PIN EXP1_10_PIN + //#define KILL_PIN EXP1_01_PIN #elif ENABLED(LCD_I2C_VIKI) // TO TEST - //#define BTN_EN1 EXP1_09_PIN // https://files.panucatt.com/datasheets/viki_wiring_diagram.pdf explains 40/42. - //#define BTN_EN2 EXP2_06_PIN + //#define BTN_EN1 EXP1_02_PIN // https://files.panucatt.com/datasheets/viki_wiring_diagram.pdf explains 40/42. + //#define BTN_EN2 EXP2_05_PIN //#define BTN_ENC -1 //#define LCD_SDSS SDSS - //#define SD_DETECT_PIN EXP2_01_PIN + //#define SD_DETECT_PIN EXP2_10_PIN - #elif ANY(VIKI2, miniVIKI) + #elif EITHER(VIKI2, miniVIKI) // TO TEST //#define DOGLCD_CS 45 - //#define DOGLCD_A0 EXP2_04_PIN + //#define DOGLCD_A0 EXP2_07_PIN //#define LCD_SCREEN_ROT_180 //#define BEEPER_PIN 33 //#define STAT_LED_RED_PIN 32 - //#define STAT_LED_BLUE_PIN EXP1_08_PIN + //#define STAT_LED_BLUE_PIN EXP1_03_PIN //#define BTN_EN1 22 //#define BTN_EN2 7 - //#define BTN_ENC EXP1_03_PIN + //#define BTN_ENC EXP1_08_PIN //#define SD_DETECT_PIN -1 // Pin 49 for display SD interface, 72 for easy adapter board //#define KILL_PIN 31 @@ -400,23 +400,23 @@ //#define BEEPER_PIN 23 //#define LCD_BACKLIGHT_PIN 33 - //#define BTN_EN1 EXP1_08_PIN - //#define BTN_EN2 EXP1_05_PIN + //#define BTN_EN1 EXP1_03_PIN + //#define BTN_EN2 EXP1_06_PIN //#define BTN_ENC 31 //#define LCD_SDSS SDSS - //#define SD_DETECT_PIN EXP2_01_PIN - //#define KILL_PIN EXP1_10_PIN + //#define SD_DETECT_PIN EXP2_10_PIN + //#define KILL_PIN EXP1_01_PIN #elif EITHER(MKS_MINI_12864, FYSETC_MINI_12864) // TO TEST - //#define BEEPER_PIN EXP1_05_PIN - //#define BTN_ENC EXP1_08_PIN - //#define SD_DETECT_PIN EXP2_01_PIN + //#define BEEPER_PIN EXP1_06_PIN + //#define BTN_ENC EXP1_03_PIN + //#define SD_DETECT_PIN EXP2_10_PIN //#ifndef KILL_PIN - // #define KILL_PIN EXP1_10_PIN + // #define KILL_PIN EXP1_01_PIN //#endif #if ENABLED(MKS_MINI_12864) @@ -476,11 +476,11 @@ #elif ENABLED(MINIPANEL) // TO TEST - //#define BEEPER_PIN EXP2_06_PIN + //#define BEEPER_PIN EXP2_05_PIN // not connected to a pin //#define LCD_BACKLIGHT_PIN 57 // backlight LED on A11/D? (Mega/Due:65 - AGCM4:57) - //#define DOGLCD_A0 EXP2_04_PIN + //#define DOGLCD_A0 EXP2_07_PIN //#define DOGLCD_CS 58 // Mega/Due:66 - AGCM4:58 // GLCD features @@ -489,11 +489,11 @@ //#define LCD_SCREEN_ROT_180 //#define LCD_SCREEN_ROT_270 - //#define BTN_EN1 EXP1_09_PIN + //#define BTN_EN1 EXP1_02_PIN //#define BTN_EN2 55 // Mega/Due:63 - AGCM4:55 //#define BTN_ENC 72 // Mega/Due:59 - AGCM4:72 - //#define SD_DETECT_PIN EXP2_01_PIN + //#define SD_DETECT_PIN EXP2_10_PIN //#define KILL_PIN 56 // Mega/Due:64 - AGCM4:56 #elif ENABLED(ZONESTAR_LCD) @@ -513,9 +513,9 @@ // Buttons are directly attached to AUX-2 #if IS_RRW_KEYPAD // TO TEST - //#define SHIFT_OUT_PIN EXP1_09_PIN - //#define SHIFT_CLK_PIN EXP2_04_PIN - //#define SHIFT_LD_PIN EXP2_06_PIN + //#define SHIFT_OUT_PIN EXP1_02_PIN + //#define SHIFT_CLK_PIN EXP2_07_PIN + //#define SHIFT_LD_PIN EXP2_05_PIN //#define BTN_EN1 56 // Mega/Due:64 - AGCM4:56 //#define BTN_EN2 72 // Mega/Due:59 - AGCM4:72 //#define BTN_ENC 55 // Mega/Due:63 - AGCM4:55 @@ -523,18 +523,18 @@ // TO TEST //#define BTN_EN1 72 // AUX2 PIN 3 (Mega/Due:59 - AGCM4:72) //#define BTN_EN2 55 // AUX2 PIN 4 (Mega/Due:63 - AGCM4:55) - //#define BTN_ENC EXP2_01_PIN // AUX3 PIN 7 + //#define BTN_ENC EXP2_10_PIN // AUX3 PIN 7 #else // TO TEST - //#define BTN_EN1 EXP1_05_PIN - //#define BTN_EN2 EXP1_08_PIN + //#define BTN_EN1 EXP1_06_PIN + //#define BTN_EN2 EXP1_03_PIN //#define BTN_ENC 31 #endif #if ENABLED(G3D_PANEL) // TO TEST - //#define SD_DETECT_PIN EXP2_01_PIN - //#define KILL_PIN EXP1_10_PIN + //#define SD_DETECT_PIN EXP2_10_PIN + //#define KILL_PIN EXP1_01_PIN #endif #endif @@ -565,7 +565,7 @@ #undef SD_DETECT_PIN #define SD_DETECT_PIN 95 #else - #define SDSS EXP2_07_PIN + #define SDSS EXP2_04_PIN #endif #if HAS_TMC_UART diff --git a/Marlin/src/pins/samd/pins_BRICOLEMON_V1_0.h b/Marlin/src/pins/samd/pins_BRICOLEMON_V1_0.h index 0f4bb1d0b5..2343dbcf82 100644 --- a/Marlin/src/pins/samd/pins_BRICOLEMON_V1_0.h +++ b/Marlin/src/pins/samd/pins_BRICOLEMON_V1_0.h @@ -218,33 +218,33 @@ * BTN_ENCODER 40 */ -#define EXP1_03_PIN 39 -#define EXP1_04_PIN 38 -#define EXP1_05_PIN 37 -#define EXP1_06_PIN 36 -#define EXP1_07_PIN 34 -#define EXP1_08_PIN 35 -#define EXP1_09_PIN 40 -#define EXP1_10_PIN 41 - -#define EXP2_01_PIN 49 -#define EXP2_04_PIN 44 -#define EXP2_05_PIN 51 -#define EXP2_06_PIN 42 -#define EXP2_07_PIN 53 -#define EXP2_08_PIN 43 -#define EXP2_09_PIN 52 -#define EXP2_10_PIN 50 +#define EXP1_01_PIN 41 +#define EXP1_02_PIN 40 +#define EXP1_03_PIN 35 +#define EXP1_04_PIN 34 +#define EXP1_05_PIN 36 +#define EXP1_06_PIN 37 +#define EXP1_07_PIN 38 +#define EXP1_08_PIN 39 + +#define EXP2_01_PIN 50 +#define EXP2_02_PIN 52 +#define EXP2_03_PIN 43 +#define EXP2_04_PIN 53 +#define EXP2_05_PIN 42 +#define EXP2_06_PIN 51 +#define EXP2_07_PIN 44 +#define EXP2_10_PIN 49 #if ENABLED(CR10_STOCKDISPLAY) + #define EXP3_01_PIN EXP1_01_PIN + #define EXP3_02_PIN EXP1_02_PIN #define EXP3_03_PIN EXP1_03_PIN #define EXP3_04_PIN EXP1_04_PIN #define EXP3_05_PIN EXP1_05_PIN #define EXP3_06_PIN EXP1_06_PIN #define EXP3_07_PIN EXP1_07_PIN #define EXP3_08_PIN EXP1_08_PIN - #define EXP3_09_PIN EXP1_09_PIN - #define EXP3_10_PIN EXP1_10_PIN #endif /************************************/ @@ -275,30 +275,30 @@ #endif // DWIN Encoder - #define BTN_ENC EXP1_09_PIN - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_07_PIN + #define BTN_ENC EXP1_02_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_04_PIN #ifndef BEEPER_PIN - #define BEEPER_PIN EXP1_10_PIN + #define BEEPER_PIN EXP1_01_PIN #undef SPEAKER #endif #elif ENABLED(REPRAPWORLD_GRAPHICAL_LCD) // TO TEST - //#define LCD_PINS_RS EXP2_01_PIN // CS chip select /SS chip slave select - //#define LCD_PINS_ENABLE EXP2_05_PIN // SID (MOSI) - //#define LCD_PINS_D4 EXP2_09_PIN // SCK (CLK) clock + //#define LCD_PINS_RS EXP2_10_PIN // CS chip select /SS chip slave select + //#define LCD_PINS_ENABLE EXP2_06_PIN // SID (MOSI) + //#define LCD_PINS_D4 EXP2_02_PIN // SCK (CLK) clock #elif BOTH(IS_NEWPANEL, PANEL_ONE) // TO TEST - //#define LCD_PINS_RS EXP1_09_PIN - //#define LCD_PINS_ENABLE EXP2_06_PIN + //#define LCD_PINS_RS EXP1_02_PIN + //#define LCD_PINS_ENABLE EXP2_05_PIN //#define LCD_PINS_D4 57 // Mega/Due:65 - AGCM4:57 //#define LCD_PINS_D5 58 // Mega/Due:66 - AGCM4:58 - //#define LCD_PINS_D6 EXP2_04_PIN + //#define LCD_PINS_D6 EXP2_07_PIN //#define LCD_PINS_D7 56 // Mega/Due:64 - AGCM4:56 #else @@ -319,10 +319,10 @@ // TO TEST //#define LCD_PINS_RS 56 // Mega/Due:64 - AGCM4:56 - //#define LCD_PINS_ENABLE EXP2_04_PIN + //#define LCD_PINS_ENABLE EXP2_07_PIN //#define LCD_PINS_D4 55 // Mega/Due:63 - AGCM4:55 - //#define LCD_PINS_D5 EXP1_09_PIN - //#define LCD_PINS_D6 EXP2_06_PIN + //#define LCD_PINS_D5 EXP1_02_PIN + //#define LCD_PINS_D6 EXP2_05_PIN //#define LCD_PINS_D7 57 // Mega/Due:65 - AGCM4:57 #else @@ -339,17 +339,17 @@ #else // Definitions for any standard Display - #define LCD_PINS_RS EXP1_07_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN + #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN #endif - #define LCD_PINS_D7 EXP1_03_PIN + #define LCD_PINS_D7 EXP1_08_PIN #if !IS_NEWPANEL - #define BEEPER_PIN EXP1_10_PIN + #define BEEPER_PIN EXP1_01_PIN #endif #endif @@ -357,9 +357,9 @@ #if !IS_NEWPANEL // Buttons attached to a shift register // Not wired yet - //#define SHIFT_CLK_PIN EXP1_04_PIN - //#define SHIFT_LD_PIN EXP2_06_PIN - //#define SHIFT_OUT_PIN EXP1_09_PIN + //#define SHIFT_CLK_PIN EXP1_07_PIN + //#define SHIFT_LD_PIN EXP2_05_PIN + //#define SHIFT_OUT_PIN EXP1_02_PIN //#define SHIFT_EN_PIN 17 #endif @@ -372,29 +372,29 @@ #if IS_RRD_SC - #define BEEPER_PIN EXP1_10_PIN + #define BEEPER_PIN EXP1_01_PIN #if ENABLED(CR10_STOCKDISPLAY) // TO TEST - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN #else // Definitions fpr any standard Display - #define BTN_EN1 EXP2_06_PIN - #define BTN_EN2 EXP2_08_PIN + #define BTN_EN1 EXP2_05_PIN + #define BTN_EN2 EXP2_03_PIN #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder #endif #endif - #define BTN_ENC EXP1_09_PIN + #define BTN_ENC EXP1_02_PIN #ifndef SD_DETECT_PIN - #define SD_DETECT_PIN EXP2_04_PIN + #define SD_DETECT_PIN EXP2_07_PIN #endif - #define KILL_PIN EXP2_01_PIN + #define KILL_PIN EXP2_10_PIN #if ENABLED(BQ_LCD_SMART_CONTROLLER) - //#define LCD_BACKLIGHT_PIN EXP1_03_PIN // TO TEST + //#define LCD_BACKLIGHT_PIN EXP1_08_PIN // TO TEST #endif #elif ENABLED(REPRAPWORLD_GRAPHICAL_LCD) @@ -403,41 +403,41 @@ //#define BTN_EN1 56 // Mega/Due:64 - AGCM4:56 //#define BTN_EN2 72 // Mega/Due:59 - AGCM4:72 //#define BTN_ENC 55 - //#define SD_DETECT_PIN EXP2_06_PIN + //#define SD_DETECT_PIN EXP2_05_PIN #elif ENABLED(LCD_I2C_PANELOLU2) // TO TEST //#define BTN_EN1 47 - //#define BTN_EN2 EXP2_08_PIN + //#define BTN_EN2 EXP2_03_PIN //#define BTN_ENC 32 //#define LCD_SDSS SDSS - //#define KILL_PIN EXP1_10_PIN + //#define KILL_PIN EXP1_01_PIN #elif ENABLED(LCD_I2C_VIKI) // TO TEST - //#define BTN_EN1 EXP1_09_PIN // https://files.panucatt.com/datasheets/viki_wiring_diagram.pdf explains 40/42. - //#define BTN_EN2 EXP2_06_PIN + //#define BTN_EN1 EXP1_02_PIN // https://files.panucatt.com/datasheets/viki_wiring_diagram.pdf explains 40/42. + //#define BTN_EN2 EXP2_05_PIN //#define BTN_ENC -1 //#define LCD_SDSS SDSS - //#define SD_DETECT_PIN EXP2_01_PIN + //#define SD_DETECT_PIN EXP2_10_PIN - #elif ANY(VIKI2, miniVIKI) + #elif EITHER(VIKI2, miniVIKI) // TO TEST //#define DOGLCD_CS 45 - //#define DOGLCD_A0 EXP2_04_PIN + //#define DOGLCD_A0 EXP2_07_PIN //#define LCD_SCREEN_ROT_180 //#define BEEPER_PIN 33 //#define STAT_LED_RED_PIN 32 - //#define STAT_LED_BLUE_PIN EXP1_08_PIN + //#define STAT_LED_BLUE_PIN EXP1_03_PIN //#define BTN_EN1 22 //#define BTN_EN2 7 - //#define BTN_ENC EXP1_03_PIN + //#define BTN_ENC EXP1_08_PIN //#define SD_DETECT_PIN -1 // Pin 49 for display SD interface, 72 for easy adapter board //#define KILL_PIN 31 @@ -451,23 +451,23 @@ //#define BEEPER_PIN 23 //#define LCD_BACKLIGHT_PIN 33 - //#define BTN_EN1 EXP1_08_PIN - //#define BTN_EN2 EXP1_05_PIN + //#define BTN_EN1 EXP1_03_PIN + //#define BTN_EN2 EXP1_06_PIN //#define BTN_ENC 31 //#define LCD_SDSS SDSS - //#define SD_DETECT_PIN EXP2_01_PIN - //#define KILL_PIN EXP1_10_PIN + //#define SD_DETECT_PIN EXP2_10_PIN + //#define KILL_PIN EXP1_01_PIN #elif EITHER(MKS_MINI_12864, FYSETC_MINI_12864) // TO TEST - //#define BEEPER_PIN EXP1_05_PIN - //#define BTN_ENC EXP1_08_PIN - //#define SD_DETECT_PIN EXP2_01_PIN + //#define BEEPER_PIN EXP1_06_PIN + //#define BTN_ENC EXP1_03_PIN + //#define SD_DETECT_PIN EXP2_10_PIN //#ifndef KILL_PIN - // #define KILL_PIN EXP1_10_PIN + // #define KILL_PIN EXP1_01_PIN //#endif #if ENABLED(MKS_MINI_12864) @@ -527,11 +527,11 @@ #elif ENABLED(MINIPANEL) // TO TEST - //#define BEEPER_PIN EXP2_06_PIN + //#define BEEPER_PIN EXP2_05_PIN // not connected to a pin //#define LCD_BACKLIGHT_PIN 57 // backlight LED on A11/D? (Mega/Due:65 - AGCM4:57) - //#define DOGLCD_A0 EXP2_04_PIN + //#define DOGLCD_A0 EXP2_07_PIN //#define DOGLCD_CS 58 // Mega/Due:66 - AGCM4:58 // GLCD features @@ -540,11 +540,11 @@ //#define LCD_SCREEN_ROT_180 //#define LCD_SCREEN_ROT_270 - //#define BTN_EN1 EXP1_09_PIN + //#define BTN_EN1 EXP1_02_PIN //#define BTN_EN2 55 // Mega/Due:63 - AGCM4:55 //#define BTN_ENC 72 // Mega/Due:59 - AGCM4:72 - //#define SD_DETECT_PIN EXP2_01_PIN + //#define SD_DETECT_PIN EXP2_10_PIN //#define KILL_PIN 56 // Mega/Due:64 - AGCM4:56 #elif ENABLED(ZONESTAR_LCD) @@ -564,9 +564,9 @@ // Buttons are directly attached to AUX-2 #if IS_RRW_KEYPAD // TO TEST - //#define SHIFT_OUT_PIN EXP1_09_PIN - //#define SHIFT_CLK_PIN EXP2_04_PIN - //#define SHIFT_LD_PIN EXP2_06_PIN + //#define SHIFT_OUT_PIN EXP1_02_PIN + //#define SHIFT_CLK_PIN EXP2_07_PIN + //#define SHIFT_LD_PIN EXP2_05_PIN //#define BTN_EN1 56 // Mega/Due:64 - AGCM4:56 //#define BTN_EN2 72 // Mega/Due:59 - AGCM4:72 //#define BTN_ENC 55 // Mega/Due:63 - AGCM4:55 @@ -574,18 +574,18 @@ // TO TEST //#define BTN_EN1 72 // AUX2 PIN 3 (Mega/Due:59 - AGCM4:72) //#define BTN_EN2 55 // AUX2 PIN 4 (Mega/Due:63 - AGCM4:55) - //#define BTN_ENC EXP2_01_PIN // AUX3 PIN 7 + //#define BTN_ENC EXP2_10_PIN // AUX3 PIN 7 #else // TO TEST - //#define BTN_EN1 EXP1_05_PIN - //#define BTN_EN2 EXP1_08_PIN + //#define BTN_EN1 EXP1_06_PIN + //#define BTN_EN2 EXP1_03_PIN //#define BTN_ENC 31 #endif #if ENABLED(G3D_PANEL) // TO TEST - //#define SD_DETECT_PIN EXP2_01_PIN - //#define KILL_PIN EXP1_10_PIN + //#define SD_DETECT_PIN EXP2_10_PIN + //#define KILL_PIN EXP1_01_PIN #endif #endif @@ -616,7 +616,7 @@ #undef SD_DETECT_PIN #define SD_DETECT_PIN 95 #else - #define SDSS EXP2_07_PIN + #define SDSS EXP2_04_PIN #endif #if HAS_TMC_UART diff --git a/Marlin/src/pins/samd/pins_RAMPS_144.h b/Marlin/src/pins/samd/pins_RAMPS_144.h index 406162c089..2c42506a5f 100644 --- a/Marlin/src/pins/samd/pins_RAMPS_144.h +++ b/Marlin/src/pins/samd/pins_RAMPS_144.h @@ -408,7 +408,7 @@ //#define LCD_SDSS SDSS //#define SD_DETECT_PIN 49 - #elif ANY(VIKI2, miniVIKI) + #elif EITHER(VIKI2, miniVIKI) // TO TEST //#define DOGLCD_CS 45 diff --git a/Marlin/src/pins/sanguino/pins_MELZI_CREALITY.h b/Marlin/src/pins/sanguino/pins_MELZI_CREALITY.h index a450515a79..83aa5317f9 100644 --- a/Marlin/src/pins/sanguino/pins_MELZI_CREALITY.h +++ b/Marlin/src/pins/sanguino/pins_MELZI_CREALITY.h @@ -132,10 +132,10 @@ /** * EXP1 Connector EXP1 as CR10 STOCKDISPLAY * ------ ------ - * PA4 |10 9 | PC0 BEEPER_PIN |10 9 | BTN_ENC - * PD3 | 8 7 | RESET BTN_EN1 | 8 7 | RESET - * PD2 6 5 | PA1 BTN_EN2 6 5 | LCD_PINS_D4 (ST9720 CLK) - * PA3 | 4 3 | PC1 (ST9720 CS) LCD_PINS_RS | 4 3 | LCD_PINS_ENABLE (ST9720 DAT) - * GND | 2 1 | 5V GND | 2 1 | 5V + * PA4 | 1 2 | PC0 BEEPER_PIN | 1 2 | BTN_ENC + * PD3 | 3 4 | RESET BTN_EN1 | 3 4 | RESET + * PD2 5 6 | PA1 BTN_EN2 5 6 | LCD_PINS_D4 (ST9720 CLK) + * PA3 | 7 8 | PC1 (ST9720 CS) LCD_PINS_RS | 7 8 | LCD_PINS_ENABLE (ST9720 DAT) + * GND | 9 10 | 5V GND | 9 10 | 5V * ------ ------ */ diff --git a/Marlin/src/pins/sanguino/pins_ZMIB_V2.h b/Marlin/src/pins/sanguino/pins_ZMIB_V2.h index 0a8143c376..4e8731c1cb 100644 --- a/Marlin/src/pins/sanguino/pins_ZMIB_V2.h +++ b/Marlin/src/pins/sanguino/pins_ZMIB_V2.h @@ -164,25 +164,25 @@ /** EXP1 * ------ - * (MOSI) D5 |10 9 | D7 (SCK) - * (CS) D11 | 8 7 | D10 (DC/D4) - * (EN2) D12 6 5 | D4 or D3 (EN/RS) - * (ENC) D29 | 4 3 | D2 (EN1) - * (GND) | 2 1 | (5V) + * (MOSI) D5 | 1 2 | D7 (SCK) + * (CS) D11 | 3 4 | D10 (DC/D4) + * (EN2) D12 5 6 | D4 or D3 (EN/RS) + * (ENC) D29 | 7 8 | D2 (EN1) + * (GND) | 9 10 | (5V) * ------ */ -#define EXP1_03_PIN 2 -#define EXP1_04_PIN 29 +#define EXP1_01_PIN 5 +#define EXP1_02_PIN 7 +#define EXP1_03_PIN 11 +#define EXP1_04_PIN 10 +#define EXP1_05_PIN 12 #ifndef IS_ZMIB_V2 - #define EXP1_05_PIN 4 // ZMIB V1 + #define EXP1_06_PIN 4 // ZMIB V1 #else - #define EXP1_05_PIN 3 // ZMIB V2 + #define EXP1_06_PIN 3 // ZMIB V2 #endif -#define EXP1_06_PIN 12 -#define EXP1_07_PIN 10 -#define EXP1_08_PIN 11 -#define EXP1_09_PIN 7 -#define EXP1_10_PIN 5 +#define EXP1_07_PIN 29 +#define EXP1_08_PIN 2 #if ENABLED(ZONESTAR_12864LCD) // @@ -190,10 +190,10 @@ // #define LCDSCREEN_NAME "ZONESTAR_12864LCD" #define FORCE_SOFT_SPI - //#define LCD_SDSS EXP1_08_PIN - #define LCD_PINS_RS EXP1_08_PIN // ST7920_CS_PIN (LCD module pin 4) - #define LCD_PINS_ENABLE EXP1_05_PIN // ST7920_DAT_PIN (LCD module pin 5) - #define LCD_PINS_D4 EXP1_07_PIN // ST7920_CLK_PIN (LCD module pin 6) + //#define LCD_SDSS EXP1_03_PIN + #define LCD_PINS_RS EXP1_03_PIN // ST7920_CS_PIN (LCD module pin 4) + #define LCD_PINS_ENABLE EXP1_06_PIN // ST7920_DAT_PIN (LCD module pin 5) + #define LCD_PINS_D4 EXP1_04_PIN // ST7920_CLK_PIN (LCD module pin 6) #define BOARD_ST7920_DELAY_1 DELAY_2_NOP #define BOARD_ST7920_DELAY_2 DELAY_2_NOP @@ -205,9 +205,9 @@ // #define LCDSCREEN_NAME "ZONESTAR 12864OLED" #define FORCE_SOFT_SPI - #define LCD_PINS_RS EXP1_05_PIN - #define LCD_PINS_DC EXP1_07_PIN - #define DOGLCD_CS EXP1_08_PIN + #define LCD_PINS_RS EXP1_06_PIN + #define LCD_PINS_DC EXP1_04_PIN + #define DOGLCD_CS EXP1_03_PIN #if ENABLED(OLED_HW_IIC) #error "Oops! can't choose HW IIC for ZMIB board!!" @@ -224,9 +224,9 @@ // All the above are also RRDSC with rotary encoder // #if IS_RRD_SC - #define BTN_EN1 EXP1_03_PIN - #define BTN_EN2 EXP1_06_PIN - #define BTN_ENC EXP1_04_PIN + #define BTN_EN1 EXP1_08_PIN + #define BTN_EN2 EXP1_05_PIN + #define BTN_ENC EXP1_07_PIN #define BEEPER_PIN -1 #define KILL_PIN -1 #endif diff --git a/Marlin/src/pins/stm32f0/pins_MALYAN_M300.h b/Marlin/src/pins/stm32f0/pins_MALYAN_M300.h index d38d4bbdb3..c55c63aa29 100644 --- a/Marlin/src/pins/stm32f0/pins_MALYAN_M300.h +++ b/Marlin/src/pins/stm32f0/pins_MALYAN_M300.h @@ -51,10 +51,13 @@ // // Limit Switches // -#define X_MAX_PIN PC13 -#define Y_MAX_PIN PC14 -#define Z_MAX_PIN PC15 -#define Z_MIN_PIN PB7 +#define X_STOP_PIN PC13 +#define Y_STOP_PIN PC14 +#define Z_STOP_PIN PC15 + +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PB7 +#endif // // Steppers diff --git a/Marlin/src/pins/stm32f1/pins_BEAST.h b/Marlin/src/pins/stm32f1/pins_BEAST.h index d494b29c14..4dafe2f273 100644 --- a/Marlin/src/pins/stm32f1/pins_BEAST.h +++ b/Marlin/src/pins/stm32f1/pins_BEAST.h @@ -131,7 +131,7 @@ #error "LCD_I2C_PANELOLU2 is not supported." #elif ENABLED(LCD_I2C_VIKI) #error "LCD_I2C_VIKI is not supported." - #elif ANY(VIKI2, miniVIKI) + #elif EITHER(VIKI2, miniVIKI) #error "VIKI2 / miniVIKI is not supported." #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) #error "ELB_FULL_GRAPHIC_CONTROLLER is not supported." diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h index 06788139f0..f9c9de4f03 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h @@ -157,11 +157,11 @@ /** * ------ - * (BEEPER) PA15 |10 9 | PB6 (BTN_ENC) - * (BTN_EN1) PA9 | 8 7 | RESET - * (BTN_EN2) PA10 6 5 | PB9 (LCD_D4) - * (LCD_RS) PB8 | 4 3 | PB7 (LCD_EN) - * GND | 2 1 | 5V + * (BEEPER) PA15 | 1 2 | PB6 (BTN_ENC) + * (BTN_EN1) PA9 | 3 4 | RESET + * (BTN_EN2) PA10 5 6 | PB9 (LCD_D4) + * (LCD_RS) PB8 | 7 8 | PB7 (LCD_EN) + * GND | 9 10 | 5V * ------ * EXP1 */ @@ -198,11 +198,11 @@ /** Creality Ender-2 display pinout * ------ - * (SCK) PA15 |10 9 | PB6 (BTN_ENC) - * (BTN_EN1) PA9 | 8 7 | RESET - * (BTN_EN2) PA10 6 5 | PB9 (LCD_A0) - * (LCD_RS) PB8 | 4 3 | PB7 (MOSI) - * GND | 2 1 | 5V + * (SCK) PA15 | 1 2 | PB6 (BTN_ENC) + * (BTN_EN1) PA9 | 3 4 | RESET + * (BTN_EN2) PA10 5 6 | PB9 (LCD_A0) + * (LCD_RS) PB8 | 7 8 | PB7 (MOSI) + * GND | 9 10 | 5V * ------ * EXP1 */ @@ -234,28 +234,28 @@ * * Board Display * ------ ------ - * (SD_DET) PA15 |10 9 | PB6 (BEEPER) 5V |10 9 | GND - * (MOD_RESET) PA9 | 8 7 | RESET (RESET) | 8 7 | (SD_DET) - * (SD_CS) PA10 6 5 | PB9 (MOSI) 6 5 | (LCD_CS) - * (LCD_CS) PB8 | 4 3 | PB7 (SD_CS) | 4 3 | (MOD_RESET) - * GND | 2 1 | 5V (SCK) | 2 1 | (MISO) + * (SD_DET) PA15 | 1 2 | PB6 (BEEPER) 5V |10 9 | GND + * (MOD_RESET) PA9 | 3 4 | RESET (RESET) | 8 7 | (SD_DET) + * (SD_CS) PA10 5 6 | PB9 (MOSI) 6 5 | (LCD_CS) + * (LCD_CS) PB8 | 7 8 | PB7 (SD_CS) | 4 3 | (MOD_RESET) + * GND | 9 10 | 5V (SCK) | 2 1 | (MISO) * ------ ------ * EXP1 EXP1 * * Needs custom cable: * * Board Adapter Display - * _________ - * EXP1-1 ----------- EXP1-10 - * EXP1-2 ----------- EXP1-9 - * SPI1-4 ----------- EXP1-6 - * EXP1-4 ----------- EXP1-5 - * SP11-3 ----------- EXP1-2 - * EXP1-6 ----------- EXP1-4 - * EXP1-7 ----------- EXP1-8 - * EXP1-8 ----------- EXP1-3 - * SPI1-1 ----------- EXP1-1 - * EXP1-10 ----------- EXP1-7 + * ---------------------------------- + * EXP1-10 ---------- EXP1-10 5V + * EXP1-9 ----------- EXP1-9 GND + * SPI1-4 ----------- EXP1-6 MOSI + * EXP1-7 ----------- EXP1-5 LCD_CS + * SP11-3 ----------- EXP1-2 SCK + * EXP1-5 ----------- EXP1-4 SD_CS + * EXP1-4 ----------- EXP1-8 RESET + * EXP1-3 ----------- EXP1-3 MOD_RST + * SPI1-1 ----------- EXP1-1 MISO + * EXP1-1 ----------- EXP1-7 SD_DET */ #define CLCD_SPI_BUS 1 // SPI1 connector diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h index fa7eb3dd11..537e905e21 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h @@ -120,30 +120,30 @@ /** * SKR Mini E3 V1.0, V1.2 SKR Mini E3 V2.0 * ------ ------ - * (BEEPER) PB5 |10 9 | PB6 (BTN_ENC) (BEEPER) PB5 |10 9 | PA15 (BTN_ENC) - * (BTN_EN1) PA9 | 8 7 | RESET (BTN_EN1) PA9 | 8 7 | RESET - * (BTN_EN2) PA10 6 5 | PB9 (LCD_D4) (BTN_EN2) PA10 6 5 | PB9 (LCD_D4) - * (LCD_RS) PB8 | 4 3 | PB7 (LCD_EN) (LCD_RS) PB8 | 4 3 | PB15 (LCD_EN) - * GND | 2 1 | 5V GND | 2 1 | 5V + * (BEEPER) PB5 | 1 2 | PB6 (BTN_ENC) (BEEPER) PB5 | 1 2 | PA15 (BTN_ENC) + * (BTN_EN1) PA9 | 3 4 | RESET (BTN_EN1) PA9 | 3 4 | RESET + * (BTN_EN2) PA10 5 6 | PB9 (LCD_D4) (BTN_EN2) PA10 5 6 | PB9 (LCD_D4) + * (LCD_RS) PB8 | 7 8 | PB7 (LCD_EN) (LCD_RS) PB8 | 7 8 | PB15 (LCD_EN) + * GND | 9 10 | 5V GND | 9 10 | 5V * ------ ------ * EXP1 EXP1 */ #ifdef SKR_MINI_E3_V2 - #define EXP1_9 PA15 - #define EXP1_3 PB15 + #define EXP1_02_PIN PA15 + #define EXP1_08_PIN PB15 #else - #define EXP1_9 PB6 - #define EXP1_3 PB7 + #define EXP1_02_PIN PB6 + #define EXP1_08_PIN PB7 #endif #if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI /** * ------ ------ ------ - * (ENT) |10 9 | (BEEP) |10 9 | |10 9 | - * (RX) | 8 7 | (RX) | 8 7 | (TX) RX | 8 7 | TX - * (TX) 6 5 | (ENT) 6 5 | (BEEP) ENT | 6 5 | BEEP - * (B) | 4 3 | (A) (B) | 4 3 | (A) B | 4 3 | A - * GND | 2 1 | (VCC) GND | 2 1 | VCC GND | 2 1 | VCC + * (ENT) | 1 2 | (BEEP) |10 9 | |10 9 | + * (RX) | 3 4 | (RX) | 8 7 | (TX) RX | 8 7 | TX + * (TX) 5 6 | (ENT) 6 5 | (BEEP) ENT | 6 5 | BEEP + * (B) | 7 8 | (A) (B) | 4 3 | (A) B | 4 3 | A + * GND | 9 10 | (VCC) GND | 2 1 | VCC GND | 2 1 | VCC * ------ ------ ------ * EXP1 DWIN DWIN (plug) * @@ -154,8 +154,8 @@ #error "CAUTION! Ender-3 V2 display requires a custom cable. See 'pins_BTT_SKR_MINI_E3_common.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" #endif - #define BEEPER_PIN EXP1_9 - #define BTN_EN1 EXP1_3 + #define BEEPER_PIN EXP1_02_PIN + #define BTN_EN1 EXP1_08_PIN #define BTN_EN2 PB8 #define BTN_ENC PB5 @@ -164,13 +164,13 @@ #if ENABLED(CR10_STOCKDISPLAY) #define BEEPER_PIN PB5 - #define BTN_ENC EXP1_9 + #define BTN_ENC EXP1_02_PIN #define BTN_EN1 PA9 #define BTN_EN2 PA10 #define LCD_PINS_RS PB8 - #define LCD_PINS_ENABLE EXP1_3 + #define LCD_PINS_ENABLE EXP1_08_PIN #define LCD_PINS_D4 PB9 #elif ENABLED(ZONESTAR_LCD) // ANET A8 LCD Controller - Must convert to 3.3V - CONNECTING TO 5V WILL DAMAGE THE BOARD! @@ -180,7 +180,7 @@ #endif #define LCD_PINS_RS PB9 - #define LCD_PINS_ENABLE EXP1_9 + #define LCD_PINS_ENABLE EXP1_02_PIN #define LCD_PINS_D4 PB8 #define LCD_PINS_D5 PA10 #define LCD_PINS_D6 PA9 @@ -189,14 +189,14 @@ #elif EITHER(MKS_MINI_12864, ENDER2_STOCKDISPLAY) - #define BTN_ENC EXP1_9 + #define BTN_ENC EXP1_02_PIN #define BTN_EN1 PA9 #define BTN_EN2 PA10 #define DOGLCD_CS PB8 #define DOGLCD_A0 PB9 #define DOGLCD_SCK PB5 - #define DOGLCD_MOSI EXP1_3 + #define DOGLCD_MOSI EXP1_08_PIN #define FORCE_SOFT_SPI #define LCD_BACKLIGHT_PIN -1 @@ -214,28 +214,28 @@ * * Board Display * ------ ------ - * (SD_DET) PB5 |10 9 | PB6 (BEEPER) 5V |10 9 | GND - * (MOD_RESET) PA9 | 8 7 | RESET -- | 8 7 | (SD_DET) - * (SD_CS) PA10 6 5 | PB9 (MOSI) | 6 5 | -- - * (LCD_CS) PB8 | 4 3 | PB7 (SD_CS) | 4 3 | (LCD_CS) - * GND | 2 1 | 5V (SCK) | 2 1 | (MISO) + * (SD_DET) PB5 | 1 2 | PB6 (BEEPER) 5V |10 9 | GND + * (MOD_RESET) PA9 | 3 4 | RESET -- | 8 7 | (SD_DET) + * (SD_CS) PA10 5 6 | PB9 (MOSI) | 6 5 | -- + * (LCD_CS) PB8 | 7 8 | PB7 (SD_CS) | 4 3 | (LCD_CS) + * GND | 9 10 | 5V (SCK) | 2 1 | (MISO) * ------ ------ * EXP1 EXP1 * * Needs custom cable: * - * Board Display - * - * EXP1-1 ----------- EXP1-10 - * EXP1-2 ----------- EXP1-9 - * SPI1-4 ----------- EXP1-6 - * EXP1-4 ----------- FREE - * SPI1-3 ----------- EXP1-2 - * EXP1-6 ----------- EXP1-4 - * EXP1-7 ----------- FREE - * EXP1-8 ----------- EXP1-3 - * SPI1-1 ----------- EXP1-1 - * EXP1-10 ----------- EXP1-7 + * Board Adapter Display + * ---------------------------------- + * EXP1-10 ---------- EXP1-10 5V + * EXP1-9 ----------- EXP1-9 GND + * SPI1-4 ----------- EXP1-6 MOSI + * EXP1-7 ----------- n/c + * SPI1-3 ----------- EXP1-2 SCK + * EXP1-5 ----------- EXP1-4 SD_CS + * EXP1-4 ----------- n/c + * EXP1-3 ----------- EXP1-3 LCD_CS + * SPI1-1 ----------- EXP1-1 MISO + * EXP1-1 ----------- EXP1-7 SD_DET */ #define TFTGLCD_CS PA9 @@ -253,11 +253,11 @@ * * Board Display * ------ ------ - * PB5 |10 9 | PA15 (BEEP) |10 9 | BTN_ENC - * PA9 | 8 7 | RESET LCD_CS | 8 7 | LCD A0 - * PA10 | 6 5 | PB9 LCD_RST | 6 5 | RED - * PB8 | 4 3 | PB15 (GREEN) | 4 3 | (BLUE) - * GND | 2 1 | 5V GND | 2 1 | 5V + * PB5 | 1 2 | PA15 (BEEP) |10 9 | BTN_ENC + * PA9 | 3 4 | RESET LCD_CS | 8 7 | LCD A0 + * PA10 | 5 6 | PB9 LCD_RST | 6 5 | RED + * PB8 | 7 8 | PB15 (GREEN) | 4 3 | (BLUE) + * GND | 9 10 | 5V GND | 2 1 | 5V * ------ ------ * EXP1 EXP1 * @@ -274,18 +274,19 @@ * * Board Display * - * EXP1-1 ----------- EXP1-1 - * EXP1-2 ----------- EXP1-2 - * EXP1-3 ----------- EXP2-6 - * EXP1-4 ----------- EXP1-5 - * EXP1-5 ----------- EXP2-8 - * EXP1-6 ----------- EXP1-6 - * EXP1-8 ----------- EXP1-8 - * EXP1-9 ----------- EXP1-9 - * EXP1-10 ----------- EXP1-7 + * EXP1-10 ---------- EXP1-1 5V + * EXP1-9 ----------- EXP1-2 GND + * EXP1-8 ----------- EXP2-6 EN2 + * EXP1-7 ----------- EXP1-5 RED + * EXP1-6 ----------- EXP2-8 EN1 + * EXP1-5 ----------- EXP1-6 LCD_RST + * EXP1-4 ----------- n/c + * EXP1-3 ----------- EXP1-8 LCD_CS + * EXP1-2 ----------- EXP1-9 ENC + * EXP1-1 ----------- EXP1-7 LCD_A0 * - * TFT-2 ----------- EXP2-9 - * TFT-3 ----------- EXP2-5 + * TFT-2 ----------- EXP2-9 SCK + * TFT-3 ----------- EXP2-5 MOSI * * for backlight configuration see steps 2 (V2.1) and 3 in https://wiki.fysetc.com/Mini12864_Panel/ */ @@ -325,33 +326,33 @@ * * Board Display * ------ ------ - * (SD_DET) PB5 |10 9 | PB6 (BEEPER) 5V |10 9 | GND - * (MOD_RESET) PA9 | 8 7 | RESET (RESET) | 8 7 | (SD_DET) - * (SD_CS) PA10 6 5 | PB9 (MOSI) | 6 5 | (LCD_CS) - * (LCD_CS) PB8 | 4 3 | PB7 (SD_CS) | 4 3 | (MOD_RESET) - * GND | 2 1 | 5V (SCK) | 2 1 | (MISO) + * (SD_DET) PB5 | 1 2 | PB6 (BEEPER) 5V |10 9 | GND + * (MOD_RESET) PA9 | 3 4 | RESET (RESET) | 8 7 | (SD_DET) + * (SD_CS) PA10 5 6 | PB9 (MOSI) | 6 5 | (LCD_CS) + * (LCD_CS) PB8 | 7 8 | PB7 (SD_CS) | 4 3 | (MOD_RESET) + * GND | 9 10 | 5V (SCK) | 2 1 | (MISO) * ------ ------ * EXP1 EXP1 * * Needs custom cable: * * Board Adapter Display - * _________ - * EXP1-1 ----------- EXP1-10 - * EXP1-2 ----------- EXP1-9 - * SPI1-4 ----------- EXP1-6 - * EXP1-4 ----------- EXP1-5 - * SPI1-3 ----------- EXP1-2 - * EXP1-6 ----------- EXP1-4 - * EXP1-7 ----------- EXP1-8 - * EXP1-8 ----------- EXP1-3 - * SPI1-1 ----------- EXP1-1 - * EXP1-10 ----------- EXP1-7 + * ---------------------------------- + * EXP1-10 ---------- EXP1-10 5V + * EXP1-9 ----------- EXP1-9 GND + * SPI1-4 ----------- EXP1-6 MOSI + * EXP1-7 ----------- EXP1-5 LCD_CS + * SPI1-3 ----------- EXP1-2 SCK + * EXP1-5 ----------- EXP1-4 SD_CS + * EXP1-4 ----------- EXP1-8 RESET + * EXP1-3 ----------- EXP1-3 MOD_RST + * SPI1-1 ----------- EXP1-1 MISO + * EXP1-1 ----------- EXP1-7 SD_DET */ - #define CLCD_SPI_BUS 1 // SPI1 connector + #define CLCD_SPI_BUS 1 // SPI1 connector - #define BEEPER_PIN EXP1_9 + #define BEEPER_PIN EXP1_02_PIN #define CLCD_MOD_RESET PA9 #define CLCD_SPI_CS PB8 @@ -375,7 +376,7 @@ #error "SD CUSTOM_CABLE is not compatible with SKR Mini E3." #endif -#define ONBOARD_SPI_DEVICE 1 // SPI1 -> used only by HAL/STM32F1... +#define ONBOARD_SPI_DEVICE 1 // SPI1 -> used only by HAL/STM32F1... #define ONBOARD_SD_CS_PIN PA4 // Chip select for "System" SD card #define ENABLE_SPI1 diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h index 1ea947ffdf..4e343fa8cd 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h @@ -111,47 +111,47 @@ #define TEMP_0_PIN PA0 // Analog Input /** ------ ------ - * (BEEPER) PC10 |10 9 | PC11 (BTN_ENC) (MISO) PB4 |10 9 | PB3 (SCK) - * (LCD_EN) PB6 | 8 7 | PC12 (LCD_RS) (BTN_EN1) PD2 | 8 7 | PA15 (SD_SS) - * (LCD_D4) PC13 6 5 | PB7 (LCD_D5) (BTN_EN2) PB8 6 5 | PB5 (MOSI) - * (LCD_D6) PC15 | 4 3 | PC14 (LCD_D7) (SD_DETECT) PB9 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | -- + * (BEEPER) PC10 | 1 2 | PC11 (BTN_ENC) (MISO) PB4 | 1 2 | PB3 (SCK) + * (LCD_EN) PB6 | 3 4 | PC12 (LCD_RS) (BTN_EN1) PD2 | 3 4 | PA15 (SD_SS) + * (LCD_D4) PC13 5 6 | PB7 (LCD_D5) (BTN_EN2) PB8 5 6 | PB5 (MOSI) + * (LCD_D6) PC15 | 7 8 | PC14 (LCD_D7) (SD_DETECT) PB9 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN PC14 -#define EXP1_04_PIN PC15 -#define EXP1_05_PIN PB7 -#define EXP1_06_PIN PC13 -#define EXP1_07_PIN PC12 -#define EXP1_08_PIN PB6 -#define EXP1_09_PIN PC11 -#define EXP1_10_PIN PC10 - -#define EXP2_03_PIN -1 // RESET -#define EXP2_04_PIN PB9 -#define EXP2_05_PIN PB5 -#define EXP2_06_PIN PB8 -#define EXP2_07_PIN PA15 -#define EXP2_08_PIN PD2 -#define EXP2_09_PIN PB3 -#define EXP2_10_PIN PB4 +#define EXP1_01_PIN PC10 +#define EXP1_02_PIN PC11 +#define EXP1_03_PIN PB6 +#define EXP1_04_PIN PC12 +#define EXP1_05_PIN PC13 +#define EXP1_06_PIN PB7 +#define EXP1_07_PIN PC15 +#define EXP1_08_PIN PC14 + +#define EXP2_01_PIN PB4 +#define EXP2_02_PIN PB3 +#define EXP2_03_PIN PD2 +#define EXP2_04_PIN PA15 +#define EXP2_05_PIN PB8 +#define EXP2_06_PIN PB5 +#define EXP2_07_PIN PB9 +#define EXP2_08_PIN -1 // RESET // // LCD / Controller // #if HAS_WIRED_LCD - #define BEEPER_PIN EXP1_10_PIN - #define BTN_ENC EXP1_09_PIN + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN #if ENABLED(CR10_STOCKDISPLAY) - #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_RS EXP1_07_PIN - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN - #define LCD_PINS_ENABLE EXP1_03_PIN - #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN #elif IS_TFTGLCD_PANEL @@ -159,56 +159,56 @@ #undef BTN_ENC #if ENABLED(TFTGLCD_PANEL_SPI) - #define TFTGLCD_CS EXP2_08_PIN + #define TFTGLCD_CS EXP2_03_PIN #endif - #define SD_DETECT_PIN EXP2_04_PIN + #define SD_DETECT_PIN EXP2_07_PIN #else - #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_RS EXP1_04_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN #if ENABLED(FYSETC_MINI_12864) #define LCD_BACKLIGHT_PIN -1 - #define LCD_RESET_PIN EXP1_06_PIN - #define DOGLCD_A0 EXP1_07_PIN - #define DOGLCD_CS EXP1_08_PIN - #define DOGLCD_SCK EXP2_09_PIN - #define DOGLCD_MOSI EXP2_05_PIN + #define LCD_RESET_PIN EXP1_05_PIN + #define DOGLCD_A0 EXP1_04_PIN + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_SCK EXP2_02_PIN + #define DOGLCD_MOSI EXP2_06_PIN #define FORCE_SOFT_SPI // SPI MODE3 - #define LED_PIN EXP1_05_PIN // red pwm - //#define LED_PIN EXP1_04_PIN // green - //#define LED_PIN EXP1_03_PIN // blue + #define LED_PIN EXP1_06_PIN // red pwm + //#define LED_PIN EXP1_07_PIN // green + //#define LED_PIN EXP1_08_PIN // blue //#if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) // #ifndef RGB_LED_R_PIN - // #define RGB_LED_R_PIN EXP1_05_PIN + // #define RGB_LED_R_PIN EXP1_06_PIN // #endif // #ifndef RGB_LED_G_PIN - // #define RGB_LED_G_PIN EXP1_04_PIN + // #define RGB_LED_G_PIN EXP1_07_PIN // #endif // #ifndef RGB_LED_B_PIN - // #define RGB_LED_B_PIN EXP1_03_PIN + // #define RGB_LED_B_PIN EXP1_08_PIN // #endif //#elif ENABLED(FYSETC_MINI_12864_2_1) - // #define NEOPIXEL_PIN EXP1_05_PIN + // #define NEOPIXEL_PIN EXP1_06_PIN //#endif #else // !FYSETC_MINI_12864 - #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_D4 EXP1_05_PIN #if IS_ULTIPANEL - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder @@ -241,11 +241,11 @@ #if SD_CONNECTION_IS(LCD) #define SPI_DEVICE 3 - #define SD_DETECT_PIN EXP2_04_PIN - #define SD_SCK_PIN EXP2_09_PIN - #define SD_MISO_PIN EXP2_10_PIN - #define SD_MOSI_PIN EXP2_05_PIN - #define SD_SS_PIN EXP2_07_PIN + #define SD_DETECT_PIN EXP2_07_PIN + #define SD_SCK_PIN EXP2_02_PIN + #define SD_MISO_PIN EXP2_01_PIN + #define SD_MOSI_PIN EXP2_06_PIN + #define SD_SS_PIN EXP2_04_PIN #elif SD_CONNECTION_IS(ONBOARD) #define SD_DETECT_PIN PA3 #define SD_SCK_PIN PA5 diff --git a/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h b/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h index 9dec1e1279..c73544bf43 100644 --- a/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h +++ b/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h @@ -123,35 +123,35 @@ /** * ------ - * PB5 |10 9 | PB6 - * PA2 | 8 7 | RESET - * PA3 6 5 | PB8 - * PB7 | 4 3 | PA4 - * GND | 2 1 | VCC5 + * PB5 | 1 2 | PB6 + * PA2 | 3 4 | RESET + * PA3 5 6 | PB8 + * PB7 | 7 8 | PA4 + * GND | 9 10 | VCC5 * ------ * EXP1 */ -#define EXP1_03_PIN PA4 -#define EXP1_04_PIN PB7 -#define EXP1_05_PIN PB8 -#define EXP1_06_PIN PA3 -#define EXP1_07_PIN -1 // RESET -#define EXP1_08_PIN PA2 -#define EXP1_09_PIN PB6 -#define EXP1_10_PIN PB5 +#define EXP1_01_PIN PB5 +#define EXP1_02_PIN PB6 +#define EXP1_03_PIN PA2 +#define EXP1_04_PIN -1 // RESET +#define EXP1_05_PIN PA3 +#define EXP1_06_PIN PB8 +#define EXP1_07_PIN PB7 +#define EXP1_08_PIN PA4 // // LCD / Controller // #if ENABLED(CR10_STOCKDISPLAY) - #define BEEPER_PIN EXP1_10_PIN - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_PIN - #define BTN_ENC EXP1_09_PIN - - #define LCD_PINS_RS EXP1_04_PIN // CS -- SOFT SPI for ENDER3 LCD - #define LCD_PINS_D4 EXP1_05_PIN // SCLK - #define LCD_PINS_ENABLE EXP1_03_PIN // DATA MOSI + #define BEEPER_PIN EXP1_01_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + #define BTN_ENC EXP1_02_PIN + + #define LCD_PINS_RS EXP1_07_PIN // CS -- SOFT SPI for ENDER3 LCD + #define LCD_PINS_D4 EXP1_06_PIN // SCLK + #define LCD_PINS_ENABLE EXP1_08_PIN // DATA MOSI #endif // Alter timing for graphical display diff --git a/Marlin/src/pins/stm32f1/pins_CHITU3D.h b/Marlin/src/pins/stm32f1/pins_CHITU3D.h index 1f56e59a23..3b66096a27 100644 --- a/Marlin/src/pins/stm32f1/pins_CHITU3D.h +++ b/Marlin/src/pins/stm32f1/pins_CHITU3D.h @@ -171,7 +171,7 @@ #define LCD_SDSS PD5 // 53 #define SD_DETECT_PIN PD1 // 49 - #elif ANY(VIKI2, miniVIKI) + #elif EITHER(VIKI2, miniVIKI) #define BEEPER_PIN PC1 // 33 diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h index cb11c3e53b..5a3e7337ad 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h @@ -77,8 +77,12 @@ // // Limit Switches // -#define X_STOP_PIN PA5 -#define Y_STOP_PIN PA6 +#ifndef X_STOP_PIN + #define X_STOP_PIN PA5 +#endif +#ifndef Y_STOP_PIN + #define Y_STOP_PIN PA6 +#endif #ifndef Z_STOP_PIN #define Z_STOP_PIN PA7 #endif @@ -153,7 +157,7 @@ // SD Card // #define SD_DETECT_PIN PC7 -#define SDCARD_CONNECTION ONBOARD +#define SDCARD_CONNECTION ONBOARD #define SDIO_SUPPORT #define NO_SD_HOST_DRIVE // This board's SD is only seen by the printer @@ -161,53 +165,87 @@ #if ENABLED(RET6_12864_LCD) - // RET6 12864 LCD - #define LCD_PINS_RS PB12 - #define LCD_PINS_ENABLE PB15 - #define LCD_PINS_D4 PB13 - - #define BTN_ENC PB2 - #define BTN_EN1 PB10 - #define BTN_EN2 PB14 + /** + * RET6 12864 LCD + * ------ + * PC6 | 1 2 | PB2 + * PB10 | 3 4 | PE8 + * PB14 5 6 | PB13 + * PB12 | 7 8 | PB15 + * GND | 9 10 | 5V + * ------ + * EXP1 + */ + #define EXP1_01_PIN PC6 + #define EXP1_02_PIN PB2 + #define EXP1_03_PIN PB10 + #define EXP1_04_PIN PE8 + #define EXP1_05_PIN PB14 + #define EXP1_06_PIN PB13 + #define EXP1_07_PIN PB12 + #define EXP1_08_PIN PB15 #ifndef HAS_PIN_27_BOARD - #define BEEPER_PIN PC6 + #define BEEPER_PIN EXP1_01_PIN #endif #elif ENABLED(VET6_12864_LCD) - // VET6 12864 LCD - #define LCD_PINS_RS PA4 - #define LCD_PINS_ENABLE PA7 - #define LCD_PINS_D4 PA5 - - #define BTN_ENC PC5 - #define BTN_EN1 PB10 - #define BTN_EN2 PA6 + /** + * VET6 12864 LCD + * ------ + * ? | 1 2 | PC5 + * PB10 | 3 4 | ? + * PA6 5 6 | PA5 + * PA4 | 7 8 | PA7 + * GND | 9 10 | 5V + * ------ + * EXP1 + */ + #define EXP1_01_PIN -1 + #define EXP1_02_PIN PC5 + #define EXP1_03_PIN PB10 + #define EXP1_04_PIN -1 + #define EXP1_05_PIN PA6 + #define EXP1_06_PIN PA5 + #define EXP1_07_PIN PA4 + #define EXP1_08_PIN PA7 #else #error "Define RET6_12864_LCD or VET6_12864_LCD to select pins for CR10_STOCKDISPLAY with the Creality V4 controller." #endif -#elif HAS_DWIN_E3V2 || IS_DWIN_MARLINUI + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN - // RET6 DWIN ENCODER LCD - #define BTN_ENC PB14 - #define BTN_EN1 PB15 - #define BTN_EN2 PB12 + #define BTN_ENC EXP1_02_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN - //#define LCD_LED_PIN PB2 - #ifndef BEEPER_PIN - #define BEEPER_PIN PB13 - #endif +#elif ANY(HAS_DWIN_E3V2, IS_DWIN_MARLINUI, DWIN_VET6_CREALITY_LCD) -#elif ENABLED(DWIN_VET6_CREALITY_LCD) + #if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI + // RET6 DWIN ENCODER LCD + #define EXP1_05_PIN PB14 + #define EXP1_06_PIN PB13 + #define EXP1_07_PIN PB12 + #define EXP1_08_PIN PB15 + //#define LCD_LED_PIN PB2 + #else + // VET6 DWIN ENCODER LCD + #define EXP1_05_PIN PA6 + #define EXP1_06_PIN PA5 + #define EXP1_07_PIN PA4 + #define EXP1_08_PIN PA7 + #endif - // VET6 DWIN ENCODER LCD - #define BTN_ENC PA6 - #define BTN_EN1 PA7 - #define BTN_EN2 PA4 + #define BTN_ENC EXP1_05_PIN + #define BTN_EN1 EXP1_08_PIN + #define BTN_EN2 EXP1_07_PIN - #define BEEPER_PIN PA5 + #ifndef BEEPER_PIN + #define BEEPER_PIN EXP1_06_PIN + #endif #endif diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V4210.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V4210.h index 484ff65442..86ede843be 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V4210.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V4210.h @@ -150,58 +150,58 @@ /** * RET6 12864 LCD * ------ - * PC6 |10 9 | PB2 - * PB10 | 8 7 | PE8 - * PB14 6 5 | PB13 - * PB12 | 4 3 | PB15 - * GND | 2 1 | 5V + * PC6 | 1 2 | PB2 + * PB10 | 3 4 | PE8 + * PB14 5 6 | PB13 + * PB12 | 7 8 | PB15 + * GND | 9 10 | 5V * ------ * EXP1 */ - #define EXP1_03_PIN PB15 - #define EXP1_04_PIN PB12 - #define EXP1_05_PIN PB13 - #define EXP1_06_PIN PB14 - #define EXP1_07_PIN PE8 - #define EXP1_08_PIN PB10 - #define EXP1_09_PIN PB2 - #define EXP1_10_PIN PC6 + #define EXP1_01_PIN PC6 + #define EXP1_02_PIN PB2 + #define EXP1_03_PIN PB10 + #define EXP1_04_PIN PE8 + #define EXP1_05_PIN PB14 + #define EXP1_06_PIN PB13 + #define EXP1_07_PIN PB12 + #define EXP1_08_PIN PB15 - #define BEEPER_PIN EXP1_10_PIN + #define BEEPER_PIN EXP1_01_PIN #elif ENABLED(VET6_12864_LCD) /** * VET6 12864 LCD * ------ - * ? |10 9 | PC5 - * PB10 | 8 7 | ? - * PA6 6 5 | PA5 - * PA4 | 4 3 | PA7 - * GND | 2 1 | 5V + * ? | 1 2 | PC5 + * PB10 | 3 4 | ? + * PA6 5 6 | PA5 + * PA4 | 7 8 | PA7 + * GND | 9 10 | 5V * ------ * EXP1 */ - #define EXP1_03_PIN PA7 - #define EXP1_04_PIN PA4 - #define EXP1_05_PIN PA5 - #define EXP1_06_PIN PA6 - #define EXP1_07_PIN -1 - #define EXP1_08_PIN PB10 - #define EXP1_09_PIN PC5 - #define EXP1_10_PIN -1 + #define EXP1_01_PIN -1 + #define EXP1_02_PIN PC5 + #define EXP1_03_PIN PB10 + #define EXP1_04_PIN -1 + #define EXP1_05_PIN PA6 + #define EXP1_06_PIN PA5 + #define EXP1_07_PIN PA4 + #define EXP1_08_PIN PA7 #else #error "Define RET6_12864_LCD or VET6_12864_LCD to select pins for CR10_STOCKDISPLAY with the Creality V4 controller." #endif - #define LCD_PINS_RS EXP1_04_PIN - #define LCD_PINS_ENABLE EXP1_03_PIN - #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN - #define BTN_ENC EXP1_09_PIN - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_PIN + #define BTN_ENC EXP1_02_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN #elif HAS_DWIN_E3V2 || IS_DWIN_MARLINUI diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V425.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V425.h new file mode 100644 index 0000000000..46f437ecaf --- /dev/null +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V425.h @@ -0,0 +1,77 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (C) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program 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. + * + * This program 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 this program. If not, see . + * + */ +#pragma once + +/** + * CREALITY 4.2.5 (STM32F103RE / STM32F103RC) board pin assignments + */ + +#include "env_validate.h" + +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 + #error "Creality v4.2.5 only supports 1 hotend / E stepper." +#endif + +#define BOARD_INFO_NAME "Creality V4.2.5" +#define DEFAULT_MACHINE_NAME "CR200B" + +// +// EEPROM +// +#if NO_EEPROM_SELECTED + #define IIC_BL24CXX_EEPROM // EEPROM on I2C-0 + #undef NO_EEPROM_SELECTED +#elif DISABLED(IIC_BL24CXX_EEPROM) + #define SDCARD_EEPROM_EMULATION // SD EEPROM until all EEPROM is BL24CXX +#endif + +// +// Servos +// +#define SERVO0_PIN PB1 // BLTouch OUT + +// +// Limit Switches +// +#define X_STOP_PIN PA3 +#define Y_STOP_PIN PA4 +#define Z_STOP_PIN PA5 + +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PB0 // BLTouch IN +#endif + +// +// Filament Runout Sensor +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN PA6 // "Pulled-high" +#endif + +// +// Heaters / Fans +// +#define HEATER_0_PIN PA0 // HEATER1 +#define HEATER_BED_PIN PA1 // HOT BED +#define FAN_PIN PA2 // FAN + +#include "pins_CREALITY_V4.h" diff --git a/Marlin/src/pins/stm32f1/pins_FLY_MINI.h b/Marlin/src/pins/stm32f1/pins_FLY_MINI.h index 952b40c1de..f39850f755 100644 --- a/Marlin/src/pins/stm32f1/pins_FLY_MINI.h +++ b/Marlin/src/pins/stm32f1/pins_FLY_MINI.h @@ -85,13 +85,13 @@ #if ENABLED(TMC_USE_SW_SPI) #ifndef TMC_SW_MOSI - #define TMC_SW_MOSI EXP2_05_PIN + #define TMC_SW_MOSI EXP2_06_PIN #endif #ifndef TMC_SW_MISO - #define TMC_SW_MISO EXP2_10_PIN + #define TMC_SW_MISO EXP2_01_PIN #endif #ifndef TMC_SW_SCK - #define TMC_SW_SCK EXP2_09_PIN + #define TMC_SW_SCK EXP2_02_PIN #endif #endif @@ -123,31 +123,31 @@ #define TEMP_0_PIN PC1 // Analog Input /** ------ ------ - * (BEEPER) PC14 |10 9 | PC13 (BTN_ENC) (MISO) PB14 |10 9 | PB13 (SD_SCK) - * (LCD_EN) PB9 | 8 7 | PB8 (LCD_RS) (BTN_EN1) PB3 | 8 7 | PB12 (SD_CS2) - * (LCD_D4) PB7 6 5 | PB6 (LCD_D5) (BTN_EN2) PD2 6 5 | PB15 (SD_MOSI) - * (LCD_D6) PB5 | 4 3 | PB4 (LCD_D7) (SD_DETECT) PB11 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | -- + * (BEEPER) PC14 | 1 2 | PC13 (BTN_ENC) (MISO) PB14 | 1 2 | PB13 (SD_SCK) + * (LCD_EN) PB9 | 3 4 | PB8 (LCD_RS) (BTN_EN1) PB3 | 3 4 | PB12 (SD_CS2) + * (LCD_D4) PB7 5 6 | PB6 (LCD_D5) (BTN_EN2) PD2 5 6 | PB15 (SD_MOSI) + * (LCD_D6) PB5 | 7 8 | PB4 (LCD_D7) (SD_DETECT) PB11 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN PB4 -#define EXP1_04_PIN PB5 -#define EXP1_05_PIN PB6 -#define EXP1_06_PIN PB7 -#define EXP1_07_PIN PB8 -#define EXP1_08_PIN PB9 -#define EXP1_09_PIN PC13 -#define EXP1_10_PIN PC14 - -#define EXP2_03_PIN -1 // RESET -#define EXP2_04_PIN PB11 -#define EXP2_05_PIN PB15 -#define EXP2_06_PIN PD2 -#define EXP2_07_PIN PB12 -#define EXP2_08_PIN PB3 -#define EXP2_09_PIN PB13 -#define EXP2_10_PIN PB14 +#define EXP1_01_PIN PC14 +#define EXP1_02_PIN PC13 +#define EXP1_03_PIN PB9 +#define EXP1_04_PIN PB8 +#define EXP1_05_PIN PB7 +#define EXP1_06_PIN PB6 +#define EXP1_07_PIN PB5 +#define EXP1_08_PIN PB4 + +#define EXP2_01_PIN PB14 +#define EXP2_02_PIN PB13 +#define EXP2_03_PIN PB3 +#define EXP2_04_PIN PB12 +#define EXP2_05_PIN PD2 +#define EXP2_06_PIN PB15 +#define EXP2_07_PIN PB11 +#define EXP2_08_PIN -1 // RESET // // LCD / Controller @@ -155,26 +155,26 @@ #if HAS_WIRED_LCD #define SPI_DEVICE 2 - #define SD_SS_PIN EXP2_07_PIN - #define SD_SCK_PIN EXP2_09_PIN - #define SD_MISO_PIN EXP2_10_PIN - #define SD_MOSI_PIN EXP2_05_PIN + #define SD_SS_PIN EXP2_04_PIN + #define SD_SCK_PIN EXP2_02_PIN + #define SD_MISO_PIN EXP2_01_PIN + #define SD_MOSI_PIN EXP2_06_PIN #define SDSS SD_SS_PIN - #define SD_DETECT_PIN EXP2_04_PIN + #define SD_DETECT_PIN EXP2_07_PIN - #define BEEPER_PIN EXP1_10_PIN + #define BEEPER_PIN EXP1_01_PIN - #define LCD_PINS_RS EXP1_07_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN - #define BTN_EN1 EXP2_06_PIN - #define BTN_EN2 EXP2_08_PIN - #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 EXP2_05_PIN + #define BTN_EN2 EXP2_03_PIN + #define BTN_ENC EXP1_02_PIN #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder diff --git a/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h b/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h index beda50d29b..e59e8aef59 100644 --- a/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h +++ b/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h @@ -133,11 +133,11 @@ /** * EXP1 pinout for the LCD according to FYSETC's Cheetah board schematic * ------ - * (BEEPER) PC9 |10 9 | PC12 (BTN_ENC) - * (BTN_EN2) PC11 | 8 7 | PB14 (LCD_RS / MISO) - * (BTN_EN1) PC10 6 5 | PB13 (SCK) - * (LCD_EN) PB12 | 4 3 | PB15 (MOSI) - * GND | 2 1 | 5V + * (BEEPER) PC9 | 1 2 | PC12 (BTN_ENC) + * (BTN_EN2) PC11 | 3 4 | PB14 (LCD_RS / MISO) + * (BTN_EN1) PC10 5 6 | PB13 (SCK) + * (LCD_EN) PB12 | 7 8 | PB15 (MOSI) + * GND | 9 10 | 5V * ------ * EXP1 * @@ -146,23 +146,23 @@ * - Functionally the pins are assigned in the same order as on the Ender-3 board. * - Pin 4 on the Cheetah board is assigned to an I/O, it is assigned to RESET on the Ender-3 board. */ -#define EXP1_03_PIN PB15 -#define EXP1_04_PIN PB12 -#define EXP1_05_PIN PB13 -#define EXP1_06_PIN PC10 -#define EXP1_07_PIN PB14 -#define EXP1_08_PIN PC11 -#define EXP1_09_PIN PC12 -#define EXP1_10_PIN PC9 +#define EXP1_01_PIN PC9 +#define EXP1_02_PIN PC12 +#define EXP1_03_PIN PC11 +#define EXP1_04_PIN PB14 +#define EXP1_05_PIN PC10 +#define EXP1_06_PIN PB13 +#define EXP1_07_PIN PB12 +#define EXP1_08_PIN PB15 #if HAS_WIRED_LCD - #define BEEPER_PIN EXP1_10_PIN + #define BEEPER_PIN EXP1_01_PIN #if HAS_MARLINUI_U8GLIB - #define DOGLCD_A0 EXP1_07_PIN - #define DOGLCD_CS EXP1_04_PIN - #define DOGLCD_SCK EXP1_05_PIN - #define DOGLCD_MOSI EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN + #define DOGLCD_CS EXP1_07_PIN + #define DOGLCD_SCK EXP1_06_PIN + #define DOGLCD_MOSI EXP1_08_PIN #if EITHER(FYSETC_MINI_12864, U8GLIB_ST7920) #define FORCE_SOFT_SPI @@ -170,30 +170,30 @@ //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 #endif - #define LCD_PINS_RS EXP1_04_PIN // CS -- SOFT SPI for ENDER3 LCD - #define LCD_PINS_D4 EXP1_05_PIN // SCLK - #define LCD_PINS_ENABLE EXP1_03_PIN // DATA MOSI + #define LCD_PINS_RS EXP1_07_PIN // CS -- SOFT SPI for ENDER3 LCD + #define LCD_PINS_D4 EXP1_06_PIN // SCLK + #define LCD_PINS_ENABLE EXP1_08_PIN // DATA MOSI //#define LCD_CONTRAST_INIT 190 #if IS_NEWPANEL - #define BTN_EN1 EXP1_06_PIN - #define BTN_EN2 EXP1_08_PIN - #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 EXP1_05_PIN + #define BTN_EN2 EXP1_03_PIN + #define BTN_ENC EXP1_02_PIN #endif #endif #if ENABLED(TOUCH_UI_FTDI_EVE) - #define BEEPER_PIN EXP1_10_PIN - #define CLCD_MOD_RESET EXP1_08_PIN - #define CLCD_SPI_CS EXP1_04_PIN + #define BEEPER_PIN EXP1_01_PIN + #define CLCD_MOD_RESET EXP1_03_PIN + #define CLCD_SPI_CS EXP1_07_PIN //#define CLCD_USE_SOFT_SPI // the Cheetah can use hardware-SPI so we do not really need this #if ENABLED(CLCD_USE_SOFT_SPI) - #define CLCD_SOFT_SPI_MOSI EXP1_03_PIN - #define CLCD_SOFT_SPI_MISO EXP1_07_PIN - #define CLCD_SOFT_SPI_SCLK EXP1_05_PIN + #define CLCD_SOFT_SPI_MOSI EXP1_08_PIN + #define CLCD_SOFT_SPI_MISO EXP1_04_PIN + #define CLCD_SOFT_SPI_SCLK EXP1_06_PIN #else #define CLCD_SPI_BUS 2 #endif diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h index 38f10f6713..b8f6f6a330 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h @@ -207,31 +207,31 @@ /** * ------ ------ - * PC5 |10 9 | PE13 PA6 |10 9 | PA5 - * PD13 | 8 7 | PC6 PE8 | 8 7 | PE10 - * PE14 | 6 5 PE15 PE11 | 6 5 PA7 - * PD11 | 4 3 | PD10 PE12 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | 3.3V + * PC5 | 1 2 | PE13 PA6 | 1 2 | PA5 + * PD13 | 3 4 | PC6 PE8 | 3 4 | PE10 + * PE14 | 5 6 PE15 PE11 | 5 6 PA7 + * PD11 | 7 8 | PD10 PE12 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | 3.3V * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN PD10 -#define EXP1_04_PIN PD11 -#define EXP1_05_PIN PE15 -#define EXP1_06_PIN PE14 -#define EXP1_07_PIN PC6 -#define EXP1_08_PIN PD13 -#define EXP1_09_PIN PE13 -#define EXP1_10_PIN PC5 - -#define EXP2_03_PIN -1 -#define EXP2_04_PIN PE12 -#define EXP2_05_PIN PA7 -#define EXP2_06_PIN PE11 -#define EXP2_07_PIN PE10 -#define EXP2_08_PIN PE8 -#define EXP2_09_PIN PA5 -#define EXP2_10_PIN PA6 +#define EXP1_01_PIN PC5 +#define EXP1_02_PIN PE13 +#define EXP1_03_PIN PD13 +#define EXP1_04_PIN PC6 +#define EXP1_05_PIN PE14 +#define EXP1_06_PIN PE15 +#define EXP1_07_PIN PD11 +#define EXP1_08_PIN PD10 + +#define EXP2_01_PIN PA6 +#define EXP2_02_PIN PA5 +#define EXP2_03_PIN PE8 +#define EXP2_04_PIN PE10 +#define EXP2_05_PIN PE11 +#define EXP2_06_PIN PA7 +#define EXP2_07_PIN PE12 +#define EXP2_08_PIN -1 // // SD Card @@ -247,11 +247,11 @@ #define ONBOARD_SD_CS_PIN PC11 #elif SD_CONNECTION_IS(LCD) #define ENABLE_SPI1 - #define SDSS EXP2_07_PIN - #define SD_SCK_PIN EXP2_09_PIN - #define SD_MISO_PIN EXP2_10_PIN - #define SD_MOSI_PIN EXP2_05_PIN - #define SD_DETECT_PIN EXP2_04_PIN + #define SDSS EXP2_04_PIN + #define SD_SCK_PIN EXP2_02_PIN + #define SD_MISO_PIN EXP2_01_PIN + #define SD_MOSI_PIN EXP2_06_PIN + #define SD_DETECT_PIN EXP2_07_PIN #endif // @@ -268,25 +268,25 @@ // Shared SPI TFT - #define LCD_BACKLIGHT_PIN EXP1_08_PIN + #define LCD_BACKLIGHT_PIN EXP1_03_PIN - #define TOUCH_CS_PIN EXP1_06_PIN // SPI1_NSS - #define TOUCH_SCK_PIN EXP2_09_PIN // SPI1_SCK - #define TOUCH_MISO_PIN EXP2_10_PIN // SPI1_MISO - #define TOUCH_MOSI_PIN EXP2_05_PIN // SPI1_MOSI + #define TOUCH_CS_PIN EXP1_05_PIN // SPI1_NSS + #define TOUCH_SCK_PIN EXP2_02_PIN // SPI1_SCK + #define TOUCH_MISO_PIN EXP2_01_PIN // SPI1_MISO + #define TOUCH_MOSI_PIN EXP2_06_PIN // SPI1_MOSI - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN - #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + #define BTN_ENC EXP1_02_PIN - #define TFT_CS_PIN EXP1_04_PIN - #define TFT_SCK_PIN EXP2_09_PIN - #define TFT_MISO_PIN EXP2_10_PIN - #define TFT_MOSI_PIN EXP2_05_PIN - #define TFT_DC_PIN EXP1_03_PIN + #define TFT_CS_PIN EXP1_07_PIN + #define TFT_SCK_PIN EXP2_02_PIN + #define TFT_MISO_PIN EXP2_01_PIN + #define TFT_MOSI_PIN EXP2_06_PIN + #define TFT_DC_PIN EXP1_08_PIN #define TFT_A0_PIN TFT_DC_PIN - #define TFT_RESET_PIN EXP1_07_PIN + #define TFT_RESET_PIN EXP1_04_PIN #define TFT_BACKLIGHT_PIN LCD_BACKLIGHT_PIN #define TOUCH_BUTTONS_HW_SPI @@ -298,22 +298,22 @@ #if ENABLED(TFT_CLASSIC_UI) // Emulated DOGM SPI - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_RS EXP1_07_PIN - #define BTN_ENC EXP1_09_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_RS EXP1_04_PIN + #define BTN_ENC EXP1_02_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN #elif ENABLED(TFT_COLOR_UI) #define TFT_BUFFER_SIZE 14400 #endif #if HAS_WIRED_LCD && !HAS_SPI_TFT - #define BEEPER_PIN EXP1_10_PIN - #define BTN_ENC EXP1_09_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_RS EXP1_07_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_RS EXP1_04_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN #define LCD_BACKLIGHT_PIN -1 #if ENABLED(MKS_MINI_12864) @@ -323,18 +323,18 @@ #define LCD_BACKLIGHT_PIN -1 #define LCD_RESET_PIN -1 - #define DOGLCD_A0 EXP1_04_PIN - #define DOGLCD_CS EXP1_05_PIN - #define DOGLCD_SCK EXP2_09_PIN - #define DOGLCD_MOSI EXP2_05_PIN + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_06_PIN + #define DOGLCD_SCK EXP2_02_PIN + #define DOGLCD_MOSI EXP2_06_PIN #elif IS_TFTGLCD_PANEL #if ENABLED(TFTGLCD_PANEL_SPI) - #define PIN_SPI_SCK EXP2_09_PIN - #define PIN_TFT_MISO EXP2_10_PIN - #define PIN_TFT_MOSI EXP2_05_PIN - #define TFTGLCD_CS EXP2_08_PIN + #define PIN_SPI_SCK EXP2_02_PIN + #define PIN_TFT_MISO EXP2_01_PIN + #define PIN_TFT_MOSI EXP2_06_PIN + #define TFTGLCD_CS EXP2_03_PIN #endif #ifndef BEEPER_PIN @@ -342,14 +342,14 @@ #endif #elif ENABLED(FYSETC_MINI_12864_2_1) - #define LCD_PINS_DC EXP1_07_PIN - #define DOGLCD_CS EXP1_08_PIN + #define LCD_PINS_DC EXP1_04_PIN + #define DOGLCD_CS EXP1_03_PIN #define DOGLCD_A0 DOGLCD_A0 #define LCD_BACKLIGHT_PIN -1 - #define LCD_RESET_PIN EXP1_06_PIN - #define NEOPIXEL_PIN EXP1_05_PIN - #define DOGLCD_MOSI EXP2_05_PIN - #define DOGLCD_SCK EXP2_09_PIN + #define LCD_RESET_PIN EXP1_05_PIN + #define NEOPIXEL_PIN EXP1_06_PIN + #define DOGLCD_MOSI EXP2_06_PIN + #define DOGLCD_SCK EXP2_02_PIN #if SD_CONNECTION_IS(ONBOARD) #define FORCE_SOFT_SPI #endif @@ -357,11 +357,11 @@ #else // !MKS_MINI_12864 - #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_D4 EXP1_05_PIN #if IS_ULTIPANEL - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder @@ -387,7 +387,7 @@ #endif #ifndef BEEPER_PIN - #define BEEPER_PIN EXP1_10_PIN + #define BEEPER_PIN EXP1_01_PIN #endif #if ENABLED(SPEAKER) && BEEPER_PIN == PC5 diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h index 4af88c1848..642c97bb11 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h @@ -141,82 +141,82 @@ /** * ------ ------ ------ - * (BEEPER) PC1 |10 9 | PC3 (BTN_ENC) (MISO) PB14 |10 9 | PB13 (SD_SCK) (BEEPER) PC1 |10 9 | PC3 (BTN_ENC) - * (LCD_EN) PA4 | 8 7 | PA5 (LCD_RS) (BTN_EN1) PB11 | 8 7 | PA15 (SD_SS) (BTN_EN1) PB11 | 8 7 | RESET - * (LCD_D4) PA6 6 5 | PA7 (LCD_D5) (BTN_EN2) PB0 6 5 | PB15 (SD_MOSI) (BTN_EN2) PB0 6 5 | PA6 (LCD_D4) - * (LCD_D6) PC4 | 4 3 | PC5 (LCD_D7) (SD_DETECT) PC10 | 4 3 | RESET (LCD_RS) PA5 | 4 3 | PA4 (LCD_EN) - * GND | 2 1 | 5V GND | 2 1 | -- GND | 2 1 | 5V + * (BEEPER) PC1 | 1 2 | PC3 (BTN_ENC) (MISO) PB14 | 1 2 | PB13 (SD_SCK) (BEEPER) PC1 | 1 2 | PC3 (BTN_ENC) + * (LCD_EN) PA4 | 3 4 | PA5 (LCD_RS) (BTN_EN1) PB11 | 3 4 | PA15 (SD_SS) (BTN_EN1) PB11 | 3 4 | RESET + * (LCD_D4) PA6 5 6 | PA7 (LCD_D5) (BTN_EN2) PB0 5 6 | PB15 (SD_MOSI) (BTN_EN2) PB0 5 6 | PA6 (LCD_D4) + * (LCD_D6) PC4 | 7 8 | PC5 (LCD_D7) (SD_DETECT) PC10 | 7 8 | RESET (LCD_RS) PA5 | 7 8 | PA4 (LCD_EN) + * GND | 9 10 | 5V GND | 9 10 | -- GND | 9 10 | 5V * ------ ------ ------ * EXP1 EXP2 "Ender-3 EXP1" */ -#define EXP1_03_PIN PC5 -#define EXP1_04_PIN PC4 -#define EXP1_05_PIN PA7 -#define EXP1_06_PIN PA6 -#define EXP1_07_PIN PA5 -#define EXP1_08_PIN PA4 -#define EXP1_09_PIN PC3 -#define EXP1_10_PIN PC1 - -#define EXP2_03_PIN -1 // RESET -#define EXP2_04_PIN PC10 -#define EXP2_05_PIN PB15 -#define EXP2_06_PIN PB0 -#define EXP2_07_PIN PA15 -#define EXP2_08_PIN PB11 -#define EXP2_09_PIN PB13 -#define EXP2_10_PIN PB14 +#define EXP1_01_PIN PC1 +#define EXP1_02_PIN PC3 +#define EXP1_03_PIN PA4 +#define EXP1_04_PIN PA5 +#define EXP1_05_PIN PA6 +#define EXP1_06_PIN PA7 +#define EXP1_07_PIN PC4 +#define EXP1_08_PIN PC5 + +#define EXP2_01_PIN PB14 +#define EXP2_02_PIN PB13 +#define EXP2_03_PIN PB11 +#define EXP2_04_PIN PA15 +#define EXP2_05_PIN PB0 +#define EXP2_06_PIN PB15 +#define EXP2_07_PIN PC10 +#define EXP2_08_PIN -1 // RESET // "Ender-3 EXP1" -#define E3_EXP1_03_PIN PA4 -#define E3_EXP1_04_PIN PA5 -#define E3_EXP1_05_PIN PA6 -#define E3_EXP1_06_PIN PB0 -#define E3_EXP1_07_PIN -1 // RESET -#define E3_EXP1_08_PIN PB11 -#define E3_EXP1_09_PIN PC3 -#define E3_EXP1_10_PIN PC1 +#define EXP3_01_PIN PC1 +#define EXP3_02_PIN PC3 +#define EXP3_03_PIN PB11 +#define EXP3_04_PIN -1 // RESET +#define EXP3_05_PIN PB0 +#define EXP3_06_PIN PA6 +#define EXP3_07_PIN PA5 +#define EXP3_08_PIN PA4 #if HAS_WIRED_LCD - #define BEEPER_PIN EXP1_10_PIN - #define BTN_ENC EXP1_09_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_RS EXP1_07_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_RS EXP1_04_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN // MKS MINI12864 and MKS LCD12864B; If using MKS LCD12864A (Need to remove RPK2 resistor) #if ENABLED(MKS_MINI_12864) #define LCD_BACKLIGHT_PIN -1 #define LCD_RESET_PIN -1 - #define DOGLCD_A0 EXP1_04_PIN - #define DOGLCD_CS EXP1_05_PIN - #define DOGLCD_SCK EXP2_09_PIN - #define DOGLCD_MOSI EXP2_05_PIN + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_06_PIN + #define DOGLCD_SCK EXP2_02_PIN + #define DOGLCD_MOSI EXP2_06_PIN #elif ENABLED(FYSETC_MINI_12864_2_1) - #define LCD_PINS_DC EXP1_07_PIN - #define DOGLCD_CS EXP1_08_PIN + #define LCD_PINS_DC EXP1_04_PIN + #define DOGLCD_CS EXP1_03_PIN #define DOGLCD_A0 LCD_PINS_DC #define LCD_BACKLIGHT_PIN -1 - #define LCD_RESET_PIN EXP1_06_PIN - #define NEOPIXEL_PIN EXP1_05_PIN - #define DOGLCD_MOSI EXP2_05_PIN - #define DOGLCD_SCK EXP2_09_PIN + #define LCD_RESET_PIN EXP1_05_PIN + #define NEOPIXEL_PIN EXP1_06_PIN + #define DOGLCD_MOSI EXP2_06_PIN + #define DOGLCD_SCK EXP2_02_PIN #define FORCE_SOFT_SPI #define SOFTWARE_SPI //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 #else - #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_D4 EXP1_05_PIN #if IS_ULTIPANEL - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN #if !defined(BTN_ENC_EN) && ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder @@ -254,12 +254,12 @@ #define ONBOARD_SPI_DEVICE 2 #define SDSS SD_SS_PIN #define ONBOARD_SD_CS_PIN SD_SS_PIN -#define SD_DETECT_PIN PC10 // EXP2_04_PIN +#define SD_DETECT_PIN PC10 // EXP2_07_PIN #define NO_SD_HOST_DRIVE // TODO: This is the only way to set SPI for SD on STM32 (for now) #define ENABLE_SPI2 -#define SD_SCK_PIN EXP2_09_PIN -#define SD_MISO_PIN EXP2_10_PIN -#define SD_MOSI_PIN EXP2_05_PIN -#define SD_SS_PIN EXP2_07_PIN +#define SD_SCK_PIN EXP2_02_PIN +#define SD_MISO_PIN EXP2_01_PIN +#define SD_MOSI_PIN EXP2_06_PIN +#define SD_SS_PIN EXP2_04_PIN diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h index bc42bd02eb..7ead6aa288 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h @@ -80,50 +80,50 @@ #define FIL_RUNOUT_PIN PB8 // MT_DET /** ------ - * (BEEPER) PD2 |10 9 | PB3 (BTN_ENC) - * (BTN_EN1) PB5 | 8 7 | PA11 (RESET?) - * (BTN_EN2) PB4 6 5 | PC1 (LCD_D4) - * (LCD_RS) PC3 | 4 3 | PC2 (LCD_EN) - * GND | 2 1 | 5V + * (BEEPER) PD2 | 1 2 | PB3 (BTN_ENC) + * (BTN_EN1) PB5 | 3 4 | PA11 (RESET?) + * (BTN_EN2) PB4 5 6 | PC1 (LCD_D4) + * (LCD_RS) PC3 | 7 8 | PC2 (LCD_EN) + * GND | 9 10 | 5V * ------ * "E3" EXP1 */ -#define E3_EXP1_01_PIN -1 // 5V -#define E3_EXP1_02_PIN -1 // GND -#define E3_EXP1_03_PIN PC2 -#define E3_EXP1_04_PIN PC3 -#define E3_EXP1_05_PIN PC1 -#define E3_EXP1_06_PIN PB4 -#define E3_EXP1_07_PIN PA11 // RESET? -#define E3_EXP1_08_PIN PB5 -#define E3_EXP1_09_PIN PB3 -#define E3_EXP1_10_PIN PD2 +#define EXP3_01_PIN PD2 +#define EXP3_02_PIN PB3 +#define EXP3_03_PIN PB5 +#define EXP3_04_PIN PA11 // RESET? +#define EXP3_05_PIN PB4 +#define EXP3_06_PIN PC1 +#define EXP3_07_PIN PC3 +#define EXP3_08_PIN PC2 +#define EXP3_09_PIN -1 // GND +#define EXP3_10_PIN -1 // 5V // // LCD Pins // #if HAS_WIRED_LCD - #define BEEPER_PIN E3_EXP1_10_PIN - #define BTN_ENC E3_EXP1_09_PIN - #define LCD_PINS_RS E3_EXP1_04_PIN + #define BEEPER_PIN EXP3_01_PIN + #define BTN_ENC EXP3_02_PIN + #define LCD_PINS_RS EXP3_07_PIN - #define BTN_EN1 E3_EXP1_08_PIN - #define BTN_EN2 E3_EXP1_06_PIN + #define BTN_EN1 EXP3_03_PIN + #define BTN_EN2 EXP3_05_PIN - #define LCD_PINS_ENABLE E3_EXP1_03_PIN + #define LCD_PINS_ENABLE EXP3_08_PIN #if ENABLED(MKS_MINI_12864) #define LCD_BACKLIGHT_PIN -1 #define LCD_RESET_PIN -1 - #define DOGLCD_A0 E3_EXP1_05_PIN - #define DOGLCD_CS E3_EXP1_03_PIN + #define DOGLCD_A0 EXP3_06_PIN + #define DOGLCD_CS EXP3_08_PIN #define DOGLCD_SCK PB13 #define DOGLCD_MOSI PB15 #else // !MKS_MINI_12864 - #define LCD_PINS_D4 E3_EXP1_05_PIN + #define LCD_PINS_D4 EXP3_06_PIN #if IS_ULTIPANEL #define LCD_PINS_D5 -1 #define LCD_PINS_D6 -1 @@ -164,12 +164,12 @@ // EXP1 replace LCD with keys for EasyThreeD ET4000+ Mainboard #if ENABLED(EASYTHREED_UI) - #define BTN_HOME E3_EXP1_04_PIN // INPUT_PULLUP (unused) - #define BTN_FEED E3_EXP1_09_PIN // Run E Forward - #define BTN_RETRACT E3_EXP1_08_PIN // Run E Backward - #define BTN_PRINT E3_EXP1_07_PIN // Start File Print - #define BTN_HOME_GND E3_EXP1_03_PIN // OUTPUT (LOW) - #define BTN_FEED_GND E3_EXP1_06_PIN // OUTPUT (LOW) - #define BTN_RETRACT_GND E3_EXP1_05_PIN // OUTPUT (LOW) - #define EASYTHREED_LED_PIN E3_EXP1_10_PIN // Indicator LED + #define BTN_HOME EXP3_07_PIN // INPUT_PULLUP (unused) + #define BTN_FEED EXP3_02_PIN // Run E Forward + #define BTN_RETRACT EXP3_03_PIN // Run E Backward + #define BTN_PRINT EXP3_04_PIN // Start File Print + #define BTN_HOME_GND EXP3_08_PIN // OUTPUT (LOW) + #define BTN_FEED_GND EXP3_05_PIN // OUTPUT (LOW) + #define BTN_RETRACT_GND EXP3_06_PIN // OUTPUT (LOW) + #define EASYTHREED_LED_PIN EXP3_01_PIN // Indicator LED #endif diff --git a/Marlin/src/pins/stm32f1/pins_PANDA_PI_V29.h b/Marlin/src/pins/stm32f1/pins_PANDA_PI_V29.h index ad28e5c47b..ed602d8d01 100644 --- a/Marlin/src/pins/stm32f1/pins_PANDA_PI_V29.h +++ b/Marlin/src/pins/stm32f1/pins_PANDA_PI_V29.h @@ -38,6 +38,12 @@ #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2K #endif +#if ENABLED(BD_SENSOR) + #define I2C_BD_SDA_PIN PC6 + #define I2C_BD_SCL_PIN PB2 + #define I2C_BD_DELAY 10 // (seconds) +#endif + // // Servos // @@ -179,30 +185,30 @@ /** FYSETC TFT TFT81050 display pinout * - * Board Display - * ----- ----- - * 5V | 1 2 | GND (SPI1-MISO) MISO | 1 2 | SCK (SPI1-SCK) - * (FREE) PB7 | 3 4 | PB8 (LCD_CS) (PA9) MOD_RESET | 3 4 | SD_CS (PA10) - * (FREE) PB9 | 5 6 PA10 (SD_CS) (PB8) LCD_CS | 5 6 MOSI (SPI1-MOSI) - * RESET | 7 8 | PA9 (MOD_RESET) (PA15) SD_DET | 7 8 | RESET - * (BEEPER) PB6 | 9 10| PA15 (SD_DET) GND | 9 10| 5V - * ----- ----- - * EXP1 EXP1 + * Board Display + * ------ ------ + * (SD_DET) PA15 | 1 2 | PB6 (BEEPER) (SPI1-MISO) MISO | 1 2 | SCK (SPI1-SCK) + * (MOD_RESET) PA9 | 3 4 | RESET MOD_RESET | 3 4 | SD_CS + * (SD_CS) PA10 5 6 | PB9 (FREE) LCD_CS | 5 6 MOSI (SPI1-MOSI) + * (LCD_CS) PB8 | 7 8 | PB7 (FREE) SD_DET | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | 5V + * ------ ------ + * EXP1 EXP1 * * Needs custom cable: * * Board Adapter Display - * _________ - * EXP1-1 ----------- EXP1-10 - * EXP1-2 ----------- EXP1-9 - * SPI1-4 ----------- EXP1-6 - * EXP1-4 ----------- EXP1-5 - * SP11-3 ----------- EXP1-2 - * EXP1-6 ----------- EXP1-4 - * EXP1-7 ----------- EXP1-8 - * EXP1-8 ----------- EXP1-3 - * SPI1-1 ----------- EXP1-1 - * EXP1-10 ----------- EXP1-7 + * ---------------------------------- + * EXP1-10 ---------- EXP1-10 5V + * EXP1-9 ----------- EXP1-9 GND + * SPI1-4 ----------- EXP1-6 MOSI + * EXP1-7 ----------- EXP1-5 LCD_CS + * SP11-3 ----------- EXP1-2 SCK + * EXP1-5 ----------- EXP1-4 SD_CS + * EXP1-4 ----------- EXP1-8 RESET + * EXP1-3 ----------- EXP1-3 MOD_RST + * SPI1-1 ----------- EXP1-1 MISO + * EXP1-1 ----------- EXP1-7 SD_DET */ #define CLCD_SPI_BUS 1 // SPI1 connector diff --git a/Marlin/src/pins/stm32f1/pins_STM32F1R.h b/Marlin/src/pins/stm32f1/pins_STM32F1R.h index c08b707d7e..634cadc1aa 100644 --- a/Marlin/src/pins/stm32f1/pins_STM32F1R.h +++ b/Marlin/src/pins/stm32f1/pins_STM32F1R.h @@ -120,7 +120,7 @@ #error "LCD_I2C_PANELOLU2 is not supported." #elif ENABLED(LCD_I2C_VIKI) #error "LCD_I2C_VIKI is not supported." - #elif ANY(VIKI2, miniVIKI) + #elif EITHER(VIKI2, miniVIKI) #error "VIKI2 / miniVIKI is not supported." #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) #error "ELB_FULL_GRAPHIC_CONTROLLER is not supported." diff --git a/Marlin/src/pins/stm32f1/pins_STM3R_MINI.h b/Marlin/src/pins/stm32f1/pins_STM3R_MINI.h index e189fc3f97..eee7dbf316 100644 --- a/Marlin/src/pins/stm32f1/pins_STM3R_MINI.h +++ b/Marlin/src/pins/stm32f1/pins_STM3R_MINI.h @@ -144,7 +144,7 @@ #error "LCD_I2C_PANELOLU2 is not supported." #elif ENABLED(LCD_I2C_VIKI) #error "LCD_I2C_VIKI is not supported." - #elif ANY(VIKI2, miniVIKI) + #elif EITHER(VIKI2, miniVIKI) #error "VIKI2 / miniVIKI is not supported." #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) #error "ELB_FULL_GRAPHIC_CONTROLLER is not supported." diff --git a/Marlin/src/pins/stm32f1/pins_ZM3E2_V1_0.h b/Marlin/src/pins/stm32f1/pins_ZM3E2_V1_0.h index f1f03a7dd7..1347a14678 100644 --- a/Marlin/src/pins/stm32f1/pins_ZM3E2_V1_0.h +++ b/Marlin/src/pins/stm32f1/pins_ZM3E2_V1_0.h @@ -72,14 +72,14 @@ // 2 +5V // 1 GND -#define EXP1_03_PIN PB11 -#define EXP1_04_PIN PB10 -#define EXP1_05_PIN PB2 -#define EXP1_06_PIN PC5 -#define EXP1_07_PIN PA10 -#define EXP1_08_PIN PA9 -#define EXP1_09_PIN PB0 -#define EXP1_10_PIN PB1 +#define EXP1_01_PIN PB1 +#define EXP1_02_PIN PB0 +#define EXP1_03_PIN PA9 +#define EXP1_04_PIN PA10 +#define EXP1_05_PIN PC5 +#define EXP1_06_PIN PB2 +#define EXP1_07_PIN PB10 +#define EXP1_08_PIN PB11 // AUX1 connector // 1 +5V @@ -193,14 +193,14 @@ // 1 GND #define LCDSCREEN_NAME "ZONESTAR LCD12864" - #define LCD_PINS_RS EXP1_08_PIN - #define LCD_PINS_ENABLE EXP1_05_PIN - #define LCD_PINS_D4 EXP1_07_PIN - //#define KILL_PIN EXP1_10_PIN - #define BEEPER_PIN EXP1_09_PIN - #define BTN_EN1 EXP1_03_PIN - #define BTN_EN2 EXP1_06_PIN - #define BTN_ENC EXP1_04_PIN + #define LCD_PINS_RS EXP1_03_PIN + #define LCD_PINS_ENABLE EXP1_06_PIN + #define LCD_PINS_D4 EXP1_04_PIN + //#define KILL_PIN EXP1_01_PIN + #define BEEPER_PIN EXP1_02_PIN + #define BTN_EN1 EXP1_08_PIN + #define BTN_EN2 EXP1_05_PIN + #define BTN_ENC EXP1_07_PIN #define BOARD_ST7920_DELAY_1 125 #define BOARD_ST7920_DELAY_2 200 #define BOARD_ST7920_DELAY_3 125 @@ -221,15 +221,15 @@ #define FORCE_SOFT_SPI #define LCDSCREEN_NAME "ZONESTAR 12864OLED" - #define LCD_PINS_RS EXP1_05_PIN // = LCD_RESET_PIN - #define LCD_PINS_DC EXP1_07_PIN // DC - #define DOGLCD_CS EXP1_08_PIN // CS + #define LCD_PINS_RS EXP1_06_PIN // = LCD_RESET_PIN + #define LCD_PINS_DC EXP1_04_PIN // DC + #define DOGLCD_CS EXP1_03_PIN // CS #define DOGLCD_A0 LCD_PINS_DC - #define DOGLCD_MOSI EXP1_10_PIN // SDA - #define DOGLCD_SCK EXP1_09_PIN // SCK + #define DOGLCD_MOSI EXP1_01_PIN // SDA + #define DOGLCD_SCK EXP1_02_PIN // SCK // Encoder - #define BTN_EN1 EXP1_03_PIN - #define BTN_EN2 EXP1_06_PIN - #define BTN_ENC EXP1_04_PIN + #define BTN_EN1 EXP1_08_PIN + #define BTN_EN2 EXP1_05_PIN + #define BTN_ENC EXP1_07_PIN #endif diff --git a/Marlin/src/pins/stm32f1/pins_ZM3E4_V1_0.h b/Marlin/src/pins/stm32f1/pins_ZM3E4_V1_0.h index 17e13bdc87..9618b3ad1a 100644 --- a/Marlin/src/pins/stm32f1/pins_ZM3E4_V1_0.h +++ b/Marlin/src/pins/stm32f1/pins_ZM3E4_V1_0.h @@ -89,14 +89,14 @@ // 2 +5V +5V // 1 GND GND -#define EXP1_03_PIN PE14 -#define EXP1_04_PIN PE15 -#define EXP1_05_PIN PE9 -#define EXP1_06_PIN PE8 -#define EXP1_07_PIN PE10 -#define EXP1_08_PIN PE12 -#define EXP1_09_PIN PE11 -#define EXP1_10_PIN PE13 +#define EXP1_01_PIN PE13 +#define EXP1_02_PIN PE11 +#define EXP1_03_PIN PE12 +#define EXP1_04_PIN PE10 +#define EXP1_05_PIN PE8 +#define EXP1_06_PIN PE9 +#define EXP1_07_PIN PE15 +#define EXP1_08_PIN PE14 // EXP2 connector // MARK I/O ZONESTAR_LCD12864 REPRAPDISCOUNT_LCD12864 @@ -111,12 +111,12 @@ // 2 +5V +5V // 1 GND GND -#define EXP2_03_PIN PB3 -#define EXP2_04_PIN PB5 -#define EXP2_05_PIN PB4 -#define EXP2_06_PIN PA15 -#define EXP2_07_PIN PA10 -#define EXP2_08_PIN PA9 +#define EXP2_03_PIN PA9 +#define EXP2_04_PIN PA10 +#define EXP2_05_PIN PA15 +#define EXP2_06_PIN PB4 +#define EXP2_07_PIN PB5 +#define EXP2_08_PIN PB3 // AUX1 connector // 1 +5V @@ -279,55 +279,55 @@ // #if ENABLED(ZONESTAR_12864LCD) #define LCDSCREEN_NAME "ZONESTAR LCD12864" - #define LCD_PINS_RS EXP1_08_PIN // 7 CS make sure for zonestar zm3e4! - #define LCD_PINS_ENABLE EXP1_05_PIN // 6 DATA make sure for zonestar zm3e4! - #define LCD_PINS_D4 EXP1_07_PIN // 8 SCK make sure for zonestar zm3e4! - #define BEEPER_PIN EXP1_09_PIN - #define KILL_PIN -1 // EXP1_10_PIN - #define BTN_EN1 EXP1_06_PIN - #define BTN_EN2 EXP1_03_PIN - #define BTN_ENC EXP1_04_PIN + #define LCD_PINS_RS EXP1_03_PIN // 7 CS make sure for zonestar zm3e4! + #define LCD_PINS_ENABLE EXP1_06_PIN // 6 DATA make sure for zonestar zm3e4! + #define LCD_PINS_D4 EXP1_04_PIN // 8 SCK make sure for zonestar zm3e4! + #define BEEPER_PIN EXP1_02_PIN + #define KILL_PIN -1 // EXP1_01_PIN + #define BTN_EN1 EXP1_05_PIN + #define BTN_EN2 EXP1_08_PIN + #define BTN_ENC EXP1_07_PIN #elif ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) #define LCDSCREEN_NAME "REPRAPDISCOUNT LCD12864" - #define LCD_PINS_RS EXP1_08_PIN // 7 CS make sure for zonestar zm3e4! - #define LCD_PINS_ENABLE EXP1_07_PIN // 6 DATA make sure for zonestar zm3e4! - #define LCD_PINS_D4 EXP1_05_PIN // 8 SCK make sure for zonestar zm3e4! - #define BEEPER_PIN EXP1_09_PIN - #define KILL_PIN EXP2_04_PIN - #define BTN_EN1 EXP2_05_PIN - #define BTN_EN2 EXP2_07_PIN - #define BTN_ENC EXP1_10_PIN + #define LCD_PINS_RS EXP1_03_PIN // 7 CS make sure for zonestar zm3e4! + #define LCD_PINS_ENABLE EXP1_04_PIN // 6 DATA make sure for zonestar zm3e4! + #define LCD_PINS_D4 EXP1_06_PIN // 8 SCK make sure for zonestar zm3e4! + #define BEEPER_PIN EXP1_02_PIN + #define KILL_PIN EXP2_07_PIN + #define BTN_EN1 EXP2_06_PIN + #define BTN_EN2 EXP2_04_PIN + #define BTN_ENC EXP1_01_PIN #elif ENABLED(ZONESTAR_DWIN_LCD) // Connect to EXP2 connector #define LCDSCREEN_NAME "ZONESTAR DWIN LCD" - #define BEEPER_PIN EXP2_06_PIN + #define BEEPER_PIN EXP2_05_PIN #define KILL_PIN PC0 - #define BTN_EN1 EXP2_03_PIN - #define BTN_EN2 EXP2_04_PIN - #define BTN_ENC EXP2_05_PIN + #define BTN_EN1 EXP2_08_PIN + #define BTN_EN2 EXP2_07_PIN + #define BTN_ENC EXP2_06_PIN #endif #if ENABLED(ZONESTAR_LCD2004_KNOB) #define LCDSCREEN_NAME "LCD2004 KNOB" - #define LCD_PINS_RS EXP1_08_PIN - #define LCD_PINS_ENABLE EXP1_07_PIN - #define LCD_PINS_D4 EXP1_05_PIN - #define LCD_PINS_D5 EXP1_06_PIN - #define LCD_PINS_D6 EXP1_03_PIN - #define LCD_PINS_D7 EXP1_04_PIN - #define BTN_EN1 EXP2_07_PIN - #define BTN_EN2 EXP2_05_PIN - #define BTN_ENC EXP1_10_PIN - #define BEEPER_PIN EXP1_09_PIN - #define KILL_PIN EXP2_04_PIN + #define LCD_PINS_RS EXP1_03_PIN + #define LCD_PINS_ENABLE EXP1_04_PIN + #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_D5 EXP1_05_PIN + #define LCD_PINS_D6 EXP1_08_PIN + #define LCD_PINS_D7 EXP1_07_PIN + #define BTN_EN1 EXP2_04_PIN + #define BTN_EN2 EXP2_06_PIN + #define BTN_ENC EXP1_01_PIN + #define BEEPER_PIN EXP1_02_PIN + #define KILL_PIN EXP2_07_PIN #elif ENABLED(ZONESTAR_LCD2004_ADCKEY) #define LCDSCREEN_NAME "LCD2004 5KEY" - #define LCD_PINS_RS EXP1_08_PIN - #define LCD_PINS_ENABLE EXP1_07_PIN - #define LCD_PINS_D4 EXP1_05_PIN - #define LCD_PINS_D5 EXP1_06_PIN - #define LCD_PINS_D6 EXP1_03_PIN - #define LCD_PINS_D7 EXP1_04_PIN + #define LCD_PINS_RS EXP1_03_PIN + #define LCD_PINS_ENABLE EXP1_04_PIN + #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_D5 EXP1_05_PIN + #define LCD_PINS_D6 EXP1_08_PIN + #define LCD_PINS_D7 EXP1_07_PIN #define ADC_KEYPAD_PIN PC0 // PIN6 of AUX1 #endif @@ -341,16 +341,16 @@ // Remap SERVO0 PIN for BLTouch #if ENABLED(BLTOUCH_ON_EXP1) // BLTouch connected to EXP1 - #define BLTOUCH_PROBE_PIN EXP1_06_PIN - #define BLTOUCH_GND_PIN EXP1_04_PIN + #define BLTOUCH_PROBE_PIN EXP1_05_PIN + #define BLTOUCH_GND_PIN EXP1_07_PIN #undef SERVO0_PIN - #define SERVO0_PIN EXP1_03_PIN + #define SERVO0_PIN EXP1_08_PIN #elif ENABLED(BLTOUCH_ON_EXP2) // BLTouch connected to EXP2 - #define BLTOUCH_PROBE_PIN EXP2_03_PIN - #define BLTOUCH_GND_PIN EXP2_04_PIN + #define BLTOUCH_PROBE_PIN EXP2_08_PIN + #define BLTOUCH_GND_PIN EXP2_07_PIN #undef SERVO0_PIN - #define SERVO0_PIN EXP2_06_PIN + #define SERVO0_PIN EXP2_05_PIN #else #define BLTOUCH_PROBE_PIN PB13 #endif diff --git a/Marlin/src/pins/stm32f1/pins_ZM3E4_V2_0.h b/Marlin/src/pins/stm32f1/pins_ZM3E4_V2_0.h index df0eb9c3d8..d1d8a4c68f 100644 --- a/Marlin/src/pins/stm32f1/pins_ZM3E4_V2_0.h +++ b/Marlin/src/pins/stm32f1/pins_ZM3E4_V2_0.h @@ -90,14 +90,14 @@ // 2 +5V // 1 GND -#define EXP1_03_PIN PE14 -#define EXP1_04_PIN PE15 -#define EXP1_05_PIN PE9 -#define EXP1_06_PIN PE8 -#define EXP1_07_PIN PE10 -#define EXP1_08_PIN PE12 -#define EXP1_09_PIN PE11 -#define EXP1_10_PIN PE13 +#define EXP1_01_PIN PE13 +#define EXP1_02_PIN PE11 +#define EXP1_03_PIN PE12 +#define EXP1_04_PIN PE10 +#define EXP1_05_PIN PE8 +#define EXP1_06_PIN PE9 +#define EXP1_07_PIN PE15 +#define EXP1_08_PIN PE14 // EXP2 connector // MARK I/O ZONESTAR_LCD12864 REPRAPDISCOUNT_LCD12864 @@ -112,14 +112,14 @@ // 2 +5V // 1 GND -#define EXP2_03_PIN PB3 -#define EXP2_04_PIN PB5 -#define EXP2_05_PIN PB4 -#define EXP2_06_PIN PA15 -#define EXP2_07_PIN PA10 -#define EXP2_08_PIN PA9 -#define EXP2_09_PIN PE7 -#define EXP2_10_PIN PC0 +#define EXP2_01_PIN PC0 +#define EXP2_02_PIN PE7 +#define EXP2_03_PIN PA9 +#define EXP2_04_PIN PA10 +#define EXP2_05_PIN PA15 +#define EXP2_06_PIN PB4 +#define EXP2_07_PIN PB5 +#define EXP2_08_PIN PB3 // AUX1 connector // 1 +5V @@ -276,32 +276,32 @@ #if ENABLED(ZONESTAR_12864LCD) #define LCDSCREEN_NAME "ZONESTAR LCD12864" - #define LCD_PINS_RS EXP1_08_PIN // 7 CS make sure for zonestar zm3e4! - #define LCD_PINS_ENABLE EXP1_05_PIN // 6 DATA make sure for zonestar zm3e4! - #define LCD_PINS_D4 EXP1_07_PIN // 8 SCK make sure for zonestar zm3e4! - #define BEEPER_PIN EXP1_09_PIN - #define KILL_PIN -1 // EXP1_10_PIN - #define BTN_EN1 EXP1_06_PIN - #define BTN_EN2 EXP1_03_PIN - #define BTN_ENC EXP1_04_PIN + #define LCD_PINS_RS EXP1_03_PIN // 7 CS make sure for zonestar zm3e4! + #define LCD_PINS_ENABLE EXP1_06_PIN // 6 DATA make sure for zonestar zm3e4! + #define LCD_PINS_D4 EXP1_04_PIN // 8 SCK make sure for zonestar zm3e4! + #define BEEPER_PIN EXP1_02_PIN + #define KILL_PIN -1 // EXP1_01_PIN + #define BTN_EN1 EXP1_05_PIN + #define BTN_EN2 EXP1_08_PIN + #define BTN_ENC EXP1_07_PIN #elif ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) #define LCDSCREEN_NAME "REPRAPDISCOUNT LCD12864" - #define LCD_PINS_RS EXP2_08_PIN // 7 CS make sure for zonestar zm3e4! - #define LCD_PINS_ENABLE EXP2_05_PIN // 6 DATA make sure for zonestar zm3e4! - #define LCD_PINS_D4 EXP2_07_PIN // 8 SCK make sure for zonestar zm3e4! - #define BEEPER_PIN EXP2_10_PIN - #define KILL_PIN EXP2_09_PIN - #define BTN_EN1 EXP2_03_PIN - #define BTN_EN2 EXP2_06_PIN - #define BTN_ENC EXP2_04_PIN + #define LCD_PINS_RS EXP2_03_PIN // 7 CS make sure for zonestar zm3e4! + #define LCD_PINS_ENABLE EXP2_06_PIN // 6 DATA make sure for zonestar zm3e4! + #define LCD_PINS_D4 EXP2_04_PIN // 8 SCK make sure for zonestar zm3e4! + #define BEEPER_PIN EXP2_01_PIN + #define KILL_PIN EXP2_02_PIN + #define BTN_EN1 EXP2_08_PIN + #define BTN_EN2 EXP2_05_PIN + #define BTN_ENC EXP2_07_PIN #elif ENABLED(ZONESTAR_DWIN_LCD) // Connect to EXP2 connector #define LCDSCREEN_NAME "ZONESTAR DWIN LCD" - #define BEEPER_PIN EXP2_06_PIN // PE11 - #define KILL_PIN -1 // EXP1_10_PIN - #define BTN_EN2 EXP2_04_PIN // PE8 - #define BTN_EN1 EXP2_03_PIN // PE14 - #define BTN_ENC EXP2_05_PIN // PE15 + #define BEEPER_PIN EXP2_05_PIN // PE11 + #define KILL_PIN -1 // EXP1_01_PIN + #define BTN_EN2 EXP2_07_PIN // PE8 + #define BTN_EN1 EXP2_08_PIN // PE14 + #define BTN_ENC EXP2_06_PIN // PE15 #endif // Alter timing for graphical display @@ -314,16 +314,16 @@ // Remap SERVO0 PIN for BLTouch #if ENABLED(BLTOUCH_ON_EXP1) // BLTouch connected to EXP1 - #define BLTOUCH_PROBE_PIN EXP1_06_PIN - #define BLTOUCH_GND_PIN EXP1_04_PIN + #define BLTOUCH_PROBE_PIN EXP1_05_PIN + #define BLTOUCH_GND_PIN EXP1_07_PIN #undef SERVO0_PIN - #define SERVO0_PIN EXP1_03_PIN + #define SERVO0_PIN EXP1_08_PIN #elif ENABLED(BLTOUCH_ON_EXP2) // BLTouch connected to EXP2 - #define BLTOUCH_PROBE_PIN EXP2_03_PIN - #define BLTOUCH_GND_PIN EXP2_04_PIN + #define BLTOUCH_PROBE_PIN EXP2_08_PIN + #define BLTOUCH_GND_PIN EXP2_07_PIN #undef SERVO0_PIN - #define SERVO0_PIN EXP2_06_PIN + #define SERVO0_PIN EXP2_05_PIN #else #define BLTOUCH_PROBE_PIN PB13 // Z1_MAX #endif diff --git a/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h b/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h index 531ab7a958..2147dd9b4f 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h @@ -199,109 +199,109 @@ /** * ---------------------------------BTT002 V1.0--------------------------------- * ------ ------ | - * (BEEPER) PE7 |10 9 | PB1 (BTN_ENC) (MISO) PA6 |10 9 | PA5 (SCK) | - * (LCD_EN) PE9 | 8 7 | PE8 (LCD_RS) (BTN_EN1) PC5 | 8 7 | PA4 (SD_SS) | - * (LCD_D4) PE10 6 5 | PE11 (LCD_D5) (BTN_EN2) PB0 6 5 | PA7 (MOSI) | - * (LCD_D6) PE12 | 4 3 | PE13 (LCD_D7) (SD_DET) PC4 | 4 3 | RESET | - * GND | 2 1 | 5V GND | 2 1 | PA3 | + * (BEEPER) PE7 | 1 2 | PB1 (BTN_ENC) (MISO) PA6 | 1 2 | PA5 (SCK) | + * (LCD_EN) PE9 | 3 4 | PE8 (LCD_RS) (BTN_EN1) PC5 | 3 4 | PA4 (SD_SS) | + * (LCD_D4) PE10 5 6 | PE11 (LCD_D5) (BTN_EN2) PB0 5 6 | PA7 (MOSI) | + * (LCD_D6) PE12 | 7 8 | PE13 (LCD_D7) (SD_DET) PC4 | 7 8 | RESET | + * GND | 9 10 | 5V GND | 9 10 | PA3 | * ------ ------ | * EXP1 EXP2 | * ------------------------------------------------------------------------------ */ -#define EXP1_03_PIN PE13 -#define EXP1_04_PIN PE12 -#define EXP1_05_PIN PE11 -#define EXP1_06_PIN PE10 -#define EXP1_07_PIN PE8 -#define EXP1_08_PIN PE9 -#define EXP1_09_PIN PB1 -#define EXP1_10_PIN PE7 - -#define EXP2_01_PIN PA3 -#define EXP2_03_PIN -1 -#define EXP2_04_PIN PC4 -#define EXP2_05_PIN PA7 -#define EXP2_06_PIN PB0 -#define EXP2_07_PIN PA4 -#define EXP2_08_PIN PC5 -#define EXP2_09_PIN PA5 -#define EXP2_10_PIN PA6 +#define EXP1_01_PIN PE7 +#define EXP1_02_PIN PB1 +#define EXP1_03_PIN PE9 +#define EXP1_04_PIN PE8 +#define EXP1_05_PIN PE10 +#define EXP1_06_PIN PE11 +#define EXP1_07_PIN PE12 +#define EXP1_08_PIN PE13 + +#define EXP2_01_PIN PA6 +#define EXP2_02_PIN PA5 +#define EXP2_03_PIN PC5 +#define EXP2_04_PIN PA4 +#define EXP2_05_PIN PB0 +#define EXP2_06_PIN PA7 +#define EXP2_07_PIN PC4 +#define EXP2_08_PIN -1 +#define EXP2_10_PIN PA3 // HAL SPI1 pins -#define SD_SCK_PIN EXP2_09_PIN // SPI1 SCLK -#define SD_SS_PIN EXP2_07_PIN // SPI1 SSEL -#define SD_MISO_PIN EXP2_10_PIN // SPI1 MISO -#define SD_MOSI_PIN EXP2_05_PIN // SPI1 MOSI +#define SD_SCK_PIN EXP2_02_PIN // SPI1 SCLK +#define SD_SS_PIN EXP2_04_PIN // SPI1 SSEL +#define SD_MISO_PIN EXP2_01_PIN // SPI1 MISO +#define SD_MOSI_PIN EXP2_06_PIN // SPI1 MOSI -#define SDSS EXP2_07_PIN +#define SDSS EXP2_04_PIN // // LCDs and Controllers // #if HAS_WIRED_LCD - #define BEEPER_PIN EXP1_10_PIN - #define BTN_ENC EXP1_09_PIN + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN - #define SD_DETECT_PIN EXP2_04_PIN + #define SD_DETECT_PIN EXP2_07_PIN #if ENABLED(CR10_STOCKDISPLAY) - #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_RS EXP1_07_PIN - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN - #define LCD_PINS_ENABLE EXP1_03_PIN - #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN #elif ENABLED(MKS_MINI_12864) - #define DOGLCD_A0 EXP1_04_PIN - #define DOGLCD_CS EXP1_05_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN #else - #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_RS EXP1_04_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN #if ENABLED(FYSETC_MINI_12864) - #define DOGLCD_CS EXP1_08_PIN - #define DOGLCD_A0 EXP1_07_PIN - #define DOGLCD_MOSI EXP2_05_PIN - #define DOGLCD_MISO EXP2_10_PIN - #define DOGLCD_SCK EXP2_09_PIN + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN + #define DOGLCD_MOSI EXP2_06_PIN + #define DOGLCD_MISO EXP2_01_PIN + #define DOGLCD_SCK EXP2_02_PIN #define LCD_BACKLIGHT_PIN -1 #define FORCE_SOFT_SPI - #define LCD_RESET_PIN EXP1_06_PIN // Must be high or open for LCD to operate normally. + #define LCD_RESET_PIN EXP1_05_PIN // Must be high or open for LCD to operate normally. #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) #ifndef RGB_LED_R_PIN - #define RGB_LED_R_PIN EXP1_05_PIN + #define RGB_LED_R_PIN EXP1_06_PIN #endif #ifndef RGB_LED_G_PIN - #define RGB_LED_G_PIN EXP1_04_PIN + #define RGB_LED_G_PIN EXP1_07_PIN #endif #ifndef RGB_LED_B_PIN - #define RGB_LED_B_PIN EXP1_03_PIN + #define RGB_LED_B_PIN EXP1_08_PIN #endif #elif ENABLED(FYSETC_MINI_12864_2_1) - #define NEOPIXEL_PIN EXP1_05_PIN + #define NEOPIXEL_PIN EXP1_06_PIN #endif #endif // !FYSETC_MINI_12864 #if IS_ULTIPANEL - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder diff --git a/Marlin/src/pins/stm32f4/pins_BTT_E3_RRF.h b/Marlin/src/pins/stm32f4/pins_BTT_E3_RRF.h index c7cd35c7ad..c29949e814 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_E3_RRF.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_E3_RRF.h @@ -186,11 +186,11 @@ /** * BTT E3 RRF * ------ - * (BEEPER) PE8 |10 9 | PE9 (BTN_ENC) - * (BTN_EN1) PE7 | 8 7 | RESET - * (BTN_EN2) PB2 6 5 | PE10 (LCD_D4) - * (LCD_RS) PB1 | 4 3 | PE11 (LCD_EN) - * GND | 2 1 | 5V + * (BEEPER) PE8 | 1 2 | PE9 (BTN_ENC) + * (BTN_EN1) PE7 | 3 4 | RESET + * (BTN_EN2) PB2 5 6 | PE10 (LCD_D4) + * (LCD_RS) PB1 | 7 8 | PE11 (LCD_EN) + * GND | 9 10 | 5V * ------ * EXP1 */ @@ -219,28 +219,28 @@ * * BTT E3 RRF Display Ribbon * ------ ------ - * (BEEPER) PE8 |10 9 | PE9 (BTN_ENC) GND |10 9 | 5V - * (BTN_EN1) PE7 | 8 7 | RESET BEEPER | 8 7 | ESTOP (RESET) - * (BTN_EN2) PB2 6 5 | PE10 (LCD_D4) (BTN_ENC) ENC_BTN | 6 5 | LCD_SCLK (LCD_D4) - * (LCD_RS) PB1 | 4 3 | PE11 (LCD_EN) (BTN_EN2) ENC_A | 4 3 | LCD_DATA (LCD_EN) - * GND | 2 1 | 5V (BTN_EN1) ENC_B | 2 1 | LCD_CS (LCD_RS) + * (BEEPER) PE8 | 1 2 | PE9 (BTN_ENC) GND |10 9 | 5V + * (BTN_EN1) PE7 | 3 4 | RESET BEEPER | 8 7 | ESTOP (RESET) + * (BTN_EN2) PB2 5 6 | PE10 (LCD_D4) (BTN_ENC) ENC_BTN | 6 5 | LCD_SCLK (LCD_D4) + * (LCD_RS) PB1 | 7 8 | PE11 (LCD_EN) (BTN_EN2) ENC_A | 4 3 | LCD_DATA (LCD_EN) + * GND | 9 10 | 5V (BTN_EN1) ENC_B | 2 1 | LCD_CS (LCD_RS) * ------ ------ - * EXP1 Ribbon + * EXP1 LCD * * Needs custom cable: * * Board Adapter Display Ribbon (coming from display) - * - * EXP1-1 ----------- EXP1-9 - * EXP1-2 ----------- EXP1-10 - * EXP1-3 ----------- EXP1-3 - * EXP1-4 ----------- EXP1-1 - * EXP1-5 ----------- EXP1-5 - * EXP1-6 ----------- EXP1-4 - * EXP1-7 ----------- EXP1-7 - * EXP1-8 ----------- EXP1-8 - * EXP1-9 ----------- EXP1-6 - * EXP1-10 ----------- EXP1-8 + * ---------------------------------- + * EXP1-10 ---------- LCD-9 5V + * EXP1-9 ----------- LCD-10 GND + * EXP1-8 ----------- LCD-3 LCD_EN + * EXP1-7 ----------- LCD-1 LCD_RS + * EXP1-6 ----------- LCD-5 LCD_D4 + * EXP1-5 ----------- LCD-4 EN2 + * EXP1-4 ----------- LCD-7 RESET + * EXP1-3 ----------- LCD-2 EN1 + * EXP1-2 ----------- LCD-6 BTN + * EXP1-1 ----------- LCD-8 BEEPER */ #endif @@ -286,28 +286,28 @@ * * Board Display * ------ ------ - * (SD_DET) PE8 |10 9 | PE9 (BEEPER) 5V |10 9 | GND - * (MOD_RESET) PE7 | 8 7 | RESET -- | 8 7 | (SD_DET) - * (SD_CS) PB2 6 5 | PE10 (MOSI) 6 5 | -- - * (LCD_CS) PB1 | 4 3 | PE11 (SD_CS) | 4 3 | (LCD_CS) - * GND | 2 1 | 5V (SCK) | 2 1 | (MISO) + * (SD_DET) PE8 | 1 2 | PE9 (BEEPER) 5V |10 9 | GND + * (MOD_RESET) PE7 | 3 4 | RESET -- | 8 7 | (SD_DET) + * (SD_CS) PB2 5 6 | PE10 (MOSI) 6 5 | -- + * (LCD_CS) PB1 | 7 8 | PE11 (SD_CS) | 4 3 | (LCD_CS) + * GND | 9 10 | 5V (SCK) | 2 1 | (MISO) * ------ ------ * EXP1 EXP1 * * Needs custom cable: * * Board Adapter Display - * _________ - * EXP1-1 ----------- EXP1-10 - * EXP1-2 ----------- EXP1-9 - * SPI1-4 ----------- EXP1-6 - * EXP1-4 ----------- FREE - * SPI1-3 ----------- EXP1-2 - * EXP1-6 ----------- EXP1-4 - * EXP1-7 ----------- FREE - * EXP1-8 ----------- EXP1-3 - * SPI1-1 ----------- EXP1-1 - * EXP1-10 ----------- EXP1-7 + * ---------------------------------- + * EXP1-10 ---------- EXP1-10 5V + * EXP1-9 ----------- EXP1-9 GND + * SPI1-4 ----------- EXP1-6 MOSI + * EXP1-7 ----------- n/c + * SPI1-3 ----------- EXP1-2 SCK + * EXP1-5 ----------- EXP1-4 SD_CS + * EXP1-4 ----------- n/c + * EXP1-3 ----------- EXP1-3 LCD_CS + * SPI1-1 ----------- EXP1-1 MISO + * EXP1-1 ----------- EXP1-7 SD_DET */ #define TFTGLCD_CS PE7 @@ -341,28 +341,28 @@ * * Board Display * ------ ------ - * (SD_DET) PE8 |10 9 | PE9 (BEEPER) 5V |10 9 | GND - * (MOD_RESET) PE7 | 8 7 | RESET RESET | 8 7 | (SD_DET) - * (SD_CS) PB2 6 5 | PE10 (MOSI) | 6 5 | (LCD_CS) - * (LCD_CS) PB1 | 4 3 | PE11 (SD_CS) | 4 3 | (MOD_RESET) - * GND | 2 1 | 5V (SCK) | 2 1 | (MISO) + * (SD_DET) PE8 | 1 2 | PE9 (BEEPER) 5V |10 9 | GND + * (MOD_RESET) PE7 | 3 4 | RESET RESET | 8 7 | (SD_DET) + * (SD_CS) PB2 5 6 | PE10 (MOSI) | 6 5 | (LCD_CS) + * (LCD_CS) PB1 | 7 8 | PE11 (SD_CS) | 4 3 | (MOD_RESET) + * GND | 9 10 | 5V (SCK) | 2 1 | (MISO) * ------ ------ * EXP1 EXP1 * * Needs custom cable: * * Board Adapter Display - * - * EXP1-1 ----------- EXP1-10 - * EXP1-2 ----------- EXP1-9 - * SPI1-4 ----------- EXP1-6 - * EXP1-4 ----------- EXP1-5 - * SPI1-3 ----------- EXP1-2 - * EXP1-6 ----------- EXP1-4 - * EXP1-7 ----------- EXP1-8 - * EXP1-8 ----------- EXP1-3 - * SPI1-1 ----------- EXP1-1 - * EXP1-10 ----------- EXP1-7 + * ---------------------------------- + * EXP1-10 ---------- EXP1-10 5V + * EXP1-9 ----------- EXP1-9 GND + * SPI1-4 ----------- EXP1-6 MOSI + * EXP1-7 ----------- EXP1-5 LCD_CS + * SPI1-3 ----------- EXP1-2 SCK + * EXP1-5 ----------- EXP1-4 SD_CS + * EXP1-4 ----------- EXP1-8 RESET + * EXP1-3 ----------- EXP1-3 MOD_RST + * SPI1-1 ----------- EXP1-1 MISO + * EXP1-1 ----------- EXP1-7 SD_DET */ #define CLCD_SPI_BUS 1 // SPI1 connector diff --git a/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h b/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h index b9525a9267..fe03ec8983 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h @@ -348,8 +348,8 @@ // #if SD_CONNECTION_IS(LCD) - #define SD_DETECT_PIN EXP2_04_PIN - #define SDSS EXP2_07_PIN + #define SD_DETECT_PIN EXP2_07_PIN + #define SDSS EXP2_04_PIN #elif SD_CONNECTION_IS(ONBOARD) @@ -366,112 +366,112 @@ /** * ------ ------ - * (BEEPER) PC11 |10 9 | PA15 (BTN_ENC) (MISO) PB14 |10 9 | PB13 (SCK) - * (LCD_EN) PC10 | 8 7 | PA8 (LCD_RS) (BTN_EN1) PD10 | 8 7 | PB12 (SD_SS) - * (LCD_D4) PG8 6 5 | PG7 (LCD_D5) (BTN_EN2) PH10 6 5 | PB15 (MOSI) - * (LCD_D6) PG6 | 4 3 | PG5 (LCD_D7) (SD_DETECT) PB10 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | -- + * (BEEPER) PC11 | 1 2 | PA15 (BTN_ENC) (MISO) PB14 | 1 2 | PB13 (SCK) + * (LCD_EN) PC10 | 3 4 | PA8 (LCD_RS) (BTN_EN1) PD10 | 3 4 | PB12 (SD_SS) + * (LCD_D4) PG8 5 6 | PG7 (LCD_D5) (BTN_EN2) PH10 5 6 | PB15 (MOSI) + * (LCD_D6) PG6 | 7 8 | PG5 (LCD_D7) (SD_DETECT) PB10 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN PG5 -#define EXP1_04_PIN PG6 -#define EXP1_05_PIN PG7 -#define EXP1_06_PIN PG8 -#define EXP1_07_PIN PA8 -#define EXP1_08_PIN PC10 -#define EXP1_09_PIN PA15 -#define EXP1_10_PIN PC11 - -#define EXP2_04_PIN PB10 -#define EXP2_05_PIN PB15 -#define EXP2_06_PIN PH10 -#define EXP2_07_PIN PB12 -#define EXP2_08_PIN PD10 -#define EXP2_09_PIN PB13 -#define EXP2_10_PIN PB14 +#define EXP1_01_PIN PC11 +#define EXP1_02_PIN PA15 +#define EXP1_03_PIN PC10 +#define EXP1_04_PIN PA8 +#define EXP1_05_PIN PG8 +#define EXP1_06_PIN PG7 +#define EXP1_07_PIN PG6 +#define EXP1_08_PIN PG5 + +#define EXP2_01_PIN PB14 +#define EXP2_02_PIN PB13 +#define EXP2_03_PIN PD10 +#define EXP2_04_PIN PB12 +#define EXP2_05_PIN PH10 +#define EXP2_06_PIN PB15 +#define EXP2_07_PIN PB10 // // LCDs and Controllers // #if ANY(TFT_COLOR_UI, TFT_LVGL_UI, TFT_CLASSIC_UI) - #define TFT_CS_PIN EXP2_07_PIN - #define TFT_A0_PIN EXP2_04_PIN - #define TFT_SCK_PIN EXP2_09_PIN - #define TFT_MISO_PIN EXP2_10_PIN - #define TFT_MOSI_PIN EXP2_05_PIN - - #define TOUCH_INT_PIN EXP1_04_PIN - #define TOUCH_MISO_PIN EXP1_05_PIN - #define TOUCH_MOSI_PIN EXP1_08_PIN - #define TOUCH_SCK_PIN EXP1_06_PIN - #define TOUCH_CS_PIN EXP1_07_PIN - #define BTN_ENC EXP1_09_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define TFT_CS_PIN EXP2_04_PIN + #define TFT_A0_PIN EXP2_07_PIN + #define TFT_SCK_PIN EXP2_02_PIN + #define TFT_MISO_PIN EXP2_01_PIN + #define TFT_MOSI_PIN EXP2_06_PIN + + #define TOUCH_INT_PIN EXP1_07_PIN + #define TOUCH_MISO_PIN EXP1_06_PIN + #define TOUCH_MOSI_PIN EXP1_03_PIN + #define TOUCH_SCK_PIN EXP1_05_PIN + #define TOUCH_CS_PIN EXP1_04_PIN + #define BTN_ENC EXP1_02_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN #elif HAS_WIRED_LCD - #define BEEPER_PIN EXP1_10_PIN - #define BTN_ENC EXP1_09_PIN + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN #if ENABLED(CR10_STOCKDISPLAY) - #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_RS EXP1_07_PIN - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN - #define LCD_PINS_ENABLE EXP1_03_PIN - #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN #elif ENABLED(MKS_MINI_12864) - #define DOGLCD_A0 EXP1_04_PIN - #define DOGLCD_CS EXP1_05_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN #if SD_CONNECTION_IS(ONBOARD) #define SOFTWARE_SPI #endif #else - #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_RS EXP1_04_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN #if ENABLED(FYSETC_MINI_12864) - #define DOGLCD_CS EXP1_08_PIN - #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN #if SD_CONNECTION_IS(ONBOARD) #define SOFTWARE_SPI #endif //#define LCD_BACKLIGHT_PIN -1 - #define LCD_RESET_PIN EXP1_06_PIN // Must be high or open for LCD to operate normally. + #define LCD_RESET_PIN EXP1_05_PIN // Must be high or open for LCD to operate normally. #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) #ifndef RGB_LED_R_PIN - #define RGB_LED_R_PIN EXP1_05_PIN + #define RGB_LED_R_PIN EXP1_06_PIN #endif #ifndef RGB_LED_G_PIN - #define RGB_LED_G_PIN EXP1_04_PIN + #define RGB_LED_G_PIN EXP1_07_PIN #endif #ifndef RGB_LED_B_PIN - #define RGB_LED_B_PIN EXP1_03_PIN + #define RGB_LED_B_PIN EXP1_08_PIN #endif #elif ENABLED(FYSETC_MINI_12864_2_1) - #define NEOPIXEL_PIN EXP1_05_PIN + #define NEOPIXEL_PIN EXP1_06_PIN #endif #endif // !FYSETC_MINI_12864 #if IS_ULTIPANEL - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder diff --git a/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_common.h b/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_common.h index 4255881baf..9ff9f6a475 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_common.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_common.h @@ -322,31 +322,31 @@ #endif /** ------ ------ - * (BEEPER) PE8 |10 9 | PE7 (BTN_ENC) (MISO) PA6 |10 9 | PA5 (SCK) - * (LCD_EN) PE9 | 8 7 | PE10 (LCD_RS) (BTN_EN1) PB2 | 8 7 | PA4 (SD_SS) - * (LCD_D4) PE12 6 5 | PE13 (LCD_D5) (BTN_EN2) PB1 6 5 | PA7 (MOSI) - * (LCD_D6) PE14 | 4 3 | PE15 (LCD_D7) (SD_DETECT) PC15 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | -- + * (BEEPER) PE8 | 1 2 | PE7 (BTN_ENC) (MISO) PA6 | 1 2 | PA5 (SCK) + * (LCD_EN) PE9 | 3 4 | PE10 (LCD_RS) (BTN_EN1) PB2 | 3 4 | PA4 (SD_SS) + * (LCD_D4) PE12 5 6 | PE13 (LCD_D5) (BTN_EN2) PB1 5 6 | PA7 (MOSI) + * (LCD_D6) PE14 | 7 8 | PE15 (LCD_D7) (SD_DETECT) PC15 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN PE15 -#define EXP1_04_PIN PE14 -#define EXP1_05_PIN PE13 -#define EXP1_06_PIN PE12 -#define EXP1_07_PIN PE10 -#define EXP1_08_PIN PE9 -#define EXP1_09_PIN PE7 -#define EXP1_10_PIN PE8 - -#define EXP2_03_PIN -1 -#define EXP2_04_PIN PC15 -#define EXP2_05_PIN PA7 -#define EXP2_06_PIN PB2 -#define EXP2_07_PIN PA4 -#define EXP2_08_PIN PB1 -#define EXP2_09_PIN PA5 -#define EXP2_10_PIN PA6 +#define EXP1_01_PIN PE8 +#define EXP1_02_PIN PE7 +#define EXP1_03_PIN PE9 +#define EXP1_04_PIN PE10 +#define EXP1_05_PIN PE12 +#define EXP1_06_PIN PE13 +#define EXP1_07_PIN PE14 +#define EXP1_08_PIN PE15 + +#define EXP2_01_PIN PA6 +#define EXP2_02_PIN PA5 +#define EXP2_03_PIN PB1 +#define EXP2_04_PIN PA4 +#define EXP2_05_PIN PB2 +#define EXP2_06_PIN PA7 +#define EXP2_07_PIN PC15 +#define EXP2_08_PIN -1 // // Onboard SD card @@ -376,45 +376,45 @@ #if ENABLED(BTT_MOTOR_EXPANSION) /** * ------ ------ - * M3DIAG |10 9 | M3RX M3STP |10 9 | M3DIR - * M2DIAG | 8 7 | M2RX M2STP | 8 7 | M2DIR - * M1DIAG 6 5 | M1RX M1DIR 6 5 | M1STP - * M3EN | 4 3 | M2EN M1EN | 4 3 | -- - * GND | 2 1 | -- GND | 2 1 | -- + * M3DIAG | 1 2 | M3RX M3STP | 1 2 | M3DIR + * M2DIAG | 3 4 | M2RX M2STP | 3 4 | M2DIR + * M1DIAG 5 6 | M1RX M1DIR 5 6 | M1STP + * M3EN | 7 8 | M2EN M1EN | 7 8 | -- + * GND | 9 10 | -- GND | 9 10 | -- * ------ ------ * EXP1 EXP2 */ // M1 on Driver Expansion Module - #define E4_STEP_PIN EXP2_05_PIN - #define E4_DIR_PIN EXP2_06_PIN - #define E4_ENABLE_PIN EXP2_04_PIN - #define E4_DIAG_PIN EXP1_06_PIN - #define E4_CS_PIN EXP1_05_PIN + #define E4_STEP_PIN EXP2_06_PIN + #define E4_DIR_PIN EXP2_05_PIN + #define E4_ENABLE_PIN EXP2_07_PIN + #define E4_DIAG_PIN EXP1_05_PIN + #define E4_CS_PIN EXP1_06_PIN #if HAS_TMC_UART - #define E4_SERIAL_TX_PIN EXP1_05_PIN + #define E4_SERIAL_TX_PIN EXP1_06_PIN #define E4_SERIAL_RX_PIN E4_SERIAL_TX_PIN #endif // M2 on Driver Expansion Module - #define E5_STEP_PIN EXP2_08_PIN - #define E5_DIR_PIN EXP2_07_PIN - #define E5_ENABLE_PIN EXP1_03_PIN - #define E5_DIAG_PIN EXP1_08_PIN - #define E5_CS_PIN EXP1_07_PIN + #define E5_STEP_PIN EXP2_03_PIN + #define E5_DIR_PIN EXP2_04_PIN + #define E5_ENABLE_PIN EXP1_08_PIN + #define E5_DIAG_PIN EXP1_03_PIN + #define E5_CS_PIN EXP1_04_PIN #if HAS_TMC_UART - #define E5_SERIAL_TX_PIN EXP1_07_PIN + #define E5_SERIAL_TX_PIN EXP1_04_PIN #define E5_SERIAL_RX_PIN E5_SERIAL_TX_PIN #endif // M3 on Driver Expansion Module - #define E6_STEP_PIN EXP2_10_PIN - #define E6_DIR_PIN EXP2_09_PIN - #define E6_ENABLE_PIN EXP1_04_PIN - #define E6_DIAG_PIN EXP1_10_PIN - #define E6_CS_PIN EXP1_09_PIN + #define E6_STEP_PIN EXP2_01_PIN + #define E6_DIR_PIN EXP2_02_PIN + #define E6_ENABLE_PIN EXP1_07_PIN + #define E6_DIAG_PIN EXP1_01_PIN + #define E6_CS_PIN EXP1_02_PIN #if HAS_TMC_UART - #define E6_SERIAL_TX_PIN EXP1_09_PIN + #define E6_SERIAL_TX_PIN EXP1_02_PIN #define E6_SERIAL_RX_PIN E6_SERIAL_TX_PIN #endif @@ -426,58 +426,58 @@ #if IS_TFTGLCD_PANEL #if ENABLED(TFTGLCD_PANEL_SPI) - #define TFTGLCD_CS EXP2_08_PIN + #define TFTGLCD_CS EXP2_03_PIN #endif #elif HAS_WIRED_LCD - #define BEEPER_PIN EXP1_10_PIN - #define BTN_ENC EXP1_09_PIN + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN #if ENABLED(CR10_STOCKDISPLAY) - #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_RS EXP1_07_PIN - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN - #define LCD_PINS_ENABLE EXP1_03_PIN - #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN #else - #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_RS EXP1_04_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN #if ENABLED(FYSETC_MINI_12864) - #define DOGLCD_CS EXP1_08_PIN - #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN //#define LCD_BACKLIGHT_PIN -1 - #define LCD_RESET_PIN EXP1_06_PIN // Must be high or open for LCD to operate normally. + #define LCD_RESET_PIN EXP1_05_PIN // Must be high or open for LCD to operate normally. #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) #ifndef RGB_LED_R_PIN - #define RGB_LED_R_PIN EXP1_05_PIN + #define RGB_LED_R_PIN EXP1_06_PIN #endif #ifndef RGB_LED_G_PIN - #define RGB_LED_G_PIN EXP1_04_PIN + #define RGB_LED_G_PIN EXP1_07_PIN #endif #ifndef RGB_LED_B_PIN - #define RGB_LED_B_PIN EXP1_03_PIN + #define RGB_LED_B_PIN EXP1_08_PIN #endif #elif ENABLED(FYSETC_MINI_12864_2_1) - #define NEOPIXEL_PIN EXP1_05_PIN + #define NEOPIXEL_PIN EXP1_06_PIN #endif #endif // !FYSETC_MINI_12864 #if IS_ULTIPANEL - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder @@ -496,21 +496,21 @@ #endif #if HAS_SPI_TFT - #define TFT_CS_PIN EXP2_07_PIN - #define TFT_A0_PIN EXP2_04_PIN - #define TFT_SCK_PIN EXP2_09_PIN - #define TFT_MISO_PIN EXP2_10_PIN - #define TFT_MOSI_PIN EXP2_05_PIN - - #define TOUCH_INT_PIN EXP1_04_PIN - #define TOUCH_MISO_PIN EXP1_05_PIN - #define TOUCH_MOSI_PIN EXP1_08_PIN - #define TOUCH_SCK_PIN EXP1_06_PIN - #define TOUCH_CS_PIN EXP1_07_PIN - - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN - #define BTN_ENC EXP1_09_PIN + #define TFT_CS_PIN EXP2_04_PIN + #define TFT_A0_PIN EXP2_07_PIN + #define TFT_SCK_PIN EXP2_02_PIN + #define TFT_MISO_PIN EXP2_01_PIN + #define TFT_MOSI_PIN EXP2_06_PIN + + #define TOUCH_INT_PIN EXP1_07_PIN + #define TOUCH_MISO_PIN EXP1_06_PIN + #define TOUCH_MOSI_PIN EXP1_03_PIN + #define TOUCH_SCK_PIN EXP1_05_PIN + #define TOUCH_CS_PIN EXP1_04_PIN + + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + #define BTN_ENC EXP1_02_PIN #endif // diff --git a/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h b/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h index 7c902b008c..78a137b35d 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h @@ -313,31 +313,31 @@ #endif /** ------ ------ - * (BEEPER) PG4 |10 9 | PA8 (BTN_ENC) (MISO) PB14 |10 9 | PB13 (SCK) - * (LCD_EN) PD11 | 8 7 | PD10 (LCD_RS) (BTN_EN1) PG10 | 8 7 | PB12 (SD_SS) - * (LCD_D4) PG2 6 5 | PG3 (LCD_D5) (BTN_EN2) PF11 6 5 | PB15 (MOSI) - * (LCD_D6) PG6 | 4 3 | PG7 (LCD_D7) (SD_DETECT) PF12 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | -- + * (BEEPER) PG4 | 1 2 | PA8 (BTN_ENC) (MISO) PB14 | 1 2 | PB13 (SCK) + * (LCD_EN) PD11 | 3 4 | PD10 (LCD_RS) (BTN_EN1) PG10 | 3 4 | PB12 (SD_SS) + * (LCD_D4) PG2 5 6 | PG3 (LCD_D5) (BTN_EN2) PF11 5 6 | PB15 (MOSI) + * (LCD_D6) PG6 | 7 8 | PG7 (LCD_D7) (SD_DETECT) PF12 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN PG7 -#define EXP1_04_PIN PG6 -#define EXP1_05_PIN PG3 -#define EXP1_06_PIN PG2 -#define EXP1_07_PIN PD10 -#define EXP1_08_PIN PD11 -#define EXP1_09_PIN PA8 -#define EXP1_10_PIN PG4 - -#define EXP2_03_PIN -1 -#define EXP2_04_PIN PF12 -#define EXP2_05_PIN PB15 -#define EXP2_06_PIN PF11 -#define EXP2_07_PIN PB12 -#define EXP2_08_PIN PG10 -#define EXP2_09_PIN PB13 -#define EXP2_10_PIN PB14 +#define EXP1_01_PIN PG4 +#define EXP1_02_PIN PA8 +#define EXP1_03_PIN PD11 +#define EXP1_04_PIN PD10 +#define EXP1_05_PIN PG2 +#define EXP1_06_PIN PG3 +#define EXP1_07_PIN PG6 +#define EXP1_08_PIN PG7 + +#define EXP2_01_PIN PB14 +#define EXP2_02_PIN PB13 +#define EXP2_03_PIN PG10 +#define EXP2_04_PIN PB12 +#define EXP2_05_PIN PF11 +#define EXP2_06_PIN PB15 +#define EXP2_07_PIN PF12 +#define EXP2_08_PIN -1 // // Onboard SD card @@ -345,8 +345,8 @@ // #if SD_CONNECTION_IS(LCD) - #define SD_DETECT_PIN EXP2_04_PIN - #define SDSS EXP2_07_PIN + #define SD_DETECT_PIN EXP2_07_PIN + #define SDSS EXP2_04_PIN #elif SD_CONNECTION_IS(ONBOARD) @@ -379,46 +379,46 @@ */ // M1 on Driver Expansion Module - #define E3_STEP_PIN EXP2_05_PIN - #define E3_DIR_PIN EXP2_06_PIN - #define E3_ENABLE_PIN EXP2_04_PIN + #define E3_STEP_PIN EXP2_06_PIN + #define E3_DIR_PIN EXP2_05_PIN + #define E3_ENABLE_PIN EXP2_07_PIN #if !EXP_MOT_USE_EXP2_ONLY - #define E3_DIAG_PIN EXP1_06_PIN - #define E3_CS_PIN EXP1_05_PIN + #define E3_DIAG_PIN EXP1_05_PIN + #define E3_CS_PIN EXP1_06_PIN #if HAS_TMC_UART - #define E3_SERIAL_TX_PIN EXP1_05_PIN - #define E3_SERIAL_RX_PIN EXP1_05_PIN + #define E3_SERIAL_TX_PIN EXP1_06_PIN + #define E3_SERIAL_RX_PIN EXP1_06_PIN #endif #endif // M2 on Driver Expansion Module - #define E4_STEP_PIN EXP2_08_PIN - #define E4_DIR_PIN EXP2_07_PIN + #define E4_STEP_PIN EXP2_03_PIN + #define E4_DIR_PIN EXP2_04_PIN #if !EXP_MOT_USE_EXP2_ONLY - #define E4_ENABLE_PIN EXP1_03_PIN - #define E4_DIAG_PIN EXP1_08_PIN - #define E4_CS_PIN EXP1_07_PIN + #define E4_ENABLE_PIN EXP1_08_PIN + #define E4_DIAG_PIN EXP1_03_PIN + #define E4_CS_PIN EXP1_04_PIN #if HAS_TMC_UART - #define E4_SERIAL_TX_PIN EXP1_07_PIN - #define E4_SERIAL_RX_PIN EXP1_07_PIN + #define E4_SERIAL_TX_PIN EXP1_04_PIN + #define E4_SERIAL_RX_PIN EXP1_04_PIN #endif #else - #define E4_ENABLE_PIN EXP2_04_PIN + #define E4_ENABLE_PIN EXP2_07_PIN #endif // M3 on Driver Expansion Module - #define E5_STEP_PIN EXP2_10_PIN - #define E5_DIR_PIN EXP2_09_PIN + #define E5_STEP_PIN EXP2_01_PIN + #define E5_DIR_PIN EXP2_02_PIN #if !EXP_MOT_USE_EXP2_ONLY - #define E5_ENABLE_PIN EXP1_04_PIN - #define E5_DIAG_PIN EXP1_10_PIN - #define E5_CS_PIN EXP1_09_PIN + #define E5_ENABLE_PIN EXP1_07_PIN + #define E5_DIAG_PIN EXP1_01_PIN + #define E5_CS_PIN EXP1_02_PIN #if HAS_TMC_UART - #define E5_SERIAL_TX_PIN EXP1_09_PIN - #define E5_SERIAL_RX_PIN EXP1_09_PIN + #define E5_SERIAL_TX_PIN EXP1_02_PIN + #define E5_SERIAL_RX_PIN EXP1_02_PIN #endif #else - #define E5_ENABLE_PIN EXP2_04_PIN + #define E5_ENABLE_PIN EXP2_07_PIN #endif #endif // BTT_MOTOR_EXPANSION @@ -429,30 +429,30 @@ #if IS_TFTGLCD_PANEL #if ENABLED(TFTGLCD_PANEL_SPI) - #define TFTGLCD_CS EXP2_08_PIN + #define TFTGLCD_CS EXP2_03_PIN #endif #elif HAS_WIRED_LCD - #define BEEPER_PIN EXP1_10_PIN - #define BTN_ENC EXP1_09_PIN + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN #if ENABLED(CR10_STOCKDISPLAY) - #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_RS EXP1_07_PIN - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN - #define LCD_PINS_ENABLE EXP1_03_PIN - #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN #elif ENABLED(MKS_MINI_12864) - #define DOGLCD_A0 EXP1_04_PIN - #define DOGLCD_CS EXP1_05_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN #elif ENABLED(WYH_L12864) @@ -470,59 +470,59 @@ * * BEFORE AFTER * ------ ------ - * -- |10 9 | MOSI -- |10 9 | MOSI - * BTN_ENC | 8 7 | SCK BTN_ENC | 8 7 | SCK - * BTN_EN1 | 6 5 SID BTN_EN1 | 6 5 SID - * BTN_EN2 | 4 3 | CS BTN_EN2 | 4 3 | CS - * 5V | 2 1 | GND GND | 2 1 | 5V + * -- | 1 2 | MOSI -- | 1 2 | MOSI + * BTN_ENC | 3 4 | SCK BTN_ENC | 3 4 | SCK + * BTN_EN1 | 5 6 SID BTN_EN1 | 5 6 SID + * BTN_EN2 | 7 8 | CS BTN_EN2 | 7 8 | CS + * 5V | 9 10 | GND GND | 9 10 | 5V * ------ ------ * LCD LCD */ #undef BEEPER_PIN #undef BTN_ENC - #define BTN_EN1 EXP1_06_PIN - #define BTN_EN2 EXP1_04_PIN - #define BTN_ENC EXP1_08_PIN - #define DOGLCD_CS EXP1_03_PIN - #define DOGLCD_A0 EXP1_05_PIN - #define DOGLCD_SCK EXP1_07_PIN - #define DOGLCD_MOSI EXP1_09_PIN + #define BTN_EN1 EXP1_05_PIN + #define BTN_EN2 EXP1_07_PIN + #define BTN_ENC EXP1_03_PIN + #define DOGLCD_CS EXP1_08_PIN + #define DOGLCD_A0 EXP1_06_PIN + #define DOGLCD_SCK EXP1_04_PIN + #define DOGLCD_MOSI EXP1_02_PIN #define LCD_BACKLIGHT_PIN -1 #else - #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_RS EXP1_04_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN #if ENABLED(FYSETC_MINI_12864) - #define DOGLCD_CS EXP1_08_PIN - #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN //#define LCD_BACKLIGHT_PIN -1 - #define LCD_RESET_PIN EXP1_06_PIN // Must be high or open for LCD to operate normally. + #define LCD_RESET_PIN EXP1_05_PIN // Must be high or open for LCD to operate normally. #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) #ifndef RGB_LED_R_PIN - #define RGB_LED_R_PIN EXP1_05_PIN + #define RGB_LED_R_PIN EXP1_06_PIN #endif #ifndef RGB_LED_G_PIN - #define RGB_LED_G_PIN EXP1_04_PIN + #define RGB_LED_G_PIN EXP1_07_PIN #endif #ifndef RGB_LED_B_PIN - #define RGB_LED_B_PIN EXP1_03_PIN + #define RGB_LED_B_PIN EXP1_08_PIN #endif #elif ENABLED(FYSETC_MINI_12864_2_1) - #define NEOPIXEL_PIN EXP1_05_PIN + #define NEOPIXEL_PIN EXP1_06_PIN #endif #endif // !FYSETC_MINI_12864 #if IS_ULTIPANEL - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder diff --git a/Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0_common.h b/Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0_common.h index 4e311d4862..7ac9156f40 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0_common.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0_common.h @@ -336,43 +336,43 @@ /** * ------ ------ - * (BEEPER) PC5 |10 9 | PB0 (BTN_ENC) (MISO) PA6 |10 9 | PA5 (SCK) - * (LCD_EN) PB1 | 8 7 | PE9 (LCD_RS) (BTN_EN1) PE7 | 8 7 | PA4 (SD_SS) - * (LCD_D4) PE10 | 6 5 PE11 (LCD_D5) (BTN_EN2) PB2 | 6 5 PA7 (MOSI) - * (LCD_D6) PE12 | 4 3 | PE13 (LCD_D7) (SD_DETECT) PC4 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | -- + * (BEEPER) PC5 | 1 2 | PB0 (BTN_ENC) (MISO) PA6 | 1 2 | PA5 (SCK) + * (LCD_EN) PB1 | 3 4 | PE9 (LCD_RS) (BTN_EN1) PE7 | 3 4 | PA4 (SD_SS) + * (LCD_D4) PE10 | 5 6 PE11 (LCD_D5) (BTN_EN2) PB2 | 5 6 PA7 (MOSI) + * (LCD_D6) PE12 | 7 8 | PE13 (LCD_D7) (SD_DETECT) PC4 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN PE13 -#define EXP1_04_PIN PE12 -#define EXP1_05_PIN PE11 -#define EXP1_06_PIN PE10 -#define EXP1_07_PIN PE9 -#define EXP1_08_PIN PB1 -#define EXP1_09_PIN PB0 -#define EXP1_10_PIN PC5 - -#define EXP2_03_PIN -1 -#define EXP2_04_PIN PC4 -#define EXP2_05_PIN PA7 -#define EXP2_06_PIN PB2 -#define EXP2_07_PIN PA4 -#define EXP2_08_PIN PE7 -#define EXP2_09_PIN PA5 -#define EXP2_10_PIN PA6 +#define EXP1_01_PIN PC5 +#define EXP1_02_PIN PB0 +#define EXP1_03_PIN PB1 +#define EXP1_04_PIN PE9 +#define EXP1_05_PIN PE10 +#define EXP1_06_PIN PE11 +#define EXP1_07_PIN PE12 +#define EXP1_08_PIN PE13 + +#define EXP2_01_PIN PA6 +#define EXP2_02_PIN PA5 +#define EXP2_03_PIN PE7 +#define EXP2_04_PIN PA4 +#define EXP2_05_PIN PB2 +#define EXP2_06_PIN PA7 +#define EXP2_07_PIN PC4 +#define EXP2_08_PIN -1 // // Onboard SD card // Must use soft SPI because Marlin's default hardware SPI is tied to LCD's EXP2 // #if SD_CONNECTION_IS(LCD) - #define SDSS EXP2_07_PIN + #define SDSS EXP2_04_PIN #define SD_SS_PIN SDSS - #define SD_SCK_PIN EXP2_09_PIN - #define SD_MISO_PIN EXP2_10_PIN - #define SD_MOSI_PIN EXP2_05_PIN - #define SD_DETECT_PIN EXP2_04_PIN + #define SD_SCK_PIN EXP2_02_PIN + #define SD_MISO_PIN EXP2_01_PIN + #define SD_MOSI_PIN EXP2_06_PIN + #define SD_DETECT_PIN EXP2_07_PIN #elif SD_CONNECTION_IS(ONBOARD) #define SDIO_SUPPORT // Use SDIO for onboard SD #elif SD_CONNECTION_IS(CUSTOM_CABLE) @@ -393,46 +393,46 @@ */ // M1 on Driver Expansion Module - #define E2_STEP_PIN EXP2_05_PIN - #define E2_DIR_PIN EXP2_06_PIN - #define E2_ENABLE_PIN EXP2_04_PIN + #define E2_STEP_PIN EXP2_06_PIN + #define E2_DIR_PIN EXP2_05_PIN + #define E2_ENABLE_PIN EXP2_07_PIN #if !EXP_MOT_USE_EXP2_ONLY - #define E2_DIAG_PIN EXP1_06_PIN - #define E2_CS_PIN EXP1_05_PIN + #define E2_DIAG_PIN EXP1_05_PIN + #define E2_CS_PIN EXP1_06_PIN #if HAS_TMC_UART - #define E2_SERIAL_TX_PIN EXP1_05_PIN - #define E2_SERIAL_RX_PIN EXP1_05_PIN + #define E2_SERIAL_TX_PIN EXP1_06_PIN + #define E2_SERIAL_RX_PIN EXP1_06_PIN #endif #endif // M2 on Driver Expansion Module - #define E3_STEP_PIN EXP2_08_PIN - #define E3_DIR_PIN EXP2_07_PIN + #define E3_STEP_PIN EXP2_03_PIN + #define E3_DIR_PIN EXP2_04_PIN #if !EXP_MOT_USE_EXP2_ONLY - #define E3_ENABLE_PIN EXP1_03_PIN - #define E3_DIAG_PIN EXP1_08_PIN - #define E3_CS_PIN EXP1_07_PIN + #define E3_ENABLE_PIN EXP1_08_PIN + #define E3_DIAG_PIN EXP1_03_PIN + #define E3_CS_PIN EXP1_04_PIN #if HAS_TMC_UART - #define E3_SERIAL_TX_PIN EXP1_07_PIN - #define E3_SERIAL_RX_PIN EXP1_07_PIN + #define E3_SERIAL_TX_PIN EXP1_04_PIN + #define E3_SERIAL_RX_PIN EXP1_04_PIN #endif #else - #define E3_ENABLE_PIN EXP2_04_PIN + #define E3_ENABLE_PIN EXP2_07_PIN #endif // M3 on Driver Expansion Module - #define E4_STEP_PIN EXP2_10_PIN - #define E4_DIR_PIN EXP2_09_PIN + #define E4_STEP_PIN EXP2_01_PIN + #define E4_DIR_PIN EXP2_02_PIN #if !EXP_MOT_USE_EXP2_ONLY - #define E4_ENABLE_PIN EXP1_04_PIN - #define E4_DIAG_PIN EXP1_10_PIN - #define E4_CS_PIN EXP1_09_PIN + #define E4_ENABLE_PIN EXP1_07_PIN + #define E4_DIAG_PIN EXP1_01_PIN + #define E4_CS_PIN EXP1_02_PIN #if HAS_TMC_UART - #define E4_SERIAL_TX_PIN EXP1_09_PIN - #define E4_SERIAL_RX_PIN EXP1_09_PIN + #define E4_SERIAL_TX_PIN EXP1_02_PIN + #define E4_SERIAL_RX_PIN EXP1_02_PIN #endif #else - #define E4_ENABLE_PIN EXP2_04_PIN + #define E4_ENABLE_PIN EXP2_07_PIN #endif #endif // BTT_MOTOR_EXPANSION @@ -443,65 +443,65 @@ #if IS_TFTGLCD_PANEL #if ENABLED(TFTGLCD_PANEL_SPI) - #define TFTGLCD_CS EXP2_08_PIN + #define TFTGLCD_CS EXP2_03_PIN #endif #elif HAS_WIRED_LCD - #define BEEPER_PIN EXP1_10_PIN - #define BTN_ENC EXP1_09_PIN + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN #if ENABLED(CR10_STOCKDISPLAY) - #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_RS EXP1_07_PIN - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN - #define LCD_PINS_ENABLE EXP1_03_PIN - #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN #elif ENABLED(MKS_MINI_12864) - #define DOGLCD_A0 EXP1_04_PIN - #define DOGLCD_CS EXP1_05_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN #else - #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_RS EXP1_04_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN #if ENABLED(FYSETC_MINI_12864) - #define DOGLCD_CS EXP1_08_PIN - #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN //#define LCD_BACKLIGHT_PIN -1 - #define LCD_RESET_PIN EXP1_06_PIN // Must be high or open for LCD to operate normally. + #define LCD_RESET_PIN EXP1_05_PIN // Must be high or open for LCD to operate normally. #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) #ifndef RGB_LED_R_PIN - #define RGB_LED_R_PIN EXP1_05_PIN + #define RGB_LED_R_PIN EXP1_06_PIN #endif #ifndef RGB_LED_G_PIN - #define RGB_LED_G_PIN EXP1_04_PIN + #define RGB_LED_G_PIN EXP1_07_PIN #endif #ifndef RGB_LED_B_PIN - #define RGB_LED_B_PIN EXP1_03_PIN + #define RGB_LED_B_PIN EXP1_08_PIN #endif #elif ENABLED(FYSETC_MINI_12864_2_1) - #define NEOPIXEL_PIN EXP1_05_PIN + #define NEOPIXEL_PIN EXP1_06_PIN #endif #endif // !FYSETC_MINI_12864 #if IS_ULTIPANEL - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder @@ -528,24 +528,24 @@ #if HAS_SPI_TFT - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN - #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + #define BTN_ENC EXP1_02_PIN // // e.g., BTT_TFT35_SPI_V1_0 (480x320, 3.5", SPI Stock Display with Rotary Encoder in BIQU B1 SE) // - #define TFT_CS_PIN EXP2_07_PIN - #define TFT_A0_PIN EXP2_04_PIN - #define TFT_SCK_PIN EXP2_09_PIN - #define TFT_MISO_PIN EXP2_10_PIN - #define TFT_MOSI_PIN EXP2_05_PIN - - #define TOUCH_INT_PIN EXP1_04_PIN - #define TOUCH_MISO_PIN EXP1_05_PIN - #define TOUCH_MOSI_PIN EXP1_08_PIN - #define TOUCH_SCK_PIN EXP1_06_PIN - #define TOUCH_CS_PIN EXP1_07_PIN + #define TFT_CS_PIN EXP2_04_PIN + #define TFT_A0_PIN EXP2_07_PIN + #define TFT_SCK_PIN EXP2_02_PIN + #define TFT_MISO_PIN EXP2_01_PIN + #define TFT_MOSI_PIN EXP2_06_PIN + + #define TOUCH_INT_PIN EXP1_07_PIN + #define TOUCH_MISO_PIN EXP1_06_PIN + #define TOUCH_MOSI_PIN EXP1_03_PIN + #define TOUCH_SCK_PIN EXP1_05_PIN + #define TOUCH_CS_PIN EXP1_04_PIN #endif diff --git a/Marlin/src/pins/stm32f4/pins_FLYF407ZG.h b/Marlin/src/pins/stm32f4/pins_FLYF407ZG.h index 11b5dbbb6c..8d5e094122 100644 --- a/Marlin/src/pins/stm32f4/pins_FLYF407ZG.h +++ b/Marlin/src/pins/stm32f4/pins_FLYF407ZG.h @@ -177,31 +177,31 @@ /** * ------ ------ - * PB10 |10 9 | PE15 PB14 |10 9 | PB13 - * PE14 | 8 7 | PE12 PC5 | 8 7 | PF11 - * PE10 6 5 | PE9 PC4 6 5 | PB15 - * PE8 | 4 3 | PE7 PB2 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | -- + * PB10 | 1 2 | PE15 PB14 | 1 2 | PB13 + * PE14 | 3 4 | PE12 PC5 | 3 4 | PF11 + * PE10 5 6 | PE9 PC4 5 6 | PB15 + * PE8 | 7 8 | PE7 PB2 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN PE7 -#define EXP1_04_PIN PE8 -#define EXP1_05_PIN PE9 -#define EXP1_06_PIN PE10 -#define EXP1_07_PIN PE12 -#define EXP1_08_PIN PE14 -#define EXP1_09_PIN PE15 -#define EXP1_10_PIN PB10 - -#define EXP2_03_PIN -1 // RESET -#define EXP2_04_PIN PB2 -#define EXP2_05_PIN PB15 -#define EXP2_06_PIN PC4 -#define EXP2_07_PIN PF11 -#define EXP2_08_PIN PC5 -#define EXP2_09_PIN PB13 -#define EXP2_10_PIN PB14 +#define EXP1_01_PIN PB10 +#define EXP1_02_PIN PE15 +#define EXP1_03_PIN PE14 +#define EXP1_04_PIN PE12 +#define EXP1_05_PIN PE10 +#define EXP1_06_PIN PE9 +#define EXP1_07_PIN PE8 +#define EXP1_08_PIN PE7 + +#define EXP2_01_PIN PB14 +#define EXP2_02_PIN PB13 +#define EXP2_03_PIN PC5 +#define EXP2_04_PIN PF11 +#define EXP2_05_PIN PC4 +#define EXP2_06_PIN PB15 +#define EXP2_07_PIN PB2 +#define EXP2_08_PIN -1 // RESET // // Onboard SD support @@ -226,11 +226,11 @@ #elif SD_CONNECTION_IS(LCD) - #define SD_SCK_PIN EXP2_09_PIN - #define SD_MISO_PIN EXP2_10_PIN - #define SD_MOSI_PIN EXP2_05_PIN - #define SDSS EXP2_07_PIN - #define SD_DETECT_PIN EXP2_04_PIN + #define SD_SCK_PIN EXP2_02_PIN + #define SD_MISO_PIN EXP2_01_PIN + #define SD_MOSI_PIN EXP2_06_PIN + #define SDSS EXP2_04_PIN + #define SD_DETECT_PIN EXP2_07_PIN #endif @@ -239,13 +239,13 @@ // #if ENABLED(TMC_USE_SW_SPI) #ifndef TMC_SW_SCK - #define TMC_SW_SCK EXP2_09_PIN + #define TMC_SW_SCK EXP2_02_PIN #endif #ifndef TMC_SW_MISO - #define TMC_SW_MISO EXP2_10_PIN + #define TMC_SW_MISO EXP2_01_PIN #endif #ifndef TMC_SW_MOSI - #define TMC_SW_MOSI EXP2_05_PIN + #define TMC_SW_MOSI EXP2_06_PIN #endif #endif @@ -286,16 +286,16 @@ // LCD / Controller // #if IS_RRD_SC - #define BEEPER_PIN EXP1_10_PIN - #define LCD_PINS_RS EXP1_07_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN - #define BTN_EN1 EXP2_06_PIN - #define BTN_EN2 EXP2_08_PIN - #define BTN_ENC EXP1_09_PIN + #define BEEPER_PIN EXP1_01_PIN + #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN + #define BTN_EN1 EXP2_05_PIN + #define BTN_EN2 EXP2_03_PIN + #define BTN_ENC EXP1_02_PIN #endif // diff --git a/Marlin/src/pins/stm32f4/pins_FYSETC_CHEETAH_V20.h b/Marlin/src/pins/stm32f4/pins_FYSETC_CHEETAH_V20.h index 29aff20ffd..32ec518bf8 100644 --- a/Marlin/src/pins/stm32f4/pins_FYSETC_CHEETAH_V20.h +++ b/Marlin/src/pins/stm32f4/pins_FYSETC_CHEETAH_V20.h @@ -140,100 +140,100 @@ /** * ------ ------ - * (SD_MISO) PA6 |10 9 | PA5 (SD_SCK) (BEEPER) PC9 |10 9 | PC12 (BTN_ENC) - * (BTN_EN1) PC10 | 8 7 | PA4 (SD_SS) (LCD_EN) PB15 | 8 7 | PB12 (LCD_RS) - * (BTN_EN2) PC11 6 5 | PA7 (SD_MOSI) (LCD_D4) PB13 6 5 | PB14 (LCD_D5) - * (SD_DETECT) PC3 | 4 3 | RESET (LCD_D6) PB6 | 4 3 | PB7 (LCD_D7) - * GND | 2 1 | 5V GND | 2 1 | 5V + * (SD_MISO) PA6 | 1 2 | PA5 (SD_SCK) (BEEPER) PC9 | 1 2 | PC12 (BTN_ENC) + * (BTN_EN1) PC10 | 3 4 | PA4 (SD_SS) (LCD_EN) PB15 | 3 4 | PB12 (LCD_RS) + * (BTN_EN2) PC11 5 6 | PA7 (SD_MOSI) (LCD_D4) PB13 5 6 | PB14 (LCD_D5) + * (SD_DETECT) PC3 | 7 8 | RESET (LCD_D6) PB6 | 7 8 | PB7 (LCD_D7) + * GND | 9 10 | 5V GND | 9 10 | 5V * ------ ------ * EXP2 EXP1 */ /** * ------ - * 5V |10 9 | GND - * (LCD_EN/MOSI) PB15 | 8 7 | PB12 (LCD_RS) - * (LCD_D4/SCK) PB13 6 5 | PC11 (BTN_EN2) - * (LCD_D5/MISO) PB14 | 4 3 | PC10 (BTN_EN1) - * (BTN_ENC) PC12 | 2 1 | PC9 (BEEPER) + * 5V | 1 2 | GND + * (LCD_EN/MOSI) PB15 | 3 4 | PB12 (LCD_RS) + * (LCD_D4/SCK) PB13 5 6 | PC11 (BTN_EN2) + * (LCD_D5/MISO) PB14 | 7 8 | PC10 (BTN_EN1) + * (BTN_ENC) PC12 | 9 10 | PC9 (BEEPER) * ------ * EXP3 */ -#define EXP1_03_PIN PB7 -#define EXP1_04_PIN PB6 -#define EXP1_05_PIN PB14 -#define EXP1_06_PIN PB13 -#define EXP1_07_PIN PB12 -#define EXP1_08_PIN PB15 -#define EXP1_09_PIN PC12 -#define EXP1_10_PIN PC9 - -#define EXP2_03_PIN -1 -#define EXP2_04_PIN PC3 -#define EXP2_05_PIN PA7 -#define EXP2_06_PIN PC11 -#define EXP2_07_PIN PA4 -#define EXP2_08_PIN PC10 -#define EXP2_09_PIN PA5 -#define EXP2_10_PIN PA6 +#define EXP1_01_PIN PC9 +#define EXP1_02_PIN PC12 +#define EXP1_03_PIN PB15 +#define EXP1_04_PIN PB12 +#define EXP1_05_PIN PB13 +#define EXP1_06_PIN PB14 +#define EXP1_07_PIN PB6 +#define EXP1_08_PIN PB7 + +#define EXP2_01_PIN PA6 +#define EXP2_02_PIN PA5 +#define EXP2_03_PIN PC10 +#define EXP2_04_PIN PA4 +#define EXP2_05_PIN PC11 +#define EXP2_06_PIN PA7 +#define EXP2_07_PIN PC3 +#define EXP2_08_PIN -1 #if HAS_WIRED_LCD - #define BEEPER_PIN EXP1_10_PIN - #define BTN_ENC EXP1_09_PIN + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN #if ENABLED(CR10_STOCKDISPLAY) - #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_RS EXP1_04_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN #elif ENABLED(MKS_MINI_12864) - #define DOGLCD_A0 EXP1_04_PIN - #define DOGLCD_CS EXP1_05_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN #else - #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_RS EXP1_04_PIN - #define BTN_EN1 EXP2_06_PIN - #define BTN_EN2 EXP2_08_PIN + #define BTN_EN1 EXP2_05_PIN + #define BTN_EN2 EXP2_03_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN #if ENABLED(FYSETC_MINI_12864) - #define DOGLCD_CS EXP1_08_PIN - #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN //#define LCD_BACKLIGHT_PIN -1 - #define LCD_RESET_PIN EXP1_06_PIN // Must be high or open for LCD to operate normally. + #define LCD_RESET_PIN EXP1_05_PIN // Must be high or open for LCD to operate normally. #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) #ifndef RGB_LED_R_PIN - #define RGB_LED_R_PIN EXP1_05_PIN + #define RGB_LED_R_PIN EXP1_06_PIN #endif #ifndef RGB_LED_G_PIN - #define RGB_LED_G_PIN EXP1_04_PIN + #define RGB_LED_G_PIN EXP1_07_PIN #endif #ifndef RGB_LED_B_PIN - #define RGB_LED_B_PIN EXP1_03_PIN + #define RGB_LED_B_PIN EXP1_08_PIN #endif #elif ENABLED(FYSETC_MINI_12864_2_1) - #define NEOPIXEL_PIN EXP1_05_PIN + #define NEOPIXEL_PIN EXP1_06_PIN #endif #endif // !FYSETC_MINI_12864 #if IS_ULTIPANEL - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder @@ -253,7 +253,7 @@ #endif #if ENABLED(TOUCH_UI_FTDI_EVE) - #define BEEPER_PIN EXP1_10_PIN - #define CLCD_MOD_RESET EXP2_08_PIN - #define CLCD_SPI_CS EXP2_06_PIN + #define BEEPER_PIN EXP1_01_PIN + #define CLCD_MOD_RESET EXP2_03_PIN + #define CLCD_SPI_CS EXP2_05_PIN #endif diff --git a/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h b/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h index 3ed18f9abc..fca181c1f4 100644 --- a/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h +++ b/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h @@ -199,117 +199,117 @@ /** * ------ ------ - * PC9 |10 9 | PA8 PA6 |10 9 | PA5 - * PC11 | 8 7 | PD2 PC6 | 8 7 | PA4 - * PC10 6 5 | PC12 PC7 6 5 | PA7 - * PD0 | 4 3 | PD1 PB10 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | 5V + * PC9 | 1 2 | PA8 PA6 | 1 2 | PA5 + * PC11 | 3 4 | PD2 PC6 | 3 4 | PA4 + * PC10 5 6 | PC12 PC7 5 6 | PA7 + * PD0 | 7 8 | PD1 PB10 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | 5V * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN PD1 -#define EXP1_04_PIN PD0 -#define EXP1_05_PIN PC12 -#define EXP1_06_PIN PC10 -#define EXP1_07_PIN PD2 -#define EXP1_08_PIN PC11 -#define EXP1_09_PIN PA8 -#define EXP1_10_PIN PC9 - -#define EXP2_03_PIN -1 // RESET -#define EXP2_04_PIN PB10 -#define EXP2_05_PIN PA7 -#define EXP2_06_PIN PC7 -#define EXP2_07_PIN PA4 -#define EXP2_08_PIN PC6 -#define EXP2_09_PIN PA5 -#define EXP2_10_PIN PA6 +#define EXP1_01_PIN PC9 +#define EXP1_02_PIN PA8 +#define EXP1_03_PIN PC11 +#define EXP1_04_PIN PD2 +#define EXP1_05_PIN PC10 +#define EXP1_06_PIN PC12 +#define EXP1_07_PIN PD0 +#define EXP1_08_PIN PD1 + +#define EXP2_01_PIN PA6 +#define EXP2_02_PIN PA5 +#define EXP2_03_PIN PC6 +#define EXP2_04_PIN PA4 +#define EXP2_05_PIN PC7 +#define EXP2_06_PIN PA7 +#define EXP2_07_PIN PB10 +#define EXP2_08_PIN -1 // RESET // // SPI / SD Card // -#define SD_SCK_PIN EXP2_09_PIN -#define SD_MISO_PIN EXP2_10_PIN -#define SD_MOSI_PIN EXP2_05_PIN +#define SD_SCK_PIN EXP2_02_PIN +#define SD_MISO_PIN EXP2_01_PIN +#define SD_MOSI_PIN EXP2_06_PIN -#define SDSS EXP2_07_PIN -#define SD_DETECT_PIN EXP2_04_PIN +#define SDSS EXP2_04_PIN +#define SD_DETECT_PIN EXP2_07_PIN // // LCD / Controller // #if ENABLED(FYSETC_242_OLED_12864) - #define BTN_EN1 EXP1_10_PIN - #define BTN_EN2 EXP1_03_PIN - #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 EXP1_01_PIN + #define BTN_EN2 EXP1_08_PIN + #define BTN_ENC EXP1_02_PIN - #define BEEPER_PIN EXP2_08_PIN + #define BEEPER_PIN EXP2_03_PIN - #define LCD_PINS_DC EXP1_05_PIN - #define LCD_PINS_RS EXP2_06_PIN // LCD_RST - #define DOGLCD_CS EXP1_07_PIN - #define DOGLCD_MOSI EXP1_06_PIN - #define DOGLCD_SCK EXP1_08_PIN + #define LCD_PINS_DC EXP1_06_PIN + #define LCD_PINS_RS EXP2_05_PIN // LCD_RST + #define DOGLCD_CS EXP1_04_PIN + #define DOGLCD_MOSI EXP1_05_PIN + #define DOGLCD_SCK EXP1_03_PIN #define DOGLCD_A0 LCD_PINS_DC #define FORCE_SOFT_SPI #define KILL_PIN -1 // NC - #define NEOPIXEL_PIN EXP1_04_PIN + #define NEOPIXEL_PIN EXP1_07_PIN #elif HAS_WIRED_LCD - #define BEEPER_PIN EXP1_10_PIN - #define BTN_ENC EXP1_09_PIN + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN #if ENABLED(CR10_STOCKDISPLAY) - #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_RS EXP1_07_PIN - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN - #define LCD_PINS_ENABLE EXP1_03_PIN - #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN #else - #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_RS EXP1_04_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN - #define LCD_SDSS EXP2_07_PIN + #define LCD_SDSS EXP2_04_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN #if ENABLED(FYSETC_MINI_12864) // See https://wiki.fysetc.com/Mini12864_Panel - #define DOGLCD_CS EXP1_08_PIN - #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN #if ENABLED(FYSETC_GENERIC_12864_1_1) - #define LCD_BACKLIGHT_PIN EXP1_04_PIN + #define LCD_BACKLIGHT_PIN EXP1_07_PIN #endif - #define LCD_RESET_PIN EXP1_06_PIN // Must be high or open for LCD to operate normally. + #define LCD_RESET_PIN EXP1_05_PIN // Must be high or open for LCD to operate normally. #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) #ifndef RGB_LED_R_PIN - #define RGB_LED_R_PIN EXP1_05_PIN + #define RGB_LED_R_PIN EXP1_06_PIN #endif #ifndef RGB_LED_G_PIN - #define RGB_LED_G_PIN EXP1_04_PIN + #define RGB_LED_G_PIN EXP1_07_PIN #endif #ifndef RGB_LED_B_PIN - #define RGB_LED_B_PIN EXP1_03_PIN + #define RGB_LED_B_PIN EXP1_08_PIN #endif #elif ENABLED(FYSETC_MINI_12864_2_1) - #define NEOPIXEL_PIN EXP1_05_PIN + #define NEOPIXEL_PIN EXP1_06_PIN #endif #endif #if IS_ULTIPANEL - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder #endif diff --git a/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V1.h b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V1.h new file mode 100644 index 0000000000..7163625e40 --- /dev/null +++ b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V1.h @@ -0,0 +1,51 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program 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. + * + * This program 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 this program. If not, see . + * + */ +#pragma once + +#define BOARD_INFO_NAME "MKS Monster8 V1" + +// +// Limit Switches +// +#define X_MAX_PIN PA13 +#define Y_MAX_PIN PC5 + +// +// Steppers +// +#define E4_ENABLE_PIN PD14 // Driver7 + +// +// Misc. Functions +// +#define PW_DET PC5 // Y+ +#define PW_OFF PB12 // Z+ +#define MT_DET_1_PIN PW_DET +#define MT_DET_2_PIN PW_OFF +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN MT_DET_1_PIN +#endif +#ifndef FIL_RUNOUT2_PIN + #define FIL_RUNOUT2_PIN MT_DET_2_PIN +#endif + +#include "pins_MKS_MONSTER8_common.h" diff --git a/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V2.h b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V2.h new file mode 100644 index 0000000000..9c012999b3 --- /dev/null +++ b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V2.h @@ -0,0 +1,57 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program 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. + * + * This program 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 this program. If not, see . + * + */ +#pragma once + +#define BOARD_INFO_NAME "MKS Monster8 V2" + +// +// Steppers +// +#define E4_ENABLE_PIN PB6 // Driver7 + +// +// Misc. Functions +// +#define PW_DET PA13 // MT_DET +#define PW_OFF PB12 // Z+ +#define MT_DET_1_PIN PW_DET +#define MT_DET_2_PIN PW_OFF +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN MT_DET_1_PIN +#endif +#ifndef FIL_RUNOUT2_PIN + #define FIL_RUNOUT2_PIN MT_DET_2_PIN +#endif + +// +// MKS WIFI MODULE +// +//#define WIFI_SERIAL 1// USART1 +#if ENABLED(MKS_WIFI_MODULE) + #define WIFI_IO0_PIN PB14 // MKS ESP WIFI IO0 PIN + #define WIFI_IO1_PIN PB15 // MKS ESP WIFI IO1 PIN + #define WIFI_RESET_PIN PD14 // MKS ESP WIFI RESET PIN +#endif + +#define NEOPIXEL_PIN PC5 + +#include "pins_MKS_MONSTER8_common.h" diff --git a/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8.h b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_common.h similarity index 66% rename from Marlin/src/pins/stm32f4/pins_MKS_MONSTER8.h rename to Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_common.h index e55f3170d0..8a9b72225d 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_common.h @@ -30,8 +30,6 @@ #error "MKS Monster doesn't support FSMC-based TFT displays." #endif -#define BOARD_INFO_NAME "MKS Monster8 V1.x" - #define HAS_OTG_USB_HOST_SUPPORT // USB Flash Drive support #define USES_DIAG_JUMPERS @@ -54,82 +52,76 @@ #define SERVO0_PIN PA8 // Enable BLTOUCH // -// Limit Switches for diag signal +// Limit Switches for diag signals // -#define X_DIAG_PIN PA14 // Driver0 diag signal is connect to X- -#define Y_DIAG_PIN PA15 // Driver1 diag signal is connect to Y- -#define Z_DIAG_PIN PB13 // Driver2 diag signal is connect to Z- -#define E0_DIAG_PIN PA13 // Driver3 diag signal is connect to X+ -#define E1_DIAG_PIN PC5 // Driver4 diag signal is connect to Y+ -#define E2_DIAG_PIN PB12 // Driver5 diag signal is connect to Z+ -#define E3_DIAG_PIN -1 // Driver6 diag signal is not connect -#define E4_DIAG_PIN -1 // Driver7 diag signal is not connect - -// Limit Switches for endstop +#define X_DIAG_PIN PA14 // Driver0 diag signal is connected to X- +#define Y_DIAG_PIN PA15 // Driver1 diag signal is connected to Y- +#define Z_DIAG_PIN PB13 // Driver2 diag signal is connected to Z- +#define E0_DIAG_PIN PA13 // Driver3 diag signal is connected to X+ +#define E1_DIAG_PIN PC5 // Driver4 diag signal is connected to Y+ +#define E2_DIAG_PIN PB12 // Driver5 diag signal is connected to Z+ +#define E3_DIAG_PIN -1 // Driver6 diag signal is not connected +#define E4_DIAG_PIN -1 // Driver7 diag signal is not connected + +// Limit Switches for endstops #define X_MIN_PIN PA14 -#define X_MAX_PIN PA13 #define Y_MIN_PIN PA15 -#define Y_MAX_PIN PC5 #define Z_MIN_PIN PB13 #define Z_MAX_PIN PB12 // // Steppers -// Driver 0 1 2 3 4 5 6 7 -// For X Y Z E0 E1 E2 E3 E4(default pin settings) // -//Driver0 -#define X_ENABLE_PIN PC15 +#define X_ENABLE_PIN PC15 // Driver0 #define X_STEP_PIN PC14 #define X_DIR_PIN PC13 #ifndef X_CS_PIN #define X_CS_PIN PE6 #endif -//Driver1 -#define Y_ENABLE_PIN PC15 + +#define Y_ENABLE_PIN PC15 // Driver1 #define Y_STEP_PIN PE5 #define Y_DIR_PIN PE4 #ifndef Y_CS_PIN #define Y_CS_PIN PE3 #endif -//Driver2 -#define Z_ENABLE_PIN PE2 + +#define Z_ENABLE_PIN PE2 // Driver2 #define Z_STEP_PIN PE1 #define Z_DIR_PIN PE0 #ifndef Z_CS_PIN #define Z_CS_PIN PB7 #endif -//Driver3 -#define E0_ENABLE_PIN PB6 + +#define E0_ENABLE_PIN PB6 // Driver3 #define E0_STEP_PIN PB5 #define E0_DIR_PIN PB4 #ifndef E0_CS_PIN #define E0_CS_PIN PB3 #endif -//Driver4 -#define E1_ENABLE_PIN PD7 + +#define E1_ENABLE_PIN PD7 // Driver4 #define E1_STEP_PIN PD6 #define E1_DIR_PIN PD5 #ifndef E1_CS_PIN #define E1_CS_PIN PD4 #endif -//Driver5 -#define E2_ENABLE_PIN PD3 + +#define E2_ENABLE_PIN PD3 // Driver5 #define E2_STEP_PIN PD2 #define E2_DIR_PIN PD1 #ifndef E2_CS_PIN #define E2_CS_PIN PD0 #endif -//Driver6 -#define E3_ENABLE_PIN PC8 + +#define E3_ENABLE_PIN PC8 // Driver6 #define E3_STEP_PIN PC7 #define E3_DIR_PIN PC6 #ifndef E3_CS_PIN #define E3_CS_PIN PD15 #endif -//Driver7 -#define E4_ENABLE_PIN PD14 -#define E4_STEP_PIN PD13 + +#define E4_STEP_PIN PD13 // Driver7 #define E4_DIR_PIN PD12 #ifndef E4_CS_PIN #define E4_CS_PIN PD11 @@ -207,20 +199,6 @@ #define FAN1_PIN PA1 // FAN1 #define FAN2_PIN PA0 // FAN2 -// -// Misc. Functions -// -#define PW_DET PC5 // Y+ -#define PW_OFF PB12 // Z+ -#define MT_DET_1_PIN PW_DET -#define MT_DET_2_PIN PW_OFF -#ifndef FIL_RUNOUT_PIN - #define FIL_RUNOUT_PIN MT_DET_1_PIN -#endif -#ifndef FIL_RUNOUT2_PIN - #define FIL_RUNOUT2_PIN MT_DET_2_PIN -#endif - // // Power Supply Control // @@ -235,31 +213,31 @@ /** * ------ ------ - * (BEEPER) PB2 |10 9 | PE10 (BTN_ENC) (SPI1 MISO) PA6 |10 9 | PA5 (SPI1 SCK) - * (LCD_EN) PE11 | 8 7 | PD10 (LCD_RS) (BTN_EN1) PE9 | 8 7 | PA4 (SPI1 CS) - * (LCD_D4) PD9 6 5 | PD8 (LCD_D5) (BTN_EN2) PE8 6 5 | PA7 (SPI1 MOSI) - * (LCD_D6) PE15 | 4 3 | PE7 (LCD_D7) (SPI1_RS) PB11 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | 3.3V + * (BEEPER) PB2 | 1 2 | PE10 (BTN_ENC) (SPI1 MISO) PA6 | 1 2 | PA5 (SPI1 SCK) + * (LCD_EN) PE11 | 3 4 | PD10 (LCD_RS) (BTN_EN1) PE9 | 3 4 | PA4 (SPI1 CS) + * (LCD_D4) PD9 5 6 | PD8 (LCD_D5) (BTN_EN2) PE8 5 6 | PA7 (SPI1 MOSI) + * (LCD_D6) PE15 | 7 8 | PE7 (LCD_D7) (SPI1_RS) PB11 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | 3.3V * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN PE7 -#define EXP1_04_PIN PE15 -#define EXP1_05_PIN PD8 -#define EXP1_06_PIN PD9 -#define EXP1_07_PIN PD10 -#define EXP1_08_PIN PE11 -#define EXP1_09_PIN PE10 -#define EXP1_10_PIN PB2 - -#define EXP2_03_PIN -1 // RESET -#define EXP2_04_PIN PB11 -#define EXP2_05_PIN PA7 -#define EXP2_06_PIN PE8 -#define EXP2_07_PIN PA4 -#define EXP2_08_PIN PE9 -#define EXP2_09_PIN PA5 -#define EXP2_10_PIN PA6 +#define EXP1_01_PIN PB2 +#define EXP1_02_PIN PE10 +#define EXP1_03_PIN PE11 +#define EXP1_04_PIN PD10 +#define EXP1_05_PIN PD9 +#define EXP1_06_PIN PD8 +#define EXP1_07_PIN PE15 +#define EXP1_08_PIN PE7 + +#define EXP2_01_PIN PA6 +#define EXP2_02_PIN PA5 +#define EXP2_03_PIN PE9 +#define EXP2_04_PIN PA4 +#define EXP2_05_PIN PE8 +#define EXP2_06_PIN PA7 +#define EXP2_07_PIN PB11 +#define EXP2_08_PIN -1 // RESET #if ENABLED(SDSUPPORT) #ifndef SDCARD_CONNECTION @@ -275,25 +253,25 @@ #define SD_DETECT_PIN PC4 // SD_DETECT_PIN doesn't work with NO_SD_HOST_DRIVE disabled #elif SD_CONNECTION_IS(LCD) #define ENABLE_SPI1 - #define SDSS EXP2_07_PIN - #define SD_SCK_PIN EXP2_09_PIN - #define SD_MISO_PIN EXP2_10_PIN - #define SD_MOSI_PIN EXP2_05_PIN - #define SD_DETECT_PIN EXP2_04_PIN + #define SDSS EXP2_04_PIN + #define SD_SCK_PIN EXP2_02_PIN + #define SD_MISO_PIN EXP2_01_PIN + #define SD_MOSI_PIN EXP2_06_PIN + #define SD_DETECT_PIN EXP2_07_PIN #endif #endif -#if ANY(TFT_COLOR_UI, TFT_CLASSIC_UI) - #define TFT_CS_PIN EXP1_04_PIN - #define TFT_SCK_PIN EXP2_09_PIN - #define TFT_MISO_PIN EXP2_10_PIN - #define TFT_MOSI_PIN EXP2_05_PIN - #define TFT_DC_PIN EXP1_03_PIN +#if EITHER(TFT_COLOR_UI, TFT_CLASSIC_UI) + #define TFT_CS_PIN EXP1_07_PIN + #define TFT_SCK_PIN EXP2_02_PIN + #define TFT_MISO_PIN EXP2_01_PIN + #define TFT_MOSI_PIN EXP2_06_PIN + #define TFT_DC_PIN EXP1_08_PIN #define TFT_A0_PIN TFT_DC_PIN - #define TFT_RESET_PIN EXP1_07_PIN + #define TFT_RESET_PIN EXP1_04_PIN - #define LCD_BACKLIGHT_PIN EXP1_08_PIN + #define LCD_BACKLIGHT_PIN EXP1_03_PIN #define TFT_BACKLIGHT_PIN LCD_BACKLIGHT_PIN #define TOUCH_BUTTONS_HW_SPI @@ -306,10 +284,10 @@ #define TFT_HEIGHT 320 #endif - #define TOUCH_CS_PIN EXP1_06_PIN // SPI1_NSS - #define TOUCH_SCK_PIN EXP2_09_PIN // SPI1_SCK - #define TOUCH_MISO_PIN EXP2_10_PIN // SPI1_MISO - #define TOUCH_MOSI_PIN EXP2_05_PIN // SPI1_MOSI + #define TOUCH_CS_PIN EXP1_05_PIN // SPI1_NSS + #define TOUCH_SCK_PIN EXP2_02_PIN // SPI1_SCK + #define TOUCH_MISO_PIN EXP2_01_PIN // SPI1_MISO + #define TOUCH_MOSI_PIN EXP2_06_PIN // SPI1_MOSI #define LCD_READ_ID 0xD3 #define LCD_USE_DMA_SPI @@ -334,8 +312,8 @@ #elif HAS_WIRED_LCD - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_RS EXP1_04_PIN #define LCD_BACKLIGHT_PIN -1 // MKS MINI12864 and MKS LCD12864B; If using MKS LCD12864A (Need to remove RPK2 resistor) @@ -343,23 +321,23 @@ #define ENABLE_SPI1 #define FORCE_SOFT_SPI - #define DOGLCD_A0 EXP1_04_PIN - #define DOGLCD_CS EXP1_05_PIN - #define DOGLCD_SCK EXP2_09_PIN - #define DOGLCD_MOSI EXP2_05_PIN - //#define LCD_BACKLIGHT_PIN -1 - //#define LCD_RESET_PIN -1 + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_06_PIN + #define DOGLCD_SCK EXP2_02_PIN + #define DOGLCD_MOSI EXP2_06_PIN + //#define LCD_BACKLIGHT_PIN -1 + //#define LCD_RESET_PIN -1 #elif ENABLED(FYSETC_MINI_12864_2_1) - #define LCD_PINS_DC EXP1_07_PIN - #define DOGLCD_CS EXP1_08_PIN + #define LCD_PINS_DC EXP1_04_PIN + #define DOGLCD_CS EXP1_03_PIN #define DOGLCD_A0 LCD_PINS_DC #define LCD_BACKLIGHT_PIN -1 - #define LCD_RESET_PIN EXP1_06_PIN - #define NEOPIXEL_PIN EXP1_05_PIN - #define DOGLCD_MOSI EXP2_05_PIN - #define DOGLCD_SCK EXP2_09_PIN + #define LCD_RESET_PIN EXP1_05_PIN + #define NEOPIXEL_PIN EXP1_06_PIN + #define DOGLCD_MOSI EXP2_06_PIN + #define DOGLCD_SCK EXP2_02_PIN #if SD_CONNECTION_IS(ONBOARD) #define FORCE_SOFT_SPI #endif @@ -367,11 +345,11 @@ #else - #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_D4 EXP1_05_PIN #if ENABLED(ULTIPANEL) - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN #endif #define BOARD_ST7920_DELAY_1 96 @@ -383,8 +361,8 @@ #endif // HAS_WIRED_LCD #if ANY(TFT_COLOR_UI, TFT_CLASSIC_UI, HAS_WIRED_LCD) - #define BEEPER_PIN EXP1_10_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN - #define BTN_ENC EXP1_09_PIN + #define BEEPER_PIN EXP1_01_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + #define BTN_ENC EXP1_02_PIN #endif diff --git a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3_common.h b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3_common.h index 989010e47f..4ac64ae1d2 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3_common.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3_common.h @@ -236,58 +236,58 @@ /** * ------ ------ - * (BEEPER) PC5 |10 9 | PE13 (BTN_ENC) (SPI1 MISO) PA6 |10 9 | PA5 (SPI1 SCK) - * (LCD_EN) PD13 | 8 7 | PC6 (LCD_RS) (BTN_EN1) PE8 | 8 7 | PE10 (SPI1 CS) - * (LCD_D4) PE14 6 5 | PE15 (LCD_D5) (BTN_EN2) PE11 6 5 | PA7 (SPI1 MOSI) - * (LCD_D6) PD11 | 4 3 | PD10 (LCD_D7) (SPI1_RS) PE12 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | 3.3V + * (BEEPER) PC5 | 1 2 | PE13 (BTN_ENC) (SPI1 MISO) PA6 | 1 2 | PA5 (SPI1 SCK) + * (LCD_EN) PD13 | 3 4 | PC6 (LCD_RS) (BTN_EN1) PE8 | 3 4 | PE10 (SPI1 CS) + * (LCD_D4) PE14 5 6 | PE15 (LCD_D5) (BTN_EN2) PE11 5 6 | PA7 (SPI1 MOSI) + * (LCD_D6) PD11 | 7 8 | PD10 (LCD_D7) (SPI1_RS) PE12 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | 3.3V * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN PD10 -#define EXP1_04_PIN PD11 -#define EXP1_05_PIN PE15 -#define EXP1_06_PIN PE14 -#define EXP1_07_PIN PC6 -#define EXP1_08_PIN PD13 -#define EXP1_09_PIN PE13 -#define EXP1_10_PIN PC5 - -#define EXP2_03_PIN -1 // RESET -#define EXP2_04_PIN PE12 -#define EXP2_05_PIN PA7 -#define EXP2_06_PIN PE11 -#define EXP2_07_PIN PE10 -#define EXP2_08_PIN PE8 -#define EXP2_09_PIN PA5 -#define EXP2_10_PIN PA6 +#define EXP1_01_PIN PC5 +#define EXP1_02_PIN PE13 +#define EXP1_03_PIN PD13 +#define EXP1_04_PIN PC6 +#define EXP1_05_PIN PE14 +#define EXP1_06_PIN PE15 +#define EXP1_07_PIN PD11 +#define EXP1_08_PIN PD10 + +#define EXP2_01_PIN PA6 +#define EXP2_02_PIN PA5 +#define EXP2_03_PIN PE8 +#define EXP2_04_PIN PE10 +#define EXP2_05_PIN PE11 +#define EXP2_06_PIN PA7 +#define EXP2_07_PIN PE12 +#define EXP2_08_PIN -1 // RESET // // SPI SD Card // #if SD_CONNECTION_IS(LCD) #define ENABLE_SPI1 - #define SDSS EXP2_07_PIN - #define SD_SCK_PIN EXP2_09_PIN - #define SD_MISO_PIN EXP2_10_PIN - #define SD_MOSI_PIN EXP2_05_PIN - #define SD_DETECT_PIN EXP2_04_PIN + #define SDSS EXP2_04_PIN + #define SD_SCK_PIN EXP2_02_PIN + #define SD_MISO_PIN EXP2_01_PIN + #define SD_MOSI_PIN EXP2_06_PIN + #define SD_DETECT_PIN EXP2_07_PIN #endif // // LCD / Controller // #if ANY(TFT_COLOR_UI, TFT_LVGL_UI, TFT_CLASSIC_UI) - #define TFT_CS_PIN EXP1_04_PIN - #define TFT_SCK_PIN EXP2_09_PIN - #define TFT_MISO_PIN EXP2_10_PIN - #define TFT_MOSI_PIN EXP2_05_PIN - #define TFT_DC_PIN EXP1_03_PIN + #define TFT_CS_PIN EXP1_07_PIN + #define TFT_SCK_PIN EXP2_02_PIN + #define TFT_MISO_PIN EXP2_01_PIN + #define TFT_MOSI_PIN EXP2_06_PIN + #define TFT_DC_PIN EXP1_08_PIN #define TFT_A0_PIN TFT_DC_PIN - #define TFT_RESET_PIN EXP1_07_PIN + #define TFT_RESET_PIN EXP1_04_PIN - #define LCD_BACKLIGHT_PIN EXP1_08_PIN + #define LCD_BACKLIGHT_PIN EXP1_03_PIN #define TFT_BACKLIGHT_PIN LCD_BACKLIGHT_PIN #define TOUCH_BUTTONS_HW_SPI @@ -300,10 +300,10 @@ #define TFT_HEIGHT 320 #endif - #define TOUCH_CS_PIN EXP1_06_PIN // SPI1_NSS - #define TOUCH_SCK_PIN EXP2_09_PIN // SPI1_SCK - #define TOUCH_MISO_PIN EXP2_10_PIN // SPI1_MISO - #define TOUCH_MOSI_PIN EXP2_05_PIN // SPI1_MOSI + #define TOUCH_CS_PIN EXP1_05_PIN // SPI1_NSS + #define TOUCH_SCK_PIN EXP2_02_PIN // SPI1_SCK + #define TOUCH_MISO_PIN EXP2_01_PIN // SPI1_MISO + #define TOUCH_MOSI_PIN EXP2_06_PIN // SPI1_MOSI #define LCD_READ_ID 0xD3 #define LCD_USE_DMA_SPI @@ -328,32 +328,32 @@ #elif HAS_WIRED_LCD - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_RS EXP1_04_PIN #define LCD_BACKLIGHT_PIN -1 // MKS MINI12864 and MKS LCD12864B; If using MKS LCD12864A (Need to remove RPK2 resistor) #if ENABLED(MKS_MINI_12864) //#define LCD_BACKLIGHT_PIN -1 //#define LCD_RESET_PIN -1 - #define DOGLCD_A0 EXP1_04_PIN - #define DOGLCD_CS EXP1_05_PIN - //#define DOGLCD_SCK EXP2_09_PIN - //#define DOGLCD_MOSI EXP2_05_PIN + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_06_PIN + //#define DOGLCD_SCK EXP2_02_PIN + //#define DOGLCD_MOSI EXP2_06_PIN // Required for MKS_MINI_12864 with this board //#define MKS_LCD12864B //#undef SHOW_BOOTSCREEN #elif ENABLED(FYSETC_MINI_12864_2_1) - #define LCD_PINS_DC EXP1_07_PIN - #define DOGLCD_CS EXP1_08_PIN + #define LCD_PINS_DC EXP1_04_PIN + #define DOGLCD_CS EXP1_03_PIN #define DOGLCD_A0 LCD_PINS_DC #define LCD_BACKLIGHT_PIN -1 - #define LCD_RESET_PIN EXP1_06_PIN - #define NEOPIXEL_PIN EXP1_05_PIN - #define DOGLCD_MOSI EXP2_05_PIN - #define DOGLCD_SCK EXP2_09_PIN + #define LCD_RESET_PIN EXP1_05_PIN + #define NEOPIXEL_PIN EXP1_06_PIN + #define DOGLCD_MOSI EXP2_06_PIN + #define DOGLCD_SCK EXP2_02_PIN #if SD_CONNECTION_IS(ONBOARD) #define FORCE_SOFT_SPI #endif @@ -361,11 +361,11 @@ #else // !MKS_MINI_12864 - #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_D4 EXP1_05_PIN #if ENABLED(ULTIPANEL) - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN #endif #define BOARD_ST7920_DELAY_1 96 @@ -382,10 +382,10 @@ #endif #if ANY(TFT_COLOR_UI, TFT_LVGL_UI, TFT_CLASSIC_UI, HAS_WIRED_LCD) - #define BEEPER_PIN EXP1_10_PIN + #define BEEPER_PIN EXP1_01_PIN #if DISABLED(USE_SPI_DMA_TC) - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN - #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + #define BTN_ENC EXP1_02_PIN #endif #endif diff --git a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h index 1627bb909b..7e08caaa82 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h @@ -230,31 +230,31 @@ #endif /** ------ ------ - * (BEEPER) PC5 |10 9 | PE13 (BTN_ENC) (SPI1 MISO) PA6 |10 9 | PA5 (SPI1 SCK) - * (LCD_EN) PD13 | 8 7 | PC6 (LCD_RS) (BTN_EN1) PE8 | 8 7 | PE10 (SPI1 CS) - * (LCD_D4) PE14 6 5 | PE15 (LCD_D5) (BTN_EN2) PE11 6 5 | PA7 (SPI1 MOSI) - * (LCD_D6) PD11 | 4 3 | PD10 (LCD_D7) (SPI DET) PE12 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | 3.3V + * (BEEPER) PC5 | 1 2 | PE13 (BTN_ENC) (SPI1 MISO) PA6 | 1 2 | PA5 (SPI1 SCK) + * (LCD_EN) PD13 | 3 4 | PC6 (LCD_RS) (BTN_EN1) PE8 | 3 4 | PE10 (SPI1 CS) + * (LCD_D4) PE14 5 6 | PE15 (LCD_D5) (BTN_EN2) PE11 5 6 | PA7 (SPI1 MOSI) + * (LCD_D6) PD11 | 7 8 | PD10 (LCD_D7) (SPI DET) PE12 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | 3.3V * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN PD10 -#define EXP1_04_PIN PD11 -#define EXP1_05_PIN PE15 -#define EXP1_06_PIN PE14 -#define EXP1_07_PIN PC6 -#define EXP1_08_PIN PD13 -#define EXP1_09_PIN PE13 -#define EXP1_10_PIN PC5 - -#define EXP2_03_PIN -1 // RESET -#define EXP2_04_PIN PE12 -#define EXP2_05_PIN PA7 -#define EXP2_06_PIN PE11 -#define EXP2_07_PIN PE10 -#define EXP2_08_PIN PE8 -#define EXP2_09_PIN PA5 -#define EXP2_10_PIN PA6 +#define EXP1_01_PIN PC5 +#define EXP1_02_PIN PE13 +#define EXP1_03_PIN PD13 +#define EXP1_04_PIN PC6 +#define EXP1_05_PIN PE14 +#define EXP1_06_PIN PE15 +#define EXP1_07_PIN PD11 +#define EXP1_08_PIN PD10 + +#define EXP2_01_PIN PA6 +#define EXP2_02_PIN PA5 +#define EXP2_03_PIN PE8 +#define EXP2_04_PIN PE10 +#define EXP2_05_PIN PE11 +#define EXP2_06_PIN PA7 +#define EXP2_07_PIN PE12 +#define EXP2_08_PIN -1 // RESET // // LCD SD @@ -262,11 +262,11 @@ /* #if SD_CONNECTION_IS(LCD) #define ENABLE_SPI1 - #define SDSS EXP2_07_PIN - #define SD_SCK_PIN EXP2_09_PIN - #define SD_MISO_PIN EXP2_10_PIN - #define SD_MOSI_PIN EXP2_05_PIN - #define SD_DETECT_PIN EXP2_04_PIN + #define SDSS EXP2_04_PIN + #define SD_SCK_PIN EXP2_02_PIN + #define SD_MISO_PIN EXP2_01_PIN + #define SD_MOSI_PIN EXP2_06_PIN + #define SD_DETECT_PIN EXP2_07_PIN #endif */ @@ -300,15 +300,15 @@ #define TOUCH_ORIENTATION TOUCH_LANDSCAPE #endif - #define TFT_CS_PIN EXP1_04_PIN - #define TFT_SCK_PIN EXP2_09_PIN - #define TFT_MISO_PIN EXP2_10_PIN - #define TFT_MOSI_PIN EXP2_05_PIN - #define TFT_DC_PIN EXP1_03_PIN + #define TFT_CS_PIN EXP1_07_PIN + #define TFT_SCK_PIN EXP2_02_PIN + #define TFT_MISO_PIN EXP2_01_PIN + #define TFT_MOSI_PIN EXP2_06_PIN + #define TFT_DC_PIN EXP1_08_PIN #define TFT_A0_PIN TFT_DC_PIN - #define TFT_RESET_PIN EXP1_07_PIN - #define LCD_BACKLIGHT_PIN EXP1_08_PIN + #define TFT_RESET_PIN EXP1_04_PIN + #define LCD_BACKLIGHT_PIN EXP1_03_PIN #define TFT_BACKLIGHT_PIN LCD_BACKLIGHT_PIN #define TOUCH_BUTTONS_HW_SPI @@ -321,15 +321,15 @@ #define TFT_HEIGHT 320 #endif - #define TOUCH_CS_PIN EXP1_06_PIN // SPI1_NSS - #define TOUCH_SCK_PIN EXP2_09_PIN // SPI1_SCK - #define TOUCH_MISO_PIN EXP2_10_PIN // SPI1_MISO - #define TOUCH_MOSI_PIN EXP2_05_PIN // SPI1_MOSI + #define TOUCH_CS_PIN EXP1_05_PIN // SPI1_NSS + #define TOUCH_SCK_PIN EXP2_02_PIN // SPI1_SCK + #define TOUCH_MISO_PIN EXP2_01_PIN // SPI1_MISO + #define TOUCH_MOSI_PIN EXP2_06_PIN // SPI1_MOSI - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN - #define BEEPER_PIN EXP1_10_PIN - #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN #define LCD_READ_ID 0xD3 #define LCD_USE_DMA_SPI @@ -339,22 +339,22 @@ #elif HAS_WIRED_LCD - #define BEEPER_PIN EXP1_10_PIN - #define BTN_ENC EXP1_09_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_RS EXP1_07_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_RS EXP1_04_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN #define LCD_BACKLIGHT_PIN -1 // MKS MINI12864 and MKS LCD12864B; If using MKS LCD12864A (Need to remove RPK2 resistor) #if ENABLED(MKS_MINI_12864) //#define LCD_BACKLIGHT_PIN -1 //#define LCD_RESET_PIN -1 - #define DOGLCD_A0 EXP1_04_PIN - #define DOGLCD_CS EXP1_05_PIN - //#define DOGLCD_SCK EXP2_09_PIN - //#define DOGLCD_MOSI EXP2_05_PIN + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_06_PIN + //#define DOGLCD_SCK EXP2_02_PIN + //#define DOGLCD_MOSI EXP2_06_PIN // Required for MKS_MINI_12864 with this board //#define MKS_LCD12864B @@ -362,11 +362,11 @@ #else // !MKS_MINI_12864 - #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_D4 EXP1_05_PIN #if ENABLED(ULTIPANEL) - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN #endif #define BOARD_ST7920_DELAY_1 96 diff --git a/Marlin/src/pins/stm32f4/pins_INDEX_REV03.h b/Marlin/src/pins/stm32f4/pins_OPULO_LUMEN_REV3.h similarity index 97% rename from Marlin/src/pins/stm32f4/pins_INDEX_REV03.h rename to Marlin/src/pins/stm32f4/pins_OPULO_LUMEN_REV3.h index ba3172aa80..36dde88105 100644 --- a/Marlin/src/pins/stm32f4/pins_INDEX_REV03.h +++ b/Marlin/src/pins/stm32f4/pins_OPULO_LUMEN_REV3.h @@ -22,15 +22,15 @@ #pragma once /** - * STM32F407VET6 on Index PnP Mobo Rev03 - * Website - https://indexmachines.io/ + * STM32F407VET6 on Opulo Lumen PnP Rev3 + * Website - https://opulo.io/ */ #define ALLOW_STM32DUINO #include "env_validate.h" -#define BOARD_INFO_NAME "Index Mobo Rev03" -#define DEFAULT_MACHINE_NAME "Index Pick and Place" +#define BOARD_INFO_NAME "Opulo Lumen REV3" +#define DEFAULT_MACHINE_NAME "Opulo Pick-and-Place" /** * By default, the extra stepper motor configuration is: diff --git a/Marlin/src/pins/stm32f4/pins_STEVAL_3DP001V1.h b/Marlin/src/pins/stm32f4/pins_STEVAL_3DP001V1.h deleted file mode 100644 index 0b527a6fdb..0000000000 --- a/Marlin/src/pins/stm32f4/pins_STEVAL_3DP001V1.h +++ /dev/null @@ -1,325 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * - * Based on Sprinter and grbl. - * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm - * - * This program 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. - * - * This program 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 this program. If not, see . - * - */ -#pragma once - -// Source: https://github.com/stm32duino/Arduino_Core_STM32/blob/master/variants/ST3DP001_EVAL/variant.cpp - -/** - * HOW TO COMPILE - * - * PlatformIO - Use the STM32F401VE_STEVAL environment (or the "Auto Build Marlin" extension). - * - * Arduino - Tested with 1.8.10 - * Install library per https://github.com/stm32duino/Arduino_Core_STM32 - * Make the following selections under the TOOL menu in the Arduino IDE - * Board: "3D printer boards" - * Board part number: "STEVAL-3DP001V1" - * U(S)ART support: "Enabled (generic "Serial")" - * USB support (if available): "CDC (no generic "Serial")" - * Optimize: "Smallest (-Os default)" - * C Runtime Library: "newlib Nano (default)" - */ - -#include "env_validate.h" - -#ifndef MACHINE_NAME - #define MACHINE_NAME "STEVAL-3DP001V1" -#endif - -// -// Limit Switches -// -#define X_MIN_PIN PD8 // X_STOP -#define Y_MIN_PIN PD9 // Y_STOP -#define Z_MIN_PIN PD10 // Z_STOP - -#define X_MAX_PIN PD0 // W_STOP -#define Y_MAX_PIN PA8 // V_STOP -#define Z_MAX_PIN PD11 // U_STOP - -// -// Z Probe (when not Z_MIN_PIN) -// -//#ifndef Z_MIN_PROBE_PIN -// #define Z_MIN_PROBE_PIN PA4 // SPI1_CS -//#endif - -// -// Filament runout -// -//#define FIL_RUNOUT_PIN PA3 // BED_THERMISTOR_3 - -// -// Steppers -// - -#define X_STEP_PIN PE14 // X_PWM -#define X_DIR_PIN PE15 // X_DIR -#define X_ENABLE_PIN PE13 // X_RESET -#define X_CS_PIN PA4 // SPI1_CS - -#define Y_STEP_PIN PB10 // Y_PWM -#define Y_DIR_PIN PE9 // Y_DIR -#define Y_ENABLE_PIN PE10 // Y_RESET -#define Y_CS_PIN PA4 // SPI1_CS - -#define Z_STEP_PIN PC6 // Z_PWM -#define Z_DIR_PIN PC0 // Z_DIR -#define Z_ENABLE_PIN PC15 // Z_RESET -#define Z_CS_PIN PA4 // SPI1_CS - -#define E0_STEP_PIN PD12 // E1_PW -#define E0_DIR_PIN PC13 // E1_DIR -#define E0_ENABLE_PIN PC14 // E1_RESET -#define E0_CS_PIN PA4 // SPI1_CS - -#define E1_STEP_PIN PE5 // E2_PWM -#define E1_DIR_PIN PE6 // E2_DIR -#define E1_ENABLE_PIN PE4 // E2_RESET -#define E1_CS_PIN PA4 // SPI1_CS - -#define E2_STEP_PIN PB8 // E3_PWM -#define E2_DIR_PIN PE2 // E3_DIR -#define E2_ENABLE_PIN PE3 // E3_RESET -#define E2_CS_PIN PA4 // SPI1_CS - -// needed to pass a sanity check -#define X2_CS_PIN PA4 // SPI1_CS -#define Y2_CS_PIN PA4 // SPI1_CS -#define Z2_CS_PIN PA4 // SPI1_CS -#define Z3_CS_PIN PA4 // SPI1_CS -#define E3_CS_PIN PA4 // SPI1_CS -#define E4_CS_PIN PA4 // SPI1_CS -#define E5_CS_PIN PA4 // SPI1_CS - -#if HAS_L64XX - #define L6470_CHAIN_SCK_PIN PA5 // SPI1_SCK - #define L6470_CHAIN_MISO_PIN PA6 // SPI1_MISO - #define L6470_CHAIN_MOSI_PIN PA7 // SPI1_MOSI - #define L6470_CHAIN_SS_PIN PA4 // SPI1_CS - - //#define SD_SCK_PIN L6470_CHAIN_SCK_PIN - //#define SD_MISO_PIN L6470_CHAIN_MISO_PIN - //#define SD_MOSI_PIN L6470_CHAIN_MOSI_PIN -#else - //#define SD_SCK_PIN PB13 // SPI2_SCK - //#define SD_MISO_PIN PB14 // SPI2_MISO - //#define SD_MOSI_PIN PB15 // SPI2_MOSI -#endif - -/** - * Macro to reset/enable L6474 stepper drivers - * - * IMPORTANT - To disable (bypass) L6474s, install the corresponding - * resistors (R11 - R17) and change the "V" to "0" for the - * corresponding pins here: - */ -#define ENABLE_RESET_L64XX_CHIPS(V) do{ OUT_WRITE(X_ENABLE_PIN, V); \ - OUT_WRITE(Y_ENABLE_PIN, V); \ - OUT_WRITE(Z_ENABLE_PIN, V); \ - OUT_WRITE(E0_ENABLE_PIN,V); \ - OUT_WRITE(E1_ENABLE_PIN,V); \ - OUT_WRITE(E2_ENABLE_PIN,V); \ - }while(0) - -// -// Temperature Sensors -// -#define TEMP_0_PIN PA0 // Analog Input 3 -#define TEMP_1_PIN PA1 // Analog Input 4 -#define TEMP_2_PIN PA2 // Analog Input 5 -#define TEMP_BED_PIN PC2 // Analog Input 0 -#define TEMP_BED_1_PIN PC3 // Analog Input 1 -#define TEMP_BED_2_PIN PA3 // Analog Input 2 - -// -// Heaters / Fans -// -#define HEATER_0_PIN PC7 // E1_HEAT_PWM -#define HEATER_1_PIN PB0 // E2_HEAT_PWM -#define HEATER_2_PIN PB1 // E3_HEAT_PWM -#define HEATER_BED_PIN PD14 // BED_HEAT_1 FET -#define HEATER_BED_1_PIN PD13 // BED_HEAT_2 FET -#define HEATER_BED_2_PIN PD15 // BED_HEAT_3 FET - -#define FAN_PIN PC4 // E1_FAN PWM pin, Part cooling fan FET -#define FAN1_PIN PC5 // E2_FAN PWM pin, Extruder fan FET -#define FAN2_PIN PE8 // E3_FAN PWM pin, Controller fan FET - -#ifndef E0_AUTO_FAN_PIN - #define E0_AUTO_FAN_PIN PC5 // FAN1_PIN -#endif - -// -// Misc functions -// -#define LED_PIN -1 // PE1 Green LED Heartbeat -#define PS_ON_PIN -1 -#define KILL_PIN -1 -#define POWER_LOSS_PIN -1 // PWR_LOSS / nAC_FAULT - -// -// LCD / Controller -// -//#define SD_DETECT_PIN PA15 // SD_CARD_DETECT -//#define BEEPER_PIN PC9 // SDIO_D1 -//#define LCD_PINS_RS PE9 // Y_DIR -//#define LCD_PINS_ENABLE PE8 // E3_FAN -//#define LCD_PINS_D4 PB12 // SPI2_CS -//#define LCD_PINS_D5 PB13 // SPI2_SCK -//#define LCD_PINS_D6 PB14 // SPI2_MISO -//#define LCD_PINS_D7 PB15 // SPI2_MOSI -//#define BTN_EN1 PC4 // E1_FAN -//#define BTN_EN2 PC5 // E2_FAN -//#define BTN_ENC PC3 // BED_THERMISTOR_2 - -// -// Extension pins -// -//#define EXT0_PIN PB0 // E2_HEAT -//#define EXT1_PIN PB1 // E3_HEAT -//#define EXT2_PIN PB2 // not used (tied to ground) -//#define EXT3_PIN PD8 // X_STOP -//#define EXT4_PIN PD9 // Y_STOP -//#define EXT5_PIN PD10 // Z_STOP -//#define EXT6_PIN PD11 // U_STOP -//#define EXT7_PIN PD12 // E1_PWM -//#define EXT8_PIN PB10 // Y_PWM - -// WIFI -// PD3 CTS -// PD4 RTS -// PD5 TX -// PD6 RX -// PB5 WIFI_WAKEUP -// PE11 WIFI_RESET -// PE12 WIFI_BOOT - -// I2C USER -// PB7 SDA -// PB6 SCL - -// JTAG -// PA13 JTAG_TMS/SWDIO -// PA14 JTAG_TCK/SWCLK -// PB3 JTAG_TDO/SWO - -// -// Onboard SD support -// -#ifndef SDCARD_CONNECTION - #define SDCARD_CONNECTION ONBOARD -#endif - -#if SD_CONNECTION_IS(ONBOARD) - - #define SDIO_SUPPORT // Use SDIO for onboard SD - #if DISABLED(SDIO_SUPPORT) - #define SOFTWARE_SPI // Use soft SPI for onboard SD - #define SDSS PC11 - #define SD_SCK_PIN PC12 - #define SD_MISO_PIN PC8 - #define SD_MOSI_PIN PD2 - #endif - - //#define SD_DETECT_PIN PA15 - -#endif - -#ifndef SDSS - #define SDSS PA4 // SPI1_CS -#endif - -// OTG -// PA11 OTG_DM -// PA12 OTG_DP - -// USER_PINS -// PD7 USER3 -// PB9 USER1 -// PE0 USER2 -// PB4 USER4 - -// USERKET -// PE7 USER_BUTTON - -// PA9 TX -// PA10 RX - -// IR/PROBE -// PD1 IR_OUT -// PC1 IR_ON - -/** - * Logical pin vs. port/pin cross reference - * - * PA0 E1_THERMISTOR PD0 W_STOP - * PA1 E2_THERMISTOR PD1 IR_OUT - * PA2 E3_THERMISTOR PD2 SDIO_CMD - * PA3 BED_THERMISTOR_3 PD3 CTS - * PA4 SPI1_CS PD4 RTS - * PA5 SPI1_SCK PD5 TX - * PA6 SPI1_MISO PD6 RX - * PA7 SPI1_MOSI PD7 USER3 - * PA8 V_STOP PD8 X_STOP - * PA9 TX PD9 Y_STOP - * PA10 RX PD10 Z_STOP - * PA11 OTG_DM PD11 U_STOP - * PA12 OTG_DP PD12 E1_PWM - * PA13 JTAG_TMS/SWDIO PD13 BED_HEAT_2 - * PA14 JTAG_TCK/SWCLK PD14 BED_HEAT_1 - * PA15 SD_CARD_DETECT PD15 BED_HEAT_3 - * - * PB0 E2_HEAT_PWM PE0 USER2 - * PB1 E3_HEAT_PWM PE1 STATUS_LED - * PB2 --- PE2 E3_DIR - * PB3 JTAG_TDO/SWO PE3 E3_RESET - * PB4 USER4 PE4 E2_RESET - * PB5 WIFI_WAKEUP PE5 E2_PWM - * PB6 SCL PE6 E2_DIR - * PB7 SDA PE7 USER_BUTTON - * PB8 E3_PWM PE8 E3_FAN - * PB9 USER1 PE9 Y_DIR - * PB10 Y_PWM PE10 Y_RESET - * PB11 --- PE11 WIFI_RESET - * PB12 SPI2_CS PE12 WIFI_BOOT - * PB13 SPI2_SCK PE13 X_RESET - * PB14 SPI2_MISO PE14 X_PWM - * PB15 SPI2_MOSI PE15 X_DIR - * - * PC0 Z_DIR - * PC1 IR_ON - * PC2 BED_THERMISTOR_1 - * PC3 BED_THERMISTOR_2 - * PC4 E1_FAN - * PC5 E2_FAN - * PC6 Z_PWM - * PC7 E1_HEAT_PWM - * PC8 SDIO_D0 - * PC9 SDIO_D1 - * PC10 SDIO_D2 - * PC11 SDIO_D3 - * PC12 SDIO_CK - * PC13 E1_DIR - * PC14 E1_RESET - * PC15 Z_RESET - */ diff --git a/Marlin/src/pins/stm32f4/pins_TH3D_EZBOARD_V2.h b/Marlin/src/pins/stm32f4/pins_TH3D_EZBOARD_V2.h index 1439e6de65..1a75a859e6 100644 --- a/Marlin/src/pins/stm32f4/pins_TH3D_EZBOARD_V2.h +++ b/Marlin/src/pins/stm32f4/pins_TH3D_EZBOARD_V2.h @@ -199,11 +199,11 @@ /** * ------ - * PA14 |10 9 | PB0 - * PC4 | 8 7 | -- - * PC5 | 6 5 PB13 - * PB12 | 4 3 | PB15 - * GND | 2 1 | 5V + * PA14 | 1 2 | PB0 + * PC4 | 3 4 | -- + * PC5 | 5 6 PB13 + * PB12 | 7 8 | PB15 + * GND | 9 10 | 5V * ------ * EXP1 * @@ -213,30 +213,30 @@ * A remote SD card is currently not supported because the pins routed to the EXP2 * connector are shared with the onboard SD card. */ -#define EXP1_03_PIN PB15 -#define EXP1_04_PIN PB12 -#define EXP1_05_PIN PB13 -#define EXP1_06_PIN PC5 -//#define EXP1_07_PIN -1 -#define EXP1_08_PIN PC4 -#define EXP1_09_PIN PB0 -#define EXP1_10_PIN PA14 +#define EXP1_01_PIN PA14 +#define EXP1_02_PIN PB0 +#define EXP1_03_PIN PC4 +//#define EXP1_04_PIN -1 +#define EXP1_05_PIN PC5 +#define EXP1_06_PIN PB13 +#define EXP1_07_PIN PB12 +#define EXP1_08_PIN PB15 #if ENABLED(CR10_STOCKDISPLAY) /** ------ - * BEEPER |10 9 | ENC - * EN1 | 8 7 | RESET - * EN2 | 6 5 LCD_D4 - * LCD_RS | 4 3 | LCD_EN - * GND | 2 1 | 5V + * BEEPER | 1 2 | ENC + * EN1 | 3 4 | RESET + * EN2 | 5 6 LCD_D4 + * LCD_RS | 7 8 | LCD_EN + * GND | 9 10 | 5V * ------ */ #ifdef DISABLE_JTAGSWD - #define BEEPER_PIN EXP1_10_PIN // Not connected in dev board + #define BEEPER_PIN EXP1_01_PIN // Not connected in dev board #endif - #define LCD_PINS_RS EXP1_04_PIN - #define LCD_PINS_ENABLE EXP1_03_PIN - #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN //#define KILL_PIN -1 #define BOARD_ST7920_DELAY_1 600 @@ -245,17 +245,17 @@ #elif ENABLED(MKS_MINI_12864) /** ------ - * SCK |10 9 | ENC - * EN1 | 8 7 | -- - * EN2 | 6 5 A0 - * CS | 4 3 | MOSI - * GND | 2 1 | 5V + * SCK | 1 2 | ENC + * EN1 | 3 4 | -- + * EN2 | 5 6 A0 + * CS | 7 8 | MOSI + * GND | 9 10 | 5V * ------ */ - #define DOGLCD_CS EXP1_04_PIN - #define DOGLCD_A0 EXP1_05_PIN - #define DOGLCD_SCK EXP1_10_PIN - #define DOGLCD_MOSI EXP1_03_PIN + #define DOGLCD_CS EXP1_07_PIN + #define DOGLCD_A0 EXP1_06_PIN + #define DOGLCD_SCK EXP1_01_PIN + #define DOGLCD_MOSI EXP1_08_PIN #define LCD_CONTRAST_INIT 160 #define LCD_CONTRAST_MIN 120 #define LCD_CONTRAST_MAX 180 @@ -269,7 +269,7 @@ #endif #if EITHER(CR10_STOCKDISPLAY, MKS_MINI_12864) - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_PIN - #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + #define BTN_ENC EXP1_02_PIN #endif diff --git a/Marlin/src/pins/stm32f4/pins_VAKE403D.h b/Marlin/src/pins/stm32f4/pins_VAKE403D.h index 66caec588f..21ab9d0e70 100644 --- a/Marlin/src/pins/stm32f4/pins_VAKE403D.h +++ b/Marlin/src/pins/stm32f4/pins_VAKE403D.h @@ -161,37 +161,37 @@ #define POWER_LOSS_PIN PA4 // ?? Power loss / nAC_FAULT #if ENABLED(SDSUPPORT) - #define SD_DETECT_PIN EXP2_04_PIN + #define SD_DETECT_PIN EXP2_07_PIN #define SD_SS_PIN PB15 // USD_CS -> CS for onboard SD #endif /** * ------ ------ - * PC9 |10 9 | PB12 ? |10 9 | ? - * PD7 | 8 7 | PC12 PD6 | 8 7 | ? - * PD1 | 6 5 PD2 PD0 | 6 5 ? - * PD3 | 4 3 | PD4 PB7 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | 3.3V + * PC9 | 1 2 | PB12 ? | 1 2 | ? + * PD7 | 3 4 | PC12 PD6 | 3 4 | ? + * PD1 | 5 6 PD2 PD0 | 5 6 ? + * PD3 | 7 8 | PD4 PB7 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | 3.3V * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN PD4 -#define EXP1_04_PIN PD3 -#define EXP1_05_PIN PD2 -#define EXP1_06_PIN PD1 -#define EXP1_07_PIN PC12 -#define EXP1_08_PIN PD7 -#define EXP1_09_PIN PB12 -#define EXP1_10_PIN PC9 - -#define EXP2_03_PIN -1 -#define EXP2_04_PIN PB7 -//#define EXP2_05_PIN ? -#define EXP2_06_PIN PD0 -//#define EXP2_07_PIN ? -#define EXP2_08_PIN PD6 -//#define EXP2_09_PIN ? -//#define EXP2_10_PIN ? +#define EXP1_01_PIN PC9 +#define EXP1_02_PIN PB12 +#define EXP1_03_PIN PD7 +#define EXP1_04_PIN PC12 +#define EXP1_05_PIN PD1 +#define EXP1_06_PIN PD2 +#define EXP1_07_PIN PD3 +#define EXP1_08_PIN PD4 + +//#define EXP2_01_PIN ? +//#define EXP2_02_PIN ? +#define EXP2_03_PIN PD6 +//#define EXP2_04_PIN ? +#define EXP2_05_PIN PD0 +//#define EXP2_06_PIN ? +#define EXP2_07_PIN PB7 +#define EXP2_08_PIN -1 // // LCD / Controller @@ -202,19 +202,19 @@ #define SDSS PB6 // CS for SD card in LCD #endif - #define BEEPER_PIN EXP1_10_PIN + #define BEEPER_PIN EXP1_01_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN - #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + #define BTN_ENC EXP1_02_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_RS EXP1_04_PIN - #define LCD_PINS_D4 EXP1_06_PIN - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN #endif diff --git a/Marlin/src/pins/stm32g0/pins_BTT_SKR_MINI_E3_V3_0.h b/Marlin/src/pins/stm32g0/pins_BTT_SKR_MINI_E3_V3_0.h index 769f10c8a4..956cb71f83 100644 --- a/Marlin/src/pins/stm32g0/pins_BTT_SKR_MINI_E3_V3_0.h +++ b/Marlin/src/pins/stm32g0/pins_BTT_SKR_MINI_E3_V3_0.h @@ -75,10 +75,6 @@ #define POWER_LOSS_PIN PC12 // Power Loss Detection: PWR-DET #endif -#ifndef NEOPIXEL_PIN - #define NEOPIXEL_PIN PA8 // LED driving pin -#endif - #ifndef PS_ON_PIN #define PS_ON_PIN PC13 // Power Supply Control #endif @@ -145,25 +141,33 @@ /** * SKR Mini E3 V3.0 * ------ - * (BEEPER) PB5 |10 9 | PA15 (BTN_ENC) - * (BTN_EN1) PA9 | 8 7 | RESET - * (BTN_EN2) PA10 6 5 | PB9 (LCD_D4) - * (LCD_RS) PB8 | 4 3 | PD6 (LCD_EN) - * GND | 2 1 | 5V + * (BEEPER) PB5 | 1 2 | PA15 (BTN_ENC) + * (BTN_EN1) PA9 | 3 4 | RESET + * (BTN_EN2) PA10 5 6 | PB9 (LCD_D4) + * (LCD_RS) PB8 | 7 8 | PD6 (LCD_EN) + * GND | 9 10 | 5V * ------ * EXP1 */ -#define EXP1_09_PIN PA15 -#define EXP1_03_PIN PD6 +#define EXP1_01_PIN PB5 +#define EXP1_02_PIN PA15 +#define EXP1_03_PIN PA9 +#define EXP1_04_PIN -1 +#define EXP1_05_PIN PA10 +#define EXP1_06_PIN PB9 +#define EXP1_07_PIN PB8 +#define EXP1_08_PIN PD6 +#define EXP1_09_PIN -1 +#define EXP1_10_PIN -1 #if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI /** * ------ ------ ------ - * (ENT) |10 9 | (BEEP) |10 9 | |10 9 | - * (RX) | 8 7 | (RX) | 8 7 | (TX) RX | 8 7 | TX - * (TX) 6 5 | (ENT) 6 5 | (BEEP) ENT | 6 5 | BEEP - * (B) | 4 3 | (A) (B) | 4 3 | (A) B | 4 3 | A - * GND | 2 1 | (VCC) GND | 2 1 | VCC GND | 2 1 | VCC + * (ENT) | 1 2 | (BEEP) |10 9 | |10 9 | + * (RX) | 3 4 | (RX) | 8 7 | (TX) RX | 8 7 | TX + * (TX) 5 6 | (ENT) 6 5 | (BEEP) ENT | 6 5 | BEEP + * (B) | 7 8 | (A) (B) | 4 3 | (A) B | 4 3 | A + * GND | 9 10 | (VCC) GND | 2 1 | VCC GND | 2 1 | VCC * ------ ------ ------ * EXP1 DWIN DWIN (plug) * @@ -174,95 +178,137 @@ #error "CAUTION! DWIN_CREALITY_LCD requires a custom cable, see diagram above this line. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" #endif - #define BEEPER_PIN EXP1_09_PIN - #define BTN_EN1 EXP1_03_PIN - #define BTN_EN2 PB8 - #define BTN_ENC PB5 + #define BEEPER_PIN EXP1_02_PIN + #define BTN_EN1 EXP1_08_PIN + #define BTN_EN2 EXP1_07_PIN + #define BTN_ENC EXP1_01_PIN #elif HAS_WIRED_LCD - #if ENABLED(CR10_STOCKDISPLAY) - - #define BEEPER_PIN PB5 - #define BTN_ENC EXP1_09_PIN - - #define BTN_EN1 PA9 - #define BTN_EN2 PA10 - - #define LCD_PINS_RS PB8 - #define LCD_PINS_ENABLE EXP1_03_PIN - #define LCD_PINS_D4 PB9 - - #elif ENABLED(ZONESTAR_LCD) // ANET A8 LCD Controller - Must convert to 3.3V - CONNECTING TO 5V WILL DAMAGE THE BOARD! - - #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING - #error "CAUTION! ZONESTAR_LCD requires wiring modifications. See 'pins_BTT_SKR_MINI_E3_common.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" + #if ENABLED(SKR_MINI_SCREEN_ADAPTER) + /** https://github.com/VoronDesign/Voron-Hardware/tree/master/SKR-Mini_Screen_Adaptor/SRK%20Mini%20E3%20V3.0 + * + * SKR Mini E3 V3.0 SKR Mini Screen Adaptor + * ------ ------ + * 5V | 1 2 | GND MISO | 1 2 | SCK + * CS | 3 4 | SCK (EN1) PA10 | 3 4 | -- + * MOSI | 5 6 | MISO (EN2) PA9 5 6 | MOSI + * 3V3 | 7 8 | GND -- | 7 8 | -- + * ------ GND | 9 10| RESET (Kill) + * SPI ------ + * EXP2 + * + * ------ ------ + * PB5 | 1 2 | PA15 -- | 1 2 | PB5 (BTN_ENC) + * PA9 | 3 4 | RESET (LCD CS) PB8 | 3 4 | PD6 (LCD_A0) + * PA10 5 6 | PB9 (RESET) PB9 5 6 | PA15 (DIN) + * PB8 | 7 8 | PD6 -- | 7 8 | -- + * GND | 9 10| 5V GND | 9 10| 5V + * ------ ------ + * EXP1 EXP1 + */ + #if ENABLED(FYSETC_MINI_12864_2_1) + #define BTN_ENC EXP1_01_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + #define BEEPER_PIN -1 + #define LCD_RESET_PIN EXP1_06_PIN + #define DOGLCD_CS EXP1_07_PIN + #define DOGLCD_A0 EXP1_08_PIN + #define DOGLCD_SCK PA5 + #define DOGLCD_MOSI PA7 + + #define FORCE_SOFT_SPI + #define LCD_BACKLIGHT_PIN -1 + #define NEOPIXEL_PIN EXP1_02_PIN + #else + #error "Only CR10_FYSETC_MINI_12864_2_1 and compatibles are currently supported on the BIGTREE_SKR_MINI_E3 with SKR_MINI_SCREEN_ADAPTER" #endif - #define LCD_PINS_RS PB9 - #define LCD_PINS_ENABLE EXP1_09_PIN - #define LCD_PINS_D4 PB8 - #define LCD_PINS_D5 PA10 - #define LCD_PINS_D6 PA9 - #define LCD_PINS_D7 PB5 - #define ADC_KEYPAD_PIN PA1 // Repurpose servo pin for ADC - CONNECTING TO 5V WILL DAMAGE THE BOARD! - - #elif EITHER(MKS_MINI_12864, ENDER2_STOCKDISPLAY) + #else - #define BTN_ENC EXP1_09_PIN - #define BTN_EN1 PA9 - #define BTN_EN2 PA10 + #if ENABLED(CR10_STOCKDISPLAY) - #define DOGLCD_CS PB8 - #define DOGLCD_A0 PB9 - #define DOGLCD_SCK PB5 - #define DOGLCD_MOSI EXP1_03_PIN + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN - #define FORCE_SOFT_SPI - #define LCD_BACKLIGHT_PIN -1 + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN - #elif IS_TFTGLCD_PANEL + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN - #if ENABLED(TFTGLCD_PANEL_SPI) + #elif ENABLED(ZONESTAR_LCD) // ANET A8 LCD Controller - Must convert to 3.3V - CONNECTING TO 5V WILL DAMAGE THE BOARD! #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING - #error "CAUTION! TFTGLCD_PANEL_SPI requires wiring modifications. See 'pins_BTT_SKR_MINI_E3_common.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" + #error "CAUTION! ZONESTAR_LCD requires wiring modifications. See 'pins_BTT_SKR_MINI_E3_common.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" #endif - /** - * TFTGLCD_PANEL_SPI display pinout - * - * Board Display - * ------ ------ - * (BEEPER) PB6 |10 9 | PB5 (SD_DET) 5V |10 9 | GND - * RESET | 8 7 | PA9 (MOD_RESET) -- | 8 7 | (SD_DET) - * PB9 6 5 | PA10 (SD_CS) (MOSI) | 6 5 | -- - * PB7 | 4 3 | PB8 (LCD_CS) (SD_CS) | 4 3 | (LCD_CS) - * GND | 2 1 | 5V (SCK) | 2 1 | (MISO) - * ------ ------ - * EXP1 EXP1 - * - * Needs custom cable: - * - * Board Display - * - * EXP1-1 ----------- EXP1-10 - * EXP1-2 ----------- EXP1-9 - * SPI1-4 ----------- EXP1-6 - * EXP1-4 ----------- FREE - * SPI1-3 ----------- EXP1-2 - * EXP1-6 ----------- EXP1-4 - * EXP1-7 ----------- FREE - * EXP1-8 ----------- EXP1-3 - * SPI1-1 ----------- EXP1-1 - * EXP1-10 ----------- EXP1-7 - */ + #define LCD_PINS_RS EXP1_06_PIN + #define LCD_PINS_ENABLE EXP1_02_PIN + #define LCD_PINS_D4 EXP1_07_PIN + #define LCD_PINS_D5 EXP1_05_PIN + #define LCD_PINS_D6 EXP1_03_PIN + #define LCD_PINS_D7 EXP1_01_PIN + #define ADC_KEYPAD_PIN PA1 // Repurpose servo pin for ADC - CONNECTING TO 5V WILL DAMAGE THE BOARD! + + #elif EITHER(MKS_MINI_12864, ENDER2_STOCKDISPLAY) + + #define BTN_ENC EXP1_02_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + + #define DOGLCD_CS EXP1_07_PIN + #define DOGLCD_A0 EXP1_06_PIN + #define DOGLCD_SCK EXP1_01_PIN + #define DOGLCD_MOSI EXP1_08_PIN + + #define FORCE_SOFT_SPI + #define LCD_BACKLIGHT_PIN -1 + + #elif IS_TFTGLCD_PANEL + + #if ENABLED(TFTGLCD_PANEL_SPI) + + #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING + #error "CAUTION! TFTGLCD_PANEL_SPI requires wiring modifications. See 'pins_BTT_SKR_MINI_E3_common.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" + #endif + + /** + * TFTGLCD_PANEL_SPI display pinout + * + * Board Display + * ------ ------ + * (BEEPER) PB6 | 1 2 | PB5 (SD_DET) 5V |10 9 | GND + * RESET | 3 4 | PA9 (MOD_RESET) -- | 8 7 | (SD_DET) + * PB9 5 6 | PA10 (SD_CS) (MOSI) | 6 5 | -- + * PB7 | 7 8 | PB8 (LCD_CS) (SD_CS) | 4 3 | (LCD_CS) + * GND | 9 10 | 5V (SCK) | 2 1 | (MISO) + * ------ ------ + * EXP1 EXP1 + * + * Needs custom cable: + * + * Board Display + * + * EXP1-10 ----------- EXP1-10 5V + * EXP1-9 ------------ EXP1-9 GND + * SPI1-4 ------------ EXP1-6 MOSI + * EXP1-7 ------------ n/c + * SPI1-3 ------------ EXP1-2 SCK + * EXP1-5 ------------ EXP1-4 SD_CS + * EXP1-4 ------------ n/c + * EXP1-3 ------------ EXP1-3 LCD_CS + * SPI1-1 ------------ EXP1-1 MISO + * EXP1-1 ------------ EXP1-7 SD_DET + */ + + #define TFTGLCD_CS EXP1_03_PIN - #define TFTGLCD_CS PA9 - - #endif + #endif - #elif ENABLED(FYSETC_MINI_12864_2_1) + #elif ENABLED(FYSETC_MINI_12864_2_1) #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING #error "CAUTION! FYSETC_MINI_12864_2_1 and clones require wiring modifications. See 'pins_BTT_SKR_MINI_E3_V3_0.h' for details. Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning" @@ -272,18 +318,18 @@ * * Board Display * ------ ------ - * (EN2) PB5 |10 9 | PA15(BTN_ENC) 5V |10 9 | GND - * (LCD_CS) PA9 | 8 7 | RST (RESET) -- | 8 7 | -- - * (LCD_A0) PA10 |#6 5 | PB9 (EN1) (DIN) | 6 5#| (RESET) - * (LCD_SCK)PB8 | 4 3 | PD6 (MOSI) (LCD_A0) | 4 3 | (LCD_CS) - * GND | 2 1 | 5V (BTN_ENC) | 2 1 | -- + * (EN2) PB5 | 1 2 | PA15(BTN_ENC) 5V |10 9 | GND + * (LCD_CS) PA9 | 3 4 | RST (RESET) -- | 8 7 | -- + * (LCD_A0) PA10 5 6 | PB9 (EN1) (DIN) | 6 5 (RESET) + * (LCD_SCK)PB8 | 7 8 | PD6 (MOSI) (LCD_A0) | 4 3 | (LCD_CS) + * GND | 9 10 | 5V (BTN_ENC) | 2 1 | -- * ------ ------ * EXP1 EXP1 * * ------ * -- |10 9 | -- * --- (RESET) | 8 7 | -- - * | 3 | (MOSI) | 6 5#| (EN2) + * | 3 | (MOSI) | 6 5 (EN2) * | 2 | (DIN) -- | 4 3 | (EN1) * | 1 | (LCD_SCK)| 2 1 | -- * --- ------ @@ -291,25 +337,27 @@ * * Needs custom cable. Connect EN2-EN2, LCD_CS-LCD_CS and so on. * - * Check twice index position!!! (marked as # here) + * Check the index/notch position twice!!! * On BTT boards pins from IDC10 connector are numbered in unusual order. */ - #define BTN_ENC EXP1_09_PIN - #define BTN_EN1 PB9 - #define BTN_EN2 PB5 - #define BEEPER_PIN -1 + #define BTN_ENC EXP1_02_PIN + #define BTN_EN1 EXP1_06_PIN + #define BTN_EN2 EXP1_01_PIN + #define BEEPER_PIN -1 - #define DOGLCD_CS PA9 - #define DOGLCD_A0 PA10 - #define DOGLCD_SCK PB8 - #define DOGLCD_MOSI PD6 + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_05_PIN + #define DOGLCD_SCK EXP1_07_PIN + #define DOGLCD_MOSI EXP1_08_PIN - #define FORCE_SOFT_SPI - #define LCD_BACKLIGHT_PIN -1 + #define FORCE_SOFT_SPI + #define LCD_BACKLIGHT_PIN -1 - #else - #error "Only CR10_STOCKDISPLAY, ZONESTAR_LCD, ENDER2_STOCKDISPLAY, MKS_MINI_12864, FYSETC_MINI_12864_2_1, and TFTGLCD_PANEL_(SPI|I2C) are currently supported on the BIGTREE_SKR_MINI_E3." - #endif + #else + #error "Only CR10_STOCKDISPLAY, ZONESTAR_LCD, ENDER2_STOCKDISPLAY, MKS_MINI_12864, FYSETC_MINI_12864_2_1, and TFTGLCD_PANEL_(SPI|I2C) are currently supported on the BIGTREE_SKR_MINI_E3." + #endif + + #endif // SKR_MINI_SCREEN_ADAPTER #endif // HAS_WIRED_LCD @@ -324,37 +372,36 @@ * * Board Display * ------ ------ - * (SD_DET) PB5 |10 9 | PB6 (BEEPER) 5V |10 9 | GND - * (MOD_RESET) PA9 | 8 7 | RESET (RESET) | 8 7 | (SD_DET) - * (SD_CS) PA10 6 5 | PB9 (FREE) (MOSI) | 6 5 | (LCD_CS) - * (LCD_CS) PB8 | 4 3 | PB7 (FREE) (SD_CS) | 4 3 | (MOD_RESET) - * 5V | 2 1 | GND (SCK) | 2 1 | (MISO) + * (SD_DET) PB5 | 1 2 | PB6 (BEEPER) 5V |10 9 | GND + * (MOD_RESET) PA9 | 3 4 | RESET (RESET) | 8 7 | (SD_DET) + * (SD_CS) PA10 5 6 | PB9 (FREE) (MOSI) | 6 5 | (LCD_CS) + * (LCD_CS) PB8 | 7 8 | PB7 (FREE) (SD_CS) | 4 3 | (MOD_RESET) + * 5V | 9 10 | GND (SCK) | 2 1 | (MISO) * ------ ------ * EXP1 EXP1 * * Needs custom cable: * * Board Adapter Display - * _________ - * EXP1-1 ----------- EXP1-10 - * EXP1-2 ----------- EXP1-9 - * SPI1-4 ----------- EXP1-6 - * EXP1-4 ----------- EXP1-5 - * SPI1-3 ----------- EXP1-2 - * EXP1-6 ----------- EXP1-4 - * EXP1-7 ----------- EXP1-8 - * EXP1-8 ----------- EXP1-3 - * SPI1-1 ----------- EXP1-1 - * EXP1-10 ----------- EXP1-7 + * ---------------------------------- + * EXP1-10 ----------- EXP1-10 5V + * EXP1-9 ------------ EXP1-9 GND + * SPI1-4 ------------ EXP1-6 MOSI + * EXP1-7 ------------ EXP1-5 LCD_CS + * SPI1-3 ------------ EXP1-2 SCK + * EXP1-5 ------------ EXP1-4 SD_CS + * EXP1-4 ------------ EXP1-8 RESET + * EXP1-3 ------------ EXP1-3 MOD_RST + * SPI1-1 ------------ EXP1-1 MISO + * EXP1-1 ------------ EXP1-7 SD_DET */ #define CLCD_SPI_BUS 1 // SPI1 connector - #define BEEPER_PIN EXP1_09_PIN - - #define CLCD_MOD_RESET PA9 - #define CLCD_SPI_CS PB8 + #define BEEPER_PIN EXP1_02_PIN + #define CLCD_MOD_RESET EXP1_03_PIN + #define CLCD_SPI_CS EXP1_07_PIN #endif // TOUCH_UI_FTDI_EVE && LCD_FYSETC_TFT81050 // @@ -368,8 +415,8 @@ #if SD_CONNECTION_IS(ONBOARD) #define SD_DETECT_PIN PC3 #elif SD_CONNECTION_IS(LCD) && (BOTH(TOUCH_UI_FTDI_EVE, LCD_FYSETC_TFT81050) || IS_TFTGLCD_PANEL) - #define SD_DETECT_PIN PB5 - #define SD_SS_PIN PA10 + #define SD_DETECT_PIN EXP1_01_PIN + #define SD_SS_PIN EXP1_05_PIN #elif SD_CONNECTION_IS(CUSTOM_CABLE) #error "SD CUSTOM_CABLE is not compatible with SKR Mini E3." #endif @@ -383,3 +430,10 @@ #define SD_SCK_PIN PA5 #define SD_MISO_PIN PA6 #define SD_MOSI_PIN PA7 + +// +// Default NEOPIXEL_PIN +// +#ifndef NEOPIXEL_PIN + #define NEOPIXEL_PIN PA8 // LED driving pin +#endif diff --git a/Marlin/src/advi3pp/screens/tuning/usb_to_lcd.h b/Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX_V2.h similarity index 59% rename from Marlin/src/advi3pp/screens/tuning/usb_to_lcd.h rename to Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX_V2.h index 30debe20df..8be6dadee4 100644 --- a/Marlin/src/advi3pp/screens/tuning/usb_to_lcd.h +++ b/Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX_V2.h @@ -1,7 +1,9 @@ /** - * ADVi3++ Firmware For Wanhao Duplicator i3 Plus (based on Marlin 2) + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] * - * Copyright (C) 2017-2022 Sebastien Andrivet [https://github.com/andrivet/] + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,25 +16,13 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . * */ - #pragma once -#include "../core/screen.h" - -namespace ADVi3pp { - -//! USB 2 LCD Page -struct Usb2Lcd: Screen -{ -private: - Page do_prepare_page(); - - friend Parent; -}; +#define BOARD_INFO_NAME "BTT SKR SE BX V2.0" -extern Usb2Lcd usb_2_lcd; +#define SAFE_POWER_PIN PI11 -} +#include "pins_BTT_SKR_SE_BX_common.h" diff --git a/Marlin/src/advi3pp/screens/info/sponsors.h b/Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX_V3.h similarity index 59% rename from Marlin/src/advi3pp/screens/info/sponsors.h rename to Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX_V3.h index c036600df4..8d8143ee62 100644 --- a/Marlin/src/advi3pp/screens/info/sponsors.h +++ b/Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX_V3.h @@ -1,7 +1,9 @@ /** - * ADVi3++ Firmware For Wanhao Duplicator i3 Plus (based on Marlin 2) + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] * - * Copyright (C) 2017-2022 Sebastien Andrivet [https://github.com/andrivet/] + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,25 +16,11 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . * */ - #pragma once -#include "../core/screen.h" - -namespace ADVi3pp { - -//! Sponsors Page -struct Sponsors: Screen -{ -private: - Page do_prepare_page(); - - friend Parent; -}; - -extern Sponsors sponsors; +#define BOARD_INFO_NAME "BTT SKR SE BX V3.0" -} +#include "pins_BTT_SKR_SE_BX_common.h" diff --git a/Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX.h b/Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX_common.h similarity index 98% rename from Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX.h rename to Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX_common.h index ddc0a202ea..1ee7846c93 100644 --- a/Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX.h +++ b/Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX_common.h @@ -25,8 +25,7 @@ #error "Oops! Select an STM32H7 board in 'Tools > Board.'" #endif -#define BOARD_INFO_NAME "BTT SKR SE BX" -#define DEFAULT_MACHINE_NAME "BIQU-BX" +#define DEFAULT_MACHINE_NAME "Biqu BX" // Onboard I2C EEPROM #define I2C_EEPROM @@ -56,7 +55,6 @@ #define POWER_MONITOR_PIN PB0 #define RPI_POWER_PIN PE5 -#define SAFE_POWER_PIN PI11 #define SERVO0_PIN PA2 // diff --git a/Marlin/src/pins/stm32h7/pins_BTT_SKR_V3_0_common.h b/Marlin/src/pins/stm32h7/pins_BTT_SKR_V3_0_common.h index 02e195a185..24376d6f9c 100644 --- a/Marlin/src/pins/stm32h7/pins_BTT_SKR_V3_0_common.h +++ b/Marlin/src/pins/stm32h7/pins_BTT_SKR_V3_0_common.h @@ -326,43 +326,43 @@ /** * ------ ------ - * (BEEPER) PC5 |10 9 | PB0 (BTN_ENC) (MISO) PA6 |10 9 | PA5 (SCK) - * (LCD_EN) PB1 | 8 7 | PE8 (LCD_RS) (BTN_EN1) PE7 | 8 7 | PA4 (SD_SS) - * (LCD_D4) PE9 | 6 5 PE10 (LCD_D5) (BTN_EN2) PB2 | 6 5 PA7 (MOSI) - * (LCD_D6) PE11 | 4 3 | PE12 (LCD_D7) (SD_DETECT) PC4 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | -- + * (BEEPER) PC5 | 1 2 | PB0 (BTN_ENC) (MISO) PA6 | 1 2 | PA5 (SCK) + * (LCD_EN) PB1 | 3 4 | PE8 (LCD_RS) (BTN_EN1) PE7 | 3 4 | PA4 (SD_SS) + * (LCD_D4) PE9 | 5 6 PE10 (LCD_D5) (BTN_EN2) PB2 | 5 6 PA7 (MOSI) + * (LCD_D6) PE11 | 7 8 | PE12 (LCD_D7) (SD_DETECT) PC4 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN PE12 -#define EXP1_04_PIN PE11 -#define EXP1_05_PIN PE10 -#define EXP1_06_PIN PE9 -#define EXP1_07_PIN PE8 -#define EXP1_08_PIN PB1 -#define EXP1_09_PIN PB0 -#define EXP1_10_PIN PC5 - -#define EXP2_03_PIN -1 -#define EXP2_04_PIN PC4 -#define EXP2_05_PIN PA7 -#define EXP2_06_PIN PB2 -#define EXP2_07_PIN PA4 -#define EXP2_08_PIN PE7 -#define EXP2_09_PIN PA5 -#define EXP2_10_PIN PA6 +#define EXP1_01_PIN PC5 +#define EXP1_02_PIN PB0 +#define EXP1_03_PIN PB1 +#define EXP1_04_PIN PE8 +#define EXP1_05_PIN PE9 +#define EXP1_06_PIN PE10 +#define EXP1_07_PIN PE11 +#define EXP1_08_PIN PE12 + +#define EXP2_01_PIN PA6 +#define EXP2_02_PIN PA5 +#define EXP2_03_PIN PE7 +#define EXP2_04_PIN PA4 +#define EXP2_05_PIN PB2 +#define EXP2_06_PIN PA7 +#define EXP2_07_PIN PC4 +#define EXP2_08_PIN -1 // // Onboard SD card // Must use soft SPI because Marlin's default hardware SPI is tied to LCD's EXP2 // #if SD_CONNECTION_IS(LCD) - #define SDSS EXP2_07_PIN + #define SDSS EXP2_04_PIN #define SD_SS_PIN SDSS - #define SD_SCK_PIN EXP2_09_PIN - #define SD_MISO_PIN EXP2_10_PIN - #define SD_MOSI_PIN EXP2_05_PIN - #define SD_DETECT_PIN EXP2_04_PIN + #define SD_SCK_PIN EXP2_02_PIN + #define SD_MISO_PIN EXP2_01_PIN + #define SD_MOSI_PIN EXP2_06_PIN + #define SD_DETECT_PIN EXP2_07_PIN #elif SD_CONNECTION_IS(ONBOARD) #define SDIO_SUPPORT #define SDIO_CLOCK 24000000 // 24MHz @@ -371,59 +371,59 @@ #endif #if ENABLED(BTT_MOTOR_EXPANSION) - /** ----- ----- - * -- | . . | GND -- | . . | GND - * -- | . . | M1EN M2EN | . . | M3EN - * M1STP | . . M1DIR M1RX | . . M1DIAG - * M2DIR | . . | M2STP M2RX | . . | M2DIAG - * M3DIR | . . | M3STP M3RX | . . | M3DIAG - * ----- ----- - * EXP2 EXP1 + /** ------ ------ + * M3DIAG | 1 2 | M3RX M3STP | 1 2 | M3DIR + * M2DIAG | 3 4 | M2RX M2STP | 3 4 | M2DIR + * M1DIAG 5 6 | M1RX M1DIR 5 6 | M1STP + * M3EN | 7 8 | M2EN M1EN | 7 8 | -- + * GND | 9 10 | -- GND | 9 10 | -- + * ------ ------ + * EXP1 EXP2 * * NB In EXP_MOT_USE_EXP2_ONLY mode EXP1 is not used and M2EN and M3EN need to be jumpered to M1EN */ // M1 on Driver Expansion Module - #define E2_STEP_PIN EXP2_05_PIN - #define E2_DIR_PIN EXP2_06_PIN - #define E2_ENABLE_PIN EXP2_04_PIN + #define E2_STEP_PIN EXP2_06_PIN + #define E2_DIR_PIN EXP2_05_PIN + #define E2_ENABLE_PIN EXP2_07_PIN #if !EXP_MOT_USE_EXP2_ONLY - #define E2_DIAG_PIN EXP1_06_PIN - #define E2_CS_PIN EXP1_05_PIN + #define E2_DIAG_PIN EXP1_05_PIN + #define E2_CS_PIN EXP1_06_PIN #if HAS_TMC_UART - #define E2_SERIAL_TX_PIN EXP1_05_PIN - #define E2_SERIAL_RX_PIN EXP1_05_PIN + #define E2_SERIAL_TX_PIN EXP1_06_PIN + #define E2_SERIAL_RX_PIN EXP1_06_PIN #endif #endif // M2 on Driver Expansion Module - #define E3_STEP_PIN EXP2_08_PIN - #define E3_DIR_PIN EXP2_07_PIN + #define E3_STEP_PIN EXP2_03_PIN + #define E3_DIR_PIN EXP2_04_PIN #if !EXP_MOT_USE_EXP2_ONLY - #define E3_ENABLE_PIN EXP1_03_PIN - #define E3_DIAG_PIN EXP1_08_PIN - #define E3_CS_PIN EXP1_07_PIN + #define E3_ENABLE_PIN EXP1_08_PIN + #define E3_DIAG_PIN EXP1_03_PIN + #define E3_CS_PIN EXP1_04_PIN #if HAS_TMC_UART - #define E3_SERIAL_TX_PIN EXP1_07_PIN - #define E3_SERIAL_RX_PIN EXP1_07_PIN + #define E3_SERIAL_TX_PIN EXP1_04_PIN + #define E3_SERIAL_RX_PIN EXP1_04_PIN #endif #else - #define E3_ENABLE_PIN EXP2_04_PIN + #define E3_ENABLE_PIN EXP2_07_PIN #endif // M3 on Driver Expansion Module - #define E4_STEP_PIN EXP2_10_PIN - #define E4_DIR_PIN EXP2_09_PIN + #define E4_STEP_PIN EXP2_01_PIN + #define E4_DIR_PIN EXP2_02_PIN #if !EXP_MOT_USE_EXP2_ONLY - #define E4_ENABLE_PIN EXP1_04_PIN - #define E4_DIAG_PIN EXP1_10_PIN - #define E4_CS_PIN EXP1_09_PIN + #define E4_ENABLE_PIN EXP1_07_PIN + #define E4_DIAG_PIN EXP1_01_PIN + #define E4_CS_PIN EXP1_02_PIN #if HAS_TMC_UART - #define E4_SERIAL_TX_PIN EXP1_09_PIN - #define E4_SERIAL_RX_PIN EXP1_09_PIN + #define E4_SERIAL_TX_PIN EXP1_02_PIN + #define E4_SERIAL_RX_PIN EXP1_02_PIN #endif #else - #define E4_ENABLE_PIN EXP2_04_PIN + #define E4_ENABLE_PIN EXP2_07_PIN #endif #endif // BTT_MOTOR_EXPANSION @@ -434,65 +434,65 @@ #if IS_TFTGLCD_PANEL #if ENABLED(TFTGLCD_PANEL_SPI) - #define TFTGLCD_CS EXP2_08_PIN + #define TFTGLCD_CS EXP2_03_PIN #endif #elif HAS_WIRED_LCD - #define BEEPER_PIN EXP1_10_PIN - #define BTN_ENC EXP1_09_PIN + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN #if ENABLED(CR10_STOCKDISPLAY) - #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_RS EXP1_07_PIN - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN - #define LCD_PINS_ENABLE EXP1_03_PIN - #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN #elif ENABLED(MKS_MINI_12864) - #define DOGLCD_A0 EXP1_04_PIN - #define DOGLCD_CS EXP1_05_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN #else - #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_RS EXP1_04_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN #if ENABLED(FYSETC_MINI_12864) - #define DOGLCD_CS EXP1_08_PIN - #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN //#define LCD_BACKLIGHT_PIN -1 - #define LCD_RESET_PIN EXP1_06_PIN // Must be high or open for LCD to operate normally. + #define LCD_RESET_PIN EXP1_05_PIN // Must be high or open for LCD to operate normally. #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) #ifndef RGB_LED_R_PIN - #define RGB_LED_R_PIN EXP1_05_PIN + #define RGB_LED_R_PIN EXP1_06_PIN #endif #ifndef RGB_LED_G_PIN - #define RGB_LED_G_PIN EXP1_04_PIN + #define RGB_LED_G_PIN EXP1_07_PIN #endif #ifndef RGB_LED_B_PIN - #define RGB_LED_B_PIN EXP1_03_PIN + #define RGB_LED_B_PIN EXP1_08_PIN #endif #elif ENABLED(FYSETC_MINI_12864_2_1) - #define NEOPIXEL_PIN EXP1_05_PIN + #define NEOPIXEL_PIN EXP1_06_PIN #endif #endif // !FYSETC_MINI_12864 #if IS_ULTIPANEL - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder @@ -521,21 +521,21 @@ // // e.g., BTT_TFT35_SPI_V1_0 (480x320, 3.5", SPI Stock Display with Rotary Encoder in BIQU B1 SE) // - #define TFT_CS_PIN EXP2_07_PIN - #define TFT_A0_PIN EXP2_04_PIN - #define TFT_SCK_PIN EXP2_09_PIN - #define TFT_MISO_PIN EXP2_10_PIN - #define TFT_MOSI_PIN EXP2_05_PIN - - #define TOUCH_INT_PIN EXP1_04_PIN - #define TOUCH_MISO_PIN EXP1_05_PIN - #define TOUCH_MOSI_PIN EXP1_08_PIN - #define TOUCH_SCK_PIN EXP1_06_PIN - #define TOUCH_CS_PIN EXP1_07_PIN - - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN - #define BTN_ENC EXP1_09_PIN + #define TFT_CS_PIN EXP2_04_PIN + #define TFT_A0_PIN EXP2_07_PIN + #define TFT_SCK_PIN EXP2_02_PIN + #define TFT_MISO_PIN EXP2_01_PIN + #define TFT_MOSI_PIN EXP2_06_PIN + + #define TOUCH_INT_PIN EXP1_07_PIN + #define TOUCH_MISO_PIN EXP1_06_PIN + #define TOUCH_MOSI_PIN EXP1_03_PIN + #define TOUCH_SCK_PIN EXP1_05_PIN + #define TOUCH_CS_PIN EXP1_04_PIN + + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + #define BTN_ENC EXP1_02_PIN #endif // diff --git a/Marlin/src/pins/teensy2/pins_PRINTRBOARD.h b/Marlin/src/pins/teensy2/pins_PRINTRBOARD.h index 82d9cec894..ddf0d53ea6 100644 --- a/Marlin/src/pins/teensy2/pins_PRINTRBOARD.h +++ b/Marlin/src/pins/teensy2/pins_PRINTRBOARD.h @@ -130,7 +130,7 @@ #define LCD_PINS_D6 5 // D5 JP11-6 #define LCD_PINS_D7 4 // D4 JP11-5 - #if ANY(VIKI2, miniVIKI) + #if EITHER(VIKI2, miniVIKI) #define BEEPER_PIN 8 // E0 JP11-10 #define DOGLCD_A0 40 // F2 JP2-2 diff --git a/Marlin/src/pins/teensy2/pins_PRINTRBOARD_REVF.h b/Marlin/src/pins/teensy2/pins_PRINTRBOARD_REVF.h index 1ac953c89f..1867398087 100644 --- a/Marlin/src/pins/teensy2/pins_PRINTRBOARD_REVF.h +++ b/Marlin/src/pins/teensy2/pins_PRINTRBOARD_REVF.h @@ -207,7 +207,7 @@ #define LCD_PINS_D6 5 // D5 JP11-6 #define LCD_PINS_D7 4 // D4 JP11-5 - #if ANY(VIKI2, miniVIKI) + #if EITHER(VIKI2, miniVIKI) #define BEEPER_PIN 8 // E0 JP11-10 #define DOGLCD_A0 40 // F2 JP2-2 diff --git a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp index a681af4efa..b5968b7021 100644 --- a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp +++ b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp @@ -62,7 +62,7 @@ #define USB_HOST_MANUAL_POLL // Optimization to shut off IRQ automatically // Workarounds to keep Marlin's watchdog timer from barking... - void marlin_yield() { thermalManager.manage_heater(); } + void marlin_yield() { thermalManager.task(); } #define SYSTEM_OR_SPECIAL_YIELD(...) marlin_yield(); #define delay(x) safe_delay(x) @@ -159,18 +159,18 @@ void DiskIODriver_USBFlash::idle() { static uint8_t laststate = 232; if (task_state != laststate) { laststate = task_state; - #define UHS_USB_DEBUG(x) case UHS_STATE(x): SERIAL_ECHOLNPGM(#x); break + #define UHS_USB_DEBUG(x,y) case UHS_STATE(x): SERIAL_ECHOLNPGM(y); break switch (task_state) { - UHS_USB_DEBUG(IDLE); - UHS_USB_DEBUG(RESET_DEVICE); - UHS_USB_DEBUG(RESET_NOT_COMPLETE); - UHS_USB_DEBUG(DEBOUNCE); - UHS_USB_DEBUG(DEBOUNCE_NOT_COMPLETE); - UHS_USB_DEBUG(WAIT_SOF); - UHS_USB_DEBUG(ERROR); - UHS_USB_DEBUG(CONFIGURING); - UHS_USB_DEBUG(CONFIGURING_DONE); - UHS_USB_DEBUG(RUNNING); + UHS_USB_DEBUG(IDLE, "IDLE"); + UHS_USB_DEBUG(RESET_DEVICE, "RESET_DEVICE"); + UHS_USB_DEBUG(RESET_NOT_COMPLETE, "RESET_NOT_COMPLETE"); + UHS_USB_DEBUG(DEBOUNCE, "DEBOUNCE"); + UHS_USB_DEBUG(DEBOUNCE_NOT_COMPLETE, "DEBOUNCE_NOT_COMPLETE"); + UHS_USB_DEBUG(WAIT_SOF, "WAIT_SOF"); + UHS_USB_DEBUG(ERROR, "ERROR"); + UHS_USB_DEBUG(CONFIGURING, "CONFIGURING"); + UHS_USB_DEBUG(CONFIGURING_DONE, "CONFIGURING_DONE"); + UHS_USB_DEBUG(RUNNING, "RUNNING"); default: SERIAL_ECHOLNPGM("UHS_USB_HOST_STATE: ", task_state); break; diff --git a/Marlin/src/sd/usb_flashdrive/lib-uhs2/message.cpp b/Marlin/src/sd/usb_flashdrive/lib-uhs2/message.cpp index dcc309025a..1c1131cd3c 100644 --- a/Marlin/src/sd/usb_flashdrive/lib-uhs2/message.cpp +++ b/Marlin/src/sd/usb_flashdrive/lib-uhs2/message.cpp @@ -59,7 +59,7 @@ void E_NotifyStr(char const * msg, int lvl) { void E_Notify(uint8_t b, int lvl) { if (UsbDEBUGlvl < lvl) return; USB_HOST_SERIAL.print(b - #if !defined(ARDUINO) || ARDUINO < 100 + #if !defined(ARDUINO) && !defined(ARDUINO_ARCH_LPC176X) , DEC #endif ); diff --git a/Marlin/src/tests/marlin_tests.cpp b/Marlin/src/tests/marlin_tests.cpp new file mode 100644 index 0000000000..89e5664345 --- /dev/null +++ b/Marlin/src/tests/marlin_tests.cpp @@ -0,0 +1,47 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program 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. + * + * This program 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 this program. If not, see . + * + */ + +#include "../inc/MarlinConfigPre.h" + +#if ENABLED(MARLIN_TEST_BUILD) + +#include "../module/endstops.h" +#include "../module/motion.h" +#include "../module/planner.h" +#include "../module/settings.h" +#include "../module/stepper.h" +#include "../module/temperature.h" + +// Individual tests are localized in each module. +// Each test produces its own report. + +// Startup tests are run at the end of setup() +void runStartupTests() { + // Call post-setup tests here to validate behaviors. +} + +// Periodic tests are run from within loop() +void runPeriodicTests() { + // Call periodic tests here to validate behaviors. +} + +#endif // MARLIN_TEST_BUILD diff --git a/Marlin/src/advi3pp/screens/core/screen.cpp b/Marlin/src/tests/marlin_tests.h similarity index 63% rename from Marlin/src/advi3pp/screens/core/screen.cpp rename to Marlin/src/tests/marlin_tests.h index 78b374b3dd..6afce1ef37 100644 --- a/Marlin/src/advi3pp/screens/core/screen.cpp +++ b/Marlin/src/tests/marlin_tests.h @@ -1,7 +1,9 @@ /** - * ADVi3++ Firmware For Wanhao Duplicator i3 Plus (based on Marlin 2) + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] * - * Copyright (C) 2017-2020 Sebastien Andrivet [https://github.com/andrivet/] + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,14 +16,10 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . * */ +#pragma once -#include "../../parameters.h" -#include "screen.h" - -namespace ADVi3pp { - - -} +void runStartupTests(); +void runPeriodicTests(); diff --git a/Scripts/version.sh b/Scripts/version.sh index 5368263a5a..3e08363e81 100644 --- a/Scripts/version.sh +++ b/Scripts/version.sh @@ -1 +1 @@ -version="5.4.2" +version="5.5.0" diff --git a/buildroot/bin/build_all_examples b/buildroot/bin/build_all_examples index bce95dce88..a6d6ede47d 100755 --- a/buildroot/bin/build_all_examples +++ b/buildroot/bin/build_all_examples @@ -1,57 +1,97 @@ #!/usr/bin/env bash # -# build_all_examples base_branch [resume_point] +# Usage: # +# build_all_examples [-b|--branch=] - Branch to fetch from Configurations repo +# [-c|--continue] - Continue the paused build +# [-d|--debug] - Print extra debug output +# [-i|--ini] - Archive ini/json/yml files in the temp config folder +# [-l|--limit=#] - Limit the number of builds in this run +# [-n|--nobuild] - Don't actually build anything. +# [-r|--resume=] - Start at some config in the filesystem order +# [-s|--skip] - Do the thing +# +# build_all_examples [...] branch [resume-from] +# + +. mfutil GITREPO=https://github.com/MarlinFirmware/Configurations.git STAT_FILE=./.pio/.buildall -# Check dependencies -which curl 1>/dev/null 2>&1 || { echo "curl not found! Please install it."; exit ; } -which git 1>/dev/null 2>&1 || { echo "git not found! Please install it."; exit ; } +usage() { echo " +Usage: $SELF [-b|--branch=] [-d|--debug] [-i|--ini] [-r|--resume=] + $SELF [-b|--branch=] [-d|--debug] [-i|--ini] [-c|--continue] + $SELF [-b|--branch=] [-d|--debug] [-i|--ini] [-s|--skip] + $SELF [-b|--branch=] [-d|--debug] [-n|--nobuild] + $SELF [...] branch [resume-point] +" +} -SED=$(command -v gsed 2>/dev/null || command -v sed 2>/dev/null) -[[ -z "$SED" ]] && { echo "No sed found, please install sed" ; exit 1 ; } +# Assume the most recent configs +BRANCH=import-2.1.x +unset FIRST_CONF +EXIT_USAGE= +LIMIT=1000 -SELF=`basename "$0"` -HERE=`dirname "$0"` +while getopts 'b:cdhil:nqr:sv-:' OFLAG; do + case "${OFLAG}" in + b) BRANCH=$OPTARG ; bugout "Branch: $BRANCH" ;; + r) FIRST_CONF="$OPTARG" ; bugout "Resume: $FIRST_CONF" ;; + c) CONTINUE=1 ; bugout "Continue" ;; + s) CONTSKIP=1 ; bugout "Continue, skipping" ;; + i) COPY_INI=1 ; bugout "Archive INI/JSON/YML files" ;; + h) EXIT_USAGE=1 ; break ;; + l) LIMIT=$OPTARG ; bugout "Limit to $LIMIT build(s)" ;; + d|v) DEBUG=1 ; bugout "Debug ON" ;; + n) DRYRUN=1 ; bugout "Dry Run" ;; + -) IFS="=" read -r ONAM OVAL <<< "$OPTARG" + case "$ONAM" in + branch) BRANCH=$OVAL ; bugout "Branch: $BRANCH" ;; + resume) FIRST_CONF="$OVAL" ; bugout "Resume: $FIRST_CONF" ;; + continue) CONTINUE=1 ; bugout "Continue" ;; + skip) CONTSKIP=2 ; bugout "Continue, skipping" ;; + limit) LIMIT=$OVAL ; bugout "Limit to $LIMIT build(s)" ;; + ini) COPY_INI=1 ; bugout "Archive INI/JSON/YML files" ;; + help) [[ -z "$OVAL" ]] || perror "option can't take value $OVAL" $ONAM ; EXIT_USAGE=1 ;; + debug) DEBUG=1 ; bugout "Debug ON" ;; + nobuild) DRYRUN=1 ; bugout "Dry Run" ;; + *) EXIT_USAGE=2 ; echo "$SELF: unrecognized option \`--$ONAM'" ; break ;; + esac + ;; + *) EXIT_USAGE=2 ; break ;; + esac +done -# Check if called in the right location -[[ -e "Marlin/src" ]] || { echo -e "This script must be called from a Marlin working copy with:\n ./buildroot/bin/$SELF $1" ; exit ; } +# Extra arguments count as BRANCH, FIRST_CONF +shift $((OPTIND - 1)) +[[ $# > 0 ]] && { BRANCH=$1 ; shift 1 ; bugout "BRANCH=$BRANCH" ; } +[[ $# > 0 ]] && { FIRST_CONF=$1 ; shift 1 ; bugout "FIRST_CONF=$FIRST_CONF" ; } +[[ $# > 0 ]] && { EXIT_USAGE=2 ; echo "too many arguments" ; } -if [[ $# -lt 1 || $# -gt 2 ]]; then - echo "Usage: $SELF base_branch [resume_point] - base_branch - Configuration branch to download and build - resume_point - Configuration path to start from" - exit -fi +((EXIT_USAGE)) && { usage ; let EXIT_USAGE-- ; exit $EXIT_USAGE ; } -echo "This script downloads all Configurations and builds Marlin with each one." +echo "This script downloads each Configuration and attempts to build it." echo "On failure the last-built configs will be left in your working copy." echo "Restore your configs with 'git checkout -f' or 'git reset --hard HEAD'." -unset BRANCH -unset FIRST_CONF if [[ -f "$STAT_FILE" ]]; then IFS='*' read BRANCH FIRST_CONF <"$STAT_FILE" fi # If -c is given start from the last attempted build -if [[ $1 == '-c' ]]; then +if ((CONTINUE)); then if [[ -z $BRANCH || -z $FIRST_CONF ]]; then echo "Nothing to continue" exit fi -elif [[ $1 == '-s' ]]; then +elif ((CONTSKIP)); then if [[ -n $BRANCH && -n $FIRST_CONF ]]; then SKIP_CONF=1 else echo "Nothing to skip" exit fi -else - BRANCH=${1:-"import-2.0.x"} - FIRST_CONF=$2 fi # Check if the current repository has unmerged changes @@ -69,33 +109,63 @@ TMP=./.pio/build-$BRANCH # Download Configurations into the temporary folder if [[ ! -e "$TMP/README.md" ]]; then - echo "Downloading Configurations from GitHub into $TMP" + echo "Fetching Configurations from GitHub to $TMP" git clone --depth=1 --single-branch --branch "$BRANCH" $GITREPO "$TMP" || { echo "Failed to clone the configuration repository"; exit ; } else - echo "Using previously downloaded Configurations at $TMP" + echo "Using cached Configurations at $TMP" fi -echo -e "Start building now...\n=====================" +echo -e "Start build...\n=====================" shopt -s nullglob IFS=' ' CONF_TREE=$( ls -d "$TMP"/config/examples/*/ "$TMP"/config/examples/*/*/ "$TMP"/config/examples/*/*/*/ "$TMP"/config/examples/*/*/*/*/ | grep -vE ".+\.(\w+)$" ) -DOSKIP=0 for CONF in $CONF_TREE ; do + # Get a config's directory name DIR=$( echo $CONF | sed "s|$TMP/config/examples/||" ) + # If looking for a config, skip others [[ $FIRST_CONF ]] && [[ $FIRST_CONF != $DIR && "$FIRST_CONF/" != $DIR ]] && continue # Once found, stop looking unset FIRST_CONF + # If skipping, don't build the found one [[ $SKIP_CONF ]] && { unset SKIP_CONF ; continue ; } + # ...if skipping, don't build this one compgen -G "${CONF}Con*.h" > /dev/null || continue - echo "${BRANCH}*${DIR}" >"$STAT_FILE" - "$HERE/build_example" "internal" "$TMP" "$DIR" || { echo "Failed to build $DIR"; exit ; } + + # Build or print build command for --nobuild + if [[ $DRYRUN ]]; then + echo -e "\033[0;32m[DRYRUN] build_example internal \"$TMP\" \"$DIR\"\033[0m" + else + # Remember where we are in case of failure + echo "${BRANCH}*${DIR}" >"$STAT_FILE" + # Build folder is unknown so delete all report files + if [[ $COPY_INI ]]; then + IFIND='find ./.pio/build/ -name "config.ini" -o -name "schema.json" -o -name "schema.yml"' + $IFIND -exec rm "{}" \; + fi + ((DEBUG)) && echo "\"$HERE/build_example\" internal \"$TMP\" \"$DIR\"" + "$HERE/build_example" internal "$TMP" "$DIR" || { echo "Failed to build $DIR"; exit ; } + # Build folder is unknown so copy all report files + [[ $COPY_INI ]] && $IFIND -exec cp "{}" "$CONF" \; + fi + + ((--LIMIT)) || { echo "Limit reached" ; PAUSE=1 ; break ; } + done -# Delete the temp folder and build state -[[ -e "$TMP/config/examples" ]] && rm -rf "$TMP" -rm "$STAT_FILE" +# Delete the build state if not paused early +[[ $PAUSE ]] || rm "$STAT_FILE" + +# Delete the temp folder if not preserving generated INI files +if [[ -e "$TMP/config/examples" ]]; then + if [[ $COPY_INI ]]; then + OPEN=$( which gnome-open xdg-open open | head -n1 ) + $OPEN "$TMP" + elif [[ ! $PAUSE ]]; then + rm -rf "$TMP" + fi +fi diff --git a/buildroot/bin/build_example b/buildroot/bin/build_example index cff8ea253e..34549769bb 100755 --- a/buildroot/bin/build_example +++ b/buildroot/bin/build_example @@ -5,6 +5,8 @@ # Usage: build_example internal config-home config-folder # +. mfutil + # Require 'internal' as the first argument [[ "$1" == "internal" ]] || { echo "Don't call this script directly, use build_all_examples instead." ; exit 1 ; } @@ -22,8 +24,15 @@ cp "$SUB"/Configuration_adv.h Marlin/ 2>/dev/null cp "$SUB"/_Bootscreen.h Marlin/ 2>/dev/null cp "$SUB"/_Statusscreen.h Marlin/ 2>/dev/null +set -e + +# Strip #error lines from Configuration.h +IFS=$'\n'; set -f +$SED -i~ -e "20,30{/#error/d}" Marlin/Configuration.h +rm Marlin/Configuration.h~ +unset IFS; set +f + echo "Building the firmware now..." -HERE=`dirname "$0"` $HERE/mftest -s -a -n1 || { echo "Failed"; exit 1; } echo "Success" diff --git a/buildroot/bin/mftest b/buildroot/bin/mftest index 9aa5e12732..8a4f3afd4f 100755 --- a/buildroot/bin/mftest +++ b/buildroot/bin/mftest @@ -3,7 +3,7 @@ # mftest Select a test to apply and build # mftest -b [#] Build the auto-detected environment # mftest -u [#] Upload the auto-detected environment -# mftest [name] [index] [-y] Set config options and optionally build a test +# mftest -tname -n# [-y] Set config options and optionally build a test # [[ -d Marlin/src ]] || { echo "Please 'cd' to the Marlin repo root." ; exit 1 ; } @@ -30,6 +30,7 @@ OPTIONS -u --autoupload PIO Upload using the MOTHERBOARD environment. -v --verbose Extra output for debugging. -s --silent Silence build output from PlatformIO. + -d --default Restore to defaults before applying configs. env shortcuts: tree due esp lin lp8|lpc8 lp9|lpc9 m128 m256|mega stm|f1 f4 f7 s6 teensy|t31|t32 t35|t36 t40|t41 " @@ -44,6 +45,7 @@ shopt -s extglob nocasematch # Matching patterns ISNUM='^[0-9]+$' +ISRST='^(restore)_' ISCMD='^(restore|opt|exec|use|pins|env)_' ISEXEC='^exec_' ISCONT='\\ *$' @@ -53,9 +55,10 @@ TESTENV='-' CHOICE=0 DEBUG=0 -while getopts 'abhmrsuvyn:t:-:' OFLAG; do +while getopts 'abdhmrsuvyn:t:-:' OFLAG; do case "${OFLAG}" in a) AUTO_BUILD=1 ; bugout "Auto-Build target..." ;; + d) DL_DEFAULTS=1 ; bugout "Restore to defaults..." ;; h) EXIT_USAGE=1 ;; m) USE_MAKE=1 ; bugout "Using make with Docker..." ;; n) case "$OPTARG" in @@ -88,6 +91,7 @@ while getopts 'abhmrsuvyn:t:-:' OFLAG; do silent) SILENT_FLAG="-s" ;; make) USE_MAKE=1 ; bugout "Using make with Docker..." ;; debug|verbose) DEBUG=1 ; bugout "Debug ON" ;; + default) DL_DEFAULTS=1 ; bugout "Restore to defaults..." ;; build) case "$OVAL" in ''|y|yes) BUILD_YES='Y' ;; n|no) BUILD_YES='N' ;; @@ -282,6 +286,11 @@ if [[ $CHOICE == 0 ]]; then fi fi +# +# Restore to defaults if requested +# +((DL_DEFAULTS)) && use_example_configs + # # Run the specified test lines # @@ -303,6 +312,7 @@ echo "$OUT" | { } ((IND == CHOICE)) && { GOTX=1 + [[ -n $DL_DEFAULTS && $LINE =~ $ISRST ]] && LINE="use_example_configs" [[ $CMD == "" ]] && CMD="$LINE" || CMD=$( echo -e "$CMD$LINE" | $SED -e 's/\\//g' | $SED -E 's/ +/ /g' ) [[ $LINE =~ $ISCONT ]] || { echo "$CMD" ; eval "$CMD" ; CMD="" ; } } diff --git a/buildroot/bin/mfutil b/buildroot/bin/mfutil new file mode 100755 index 0000000000..75a2791cfe --- /dev/null +++ b/buildroot/bin/mfutil @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +# +# mfutil - check env and define helpers +# + +# Check dependencies +which curl 1>/dev/null 2>&1 || { echo "curl not found! Please install it."; exit ; } +which git 1>/dev/null 2>&1 || { echo "git not found! Please install it."; exit ; } + +SED=$(command -v gsed 2>/dev/null || command -v sed 2>/dev/null) +[[ -z "$SED" ]] && { echo "No sed found, please install sed" ; exit 1 ; } + +OPEN=$( which gnome-open xdg-open open | head -n1 ) + +SELF=`basename "$0"` +HERE=`dirname "$0"` + +# Check if called in the right location +[[ -e "Marlin/src" ]] || { echo -e "This script must be called from a Marlin working copy with:\n ./buildroot/bin/$SELF $1" ; exit ; } + +perror() { echo -e "$0: \033[0;31m$1 -- $2\033[0m" ; } +bugout() { ((DEBUG)) && echo -e "\033[0;32m$1\033[0m" ; } diff --git a/buildroot/bin/restore_configs b/buildroot/bin/restore_configs index 61aa3f9ee1..ea998484c2 100755 --- a/buildroot/bin/restore_configs +++ b/buildroot/bin/restore_configs @@ -1,5 +1,11 @@ #!/usr/bin/env bash -git checkout Marlin/Configuration*.h 2>/dev/null -git checkout Marlin/src/pins/ramps/pins_RAMPS.h 2>/dev/null rm -f Marlin/_Bootscreen.h Marlin/_Statusscreen.h marlin_config.json .pio/build/mc.zip + +if [[ $1 == '-d' || $1 == '--default' ]]; then + use_example_configs +else + git checkout Marlin/Configuration.h 2>/dev/null + git checkout Marlin/Configuration_adv.h 2>/dev/null + git checkout Marlin/src/pins/ramps/pins_RAMPS.h 2>/dev/null +fi diff --git a/buildroot/bin/use_example_configs b/buildroot/bin/use_example_configs index bfd4aa612f..1fdab1de6c 100755 --- a/buildroot/bin/use_example_configs +++ b/buildroot/bin/use_example_configs @@ -3,33 +3,42 @@ # use_example_configs [repo:]configpath # # Examples: +# use_example_configs # use_example_configs Creality/CR-10/CrealityV1 # use_example_configs release-2.0.9.4:Creality/CR-10/CrealityV1 # # If a configpath has spaces (or quotes) escape them or enquote the path # +which curl >/dev/null && TOOL='curl -L -s -S -f -o wgot' +which wget >/dev/null && TOOL='wget -q -O wgot' + CURR=$(git branch 2>/dev/null | grep ^* | sed 's/\* //g') [[ $CURR == "bugfix-2.0.x" ]] && BRANCH=bugfix-2.0.x || BRANCH=bugfix-2.1.x -IFS=: read -r PART1 PART2 <<< "$@" -[[ -n $PART2 ]] && { REPO="$PART1" ; RDIR="${PART2// /%20}" ; } \ - || { REPO=$BRANCH ; RDIR="${PART1// /%20}" ; } -EXAMPLES="https://raw.githubusercontent.com/MarlinFirmware/Configurations/$REPO/config/examples" +REPO=$BRANCH -which curl >/dev/null && TOOL='curl -L -s -S -f -o wgot' -which wget >/dev/null && TOOL='wget -q -O wgot' +if [[ $# > 0 ]]; then + IFS=: read -r PART1 PART2 <<< "$@" + [[ -n $PART2 ]] && { UDIR="$PART2" ; REPO="$PART1" ; } \ + || { UDIR="$PART1" ; } + RDIR="${UDIR// /%20}" + echo "Fetching $UDIR configurations from $REPO..." + EXAMPLES="examples/$RDIR" +else + EXAMPLES="default" +fi + +CONFIGS="https://raw.githubusercontent.com/MarlinFirmware/Configurations/$REPO/config/${EXAMPLES}" restore_configs cd Marlin -echo "Fetching $RDIR configurations from $REPO..." - -$TOOL "$EXAMPLES/$RDIR/Configuration.h" >/dev/null 2>&1 && mv wgot Configuration.h -$TOOL "$EXAMPLES/$RDIR/Configuration_adv.h" >/dev/null 2>&1 && mv wgot Configuration_adv.h -$TOOL "$EXAMPLES/$RDIR/_Bootscreen.h" >/dev/null 2>&1 && mv wgot _Bootscreen.h -$TOOL "$EXAMPLES/$RDIR/_Statusscreen.h" >/dev/null 2>&1 && mv wgot _Statusscreen.h +$TOOL "$CONFIGS/Configuration.h" >/dev/null 2>&1 && mv wgot Configuration.h +$TOOL "$CONFIGS/Configuration_adv.h" >/dev/null 2>&1 && mv wgot Configuration_adv.h +$TOOL "$CONFIGS/_Bootscreen.h" >/dev/null 2>&1 && mv wgot _Bootscreen.h +$TOOL "$CONFIGS/_Statusscreen.h" >/dev/null 2>&1 && mv wgot _Statusscreen.h rm -f wgot cd - >/dev/null diff --git a/buildroot/share/PlatformIO/boards/marlin_STEVAL_STM32F401VE.json b/buildroot/share/PlatformIO/boards/marlin_STEVAL_STM32F401VE.json deleted file mode 100644 index e260950f25..0000000000 --- a/buildroot/share/PlatformIO/boards/marlin_STEVAL_STM32F401VE.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "build": { - "core": "stm32", - "cpu": "cortex-m4", - "extra_flags": "-DSTM32F401xx -DARDUINO_STEVAL", - "f_cpu": "84000000L", - "hwids": [ - [ - "0x1EAF", - "0x0003" - ], - [ - "0x0483", - "0x3748" - ] - ], - "mcu": "stm32f401vet6", - "variant": "MARLIN_STEVAL_F401VE" - }, - "debug": { - "jlink_device": "STM32F401VE", - "openocd_target": "stm32f4x", - "svd_path": "STM32F40x.svd", - "tools": { - "stlink": { - "server": { - "arguments": [ - "-f", - "scripts/interface/stlink.cfg", - "-c", - "transport select hla_swd", - "-f", - "scripts/target/stm32f4x.cfg", - "-c", - "reset_config none" - ], - "executable": "bin/openocd", - "package": "tool-openocd" - } - } - } - }, - "frameworks": [ - "arduino", - "stm32cube" - ], - "name": "STM32F401VE (96k RAM. 512k Flash)", - "upload": { - "disable_flushing": false, - "maximum_ram_size": 98304, - "maximum_size": 514288, - "protocol": "stlink", - "protocols": [ - "stlink", - "dfu", - "jlink" - ], - "require_upload_port": true, - "use_1200bps_touch": false, - "wait_for_upload_port": false - }, - "url": "https://www.st.com/en/evaluation-tools/steval-3dp001v1.html", - "vendor": "Generic" -} diff --git a/buildroot/share/PlatformIO/boards/marlin_index_mobo_rev03.json b/buildroot/share/PlatformIO/boards/marlin_opulo_lumen_rev3.json similarity index 100% rename from buildroot/share/PlatformIO/boards/marlin_index_mobo_rev03.json rename to buildroot/share/PlatformIO/boards/marlin_opulo_lumen_rev3.json diff --git a/buildroot/share/PlatformIO/debugging/launch.json b/buildroot/share/PlatformIO/debugging/launch.json index 583d860eb3..f9936ebced 100644 --- a/buildroot/share/PlatformIO/debugging/launch.json +++ b/buildroot/share/PlatformIO/debugging/launch.json @@ -25,15 +25,26 @@ "svdFile": "${env:HOME}/.platformio/platforms/ststm32@12.1.1/misc/svd/STM32F40x.svd", }, { - "name": "Debug Sim", + "name": "Launch Sim (ggdb)", "request": "launch", "type": "cppdbg", "cwd": "${workspaceRoot}", - //"program": ".pio/build/simulator_linux_debug/MarlinSimulator", - //"program": ".pio/build/simulator_windows/MarlinSimulator", - "program": ".pio/build/simulator_macos_debug/MarlinSimulator", + "program": "${workspaceRoot}/.pio/build/simulator_macos_debug/debug/MarlinSimulator", + //"program": "${workspaceRoot}/.pio/build/simulator_linux_debug/MarlinSimulator", + //"program": "${workspaceRoot}/.pio/build/simulator_windows/MarlinSimulator", "miDebuggerPath": "/opt/local/bin/ggdb", "MIMode": "gdb" + }, + { + "name": "Launch Sim (lldb)", + "request": "launch", + "type": "cppdbg", + "cwd": "${workspaceRoot}", + "program": "${workspaceRoot}/.pio/build/simulator_macos_debug/debug/MarlinSimulator", + //"program": "${workspaceRoot}/.pio/build/simulator_linux_debug/MarlinSimulator", + //"program": "${workspaceRoot}/.pio/build/simulator_windows/MarlinSimulator", + //"targetArchitecture": "arm64", + "MIMode": "lldb" } ] } diff --git a/buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py b/buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py index 592fa50e5e..0eab7a8361 100644 --- a/buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py +++ b/buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py @@ -3,30 +3,29 @@ # import pioutil if pioutil.is_pio_build(): - import os,shutil,marlin - from SCons.Script import DefaultEnvironment - from platformio import util + import shutil,marlin + from pathlib import Path - env = DefaultEnvironment() + Import("env") platform = env.PioPlatform() board = env.BoardConfig() - FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoststm32-maple") - assert os.path.isdir(FRAMEWORK_DIR) + FRAMEWORK_DIR = Path(platform.get_package_dir("framework-arduinoststm32-maple")) + assert FRAMEWORK_DIR.is_dir() - source_root = os.path.join("buildroot", "share", "PlatformIO", "variants") - assert os.path.isdir(source_root) + source_root = Path("buildroot/share/PlatformIO/variants") + assert source_root.is_dir() variant = board.get("build.variant") - variant_dir = os.path.join(FRAMEWORK_DIR, "STM32F1", "variants", variant) + variant_dir = FRAMEWORK_DIR / "STM32F1/variants" / variant - source_dir = os.path.join(source_root, variant) - assert os.path.isdir(source_dir) + source_dir = source_root / variant + assert source_dir.is_dir() - if os.path.isdir(variant_dir): + if variant_dir.is_dir(): shutil.rmtree(variant_dir) - if not os.path.isdir(variant_dir): - os.mkdir(variant_dir) + if not variant_dir.is_dir(): + variant_dir.mkdir() marlin.copytree(source_dir, variant_dir) diff --git a/buildroot/share/PlatformIO/scripts/chitu_crypt.py b/buildroot/share/PlatformIO/scripts/chitu_crypt.py index b28156bfb9..76792030cf 100644 --- a/buildroot/share/PlatformIO/scripts/chitu_crypt.py +++ b/buildroot/share/PlatformIO/scripts/chitu_crypt.py @@ -4,9 +4,9 @@ # import pioutil if pioutil.is_pio_build(): - import os,random,struct,uuid,marlin - # Relocate firmware from 0x08000000 to 0x08008800 - marlin.relocate_firmware("0x08008800") + import struct,uuid,marlin + + board = marlin.env.BoardConfig() def calculate_crc(contents, seed): accumulating_xor_value = seed; @@ -105,13 +105,22 @@ def encrypt_file(input, output_file, file_length): # Encrypt ${PROGNAME}.bin and save it as 'update.cbd' def encrypt(source, target, env): - firmware = open(target[0].path, "rb") - update = open(target[0].dir.path + '/update.cbd', "wb") - length = os.path.getsize(target[0].path) + from pathlib import Path + + fwpath = Path(target[0].path) + fwsize = fwpath.stat().st_size - encrypt_file(firmware, update, length) + enname = board.get("build.crypt_chitu") + enpath = Path(target[0].dir.path) - firmware.close() - update.close() + fwfile = fwpath.open("rb") + enfile = (enpath / enname).open("wb") + print(f"Encrypting {fwpath} to {enname}") + encrypt_file(fwfile, enfile, fwsize) + fwfile.close() + enfile.close() + fwpath.unlink() + + marlin.relocate_firmware("0x08008800") marlin.add_post_action(encrypt); diff --git a/buildroot/share/PlatformIO/scripts/common-dependencies.py b/buildroot/share/PlatformIO/scripts/common-dependencies.py index e9e8c79187..4b986274ee 100644 --- a/buildroot/share/PlatformIO/scripts/common-dependencies.py +++ b/buildroot/share/PlatformIO/scripts/common-dependencies.py @@ -56,7 +56,7 @@ def add_to_feat_cnf(feature, flines): # Split up passed lines on commas or newlines and iterate # Add common options to the features config under construction # For lib_deps replace a previous instance of the same library - atoms = re.sub(r',\\s*', '\n', flines).strip().split('\n') + atoms = re.sub(r',\s*', '\n', flines).strip().split('\n') for line in atoms: parts = line.split('=') name = parts.pop(0) @@ -64,16 +64,15 @@ def add_to_feat_cnf(feature, flines): feat[name] = '='.join(parts) blab("[%s] %s=%s" % (feature, name, feat[name]), 3) else: - for dep in re.split(r",\s*", line): + for dep in re.split(r',\s*', line): lib_name = re.sub(r'@([~^]|[<>]=?)?[\d.]+', '', dep.strip()).split('=').pop(0) lib_re = re.compile('(?!^' + lib_name + '\\b)') feat['lib_deps'] = list(filter(lib_re.match, feat['lib_deps'])) + [dep] blab("[%s] lib_deps = %s" % (feature, dep), 3) - def load_config(): + def load_features(): blab("========== Gather [features] entries...") - items = ProjectConfig().items('features') - for key in items: + for key in ProjectConfig().items('features'): feature = key[0].upper() if not feature in FEATURE_CONFIG: FEATURE_CONFIG[feature] = { 'lib_deps': [] } @@ -81,8 +80,7 @@ def load_config(): # Add options matching custom_marlin.MY_OPTION to the pile blab("========== Gather custom_marlin entries...") - all_opts = env.GetProjectOptions() - for n in all_opts: + for n in env.GetProjectOptions(): key = n[0] mat = re.match(r'custom_marlin\.(.+)', key) if mat: @@ -91,7 +89,7 @@ def load_config(): except: val = None if val: - opt = mat.group(1).upper() + opt = mat[1].upper() blab("%s.custom_marlin.%s = '%s'" % ( env['PIOENV'], opt, val )) add_to_feat_cnf(opt, val) @@ -127,10 +125,10 @@ def force_ignore_unused_libs(): set_env_field('lib_ignore', lib_ignore) def apply_features_config(): - load_config() + load_features() blab("========== Apply enabled features...") for feature in FEATURE_CONFIG: - if not env.MarlinFeatureIsEnabled(feature): + if not env.MarlinHas(feature): continue feat = FEATURE_CONFIG[feature] @@ -212,7 +210,7 @@ def load_marlin_features(): # # Return True if a matching feature is enabled # - def MarlinFeatureIsEnabled(env, feature): + def MarlinHas(env, feature): load_marlin_features() r = re.compile('^' + feature + '$') found = list(filter(r.match, env['MARLIN_FEATURES'])) @@ -225,7 +223,7 @@ def MarlinFeatureIsEnabled(env, feature): if val in [ '', '1', 'true' ]: some_on = True elif val in env['MARLIN_FEATURES']: - some_on = env.MarlinFeatureIsEnabled(val) + some_on = env.MarlinHas(val) return some_on @@ -239,7 +237,7 @@ def MarlinFeatureIsEnabled(env, feature): # # Add a method for other PIO scripts to query enabled features # - env.AddMethod(MarlinFeatureIsEnabled) + env.AddMethod(MarlinHas) # # Add dependencies for enabled Marlin features diff --git a/buildroot/share/PlatformIO/scripts/configuration.py b/buildroot/share/PlatformIO/scripts/configuration.py new file mode 100644 index 0000000000..3ab0295749 --- /dev/null +++ b/buildroot/share/PlatformIO/scripts/configuration.py @@ -0,0 +1,239 @@ +# +# configuration.py +# Apply options from config.ini to the existing Configuration headers +# +import re, shutil, configparser +from pathlib import Path + +verbose = 0 +def blab(str,level=1): + if verbose >= level: print(f"[config] {str}") + +def config_path(cpath): + return Path("Marlin", cpath) + +# Apply a single name = on/off ; name = value ; etc. +# TODO: Limit to the given (optional) configuration +def apply_opt(name, val, conf=None): + if name == "lcd": name, val = val, "on" + + # Create a regex to match the option and capture parts of the line + regex = re.compile(rf'^(\s*)(//\s*)?(#define\s+)({name}\b)(\s*)(.*?)(\s*)(//.*)?$', re.IGNORECASE) + + # Find and enable and/or update all matches + for file in ("Configuration.h", "Configuration_adv.h"): + fullpath = config_path(file) + lines = fullpath.read_text().split('\n') + found = False + for i in range(len(lines)): + line = lines[i] + match = regex.match(line) + if match and match[4].upper() == name.upper(): + found = True + # For boolean options un/comment the define + if val in ("on", "", None): + newline = re.sub(r'^(\s*)//+\s*(#define)(\s{1,3})?(\s*)', r'\1\2 \4', line) + elif val == "off": + newline = re.sub(r'^(\s*)(#define)(\s{1,3})?(\s*)', r'\1//\2 \4', line) + else: + # For options with values, enable and set the value + newline = match[1] + match[3] + match[4] + match[5] + val + if match[8]: + sp = match[7] if match[7] else ' ' + newline += sp + match[8] + lines[i] = newline + blab(f"Set {name} to {val}") + + # If the option was found, write the modified lines + if found: + fullpath.write_text('\n'.join(lines)) + break + + # If the option didn't appear in either config file, add it + if not found: + # OFF options are added as disabled items so they appear + # in config dumps. Useful for custom settings. + prefix = "" + if val == "off": + prefix, val = "//", "" # Item doesn't appear in config dump + #val = "false" # Item appears in config dump + + # Uppercase the option unless already mixed/uppercase + added = name.upper() if name.islower() else name + + # Add the provided value after the name + if val != "on" and val != "" and val is not None: + added += " " + val + + # Prepend the new option after the first set of #define lines + fullpath = config_path("Configuration.h") + with fullpath.open() as f: + lines = f.readlines() + linenum = 0 + gotdef = False + for line in lines: + isdef = line.startswith("#define") + if not gotdef: + gotdef = isdef + elif not isdef: + break + linenum += 1 + lines.insert(linenum, f"{prefix}#define {added} // Added by config.ini\n") + fullpath.write_text('\n'.join(lines)) + +# Fetch configuration files from GitHub given the path. +# Return True if any files were fetched. +def fetch_example(path): + if path.endswith("/"): + path = path[:-1] + + if '@' in path: + path, brch = map(strip, path.split('@')) + + url = path.replace("%", "%25").replace(" ", "%20") + if not path.startswith('http'): + url = "https://raw.githubusercontent.com/MarlinFirmware/Configurations/bugfix-2.1.x/config/%s" % url + + # Find a suitable fetch command + if shutil.which("curl") is not None: + fetch = "curl -L -s -S -f -o" + elif shutil.which("wget") is not None: + fetch = "wget -q -O" + else: + blab("Couldn't find curl or wget", -1) + return False + + import os + + # Reset configurations to default + os.system("git reset --hard HEAD") + + gotfile = False + + # Try to fetch the remote files + for fn in ("Configuration.h", "Configuration_adv.h", "_Bootscreen.h", "_Statusscreen.h"): + if os.system("%s wgot %s/%s >/dev/null 2>&1" % (fetch, url, fn)) == 0: + shutil.move('wgot', config_path(fn)) + gotfile = True + + if Path('wgot').exists(): + shutil.rmtree('wgot') + + return gotfile + +def section_items(cp, sectkey): + return cp.items(sectkey) if sectkey in cp.sections() else [] + +# Apply all items from a config section +def apply_ini_by_name(cp, sect): + iniok = True + if sect in ('config:base', 'config:root'): + iniok = False + items = section_items(cp, 'config:base') + section_items(cp, 'config:root') + else: + items = cp.items(sect) + + for item in items: + if iniok or not item[0].startswith('ini_'): + apply_opt(item[0], item[1]) + +# Apply all config sections from a parsed file +def apply_all_sections(cp): + for sect in cp.sections(): + if sect.startswith('config:'): + apply_ini_by_name(cp, sect) + +# Apply certain config sections from a parsed file +def apply_sections(cp, ckey='all', addbase=False): + blab("[config] apply section key: %s" % ckey) + if ckey == 'all': + apply_all_sections(cp) + else: + # Apply the base/root config.ini settings after external files are done + if addbase or ckey in ('base', 'root'): + apply_ini_by_name(cp, 'config:base') + + # Apply historically 'Configuration.h' settings everywhere + if ckey == 'basic': + apply_ini_by_name(cp, 'config:basic') + + # Apply historically Configuration_adv.h settings everywhere + # (Some of which rely on defines in 'Conditionals_LCD.h') + elif ckey in ('adv', 'advanced'): + apply_ini_by_name(cp, 'config:advanced') + + # Apply a specific config: section directly + elif ckey.startswith('config:'): + apply_ini_by_name(cp, ckey) + +# Apply settings from a top level config.ini +def apply_config_ini(cp): + blab("=" * 20 + " Gather 'config.ini' entries...") + + # Pre-scan for ini_use_config to get config_keys + base_items = section_items(cp, 'config:base') + section_items(cp, 'config:root') + config_keys = ['base'] + for ikey, ival in base_items: + if ikey == 'ini_use_config': + config_keys = [ x.strip() for x in ival.split(',') ] + + # For each ini_use_config item perform an action + for ckey in config_keys: + addbase = False + + # For a key ending in .ini load and parse another .ini file + if ckey.endswith('.ini'): + sect = 'base' + if '@' in ckey: sect, ckey = ckey.split('@') + other_ini = configparser.ConfigParser() + other_ini.read(config_path(ckey)) + apply_sections(other_ini, sect) + + # (Allow 'example/' as a shortcut for 'examples/') + elif ckey.startswith('example/'): + ckey = 'examples' + ckey[7:] + + # For 'examples/' fetch an example set from GitHub. + # For https?:// do a direct fetch of the URL. + elif ckey.startswith('examples/') or ckey.startswith('http'): + addbase = True + fetch_example(ckey) + + # Apply keyed sections after external files are done + apply_sections(cp, 'config:' + ckey, addbase) + +if __name__ == "__main__": + # + # From command line use the given file name + # + import sys + args = sys.argv[1:] + if len(args) > 0: + if args[0].endswith('.ini'): + ini_file = args[0] + else: + print("Usage: %s <.ini file>" % sys.argv[0]) + else: + ini_file = config_path('config.ini') + + if ini_file: + user_ini = configparser.ConfigParser() + user_ini.read(ini_file) + apply_config_ini(user_ini) + +else: + # + # From within PlatformIO use the loaded INI file + # + import pioutil + if pioutil.is_pio_build(): + + Import("env") + + try: + verbose = int(env.GetProjectOption('custom_verbose')) + except: + pass + + from platformio.project.config import ProjectConfig + apply_config_ini(ProjectConfig()) diff --git a/buildroot/share/PlatformIO/scripts/download_mks_assets.py b/buildroot/share/PlatformIO/scripts/download_mks_assets.py index 1990400222..8d186b755f 100644 --- a/buildroot/share/PlatformIO/scripts/download_mks_assets.py +++ b/buildroot/share/PlatformIO/scripts/download_mks_assets.py @@ -5,45 +5,49 @@ import pioutil if pioutil.is_pio_build(): Import("env") - import os,requests,zipfile,tempfile,shutil + import requests,zipfile,tempfile,shutil + from pathlib import Path url = "https://github.com/makerbase-mks/Mks-Robin-Nano-Marlin2.0-Firmware/archive/0263cdaccf.zip" - deps_path = env.Dictionary("PROJECT_LIBDEPS_DIR") - zip_path = os.path.join(deps_path, "mks-assets.zip") - assets_path = os.path.join(env.Dictionary("PROJECT_BUILD_DIR"), env.Dictionary("PIOENV"), "assets") + deps_path = Path(env.Dictionary("PROJECT_LIBDEPS_DIR")) + zip_path = deps_path / "mks-assets.zip" + assets_path = Path(env.Dictionary("PROJECT_BUILD_DIR"), env.Dictionary("PIOENV"), "assets") def download_mks_assets(): print("Downloading MKS Assets") r = requests.get(url, stream=True) # the user may have a very clean workspace, # so create the PROJECT_LIBDEPS_DIR directory if not exits - if os.path.exists(deps_path) == False: - os.mkdir(deps_path) - with open(zip_path, 'wb') as fd: + if not deps_path.exists(): + deps_path.mkdir() + with zip_path.open('wb') as fd: for chunk in r.iter_content(chunk_size=128): fd.write(chunk) def copy_mks_assets(): print("Copying MKS Assets") - output_path = tempfile.mkdtemp() + output_path = Path(tempfile.mkdtemp()) zip_obj = zipfile.ZipFile(zip_path, 'r') zip_obj.extractall(output_path) zip_obj.close() - if os.path.exists(assets_path) == True and os.path.isdir(assets_path) == False: - os.unlink(assets_path) - if os.path.exists(assets_path) == False: - os.mkdir(assets_path) + if assets_path.exists() and not assets_path.is_dir(): + assets_path.unlink() + if not assets_path.exists(): + assets_path.mkdir() base_path = '' - for filename in os.listdir(output_path): + for filename in output_path.iterdir(): base_path = filename - for filename in os.listdir(os.path.join(output_path, base_path, 'Firmware', 'mks_font')): - shutil.copy(os.path.join(output_path, base_path, 'Firmware', 'mks_font', filename), assets_path) - for filename in os.listdir(os.path.join(output_path, base_path, 'Firmware', 'mks_pic')): - shutil.copy(os.path.join(output_path, base_path, 'Firmware', 'mks_pic', filename), assets_path) + fw_path = (output_path / base_path / 'Firmware') + font_path = fw_path / 'mks_font' + for filename in font_path.iterdir(): + shutil.copy(font_path / filename, assets_path) + pic_path = fw_path / 'mks_pic' + for filename in pic_path.iterdir(): + shutil.copy(pic_path / filename, assets_path) shutil.rmtree(output_path, ignore_errors=True) - if os.path.exists(zip_path) == False: + if not zip_path.exists(): download_mks_assets() - if os.path.exists(assets_path) == False: + if not assets_path.exists(): copy_mks_assets() diff --git a/buildroot/share/PlatformIO/scripts/fix_framework_weakness.py b/buildroot/share/PlatformIO/scripts/fix_framework_weakness.py index 663e7c76d9..83ed17ccca 100644 --- a/buildroot/share/PlatformIO/scripts/fix_framework_weakness.py +++ b/buildroot/share/PlatformIO/scripts/fix_framework_weakness.py @@ -10,7 +10,7 @@ Import("env") - if env.MarlinFeatureIsEnabled("POSTMORTEM_DEBUGGING"): + if env.MarlinHas("POSTMORTEM_DEBUGGING"): FRAMEWORK_DIR = env.PioPlatform().get_package_dir("framework-arduinoststm32-maple") patchflag_path = join(FRAMEWORK_DIR, ".exc-patching-done") diff --git a/buildroot/share/PlatformIO/scripts/generic_create_variant.py b/buildroot/share/PlatformIO/scripts/generic_create_variant.py index d572873ad7..5e3637604f 100644 --- a/buildroot/share/PlatformIO/scripts/generic_create_variant.py +++ b/buildroot/share/PlatformIO/scripts/generic_create_variant.py @@ -7,20 +7,22 @@ # import pioutil if pioutil.is_pio_build(): - import os,shutil,marlin - from SCons.Script import DefaultEnvironment - from platformio import util - - env = DefaultEnvironment() + import shutil,marlin + from pathlib import Path # # Get the platform name from the 'platform_packages' option, # or look it up by the platform.class.name. # + env = marlin.env platform = env.PioPlatform() from platformio.package.meta import PackageSpec platform_packages = env.GetProjectOption('platform_packages') + + # Remove all tool items from platform_packages + platform_packages = [x for x in platform_packages if not x.startswith("platformio/tool-")] + if len(platform_packages) == 0: framewords = { "Ststm32Platform": "framework-arduinoststm32", @@ -33,8 +35,8 @@ if platform_name in [ "usb-host-msc", "usb-host-msc-cdc-msc", "usb-host-msc-cdc-msc-2", "usb-host-msc-cdc-msc-3", "tool-stm32duino", "biqu-bx-workaround", "main" ]: platform_name = "framework-arduinoststm32" - FRAMEWORK_DIR = platform.get_package_dir(platform_name) - assert os.path.isdir(FRAMEWORK_DIR) + FRAMEWORK_DIR = Path(platform.get_package_dir(platform_name)) + assert FRAMEWORK_DIR.is_dir() board = env.BoardConfig() @@ -43,14 +45,14 @@ #series = mcu_type[:7].upper() + "xx" # Prepare a new empty folder at the destination - variant_dir = os.path.join(FRAMEWORK_DIR, "variants", variant) - if os.path.isdir(variant_dir): + variant_dir = FRAMEWORK_DIR / "variants" / variant + if variant_dir.is_dir(): shutil.rmtree(variant_dir) - if not os.path.isdir(variant_dir): - os.mkdir(variant_dir) + if not variant_dir.is_dir(): + variant_dir.mkdir() # Source dir is a local variant sub-folder - source_dir = os.path.join("buildroot/share/PlatformIO/variants", variant) - assert os.path.isdir(source_dir) + source_dir = Path("buildroot/share/PlatformIO/variants", variant) + assert source_dir.is_dir() marlin.copytree(source_dir, variant_dir) diff --git a/buildroot/share/PlatformIO/scripts/jgaurora_a5s_a1_with_bootloader.py b/buildroot/share/PlatformIO/scripts/jgaurora_a5s_a1_with_bootloader.py index 0af9c1046d..b9516931b5 100644 --- a/buildroot/share/PlatformIO/scripts/jgaurora_a5s_a1_with_bootloader.py +++ b/buildroot/share/PlatformIO/scripts/jgaurora_a5s_a1_with_bootloader.py @@ -4,37 +4,32 @@ # import pioutil if pioutil.is_pio_build(): - import os,marlin + # Append ${PROGNAME}.bin firmware after bootloader and save it as 'jgaurora_firmware.bin' def addboot(source, target, env): - firmware = open(target[0].path, "rb") - lengthfirmware = os.path.getsize(target[0].path) - bootloader_bin = "buildroot/share/PlatformIO/scripts/" + "jgaurora_bootloader.bin" - bootloader = open(bootloader_bin, "rb") - lengthbootloader = os.path.getsize(bootloader_bin) + from pathlib import Path + + fw_path = Path(target[0].path) + fwb_path = fw_path.parent / 'firmware_with_bootloader.bin' + with fwb_path.open("wb") as fwb_file: + bl_path = Path("buildroot/share/PlatformIO/scripts/jgaurora_bootloader.bin") + bl_file = bl_path.open("rb") + while True: + b = bl_file.read(1) + if b == b'': break + else: fwb_file.write(b) + + with fw_path.open("rb") as fw_file: + while True: + b = fw_file.read(1) + if b == b'': break + else: fwb_file.write(b) - firmware_with_boothloader_bin = target[0].dir.path + '/firmware_with_bootloader.bin' - if os.path.exists(firmware_with_boothloader_bin): - os.remove(firmware_with_boothloader_bin) - firmwareimage = open(firmware_with_boothloader_bin, "wb") - position = 0 - while position < lengthbootloader: - byte = bootloader.read(1) - firmwareimage.write(byte) - position += 1 - position = 0 - while position < lengthfirmware: - byte = firmware.read(1) - firmwareimage.write(byte) - position += 1 - bootloader.close() - firmware.close() - firmwareimage.close() + fws_path = Path(target[0].dir.path, 'firmware_for_sd_upload.bin') + if fws_path.exists(): + fws_path.unlink() - firmware_without_bootloader_bin = target[0].dir.path + '/firmware_for_sd_upload.bin' - if os.path.exists(firmware_without_bootloader_bin): - os.remove(firmware_without_bootloader_bin) - os.rename(target[0].path, firmware_without_bootloader_bin) - #os.rename(target[0].dir.path+'/firmware_with_bootloader.bin', target[0].dir.path+'/firmware.bin') + fw_path.rename(fws_path) + import marlin marlin.add_post_action(addboot); diff --git a/buildroot/share/PlatformIO/scripts/lerdge.py b/buildroot/share/PlatformIO/scripts/lerdge.py index 06e4543930..dc0c633139 100644 --- a/buildroot/share/PlatformIO/scripts/lerdge.py +++ b/buildroot/share/PlatformIO/scripts/lerdge.py @@ -8,10 +8,8 @@ import pioutil if pioutil.is_pio_build(): import os,marlin - Import("env") - from SCons.Script import DefaultEnvironment - board = DefaultEnvironment().BoardConfig() + board = marlin.env.BoardConfig() def encryptByte(byte): byte = 0xFF & ((byte << 6) | (byte >> 2)) diff --git a/buildroot/share/PlatformIO/scripts/marlin.py b/buildroot/share/PlatformIO/scripts/marlin.py index 580268c423..068d0331a8 100644 --- a/buildroot/share/PlatformIO/scripts/marlin.py +++ b/buildroot/share/PlatformIO/scripts/marlin.py @@ -2,21 +2,18 @@ # marlin.py # Helper module with some commonly-used functions # -import os,shutil +import shutil +from pathlib import Path from SCons.Script import DefaultEnvironment env = DefaultEnvironment() -from os.path import join - def copytree(src, dst, symlinks=False, ignore=None): - for item in os.listdir(src): - s = join(src, item) - d = join(dst, item) - if os.path.isdir(s): - shutil.copytree(s, d, symlinks, ignore) + for item in src.iterdir(): + if item.is_dir(): + shutil.copytree(item, dst / item.name, symlinks, ignore) else: - shutil.copy2(s, d) + shutil.copy2(item, dst / item.name) def replace_define(field, value): for define in env['CPPDEFINES']: @@ -34,7 +31,7 @@ def relocate_vtab(address): # Replace the existing -Wl,-T with the given ldscript path def custom_ld_script(ldname): - apath = os.path.abspath("buildroot/share/PlatformIO/ldscripts/" + ldname) + apath = str(Path("buildroot/share/PlatformIO/ldscripts", ldname).resolve()) for i, flag in enumerate(env["LINKFLAGS"]): if "-Wl,-T" in flag: env["LINKFLAGS"][i] = "-Wl,-T" + apath @@ -52,15 +49,15 @@ def encrypt_mks(source, target, env, new_name): mf = env["MARLIN_FEATURES"] if "FIRMWARE_BIN" in mf: new_name = mf["FIRMWARE_BIN"] - fwpath = target[0].path - fwfile = open(fwpath, "rb") - enfile = open(target[0].dir.path + "/" + new_name, "wb") - length = os.path.getsize(fwpath) + fwpath = Path(target[0].path) + fwfile = fwpath.open("rb") + enfile = Path(target[0].dir.path, new_name).open("wb") + length = fwpath.stat().st_size position = 0 try: while position < length: byte = fwfile.read(1) - if position >= 320 and position < 31040: + if 320 <= position < 31040: byte = chr(ord(byte) ^ key[position & 31]) if sys.version_info[0] > 2: byte = bytes(byte, 'latin1') @@ -69,7 +66,7 @@ def encrypt_mks(source, target, env, new_name): finally: fwfile.close() enfile.close() - os.remove(fwpath) + fwpath.unlink() def add_post_action(action): - env.AddPostAction(join("$BUILD_DIR", "${PROGNAME}.bin"), action); + env.AddPostAction(str(Path("$BUILD_DIR", "${PROGNAME}.bin")), action); diff --git a/buildroot/share/PlatformIO/scripts/offset_and_rename.py b/buildroot/share/PlatformIO/scripts/offset_and_rename.py index 6f44524619..10a34d9c73 100644 --- a/buildroot/share/PlatformIO/scripts/offset_and_rename.py +++ b/buildroot/share/PlatformIO/scripts/offset_and_rename.py @@ -10,12 +10,10 @@ # import pioutil if pioutil.is_pio_build(): - import os,sys,marlin - Import("env") - - from SCons.Script import DefaultEnvironment - board = DefaultEnvironment().BoardConfig() + import sys,marlin + env = marlin.env + board = env.BoardConfig() board_keys = board.get("build").keys() # @@ -56,7 +54,7 @@ def encrypt(source, target, env): if 'rename' in board_keys: def rename_target(source, target, env): - firmware = os.path.join(target[0].dir.path, board.get("build.rename")) - os.replace(target[0].path, firmware) + from pathlib import Path + Path(target[0].path).replace(Path(target[0].dir.path, board.get("build.rename"))) marlin.add_post_action(rename_target) diff --git a/buildroot/share/PlatformIO/scripts/openblt.py b/buildroot/share/PlatformIO/scripts/openblt.py index 61b38a5e87..33e82898f7 100644 --- a/buildroot/share/PlatformIO/scripts/openblt.py +++ b/buildroot/share/PlatformIO/scripts/openblt.py @@ -10,11 +10,11 @@ board = env.BoardConfig() board_keys = board.get("build").keys() - if 'encrypt' in board_keys: + if 'encode' in board_keys: env.AddPostAction( join("$BUILD_DIR", "${PROGNAME}.bin"), env.VerboseAction(" ".join([ "$OBJCOPY", "-O", "srec", - "\"$BUILD_DIR/${PROGNAME}.elf\"", "\"" + join("$BUILD_DIR", board.get("build.encrypt")) + "\"" - ]), "Building $TARGET") + "\"$BUILD_DIR/${PROGNAME}.elf\"", "\"" + join("$BUILD_DIR", board.get("build.encode")) + "\"" + ]), "Building " + board.get("build.encode")) ) diff --git a/buildroot/share/PlatformIO/scripts/pioutil.py b/buildroot/share/PlatformIO/scripts/pioutil.py index b8c1e9cfca..32096dab3f 100644 --- a/buildroot/share/PlatformIO/scripts/pioutil.py +++ b/buildroot/share/PlatformIO/scripts/pioutil.py @@ -4,5 +4,10 @@ # Make sure 'vscode init' is not the current command def is_pio_build(): - from SCons.Script import COMMAND_LINE_TARGETS - return "idedata" not in COMMAND_LINE_TARGETS and "_idedata" not in COMMAND_LINE_TARGETS + from SCons.Script import DefaultEnvironment + env = DefaultEnvironment() + return not env.IsIntegrationDump() + +def get_pio_version(): + from platformio import util + return util.pioversion_to_intstr() diff --git a/buildroot/share/PlatformIO/scripts/preflight-checks.py b/buildroot/share/PlatformIO/scripts/preflight-checks.py index dbd0510b5d..0fa9f9d6cc 100644 --- a/buildroot/share/PlatformIO/scripts/preflight-checks.py +++ b/buildroot/share/PlatformIO/scripts/preflight-checks.py @@ -6,10 +6,12 @@ if pioutil.is_pio_build(): import os,re,sys + from pathlib import Path Import("env") def get_envs_for_board(board): - with open(os.path.join("Marlin", "src", "pins", "pins.h"), "r") as file: + ppath = Path("Marlin/src/pins/pins.h") + with ppath.open() as file: if sys.platform == 'win32': envregex = r"(?:env|win):" @@ -52,6 +54,11 @@ def sanity_check_target(): if 'PIOENV' not in env: raise SystemExit("Error: PIOENV is not defined. This script is intended to be used with PlatformIO") + # Require PlatformIO 6.1.1 or later + vers = pioutil.get_pio_version() + if vers < [6, 1, 1]: + raise SystemExit("Error: Marlin requires PlatformIO >= 6.1.1. Use 'pio upgrade' to get a newer version.") + if 'MARLIN_FEATURES' not in env: raise SystemExit("Error: this script should be used after common Marlin scripts") @@ -72,39 +79,46 @@ def sanity_check_target(): # # Check for Config files in two common incorrect places # - for p in [ env['PROJECT_DIR'], os.path.join(env['PROJECT_DIR'], "config") ]: - for f in [ "Configuration.h", "Configuration_adv.h" ]: - if os.path.isfile(os.path.join(p, f)): + epath = Path(env['PROJECT_DIR']) + for p in [ epath, epath / "config" ]: + for f in ("Configuration.h", "Configuration_adv.h"): + if (p / f).is_file(): err = "ERROR: Config files found in directory %s. Please move them into the Marlin subfolder." % p raise SystemExit(err) + # + # Find the name.cpp.o or name.o and remove it + # + def rm_ofile(subdir, name): + build_dir = Path(env['PROJECT_BUILD_DIR'], build_env); + for outdir in (build_dir, build_dir / "debug"): + for ext in (".cpp.o", ".o"): + fpath = outdir / "src/src" / subdir / (name + ext) + if fpath.exists(): + fpath.unlink() + # # Give warnings on every build # - srcpath = os.path.join(env['PROJECT_BUILD_DIR'], build_env, "src", "src") - warnfile = os.path.join(srcpath, "inc", "Warnings.cpp.o") - if os.path.exists(warnfile): - os.remove(warnfile) + rm_ofile("inc", "Warnings") # # Rebuild 'settings.cpp' for EEPROM_INIT_NOW # if 'EEPROM_INIT_NOW' in env['MARLIN_FEATURES']: - setfile = os.path.join(srcpath, "module", "settings.cpp.o") - if os.path.exists(setfile): - os.remove(setfile) + rm_ofile("module", "settings") # # Check for old files indicating an entangled Marlin (mixing old and new code) # mixedin = [] - p = os.path.join(env['PROJECT_DIR'], "Marlin", "src", "lcd", "dogm") + p = Path(env['PROJECT_DIR'], "Marlin/src/lcd/dogm") for f in [ "ultralcd_DOGM.cpp", "ultralcd_DOGM.h" ]: - if os.path.isfile(os.path.join(p, f)): + if (p / f).is_file(): mixedin += [ f ] - p = os.path.join(env['PROJECT_DIR'], "Marlin", "src", "feature", "bedlevel", "abl") + p = Path(env['PROJECT_DIR'], "Marlin/src/feature/bedlevel/abl") for f in [ "abl.cpp", "abl.h" ]: - if os.path.isfile(os.path.join(p, f)): + if (p / f).is_file(): mixedin += [ f ] if mixedin: err = "ERROR: Old files fell into your Marlin folder. Remove %s and try again" % ", ".join(mixedin) diff --git a/buildroot/share/PlatformIO/scripts/preprocessor.py b/buildroot/share/PlatformIO/scripts/preprocessor.py index d9c472006c..19e8dfe0e1 100644 --- a/buildroot/share/PlatformIO/scripts/preprocessor.py +++ b/buildroot/share/PlatformIO/scripts/preprocessor.py @@ -1,7 +1,7 @@ # # preprocessor.py # -import subprocess,os,re +import subprocess,re nocache = 1 verbose = 0 @@ -40,7 +40,10 @@ def run_preprocessor(env, fn=None): depcmd = cmd + [ filename ] cmd = ' '.join(depcmd) blab(cmd) - define_list = subprocess.check_output(cmd, shell=True).splitlines() + try: + define_list = subprocess.check_output(cmd, shell=True).splitlines() + except: + define_list = {} preprocessor_cache[filename] = define_list return define_list @@ -51,51 +54,41 @@ def run_preprocessor(env, fn=None): # def search_compiler(env): - ENV_BUILD_PATH = os.path.join(env['PROJECT_BUILD_DIR'], env['PIOENV']) - GCC_PATH_CACHE = os.path.join(ENV_BUILD_PATH, ".gcc_path") + from pathlib import Path, PurePath + + ENV_BUILD_PATH = Path(env['PROJECT_BUILD_DIR'], env['PIOENV']) + GCC_PATH_CACHE = ENV_BUILD_PATH / ".gcc_path" try: - filepath = env.GetProjectOption('custom_gcc') + gccpath = env.GetProjectOption('custom_gcc') blab("Getting compiler from env") - return filepath + return gccpath except: pass # Warning: The cached .gcc_path will obscure a newly-installed toolkit - if not nocache and os.path.exists(GCC_PATH_CACHE): + if not nocache and GCC_PATH_CACHE.exists(): blab("Getting g++ path from cache") - with open(GCC_PATH_CACHE, 'r') as f: - return f.read() + return GCC_PATH_CACHE.read_text() - # Find the current platform compiler by searching the $PATH - # which will be in a platformio toolchain bin folder - path_regex = re.escape(env['PROJECT_PACKAGES_DIR']) - gcc = "g++" + # Use any item in $PATH corresponding to a platformio toolchain bin folder + path_separator = ':' + gcc_exe = '*g++' if env['PLATFORM'] == 'win32': path_separator = ';' - path_regex += r'.*\\bin' - gcc += ".exe" - else: - path_separator = ':' - path_regex += r'/.+/bin' - - # Search for the compiler - for pathdir in env['ENV']['PATH'].split(path_separator): - if not re.search(path_regex, pathdir, re.IGNORECASE): - continue - for filepath in os.listdir(pathdir): - if not filepath.endswith(gcc): - continue - # Use entire path to not rely on env PATH - filepath = os.path.sep.join([pathdir, filepath]) - # Cache the g++ path to no search always - if not nocache and os.path.exists(ENV_BUILD_PATH): - blab("Caching g++ for current env") - with open(GCC_PATH_CACHE, 'w+') as f: - f.write(filepath) - - return filepath - - filepath = env.get('CXX') - blab("Couldn't find a compiler! Fallback to %s" % filepath) - return filepath + gcc_exe += ".exe" + + # Search for the compiler in PATH + for ppath in map(Path, env['ENV']['PATH'].split(path_separator)): + if ppath.match(env['PROJECT_PACKAGES_DIR'] + "/**/bin"): + for gpath in ppath.glob(gcc_exe): + gccpath = str(gpath.resolve()) + # Cache the g++ path to no search always + if not nocache and ENV_BUILD_PATH.exists(): + blab("Caching g++ for current env") + GCC_PATH_CACHE.write_text(gccpath) + return gccpath + + gccpath = env.get('CXX') + blab("Couldn't find a compiler! Fallback to %s" % gccpath) + return gccpath diff --git a/buildroot/share/PlatformIO/scripts/schema.py b/buildroot/share/PlatformIO/scripts/schema.py new file mode 100755 index 0000000000..767748757e --- /dev/null +++ b/buildroot/share/PlatformIO/scripts/schema.py @@ -0,0 +1,403 @@ +#!/usr/bin/env python3 +# +# schema.py +# +# Used by signature.py via common-dependencies.py to generate a schema file during the PlatformIO build. +# This script can also be run standalone from within the Marlin repo to generate all schema files. +# +import re,json +from pathlib import Path + +def extend_dict(d:dict, k:tuple): + if len(k) >= 1 and k[0] not in d: + d[k[0]] = {} + if len(k) >= 2 and k[1] not in d[k[0]]: + d[k[0]][k[1]] = {} + if len(k) >= 3 and k[2] not in d[k[0]][k[1]]: + d[k[0]][k[1]][k[2]] = {} + +grouping_patterns = [ + re.compile(r'^([XYZIJKUVW]|[XYZ]2|Z[34]|E[0-7])$'), + re.compile(r'^AXIS\d$'), + re.compile(r'^(MIN|MAX)$'), + re.compile(r'^[0-8]$'), + re.compile(r'^HOTEND[0-7]$'), + re.compile(r'^(HOTENDS|BED|PROBE|COOLER)$'), + re.compile(r'^[XYZIJKUVW]M(IN|AX)$') +] +# If the indexed part of the option name matches a pattern +# then add it to the dictionary. +def find_grouping(gdict, filekey, sectkey, optkey, pindex): + optparts = optkey.split('_') + if 1 < len(optparts) > pindex: + for patt in grouping_patterns: + if patt.match(optparts[pindex]): + subkey = optparts[pindex] + modkey = '_'.join(optparts) + optparts[pindex] = '*' + wildkey = '_'.join(optparts) + kkey = f'{filekey}|{sectkey}|{wildkey}' + if kkey not in gdict: gdict[kkey] = [] + gdict[kkey].append((subkey, modkey)) + +# Build a list of potential groups. Only those with multiple items will be grouped. +def group_options(schema): + for pindex in range(10, -1, -1): + found_groups = {} + for filekey, f in schema.items(): + for sectkey, s in f.items(): + for optkey in s: + find_grouping(found_groups, filekey, sectkey, optkey, pindex) + + fkeys = [ k for k in found_groups.keys() ] + for kkey in fkeys: + items = found_groups[kkey] + if len(items) > 1: + f, s, w = kkey.split('|') + extend_dict(schema, (f, s, w)) # Add wildcard group to schema + for subkey, optkey in items: # Add all items to wildcard group + schema[f][s][w][subkey] = schema[f][s][optkey] # Move non-wildcard item to wildcard group + del schema[f][s][optkey] + del found_groups[kkey] + +# Extract all board names from boards.h +def load_boards(): + bpath = Path("Marlin/src/core/boards.h") + if bpath.is_file(): + with bpath.open() as bfile: + boards = [] + for line in bfile: + if line.startswith("#define BOARD_"): + bname = line.split()[1] + if bname != "BOARD_UNKNOWN": boards.append(bname) + return "['" + "','".join(boards) + "']" + return '' + +# +# Extract a schema from the current configuration files +# +def extract(): + # Load board names from boards.h + boards = load_boards() + + # Parsing states + class Parse: + NORMAL = 0 # No condition yet + BLOCK_COMMENT = 1 # Looking for the end of the block comment + EOL_COMMENT = 2 # EOL comment started, maybe add the next comment? + GET_SENSORS = 3 # Gathering temperature sensor options + ERROR = 9 # Syntax error + + # List of files to process, with shorthand + filekey = { 'Configuration.h':'basic', 'Configuration_adv.h':'advanced' } + # A JSON object to store the data + sch_out = { 'basic':{}, 'advanced':{} } + # Regex for #define NAME [VALUE] [COMMENT] with sanitized line + defgrep = re.compile(r'^(//)?\s*(#define)\s+([A-Za-z0-9_]+)\s*(.*?)\s*(//.+)?$') + # Defines to ignore + ignore = ('CONFIGURATION_H_VERSION', 'CONFIGURATION_ADV_H_VERSION', 'CONFIG_EXPORT') + # Start with unknown state + state = Parse.NORMAL + # Serial ID + sid = 0 + # Loop through files and parse them line by line + for fn, fk in filekey.items(): + with Path("Marlin", fn).open() as fileobj: + section = 'none' # Current Settings section + line_number = 0 # Counter for the line number of the file + conditions = [] # Create a condition stack for the current file + comment_buff = [] # A temporary buffer for comments + options_json = '' # A buffer for the most recent options JSON found + eol_options = False # The options came from end of line, so only apply once + join_line = False # A flag that the line should be joined with the previous one + line = '' # A line buffer to handle \ continuation + last_added_ref = None # Reference to the last added item + # Loop through the lines in the file + for the_line in fileobj.readlines(): + line_number += 1 + + # Clean the line for easier parsing + the_line = the_line.strip() + + if join_line: # A previous line is being made longer + line += (' ' if line else '') + the_line + else: # Otherwise, start the line anew + line, line_start = the_line, line_number + + # If the resulting line ends with a \, don't process now. + # Strip the end off. The next line will be joined with it. + join_line = line.endswith("\\") + if join_line: + line = line[:-1].strip() + continue + else: + line_end = line_number + + defmatch = defgrep.match(line) + + # Special handling for EOL comments after a #define. + # At this point the #define is already digested and inserted, + # so we have to extend it + if state == Parse.EOL_COMMENT: + # If the line is not a comment, we're done with the EOL comment + if not defmatch and the_line.startswith('//'): + comment_buff.append(the_line[2:].strip()) + else: + last_added_ref['comment'] = ' '.join(comment_buff) + comment_buff = [] + state = Parse.NORMAL + + def use_comment(c, opt, sec, bufref): + if c.startswith(':'): # If the comment starts with : then it has magic JSON + d = c[1:].strip() # Strip the leading : + cbr = c.rindex('}') if d.startswith('{') else c.rindex(']') if d.startswith('[') else 0 + if cbr: + opt, cmt = c[1:cbr+1].strip(), c[cbr+1:].strip() + if cmt != '': bufref.append(cmt) + else: + opt = c[1:].strip() + elif c.startswith('@section'): # Start a new section + sec = c[8:].strip() + elif not c.startswith('========'): + bufref.append(c) + return opt, sec + + # In a block comment, capture lines up to the end of the comment. + # Assume nothing follows the comment closure. + if state in (Parse.BLOCK_COMMENT, Parse.GET_SENSORS): + endpos = line.find('*/') + if endpos < 0: + cline = line + else: + cline, line = line[:endpos].strip(), line[endpos+2:].strip() + + # Temperature sensors are done + if state == Parse.GET_SENSORS: + options_json = f'[ {options_json[:-2]} ]' + + state = Parse.NORMAL + + # Strip the leading '*' from block comments + if cline.startswith('*'): cline = cline[1:].strip() + + # Collect temperature sensors + if state == Parse.GET_SENSORS: + sens = re.match(r'^(-?\d+)\s*:\s*(.+)$', cline) + if sens: + s2 = sens[2].replace("'","''") + options_json += f"{sens[1]}:'{s2}', " + + elif state == Parse.BLOCK_COMMENT: + + # Look for temperature sensors + if cline == "Temperature sensors available:": + state, cline = Parse.GET_SENSORS, "Temperature Sensors" + + options_json, section = use_comment(cline, options_json, section, comment_buff) + + # For the normal state we're looking for any non-blank line + elif state == Parse.NORMAL: + # Skip a commented define when evaluating comment opening + st = 2 if re.match(r'^//\s*#define', line) else 0 + cpos1 = line.find('/*') # Start a block comment on the line? + cpos2 = line.find('//', st) # Start an end of line comment on the line? + + # Only the first comment starter gets evaluated + cpos = -1 + if cpos1 != -1 and (cpos1 < cpos2 or cpos2 == -1): + cpos = cpos1 + comment_buff = [] + state = Parse.BLOCK_COMMENT + eol_options = False + + elif cpos2 != -1 and (cpos2 < cpos1 or cpos1 == -1): + cpos = cpos2 + + # Expire end-of-line options after first use + if cline.startswith(':'): eol_options = True + + # Comment after a define may be continued on the following lines + if state == Parse.NORMAL and defmatch != None and cpos > 10: + state = Parse.EOL_COMMENT + comment_buff = [] + + # Process the start of a new comment + if cpos != -1: + cline, line = line[cpos+2:].strip(), line[:cpos].strip() + + # Strip leading '*' from block comments + if state == Parse.BLOCK_COMMENT: + if cline.startswith('*'): cline = cline[1:].strip() + + # Buffer a non-empty comment start + if cline != '': + options_json, section = use_comment(cline, options_json, section, comment_buff) + + # If the line has nothing before the comment, go to the next line + if line == '': + options_json = '' + continue + + # Parenthesize the given expression if needed + def atomize(s): + if s == '' \ + or re.match(r'^[A-Za-z0-9_]*(\([^)]+\))?$', s) \ + or re.match(r'^[A-Za-z0-9_]+ == \d+?$', s): + return s + return f'({s})' + + # + # The conditions stack is an array containing condition-arrays. + # Each condition-array lists the conditions for the current block. + # IF/N/DEF adds a new condition-array to the stack. + # ELSE/ELIF/ENDIF pop the condition-array. + # ELSE/ELIF negate the last item in the popped condition-array. + # ELIF adds a new condition to the end of the array. + # ELSE/ELIF re-push the condition-array. + # + cparts = line.split() + iselif, iselse = cparts[0] == '#elif', cparts[0] == '#else' + if iselif or iselse or cparts[0] == '#endif': + if len(conditions) == 0: + raise Exception(f'no #if block at line {line_number}') + + # Pop the last condition-array from the stack + prev = conditions.pop() + + if iselif or iselse: + prev[-1] = '!' + prev[-1] # Invert the last condition + if iselif: prev.append(atomize(line[5:].strip())) + conditions.append(prev) + + elif cparts[0] == '#if': + conditions.append([ atomize(line[3:].strip()) ]) + elif cparts[0] == '#ifdef': + conditions.append([ f'defined({line[6:].strip()})' ]) + elif cparts[0] == '#ifndef': + conditions.append([ f'!defined({line[7:].strip()})' ]) + + # Handle a complete #define line + elif defmatch != None: + + # Get the match groups into vars + enabled, define_name, val = defmatch[1] == None, defmatch[3], defmatch[4] + + # Increment the serial ID + sid += 1 + + # Create a new dictionary for the current #define + define_info = { + 'section': section, + 'name': define_name, + 'enabled': enabled, + 'line': line_start, + 'sid': sid + } + + if val != '': define_info['value'] = val + + # Type is based on the value + if val == '': + value_type = 'switch' + elif re.match(r'^(true|false)$', val): + value_type = 'bool' + val = val == 'true' + elif re.match(r'^[-+]?\s*\d+$', val): + value_type = 'int' + val = int(val) + elif re.match(r'[-+]?\s*(\d+\.|\d*\.\d+)([eE][-+]?\d+)?[fF]?', val): + value_type = 'float' + val = float(val.replace('f','')) + else: + value_type = 'string' if val[0] == '"' \ + else 'char' if val[0] == "'" \ + else 'state' if re.match(r'^(LOW|HIGH)$', val) \ + else 'enum' if re.match(r'^[A-Za-z0-9_]{3,}$', val) \ + else 'int[]' if re.match(r'^{(\s*[-+]?\s*\d+\s*(,\s*)?)+}$', val) \ + else 'float[]' if re.match(r'^{(\s*[-+]?\s*(\d+\.|\d*\.\d+)([eE][-+]?\d+)?[fF]?\s*(,\s*)?)+}$', val) \ + else 'array' if val[0] == '{' \ + else '' + + if value_type != '': define_info['type'] = value_type + + # Join up accumulated conditions with && + if conditions: define_info['requires'] = ' && '.join(sum(conditions, [])) + + # If the comment_buff is not empty, add the comment to the info + if comment_buff: + full_comment = '\n'.join(comment_buff) + + # An EOL comment will be added later + # The handling could go here instead of above + if state == Parse.EOL_COMMENT: + define_info['comment'] = '' + else: + define_info['comment'] = full_comment + comment_buff = [] + + # If the comment specifies units, add that to the info + units = re.match(r'^\(([^)]+)\)', full_comment) + if units: + units = units[1] + if units == 's' or units == 'sec': units = 'seconds' + define_info['units'] = units + + # Set the options for the current #define + if define_name == "MOTHERBOARD" and boards != '': + define_info['options'] = boards + elif options_json != '': + define_info['options'] = options_json + if eol_options: options_json = '' + + # Create section dict if it doesn't exist yet + if section not in sch_out[fk]: sch_out[fk][section] = {} + + # If define has already been seen... + if define_name in sch_out[fk][section]: + info = sch_out[fk][section][define_name] + if isinstance(info, dict): info = [ info ] # Convert a single dict into a list + info.append(define_info) # Add to the list + else: + # Add the define dict with name as key + sch_out[fk][section][define_name] = define_info + + if state == Parse.EOL_COMMENT: + last_added_ref = define_info + + return sch_out + +def dump_json(schema:dict, jpath:Path): + with jpath.open('w') as jfile: + json.dump(schema, jfile, ensure_ascii=False, indent=2) + +def dump_yaml(schema:dict, ypath:Path): + import yaml + with ypath.open('w') as yfile: + yaml.dump(schema, yfile, default_flow_style=False, width=120, indent=2) + +def main(): + try: + schema = extract() + except Exception as exc: + print("Error: " + str(exc)) + schema = None + + if schema: + print("Generating JSON ...") + dump_json(schema, Path('schema.json')) + group_options(schema) + dump_json(schema, Path('schema_grouped.json')) + + try: + import yaml + except ImportError: + print("Installing YAML module ...") + import subprocess + subprocess.run(['python3', '-m', 'pip', 'install', 'pyyaml']) + import yaml + + print("Generating YML ...") + dump_yaml(schema, Path('schema.yml')) + +if __name__ == '__main__': + main() diff --git a/buildroot/share/PlatformIO/scripts/signature.py b/buildroot/share/PlatformIO/scripts/signature.py index 593f9580b3..43d56ac6e1 100644 --- a/buildroot/share/PlatformIO/scripts/signature.py +++ b/buildroot/share/PlatformIO/scripts/signature.py @@ -1,24 +1,28 @@ # # signature.py # -import os,subprocess,re,json,hashlib +import schema + +import subprocess,re,json,hashlib +from datetime import datetime +from pathlib import Path # -# The dumbest preprocessor in the world -# Extract macro name from an header file and store them in an array -# No processing is done here, so they are raw values here and it does not match what actually enabled -# in the file (since you can have #if SOMETHING_UNDEFINED / #define BOB / #endif) -# But it's useful to filter the useful macro spit out by the preprocessor from noise from the system -# headers. +# Return all macro names in a header as an array, so we can take +# the intersection with the preprocessor output, giving a decent +# reflection of all enabled options that (probably) came from the +# configuration files. We end up with the actual configured state, +# better than what the config files say. You can then use the +# resulting config.ini to produce more exact configuration files. # def extract_defines(filepath): f = open(filepath, encoding="utf8").read().split("\n") a = [] for line in f: - sline = line.strip(" \t\n\r") + sline = line.strip() if sline[:7] == "#define": # Extract the key here (we don't care about the value) - kv = sline[8:].strip().split(' ') + kv = sline[8:].strip().split() a.append(kv[0]) return a @@ -35,8 +39,8 @@ def get_file_sha256sum(filepath): # Compress a JSON file into a zip file # import zipfile -def compress_file(filepath, outputbase): - with zipfile.ZipFile(outputbase + '.zip', 'w', compression=zipfile.ZIP_BZIP2, compresslevel=9) as zipf: +def compress_file(filepath, outpath): + with zipfile.ZipFile(outpath, 'w', compression=zipfile.ZIP_BZIP2, compresslevel=9) as zipf: zipf.write(filepath, compress_type=zipfile.ZIP_BZIP2, compresslevel=9) # @@ -51,19 +55,19 @@ def compute_build_signature(env): # Definitions from these files will be kept files_to_keep = [ 'Marlin/Configuration.h', 'Marlin/Configuration_adv.h' ] - build_dir=os.path.join(env['PROJECT_BUILD_DIR'], env['PIOENV']) + build_path = Path(env['PROJECT_BUILD_DIR'], env['PIOENV']) # Check if we can skip processing hashes = '' for header in files_to_keep: hashes += get_file_sha256sum(header)[0:10] - marlin_json = os.path.join(build_dir, 'marlin_config.json') - marlin_zip = os.path.join(build_dir, 'mc') + marlin_json = build_path / 'marlin_config.json' + marlin_zip = build_path / 'mc.zip' # Read existing config file try: - with open(marlin_json, 'r') as infile: + with marlin_json.open() as infile: conf = json.load(infile) if conf['__INITIAL_HASH'] == hashes: # Same configuration, skip recomputing the building signature @@ -77,14 +81,14 @@ def compute_build_signature(env): complete_cfg = run_preprocessor(env) # Dumb #define extraction from the configuration files - real_defines = {} + conf_defines = {} all_defines = [] for header in files_to_keep: defines = extract_defines(header) # To filter only the define we want - all_defines = all_defines + defines + all_defines += defines # To remember from which file it cames from - real_defines[header.split('/')[-1]] = defines + conf_defines[header.split('/')[-1]] = defines r = re.compile(r"\(+(\s*-*\s*_.*)\)+") @@ -109,23 +113,26 @@ def compute_build_signature(env): defines[key] = value if len(value) else "" - if not 'CONFIGURATION_EMBEDDING' in defines: + # + # Continue to gather data for CONFIGURATION_EMBEDDING or CONFIG_EXPORT + # + if not ('CONFIGURATION_EMBEDDING' in defines or 'CONFIG_EXPORT' in defines): return # Second step is to filter useless macro resolved_defines = {} for key in defines: # Remove all boards now - if key[0:6] == "BOARD_" and key != "BOARD_INFO_NAME": + if key.startswith("BOARD_") and key != "BOARD_INFO_NAME": continue # Remove all keys ending by "_NAME" as it does not make a difference to the configuration - if key[-5:] == "_NAME" and key != "CUSTOM_MACHINE_NAME": + if key.endswith("_NAME") and key != "CUSTOM_MACHINE_NAME": continue - # Remove all keys ending by "_T_DECLARED" as it's a copy of not important system stuff - if key[-11:] == "_T_DECLARED": + # Remove all keys ending by "_T_DECLARED" as it's a copy of extraneous system stuff + if key.endswith("_T_DECLARED"): continue # Remove keys that are not in the #define list in the Configuration list - if not (key in all_defines) and key != "DETAILED_BUILD_VERSION" and key != "STRING_DISTRIBUTION_DATE": + if key not in all_defines + [ 'DETAILED_BUILD_VERSION', 'STRING_DISTRIBUTION_DATE' ]: continue # Don't be that smart guy here @@ -136,15 +143,94 @@ def compute_build_signature(env): data = {} data['__INITIAL_HASH'] = hashes # First create a key for each header here - for header in real_defines: + for header in conf_defines: data[header] = {} # Then populate the object where each key is going to (that's a O(N^2) algorithm here...) for key in resolved_defines: - for header in real_defines: - if key in real_defines[header]: + for header in conf_defines: + if key in conf_defines[header]: data[header][key] = resolved_defines[key] + # Every python needs this toy + def tryint(key): + try: + return int(defines[key]) + except: + return 0 + + config_dump = tryint('CONFIG_EXPORT') + + # + # Produce an INI file if CONFIG_EXPORT == 2 + # + if config_dump == 2: + print("Generating config.ini ...") + config_ini = build_path / 'config.ini' + with config_ini.open('w') as outfile: + ignore = ('CONFIGURATION_H_VERSION', 'CONFIGURATION_ADV_H_VERSION', 'CONFIG_EXPORT') + filegrp = { 'Configuration.h':'config:basic', 'Configuration_adv.h':'config:advanced' } + vers = defines["CONFIGURATION_H_VERSION"] + dt_string = datetime.now().strftime("%Y-%m-%d at %H:%M:%S") + ini_fmt = '{0:40}{1}\n' + outfile.write( + '#\n' + + '# Marlin Firmware\n' + + '# config.ini - Options to apply before the build\n' + + '#\n' + + f'# Generated by Marlin build on {dt_string}\n' + + '#\n' + + '\n' + + '[config:base]\n' + + ini_fmt.format('ini_use_config', ' = all') + + ini_fmt.format('ini_config_vers', f' = {vers}') + ) + # Loop through the data array of arrays + for header in data: + if header.startswith('__'): + continue + outfile.write('\n[' + filegrp[header] + ']\n') + for key in sorted(data[header]): + if key not in ignore: + val = 'on' if data[header][key] == '' else data[header][key] + outfile.write(ini_fmt.format(key.lower(), ' = ' + val)) + + # + # Produce a schema.json file if CONFIG_EXPORT == 3 + # + if config_dump >= 3: + try: + conf_schema = schema.extract() + except Exception as exc: + print("Error: " + str(exc)) + conf_schema = None + + if conf_schema: + # + # Produce a schema.json file if CONFIG_EXPORT == 3 + # + if config_dump in (3, 13): + print("Generating schema.json ...") + schema.dump_json(conf_schema, build_path / 'schema.json') + if config_dump == 13: + schema.group_options(conf_schema) + schema.dump_json(conf_schema, build_path / 'schema_grouped.json') + + # + # Produce a schema.yml file if CONFIG_EXPORT == 4 + # + elif config_dump == 4: + print("Generating schema.yml ...") + try: + import yaml + except ImportError: + env.Execute(env.VerboseAction( + '$PYTHONEXE -m pip install "pyyaml"', + "Installing YAML for schema.yml export", + )) + import yaml + schema.dump_yaml(conf_schema, build_path / 'schema.yml') + # Append the source code version and date data['VERSION'] = {} data['VERSION']['DETAILED_BUILD_VERSION'] = resolved_defines['DETAILED_BUILD_VERSION'] @@ -155,24 +241,36 @@ def compute_build_signature(env): except: pass - with open(marlin_json, 'w') as outfile: - json.dump(data, outfile, separators=(',', ':')) + # + # Produce a JSON file for CONFIGURATION_EMBEDDING or CONFIG_EXPORT == 1 + # + if config_dump == 1 or 'CONFIGURATION_EMBEDDING' in defines: + with marlin_json.open('w') as outfile: + json.dump(data, outfile, separators=(',', ':')) + + # + # The rest only applies to CONFIGURATION_EMBEDDING + # + if not 'CONFIGURATION_EMBEDDING' in defines: + return # Compress the JSON file as much as we can compress_file(marlin_json, marlin_zip) # Generate a C source file for storing this array with open('Marlin/src/mczip.h','wb') as result_file: - result_file.write(b'#ifndef NO_CONFIGURATION_EMBEDDING_WARNING\n') - result_file.write(b' #warning "Generated file \'mc.zip\' is embedded (Define NO_CONFIGURATION_EMBEDDING_WARNING to suppress this warning.)"\n') - result_file.write(b'#endif\n') - result_file.write(b'const unsigned char mc_zip[] PROGMEM = {\n ') + result_file.write( + b'#ifndef NO_CONFIGURATION_EMBEDDING_WARNING\n' + + b' #warning "Generated file \'mc.zip\' is embedded (Define NO_CONFIGURATION_EMBEDDING_WARNING to suppress this warning.)"\n' + + b'#endif\n' + + b'const unsigned char mc_zip[] PROGMEM = {\n ' + ) count = 0 - for b in open(os.path.join(build_dir, 'mc.zip'), 'rb').read(): + for b in (build_path / 'mc.zip').open('rb').read(): result_file.write(b' 0x%02X,' % b) count += 1 - if (count % 16 == 0): - result_file.write(b'\n ') - if (count % 16): + if count % 16 == 0: + result_file.write(b'\n ') + if count % 16: result_file.write(b'\n') result_file.write(b'};\n') diff --git a/buildroot/share/PlatformIO/scripts/simulator.py b/buildroot/share/PlatformIO/scripts/simulator.py index c6a5277b92..2961d2826d 100644 --- a/buildroot/share/PlatformIO/scripts/simulator.py +++ b/buildroot/share/PlatformIO/scripts/simulator.py @@ -50,5 +50,3 @@ # Break out of the PIO build immediately sys.exit(1) - - env.AddCustomTarget("upload", "$BUILD_DIR/${PROGNAME}", "$BUILD_DIR/${PROGNAME}") diff --git a/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/PeripheralPins.c deleted file mode 100644 index d3d754b689..0000000000 --- a/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/PeripheralPins.c +++ /dev/null @@ -1,260 +0,0 @@ - -/* - ******************************************************************************* - * Copyright (c) 2019, STMicroelectronics - * All rights reserved. - * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ******************************************************************************* - * Automatically generated from STM32F401V(D-E)Tx.xml - */ -#include "Arduino.h" -#include "PeripheralPins.h" - -/* ===== - * Note: Commented lines are alternative possibilities which are not used per default. - * If you change them, you will have to know what you do - * ===== - */ - -//*** ADC *** - -#ifdef HAL_ADC_MODULE_ENABLED -WEAK const PinMap PinMap_ADC[] = { - {PA_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC1_IN0 - {PA_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC1_IN1 - {PA_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC1_IN2 - {PA_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_IN3 - //{PA_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4 - //{PA_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_IN5 - //{PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6 - //{PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7 - //{PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8 - //{PB_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9 - //{PC_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10 - //{PC_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11 - {PC_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC1_IN12 - {PC_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC1_IN13 - //{PC_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC1_IN14 - //{PC_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15 - {NC, NP, 0} -}; -#endif - -//*** No DAC *** - -//*** I2C *** - -#ifdef HAL_I2C_MODULE_ENABLED -WEAK const PinMap PinMap_I2C_SDA[] = { - //{PB_3, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF9_I2C2)}, - //{PB_4, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF9_I2C3)}, - {PB_7, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, - //{PB_9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, - //{PC_9, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, - {NC, NP, 0} -}; - -WEAK const PinMap PinMap_I2C_SCL[] = { - //{PA_8, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, - {PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, - //{PB_8, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, - //{PB_10, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, - {NC, NP, 0} -}; -#endif - -//*** PWM *** - -#ifdef HAL_TIM_MODULE_ENABLED -WEAK const PinMap PinMap_PWM[] = { - //{PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 - //{PA_0, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1 - //{PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 - //{PA_1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2 - //{PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 - //{PA_2, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 3, 0)}, // TIM5_CH3 - //{PA_2, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 - //{PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 - //{PA_3, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 4, 0)}, // TIM5_CH4 - //{PA_3, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 - //{PA_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 - //{PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 - //{PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N - //{PA_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 - //{PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 - //{PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 - //{PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 - //{PA_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 - //{PA_15, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 - //{PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N - {PB_0, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 - //{PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N - {PB_1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 - //{PB_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 - //{PB_4, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 - //{PB_5, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 - //{PB_6, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 - //{PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 - //{PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 - //{PB_8, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1 - //{PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 - //{PB_9, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1 - {PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 - //{PB_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N - //{PB_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N - //{PB_15, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N - {PC_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 - {PC_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 - //{PC_8, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 - //{PC_9, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 - {PD_12, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 - {PD_13, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 - {PD_14, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 - {PD_15, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 - {PE_5, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 - //{PE_6, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 - //{PE_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N - //{PE_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 - //{PE_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N - //{PE_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 - //{PE_12, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N - //{PE_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 - {PE_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 - {NC, NP, 0} -}; -#endif - -//*** SERIAL *** - -#ifdef HAL_UART_MODULE_ENABLED -WEAK const PinMap PinMap_UART_TX[] = { - //{PA_2, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, - {PA_9, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, - //{PA_11, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, - //{PB_6, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, - //{PC_6, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, - {PD_5, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, - {NC, NP, 0} -}; - -WEAK const PinMap PinMap_UART_RX[] = { - //{PA_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, - {PA_10, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, - //{PA_12, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, - //{PB_7, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, - //{PC_7, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, - {PD_6, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, - {NC, NP, 0} -}; - -WEAK const PinMap PinMap_UART_RTS[] = { - //{PA_1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, - //{PA_12, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, - {PD_4, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, - {NC, NP, 0} -}; - -WEAK const PinMap PinMap_UART_CTS[] = { - //{PA_0, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, - //{PA_11, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, - {PD_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, - {NC, NP, 0} -}; -#endif - -//*** SPI *** - -#ifdef HAL_SPI_MODULE_ENABLED -WEAK const PinMap PinMap_SPI_MOSI[] = { - {PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - //{PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - //{PB_5, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - {PB_15, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - //{PC_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - //{PC_12, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - //{PD_6, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - //{PE_6, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, - //{PE_14, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, - {NC, NP, 0} -}; - -WEAK const PinMap PinMap_SPI_MISO[] = { - {PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - //{PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - //{PB_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - {PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - //{PC_2, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - //{PC_11, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - //{PE_5, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, - //{PE_13, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, - {NC, NP, 0} -}; - -WEAK const PinMap PinMap_SPI_SCLK[] = { - {PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - //{PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - //{PB_3, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - //{PB_10, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - {PB_13, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - //{PC_10, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - //{PD_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - //{PE_2, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, - //{PE_12, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, - {NC, NP, 0} -}; - -WEAK const PinMap PinMap_SPI_SSEL[] = { - {PA_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - //{PA_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - //{PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - //{PA_15, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - //{PB_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - {PB_12, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - //{PE_4, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, - //{PE_11, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, - {NC, NP, 0} -}; -#endif - -//*** No CAN *** - -//*** No ETHERNET *** - -//*** No QUADSPI *** - -//*** USB *** - -#ifdef HAL_PCD_MODULE_ENABLED -WEAK const PinMap PinMap_USB_OTG_FS[] = { - //{PA_8, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_SOF - //{PA_9, USB_OTG_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_FS_VBUS - //{PA_10, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_ID - {PA_11, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DM - {PA_12, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DP - {NC, NP, 0} -}; -#endif - -//*** No USB_OTG_HS *** -//*** SD *** - -#ifdef HAL_SD_MODULE_ENABLED -WEAK const PinMap PinMap_SD[] = { - //{PB_8, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D4 - //{PB_9, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D5 - //{PC_6, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D6 - //{PC_7, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D7 - {PC_8, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D0 - {PC_9, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D1 - {PC_10, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D2 - {PC_11, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D3 - {PC_12, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_SDIO)}, // SDIO_CK - {PD_2, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_SDIO)}, // SDIO_CMD - {NC, NP, 0} -}; -#endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/PinNamesVar.h b/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/PinNamesVar.h deleted file mode 100644 index 6a1eb9b887..0000000000 --- a/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/PinNamesVar.h +++ /dev/null @@ -1,33 +0,0 @@ -/* SYS_WKUP */ -#ifdef PWR_WAKEUP_PIN1 - SYS_WKUP1 = PA_0, -#endif -#ifdef PWR_WAKEUP_PIN2 - SYS_WKUP2 = NC, -#endif -#ifdef PWR_WAKEUP_PIN3 - SYS_WKUP3 = NC, -#endif -#ifdef PWR_WAKEUP_PIN4 - SYS_WKUP4 = NC, -#endif -#ifdef PWR_WAKEUP_PIN5 - SYS_WKUP5 = NC, -#endif -#ifdef PWR_WAKEUP_PIN6 - SYS_WKUP6 = NC, -#endif -#ifdef PWR_WAKEUP_PIN7 - SYS_WKUP7 = NC, -#endif -#ifdef PWR_WAKEUP_PIN8 - SYS_WKUP8 = NC, -#endif -/* USB */ -#ifdef USBCON - USB_OTG_FS_SOF = PA_8, - USB_OTG_FS_VBUS = PA_9, - USB_OTG_FS_ID = PA_10, - USB_OTG_FS_DM = PA_11, - USB_OTG_FS_DP = PA_12, -#endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/hal_conf_custom.h b/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/hal_conf_custom.h deleted file mode 100644 index 7d013d2b27..0000000000 --- a/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/hal_conf_custom.h +++ /dev/null @@ -1,495 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f4xx_hal_conf.h - * @brief HAL configuration file. - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2017 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32F4xx_HAL_CONF_CUSTOM -#define __STM32F4xx_HAL_CONF_CUSTOM - -#ifdef __cplusplus -extern "C" { -#endif - -/* Exported types ------------------------------------------------------------*/ -/* Exported constants --------------------------------------------------------*/ - -/* ########################## Module Selection ############################## */ - /** - * @brief This is the list of modules to be used in the HAL driver - */ -#define HAL_MODULE_ENABLED -#define HAL_ADC_MODULE_ENABLED -#define HAL_CRC_MODULE_ENABLED -#define HAL_DMA_MODULE_ENABLED -#define HAL_EXTI_MODULE_ENABLED // Needed for Endstop (and other external) Interrupts -#define HAL_FLASH_MODULE_ENABLED -#define HAL_GPIO_MODULE_ENABLED -#define HAL_I2C_MODULE_ENABLED -#define HAL_IWDG_MODULE_ENABLED -#define HAL_PWR_MODULE_ENABLED -#define HAL_RCC_MODULE_ENABLED -#define HAL_RTC_MODULE_ENABLED -#define HAL_SD_MODULE_ENABLED -#define HAL_SPI_MODULE_ENABLED -#define HAL_TIM_MODULE_ENABLED -#define HAL_CORTEX_MODULE_ENABLED -//#define HAL_PCD_MODULE_ENABLED // Automatically added if any type of USB is enabled, as in Arduino IDE. (STM32 v3.10700.191028) - -//#define HAL_CAN_MODULE_ENABLED -//#define HAL_CAN_LEGACY_MODULE_ENABLED -//#define HAL_CEC_MODULE_ENABLED -//#define HAL_CRYP_MODULE_ENABLED -//#define HAL_DAC_MODULE_ENABLED -//#define HAL_DCMI_MODULE_ENABLED -//#define HAL_DMA2D_MODULE_ENABLED -//#define HAL_ETH_MODULE_ENABLED -//#define HAL_NAND_MODULE_ENABLED -//#define HAL_NOR_MODULE_ENABLED -//#define HAL_PCCARD_MODULE_ENABLED -//#define HAL_SRAM_MODULE_ENABLED -//#define HAL_SDRAM_MODULE_ENABLED -//#define HAL_HASH_MODULE_ENABLED -//#define HAL_SMBUS_MODULE_ENABLED -//#define HAL_I2S_MODULE_ENABLED -//#define HAL_LTDC_MODULE_ENABLED -//#define HAL_DSI_MODULE_ENABLED -//#define HAL_QSPI_MODULE_ENABLED -//#define HAL_RNG_MODULE_ENABLED -//#define HAL_SAI_MODULE_ENABLED -//#define HAL_UART_MODULE_ENABLED // by default -//#define HAL_USART_MODULE_ENABLED -//#define HAL_IRDA_MODULE_ENABLED -//#define HAL_SMARTCARD_MODULE_ENABLED -//#define HAL_WWDG_MODULE_ENABLED -//#define HAL_HCD_MODULE_ENABLED -//#define HAL_FMPI2C_MODULE_ENABLED -//#define HAL_SPDIFRX_MODULE_ENABLED -//#define HAL_DFSDM_MODULE_ENABLED -//#define HAL_LPTIM_MODULE_ENABLED -//#define HAL_MMC_MODULE_ENABLED - -/* ########################## HSE/HSI Values adaptation ##################### */ -/** - * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. - * This value is used by the RCC HAL module to compute the system frequency - * (when HSE is used as system clock source, directly or through the PLL). - */ -#ifndef HSE_VALUE -#define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */ -#endif /* HSE_VALUE */ - -#ifndef HSE_STARTUP_TIMEOUT -#define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ -#endif /* HSE_STARTUP_TIMEOUT */ - -/** - * @brief Internal High Speed oscillator (HSI) value. - * This value is used by the RCC HAL module to compute the system frequency - * (when HSI is used as system clock source, directly or through the PLL). - */ -#ifndef HSI_VALUE -#define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz */ -#endif /* HSI_VALUE */ - -/** - * @brief Internal Low Speed oscillator (LSI) value. - */ -#ifndef LSI_VALUE -#define LSI_VALUE 32000U /*!< LSI Typical Value in Hz */ -#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz -The real value may vary depending on the variations -in voltage and temperature. */ -/** - * @brief External Low Speed oscillator (LSE) value. - */ -#ifndef LSE_VALUE -#define LSE_VALUE 32768U /*!< Value of the External Low Speed oscillator in Hz */ -#endif /* LSE_VALUE */ - -#ifndef LSE_STARTUP_TIMEOUT -#define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ -#endif /* LSE_STARTUP_TIMEOUT */ - -/** - * @brief External clock source for I2S peripheral - * This value is used by the I2S HAL module to compute the I2S clock source - * frequency, this source is inserted directly through I2S_CKIN pad. - */ -#ifndef EXTERNAL_CLOCK_VALUE -#define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the External oscillator in Hz*/ -#endif /* EXTERNAL_CLOCK_VALUE */ - -/* Tip: To avoid modifying this file each time you need to use different HSE, - === you can define the HSE value in your toolchain compiler preprocessor. */ - -/* ########################### System Configuration ######################### */ -/** - * @brief This is the HAL system configuration section - */ -#if !defined (VDD_VALUE) -#define VDD_VALUE 3300U /*!< Value of VDD in mv */ -#endif -#if !defined (TICK_INT_PRIORITY) -#define TICK_INT_PRIORITY 0x00U /*!< tick interrupt priority */ -#endif -#if !defined (USE_RTOS) -#define USE_RTOS 0U -#endif -#if !defined (PREFETCH_ENABLE) -#define PREFETCH_ENABLE 1U -#endif -#if !defined (INSTRUCTION_CACHE_ENABLE) -#define INSTRUCTION_CACHE_ENABLE 1U -#endif -#if !defined (DATA_CACHE_ENABLE) -#define DATA_CACHE_ENABLE 1U -#endif - -#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ -#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */ -#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ -#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */ -#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ -#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */ -#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */ -#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */ -#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */ -#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ -#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */ -#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ -#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ -#define USE_HAL_FMPI2C_REGISTER_CALLBACKS 0U /* FMPI2C register callback disabled */ -#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ -#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ -#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */ -#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */ -#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */ -#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ -#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ -#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */ -#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ -#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */ -#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */ -#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ -#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */ -#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */ -#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */ -#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */ -#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ -#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */ -#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */ -#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ -#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ -#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */ -#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */ -#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ - -/* ########################## Assert Selection ############################## */ -/** - * @brief Uncomment the line below to expanse the "assert_param" macro in the - * HAL drivers code - */ -/* #define USE_FULL_ASSERT 1U */ - -/* ################## Ethernet peripheral configuration ##################### */ - -/* Section 1 : Ethernet peripheral configuration */ - -/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ -#define MAC_ADDR0 2U -#define MAC_ADDR1 0U -#define MAC_ADDR2 0U -#define MAC_ADDR3 0U -#define MAC_ADDR4 0U -#define MAC_ADDR5 0U - -/* Definition of the Ethernet driver buffers size and count */ -#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ -#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ -#define ETH_RXBUFNB ((uint32_t)4U) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ -#define ETH_TXBUFNB ((uint32_t)4U) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ - -/* Section 2: PHY configuration section */ - -/* DP83848_PHY_ADDRESS Address*/ -#define DP83848_PHY_ADDRESS 0x01U -/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ -#define PHY_RESET_DELAY 0x000000FFU -/* PHY Configuration delay */ -#define PHY_CONFIG_DELAY 0x00000FFFU - -#define PHY_READ_TO 0x0000FFFFU -#define PHY_WRITE_TO 0x0000FFFFU - -/* Section 3: Common PHY Registers */ - -#define PHY_BCR ((uint16_t)0x0000) /*!< Transceiver Basic Control Register */ -#define PHY_BSR ((uint16_t)0x0001) /*!< Transceiver Basic Status Register */ - -#define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */ -#define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */ -#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */ -#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */ -#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */ -#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */ -#define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */ -#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */ -#define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */ -#define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */ - -#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */ -#define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */ -#define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */ - -/* Section 4: Extended PHY Registers */ -#define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */ - -#define PHY_SPEED_STATUS ((uint16_t)0x0002U) /*!< PHY Speed mask */ -#define PHY_DUPLEX_STATUS ((uint16_t)0x0004U) /*!< PHY Duplex mask */ - -/* ################## SPI peripheral configuration ########################## */ - -/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver - * Activated: CRC code is present inside driver - * Deactivated: CRC code cleaned from driver - */ -#ifndef USE_SPI_CRC -#define USE_SPI_CRC 0U -#endif - -/* Includes ------------------------------------------------------------------*/ -/** - * @brief Include module's header file - */ - -#ifdef HAL_RCC_MODULE_ENABLED -#include "stm32f4xx_hal_rcc.h" -#endif /* HAL_RCC_MODULE_ENABLED */ - -#ifdef HAL_GPIO_MODULE_ENABLED -#include "stm32f4xx_hal_gpio.h" -#endif /* HAL_GPIO_MODULE_ENABLED */ - -#ifdef HAL_EXTI_MODULE_ENABLED -#include "stm32f4xx_hal_exti.h" -#endif /* HAL_EXTI_MODULE_ENABLED */ - -#ifdef HAL_DMA_MODULE_ENABLED -#include "stm32f4xx_hal_dma.h" -#endif /* HAL_DMA_MODULE_ENABLED */ - -#ifdef HAL_CORTEX_MODULE_ENABLED -#include "stm32f4xx_hal_cortex.h" -#endif /* HAL_CORTEX_MODULE_ENABLED */ - -#ifdef HAL_ADC_MODULE_ENABLED -#include "stm32f4xx_hal_adc.h" -#endif /* HAL_ADC_MODULE_ENABLED */ - -#ifdef HAL_CAN_MODULE_ENABLED -#include "stm32f4xx_hal_can.h" -#endif /* HAL_CAN_MODULE_ENABLED */ - -#ifdef HAL_CAN_LEGACY_MODULE_ENABLED -#include "stm32f4xx_hal_can_legacy.h" -#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */ - -#ifdef HAL_CRC_MODULE_ENABLED -#include "stm32f4xx_hal_crc.h" -#endif /* HAL_CRC_MODULE_ENABLED */ - -#ifdef HAL_CRYP_MODULE_ENABLED -#include "stm32f4xx_hal_cryp.h" -#endif /* HAL_CRYP_MODULE_ENABLED */ - -#ifdef HAL_DMA2D_MODULE_ENABLED -#include "stm32f4xx_hal_dma2d.h" -#endif /* HAL_DMA2D_MODULE_ENABLED */ - -#ifdef HAL_DAC_MODULE_ENABLED -#include "stm32f4xx_hal_dac.h" -#endif /* HAL_DAC_MODULE_ENABLED */ - -#ifdef HAL_DCMI_MODULE_ENABLED -#include "stm32f4xx_hal_dcmi.h" -#endif /* HAL_DCMI_MODULE_ENABLED */ - -#ifdef HAL_ETH_MODULE_ENABLED -#include "stm32f4xx_hal_eth.h" -#endif /* HAL_ETH_MODULE_ENABLED */ - -#ifdef HAL_FLASH_MODULE_ENABLED -#include "stm32f4xx_hal_flash.h" -#endif /* HAL_FLASH_MODULE_ENABLED */ - -#ifdef HAL_SRAM_MODULE_ENABLED -#include "stm32f4xx_hal_sram.h" -#endif /* HAL_SRAM_MODULE_ENABLED */ - -#ifdef HAL_NOR_MODULE_ENABLED -#include "stm32f4xx_hal_nor.h" -#endif /* HAL_NOR_MODULE_ENABLED */ - -#ifdef HAL_NAND_MODULE_ENABLED -#include "stm32f4xx_hal_nand.h" -#endif /* HAL_NAND_MODULE_ENABLED */ - -#ifdef HAL_PCCARD_MODULE_ENABLED -#include "stm32f4xx_hal_pccard.h" -#endif /* HAL_PCCARD_MODULE_ENABLED */ - -#ifdef HAL_SDRAM_MODULE_ENABLED -#include "stm32f4xx_hal_sdram.h" -#endif /* HAL_SDRAM_MODULE_ENABLED */ - -#ifdef HAL_HASH_MODULE_ENABLED -#include "stm32f4xx_hal_hash.h" -#endif /* HAL_HASH_MODULE_ENABLED */ - -#ifdef HAL_I2C_MODULE_ENABLED -#include "stm32f4xx_hal_i2c.h" -#endif /* HAL_I2C_MODULE_ENABLED */ - -#ifdef HAL_SMBUS_MODULE_ENABLED -#include "stm32f4xx_hal_smbus.h" -#endif /* HAL_SMBUS_MODULE_ENABLED */ - -#ifdef HAL_I2S_MODULE_ENABLED -#include "stm32f4xx_hal_i2s.h" -#endif /* HAL_I2S_MODULE_ENABLED */ - -#ifdef HAL_IWDG_MODULE_ENABLED -#include "stm32f4xx_hal_iwdg.h" -#endif /* HAL_IWDG_MODULE_ENABLED */ - -#ifdef HAL_LTDC_MODULE_ENABLED -#include "stm32f4xx_hal_ltdc.h" -#endif /* HAL_LTDC_MODULE_ENABLED */ - -#ifdef HAL_PWR_MODULE_ENABLED -#include "stm32f4xx_hal_pwr.h" -#endif /* HAL_PWR_MODULE_ENABLED */ - -#ifdef HAL_RNG_MODULE_ENABLED -#include "stm32f4xx_hal_rng.h" -#endif /* HAL_RNG_MODULE_ENABLED */ - -#ifdef HAL_RTC_MODULE_ENABLED -#include "stm32f4xx_hal_rtc.h" -#endif /* HAL_RTC_MODULE_ENABLED */ - -#ifdef HAL_SAI_MODULE_ENABLED -#include "stm32f4xx_hal_sai.h" -#endif /* HAL_SAI_MODULE_ENABLED */ - -#ifdef HAL_SD_MODULE_ENABLED -#include "stm32f4xx_hal_sd.h" -#endif /* HAL_SD_MODULE_ENABLED */ - -#ifdef HAL_SPI_MODULE_ENABLED -#include "stm32f4xx_hal_spi.h" -#endif /* HAL_SPI_MODULE_ENABLED */ - -#ifdef HAL_TIM_MODULE_ENABLED -#include "stm32f4xx_hal_tim.h" -#endif /* HAL_TIM_MODULE_ENABLED */ - -#ifdef HAL_UART_MODULE_ENABLED -#include "stm32f4xx_hal_uart.h" -#endif /* HAL_UART_MODULE_ENABLED */ - -#ifdef HAL_USART_MODULE_ENABLED -#include "stm32f4xx_hal_usart.h" -#endif /* HAL_USART_MODULE_ENABLED */ - -#ifdef HAL_IRDA_MODULE_ENABLED -#include "stm32f4xx_hal_irda.h" -#endif /* HAL_IRDA_MODULE_ENABLED */ - -#ifdef HAL_SMARTCARD_MODULE_ENABLED -#include "stm32f4xx_hal_smartcard.h" -#endif /* HAL_SMARTCARD_MODULE_ENABLED */ - -#ifdef HAL_WWDG_MODULE_ENABLED -#include "stm32f4xx_hal_wwdg.h" -#endif /* HAL_WWDG_MODULE_ENABLED */ - -#ifdef HAL_PCD_MODULE_ENABLED -#include "stm32f4xx_hal_pcd.h" -#endif /* HAL_PCD_MODULE_ENABLED */ - -#ifdef HAL_HCD_MODULE_ENABLED -#include "stm32f4xx_hal_hcd.h" -#endif /* HAL_HCD_MODULE_ENABLED */ - -#ifdef HAL_DSI_MODULE_ENABLED -#include "stm32f4xx_hal_dsi.h" -#endif /* HAL_DSI_MODULE_ENABLED */ - -#ifdef HAL_QSPI_MODULE_ENABLED -#include "stm32f4xx_hal_qspi.h" -#endif /* HAL_QSPI_MODULE_ENABLED */ - -#ifdef HAL_CEC_MODULE_ENABLED -#include "stm32f4xx_hal_cec.h" -#endif /* HAL_CEC_MODULE_ENABLED */ - -#ifdef HAL_FMPI2C_MODULE_ENABLED -#include "stm32f4xx_hal_fmpi2c.h" -#endif /* HAL_FMPI2C_MODULE_ENABLED */ - -#ifdef HAL_SPDIFRX_MODULE_ENABLED -#include "stm32f4xx_hal_spdifrx.h" -#endif /* HAL_SPDIFRX_MODULE_ENABLED */ - -#ifdef HAL_DFSDM_MODULE_ENABLED -#include "stm32f4xx_hal_dfsdm.h" -#endif /* HAL_DFSDM_MODULE_ENABLED */ - -#ifdef HAL_LPTIM_MODULE_ENABLED -#include "stm32f4xx_hal_lptim.h" -#endif /* HAL_LPTIM_MODULE_ENABLED */ - -#ifdef HAL_MMC_MODULE_ENABLED -#include "stm32f4xx_hal_mmc.h" -#endif /* HAL_MMC_MODULE_ENABLED */ - -/* Exported macro ------------------------------------------------------------*/ -#ifdef USE_FULL_ASSERT -/** - * @brief The assert_param macro is used for function's parameters check. - * @param expr If expr is false, it calls assert_failed function - * which reports the name of the source file and the source - * line number of the call that failed. - * If expr is true, it returns no value. - * @retval None - */ -#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) -/* Exported functions ------------------------------------------------------- */ -void assert_failed(uint8_t *file, uint32_t line); -#else -#define assert_param(expr) ((void)0U) -#endif /* USE_FULL_ASSERT */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32F4xx_HAL_CONF_CUSTOM_H */ - - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/ldscript.ld deleted file mode 100644 index c5788dbebe..0000000000 --- a/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/ldscript.ld +++ /dev/null @@ -1,187 +0,0 @@ -/* -***************************************************************************** -** -** File : ldscript.ld -** -** Abstract : Linker script for STM32F401RETx Device with -** 512KByte FLASH, 96KByte RAM -** -** Set heap size, stack size and stack location according -** to application requirements. -** -** Set memory bank area and size if external memory is used. -** -** Target : STMicroelectronics STM32 -** -** -** Distribution: The file is distributed as is, without any warranty -** of any kind. -** -***************************************************************************** -** @attention -** -**

© COPYRIGHT(c) 2014 Ac6

-** -** Redistribution and use in source and binary forms, with or without modification, -** are permitted provided that the following conditions are met: -** 1. Redistributions of source code must retain the above copyright notice, -** this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright notice, -** this list of conditions and the following disclaimer in the documentation -** and/or other materials provided with the distribution. -** 3. Neither the name of Ac6 nor the names of its contributors -** may be used to endorse or promote products derived from this software -** without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -** -***************************************************************************** -*/ - -/* Entry Point */ -ENTRY(Reset_Handler) - -/* Highest address of the user mode stack */ -_estack = 0x20018000; /* end of RAM */ -/* Generate a link error if heap and stack don't fit into RAM */ -_Min_Heap_Size = 0x200; /* required amount of heap */ -_Min_Stack_Size = 0x400; /* required amount of stack */ - -/* Specify the memory areas */ -MEMORY -{ -FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K -RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 96K -} - -/* Define output sections */ -SECTIONS -{ - /* The startup code goes first into FLASH */ - .isr_vector : - { - . = ALIGN(4); - KEEP(*(.isr_vector)) /* Startup code */ - . = ALIGN(4); - } >FLASH - - /* The program code and other data goes into FLASH */ - .text : - { - . = ALIGN(4); - *(.text) /* .text sections (code) */ - *(.text*) /* .text* sections (code) */ - *(.glue_7) /* glue arm to thumb code */ - *(.glue_7t) /* glue thumb to arm code */ - *(.eh_frame) - - KEEP (*(.init)) - KEEP (*(.fini)) - - . = ALIGN(4); - _etext = .; /* define a global symbols at end of code */ - } >FLASH - - /* Constant data goes into FLASH */ - .rodata : - { - . = ALIGN(4); - *(.rodata) /* .rodata sections (constants, strings, etc.) */ - *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ - . = ALIGN(4); - } >FLASH - - .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH - .ARM : { - __exidx_start = .; - *(.ARM.exidx*) - __exidx_end = .; - } >FLASH - - .preinit_array : - { - PROVIDE_HIDDEN (__preinit_array_start = .); - KEEP (*(.preinit_array*)) - PROVIDE_HIDDEN (__preinit_array_end = .); - } >FLASH - .init_array : - { - PROVIDE_HIDDEN (__init_array_start = .); - KEEP (*(SORT(.init_array.*))) - KEEP (*(.init_array*)) - PROVIDE_HIDDEN (__init_array_end = .); - } >FLASH - .fini_array : - { - PROVIDE_HIDDEN (__fini_array_start = .); - KEEP (*(SORT(.fini_array.*))) - KEEP (*(.fini_array*)) - PROVIDE_HIDDEN (__fini_array_end = .); - } >FLASH - - /* used by the startup to initialize data */ - _sidata = LOADADDR(.data); - - /* Initialized data sections goes into RAM, load LMA copy after code */ - .data : - { - . = ALIGN(4); - _sdata = .; /* create a global symbol at data start */ - *(.data) /* .data sections */ - *(.data*) /* .data* sections */ - - . = ALIGN(4); - _edata = .; /* define a global symbol at data end */ - } >RAM AT> FLASH - - - /* Uninitialized data section */ - . = ALIGN(4); - .bss : - { - /* This is used by the startup in order to initialize the .bss section */ - _sbss = .; /* define a global symbol at bss start */ - __bss_start__ = _sbss; - *(.bss) - *(.bss*) - *(COMMON) - - . = ALIGN(4); - _ebss = .; /* define a global symbol at bss end */ - __bss_end__ = _ebss; - } >RAM - - /* User_heap_stack section, used to check that there is enough RAM left */ - ._user_heap_stack : - { - . = ALIGN(4); - PROVIDE ( end = . ); - PROVIDE ( _end = . ); - . = . + _Min_Heap_Size; - . = . + _Min_Stack_Size; - . = ALIGN(4); - } >RAM - - - - /* Remove information from the standard libraries */ - /DISCARD/ : - { - libc.a ( * ) - libm.a ( * ) - libgcc.a ( * ) - } - - .ARM.attributes 0 : { *(.ARM.attributes) } -} - - diff --git a/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/variant.cpp b/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/variant.cpp deleted file mode 100644 index 4ecbff0ecc..0000000000 --- a/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/variant.cpp +++ /dev/null @@ -1,310 +0,0 @@ -/* - ******************************************************************************* - * Copyright (c) 2017, STMicroelectronics - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************* - */ - -#include "pins_arduino.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef ARDUINO_STEVAL -// Pin number -// This array allows to wrap Arduino pin number(Dx or x) -// to STM32 PinName (PX_n) -const PinName digitalPin[] = { - PA_9, // TX - PA_10, // RX - - // WIFI - PD_3, // CTS - PD_4, // RTS - PD_5, // TX - PD_6, // RX - PB_5, // WIFI_WAKEUP - PE_11, // WIFI_RESET - PE_12, // WIFI_BOOT - - // STATUS_LED - PE_1, //STATUS_LED - - // SPI USER - PB_12, // SPI_CS - PB_15, // SPI_MOSI - PB_14, // SPI_MISO - PB_13, // SPI_SCK - - // I2C USER - PB_7, // SDA - PB_6, // SCL - - // SPI - PA_4, // SPI_CS - PA_5, // SPI_SCK - PA_6, // SPI_MISO - PA_7, // SPI_MOSI - - // JTAG - PA_13, // JTAG_TMS/SWDIO - PA_14, // JTAG_TCK/SWCLK - PB_3, // JTAG_TDO/SWO - - // SDCARD - PC_8, // SDIO_D0 - PC_9, // SDIO_D1 - PA_15, // SD_CARD_DETECT - PC_10, // SDIO_D2 - PC_11, // SDIO_D3 - PC_12, // SDIO_CK - PD_2, // SDIO_CMD - - // OTG - PA_11, // OTG_DM - PA_12, // OTG_DP - - // IR/PROBE - PD_1, // IR_OUT - PC_1, // IR_ON - - // USER_PINS - PD_7, // USER3 - PB_9, // USER1 - PE_0, // USER2 - PB_4, // USER4 - - // USERKET - PE_7, // USER_BUTTON - - // ENDSTOPS - PD_8, // X_STOP - PD_9, // Y_STOP - PD_10, // Z_STOP - PD_11, // U_STOP - PA_8, // V_STOP - PD_0, // W_STOP - - // HEATERS - PD_13, // BED_HEAT_2 - PD_14, // BED_HEAT_1 - PD_15, // BED_HEAT_3 - PC_7, // E1_HEAT_PWM - PB_0, // E2_HEAT_PWM - PB_1, // E3_HEAT_PWM - - // THERMISTOR - PC_2, // BED_THERMISTOR_1 - PC_3, // BED_THERMISTOR_2 - PA_3, // BED_THERMISTOR_3 - PA_0, // E1_THERMISTOR - PA_1, // E2_THERMISTOR - PA_2, // E3_THERMISTOR - - // FANS - PC_4, // E1_FAN - PC_5, // E2_FAN - PE_8, // E3_FAN - - // X_MOTOR - PE_13, // X_RESET - PE_14, // X_PWM - PE_15, // X_DIR - - // Y_MOTOR - PE_10, // Y_RESET - PB_10, // Y_PWM - PE_9, // Y_DIR - - // Z_MOTOR - PC_15, // Z_RESET - PC_6, // Z_PWM - PC_0, // Z_DIR - - // E1_MOTOR - PC_14, // E1_RESET - PC_13, // E1_DIR - PD_12, // E1_PWM - - // E2_MOTOR - PE_4, // E2_RESET - PE_5, // E2_PWM - PE_6, // E2_DIR - - // E3_MOTOR - PE_3, // E3_RESET - PE_2, // E3_DIR - PB_8 // E3_PWM -}; -#endif - -#ifdef __cplusplus -} -#endif - -// ---------------------------------------------------------------------------- - -#ifdef __cplusplus -extern "C" { -#endif -/** - * @brief System Clock Configuration - * The system Clock is configured as follow : - * System Clock source = PLL (HSI) - * SYSCLK(Hz) = 84000000 - * HCLK(Hz) = 84000000 - * AHB Prescaler = 1 - * APB1 Prescaler = 2 - * APB2 Prescaler = 1 - * HSI Frequency(Hz) = 16000000 - * PLL_M = 16 - * PLL_N = 336 - * PLL_P = 4 - * PLL_Q = 7 - * VDD(V) = 3.3 - * Main regulator output voltage = Scale2 mode - * Flash Latency(WS) = 2 - * @param None - * @retval None - */ -WEAK void SystemClock_Config(void) -{ - RCC_OscInitTypeDef RCC_OscInitStruct = {}; - RCC_ClkInitTypeDef RCC_ClkInitStruct = {}; - - /* Configure the main internal regulator output voltage */ - __HAL_RCC_PWR_CLK_ENABLE(); - __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE2); - - /* Initializes the CPU, AHB and APB busses clocks */ - RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; - RCC_OscInitStruct.HSEState = RCC_HSE_ON; - RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; - RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; - RCC_OscInitStruct.PLL.PLLM = 15; - RCC_OscInitStruct.PLL.PLLN = 144; - RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4; - RCC_OscInitStruct.PLL.PLLQ = 5; - if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { - Error_Handler(); - } - /* Initializes the CPU, AHB and APB busses clocks */ - RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK - | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2; - RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; - RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; - RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; - RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; - - if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) { - Error_Handler(); - } -} - -#ifdef __cplusplus -} -#endif - - -// PA_0 54 // E1_THERMISTOR -// PA_1 55 // E2_THERMISTOR -// PA_2 56 // E3_THERMISTOR -// PA_3 53 // BED_THERMISTOR_3 -// PA_4 16 // SPI_CS -// PA_5 17 // SPI_SCK -// PA_6 18 // SPI_MISO -// PA_7 19 // SPI_MOSI -// PA_8 43 // V_STOP -// PA_9 0 //TX -// PA_10 1 //RX -// PA_11 30 //OTG_DM -// PA_12 31 //OTG_DP -// PA_13 20 // JTAG_TMS/SWDIO -// PA_14 21 // JTAG_TCK/SWCLK -// PA_15 25 // SD_CARD_DETECT -// PB_0 49 // E2_HEAT_PWM -// PB_1 50 // E3_HEAT_PWM -// PB_3 22 // JTAG_TDO/SWO -// PB_4 37 // USER4 -// PB_5 6 // WIFI_WAKEUP -// PB_6 15 // SCL -// PB_7 14 // SDA -// PB_8 77 // E3_PWM -// PB_9 35 // USER1 -// PB_10 64 // Y_PWM -// PB_12 10 // SPI_CS -// PB_13 13 // SPI_SCK -// PB_14 12 // SPI_MISO -// PB_15 11 // SPI_MOSI -// PC_0 68 // Z_DIR -// PC_1 33 //IR_ON -// PC_2 51 // BED_THERMISTOR_1 -// PC_3 52 // BED_THERMISTOR_2 -// PC_4 57 // E1_FAN -// PC_5 58 // E2_FAN -// PC_6 67 // Z_PWM -// PC_7 48 // E1_HEAT_PWM -// PC_8 23 // SDIO_D0 -// PC_9 24 // SDIO_D1 -// PC_10 26 // SDIO_D2 -// PC_11 27 // SDIO_D3 -// PC_12 28 // SDIO_CK -// PC_13 70 // E1_DIR -// PC_14 69 // E1_RESET -// PC_15 66 // Z_RESET -// PD_0 44 // W_STOP -// PD_1 32 //IR_OUT -// PD_2 29 // SDIO_CMD -// PD_3 2 // CTS -// PD_4 3 // RTS -// PD_5 4 // TX -// PD_6 5 // RX -// PD_7 34 // USER3 -// PD_8 39 // X_STOP -// PD_9 40 // Y_STOP -// PD_10 41 // Z_STOP -// PD_11 42 // U_STOP -// PD_12 71 // E1_PWM -// PD_13 45 // BED_HEAT_2 -// PD_14 46 // BED_HEAT_1 -// PD_15 47 // BED_HEAT_3 -// PE_0 36 // USER2 -// PE_1 9 // STATUS_LED -// PE_2 76 // E3_DIR -// PE_3 75 // E3_RESET -// PE_4 72 // E2_RESET -// PE_5 73 // E2_PWM -// PE_6 74 // E2_DIR -// PE_7 38 // USER_BUTTON -// PE_8 59 // E3_FAN -// PE_9 65 // Y_DIR -// PE_10 63 // Y_RESET -// PE_11 7 // WIFI_RESET -// PE_12 8 // WIFI_BOOT -// PE_13 60 // X_RESET -// PE_14 61 // X_PWM -// PE_15 62 // X_DIR diff --git a/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/variant.h deleted file mode 100644 index df7295ab17..0000000000 --- a/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/variant.h +++ /dev/null @@ -1,327 +0,0 @@ -/* - ******************************************************************************* - * Copyright (c) 2017, STMicroelectronics - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************* - */ - -#ifndef _VARIANT_ARDUINO_STM32_ -#define _VARIANT_ARDUINO_STM32_ -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ - -#ifdef __cplusplus -extern "C" { -#endif // __cplusplus - -/*---------------------------------------------------------------------------- - * Pins - *----------------------------------------------------------------------------*/ -#ifdef ARDUINO_STEVAL - - -/*---------------------------------------------------------------------------- - * Pins - *----------------------------------------------------------------------------*/ -// USART1_MAIN -#define PA9 0 //TX -#define PA10 1 //RX - -// WIFI (USART2) -#define PD3 2 // CTS -#define PD4 3 // RTS -#define PD5 4 // TX -#define PD6 5 // RX -#define PB5 6 // WIFI_WAKEUP -#define PE11 7 // WIFI_RESET -#define PE12 8 // WIFI_BOOT - -// STATUS_LED -#define PE1 9 // STATUS_LED - -// SPI USER -#define PB12 10 // SPI_CS -#define PB15 11 // SPI_MOSI -#define PB14 12 // SPI_MISO -#define PB13 13 // SPI_SCK - -// I2C USER -#define PB7 14 // SDA -#define PB6 15 // SCL - -// SPI -#define PA4 16 // SPI_CS -#define PA5 17 // SPI_SCK -#define PA6 18 // SPI_MISO -#define PA7 19 // SPI_MOSI - -// JTAG -#define PA13 20 // JTAG_TMS/SWDIO -#define PA14 21 // JTAG_TCK/SWCLK -#define PB3 22 // JTAG_TDO/SWO - -// SDCARD -#define PC8 23 // SDIO_D0 -#define PC9 24 // SDIO_D1 -#define PA15 25 // SD_CARD_DETECT -#define PC10 26 // SDIO_D2 -#define PC11 27 // SDIO_D3 -#define PC12 28 // SDIO_CK -#define PD2 29 // SDIO_CMD - -// OTG -#define PA11 30 //OTG_DM -#define PA12 31 //OTG_DP - -// IR/PROBE -#define PD1 32 //IR_OUT -#define PC1 33 //IR_ON - -// USER_PINS -#define PD7 34 // USER3 -#define PB9 35 // USER1 -#define PE0 36 // USER2 -#define PB4 37 // USER4 - -// USERKET -#define PE7 38 // USER_BUTTON - -// ENDSTOPS -#define PD8 39 // X_STOP -#define PD9 40 // Y_STOP -#define PD10 41 // Z_STOP -#define PD11 42 // U_STOP -#define PA8 43 // V_STOP -#define PD0 44 // W_STOP - -// HEATERS -#define PD13 45 // BED_HEAT_2 -#define PD14 46 // BED_HEAT_1 -#define PD15 47 // BED_HEAT_3 -#define PC7 48 // E1_HEAT_PWM -#define PB0 49 // E2_HEAT_PWM -#define PB1 50 // E3_HEAT_PWM - -// THERMISTOR -#define PC2 51 // BED_THERMISTOR_1 -#define PC3 52 // BED_THERMISTOR_2 -#define PA3 53 // BED_THERMISTOR_3 -#define PA0 54 // E1_THERMISTOR -#define PA1 55 // E2_THERMISTOR -#define PA2 56 // E3_THERMISTOR - -// FANS -#define PC4 57 // E1_FAN -#define PC5 58 // E2_FAN -#define PE8 59 // E3_FAN - -// X_MOTOR -#define PE13 60 // X_RESET -#define PE14 61 // X_PWM -#define PE15 62 // X_DIR - -// Y_MOTOR -#define PE10 63 // Y_RESET -#define PB10 64 // Y_PWM -#define PE9 65 // Y_DIR - -// Z_MOTOR -#define PC15 66 // Z_RESET -#define PC6 67 // Z_PWM -#define PC0 68 // Z_DIR - -// E1_MOTOR -#define PC14 69 // E1_RESET -#define PC13 70 // E1_DIR -#define PD12 71 // E1_PWM - -// E2_MOTOR -#define PE4 72 // E2_RESET -#define PE5 73 // E2_PWM -#define PE6 74 // E2_DIR - -// E3_MOTOR -#define PE3 75 // E3_RESET -#define PE2 76 // E3_DIR -#define PB8 77 // E3_PWM - -// This must be a literal -#define NUM_DIGITAL_PINS 78 -// This must be a literal with a value less than or equal to to MAX_ANALOG_INPUTS -#define NUM_ANALOG_INPUTS 6 -#define NUM_ANALOG_FIRST 51 - -// On-board LED pin number -#define LED_BUILTIN PE1 -#define LED_GREEN LED_BUILTIN - -// On-board user button -#define USER_BTN PE7 - -// UART Definitions -#define SERIAL_UART_INSTANCE 1 // Connected to ST-Link -//#define SERIAL_UART_INSTANCE 2 // Connected to WIFI - -// Default pin used for 'Serial' instance (ex: ST-Link) -// Mandatory for Firmata -#if SERIAL_UART_INSTANCE == 1 // ST-Link & J23 - #define PIN_SERIAL_RX PA10 - #define PIN_SERIAL_TX PA9 -#elif SERIAL_UART_INSTANCE == 2 // WIFI interface - #define PIN_SERIAL2_RX PD6 - #define PIN_SERIAL2_TX PD5 -#else - #error "Invalid setting for SERIAL_UART_INSTANCE." -#endif - -// Timer Definitions -#define TIMER_SERVO TIM4 // TIMER_SERVO must be defined in this file -#define TIMER_TONE TIM5 // TIMER_TONE must be defined in this file - -/* SD detect signal */ -/* - * By default, R67 is not provided, so SD card detect is not used. - * Note: SD CD (pin 16 of expansion connector J23) can be connected - * to GND in order to be able to use SD_DETECT_PIN - */ -/*#define SD_DETECT_PIN PA15*/ - -/* HAL configuration */ -#define HSE_VALUE 25000000U - -/* Extra HAL modules */ -#define HAL_SD_MODULE_ENABLED - -#endif - -#ifdef __cplusplus -} // extern "C" -#endif -/*---------------------------------------------------------------------------- - * Arduino objects - C++ only - *----------------------------------------------------------------------------*/ - -#ifdef __cplusplus -// These serial port names are intended to allow libraries and architecture-neutral -// sketches to automatically default to the correct port name for a particular type -// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, -// the first hardware serial port whose RX/TX pins are not dedicated to another use. -// -// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor -// -// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial -// -// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library -// -// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. -// -// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX -// pins are NOT connected to anything by default. -#define SERIAL_PORT_MONITOR Serial -#define SERIAL_PORT_HARDWARE Serial1 -#endif - -#endif // _VARIANT_ARDUINO_STM32_ - -// PA0 54 // E1_THERMISTOR -// PA1 55 // E2_THERMISTOR -// PA2 56 // E3_THERMISTOR -// PA3 53 // BED_THERMISTOR_3 -// PA4 16 // SPI_CS -// PA5 17 // SPI_SCK -// PA6 18 // SPI_MISO -// PA7 19 // SPI_MOSI -// PA8 43 // V_STOP -// PA9 0 //TX -// PA10 1 //RX -// PA11 30 //OTG_DM -// PA12 31 //OTG_DP -// PA13 20 // JTAG_TMS/SWDIO -// PA14 21 // JTAG_TCK/SWCLK -// PA15 25 // SD_CARD_DETECT -// PB0 49 // E2_HEAT_PWM -// PB1 50 // E3_HEAT_PWM -// PB3 22 // JTAG_TDO/SWO -// PB4 37 // USER4 -// PB5 6 // WIFI_WAKEUP -// PB6 15 // SCL -// PB7 14 // SDA -// PB8 77 // E3_PWM -// PB9 35 // USER1 -// PB10 64 // Y_PWM -// PB12 10 // SPI_CS -// PB13 13 // SPI_SCK -// PB14 12 // SPI_MISO -// PB15 11 // SPI_MOSI -// PC0 68 // Z_DIR -// PC1 33 //IR_ON -// PC2 51 // BED_THERMISTOR_1 -// PC3 52 // BED_THERMISTOR_2 -// PC4 57 // E1_FAN -// PC5 58 // E2_FAN -// PC6 67 // Z_PWM -// PC7 48 // E1_HEAT_PWM -// PC8 23 // SDIO_D0 -// PC9 24 // SDIO_D1 -// PC10 26 // SDIO_D2 -// PC11 27 // SDIO_D3 -// PC12 28 // SDIO_CK -// PC13 70 // E1_DIR -// PC14 69 // E1_RESET -// PC15 66 // Z_RESET -// PD0 44 // W_STOP -// PD1 32 //IR_OUT -// PD2 29 // SDIO_CMD -// PD3 2 // CTS -// PD4 3 // RTS -// PD5 4 // TX -// PD6 5 // RX -// PD7 34 // USER3 -// PD8 39 // X_STOP -// PD9 40 // Y_STOP -// PD10 41 // Z_STOP -// PD11 42 // U_STOP -// PD12 71 // E1_PWM -// PD13 45 // BED_HEAT_2 -// PD14 46 // BED_HEAT_1 -// PD15 47 // BED_HEAT_3 -// PE0 36 // USER2 -// PE1 9 // STATUS_LED -// PE2 76 // E3_DIR -// PE3 75 // E3_RESET -// PE4 72 // E2_RESET -// PE5 73 // E2_PWM -// PE6 74 // E2_DIR -// PE7 38 // USER_BUTTON -// PE8 59 // E3_FAN -// PE9 65 // Y_DIR -// PE10 63 // Y_RESET -// PE11 7 // WIFI_RESET -// PE12 8 // WIFI_BOOT -// PE13 60 // X_RESET -// PE14 61 // X_PWM -// PE15 62 // X_DIR diff --git a/buildroot/share/dwin/bin/DWIN_ICO.py b/buildroot/share/dwin/bin/DWIN_ICO.py index 8ac680c61e..3ddc734022 100644 --- a/buildroot/share/dwin/bin/DWIN_ICO.py +++ b/buildroot/share/dwin/bin/DWIN_ICO.py @@ -144,7 +144,7 @@ def createFile(self, iconDir, filename): # process each file: try: index = int(dirEntry.name[0:3]) - if (index < 0) or (index > 255): + if not (0 <= index <= 255): print('...Ignoring invalid index on', dirEntry.path) continue #dirEntry.path is iconDir/name diff --git a/buildroot/share/git/firstpush b/buildroot/share/git/firstpush index 9a68fc5afd..db025f6c52 100755 --- a/buildroot/share/git/firstpush +++ b/buildroot/share/git/firstpush @@ -16,7 +16,7 @@ BRANCH=${INFO[5]} git push --set-upstream origin HEAD:$BRANCH -OPEN=$(echo $(which gnome-open xdg-open open) | awk '{ print $1 }') +OPEN=$( which gnome-open xdg-open open | head -n1 ) URL="https://github.com/$FORK/$REPO/commits/$BRANCH" if [ -z "$OPEN" ]; then diff --git a/buildroot/share/git/mfconfig b/buildroot/share/git/mfconfig index 7092bc8220..b379317d98 100755 --- a/buildroot/share/git/mfconfig +++ b/buildroot/share/git/mfconfig @@ -110,53 +110,15 @@ if [[ $ACTION == "init" ]]; then ((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Commit for comparison" >/dev/null # Init Cartesian/SCARA/TPARA configurations to default - echo "- Initializing Cartesian/SCARA/TPARA configs to default state..." + echo "- Initializing configs to default state..." - find "$CEXA" -name $BC ! -path */delta/* -print0 \ + find "$CEXA" -name $BC -print0 \ | while read -d $'\0' F ; do cp "$CDEF/$BC" "$F" ; done - find "$CEXA" -name $AC ! -path */delta/* -print0 \ + find "$CEXA" -name $AC -print0 \ | while read -d $'\0' F ; do cp "$CDEF/$AC" "$F" ; done # DEBUG: Commit the reset for review - ((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Reset Cartesian/SCARA/TPARA configs..." >/dev/null - - # Create base Delta configurations - cp "$CDEF"/* "$CEXA/delta/generic" - - # DEBUG: Commit the reset for review - ((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Reset Generic Delta..." >/dev/null - - cp -R "$TEMP/$CEXA/delta/generic"/Conf* "$CEXA/delta/generic" - - # DEBUG: Commit Generic Delta changes for review - ((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Apply Generic Delta..." >/dev/null - - # Reset all Delta configs to the generic version - find "$CEXA/delta" -name $BC ! -path */generic/* -print0 \ - | while read -d $'\0' F ; do cp "$CEXA/delta/generic/$BC" "$F" ; done - find "$CEXA/delta" -name $AC ! -path */generic/* -print0 \ - | while read -d $'\0' F ; do cp "$CEXA/delta/generic/$AC" "$F" ; done - - # DEBUG: Commit the Delta reset for review - ((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Reset Delta configs..." >/dev/null - - # Reset all SCARA configs to the default cartesian - find "$CEXA/SCARA" -name $BC \ - | while read -d $'\0' F ; do cp "$CDEF/$BC" "$F" ; done - find "$CEXA/SCARA" -name $AC \ - | while read -d $'\0' F ; do cp "$CDEF/$AC" "$F" ; done - - # DEBUG: Commit the SCARA reset for review - ((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Reset SCARA..." >/dev/null - - # Reset all TPARA configs to the default cartesian - find "$CEXA/TPARA" -name $BC \ - | while read -d $'\0' F ; do cp "$CDEF/$BC" "$F" ; done - find "$CEXA/TPARA" -name $AC \ - | while read -d $'\0' F ; do cp "$CDEF/$AC" "$F" ; done - - # DEBUG: Commit the TPARA reset for review - ((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Reset TPARA..." >/dev/null + ((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Reset configs..." >/dev/null # Update the %VERSION% in the README.md file VERS=$( echo $EXPORT | $SED 's/release-//' ) diff --git a/buildroot/share/git/mfdoc b/buildroot/share/git/mfdoc index ce21419016..29f0ec6873 100755 --- a/buildroot/share/git/mfdoc +++ b/buildroot/share/git/mfdoc @@ -17,7 +17,7 @@ BRANCH=${INFO[5]} opensite() { URL="http://127.0.0.1:4000/" - OPEN=$(echo $(which gnome-open xdg-open open) | awk '{ print $1 }') + OPEN=$( which gnome-open xdg-open open | head -n1 ) if [ -z "$OPEN" ]; then echo "Can't find a tool to open the URL:" echo $URL diff --git a/buildroot/share/git/mfpr b/buildroot/share/git/mfpr index 230bd2886c..c5eb4522c7 100755 --- a/buildroot/share/git/mfpr +++ b/buildroot/share/git/mfpr @@ -23,7 +23,7 @@ OLDBRANCH=${INFO[5]} # See if it's been pushed yet if [ -z "$(git branch -vv | grep ^\* | grep \\[origin)" ]; then firstpush; fi -OPEN=$(echo $(which gnome-open xdg-open open) | awk '{ print $1 }') +OPEN=$( which gnome-open xdg-open open | head -n1 ) URL="https://github.com/$ORG/$REPO/compare/$TARG...$FORK:$BRANCH?expand=1" if [ -z "$OPEN" ]; then diff --git a/buildroot/share/git/mfprep b/buildroot/share/git/mfprep index 0c9e54fe8d..75776cbba3 100755 --- a/buildroot/share/git/mfprep +++ b/buildroot/share/git/mfprep @@ -2,7 +2,7 @@ # # mfprep tag1 [tag2] # -# Find commits in bugfix-2.1.x that are not yet in 2.0.x. +# Find commits in bugfix-2.1.x that are not yet in 2.1.x. # # Specify a version tag to start from, and optional version tag to end at. # For bugfix-2.1.x the tag will be prefixed by dev- to distinguish it from the version tag, diff --git a/buildroot/share/git/mfpub b/buildroot/share/git/mfpub index 6a912e5515..6ffe627b92 100755 --- a/buildroot/share/git/mfpub +++ b/buildroot/share/git/mfpub @@ -45,7 +45,7 @@ git clean -d -f opensite() { URL="$1" - OPEN=$(echo $(which gnome-open xdg-open open) | awk '{ print $1 }') + OPEN=$( which gnome-open xdg-open open | head -n1 ) if [ -z "$OPEN" ]; then echo "Can't find a tool to open the URL:" echo $URL diff --git a/buildroot/share/scripts/MarlinBinaryProtocol.py b/buildroot/share/scripts/MarlinBinaryProtocol.py index 4887ad9919..ecf9df35e2 100644 --- a/buildroot/share/scripts/MarlinBinaryProtocol.py +++ b/buildroot/share/scripts/MarlinBinaryProtocol.py @@ -376,11 +376,13 @@ def close(self): token, data = self.await_response(1000) if token == 'PFT:success': print("File closed") - return + return True elif token == 'PFT:ioerror': print("Client storage device IO error") + return False elif token == 'PFT:invalid': print("No open file") + return False def abort(self): self.protocol.send(FileTransferProtocol.protocol_id, FileTransferProtocol.Packet.ABORT); @@ -417,12 +419,23 @@ def copy(self, filename, dest_filename, compression, dummy): self.write(data[start:end]) kibs = (( (i+1) * block_size) / 1024) / (millis() + 1 - start_time) * 1000 if (i / blocks) >= dump_pctg: - print("\r{0:2.2f}% {1:4.2f}KiB/s {2} Errors: {3}".format((i / blocks) * 100, kibs, "[{0:4.2f}KiB/s]".format(kibs * cratio) if compression_support else "", self.protocol.errors), end='') + print("\r{0:2.0f}% {1:4.2f}KiB/s {2} Errors: {3}".format((i / blocks) * 100, kibs, "[{0:4.2f}KiB/s]".format(kibs * cratio) if compression_support else "", self.protocol.errors), end='') dump_pctg += 0.1 - print("\r{0:2.2f}% {1:4.2f}KiB/s {2} Errors: {3}".format(100, kibs, "[{0:4.2f}KiB/s]".format(kibs * cratio) if compression_support else "", self.protocol.errors)) # no one likes transfers finishing at 99.8% - - self.close() + if self.protocol.errors > 0: + # Dump last status (errors may not be visible) + print("\r{0:2.0f}% {1:4.2f}KiB/s {2} Errors: {3} - Aborting...".format((i / blocks) * 100, kibs, "[{0:4.2f}KiB/s]".format(kibs * cratio) if compression_support else "", self.protocol.errors), end='') + print("") # New line to break the transfer speed line + self.close() + print("Transfer aborted due to protocol errors") + #raise Exception("Transfer aborted due to protocol errors") + return False; + print("\r{0:2.0f}% {1:4.2f}KiB/s {2} Errors: {3}".format(100, kibs, "[{0:4.2f}KiB/s]".format(kibs * cratio) if compression_support else "", self.protocol.errors)) # no one likes transfers finishing at 99.8% + + if not self.close(): + print("Transfer failed") + return False print("Transfer complete") + return True class EchoProtocol(object): diff --git a/buildroot/share/scripts/config-labels.py b/buildroot/share/scripts/config-labels.py index 700604e452..519f7b67ca 100755 --- a/buildroot/share/scripts/config-labels.py +++ b/buildroot/share/scripts/config-labels.py @@ -22,7 +22,7 @@ # 2020-06-05 SRL style tweaks #----------------------------------- # -import sys,os +import sys from pathlib import Path from distutils.dir_util import copy_tree # for copy_tree, because shutil.copytree can't handle existing files, dirs @@ -58,10 +58,10 @@ def process_file(subdir: str, filename: str): # Read file #------------------------ lines = [] - infilepath = os.path.join(input_examples_dir, subdir, filename) + infilepath = Path(input_examples_dir, subdir, filename) try: # UTF-8 because some files contain unicode chars - with open(infilepath, 'rt', encoding="utf-8") as infile: + with infilepath.open('rt', encoding="utf-8") as infile: lines = infile.readlines() except Exception as e: @@ -123,25 +123,24 @@ def process_file(subdir: str, filename: str): #------------------------- # Output file #------------------------- - outdir = os.path.join(output_examples_dir, subdir) - outfilepath = os.path.join(outdir, filename) + outdir = Path(output_examples_dir, subdir) + outfilepath = outdir / filename if file_modified: # Note: no need to create output dirs, as the initial copy_tree # will do that. - print(' writing ' + str(outfilepath)) + print(' writing ' + outfilepath) try: # Preserve unicode chars; Avoid CR-LF on Windows. - with open(outfilepath, "w", encoding="utf-8", newline='\n') as outfile: - outfile.write("\n".join(outlines)) - outfile.write("\n") + with outfilepath.open("w", encoding="utf-8", newline='\n') as outfile: + outfile.write("\n".join(outlines) + "\n") except Exception as e: print('Failed to write file: ' + str(e) ) raise Exception else: - print(' no change for ' + str(outfilepath)) + print(' no change for ' + outfilepath) #---------- def main(): @@ -159,8 +158,8 @@ def main(): output_examples_dir = output_examples_dir.strip() output_examples_dir = output_examples_dir.rstrip('\\/') - for dir in [input_examples_dir, output_examples_dir]: - if not (os.path.exists(dir)): + for dir in (input_examples_dir, output_examples_dir): + if not Path(dir).exists(): print('Directory not found: ' + dir) sys.exit(1) @@ -181,8 +180,7 @@ def main(): #----------------------------- # Find and process files #----------------------------- - len_input_examples_dir = len(input_examples_dir); - len_input_examples_dir += 1 + len_input_examples_dir = 1 + len(input_examples_dir) for filename in files_to_mod: input_path = Path(input_examples_dir) diff --git a/buildroot/share/scripts/upload.py b/buildroot/share/scripts/upload.py index c7730d8f29..52fa1abc54 100644 --- a/buildroot/share/scripts/upload.py +++ b/buildroot/share/scripts/upload.py @@ -20,14 +20,18 @@ import MarlinBinaryProtocol -# Internal debug flag -Debug = False - #-----------------# # Upload Callback # #-----------------# def Upload(source, target, env): + #-------# + # Debug # + #-------# + Debug = False # Set to True to enable script debug + def debugPrint(data): + if Debug: print(f"[Debug]: {data}") + #------------------# # Marlin functions # #------------------# @@ -39,19 +43,35 @@ def _GetMarlinEnv(marlinEnv, feature): # Port functions # #----------------# def _GetUploadPort(env): - if Debug: print('Autodetecting upload port...') + debugPrint('Autodetecting upload port...') env.AutodetectUploadPort(env) - port = env.subst('$UPLOAD_PORT') - if not port: + portName = env.subst('$UPLOAD_PORT') + if not portName: raise Exception('Error detecting the upload port.') - if Debug: print('OK') - return port + debugPrint('OK') + return portName #-------------------------# # Simple serial functions # #-------------------------# + def _OpenPort(): + # Open serial port + if port.is_open: return + debugPrint('Opening upload port...') + port.open() + port.reset_input_buffer() + debugPrint('OK') + + def _ClosePort(): + # Open serial port + if port is None: return + if not port.is_open: return + debugPrint('Closing upload port...') + port.close() + debugPrint('OK') + def _Send(data): - if Debug: print(f'>> {data}') + debugPrint(f'>> {data}') strdata = bytearray(data, 'utf8') + b'\n' port.write(strdata) time.sleep(0.010) @@ -60,37 +80,37 @@ def _Recv(): clean_responses = [] responses = port.readlines() for Resp in responses: - # Test: suppress invaid chars (coming from debug info) + # Suppress invalid chars (coming from debug info) try: clean_response = Resp.decode('utf8').rstrip().lstrip() clean_responses.append(clean_response) + debugPrint(f'<< {clean_response}') except: pass - if Debug: print(f'<< {clean_response}') return clean_responses #------------------# # SDCard functions # #------------------# def _CheckSDCard(): - if Debug: print('Checking SD card...') + debugPrint('Checking SD card...') _Send('M21') Responses = _Recv() if len(Responses) < 1 or not any('SD card ok' in r for r in Responses): raise Exception('Error accessing SD card') - if Debug: print('SD Card OK') + debugPrint('SD Card OK') return True #----------------# # File functions # #----------------# def _GetFirmwareFiles(UseLongFilenames): - if Debug: print('Get firmware files...') + debugPrint('Get firmware files...') _Send(f"M20 F{'L' if UseLongFilenames else ''}") Responses = _Recv() if len(Responses) < 3 or not any('file list' in r for r in Responses): raise Exception('Error getting firmware files') - if Debug: print('OK') + debugPrint('OK') return Responses def _FilterFirmwareFiles(FirmwareList, UseLongFilenames): @@ -114,6 +134,17 @@ def _RemoveFirmwareFile(FirmwareFile): raise Exception(f"Firmware file '{FirmwareFile}' not removed") return Removed + def _RollbackUpload(FirmwareFile): + if not rollback: return + print(f"Rollback: trying to delete firmware '{FirmwareFile}'...") + _OpenPort() + # Wait for SD card release + time.sleep(1) + # Remount SD card + _CheckSDCard() + print(' OK' if _RemoveFirmwareFile(FirmwareFile) else ' Error!') + _ClosePort() + #---------------------# # Callback Entrypoint # @@ -121,6 +152,7 @@ def _RemoveFirmwareFile(FirmwareFile): port = None protocol = None filetransfer = None + rollback = False # Get Marlin evironment vars MarlinEnv = env['MARLIN_FEATURES'] @@ -204,9 +236,9 @@ def _RemoveFirmwareFile(FirmwareFile): if not marlin_custom_firmware_upload: raise Exception(f"CUSTOM_FIRMWARE_UPLOAD must be enabled in 'Configuration_adv.h' for '{marlin_motherboard}'") - # Init serial port + # Init & Open serial port port = serial.Serial(upload_port, baudrate = upload_speed, write_timeout = 0, timeout = 0.1) - port.reset_input_buffer() + _OpenPort() # Check SD card status _CheckSDCard() @@ -228,24 +260,26 @@ def _RemoveFirmwareFile(FirmwareFile): print(' OK' if _RemoveFirmwareFile(OldFirmwareFile) else ' Error!') # Close serial - port.close() + _ClosePort() # Cleanup completed - if Debug: print('Cleanup completed') + debugPrint('Cleanup completed') # WARNING! The serial port must be closed here because the serial transfer that follow needs it! # Upload firmware file - if Debug: print(f"Copy '{upload_firmware_source_name}' --> '{upload_firmware_target_name}'") + debugPrint(f"Copy '{upload_firmware_source_name}' --> '{upload_firmware_target_name}'") protocol = MarlinBinaryProtocol.Protocol(upload_port, upload_speed, upload_blocksize, float(upload_error_ratio), int(upload_timeout)) #echologger = MarlinBinaryProtocol.EchoProtocol(protocol) protocol.connect() + # Mark the rollback (delete broken transfer) from this point on + rollback = True filetransfer = MarlinBinaryProtocol.FileTransferProtocol(protocol) - filetransfer.copy(upload_firmware_source_name, upload_firmware_target_name, upload_compression, upload_test) + transferOK = filetransfer.copy(upload_firmware_source_name, upload_firmware_target_name, upload_compression, upload_test) protocol.disconnect() # Notify upload completed - protocol.send_ascii('M117 Firmware uploaded') + protocol.send_ascii('M117 Firmware uploaded' if transferOK else 'M117 Firmware upload failed') # Remount SD card print('Wait for SD card release...') @@ -253,34 +287,56 @@ def _RemoveFirmwareFile(FirmwareFile): print('Remount SD card') protocol.send_ascii('M21') - # Trigger firmware update - if upload_reset: - print('Trigger firmware update...') - protocol.send_ascii('M997', True) + # Transfer failed? + if not transferOK: + protocol.shutdown() + _RollbackUpload(upload_firmware_target_name) + else: + # Trigger firmware update + if upload_reset: + print('Trigger firmware update...') + protocol.send_ascii('M997', True) + protocol.shutdown() - protocol.shutdown() - print('Firmware update completed') + print('Firmware update completed' if transferOK else 'Firmware update failed') + return 0 if transferOK else -1 except KeyboardInterrupt: - if port: port.close() + print('Aborted by user') if filetransfer: filetransfer.abort() - if protocol: protocol.shutdown() + if protocol: + protocol.disconnect() + protocol.shutdown() + _RollbackUpload(upload_firmware_target_name) + _ClosePort() raise except serial.SerialException as se: - if port: port.close() - print(f'Serial excepion: {se}') + # This exception is raised only for send_ascii data (not for binary transfer) + print(f'Serial excepion: {se}, transfer aborted') + if protocol: + protocol.disconnect() + protocol.shutdown() + _RollbackUpload(upload_firmware_target_name) + _ClosePort() raise Exception(se) except MarlinBinaryProtocol.FatalError: - if port: port.close() - if protocol: protocol.shutdown() - print('Too many retries, Abort') + print('Too many retries, transfer aborted') + if protocol: + protocol.disconnect() + protocol.shutdown() + _RollbackUpload(upload_firmware_target_name) + _ClosePort() raise - except: - if port: port.close() - if protocol: protocol.shutdown() + except Exception as ex: + print(f"\nException: {ex}, transfer aborted") + if protocol: + protocol.disconnect() + protocol.shutdown() + _RollbackUpload(upload_firmware_target_name) + _ClosePort() print('Firmware not updated') raise diff --git a/buildroot/share/vscode/auto_build.py b/buildroot/share/vscode/auto_build.py index 5bd769478e..31ef271551 100644 --- a/buildroot/share/vscode/auto_build.py +++ b/buildroot/share/vscode/auto_build.py @@ -252,7 +252,7 @@ def resolve_path(path): while 0 <= path.find('../'): end = path.find('../') - 1 start = path.find('/') - while 0 <= path.find('/', start) and end > path.find('/', start): + while 0 <= path.find('/', start) < end: start = path.find('/', start) + 1 path = path[0:start] + path[end + 4:] @@ -674,7 +674,7 @@ def write_to_screen_with_replace(text, highlights): # search for highlights & s if 0 == highlight[1]: found_1 = text.find(' ') found_tab = text.find('\t') - if found_1 < 0 or found_1 > found_tab: + if not (0 <= found_1 <= found_tab): found_1 = found_tab write_to_screen_queue(text[:found_1 + 1]) for highlight_2 in highlights: @@ -684,7 +684,7 @@ def write_to_screen_with_replace(text, highlights): # search for highlights & s if found >= 0: found_space = text.find(' ', found_1 + 1) found_tab = text.find('\t', found_1 + 1) - if found_space < 0 or found_space > found_tab: + if not (0 <= found_space <= found_tab): found_space = found_tab found_right = text.find(']', found + 1) write_to_screen_queue(text[found_1 + 1:found_space + 1], highlight[2]) @@ -701,7 +701,7 @@ def write_to_screen_with_replace(text, highlights): # search for highlights & s break if did_something == False: r_loc = text.find('\r') + 1 - if r_loc > 0 and r_loc < len(text): # need to split this line + if 0 < r_loc < len(text): # need to split this line text = text.split('\r') for line in text: if line != '': diff --git a/buildroot/tests/FYSETC_F6 b/buildroot/tests/FYSETC_F6 index 17f8eb42b1..91b1f899ff 100755 --- a/buildroot/tests/FYSETC_F6 +++ b/buildroot/tests/FYSETC_F6 @@ -18,15 +18,11 @@ exec_test $1 $2 "FYSETC F6 1.3 with DGUS" "$3" # Delta Config (generic) + UBL + ALLEN_KEY + EEPROM_SETTINGS + OLED_PANEL_TINYBOY2 # use_example_configs delta/generic -opt_set MOTHERBOARD BOARD_FYSETC_F6_13 \ - LCD_LANGUAGE ko_KR \ - X_DRIVER_TYPE L6470 Y_DRIVER_TYPE L6470 Z_DRIVER_TYPE L6470 \ - L6470_CHAIN_SCK_PIN 53 L6470_CHAIN_MISO_PIN 49 L6470_CHAIN_MOSI_PIN 40 L6470_CHAIN_SS_PIN 42 \ - 'ENABLE_RESET_L64XX_CHIPS(V)' NOOP +opt_set MOTHERBOARD BOARD_FYSETC_F6_13 LCD_LANGUAGE ko_KR opt_enable RESTORE_LEVELING_AFTER_G28 EEPROM_SETTINGS EEPROM_CHITCHAT \ Z_PROBE_ALLEN_KEY AUTO_BED_LEVELING_UBL UBL_MESH_WIZARD \ OLED_PANEL_TINYBOY2 MESH_EDIT_GFX_OVERLAY DELTA_CALIBRATION_MENU -exec_test $1 $2 "DELTA, RAMPS, L6470, UBL, Allen Key, EEPROM, OLED_PANEL_TINYBOY2..." "$3" +exec_test $1 $2 "DELTA, FYSETC F6 1.3, UBL, Allen Key, EEPROM, OLED_PANEL_TINYBOY2..." "$3" # # Test mixed TMC config diff --git a/buildroot/tests/Index_Mobo_Rev03 b/buildroot/tests/Index_Mobo_Rev03 deleted file mode 100755 index 501386489d..0000000000 --- a/buildroot/tests/Index_Mobo_Rev03 +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash -# -# Build tests for Index_Mobo_Rev03 -# - -# exit on first failure -set -e - -use_example_configs Index/REV_03 -exec_test $1 $2 "Index REV03 Pick and Place" "$3" - -# cleanup -restore_configs diff --git a/buildroot/tests/Opulo_Lumen_REV3 b/buildroot/tests/Opulo_Lumen_REV3 new file mode 100755 index 0000000000..ddd8e1f3c9 --- /dev/null +++ b/buildroot/tests/Opulo_Lumen_REV3 @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +# +# Build tests for Opulo_Lumen_REV3 +# + +# exit on first failure +set -e + +use_example_configs Opulo/Lumen_REV3 +exec_test $1 $2 "Opulo Lumen REV3 Pick-and-Place" "$3" + +# cleanup +restore_configs diff --git a/buildroot/tests/PANDA_PI_V29 b/buildroot/tests/PANDA_PI_V29 new file mode 100755 index 0000000000..a176e571ba --- /dev/null +++ b/buildroot/tests/PANDA_PI_V29 @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# +# Build tests for PANDA_PI_V29 +# + +# exit on first failure +set -e + +# +# Build with the default configurations +# +restore_configs +opt_set MOTHERBOARD BOARD_PANDA_PI_V29 SERIAL_PORT -1 \ + Z_CLEARANCE_DEPLOY_PROBE 0 Z_CLEARANCE_BETWEEN_PROBES 1 Z_CLEARANCE_MULTI_PROBE 1 +opt_enable BD_SENSOR AUTO_BED_LEVELING_BILINEAR Z_SAFE_HOMING BABYSTEPPING +exec_test $1 $2 "Panda Pi V29 | BD Sensor | ABL-B" "$3" + +# clean up +restore_configs diff --git a/buildroot/tests/STM32F103RE_creality b/buildroot/tests/STM32F103RE_creality index 5e6d5f044a..f1478bc2c4 100755 --- a/buildroot/tests/STM32F103RE_creality +++ b/buildroot/tests/STM32F103RE_creality @@ -18,7 +18,7 @@ opt_disable DWIN_CREALITY_LCD opt_enable DWIN_CREALITY_LCD_JYERSUI AUTO_BED_LEVELING_BILINEAR PROBE_MANUALLY exec_test $1 $2 "Ender 3 v2 with JyersUI" "$3" -use_example_configs "Creality/Ender-3 S1" +use_example_configs "Creality/Ender-3 S1/STM32F1" opt_disable DWIN_CREALITY_LCD Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN AUTO_BED_LEVELING_BILINEAR CONFIGURATION_EMBEDDING CANCEL_OBJECTS FWRETRACT opt_enable DWIN_LCD_PROUI INDIVIDUAL_AXIS_HOMING_SUBMENU LCD_SET_PROGRESS_MANUALLY STATUS_MESSAGE_SCROLLING \ SOUND_MENU_ITEM PRINTCOUNTER NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE FILAMENT_RUNOUT_SENSOR \ diff --git a/buildroot/tests/STM32F401VE_STEVAL b/buildroot/tests/STM32F401VE_STEVAL deleted file mode 100755 index 1704f3d2f0..0000000000 --- a/buildroot/tests/STM32F401VE_STEVAL +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash -# -# Build tests for STM32F401VE_STEVAL -# - -# exit on first failure -set -e - -# Build examples -restore_configs -opt_set MOTHERBOARD BOARD_STEVAL_3DP001V1 SERIAL_PORT -1 -exec_test $1 $2 "STM32F401VE_STEVAL Default Config" "$3" - -# cleanup -restore_configs diff --git a/buildroot/tests/mega2560 b/buildroot/tests/mega2560 index 6871ce4a0c..536f723b73 100755 --- a/buildroot/tests/mega2560 +++ b/buildroot/tests/mega2560 @@ -32,7 +32,7 @@ opt_enable AUTO_BED_LEVELING_UBL RESTORE_LEVELING_AFTER_G28 DEBUG_LEVELING_FEATU EEPROM_SETTINGS EEPROM_CHITCHAT GCODE_MACROS CUSTOM_MENU_MAIN FREEZE_FEATURE CANCEL_OBJECTS SOUND_MENU_ITEM \ MULTI_NOZZLE_DUPLICATION CLASSIC_JERK LIN_ADVANCE EXTRA_LIN_ADVANCE_K QUICK_HOME \ LCD_SET_PROGRESS_MANUALLY PRINT_PROGRESS_SHOW_DECIMALS SHOW_REMAINING_TIME \ - BABYSTEPPING BABYSTEP_XY NANODLP_Z_SYNC I2C_POSITION_ENCODERS M114_DETAIL + ENCODER_NOISE_FILTER BABYSTEPPING BABYSTEP_XY NANODLP_Z_SYNC I2C_POSITION_ENCODERS M114_DETAIL exec_test $1 $2 "Azteeg X3 Pro | EXTRUDERS 5 | RRDFGSC | UBL | LIN_ADVANCE ..." "$3" # @@ -188,8 +188,8 @@ opt_set MOTHERBOARD BOARD_RAMPS_14_EFB EXTRUDERS 0 LCD_LANGUAGE en TEMP_SENSOR_C MANUAL_FEEDRATE '{ 50*60, 50*60, 4*60 }' \ AXIS_RELATIVE_MODES '{ false, false, false }' opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER SDSUPPORT EEPROM_SETTINGS EEPROM_BOOT_SILENT EEPROM_AUTO_INIT MEATPACK_ON_SERIAL_PORT_1 \ - LASER_FEATURE LASER_SAFETY_TIMEOUT_MS LASER_COOLANT_FLOW_METER AIR_EVACUATION AIR_EVACUATION_PIN AIR_ASSIST AIR_ASSIST_PIN -exec_test $1 $2 "MEGA2560 RAMPS | Laser Feature | Air Evacuation | Air Assist | Cooler | Flowmeter | 12864 LCD | meatpack | SERIAL_PORT_2 " "$3" + LASER_FEATURE LASER_SAFETY_TIMEOUT_MS LASER_COOLANT_FLOW_METER AIR_EVACUATION AIR_EVACUATION_PIN AIR_ASSIST AIR_ASSIST_PIN LASER_SYNCHRONOUS_M106_M107 +exec_test $1 $2 "MEGA2560 RAMPS | Laser Options | 12864 | Meatpack | Fan Sync | SERIAL_PORT_2 " "$3" # # Test Laser features with 44780 LCD @@ -203,19 +203,20 @@ opt_set MOTHERBOARD BOARD_RAMPS_14_EFB EXTRUDERS 0 LCD_LANGUAGE en TEMP_SENSOR_C AXIS_RELATIVE_MODES '{ false, false, false }' opt_enable REPRAP_DISCOUNT_SMART_CONTROLLER SDSUPPORT EEPROM_SETTINGS EEPROM_BOOT_SILENT EEPROM_AUTO_INIT PRINTCOUNTER I2C_AMMETER \ LASER_FEATURE LASER_SAFETY_TIMEOUT_MS LASER_COOLANT_FLOW_METER AIR_EVACUATION AIR_EVACUATION_PIN AIR_ASSIST AIR_ASSIST_PIN -exec_test $1 $2 "MEGA2560 RAMPS | Laser Feature | Air Evacuation | Air Assist | Cooler | Flowmeter | 44780 LCD " "$3" +exec_test $1 $2 "MEGA2560 RAMPS | Laser Feature | Air Evacuation | Air Assist | Cooler | Laser Safety Timeout | Flowmeter | 44780 LCD " "$3" # -# Test redundant temperature sensors + MAX TC +# Test redundant temperature sensors + MAX TC + Backlight Timeout # restore_configs opt_set MOTHERBOARD BOARD_RAMPS_14_EFB EXTRUDERS 1 \ TEMP_SENSOR_0 -2 TEMP_SENSOR_REDUNDANT -2 \ TEMP_SENSOR_REDUNDANT_SOURCE E1 TEMP_SENSOR_REDUNDANT_TARGET E0 \ - TEMP_0_CS_PIN 11 TEMP_1_CS_PIN 12 -opt_enable MPCTEMP + TEMP_0_CS_PIN 11 TEMP_1_CS_PIN 12 \ + LCD_BACKLIGHT_TIMEOUT 30 +opt_enable MPCTEMP MINIPANEL opt_disable PIDTEMP -exec_test $1 $2 "MEGA2560 RAMPS | Redundant temperature sensor | 2x MAX6675" "$3" +exec_test $1 $2 "MEGA2560 RAMPS | Redundant temperature sensor | 2x MAX6675 | BL Timeout" "$3" # # Polargraph Config diff --git a/buildroot/tests/mks_tinybee b/buildroot/tests/mks_tinybee new file mode 100755 index 0000000000..8b5aa0f075 --- /dev/null +++ b/buildroot/tests/mks_tinybee @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +# +# Build tests for MKS TinyBee +# + +# exit on first failure +set -e + +# +# Build with ESP3D WiFi, OTA and custom WIFI commands support +# +restore_configs +opt_set MOTHERBOARD BOARD_MKS_TINYBEE TX_BUFFER_SIZE 64 \ + WIFI_SSID '"ssid"' WIFI_PWD '"password"' \ + SERIAL_PORT_2 -1 BAUDRATE_2 250000 +opt_enable ESP3D_WIFISUPPORT WEBSUPPORT OTASUPPORT WIFI_CUSTOM_COMMAND +exec_test $1 "$2" "MKS TinyBee with ESP3D_WIFISUPPORT" "$3" + +# +# Build with LCD, SD support and Speaker support +# +restore_configs +opt_set MOTHERBOARD BOARD_MKS_TINYBEE \ + LCD_LANGUAGE en \ + LCD_INFO_SCREEN_STYLE 0 \ + DISPLAY_CHARSET_HD44780 WESTERN \ + NEOPIXEL_TYPE NEO_RGB +opt_enable FYSETC_MINI_12864_2_1 SDSUPPORT +opt_enable LED_CONTROL_MENU LED_USER_PRESET_STARTUP LED_COLOR_PRESETS NEOPIXEL_LED +exec_test $1 $2 "MKS TinyBee with NeoPixel LCD, SD and Speaker" "$3" + +# cleanup +restore_configs diff --git a/docs/ConfigEmbedding.md b/docs/ConfigEmbedding.md index ed4ea39eda..90075bc373 100644 --- a/docs/ConfigEmbedding.md +++ b/docs/ConfigEmbedding.md @@ -1,9 +1,9 @@ # Configuration Embedding -Starting with version 2.0.9.3, Marlin automatically extracts the configuration used to generate the firmware and stores it in the firmware binary. This is enabled by defining `CONFIGURATION_EMBEDDING` in `Configuration_adv.h`. +Starting with version 2.0.9.3, Marlin can automatically extract the configuration used to generate the firmware and store it in the firmware binary. This is enabled by defining `CONFIGURATION_EMBEDDING` in `Configuration_adv.h`. ## How it's done -To create the embedded configuration, we do a compiler pass to process the Configuration files and extract all active options. The active options are parsed into key/value pairs, serialized to JSON format, and stored in a file called `marlin_config.json`, which also includes specific build information (like the git revision, the build date, and some version information. The JSON file is then compressed in a ZIP archive called `.pio/build/mc.zip` which is converted into a C array and stored in a C++ file called `mc.h` which is included in the build. +At the start of the PlatformIO build process, we create an embedded configuration by extracting all active options from the Configuration files and writing them out as JSON to `marlin_config.json`, which also includes specific build information (like the git revision, the build date, and some version information. The JSON file is then compressed in a ZIP archive called `.pio/build/mc.zip` which is converted into a C array and stored in a C++ file called `mc.h` which is included in the build. ## Extracting configurations from a Marlin binary To get the configuration out of a binary firmware, you'll need a non-write-protected SD card inserted into the printer while running the firmware. diff --git a/docs/Cutter.md b/docs/Cutter.md new file mode 100644 index 0000000000..c78b0551a0 --- /dev/null +++ b/docs/Cutter.md @@ -0,0 +1,137 @@ +### Introduction + +With Marlin version 2.0.9.x or higher, Laser improvements were introduced that enhance inline functionality. Previously the inline feature option was not operational without enabling and recompiling the source. Also with inline enabled the base features are not functional. With v2.0.9.x new functionality is added which allows the standard and inline modes to be G-Code selectable and also compatible with each other. Additionally an experimental dynamic mode is also available. Spindle operational features are available with defines and recompiling. + +### Architecture + +Laser selectable feature capability is defined through 4 global mode flags within gcode ,laser/spindle, planner and stepper routines. The default mode maintains the standard laser function. G-Codes are received, processed and parsed to determine what mode to set through M3, M4 and M5 commands. When the inline mode parameter set is detected, laser power processing will be driven through the planner and stepper routines. Handling of the initial power values and settings are performed by G-Code parsing and the laser/spindle routines. + +Inline power feeds from the block->inline_power variable into the planner's laser.power when in continuous power mode. Further power adjustment will be applied if the laser power trap feature is active otherwise laser.power is used as set in the stepper for the entire block. When laser power trap is active the power levels are step incremented during acceleration and step decremented during deceleration. + +Two additional power sets are fed in the planner by features laser power sync and laser fan power sync. Both of these power sets are done with planner sync block bit flags. With laser power sync, when the bit flag is matched the global block laser.power value is updated from laser/spindle standard M3 S-Value power sets. For laser fan sync, power values are updated into the planner block->fan_speed[i] variable from fan G-Code S-Value sets. + +With dynamic inline power mode, F-Value feedrate sets are processed with cutter.calc_dynamic_power() and fed into the planner laser.power value. + +Irrespective of what laser power value source is used, the final laser output pin is always updated using the laser/spindle code. Specifically the apply_power(value) call is used to set the laser or spindle output. This call permits safe power control in the event that a sensor fault occurs. + +Note: Spindle operation is not selectable with G-Codes at this time. + +The following flow charts depict the flow control logic for spindle and laser operations in the code base. + +#### Spindle Mode Logic: + + ┌──────────┐ ┌───────────┐ ┌───────────┐ + │M3 S-Value│ │Dir !same ?│ │Stepper │ + │Spindle │ │stop & wait│ │processes │ + ┌──┤Clockwise ├──┤ & start ├──┤moves │ + ┌─────┐ │ │ │ │spindle │ │ │ + │GCode│ │ └──────────┘ └───────────┘ └───────────┘ + │Send ├──┤ ┌──────────┐ ┌───────────┐ ┌───────────┐ + └─────┘ │ │M4 S-Value│ │Dir !same ?│ │Stepper │ + ├──┤Spindle ├──┤stop & wait├──┤processes │ + │ │Counter │ │& start │ │moves │ + │ │Clockwise │ │spindle │ │ │ + │ └──────────┘ └───────────┘ └───────────┘ + │ ┌──────────┐ ┌────────┐ + │ │M5 │ │Wait for│ + │ │Spindle ├──┤move & │ + └──┤Stop │ │disable │ + └──────────┘ └────────┘ + ┌──────────┐ ┌──────────┐ + Sensors─────┤Fault ├──┤Disable │ + └──────────┘ │power │ + └──────────┘ + +#### Laser Mode Logic: + + ┌──────────┐ ┌─────────────┐ ┌───────────┐ + │M3,M4,M5 I│ │Set power │ │Stepper │ + ┌──┤Standard ├──┤Immediately &├──┤processes │ + │ │Default │ │wait for move│ │moves │ + │ │ │ │completion │ │ │ + │ └──────────┘ └─────────────┘ └───────────┘ + │ ┌──────────┐ ┌───────────┐ ┌───────────┐ ┌────────────┐ ┌────────────┐ ┌────────────┐ ┌───────────┐ + ┌─────┐ │ │M3 I │ │G0,G1,G2,G4│ │Planner │ │Planner │ │Planner fan │ │Planner │ │Stepper │ + │GCode│ │ │Continuous│ │M3 receive │ │sets block │ │sync power ?│ │sync power ?│ │trap power ?│ │uses block │ + │Send ├──┼──┤Inline ├──┤power from ├──┤power using├──┤process M3 ├──┤process fan ├──┤adjusts for ├──┤values to │ + └─────┘ │ │ │ │S-Value │ │Gx S-Value │ │power inline│ │power inline│ │accel/decel │ │apply power│ + │ └──────────┘ └───────────┘ └───────────┘ └────────────┘ └────────────┘ └────────────┘ └───────────┘ + │ ┌──────────┐ ┌───────────┐ ┌────────────────┐ ┌───────────┐ + │ │M4 I │ │Gx F-Value │ │Planner │ │Stepper │ + │ │Dynamic │ │set power │ │Calc & set block│ │uses block │ + └──┤Inline ├──┤or use ├──┤block power ├──┤values to │ + │ │ │default │ │using F-Value │ │apply power│ + └──────────┘ └───────────┘ └────────────────┘ └───────────┘ + ┌──────────┐ ┌──────────┐ + Sensors─────┤Fault ├──┤Disable │ + └──────────┘ │Power │ + └──────────┘ + + + +### Continuous Inline Trap Power Calculations + +When LASER_FEATURE and LASER_POWER_TRAP are defined, planner calculations are performed and applied to the incoming laser power S-Value. The power will be factored and distributed across trapezoid acceleration and deceleration movements. + +When the laser.power > 0 + +We set a minimum power if defined in SPEED_POWER_MIN it's fed into the planner block as laser_power_floor. + +A reduced entry laser power factor is based on the entry step rate to cruise step rate ratio for acceleration. + + block entry laser power = laser power * ( entry step rate / cruise step rate ) + +The initial power will be set to no less than the laser_power_floor or the inital power calculation. + +The reduced final power factor is based on the final step rate to cruise step rate ratio for deceleration. + + block exit laser power = laser power * ( exit step rate / cruise step rate ) + +Once the entry and exit power values are determined, the values are divided into step increments to be applied in the stepper. + + trap step power incr_decr = ( cruize power - entry_exit ) / accel_decel_steps + +The trap steps are incremented or decremented during each accel or decel step until the block is complete. +Step power is either cumulatively added or subtracted during trapeziod ramp progressions. + +#### Planner Code: + + ``` + if (block->laser.power > 0) { + NOLESS(block->laser.power, laser_power_floor); + block->laser.trap_ramp_active_pwr = (block->laser.power - laser_power_floor) * (initial_rate / float(block->nominal_rate)) + laser_power_floor; + block->laser.trap_ramp_entry_incr = (block->laser.power - block->laser.trap_ramp_active_pwr) / accelerate_steps; + float laser_pwr = block->laser.power * (final_rate / float(block->nominal_rate)); + NOLESS(laser_pwr, laser_power_floor); + block->laser.trap_ramp_exit_decr = (block->laser.power - laser_pwr) / decelerate_steps; + ``` + +#### Stepper Code: + + ``` + if (current_block->laser.trap_ramp_entry_incr > 0) { + cutter.apply_power(current_block->laser.trap_ramp_active_pwr); + current_block->laser.trap_ramp_active_pwr += current_block->laser.trap_ramp_entry_incr; + ``` + + ``` + if (current_block->laser.trap_ramp_exit_decr > 0) { + current_block->laser.trap_ramp_active_pwr -= current_block->laser.trap_ramp_exit_decr; + cutter.apply_power(current_block->laser.trap_ramp_active_pwr); + ``` + +### Dynamic Inline Calculations + +Dynamic mode will calculate laser power based on the F-Value feedrate. The method uses bit shifting to set a power level from 0 to 255. It's simple and fast and we can use a scaler to shift the laser power output to center on a given power level. + +#### Spindle/Laser Code: + +``` + // Dynamic mode rate calculation + static inline uint8_t calc_dynamic_power() { + if (feedrate_mm_m > 65535) return 255; // Too fast, go always on + uint16_t rate = uint16_t(feedrate_mm_m); // 16 bits from the G-code parser float input + rate >>= 8; // Take the G-code input e.g. F40000 and shift off the lower bits to get an OCR value from 1-255 + return uint8_t(rate); + } +``` diff --git a/ini/advi3pp.ini b/ini/advi3pp.ini index 283894aa73..1c526d6d6d 100644 --- a/ini/advi3pp.ini +++ b/ini/advi3pp.ini @@ -44,3 +44,8 @@ build_flags = ${advi3pp.build_flags} -DADVi3PP_52C -DBLTOUCH -DNDEBUG [env:advi3pp_54] extends = advi3pp build_flags = ${advi3pp.build_flags} -DADVi3PP_54 -DNDEBUG + +[env:advi3pp_simulator] +extends = advi3pp +build_flags = ${advi3pp.build_flags} -DADVi3PP_51 -DBLTOUCH -DDEBUG -DADVi3PP_DEBUG -DADVi3PP_HARDWARE_SIMULATOR + diff --git a/ini/esp32.ini b/ini/esp32.ini index 05b045f16e..f12ef99759 100644 --- a/ini/esp32.ini +++ b/ini/esp32.ini @@ -20,6 +20,7 @@ build_src_filter = ${common.default_src_filter} + lib_ignore = NativeEthernet upload_speed = 500000 monitor_speed = 250000 +monitor_filters = colorize, time, send_on_enter, log2file, esp32_exception_decoder #upload_port = marlinesp.local #board_build.flash_mode = qio @@ -28,13 +29,13 @@ extends = env:esp32 board_build.partitions = default_16MB.csv [env:PANDA] -extends = env:esp32 -build_flags = ${env:esp32.build_flags} -DUSE_ESP32_EXIO -DUSE_ESP32_TASK_WDT -lib_deps = ${common.lib_deps} - SoftwareSerialEsp32 +extends = env:esp32 +build_flags = ${env:esp32.build_flags} -DUSE_ESP32_EXIO -DUSE_ESP32_TASK_WDT +lib_deps = ${common.lib_deps} + SoftwareSerialEsp32 board_build.partitions = Marlin/src/HAL/ESP32/esp32.csv -upload_speed = 115200 -monitor_speed = 115200 +upload_speed = 115200 +monitor_speed = 115200 [env:mks_tinybee] extends = env:esp32 diff --git a/ini/features.ini b/ini/features.ini index 355544029e..2f26aa2523 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -14,6 +14,7 @@ YHCB2004 = red-scorp/LiquidCrystal_AIP31068@^1.0.4 HAS_TFT_LVGL_UI = lvgl=https://github.com/makerbase-mks/LVGL-6.1.1-MKS/archive/master.zip src_filter=+ extra_scripts=download_mks_assets.py +MARLIN_TEST_BUILD = src_filter=+ POSTMORTEM_DEBUGGING = src_filter=+ + build_flags=-funwind-tables MKS_WIFI_MODULE = QRCode=https://github.com/makerbase-mks/QRCode/archive/master.zip @@ -26,8 +27,6 @@ HAS_MOTOR_CURRENT_I2C = SlowSoftI2CMaster src_filter=+ HAS_TMC26X = TMC26XStepper=https://github.com/MarlinFirmware/TMC26XStepper/archive/master.zip src_filter=+ -HAS_L64XX = Arduino-L6470@0.8.0 - src_filter=+ + + + LIB_INTERNAL_MAX31865 = src_filter=+ NEOPIXEL_LED = adafruit/Adafruit NeoPixel@~1.8.0 src_filter=+ @@ -100,6 +99,8 @@ HAS_MCP3426_ADC = src_filter=+ + AUTO_BED_LEVELING_(3POINT|(BI)?LINEAR) = src_filter=+ X_AXIS_TWIST_COMPENSATION = src_filter=+ + + +BD_SENSOR = markyue/Panda_SoftMasterI2C + src_filter=+ + MESH_BED_LEVELING = src_filter=+ + AUTO_BED_LEVELING_UBL = src_filter=+ + UBL_HILBERT_CURVE = src_filter=+ @@ -205,7 +206,7 @@ HAS_STATUS_MESSAGE = src_filter=+ HAS_LCD_CONTRAST = src_filter=+ HAS_GCODE_M255 = src_filter=+ HAS_LCD_BRIGHTNESS = src_filter=+ -HAS_BUZZER = src_filter=+ +HAS_SOUND = src_filter=+ TOUCH_SCREEN_CALIBRATION = src_filter=+ ARC_SUPPORT = src_filter=+ GCODE_MOTION_MODES = src_filter=+ @@ -239,5 +240,5 @@ HAS_MICROSTEPS = src_filter=+ if no Xcode is installed. # If Xcode is installed be sure to run `xcode-select --install` first. # +#================================================================================== +# +# Homebrew: +# /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" +# +# brew install gcc@12 glm sdl2 sdl2_net +# +# cd /opt/homebrew/bin +# sudo rm -f gcc g++ cc +# sudo ln -s gcc-12 gcc ; sudo ln -s g++-12 g++ ; sudo ln -s g++ cc +# cd - +# +# Use 'brew install mesa' to get a if no Xcode is installed. +# If Xcode is installed be sure to run `xcode-select --install` first. +# + [simulator_macos] -build_unflags = -lGL +build_unflags = -lGL -fstack-protector-strong build_flags = -I/opt/local/include -I/opt/local/include/freetype2 @@ -87,6 +103,7 @@ build_flags = -Wl,-framework,OpenGl -Wl,-framework,CoreFoundation -lSDL2 + -fno-stack-protector [env:simulator_macos_debug] extends = env:simulator_linux_debug @@ -109,7 +126,7 @@ custom_gcc = g++ # pacman -S --needed base-devel mingw-w64-x86_64-toolchain mingw64/mingw-w64-x86_64-glm mingw64/mingw-w64-x86_64-SDL2 mingw64/mingw-w64-x86_64-SDL2_net mingw-w64-x86_64-dlfcn # [env:simulator_windows] -extends = simulator_common +extends = simulator_common build_src_flags = ${simulator_common.build_src_flags} -fpermissive -build_flags = ${simulator_common.build_flags} ${simulator_common.debug_build_flags} -IC:\\msys64\\mingw64\\include\\SDL2 -fno-stack-protector -Wl,-subsystem,windows -ldl -lmingw32 -lSDL2main -lSDL2 -lSDL2_net -lopengl32 -lssp -build_type = debug +build_flags = ${simulator_common.build_flags} ${simulator_common.debug_build_flags} -IC:\\msys64\\mingw64\\include\\SDL2 -fno-stack-protector -Wl,-subsystem,windows -ldl -lmingw32 -lSDL2main -lSDL2 -lSDL2_net -lopengl32 -lssp +build_type = debug diff --git a/ini/stm32f1-maple.ini b/ini/stm32f1-maple.ini index 18c861ba1e..84055bebab 100644 --- a/ini/stm32f1-maple.ini +++ b/ini/stm32f1-maple.ini @@ -92,7 +92,7 @@ debug_tool = stlink upload_protocol = serial # -# BigTree SKR Mini V1.1 / SKR Mini E3 & MZ (STM32F103RCT6 ARM Cortex-M3) +# BigTreeTech SKR Mini V1.1 / SKR Mini E3 & MZ (STM32F103RCT6 ARM Cortex-M3) # # STM32F103RC_btt_maple ............. RCT6 with 256K # STM32F103RC_btt_USB_maple ......... RCT6 with 256K (USB mass storage) @@ -145,7 +145,7 @@ board_build.address = 0x08010000 board_build.ldscript = crealityPro.ld # -# BigTree SKR Mini E3 V2.0 & DIP / SKR CR6 (STM32F103RET6 ARM Cortex-M3) +# BigTreeTech SKR Mini E3 V2.0 & DIP / SKR CR6 (STM32F103RET6 ARM Cortex-M3) # # STM32F103RE_btt_maple ............. RET6 # STM32F103RE_btt_USB_maple ......... RET6 (USB mass storage) diff --git a/ini/stm32f1.ini b/ini/stm32f1.ini index 8dc9bc3061..1e29ea6de5 100644 --- a/ini/stm32f1.ini +++ b/ini/stm32f1.ini @@ -51,7 +51,7 @@ board = genericSTM32F103ZE monitor_speed = 115200 # -# BigTree SKR Mini V1.1 / SKR Mini E3 & MZ (STM32F103RCT6 ARM Cortex-M3) +# BigTreeTech SKR Mini V1.1 / SKR Mini E3 & MZ (STM32F103RCT6 ARM Cortex-M3) # # STM32F103RC_btt ............. RCT6 with 256K # STM32F103RC_btt_USB ......... RCT6 with 256K (USB mass storage) @@ -83,7 +83,8 @@ build_flags = ${common_STM32F103RC_variant.build_flags} -DTIMER_SERVO=TIM1 board_build.offset = 0x5000 board_upload.offset_address = 0x08005000 - +lib_deps = + markyue/Panda_SoftMasterI2C@1.0.3 # # MKS Robin (STM32F103ZET6) # Uses HAL STM32 to support Marlin UI for TFT screen with optional touch panel @@ -171,7 +172,7 @@ extends = STM32F103Rx_creality_xfer board = genericSTM32F103RC # -# BigTree SKR Mini E3 V2.0 & DIP / SKR CR6 (STM32F103RET6 ARM Cortex-M3) +# BigTreeTech SKR Mini E3 V2.0 & DIP / SKR CR6 (STM32F103RET6 ARM Cortex-M3) # # STM32F103RE_btt ............. RET6 # STM32F103RE_btt_USB ......... RET6 (USB mass storage) @@ -378,12 +379,31 @@ build_flags = ${stm32_variant.build_flags} build_unflags = ${stm32_variant.build_unflags} -DUSBCON -DUSBD_USE_CDC +# +# TRIGORILLA PRO DISK BASED (STM32F103ZET6) +# Builds for Trigorilla to update from SD +# +[env:trigorilla_pro_disk] +extends = stm32_variant +board = genericSTM32F103ZE +board_build.crypt_chitu = update.zw +board_build.variant = MARLIN_F103Zx +board_build.offset = 0x8800 +build_flags = ${stm32_variant.build_flags} + -DENABLE_HWSERIAL3 -DTIMER_SERIAL=TIM5 +build_unflags = ${stm32_variant.build_unflags} + -DUSBCON -DUSBD_USE_CDC +extra_scripts = ${stm32_variant.extra_scripts} + buildroot/share/PlatformIO/scripts/chitu_crypt.py + + # # Chitu boards like Tronxy X5s (STM32F103ZET6) # [env:chitu_f103] extends = stm32_variant board = genericSTM32F103ZE +board_build.crypt_chitu = update.cbd board_build.variant = MARLIN_F103Zx board_build.offset = 0x8800 build_flags = ${stm32_variant.build_flags} diff --git a/ini/stm32f4.ini b/ini/stm32f4.ini index 8bcbb88d94..5e0d4a13ec 100644 --- a/ini/stm32f4.ini +++ b/ini/stm32f4.ini @@ -28,17 +28,6 @@ board = armed_v1 build_flags = ${common_stm32.build_flags} -O2 -ffreestanding -fsigned-char -fno-move-loop-invariants -fno-strict-aliasing -# -# STM32F401VE -# 'STEVAL-3DP001V1' STM32F401VE board - https://www.st.com/en/evaluation-tools/steval-3dp001v1.html -# -[env:STM32F401VE_STEVAL] -extends = stm32_variant -board = marlin_STEVAL_STM32F401VE -build_flags = ${stm32_variant.build_flags} - -DSTM32F401xE -DDISABLE_GENERIC_SERIALUSB - -DUSBD_USE_CDC_COMPOSITE -DUSE_USB_FS - # # STM32F401RC # @@ -94,11 +83,11 @@ build_flags = ${stm32_variant.build_flags} -DUSBD_USE_CDC_COMPOSITE -DUSE_USB_FS # -# STM32F407VET6 Index Mobo Rev 03 +# STM32F407VET6 Opulo Lumen REV3 # -[env:Index_Mobo_Rev03] +[env:Opulo_Lumen_REV3] extends = stm32_variant -board = marlin_index_mobo_rev03 +board = marlin_opulo_lumen_rev3 build_flags = ${stm32_variant.build_flags} -DARDUINO_BLACK_F407VE -DUSBD_USE_CDC_COMPOSITE -DUSE_USB_FS @@ -106,24 +95,34 @@ extra_scripts = ${stm32_variant.extra_scripts} # # Anet ET4-MB_V1.x/ET4P-MB_V1.x (STM32F407VGT6 ARM Cortex-M4) -# For use with with davidtgbe's OpenBLT bootloader https://github.com/davidtgbe/openblt/releases -# Comment out board_build.offset = 0x10000 if you don't plan to use OpenBLT/flashing directly to 0x08000000. # -[env:Anet_ET4_OpenBLT] +[Anet_ET4] extends = stm32_variant board = marlin_STM32F407VGT6_CCM board_build.variant = MARLIN_F4x7Vx -board_build.encrypt_mks = firmware.srec -board_build.offset = 0x10000 -board_upload.offset_address = 0x08010000 build_flags = ${stm32_variant.build_flags} -DHAL_SD_MODULE_ENABLED -DHAL_SRAM_MODULE_ENABLED build_unflags = ${stm32_variant.build_unflags} -DUSBCON -DUSBD_USE_CDC -DUSBD_VID=0x0483 + +# +# Anet ET4 directly flashed via ST-Link +# +[env:Anet_ET4_no_bootloader] +extends = Anet_ET4 +debug_tool = stlink +upload_protocol = stlink + +# +# Anet ET4 with OpenBLT from https://github.com/davidtgbe/openblt/releases +# +[env:Anet_ET4_OpenBLT] +extends = Anet_ET4 +board_build.encode = firmware.srec +board_build.offset = 0x10000 +board_upload.offset_address = 0x08010000 extra_scripts = ${stm32_variant.extra_scripts} buildroot/share/PlatformIO/scripts/openblt.py -debug_tool = jlink -upload_protocol = jlink # # BigTreeTech SKR Pro (STM32F407ZGT6 ARM Cortex-M4) @@ -505,7 +504,7 @@ build_unflags = -DUSBD_USE_CDC build_flags = -DPIN_WIRE_SCL=PB8 -DPIN_WIRE_SDA=PB9 # -# MKS Monster8 +# MKS Monster8 V1 / V2 (STM32F407VET6 ARM Cortex-M4) # [env:mks_monster8] extends = stm32_variant @@ -521,7 +520,7 @@ debug_tool = jlink upload_protocol = jlink # -# MKS Monster8 with USB Flash Drive Support +# MKS Monster8 V1 / V2 (STM32F407VET6 ARM Cortex-M4) with USB Flash Drive Support # Currently, using a STM32duino fork, until USB Host get merged # [env:mks_monster8_usb_flash_drive] @@ -534,7 +533,7 @@ build_flags = ${stm_flash_drive.build_flags} ${stm32f4_I2C1_CAN.build_flag -DUSE_USB_HS_IN_FS # -# MKS Monster8 with USB Flash Drive Support and Shared Media +# MKS Monster8 V1 / V2 (STM32F407VET6 ARM Cortex-M4) with USB Flash Drive Support and Shared Media # Currently, using a STM32duino fork, until USB Host and USB Device MSC get merged # [env:mks_monster8_usb_flash_drive_msc] @@ -546,16 +545,28 @@ build_unflags = -DUSBD_USE_CDC # # TH3D EZBoard v2.0 (STM32F405RGT6 ARM Cortex-M4) # -[env:TH3D_EZBoard_V2] +[TH3D_EZBoard_V2] extends = stm32_variant board = genericSTM32F405RG board_build.variant = MARLIN_TH3D_EZBOARD_V2 -board_build.encrypt_mks = firmware.bin -board_build.offset = 0xC000 -board_upload.offset_address = 0x0800C000 build_flags = ${stm32_variant.build_flags} -DHSE_VALUE=12000000U -O0 + +# +# TH3D EZBoard v2.0 directly flashed via ST-Link +# +[env:TH3D_EZBoard_V2_no_bootloader] +extends = TH3D_EZBoard_V2 debug_tool = stlink upload_protocol = stlink + +# +# TH3D EZBoard v2.0 with OpenBLT from https://github.com/rhapsodyv/OpenBLT-STM32 +# +[env:TH3D_EZBoard_V2_OpenBLT] +extends = TH3D_EZBoard_V2 +board_build.encode = firmware.bin +board_build.offset = 0xC000 +board_upload.offset_address = 0x0800C000 extra_scripts = ${stm32_variant.extra_scripts} buildroot/share/PlatformIO/scripts/openblt.py diff --git a/ini/stm32g0.ini b/ini/stm32g0.ini index b6074d3af8..c80c8dd9e2 100644 --- a/ini/stm32g0.ini +++ b/ini/stm32g0.ini @@ -20,7 +20,7 @@ ################################# # -# BigTree SKR mini E3 V3.0 (STM32G0B1RET6 ARM Cortex-M0+) +# BigTreeTech SKR mini E3 V3.0 (STM32G0B1RET6 ARM Cortex-M0+) # [env:STM32G0B1RE_btt] extends = stm32_variant diff --git a/ini/stm32h7.ini b/ini/stm32h7.ini index c5d7d6299a..fb898d1b72 100644 --- a/ini/stm32h7.ini +++ b/ini/stm32h7.ini @@ -20,7 +20,7 @@ ################################# # -# BigTreeTech SKR SE BX (STM32H743IIT6 ARM Cortex-M7) +# BigTreeTech SKR SE BX V2.0 / V3.0 (STM32H743IIT6 ARM Cortex-M7) # [env:BTT_SKR_SE_BX] extends = stm32_variant diff --git a/platformio.ini b/platformio.ini index b4127cb51d..21ad91c8f9 100644 --- a/platformio.ini +++ b/platformio.ini @@ -29,12 +29,13 @@ extra_configs = build_flags = -g3 -D__MARLIN_FIRMWARE__ -DNDEBUG -fmax-errors=5 extra_scripts = + pre:buildroot/share/PlatformIO/scripts/configuration.py pre:buildroot/share/PlatformIO/scripts/common-dependencies.py pre:buildroot/share/PlatformIO/scripts/common-cxxflags.py pre:buildroot/share/PlatformIO/scripts/preflight-checks.py post:buildroot/share/PlatformIO/scripts/common-dependencies-post.py lib_deps = -default_src_filter = + - - + +default_src_filter = + - - + - - - - - - - - - - - - - @@ -86,6 +87,7 @@ default_src_filter = + - - + - - - - - + - - - - - - - @@ -252,17 +254,10 @@ framework = arduino extra_scripts = ${common.extra_scripts} build_flags = ${common.build_flags} lib_deps = ${common.lib_deps} -platform_packages = platformio/tool-dfuutil@^1.11.0 monitor_speed = 250000 -monitor_flags = - --quiet - --echo - --eol - LF - --filter - colorize - --filter - time +monitor_eol = LF +monitor_echo = yes +monitor_filters = colorize, time, send_on_enter # # Just print the dependency tree