My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

draw_machine_para.cpp 9.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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 "lv_conf.h"
  25. #include "draw_ui.h"
  26. #include "../../../../MarlinCore.h"
  27. static lv_obj_t * scr;
  28. #define ID_PARA_RETURN 1
  29. #define ID_PARA_MACHINE 2
  30. #define ID_PARA_MACHINE_ARROW 3
  31. #define ID_PARA_MOTOR 4
  32. #define ID_PARA_MOTOR_ARROW 5
  33. #define ID_PARA_ADVANCE 6
  34. #define ID_PARA_ADVANCE_ARROW 7
  35. static void event_handler(lv_obj_t * obj, lv_event_t event) {
  36. switch (obj->mks_obj_id) {
  37. case ID_PARA_RETURN:
  38. if (event == LV_EVENT_CLICKED) {
  39. }
  40. else if (event == LV_EVENT_RELEASED) {
  41. lv_clear_machine_para();
  42. draw_return_ui();
  43. }
  44. break;
  45. case ID_PARA_MACHINE:
  46. if (event == LV_EVENT_CLICKED) {
  47. }
  48. else if (event == LV_EVENT_RELEASED) {
  49. lv_clear_machine_para();
  50. lv_draw_machine_settings();
  51. }
  52. break;
  53. case ID_PARA_MACHINE_ARROW:
  54. if (event == LV_EVENT_CLICKED) {
  55. }
  56. else if (event == LV_EVENT_RELEASED) {
  57. lv_clear_machine_para();
  58. lv_draw_machine_settings();
  59. }
  60. break;
  61. case ID_PARA_MOTOR:
  62. if (event == LV_EVENT_CLICKED) {
  63. }
  64. else if (event == LV_EVENT_RELEASED) {
  65. lv_clear_machine_para();
  66. lv_draw_motor_settings();
  67. }
  68. break;
  69. case ID_PARA_MOTOR_ARROW:
  70. if (event == LV_EVENT_CLICKED) {
  71. }
  72. else if (event == LV_EVENT_RELEASED) {
  73. lv_clear_machine_para();
  74. lv_draw_motor_settings();
  75. }
  76. break;
  77. case ID_PARA_ADVANCE:
  78. if (event == LV_EVENT_CLICKED) {
  79. }
  80. else if (event == LV_EVENT_RELEASED) {
  81. lv_clear_machine_para();
  82. lv_draw_advance_settings();
  83. }
  84. break;
  85. case ID_PARA_ADVANCE_ARROW:
  86. if (event == LV_EVENT_CLICKED) {
  87. }
  88. else if (event == LV_EVENT_RELEASED) {
  89. lv_clear_machine_para();
  90. lv_draw_advance_settings();
  91. }
  92. break;
  93. }
  94. }
  95. void lv_draw_machine_para(void) {
  96. lv_obj_t *buttonBack, *label_Back;
  97. lv_obj_t *buttonMachine, *labelMachine, *buttonMachineNarrow;
  98. lv_obj_t *buttonMotor, *labelMotor, *buttonMotorNarrow;
  99. lv_obj_t *buttonAdvance, *labelAdvance, *buttonAdvanceNarrow;
  100. lv_obj_t * line1, * line2, * line3;
  101. if (disp_state_stack._disp_state[disp_state_stack._disp_index] != MACHINE_PARA_UI) {
  102. disp_state_stack._disp_index++;
  103. disp_state_stack._disp_state[disp_state_stack._disp_index] = MACHINE_PARA_UI;
  104. }
  105. disp_state = MACHINE_PARA_UI;
  106. scr = lv_obj_create(NULL, NULL);
  107. lv_obj_set_style(scr, &tft_style_scr);
  108. lv_scr_load(scr);
  109. lv_obj_clean(scr);
  110. lv_obj_t * title = lv_label_create(scr, NULL);
  111. lv_obj_set_style(title, &tft_style_label_rel);
  112. lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS);
  113. lv_label_set_text(title, creat_title_text());
  114. lv_refr_now(lv_refr_get_disp_refreshing());
  115. LV_IMG_DECLARE(bmp_para_back);
  116. LV_IMG_DECLARE(bmp_para_arrow);
  117. buttonMachine = lv_btn_create(scr, NULL); /*Add a button the current screen*/
  118. lv_obj_set_pos(buttonMachine, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/
  119. lv_obj_set_size(buttonMachine, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
  120. //lv_obj_set_event_cb(buttonMachine, event_handler);
  121. lv_obj_set_event_cb_mks(buttonMachine, event_handler, ID_PARA_MACHINE, NULL, 0);
  122. lv_btn_set_style(buttonMachine, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
  123. lv_btn_set_style(buttonMachine, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
  124. lv_btn_set_layout(buttonMachine, LV_LAYOUT_OFF);
  125. labelMachine = lv_label_create(buttonMachine, NULL); /*Add a label to the button*/
  126. buttonMachineNarrow = lv_imgbtn_create(scr, NULL);
  127. lv_obj_set_pos(buttonMachineNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y + PARA_UI_ARROW_V);
  128. lv_obj_set_event_cb_mks(buttonMachineNarrow, event_handler, ID_PARA_MACHINE_ARROW, "bmp_arrow.bin", 0);
  129. lv_imgbtn_set_src(buttonMachineNarrow, LV_BTN_STATE_REL, &bmp_para_arrow);
  130. lv_imgbtn_set_src(buttonMachineNarrow, LV_BTN_STATE_PR, &bmp_para_arrow);
  131. lv_imgbtn_set_style(buttonMachineNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
  132. lv_imgbtn_set_style(buttonMachineNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
  133. lv_btn_set_layout(buttonMachineNarrow, LV_LAYOUT_OFF);
  134. line1 = lv_line_create(scr, NULL);
  135. lv_ex_line(line1, line_points[0]);
  136. buttonMotor = lv_btn_create(scr, NULL); /*Add a button the current screen*/
  137. lv_obj_set_pos(buttonMotor, PARA_UI_POS_X, PARA_UI_POS_Y * 2); /*Set its position*/
  138. lv_obj_set_size(buttonMotor, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
  139. //lv_obj_set_event_cb(buttonMotor, event_handler);
  140. lv_obj_set_event_cb_mks(buttonMotor, event_handler, ID_PARA_MOTOR, NULL, 0);
  141. lv_btn_set_style(buttonMotor, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
  142. lv_btn_set_style(buttonMotor, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
  143. lv_btn_set_layout(buttonMotor, LV_LAYOUT_OFF);
  144. labelMotor = lv_label_create(buttonMotor, NULL); /*Add a label to the button*/
  145. buttonMotorNarrow = lv_imgbtn_create(scr, NULL);
  146. lv_obj_set_pos(buttonMotorNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 2 + PARA_UI_ARROW_V);
  147. lv_obj_set_event_cb_mks(buttonMotorNarrow, event_handler, ID_PARA_MOTOR_ARROW, "bmp_arrow.bin", 0);
  148. lv_imgbtn_set_src(buttonMotorNarrow, LV_BTN_STATE_REL, &bmp_para_arrow);
  149. lv_imgbtn_set_src(buttonMotorNarrow, LV_BTN_STATE_PR, &bmp_para_arrow);
  150. lv_imgbtn_set_style(buttonMotorNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
  151. lv_imgbtn_set_style(buttonMotorNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
  152. lv_btn_set_layout(buttonMotorNarrow, LV_LAYOUT_OFF);
  153. line2 = lv_line_create(scr, NULL);
  154. lv_ex_line(line2, line_points[1]);
  155. buttonAdvance = lv_btn_create(scr, NULL); /*Add a button the current screen*/
  156. lv_obj_set_pos(buttonAdvance, PARA_UI_POS_X, PARA_UI_POS_Y * 3); /*Set its position*/
  157. lv_obj_set_size(buttonAdvance, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
  158. //lv_obj_set_event_cb(buttonMotor, event_handler);
  159. lv_obj_set_event_cb_mks(buttonAdvance, event_handler, ID_PARA_ADVANCE, NULL, 0);
  160. lv_btn_set_style(buttonAdvance, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
  161. lv_btn_set_style(buttonAdvance, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
  162. lv_btn_set_layout(buttonAdvance, LV_LAYOUT_OFF);
  163. labelAdvance = lv_label_create(buttonAdvance, NULL); /*Add a label to the button*/
  164. buttonAdvanceNarrow = lv_imgbtn_create(scr, NULL);
  165. lv_obj_set_pos(buttonAdvanceNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 3 + PARA_UI_ARROW_V);
  166. lv_obj_set_event_cb_mks(buttonAdvanceNarrow, event_handler, ID_PARA_ADVANCE_ARROW, "bmp_arrow.bin", 0);
  167. lv_imgbtn_set_src(buttonAdvanceNarrow, LV_BTN_STATE_REL, &bmp_para_arrow);
  168. lv_imgbtn_set_src(buttonAdvanceNarrow, LV_BTN_STATE_PR, &bmp_para_arrow);
  169. lv_imgbtn_set_style(buttonAdvanceNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
  170. lv_imgbtn_set_style(buttonAdvanceNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
  171. lv_btn_set_layout(buttonAdvanceNarrow, LV_LAYOUT_OFF);
  172. line3 = lv_line_create(scr, NULL);
  173. lv_ex_line(line3, line_points[2]);
  174. buttonBack = lv_imgbtn_create(scr, NULL);
  175. lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_PARA_RETURN, "bmp_back70x40.bin", 0);
  176. lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_para_back);
  177. lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_para_back);
  178. lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
  179. lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
  180. lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
  181. lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
  182. label_Back = lv_label_create(buttonBack, NULL);
  183. if (gCfgItems.multiple_language != 0) {
  184. lv_label_set_text(label_Back, common_menu.text_back);
  185. lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
  186. lv_label_set_text(labelMachine, MachinePara_menu.MachineSetting);
  187. lv_obj_align(labelMachine, buttonMachine, LV_ALIGN_IN_LEFT_MID, 0, 0);
  188. lv_label_set_text(labelMotor, MachinePara_menu.MotorSetting);
  189. lv_obj_align(labelMotor, buttonMotor, LV_ALIGN_IN_LEFT_MID, 0, 0);
  190. lv_label_set_text(labelAdvance, MachinePara_menu.AdvanceSetting);
  191. lv_obj_align(labelAdvance, buttonAdvance, LV_ALIGN_IN_LEFT_MID, 0, 0);
  192. }
  193. }
  194. void lv_clear_machine_para() { lv_obj_del(scr); }
  195. #endif // HAS_TFT_LVGL_UI