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

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