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_jerk_settings.cpp 8.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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 BOTH(HAS_TFT_LVGL_UI, HAS_CLASSIC_JERK)
  24. #include "lv_conf.h"
  25. #include "draw_ui.h"
  26. #include "../../../../MarlinCore.h"
  27. #include "../../../../module/planner.h"
  28. extern lv_group_t * g;
  29. static lv_obj_t * scr;
  30. #define ID_JERK_RETURN 1
  31. #define ID_JERK_X 2
  32. #define ID_JERK_Y 3
  33. #define ID_JERK_Z 4
  34. #define ID_JERK_E 5
  35. static void event_handler(lv_obj_t * obj, lv_event_t event) {
  36. switch (obj->mks_obj_id) {
  37. case ID_JERK_RETURN:
  38. if (event == LV_EVENT_CLICKED) {
  39. }
  40. else if (event == LV_EVENT_RELEASED) {
  41. lv_clear_jerk_settings();
  42. draw_return_ui();
  43. }
  44. break;
  45. case ID_JERK_X:
  46. if (event == LV_EVENT_CLICKED) {
  47. }
  48. else if (event == LV_EVENT_RELEASED) {
  49. value = XJerk;
  50. lv_clear_jerk_settings();
  51. lv_draw_number_key();
  52. }
  53. break;
  54. case ID_JERK_Y:
  55. if (event == LV_EVENT_CLICKED) {
  56. }
  57. else if (event == LV_EVENT_RELEASED) {
  58. value = YJerk;
  59. lv_clear_jerk_settings();
  60. lv_draw_number_key();
  61. }
  62. break;
  63. case ID_JERK_Z:
  64. if (event == LV_EVENT_CLICKED) {
  65. }
  66. else if (event == LV_EVENT_RELEASED) {
  67. value = ZJerk;
  68. lv_clear_jerk_settings();
  69. lv_draw_number_key();
  70. }
  71. break;
  72. case ID_JERK_E:
  73. if (event == LV_EVENT_CLICKED) {
  74. }
  75. else if (event == LV_EVENT_RELEASED) {
  76. value = EJerk;
  77. lv_clear_jerk_settings();
  78. lv_draw_number_key();
  79. }
  80. break;
  81. }
  82. }
  83. void lv_draw_jerk_settings(void) {
  84. lv_obj_t *buttonBack = NULL, *label_Back = NULL;
  85. lv_obj_t *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL;
  86. lv_obj_t *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL;
  87. lv_obj_t *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL;
  88. lv_obj_t *labelEText = NULL, *buttonEValue = NULL, *labelEValue = NULL;
  89. lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL, * line4 = NULL;
  90. if (disp_state_stack._disp_state[disp_state_stack._disp_index] != JERK_UI) {
  91. disp_state_stack._disp_index++;
  92. disp_state_stack._disp_state[disp_state_stack._disp_index] = JERK_UI;
  93. }
  94. disp_state = JERK_UI;
  95. scr = lv_obj_create(NULL, NULL);
  96. lv_obj_set_style(scr, &tft_style_scr);
  97. lv_scr_load(scr);
  98. lv_obj_clean(scr);
  99. lv_obj_t * title = lv_label_create(scr, NULL);
  100. lv_obj_set_style(title, &tft_style_label_rel);
  101. lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS);
  102. lv_label_set_text(title, machine_menu.JerkConfTitle);
  103. lv_refr_now(lv_refr_get_disp_refreshing());
  104. labelXText = lv_label_create(scr, NULL);
  105. lv_obj_set_style(labelXText, &tft_style_label_rel);
  106. lv_obj_set_pos(labelXText, PARA_UI_POS_X, PARA_UI_POS_Y + 10);
  107. lv_label_set_text(labelXText, machine_menu.X_Jerk);
  108. buttonXValue = lv_btn_create(scr, NULL);
  109. lv_obj_set_pos(buttonXValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V);
  110. lv_obj_set_size(buttonXValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
  111. lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_JERK_X, NULL, 0);
  112. lv_btn_set_style(buttonXValue, LV_BTN_STYLE_REL, &style_para_value);
  113. lv_btn_set_style(buttonXValue, LV_BTN_STYLE_PR, &style_para_value);
  114. labelXValue = lv_label_create(buttonXValue, NULL);
  115. line1 = lv_line_create(scr, NULL);
  116. lv_ex_line(line1, line_points[0]);
  117. labelYText = lv_label_create(scr, NULL);
  118. lv_obj_set_style(labelYText, &tft_style_label_rel);
  119. lv_obj_set_pos(labelYText, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10);
  120. lv_label_set_text(labelYText, machine_menu.Y_Jerk);
  121. buttonYValue = lv_btn_create(scr, NULL);
  122. lv_obj_set_pos(buttonYValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V);
  123. lv_obj_set_size(buttonYValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
  124. lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_JERK_Y, NULL, 0);
  125. lv_btn_set_style(buttonYValue, LV_BTN_STYLE_REL, &style_para_value);
  126. lv_btn_set_style(buttonYValue, LV_BTN_STYLE_PR, &style_para_value);
  127. labelYValue = lv_label_create(buttonYValue, NULL);
  128. line2 = lv_line_create(scr, NULL);
  129. lv_ex_line(line2, line_points[1]);
  130. labelZText = lv_label_create(scr, NULL);
  131. lv_obj_set_style(labelZText, &tft_style_label_rel);
  132. lv_obj_set_pos(labelZText, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10);
  133. lv_label_set_text(labelZText, machine_menu.Z_Jerk);
  134. buttonZValue = lv_btn_create(scr, NULL);
  135. lv_obj_set_pos(buttonZValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V);
  136. lv_obj_set_size(buttonZValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
  137. lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_JERK_Z, NULL, 0);
  138. lv_btn_set_style(buttonZValue, LV_BTN_STYLE_REL, &style_para_value);
  139. lv_btn_set_style(buttonZValue, LV_BTN_STYLE_PR, &style_para_value);
  140. labelZValue = lv_label_create(buttonZValue, NULL);
  141. line3 = lv_line_create(scr, NULL);
  142. lv_ex_line(line3, line_points[2]);
  143. labelEText = lv_label_create(scr, NULL);
  144. lv_obj_set_style(labelEText, &tft_style_label_rel);
  145. lv_obj_set_pos(labelEText, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10);
  146. lv_label_set_text(labelEText, machine_menu.E_Jerk);
  147. buttonEValue = lv_btn_create(scr, NULL);
  148. lv_obj_set_pos(buttonEValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V);
  149. lv_obj_set_size(buttonEValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
  150. lv_obj_set_event_cb_mks(buttonEValue, event_handler, ID_JERK_E, NULL, 0);
  151. lv_btn_set_style(buttonEValue, LV_BTN_STYLE_REL, &style_para_value);
  152. lv_btn_set_style(buttonEValue, LV_BTN_STYLE_PR, &style_para_value);
  153. labelEValue = lv_label_create(buttonEValue, NULL);
  154. line4 = lv_line_create(scr, NULL);
  155. lv_ex_line(line4, line_points[3]);
  156. buttonBack = lv_btn_create(scr, NULL);
  157. lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_JERK_RETURN, NULL, 0);
  158. lv_btn_set_style(buttonBack, LV_BTN_STYLE_REL, &style_para_back);
  159. lv_btn_set_style(buttonBack, LV_BTN_STYLE_PR, &style_para_back);
  160. lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
  161. lv_obj_set_size(buttonBack, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
  162. label_Back = lv_label_create(buttonBack, NULL);
  163. #if HAS_ROTARY_ENCODER
  164. if (gCfgItems.encoder_enable == true) {
  165. lv_group_add_obj(g, buttonXValue);
  166. lv_group_add_obj(g, buttonYValue);
  167. lv_group_add_obj(g, buttonZValue);
  168. lv_group_add_obj(g, buttonEValue);
  169. lv_group_add_obj(g, buttonBack);
  170. }
  171. #endif
  172. if (gCfgItems.multiple_language != 0) {
  173. ZERO(public_buf_l);
  174. sprintf_P(public_buf_l, PSTR("%.1f"), planner.max_jerk[X_AXIS]);
  175. lv_label_set_text(labelXValue, public_buf_l);
  176. lv_obj_align(labelXValue, buttonXValue, LV_ALIGN_CENTER, 0, 0);
  177. ZERO(public_buf_l);
  178. sprintf_P(public_buf_l, PSTR("%.1f"), planner.max_jerk[Y_AXIS]);
  179. lv_label_set_text(labelYValue, public_buf_l);
  180. lv_obj_align(labelYValue, buttonYValue, LV_ALIGN_CENTER, 0, 0);
  181. ZERO(public_buf_l);
  182. sprintf_P(public_buf_l, PSTR("%.1f"), planner.max_jerk[Z_AXIS]);
  183. lv_label_set_text(labelZValue, public_buf_l);
  184. lv_obj_align(labelZValue, buttonZValue, LV_ALIGN_CENTER, 0, 0);
  185. ZERO(public_buf_l);
  186. sprintf_P(public_buf_l, PSTR("%.1f"), planner.max_jerk[E_AXIS]);
  187. lv_label_set_text(labelEValue, public_buf_l);
  188. lv_obj_align(labelEValue, buttonEValue, LV_ALIGN_CENTER, 0, 0);
  189. lv_label_set_text(label_Back, common_menu.text_back);
  190. lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
  191. }
  192. }
  193. void lv_clear_jerk_settings() {
  194. #if HAS_ROTARY_ENCODER
  195. if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
  196. #endif
  197. lv_obj_del(scr);
  198. }
  199. #endif // HAS_TFT_LVGL_UI && HAS_CLASSIC_JERK