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_advance_settings.cpp 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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_ADVANCE_RETURN 1
  29. #define ID_PAUSE_POS 2
  30. #define ID_PAUSE_POS_ARROW 3
  31. static void event_handler(lv_obj_t * obj, lv_event_t event) {
  32. switch (obj->mks_obj_id) {
  33. case ID_ADVANCE_RETURN:
  34. if (event == LV_EVENT_CLICKED) {
  35. }
  36. else if (event == LV_EVENT_RELEASED) {
  37. lv_clear_advance_settings();
  38. draw_return_ui();
  39. }
  40. break;
  41. case ID_PAUSE_POS:
  42. if (event == LV_EVENT_CLICKED) {
  43. }
  44. else if (event == LV_EVENT_RELEASED) {
  45. lv_clear_advance_settings();
  46. lv_draw_pause_position();
  47. }
  48. break;
  49. case ID_PAUSE_POS_ARROW:
  50. if (event == LV_EVENT_CLICKED) {
  51. }
  52. else if (event == LV_EVENT_RELEASED) {
  53. lv_clear_advance_settings();
  54. lv_draw_pause_position();
  55. }
  56. break;
  57. }
  58. }
  59. void lv_draw_advance_settings(void) {
  60. lv_obj_t *buttonBack, *label_Back;
  61. lv_obj_t *buttonPausePos, *labelPausePos, *buttonPausePosNarrow;
  62. lv_obj_t * line1;
  63. if (disp_state_stack._disp_state[disp_state_stack._disp_index] != ADVANCED_UI) {
  64. disp_state_stack._disp_index++;
  65. disp_state_stack._disp_state[disp_state_stack._disp_index] = ADVANCED_UI;
  66. }
  67. disp_state = ADVANCED_UI;
  68. scr = lv_obj_create(NULL, NULL);
  69. lv_obj_set_style(scr, &tft_style_scr);
  70. lv_scr_load(scr);
  71. lv_obj_clean(scr);
  72. lv_obj_t * title = lv_label_create(scr, NULL);
  73. lv_obj_set_style(title, &tft_style_label_rel);
  74. lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS);
  75. lv_label_set_text(title, machine_menu.AdvancedConfTitle);
  76. lv_refr_now(lv_refr_get_disp_refreshing());
  77. LV_IMG_DECLARE(bmp_para_back);
  78. LV_IMG_DECLARE(bmp_para_arrow);
  79. buttonPausePos = lv_btn_create(scr, NULL); /*Add a button the current screen*/
  80. lv_obj_set_pos(buttonPausePos, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/
  81. lv_obj_set_size(buttonPausePos, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
  82. // lv_obj_set_event_cb(buttonMachine, event_handler);
  83. lv_obj_set_event_cb_mks(buttonPausePos, event_handler, ID_PAUSE_POS, NULL, 0);
  84. lv_btn_set_style(buttonPausePos, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
  85. lv_btn_set_style(buttonPausePos, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
  86. lv_btn_set_layout(buttonPausePos, LV_LAYOUT_OFF);
  87. labelPausePos = lv_label_create(buttonPausePos, NULL); /*Add a label to the button*/
  88. buttonPausePosNarrow = lv_imgbtn_create(scr, NULL);
  89. lv_obj_set_pos(buttonPausePosNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y + PARA_UI_ARROW_V);
  90. lv_obj_set_event_cb_mks(buttonPausePosNarrow, event_handler, ID_PAUSE_POS_ARROW, "bmp_arrow.bin", 0);
  91. lv_imgbtn_set_src(buttonPausePosNarrow, LV_BTN_STATE_REL, &bmp_para_arrow);
  92. lv_imgbtn_set_src(buttonPausePosNarrow, LV_BTN_STATE_PR, &bmp_para_arrow);
  93. lv_imgbtn_set_style(buttonPausePosNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
  94. lv_imgbtn_set_style(buttonPausePosNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
  95. lv_btn_set_layout(buttonPausePosNarrow, LV_LAYOUT_OFF);
  96. line1 = lv_line_create(lv_scr_act(), NULL);
  97. lv_ex_line(line1, line_points[0]);
  98. buttonBack = lv_imgbtn_create(scr, NULL);
  99. lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_ADVANCE_RETURN, "bmp_back70x40.bin", 0);
  100. lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_para_back);
  101. lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_para_back);
  102. lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
  103. lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
  104. lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
  105. lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
  106. label_Back = lv_label_create(buttonBack, NULL);
  107. if (gCfgItems.multiple_language != 0) {
  108. lv_label_set_text(label_Back, common_menu.text_back);
  109. lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
  110. lv_label_set_text(labelPausePos, machine_menu.PausePosition);
  111. lv_obj_align(labelPausePos, buttonPausePos, LV_ALIGN_IN_LEFT_MID, 0, 0);
  112. }
  113. }
  114. void lv_clear_advance_settings() { lv_obj_del(scr); }
  115. #endif // HAS_TFT_LVGL_UI