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_max_feedrate_settings.cpp 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  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 "../../../../module/planner.h"
  27. #include "../../../../inc/MarlinConfig.h"
  28. extern lv_group_t * g;
  29. static lv_obj_t * scr;
  30. #define ID_FEED_RETURN 1
  31. #define ID_FEED_X 2
  32. #define ID_FEED_Y 3
  33. #define ID_FEED_Z 4
  34. #define ID_FEED_E0 5
  35. #define ID_FEED_E1 6
  36. #define ID_FEED_DOWN 7
  37. #define ID_FEED_UP 8
  38. static void event_handler(lv_obj_t * obj, lv_event_t event) {
  39. switch (obj->mks_obj_id) {
  40. case ID_FEED_RETURN:
  41. if (event == LV_EVENT_CLICKED) {
  42. }
  43. else if (event == LV_EVENT_RELEASED) {
  44. uiCfg.para_ui_page = 0;
  45. lv_clear_max_feedrate_settings();
  46. draw_return_ui();
  47. }
  48. break;
  49. case ID_FEED_X:
  50. if (event == LV_EVENT_CLICKED) {
  51. }
  52. else if (event == LV_EVENT_RELEASED) {
  53. value = XMaxFeedRate;
  54. lv_clear_max_feedrate_settings();
  55. lv_draw_number_key();
  56. }
  57. break;
  58. case ID_FEED_Y:
  59. if (event == LV_EVENT_CLICKED) {
  60. }
  61. else if (event == LV_EVENT_RELEASED) {
  62. value = YMaxFeedRate;
  63. lv_clear_max_feedrate_settings();
  64. lv_draw_number_key();
  65. }
  66. break;
  67. case ID_FEED_Z:
  68. if (event == LV_EVENT_CLICKED) {
  69. }
  70. else if (event == LV_EVENT_RELEASED) {
  71. value = ZMaxFeedRate;
  72. lv_clear_max_feedrate_settings();
  73. lv_draw_number_key();
  74. }
  75. break;
  76. case ID_FEED_E0:
  77. if (event == LV_EVENT_CLICKED) {
  78. }
  79. else if (event == LV_EVENT_RELEASED) {
  80. value = E0MaxFeedRate;
  81. lv_clear_max_feedrate_settings();
  82. lv_draw_number_key();
  83. }
  84. break;
  85. case ID_FEED_E1:
  86. if (event == LV_EVENT_CLICKED) {
  87. }
  88. else if (event == LV_EVENT_RELEASED) {
  89. value = E1MaxFeedRate;
  90. lv_clear_max_feedrate_settings();
  91. lv_draw_number_key();
  92. }
  93. break;
  94. case ID_FEED_UP:
  95. if (event == LV_EVENT_CLICKED) {
  96. }
  97. else if (event == LV_EVENT_RELEASED) {
  98. uiCfg.para_ui_page = 0;
  99. lv_clear_max_feedrate_settings();
  100. lv_draw_max_feedrate_settings();
  101. }
  102. break;
  103. case ID_FEED_DOWN:
  104. if (event == LV_EVENT_CLICKED) {
  105. }
  106. else if (event == LV_EVENT_RELEASED) {
  107. uiCfg.para_ui_page = 1;
  108. lv_clear_max_feedrate_settings();
  109. lv_draw_max_feedrate_settings();
  110. }
  111. break;
  112. }
  113. }
  114. void lv_draw_max_feedrate_settings(void) {
  115. lv_obj_t *buttonBack = NULL, *label_Back = NULL, *buttonTurnPage = NULL, *labelTurnPage = NULL;
  116. lv_obj_t *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL;
  117. lv_obj_t *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL;
  118. lv_obj_t *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL;
  119. lv_obj_t *labelE0Text = NULL, *buttonE0Value = NULL, *labelE0Value = NULL;
  120. lv_obj_t *labelE1Text = NULL, *buttonE1Value = NULL, *labelE1Value = NULL;
  121. lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL, * line4 = NULL;
  122. if (disp_state_stack._disp_state[disp_state_stack._disp_index] != MAXFEEDRATE_UI) {
  123. disp_state_stack._disp_index++;
  124. disp_state_stack._disp_state[disp_state_stack._disp_index] = MAXFEEDRATE_UI;
  125. }
  126. disp_state = MAXFEEDRATE_UI;
  127. scr = lv_obj_create(NULL, NULL);
  128. lv_obj_set_style(scr, &tft_style_scr);
  129. lv_scr_load(scr);
  130. lv_obj_clean(scr);
  131. lv_obj_t * title = lv_label_create(scr, NULL);
  132. lv_obj_set_style(title, &tft_style_label_rel);
  133. lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS);
  134. lv_label_set_text(title, machine_menu.MaxFeedRateConfTitle);
  135. lv_refr_now(lv_refr_get_disp_refreshing());
  136. if (uiCfg.para_ui_page != 1) {
  137. labelXText = lv_label_create(scr, NULL);
  138. lv_obj_set_style(labelXText, &tft_style_label_rel);
  139. lv_obj_set_pos(labelXText, PARA_UI_POS_X, PARA_UI_POS_Y + 10);
  140. lv_label_set_text(labelXText, machine_menu.XMaxFeedRate);
  141. buttonXValue = lv_btn_create(scr, NULL);
  142. lv_obj_set_pos(buttonXValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V);
  143. lv_obj_set_size(buttonXValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
  144. lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_FEED_X, NULL, 0);
  145. lv_btn_set_style(buttonXValue, LV_BTN_STYLE_REL, &style_para_value);
  146. lv_btn_set_style(buttonXValue, LV_BTN_STYLE_PR, &style_para_value);
  147. lv_btn_set_layout(buttonXValue, LV_LAYOUT_OFF);
  148. labelXValue = lv_label_create(buttonXValue, NULL);
  149. line1 = lv_line_create(scr, NULL);
  150. lv_ex_line(line1, line_points[0]);
  151. labelYText = lv_label_create(scr, NULL);
  152. lv_obj_set_style(labelYText, &tft_style_label_rel);
  153. lv_obj_set_pos(labelYText, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10);
  154. lv_label_set_text(labelYText, machine_menu.YMaxFeedRate);
  155. buttonYValue = lv_btn_create(scr, NULL);
  156. lv_obj_set_pos(buttonYValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V);
  157. lv_obj_set_size(buttonYValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
  158. lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_FEED_Y, NULL, 0);
  159. lv_btn_set_style(buttonYValue, LV_BTN_STYLE_REL, &style_para_value);
  160. lv_btn_set_style(buttonYValue, LV_BTN_STYLE_PR, &style_para_value);
  161. lv_btn_set_layout(buttonYValue, LV_LAYOUT_OFF);
  162. labelYValue = lv_label_create(buttonYValue, NULL);
  163. line2 = lv_line_create(scr, NULL);
  164. lv_ex_line(line2, line_points[1]);
  165. labelZText = lv_label_create(scr, NULL);
  166. lv_obj_set_style(labelZText, &tft_style_label_rel);
  167. lv_obj_set_pos(labelZText, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10);
  168. lv_label_set_text(labelZText, machine_menu.ZMaxFeedRate);
  169. buttonZValue = lv_btn_create(scr, NULL);
  170. lv_obj_set_pos(buttonZValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V);
  171. lv_obj_set_size(buttonZValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
  172. lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_FEED_Z, NULL, 0);
  173. lv_btn_set_style(buttonZValue, LV_BTN_STYLE_REL, &style_para_value);
  174. lv_btn_set_style(buttonZValue, LV_BTN_STYLE_PR, &style_para_value);
  175. lv_btn_set_layout(buttonZValue, LV_LAYOUT_OFF);
  176. labelZValue = lv_label_create(buttonZValue, NULL);
  177. line3 = lv_line_create(scr, NULL);
  178. lv_ex_line(line3, line_points[2]);
  179. labelE0Text = lv_label_create(scr, NULL);
  180. lv_obj_set_style(labelE0Text, &tft_style_label_rel);
  181. lv_obj_set_pos(labelE0Text, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10);
  182. lv_label_set_text(labelE0Text, machine_menu.E0MaxFeedRate);
  183. buttonE0Value = lv_btn_create(scr, NULL);
  184. lv_obj_set_pos(buttonE0Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V);
  185. lv_obj_set_size(buttonE0Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
  186. lv_obj_set_event_cb_mks(buttonE0Value, event_handler, ID_FEED_E0, NULL, 0);
  187. lv_btn_set_style(buttonE0Value, LV_BTN_STYLE_REL, &style_para_value);
  188. lv_btn_set_style(buttonE0Value, LV_BTN_STYLE_PR, &style_para_value);
  189. lv_btn_set_layout(buttonE0Value, LV_LAYOUT_OFF);
  190. labelE0Value = lv_label_create(buttonE0Value, NULL);
  191. line4 = lv_line_create(scr, NULL);
  192. lv_ex_line(line4, line_points[3]);
  193. buttonTurnPage = lv_btn_create(scr, NULL);
  194. lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_FEED_DOWN, NULL, 0);
  195. lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_REL, &style_para_back);
  196. lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_PR, &style_para_back);
  197. #if HAS_ROTARY_ENCODER
  198. if (gCfgItems.encoder_enable) {
  199. lv_group_add_obj(g, buttonXValue);
  200. lv_group_add_obj(g, buttonYValue);
  201. lv_group_add_obj(g, buttonZValue);
  202. lv_group_add_obj(g, buttonE0Value);
  203. lv_group_add_obj(g, buttonTurnPage);
  204. }
  205. #endif
  206. }
  207. else {
  208. labelE1Text = lv_label_create(scr, NULL);
  209. lv_obj_set_style(labelE1Text, &tft_style_label_rel);
  210. lv_obj_set_pos(labelE1Text, PARA_UI_POS_X, PARA_UI_POS_Y + 10);
  211. lv_label_set_text(labelE1Text, machine_menu.E1MaxFeedRate);
  212. buttonE1Value = lv_btn_create(scr, NULL);
  213. lv_obj_set_pos(buttonE1Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V);
  214. lv_obj_set_size(buttonE1Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
  215. lv_obj_set_event_cb_mks(buttonE1Value, event_handler, ID_FEED_E1, NULL, 0);
  216. lv_btn_set_style(buttonE1Value, LV_BTN_STYLE_REL, &style_para_value);
  217. lv_btn_set_style(buttonE1Value, LV_BTN_STYLE_PR, &style_para_value);
  218. lv_btn_set_layout(buttonE1Value, LV_LAYOUT_OFF);
  219. labelE1Value = lv_label_create(buttonE1Value, NULL);
  220. line1 = lv_line_create(scr, NULL);
  221. lv_ex_line(line1, line_points[0]);
  222. buttonTurnPage = lv_btn_create(scr, NULL);
  223. lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_FEED_UP, NULL, 0);
  224. lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_REL, &style_para_back);
  225. lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_PR, &style_para_back);
  226. #if HAS_ROTARY_ENCODER
  227. if (gCfgItems.encoder_enable) {
  228. lv_group_add_obj(g, buttonE1Value);
  229. lv_group_add_obj(g, buttonTurnPage);
  230. }
  231. #endif
  232. }
  233. lv_obj_set_pos(buttonTurnPage, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y);
  234. lv_obj_set_size(buttonTurnPage, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
  235. labelTurnPage = lv_label_create(buttonTurnPage, NULL);
  236. buttonBack = lv_btn_create(scr, NULL);
  237. lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_FEED_RETURN, NULL, 0);
  238. lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
  239. lv_obj_set_size(buttonBack, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
  240. lv_btn_set_style(buttonBack, LV_BTN_STYLE_REL, &style_para_back);
  241. lv_btn_set_style(buttonBack, LV_BTN_STYLE_PR, &style_para_back);
  242. label_Back = lv_label_create(buttonBack, NULL);
  243. #if HAS_ROTARY_ENCODER
  244. if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
  245. #endif
  246. if (gCfgItems.multiple_language) {
  247. if (uiCfg.para_ui_page != 1) {
  248. lv_label_set_text(labelTurnPage, machine_menu.next);
  249. lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
  250. ZERO(public_buf_l);
  251. sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[X_AXIS]);
  252. lv_label_set_text(labelXValue, public_buf_l);
  253. lv_obj_align(labelXValue, buttonXValue, LV_ALIGN_CENTER, 0, 0);
  254. ZERO(public_buf_l);
  255. sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[Y_AXIS]);
  256. lv_label_set_text(labelYValue, public_buf_l);
  257. lv_obj_align(labelYValue, buttonYValue, LV_ALIGN_CENTER, 0, 0);
  258. ZERO(public_buf_l);
  259. sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[Z_AXIS]);
  260. lv_label_set_text(labelZValue, public_buf_l);
  261. lv_obj_align(labelZValue, buttonZValue, LV_ALIGN_CENTER, 0, 0);
  262. ZERO(public_buf_l);
  263. sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[E_AXIS]);
  264. lv_label_set_text(labelE0Value, public_buf_l);
  265. lv_obj_align(labelE0Value, buttonE0Value, LV_ALIGN_CENTER, 0, 0);
  266. }
  267. else {
  268. lv_label_set_text(labelTurnPage, machine_menu.previous);
  269. lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
  270. ZERO(public_buf_l);
  271. sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[E_AXIS_N(1)]);
  272. lv_label_set_text(labelE1Value, public_buf_l);
  273. lv_obj_align(labelE1Value, buttonE1Value, LV_ALIGN_CENTER, 0, 0);
  274. }
  275. lv_label_set_text(label_Back, common_menu.text_back);
  276. lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
  277. }
  278. }
  279. void lv_clear_max_feedrate_settings() {
  280. #if HAS_ROTARY_ENCODER
  281. if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
  282. #endif
  283. lv_obj_del(scr);
  284. }
  285. #endif // HAS_TFT_LVGL_UI