My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

draw_machine_para.cpp 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  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. #define ID_PARA_RETURN 1
  30. #define ID_PARA_MACHINE 2
  31. #define ID_PARA_MACHINE_ARROW 3
  32. #define ID_PARA_MOTOR 4
  33. #define ID_PARA_MOTOR_ARROW 5
  34. #define ID_PARA_LEVEL 6
  35. #define ID_PARA_LEVEL_ARROW 7
  36. #define ID_PARA_ADVANCE 8
  37. #define ID_PARA_ADVANCE_ARROW 9
  38. static void event_handler(lv_obj_t * obj, lv_event_t event) {
  39. switch (obj->mks_obj_id) {
  40. case ID_PARA_RETURN:
  41. if (event == LV_EVENT_CLICKED) {
  42. }
  43. else if (event == LV_EVENT_RELEASED) {
  44. lv_clear_machine_para();
  45. draw_return_ui();
  46. }
  47. break;
  48. case ID_PARA_MACHINE:
  49. if (event == LV_EVENT_CLICKED) {
  50. }
  51. else if (event == LV_EVENT_RELEASED) {
  52. lv_clear_machine_para();
  53. lv_draw_machine_settings();
  54. }
  55. break;
  56. case ID_PARA_MACHINE_ARROW:
  57. if (event == LV_EVENT_CLICKED) {
  58. }
  59. else if (event == LV_EVENT_RELEASED) {
  60. lv_clear_machine_para();
  61. lv_draw_machine_settings();
  62. }
  63. break;
  64. case ID_PARA_MOTOR:
  65. if (event == LV_EVENT_CLICKED) {
  66. }
  67. else if (event == LV_EVENT_RELEASED) {
  68. lv_clear_machine_para();
  69. lv_draw_motor_settings();
  70. }
  71. break;
  72. case ID_PARA_MOTOR_ARROW:
  73. if (event == LV_EVENT_CLICKED) {
  74. }
  75. else if (event == LV_EVENT_RELEASED) {
  76. lv_clear_machine_para();
  77. lv_draw_motor_settings();
  78. }
  79. break;
  80. case ID_PARA_LEVEL:
  81. if (event == LV_EVENT_CLICKED) {
  82. }
  83. else if (event == LV_EVENT_RELEASED) {
  84. lv_clear_machine_para();
  85. lv_draw_level_settings();
  86. }
  87. break;
  88. case ID_PARA_LEVEL_ARROW:
  89. if (event == LV_EVENT_CLICKED) {
  90. }
  91. else if (event == LV_EVENT_RELEASED) {
  92. lv_clear_machine_para();
  93. lv_draw_level_settings();
  94. }
  95. break;
  96. case ID_PARA_ADVANCE:
  97. if (event == LV_EVENT_CLICKED) {
  98. }
  99. else if (event == LV_EVENT_RELEASED) {
  100. lv_clear_machine_para();
  101. lv_draw_advance_settings();
  102. }
  103. break;
  104. case ID_PARA_ADVANCE_ARROW:
  105. if (event == LV_EVENT_CLICKED) {
  106. }
  107. else if (event == LV_EVENT_RELEASED) {
  108. lv_clear_machine_para();
  109. lv_draw_advance_settings();
  110. }
  111. break;
  112. }
  113. }
  114. void lv_draw_machine_para(void) {
  115. lv_obj_t *buttonBack, *label_Back;
  116. lv_obj_t *buttonMachine, *labelMachine, *buttonMachineNarrow;
  117. lv_obj_t *buttonMotor, *labelMotor, *buttonMotorNarrow;
  118. lv_obj_t *buttonLevel, *labelLevel, *buttonLevelNarrow;
  119. lv_obj_t *buttonAdvance, *labelAdvance, *buttonAdvanceNarrow;
  120. lv_obj_t * line1, * line2, * line3, * line4;
  121. if (disp_state_stack._disp_state[disp_state_stack._disp_index] != MACHINE_PARA_UI) {
  122. disp_state_stack._disp_index++;
  123. disp_state_stack._disp_state[disp_state_stack._disp_index] = MACHINE_PARA_UI;
  124. }
  125. disp_state = MACHINE_PARA_UI;
  126. scr = lv_obj_create(NULL, NULL);
  127. lv_obj_set_style(scr, &tft_style_scr);
  128. lv_scr_load(scr);
  129. lv_obj_clean(scr);
  130. lv_obj_t * title = lv_label_create(scr, NULL);
  131. lv_obj_set_style(title, &tft_style_label_rel);
  132. lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS);
  133. lv_label_set_text(title, creat_title_text());
  134. lv_refr_now(lv_refr_get_disp_refreshing());
  135. buttonMachine = lv_btn_create(scr, NULL); /*Add a button the current screen*/
  136. lv_obj_set_pos(buttonMachine, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/
  137. lv_obj_set_size(buttonMachine, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
  138. //lv_obj_set_event_cb(buttonMachine, event_handler);
  139. lv_obj_set_event_cb_mks(buttonMachine, event_handler, ID_PARA_MACHINE, NULL, 0);
  140. lv_btn_set_style(buttonMachine, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
  141. lv_btn_set_style(buttonMachine, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
  142. lv_btn_set_layout(buttonMachine, LV_LAYOUT_OFF);
  143. labelMachine = lv_label_create(buttonMachine, NULL); /*Add a label to the button*/
  144. buttonMachineNarrow = lv_imgbtn_create(scr, NULL);
  145. lv_obj_set_pos(buttonMachineNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y + PARA_UI_ARROW_V);
  146. lv_obj_set_event_cb_mks(buttonMachineNarrow, event_handler, ID_PARA_MACHINE_ARROW, NULL, 0);
  147. lv_imgbtn_set_src(buttonMachineNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
  148. lv_imgbtn_set_src(buttonMachineNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
  149. lv_imgbtn_set_style(buttonMachineNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
  150. lv_imgbtn_set_style(buttonMachineNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
  151. lv_btn_set_layout(buttonMachineNarrow, LV_LAYOUT_OFF);
  152. line1 = lv_line_create(scr, NULL);
  153. lv_ex_line(line1, line_points[0]);
  154. buttonMotor = lv_btn_create(scr, NULL); /*Add a button the current screen*/
  155. lv_obj_set_pos(buttonMotor, PARA_UI_POS_X, PARA_UI_POS_Y * 2); /*Set its position*/
  156. lv_obj_set_size(buttonMotor, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
  157. //lv_obj_set_event_cb(buttonMotor, event_handler);
  158. lv_obj_set_event_cb_mks(buttonMotor, event_handler, ID_PARA_MOTOR, NULL, 0);
  159. lv_btn_set_style(buttonMotor, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
  160. lv_btn_set_style(buttonMotor, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
  161. lv_btn_set_layout(buttonMotor, LV_LAYOUT_OFF);
  162. labelMotor = lv_label_create(buttonMotor, NULL); /*Add a label to the button*/
  163. buttonMotorNarrow = lv_imgbtn_create(scr, NULL);
  164. lv_obj_set_pos(buttonMotorNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 2 + PARA_UI_ARROW_V);
  165. lv_obj_set_event_cb_mks(buttonMotorNarrow, event_handler, ID_PARA_MOTOR_ARROW, NULL, 0);
  166. lv_imgbtn_set_src(buttonMotorNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
  167. lv_imgbtn_set_src(buttonMotorNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
  168. lv_imgbtn_set_style(buttonMotorNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
  169. lv_imgbtn_set_style(buttonMotorNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
  170. lv_btn_set_layout(buttonMotorNarrow, LV_LAYOUT_OFF);
  171. line2 = lv_line_create(scr, NULL);
  172. lv_ex_line(line2, line_points[1]);
  173. buttonLevel = lv_btn_create(scr, NULL); /*Add a button the current screen*/
  174. lv_obj_set_pos(buttonLevel, PARA_UI_POS_X, PARA_UI_POS_Y * 3); /*Set its position*/
  175. lv_obj_set_size(buttonLevel, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
  176. //lv_obj_set_event_cb(buttonMotor, event_handler);
  177. lv_obj_set_event_cb_mks(buttonLevel, event_handler, ID_PARA_LEVEL, NULL, 0);
  178. lv_btn_set_style(buttonLevel, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
  179. lv_btn_set_style(buttonLevel, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
  180. lv_btn_set_layout(buttonLevel, LV_LAYOUT_OFF);
  181. labelLevel = lv_label_create(buttonLevel, NULL); /*Add a label to the button*/
  182. buttonLevelNarrow = lv_imgbtn_create(scr, NULL);
  183. lv_obj_set_pos(buttonLevelNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 3 + PARA_UI_ARROW_V);
  184. lv_obj_set_event_cb_mks(buttonLevelNarrow, event_handler, ID_PARA_LEVEL_ARROW, NULL, 0);
  185. lv_imgbtn_set_src(buttonLevelNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
  186. lv_imgbtn_set_src(buttonLevelNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
  187. lv_imgbtn_set_style(buttonLevelNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
  188. lv_imgbtn_set_style(buttonLevelNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
  189. lv_btn_set_layout(buttonLevelNarrow, LV_LAYOUT_OFF);
  190. line3 = lv_line_create(scr, NULL);
  191. lv_ex_line(line3, line_points[2]);
  192. buttonAdvance = lv_btn_create(scr, NULL); /*Add a button the current screen*/
  193. lv_obj_set_pos(buttonAdvance, PARA_UI_POS_X, PARA_UI_POS_Y * 4); /*Set its position*/
  194. lv_obj_set_size(buttonAdvance, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
  195. //lv_obj_set_event_cb(buttonMotor, event_handler);
  196. lv_obj_set_event_cb_mks(buttonAdvance, event_handler, ID_PARA_ADVANCE, NULL, 0);
  197. lv_btn_set_style(buttonAdvance, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
  198. lv_btn_set_style(buttonAdvance, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
  199. lv_btn_set_layout(buttonAdvance, LV_LAYOUT_OFF);
  200. labelAdvance = lv_label_create(buttonAdvance, NULL); /*Add a label to the button*/
  201. buttonAdvanceNarrow = lv_imgbtn_create(scr, NULL);
  202. lv_obj_set_pos(buttonAdvanceNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 4 + PARA_UI_ARROW_V);
  203. lv_obj_set_event_cb_mks(buttonAdvanceNarrow, event_handler, ID_PARA_ADVANCE_ARROW, NULL, 0);
  204. lv_imgbtn_set_src(buttonAdvanceNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
  205. lv_imgbtn_set_src(buttonAdvanceNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
  206. lv_imgbtn_set_style(buttonAdvanceNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
  207. lv_imgbtn_set_style(buttonAdvanceNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
  208. lv_btn_set_layout(buttonAdvanceNarrow, LV_LAYOUT_OFF);
  209. line4 = lv_line_create(scr, NULL);
  210. lv_ex_line(line4, line_points[3]);
  211. buttonBack = lv_imgbtn_create(scr, NULL);
  212. lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_PARA_RETURN, NULL, 0);
  213. lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin");
  214. lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin");
  215. lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
  216. lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
  217. lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X + 10, PARA_UI_BACL_POS_Y);
  218. lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
  219. label_Back = lv_label_create(buttonBack, NULL);
  220. if (gCfgItems.multiple_language) {
  221. lv_label_set_text(label_Back, common_menu.text_back);
  222. lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, -2);
  223. lv_label_set_text(labelMachine, MachinePara_menu.MachineSetting);
  224. lv_obj_align(labelMachine, buttonMachine, LV_ALIGN_IN_LEFT_MID, 0, -3);
  225. lv_label_set_text(labelMotor, MachinePara_menu.MotorSetting);
  226. lv_obj_align(labelMotor, buttonMotor, LV_ALIGN_IN_LEFT_MID, 0, -3);
  227. lv_label_set_text(labelLevel, MachinePara_menu.leveling);
  228. lv_obj_align(labelLevel, buttonLevel, LV_ALIGN_IN_LEFT_MID, 0, -3);
  229. lv_label_set_text(labelAdvance, MachinePara_menu.AdvanceSetting);
  230. lv_obj_align(labelAdvance, buttonAdvance, LV_ALIGN_IN_LEFT_MID, 0, -3);
  231. }
  232. #if HAS_ROTARY_ENCODER
  233. if (gCfgItems.encoder_enable) {
  234. lv_group_add_obj(g, buttonMachine);
  235. lv_group_add_obj(g, buttonMotor);
  236. lv_group_add_obj(g, buttonLevel);
  237. lv_group_add_obj(g, buttonAdvance);
  238. lv_group_add_obj(g, buttonBack);
  239. }
  240. #endif
  241. }
  242. void lv_clear_machine_para() {
  243. #if HAS_ROTARY_ENCODER
  244. if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
  245. #endif
  246. lv_obj_del(scr);
  247. }
  248. #endif // HAS_TFT_LVGL_UI