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_machine_settings.cpp 10KB

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