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_auto_level_offset_settings.cpp 7.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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_BED_PROBE)
  24. #include "lv_conf.h"
  25. #include "draw_ui.h"
  26. #include "../../../../MarlinCore.h"
  27. #include "../../../../module/planner.h"
  28. #include "../../../../module/probe.h"
  29. extern lv_group_t * g;
  30. static lv_obj_t * scr;
  31. #define ID_OFFSET_RETURN 1
  32. #define ID_OFFSET_X 2
  33. #define ID_OFFSET_Y 3
  34. #define ID_OFFSET_Z 4
  35. static void event_handler(lv_obj_t * obj, lv_event_t event) {
  36. switch (obj->mks_obj_id) {
  37. case ID_OFFSET_RETURN:
  38. if (event == LV_EVENT_CLICKED) {
  39. }
  40. else if (event == LV_EVENT_RELEASED) {
  41. lv_clear_auto_level_offset_settings();
  42. draw_return_ui();
  43. }
  44. break;
  45. case ID_OFFSET_X:
  46. if (event == LV_EVENT_CLICKED) {
  47. }
  48. else if (event == LV_EVENT_RELEASED) {
  49. value = x_offset;
  50. lv_clear_auto_level_offset_settings();
  51. lv_draw_number_key();
  52. }
  53. break;
  54. case ID_OFFSET_Y:
  55. if (event == LV_EVENT_CLICKED) {
  56. }
  57. else if (event == LV_EVENT_RELEASED) {
  58. value = y_offset;
  59. lv_clear_auto_level_offset_settings();
  60. lv_draw_number_key();
  61. }
  62. break;
  63. case ID_OFFSET_Z:
  64. if (event == LV_EVENT_CLICKED) {
  65. }
  66. else if (event == LV_EVENT_RELEASED) {
  67. value = z_offset;
  68. lv_clear_auto_level_offset_settings();
  69. lv_draw_number_key();
  70. }
  71. break;
  72. }
  73. }
  74. void lv_draw_auto_level_offset_settings(void) {
  75. lv_obj_t *buttonBack = NULL, *label_Back = NULL;
  76. lv_obj_t *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL;
  77. lv_obj_t *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL;
  78. lv_obj_t *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL;
  79. lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL;
  80. if (disp_state_stack._disp_state[disp_state_stack._disp_index] != NOZZLE_PROBE_OFFSET_UI) {
  81. disp_state_stack._disp_index++;
  82. disp_state_stack._disp_state[disp_state_stack._disp_index] = NOZZLE_PROBE_OFFSET_UI;
  83. }
  84. disp_state = NOZZLE_PROBE_OFFSET_UI;
  85. scr = lv_obj_create(NULL, NULL);
  86. lv_obj_set_style(scr, &tft_style_scr);
  87. lv_scr_load(scr);
  88. lv_obj_clean(scr);
  89. lv_obj_t * title = lv_label_create(scr, NULL);
  90. lv_obj_set_style(title, &tft_style_label_rel);
  91. lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS);
  92. lv_label_set_text(title, machine_menu.OffsetConfTitle);
  93. lv_refr_now(lv_refr_get_disp_refreshing());
  94. labelXText = lv_label_create(scr, NULL);
  95. lv_obj_set_style(labelXText, &tft_style_label_rel);
  96. lv_obj_set_pos(labelXText, PARA_UI_POS_X, PARA_UI_POS_Y + 10);
  97. lv_label_set_text(labelXText, machine_menu.Xoffset);
  98. buttonXValue = lv_btn_create(scr, NULL);
  99. lv_obj_set_pos(buttonXValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V_2);
  100. lv_obj_set_size(buttonXValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
  101. lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_OFFSET_X, NULL, 0);
  102. lv_btn_set_style(buttonXValue, LV_BTN_STYLE_REL, &style_para_value);
  103. lv_btn_set_style(buttonXValue, LV_BTN_STYLE_PR, &style_para_value);
  104. labelXValue = lv_label_create(buttonXValue, NULL);
  105. line1 = lv_line_create(scr, NULL);
  106. lv_ex_line(line1, line_points[0]);
  107. labelYText = lv_label_create(scr, NULL);
  108. lv_obj_set_style(labelYText, &tft_style_label_rel);
  109. lv_obj_set_pos(labelYText, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10);
  110. lv_label_set_text(labelYText, machine_menu.Yoffset);
  111. buttonYValue = lv_btn_create(scr, NULL);
  112. lv_obj_set_pos(buttonYValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V_2);
  113. lv_obj_set_size(buttonYValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
  114. lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_OFFSET_Y, NULL, 0);
  115. lv_btn_set_style(buttonYValue, LV_BTN_STYLE_REL, &style_para_value);
  116. lv_btn_set_style(buttonYValue, LV_BTN_STYLE_PR, &style_para_value);
  117. labelYValue = lv_label_create(buttonYValue, NULL);
  118. line2 = lv_line_create(scr, NULL);
  119. lv_ex_line(line2, line_points[1]);
  120. labelZText = lv_label_create(scr, NULL);
  121. lv_obj_set_style(labelZText, &tft_style_label_rel);
  122. lv_obj_set_pos(labelZText, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10);
  123. lv_label_set_text(labelZText, machine_menu.Zoffset);
  124. buttonZValue = lv_btn_create(scr, NULL);
  125. lv_obj_set_pos(buttonZValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V_2);
  126. lv_obj_set_size(buttonZValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
  127. lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_OFFSET_Z, NULL, 0);
  128. lv_btn_set_style(buttonZValue, LV_BTN_STYLE_REL, &style_para_value);
  129. lv_btn_set_style(buttonZValue, LV_BTN_STYLE_PR, &style_para_value);
  130. labelZValue = lv_label_create(buttonZValue, NULL);
  131. line3 = lv_line_create(scr, NULL);
  132. lv_ex_line(line3, line_points[2]);
  133. buttonBack = lv_btn_create(scr, NULL);
  134. lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_OFFSET_RETURN, NULL, 0);
  135. lv_btn_set_style(buttonBack, LV_BTN_STYLE_REL, &style_para_back);
  136. lv_btn_set_style(buttonBack, LV_BTN_STYLE_PR, &style_para_back);
  137. lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
  138. lv_obj_set_size(buttonBack, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
  139. label_Back = lv_label_create(buttonBack, NULL);
  140. #if HAS_ROTARY_ENCODER
  141. if (gCfgItems.encoder_enable) {
  142. lv_group_add_obj(g, buttonXValue);
  143. lv_group_add_obj(g, buttonYValue);
  144. lv_group_add_obj(g, buttonZValue);
  145. lv_group_add_obj(g, buttonBack);
  146. }
  147. #endif
  148. if (gCfgItems.multiple_language != 0) {
  149. ZERO(public_buf_l);
  150. sprintf_P(public_buf_l, PSTR("%.1f"), TERN(HAS_PROBE_XY_OFFSET, probe.offset.x, 0));
  151. lv_label_set_text(labelXValue, public_buf_l);
  152. lv_obj_align(labelXValue, buttonXValue, LV_ALIGN_CENTER, 0, 0);
  153. ZERO(public_buf_l);
  154. sprintf_P(public_buf_l, PSTR("%.1f"), TERN(HAS_PROBE_XY_OFFSET, probe.offset.y, 0));
  155. lv_label_set_text(labelYValue, public_buf_l);
  156. lv_obj_align(labelYValue, buttonYValue, LV_ALIGN_CENTER, 0, 0);
  157. ZERO(public_buf_l);
  158. sprintf_P(public_buf_l, PSTR("%.1f"), probe.offset.z);
  159. lv_label_set_text(labelZValue, public_buf_l);
  160. lv_obj_align(labelZValue, buttonZValue, LV_ALIGN_CENTER, 0, 0);
  161. lv_label_set_text(label_Back, common_menu.text_back);
  162. lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
  163. }
  164. }
  165. void lv_clear_auto_level_offset_settings() {
  166. #if HAS_ROTARY_ENCODER
  167. if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
  168. #endif
  169. lv_obj_del(scr);
  170. }
  171. #endif // HAS_TFT_LVGL_UI && HAS_BED_PROBE