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_more.cpp 7.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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 "../../../MarlinCore.h"
  25. #include "draw_ready_print.h"
  26. #include "draw_set.h"
  27. #include "lv_conf.h"
  28. #include "draw_ui.h"
  29. #include "../../../gcode/queue.h"
  30. extern lv_group_t * g;
  31. static lv_obj_t * scr;
  32. enum {
  33. ID_GCODE = 1,
  34. #if HAS_USER_ITEM(1)
  35. ID_CUSTOM_1,
  36. #endif
  37. #if HAS_USER_ITEM(2)
  38. ID_CUSTOM_2,
  39. #endif
  40. #if HAS_USER_ITEM(3)
  41. ID_CUSTOM_3,
  42. #endif
  43. #if HAS_USER_ITEM(4)
  44. ID_CUSTOM_4,
  45. #endif
  46. #if HAS_USER_ITEM(5)
  47. ID_CUSTOM_5,
  48. #endif
  49. #if HAS_USER_ITEM(6)
  50. ID_CUSTOM_6,
  51. #endif
  52. ID_M_RETURN,
  53. };
  54. static void event_handler(lv_obj_t * obj, lv_event_t event) {
  55. if (event != LV_EVENT_RELEASED) return;
  56. switch (obj->mks_obj_id) {
  57. case ID_GCODE: lv_clear_more(); lv_draw_gcode(true); break;
  58. #if HAS_USER_ITEM(1)
  59. case ID_CUSTOM_1: queue.inject(F(MAIN_MENU_ITEM_1_GCODE)); break;
  60. #endif
  61. #if HAS_USER_ITEM(2)
  62. case ID_CUSTOM_2: queue.inject(F(MAIN_MENU_ITEM_2_GCODE)); break;
  63. #endif
  64. #if HAS_USER_ITEM(3)
  65. case ID_CUSTOM_3: queue.inject(F(MAIN_MENU_ITEM_3_GCODE)); break;
  66. #endif
  67. #if HAS_USER_ITEM(4)
  68. case ID_CUSTOM_4: queue.inject(F(MAIN_MENU_ITEM_4_GCODE)); break;
  69. #endif
  70. #if HAS_USER_ITEM(5)
  71. case ID_CUSTOM_5: queue.inject(F(MAIN_MENU_ITEM_5_GCODE)); break;
  72. #endif
  73. #if HAS_USER_ITEM(6)
  74. case ID_CUSTOM_6: queue.inject(F(MAIN_MENU_ITEM_6_GCODE)); break;
  75. #endif
  76. case ID_M_RETURN:
  77. lv_clear_more();
  78. lv_draw_tool();
  79. break;
  80. }
  81. }
  82. void lv_draw_more() {
  83. scr = lv_screen_create(MORE_UI);
  84. const bool enc_ena = TERN0(HAS_ROTARY_ENCODER, gCfgItems.encoder_enable);
  85. lv_obj_t *buttonGCode = lv_imgbtn_create(scr, "F:/bmp_machine_para.bin", INTERVAL_V, titleHeight, event_handler, ID_GCODE);
  86. if (enc_ena) lv_group_add_obj(g, buttonGCode);
  87. lv_obj_t *labelGCode = lv_label_create_empty(buttonGCode);
  88. #if HAS_USER_ITEM(1)
  89. lv_obj_t *buttonCustom1 = lv_imgbtn_create(scr, "F:/bmp_custom1.bin", BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_CUSTOM_1);
  90. if (enc_ena) lv_group_add_obj(g, buttonCustom1);
  91. lv_obj_t *labelCustom1 = lv_label_create_empty(buttonCustom1);
  92. #endif
  93. #if HAS_USER_ITEM(2)
  94. lv_obj_t *buttonCustom2 = lv_imgbtn_create(scr, "F:/bmp_custom2.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_CUSTOM_2);
  95. if (enc_ena) lv_group_add_obj(g, buttonCustom2);
  96. lv_obj_t *labelCustom2 = lv_label_create_empty(buttonCustom2);
  97. #endif
  98. #if HAS_USER_ITEM(3)
  99. lv_obj_t *buttonCustom3 = lv_imgbtn_create(scr, "F:/bmp_custom3.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_CUSTOM_3);
  100. if (enc_ena) lv_group_add_obj(g, buttonCustom3);
  101. lv_obj_t *labelCustom3 = lv_label_create_empty(buttonCustom3);
  102. #endif
  103. #if HAS_USER_ITEM(4)
  104. lv_obj_t *buttonCustom4 = lv_imgbtn_create(scr, "F:/bmp_custom4.bin", INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_CUSTOM_4);
  105. if (enc_ena) lv_group_add_obj(g, buttonCustom4);
  106. lv_obj_t *labelCustom4 = lv_label_create_empty(buttonCustom4);
  107. #endif
  108. #if HAS_USER_ITEM(5)
  109. lv_obj_t *buttonCustom5 = lv_imgbtn_create(scr, "F:/bmp_custom5.bin", BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_CUSTOM_5);
  110. if (enc_ena) lv_group_add_obj(g, buttonCustom5);
  111. lv_obj_t *labelCustom5 = lv_label_create_empty(buttonCustom5);
  112. #endif
  113. #if HAS_USER_ITEM(6)
  114. lv_obj_t *buttonCustom6 = lv_imgbtn_create(scr, "F:/bmp_custom6.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_CUSTOM_6);
  115. if (enc_ena) lv_group_add_obj(g, buttonCustom6);
  116. lv_obj_t *labelCustom6 = lv_label_create_empty(buttonCustom6);
  117. #endif
  118. lv_obj_t *buttonBack = lv_imgbtn_create(scr, "F:/bmp_return.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_M_RETURN);
  119. if (enc_ena) lv_group_add_obj(g, buttonBack);
  120. lv_obj_t *label_Back = lv_label_create_empty(buttonBack);
  121. if (gCfgItems.multiple_language != 0) {
  122. lv_label_set_text(labelGCode, more_menu.gcode);
  123. lv_obj_align(labelGCode, buttonGCode, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
  124. #if HAS_USER_ITEM(1)
  125. lv_label_set_text(labelCustom1, more_menu.custom1);
  126. lv_obj_align(labelCustom1, buttonCustom1, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
  127. #endif
  128. #if HAS_USER_ITEM(2)
  129. lv_label_set_text(labelCustom2, more_menu.custom2);
  130. lv_obj_align(labelCustom2, buttonCustom2, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
  131. #endif
  132. #if HAS_USER_ITEM(3)
  133. lv_label_set_text(labelCustom3, more_menu.custom3);
  134. lv_obj_align(labelCustom3, buttonCustom3, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
  135. #endif
  136. #if HAS_USER_ITEM(4)
  137. lv_label_set_text(labelCustom4, more_menu.custom4);
  138. lv_obj_align(labelCustom4, buttonCustom4, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
  139. #endif
  140. #if HAS_USER_ITEM(5)
  141. lv_label_set_text(labelCustom5, more_menu.custom5);
  142. lv_obj_align(labelCustom5, buttonCustom5, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
  143. #endif
  144. #if HAS_USER_ITEM(6)
  145. lv_label_set_text(labelCustom6, more_menu.custom6);
  146. lv_obj_align(labelCustom6, buttonCustom6, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
  147. #endif
  148. lv_label_set_text(label_Back, common_menu.text_back);
  149. lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
  150. }
  151. #if BUTTONS_EXIST(EN1, EN2, ENC)
  152. if (enc_ena) {
  153. lv_group_add_obj(g, buttonGCode);
  154. #if HAS_USER_ITEM(1)
  155. lv_group_add_obj(g, buttonCustom1);
  156. #endif
  157. #if HAS_USER_ITEM(2)
  158. lv_group_add_obj(g, buttonCustom2);
  159. #endif
  160. #if HAS_USER_ITEM(3)
  161. lv_group_add_obj(g, buttonCustom3);
  162. #endif
  163. #if HAS_USER_ITEM(4)
  164. lv_group_add_obj(g, buttonCustom4);
  165. #endif
  166. #if HAS_USER_ITEM(5)
  167. lv_group_add_obj(g, buttonCustom5);
  168. #endif
  169. #if HAS_USER_ITEM(6)
  170. lv_group_add_obj(g, buttonCustom6);
  171. #endif
  172. lv_group_add_obj(g, buttonBack);
  173. }
  174. #endif
  175. }
  176. void lv_clear_more() {
  177. #if BUTTONS_EXIST(EN1, EN2, ENC)
  178. if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
  179. #endif
  180. lv_obj_del(scr);
  181. }
  182. #endif // HAS_TFT_LVGL_UI