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_tool.cpp 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 "../../../module/temperature.h"
  28. #include "../../../inc/MarlinConfig.h"
  29. extern lv_group_t *g;
  30. static lv_obj_t *scr;
  31. enum {
  32. ID_T_PRE_HEAT = 1,
  33. ID_T_EXTRUCT,
  34. ID_T_MOV,
  35. ID_T_HOME,
  36. ID_T_LEVELING,
  37. ID_T_FILAMENT,
  38. ID_T_MORE,
  39. ID_T_RETURN
  40. };
  41. #if ENABLED(MKS_TEST)
  42. extern uint8_t current_disp_ui;
  43. #endif
  44. static void event_handler(lv_obj_t *obj, lv_event_t event) {
  45. if (event != LV_EVENT_RELEASED) return;
  46. if (TERN1(AUTO_BED_LEVELING_BILINEAR, obj->mks_obj_id != ID_T_LEVELING))
  47. lv_clear_tool();
  48. switch (obj->mks_obj_id) {
  49. case ID_T_PRE_HEAT: lv_draw_preHeat(); break;
  50. case ID_T_EXTRUCT: lv_draw_extrusion(); break;
  51. case ID_T_MOV: lv_draw_move_motor(); break;
  52. case ID_T_HOME: lv_draw_home(); break;
  53. case ID_T_LEVELING:
  54. #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
  55. get_gcode_command(AUTO_LEVELING_COMMAND_ADDR, (uint8_t *)public_buf_m);
  56. public_buf_m[sizeof(public_buf_m) - 1] = 0;
  57. queue.inject(public_buf_m);
  58. #else
  59. uiCfg.leveling_first_time = true;
  60. lv_draw_manualLevel();
  61. #endif
  62. break;
  63. case ID_T_FILAMENT:
  64. uiCfg.hotendTargetTempBak = thermalManager.degTargetHotend(uiCfg.extruderIndex);
  65. lv_draw_filament_change();
  66. break;
  67. case ID_T_MORE:
  68. lv_draw_more();
  69. break;
  70. case ID_T_RETURN:
  71. TERN_(MKS_TEST, current_disp_ui = 1);
  72. lv_draw_ready_print();
  73. break;
  74. }
  75. }
  76. void lv_draw_tool() {
  77. scr = lv_screen_create(TOOL_UI);
  78. lv_big_button_create(scr, "F:/bmp_preHeat.bin", tool_menu.preheat, INTERVAL_V, titleHeight, event_handler, ID_T_PRE_HEAT);
  79. lv_big_button_create(scr, "F:/bmp_extruct.bin", tool_menu.extrude, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_T_EXTRUCT);
  80. lv_big_button_create(scr, "F:/bmp_mov.bin", tool_menu.move, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_T_MOV);
  81. lv_big_button_create(scr, "F:/bmp_zero.bin", tool_menu.home, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_T_HOME);
  82. lv_big_button_create(scr, "F:/bmp_leveling.bin", tool_menu.TERN(AUTO_BED_LEVELING_BILINEAR, autoleveling, leveling), INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_T_LEVELING);
  83. lv_big_button_create(scr, "F:/bmp_filamentchange.bin", tool_menu.filament, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_T_FILAMENT);
  84. lv_big_button_create(scr, "F:/bmp_more.bin", tool_menu.more, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_T_MORE);
  85. 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_T_RETURN);
  86. }
  87. void lv_clear_tool() {
  88. #if HAS_ROTARY_ENCODER
  89. if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
  90. #endif
  91. lv_obj_del(scr);
  92. }
  93. #endif // HAS_TFT_LVGL_UI