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_homing_sensitivity_settings.cpp 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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/MarlinConfig.h"
  23. #if HAS_TFT_LVGL_UI && USE_SENSORLESS
  24. #include "draw_ui.h"
  25. #include <lv_conf.h>
  26. #include "../../../module/planner.h"
  27. #include "../../../module/probe.h"
  28. #include "../../../module/stepper/indirection.h"
  29. #include "../../../feature/tmc_util.h"
  30. extern lv_group_t *g;
  31. static lv_obj_t *scr;
  32. enum {
  33. ID_SENSITIVITY_RETURN = 1,
  34. ID_SENSITIVITY_X,
  35. ID_SENSITIVITY_Y,
  36. ID_SENSITIVITY_Z,
  37. ID_SENSITIVITY_Z2
  38. };
  39. static void event_handler(lv_obj_t *obj, lv_event_t event) {
  40. if (event != LV_EVENT_RELEASED) return;
  41. switch (obj->mks_obj_id) {
  42. case ID_SENSITIVITY_RETURN:
  43. lv_clear_homing_sensitivity_settings();
  44. draw_return_ui();
  45. break;
  46. case ID_SENSITIVITY_X:
  47. value = x_sensitivity;
  48. lv_clear_homing_sensitivity_settings();
  49. lv_draw_number_key();
  50. break;
  51. case ID_SENSITIVITY_Y:
  52. value = y_sensitivity;
  53. lv_clear_homing_sensitivity_settings();
  54. lv_draw_number_key();
  55. break;
  56. case ID_SENSITIVITY_Z:
  57. value = z_sensitivity;
  58. lv_clear_homing_sensitivity_settings();
  59. lv_draw_number_key();
  60. break;
  61. #if Z2_SENSORLESS
  62. case ID_SENSITIVITY_Z2:
  63. value = z2_sensitivity;
  64. lv_clear_homing_sensitivity_settings();
  65. lv_draw_number_key();
  66. break;
  67. #endif
  68. }
  69. }
  70. void lv_draw_homing_sensitivity_settings() {
  71. scr = lv_screen_create(HOMING_SENSITIVITY_UI, machine_menu.HomingSensitivityConfTitle);
  72. itoa(TERN(X_SENSORLESS, stepperX.homing_threshold(), 0), public_buf_l, 10);
  73. lv_screen_menu_item_1_edit(scr, machine_menu.X_Sensitivity, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_SENSITIVITY_X, 0, public_buf_l);
  74. itoa(TERN(Y_SENSORLESS, stepperY.homing_threshold(), 0), public_buf_l, 10);
  75. lv_screen_menu_item_1_edit(scr, machine_menu.Y_Sensitivity, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_SENSITIVITY_Y, 1, public_buf_l);
  76. itoa(TERN(Z_SENSORLESS, stepperZ.homing_threshold(), 0), public_buf_l, 10);
  77. lv_screen_menu_item_1_edit(scr, machine_menu.Z_Sensitivity, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_SENSITIVITY_Z, 2, public_buf_l);
  78. #if Z2_SENSORLESS
  79. itoa(TERN(Z2_SENSORLESS, stepperZ2.homing_threshold(), 0), public_buf_l, 10);
  80. lv_screen_menu_item_1_edit(scr, machine_menu.Z2_Sensitivity, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_SENSITIVITY_Z2, 3, public_buf_l);
  81. #endif
  82. 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_SENSITIVITY_RETURN, true);
  83. }
  84. void lv_clear_homing_sensitivity_settings() {
  85. #if HAS_ROTARY_ENCODER
  86. if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
  87. #endif
  88. lv_obj_del(scr);
  89. }
  90. #endif // HAS_TFT_LVGL_UI && USE_SENSORLESS