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_acceleration_settings.cpp 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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_ACCE_RETURN = 1,
  32. ID_ACCE_PRINT,
  33. ID_ACCE_RETRA,
  34. ID_ACCE_TRAVEL,
  35. ID_ACCE_X,
  36. ID_ACCE_Y,
  37. ID_ACCE_Z,
  38. ID_ACCE_E0,
  39. ID_ACCE_E1,
  40. ID_ACCE_UP,
  41. ID_ACCE_DOWN
  42. };
  43. static void event_handler(lv_obj_t *obj, lv_event_t event) {
  44. if (event != LV_EVENT_RELEASED) return;
  45. switch (obj->mks_obj_id) {
  46. case ID_ACCE_RETURN:
  47. uiCfg.para_ui_page = false;
  48. lv_clear_acceleration_settings();
  49. draw_return_ui();
  50. break;
  51. case ID_ACCE_PRINT:
  52. value = PrintAcceleration;
  53. lv_clear_acceleration_settings();
  54. lv_draw_number_key();
  55. break;
  56. case ID_ACCE_RETRA:
  57. value = RetractAcceleration;
  58. lv_clear_acceleration_settings();
  59. lv_draw_number_key();
  60. break;
  61. case ID_ACCE_TRAVEL:
  62. value = TravelAcceleration;
  63. lv_clear_acceleration_settings();
  64. lv_draw_number_key();
  65. break;
  66. case ID_ACCE_X:
  67. value = XAcceleration;
  68. lv_clear_acceleration_settings();
  69. lv_draw_number_key();
  70. break;
  71. case ID_ACCE_Y:
  72. value = YAcceleration;
  73. lv_clear_acceleration_settings();
  74. lv_draw_number_key();
  75. break;
  76. case ID_ACCE_Z:
  77. value = ZAcceleration;
  78. lv_clear_acceleration_settings();
  79. lv_draw_number_key();
  80. break;
  81. case ID_ACCE_E0:
  82. value = E0Acceleration;
  83. lv_clear_acceleration_settings();
  84. lv_draw_number_key();
  85. break;
  86. case ID_ACCE_E1:
  87. value = E1Acceleration;
  88. lv_clear_acceleration_settings();
  89. lv_draw_number_key();
  90. break;
  91. case ID_ACCE_UP:
  92. uiCfg.para_ui_page = false;
  93. lv_clear_acceleration_settings();
  94. lv_draw_acceleration_settings();
  95. break;
  96. case ID_ACCE_DOWN:
  97. uiCfg.para_ui_page = true;
  98. lv_clear_acceleration_settings();
  99. lv_draw_acceleration_settings();
  100. break;
  101. }
  102. }
  103. void lv_draw_acceleration_settings() {
  104. scr = lv_screen_create(ACCELERATION_UI, machine_menu.AccelerationConfTitle);
  105. lv_coord_t y = PARA_UI_POS_Y;
  106. if (!uiCfg.para_ui_page) {
  107. dtostrf(planner.settings.acceleration, 1, 1, public_buf_l);
  108. lv_screen_menu_item_1_edit(scr, machine_menu.PrintAcceleration, PARA_UI_POS_X, y, event_handler, ID_ACCE_PRINT, 0, public_buf_l);
  109. y += PARA_UI_POS_Y;
  110. dtostrf(planner.settings.retract_acceleration, 1, 1, public_buf_l);
  111. lv_screen_menu_item_1_edit(scr, machine_menu.RetractAcceleration, PARA_UI_POS_X, y, event_handler, ID_ACCE_RETRA, 1, public_buf_l);
  112. y += PARA_UI_POS_Y;
  113. dtostrf(planner.settings.travel_acceleration, 1, 1, public_buf_l);
  114. lv_screen_menu_item_1_edit(scr, machine_menu.TravelAcceleration, PARA_UI_POS_X, y, event_handler, ID_ACCE_TRAVEL, 2, public_buf_l);
  115. y += PARA_UI_POS_Y;
  116. itoa(planner.settings.max_acceleration_mm_per_s2[X_AXIS], public_buf_l, 10);
  117. lv_screen_menu_item_1_edit(scr, machine_menu.X_Acceleration, PARA_UI_POS_X, y, event_handler, ID_ACCE_X, 3, public_buf_l);
  118. 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_ACCE_DOWN, true);
  119. }
  120. else {
  121. #if HAS_Y_AXIS
  122. itoa(planner.settings.max_acceleration_mm_per_s2[Y_AXIS], public_buf_l, 10);
  123. lv_screen_menu_item_1_edit(scr, machine_menu.Y_Acceleration, PARA_UI_POS_X, y, event_handler, ID_ACCE_Y, 0, public_buf_l);
  124. #endif
  125. #if HAS_Z_AXIS
  126. y += PARA_UI_POS_Y;
  127. itoa(planner.settings.max_acceleration_mm_per_s2[Z_AXIS], public_buf_l, 10);
  128. lv_screen_menu_item_1_edit(scr, machine_menu.Z_Acceleration, PARA_UI_POS_X, y, event_handler, ID_ACCE_Z, 1, public_buf_l);
  129. #endif
  130. #if HAS_HOTEND
  131. y += PARA_UI_POS_Y;
  132. itoa(planner.settings.max_acceleration_mm_per_s2[E_AXIS], public_buf_l, 10);
  133. lv_screen_menu_item_1_edit(scr, machine_menu.E0_Acceleration, PARA_UI_POS_X, y, event_handler, ID_ACCE_E0, 2, public_buf_l);
  134. #endif
  135. #if ENABLED(DISTINCT_E_FACTORS)
  136. y += PARA_UI_POS_Y;
  137. itoa(planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(1)], public_buf_l, 10);
  138. lv_screen_menu_item_1_edit(scr, machine_menu.E1_Acceleration, PARA_UI_POS_X, y, event_handler, ID_ACCE_E1, 3, public_buf_l);
  139. #endif
  140. 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_ACCE_UP, true);
  141. }
  142. lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACK_POS_X, PARA_UI_BACK_POS_Y, event_handler, ID_ACCE_RETURN, true);
  143. }
  144. void lv_clear_acceleration_settings() {
  145. #if HAS_ROTARY_ENCODER
  146. if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
  147. #endif
  148. lv_obj_del(scr);
  149. }
  150. #endif // HAS_TFT_LVGL_UI