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_manuaLevel.cpp 3.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 "../../../../gcode/queue.h"
  27. #include "../../../../inc/MarlinConfig.h"
  28. extern lv_group_t *g;
  29. static lv_obj_t *scr;
  30. enum {
  31. ID_M_POINT1 = 1,
  32. ID_M_POINT2,
  33. ID_M_POINT3,
  34. ID_M_POINT4,
  35. ID_M_POINT5,
  36. ID_MANUAL_RETURN
  37. };
  38. static void event_handler(lv_obj_t *obj, lv_event_t event) {
  39. if (event != LV_EVENT_RELEASED) return;
  40. switch (obj->mks_obj_id) {
  41. case ID_M_POINT1 ... ID_M_POINT5:
  42. if (queue.ring_buffer.empty()) {
  43. if (uiCfg.leveling_first_time) {
  44. uiCfg.leveling_first_time = false;
  45. queue.inject_P(G28_STR);
  46. }
  47. const int ind = obj->mks_obj_id - ID_M_POINT1;
  48. sprintf_P(public_buf_l, PSTR("G1 Z10\nG1 X%d Y%d\nG1 Z0"), (int)gCfgItems.levelingPos[ind][0], (int)gCfgItems.levelingPos[ind][1]);
  49. queue.inject(public_buf_l);
  50. }
  51. break;
  52. case ID_MANUAL_RETURN:
  53. lv_clear_manualLevel();
  54. lv_draw_tool();
  55. break;
  56. }
  57. }
  58. void lv_draw_manualLevel() {
  59. scr = lv_screen_create(LEVELING_UI);
  60. // Create an Image button
  61. lv_obj_t *buttonPoint1 = lv_big_button_create(scr, "F:/bmp_leveling1.bin", leveling_menu.position1, INTERVAL_V, titleHeight, event_handler, ID_M_POINT1);
  62. lv_obj_clear_protect(buttonPoint1, LV_PROTECT_FOLLOW);
  63. lv_big_button_create(scr, "F:/bmp_leveling2.bin", leveling_menu.position2, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_M_POINT2);
  64. lv_big_button_create(scr, "F:/bmp_leveling3.bin", leveling_menu.position3, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_M_POINT3);
  65. lv_big_button_create(scr, "F:/bmp_leveling4.bin", leveling_menu.position4, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_M_POINT4);
  66. lv_big_button_create(scr, "F:/bmp_leveling5.bin", leveling_menu.position5, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_M_POINT5);
  67. lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_MANUAL_RETURN);
  68. }
  69. void lv_clear_manualLevel() {
  70. #if HAS_ROTARY_ENCODER
  71. if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
  72. #endif
  73. lv_obj_del(scr);
  74. }
  75. #endif // HAS_TFT_LVGL_UI