draw_level_settings.cpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 "../../../inc/MarlinConfig.h"
  27. extern lv_group_t *g;
  28. static lv_obj_t *scr;
  29. enum {
  30. ID_LEVEL_RETURN = 1,
  31. ID_LEVEL_POSITION,
  32. ID_LEVEL_COMMAND,
  33. ID_LEVEL_ZOFFSET,
  34. ID_Z_OFFSET_WIZARD
  35. };
  36. static void event_handler(lv_obj_t *obj, lv_event_t event) {
  37. if (event != LV_EVENT_RELEASED) return;
  38. lv_clear_level_settings();
  39. switch (obj->mks_obj_id) {
  40. case ID_LEVEL_RETURN:
  41. draw_return_ui();
  42. break;
  43. case ID_LEVEL_POSITION:
  44. lv_draw_tramming_pos_settings();
  45. break;
  46. case ID_LEVEL_COMMAND:
  47. keyboard_value = autoLevelGcodeCommand;
  48. lv_draw_keyboard();
  49. break;
  50. #if HAS_BED_PROBE
  51. case ID_LEVEL_ZOFFSET:
  52. lv_draw_auto_level_offset_settings();
  53. break;
  54. #if ENABLED(PROBE_OFFSET_WIZARD)
  55. case ID_Z_OFFSET_WIZARD:
  56. lv_draw_z_offset_wizard();
  57. break;
  58. #endif
  59. #endif
  60. }
  61. }
  62. void lv_draw_level_settings() {
  63. scr = lv_screen_create(LEVELING_PARA_UI, machine_menu.LevelingParaConfTitle);
  64. lv_screen_menu_item(scr, machine_menu.TrammingPosConf, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_LEVEL_POSITION, 0);
  65. lv_screen_menu_item(scr, machine_menu.LevelingAutoCommandConf, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_LEVEL_COMMAND, 1);
  66. #if HAS_BED_PROBE
  67. lv_screen_menu_item(scr, machine_menu.LevelingAutoZoffsetConf, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_LEVEL_ZOFFSET, 2);
  68. #if ENABLED(PROBE_OFFSET_WIZARD)
  69. lv_screen_menu_item(scr, machine_menu.LevelingZoffsetWizard, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_Z_OFFSET_WIZARD, 3);
  70. #endif
  71. #endif
  72. lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACK_POS_X + 10, PARA_UI_BACK_POS_Y, event_handler, ID_LEVEL_RETURN, true);
  73. }
  74. void lv_clear_level_settings() {
  75. #if HAS_ROTARY_ENCODER
  76. if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
  77. #endif
  78. lv_obj_del(scr);
  79. }
  80. #endif // HAS_TFT_LVGL_UI