My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

draw_max_feedrate_settings.cpp 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #include "../../../../inc/MarlinConfigPre.h"
  23. #if HAS_TFT_LVGL_UI
  24. #include "draw_ui.h"
  25. #include <lv_conf.h>
  26. #include "../../../../module/planner.h"
  27. #include "../../../../inc/MarlinConfig.h"
  28. extern lv_group_t *g;
  29. static lv_obj_t *scr;
  30. enum {
  31. ID_FEED_RETURN = 1,
  32. ID_FEED_X,
  33. ID_FEED_Y,
  34. ID_FEED_Z,
  35. ID_FEED_E0,
  36. ID_FEED_E1,
  37. ID_FEED_DOWN,
  38. ID_FEED_UP
  39. };
  40. static void event_handler(lv_obj_t *obj, lv_event_t event) {
  41. if (event != LV_EVENT_RELEASED) return;
  42. lv_clear_max_feedrate_settings();
  43. switch (obj->mks_obj_id) {
  44. case ID_FEED_RETURN:
  45. uiCfg.para_ui_page = false;
  46. draw_return_ui();
  47. return;
  48. case ID_FEED_X:
  49. value = XMaxFeedRate;
  50. break;
  51. case ID_FEED_Y:
  52. value = YMaxFeedRate;
  53. break;
  54. case ID_FEED_Z:
  55. value = ZMaxFeedRate;
  56. break;
  57. case ID_FEED_E0:
  58. value = E0MaxFeedRate;
  59. break;
  60. case ID_FEED_E1:
  61. value = E1MaxFeedRate;
  62. break;
  63. case ID_FEED_UP:
  64. uiCfg.para_ui_page = false;
  65. lv_draw_max_feedrate_settings();
  66. return;
  67. case ID_FEED_DOWN:
  68. uiCfg.para_ui_page = true;
  69. lv_draw_max_feedrate_settings();
  70. return;
  71. }
  72. lv_draw_number_key();
  73. }
  74. void lv_draw_max_feedrate_settings() {
  75. scr = lv_screen_create(MAXFEEDRATE_UI, machine_menu.MaxFeedRateConfTitle);
  76. if (!uiCfg.para_ui_page) {
  77. sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[X_AXIS]);
  78. lv_screen_menu_item_1_edit(scr, machine_menu.XMaxFeedRate, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_FEED_X, 0, public_buf_l);
  79. sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[Y_AXIS]);
  80. lv_screen_menu_item_1_edit(scr, machine_menu.YMaxFeedRate, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_FEED_Y, 1, public_buf_l);
  81. sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[Z_AXIS]);
  82. lv_screen_menu_item_1_edit(scr, machine_menu.ZMaxFeedRate, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_FEED_Z, 2, public_buf_l);
  83. sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[E_AXIS]);
  84. lv_screen_menu_item_1_edit(scr, machine_menu.E0MaxFeedRate, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_FEED_E0, 3, public_buf_l);
  85. lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.next, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_FEED_DOWN, true);
  86. }
  87. else {
  88. sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[E_AXIS_N(1)]);
  89. lv_screen_menu_item_1_edit(scr, machine_menu.E1MaxFeedRate, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_FEED_E1, 0, public_buf_l);
  90. lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.previous, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_FEED_UP, true);
  91. }
  92. lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_FEED_RETURN, true);
  93. }
  94. void lv_clear_max_feedrate_settings() {
  95. #if HAS_ROTARY_ENCODER
  96. if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
  97. #endif
  98. lv_obj_del(scr);
  99. }
  100. #endif // HAS_TFT_LVGL_UI