My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

draw_advance_settings.cpp 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  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_ADVANCE_RETURN 1
  30. #define ID_PAUSE_POS 2
  31. #define ID_PAUSE_POS_ARROW 3
  32. #define ID_WIFI_PARA 4
  33. #define ID_WIFI_PARA_ARROW 5
  34. #define ID_FILAMENT_SETTINGS 6
  35. #define ID_FILAMENT_SETTINGS_ARROW 7
  36. #define ID_ENCODER_SETTINGS 8
  37. #define ID_ENCODER_SETTINGS_ARROW 9
  38. static void event_handler(lv_obj_t * obj, lv_event_t event) {
  39. switch (obj->mks_obj_id) {
  40. case ID_ADVANCE_RETURN:
  41. if (event == LV_EVENT_CLICKED) {
  42. }
  43. else if (event == LV_EVENT_RELEASED) {
  44. lv_clear_advance_settings();
  45. draw_return_ui();
  46. }
  47. break;
  48. case ID_PAUSE_POS:
  49. if (event == LV_EVENT_CLICKED) {
  50. }
  51. else if (event == LV_EVENT_RELEASED) {
  52. lv_clear_advance_settings();
  53. lv_draw_pause_position();
  54. }
  55. break;
  56. case ID_PAUSE_POS_ARROW:
  57. if (event == LV_EVENT_CLICKED) {
  58. }
  59. else if (event == LV_EVENT_RELEASED) {
  60. lv_clear_advance_settings();
  61. lv_draw_pause_position();
  62. }
  63. break;
  64. case ID_FILAMENT_SETTINGS:
  65. if (event == LV_EVENT_CLICKED) {
  66. }
  67. else if (event == LV_EVENT_RELEASED) {
  68. lv_clear_advance_settings();
  69. lv_draw_filament_settings();
  70. }
  71. break;
  72. case ID_FILAMENT_SETTINGS_ARROW:
  73. if (event == LV_EVENT_CLICKED) {
  74. }
  75. else if (event == LV_EVENT_RELEASED) {
  76. lv_clear_advance_settings();
  77. lv_draw_filament_settings();
  78. }
  79. break;
  80. #if ENABLED(USE_WIFI_FUNCTION)
  81. case ID_WIFI_PARA:
  82. if (event == LV_EVENT_CLICKED) {
  83. }
  84. else if (event == LV_EVENT_RELEASED) {
  85. lv_clear_advance_settings();
  86. lv_draw_wifi_settings();
  87. }
  88. break;
  89. case ID_WIFI_PARA_ARROW:
  90. if (event == LV_EVENT_CLICKED) {
  91. }
  92. else if (event == LV_EVENT_RELEASED) {
  93. lv_clear_advance_settings();
  94. lv_draw_wifi_settings();
  95. }
  96. break;
  97. #endif
  98. #if HAS_ROTARY_ENCODER
  99. case ID_ENCODER_SETTINGS:
  100. if (event == LV_EVENT_CLICKED) {
  101. }
  102. else if (event == LV_EVENT_RELEASED) {
  103. lv_clear_advance_settings();
  104. lv_draw_encoder_settings();
  105. }
  106. break;
  107. case ID_ENCODER_SETTINGS_ARROW:
  108. if (event == LV_EVENT_CLICKED) {
  109. }
  110. else if (event == LV_EVENT_RELEASED) {
  111. lv_clear_advance_settings();
  112. lv_draw_encoder_settings();
  113. }
  114. break;
  115. #endif
  116. }
  117. }
  118. void lv_draw_advance_settings(void) {
  119. lv_obj_t *buttonBack, *label_Back;
  120. lv_obj_t *buttonPausePos, *labelPausePos, *buttonPausePosNarrow;
  121. lv_obj_t *buttonFilamentSettings, *labelFilamentSettings, *buttonFilamentSettingsNarrow;
  122. lv_obj_t * line1,* line2;
  123. #if ENABLED(USE_WIFI_FUNCTION)
  124. lv_obj_t *buttonWifiSet,*labelWifiSet,*buttonWifiSetNarrow;
  125. #endif
  126. #if HAS_ROTARY_ENCODER
  127. lv_obj_t *buttonEcoder,*labelEcoder,*buttonEcoderNarrow;
  128. #endif
  129. if (disp_state_stack._disp_state[disp_state_stack._disp_index] != ADVANCED_UI) {
  130. disp_state_stack._disp_index++;
  131. disp_state_stack._disp_state[disp_state_stack._disp_index] = ADVANCED_UI;
  132. }
  133. disp_state = ADVANCED_UI;
  134. scr = lv_obj_create(NULL, NULL);
  135. lv_obj_set_style(scr, &tft_style_scr);
  136. lv_scr_load(scr);
  137. lv_obj_clean(scr);
  138. lv_obj_t * title = lv_label_create(scr, NULL);
  139. lv_obj_set_style(title, &tft_style_label_rel);
  140. lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS);
  141. lv_label_set_text(title, machine_menu.AdvancedConfTitle);
  142. lv_refr_now(lv_refr_get_disp_refreshing());
  143. buttonPausePos = lv_btn_create(scr, NULL);
  144. lv_obj_set_pos(buttonPausePos, PARA_UI_POS_X, PARA_UI_POS_Y);
  145. lv_obj_set_size(buttonPausePos, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);
  146. //lv_obj_set_event_cb(buttonMachine, event_handler);
  147. lv_obj_set_event_cb_mks(buttonPausePos, event_handler, ID_PAUSE_POS, NULL, 0);
  148. lv_btn_set_style(buttonPausePos, LV_BTN_STYLE_REL, &tft_style_label_rel);
  149. lv_btn_set_style(buttonPausePos, LV_BTN_STYLE_PR, &tft_style_label_pre);
  150. lv_btn_set_layout(buttonPausePos, LV_LAYOUT_OFF);
  151. labelPausePos = lv_label_create(buttonPausePos, NULL);
  152. #if HAS_ROTARY_ENCODER
  153. if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonPausePos);
  154. #endif
  155. buttonPausePosNarrow = lv_imgbtn_create(scr, NULL);
  156. lv_obj_set_pos(buttonPausePosNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y + PARA_UI_ARROW_V);
  157. lv_obj_set_event_cb_mks(buttonPausePosNarrow, event_handler, ID_PAUSE_POS_ARROW, NULL, 0);
  158. lv_imgbtn_set_src(buttonPausePosNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
  159. lv_imgbtn_set_src(buttonPausePosNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
  160. lv_imgbtn_set_style(buttonPausePosNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
  161. lv_imgbtn_set_style(buttonPausePosNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
  162. lv_btn_set_layout(buttonPausePosNarrow, LV_LAYOUT_OFF);
  163. line1 = lv_line_create(lv_scr_act(), NULL);
  164. lv_ex_line(line1, line_points[0]);
  165. buttonFilamentSettings = lv_btn_create(scr, NULL);
  166. lv_obj_set_pos(buttonFilamentSettings, PARA_UI_POS_X, PARA_UI_POS_Y*2);
  167. lv_obj_set_size(buttonFilamentSettings, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);
  168. lv_obj_set_event_cb_mks(buttonFilamentSettings, event_handler, ID_FILAMENT_SETTINGS, NULL, 0);
  169. lv_btn_set_style(buttonFilamentSettings, LV_BTN_STYLE_REL, &tft_style_label_rel);
  170. lv_btn_set_style(buttonFilamentSettings, LV_BTN_STYLE_PR, &tft_style_label_pre);
  171. lv_btn_set_layout(buttonFilamentSettings, LV_LAYOUT_OFF);
  172. labelFilamentSettings = lv_label_create(buttonFilamentSettings, NULL);
  173. #if HAS_ROTARY_ENCODER
  174. if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonFilamentSettings);
  175. #endif
  176. buttonFilamentSettingsNarrow = lv_imgbtn_create(scr, NULL);
  177. lv_obj_set_pos(buttonFilamentSettingsNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y*2 + PARA_UI_ARROW_V);
  178. lv_obj_set_event_cb_mks(buttonFilamentSettingsNarrow, event_handler, ID_FILAMENT_SETTINGS_ARROW, NULL, 0);
  179. lv_imgbtn_set_src(buttonFilamentSettingsNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
  180. lv_imgbtn_set_src(buttonFilamentSettingsNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
  181. lv_imgbtn_set_style(buttonFilamentSettingsNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
  182. lv_imgbtn_set_style(buttonFilamentSettingsNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
  183. lv_btn_set_layout(buttonFilamentSettingsNarrow, LV_LAYOUT_OFF);
  184. line2 = lv_line_create(lv_scr_act(), NULL);
  185. lv_ex_line(line2, line_points[1]);
  186. #if ENABLED(USE_WIFI_FUNCTION)
  187. buttonWifiSet = lv_btn_create(scr, NULL); /*Add a button the current screen*/
  188. lv_obj_set_pos(buttonWifiSet, PARA_UI_POS_X,PARA_UI_POS_Y*3);
  189. lv_obj_set_size(buttonWifiSet, PARA_UI_SIZE_X,PARA_UI_SIZE_Y);
  190. lv_obj_set_event_cb_mks(buttonWifiSet, event_handler,ID_WIFI_PARA,NULL,0);
  191. lv_btn_set_style(buttonWifiSet, LV_BTN_STYLE_REL, &tft_style_label_rel);
  192. lv_btn_set_style(buttonWifiSet, LV_BTN_STYLE_PR, &tft_style_label_pre);
  193. lv_btn_set_layout(buttonWifiSet, LV_LAYOUT_OFF);
  194. labelWifiSet = lv_label_create(buttonWifiSet, NULL);
  195. #if HAS_ROTARY_ENCODER
  196. if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonWifiSet);
  197. #endif
  198. buttonWifiSetNarrow = lv_imgbtn_create(scr, NULL);
  199. lv_obj_set_pos(buttonWifiSetNarrow,PARA_UI_POS_X+PARA_UI_SIZE_X,PARA_UI_POS_Y*3+PARA_UI_ARROW_V);
  200. lv_obj_set_event_cb_mks(buttonWifiSetNarrow, event_handler,ID_WIFI_PARA_ARROW, NULL,0);
  201. lv_imgbtn_set_src(buttonWifiSetNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
  202. lv_imgbtn_set_src(buttonWifiSetNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
  203. lv_imgbtn_set_style(buttonWifiSetNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
  204. lv_imgbtn_set_style(buttonWifiSetNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
  205. lv_btn_set_layout(buttonWifiSetNarrow, LV_LAYOUT_OFF);
  206. lv_obj_t * line3 = lv_line_create(scr, NULL);
  207. lv_ex_line(line3,line_points[2]);
  208. #if HAS_ROTARY_ENCODER
  209. buttonEcoder = lv_btn_create(scr, NULL); /*Add a button the current screen*/
  210. lv_obj_set_pos(buttonEcoder, PARA_UI_POS_X,PARA_UI_POS_Y*4);
  211. lv_obj_set_size(buttonEcoder, PARA_UI_SIZE_X,PARA_UI_SIZE_Y);
  212. lv_obj_set_event_cb_mks(buttonEcoder, event_handler,ID_ENCODER_SETTINGS,NULL,0);
  213. lv_btn_set_style(buttonEcoder, LV_BTN_STYLE_REL, &tft_style_label_rel);
  214. lv_btn_set_style(buttonEcoder, LV_BTN_STYLE_PR, &tft_style_label_pre);
  215. lv_btn_set_layout(buttonEcoder, LV_LAYOUT_OFF);
  216. labelEcoder = lv_label_create(buttonEcoder, NULL);
  217. if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonEcoder);
  218. buttonEcoderNarrow = lv_imgbtn_create(scr, NULL);
  219. lv_obj_set_pos(buttonEcoderNarrow,PARA_UI_POS_X+PARA_UI_SIZE_X,PARA_UI_POS_Y*4+PARA_UI_ARROW_V);
  220. lv_obj_set_event_cb_mks(buttonEcoderNarrow, event_handler,ID_ENCODER_SETTINGS_ARROW, NULL,0);
  221. lv_imgbtn_set_src(buttonEcoderNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
  222. lv_imgbtn_set_src(buttonEcoderNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
  223. lv_imgbtn_set_style(buttonEcoderNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
  224. lv_imgbtn_set_style(buttonEcoderNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
  225. lv_btn_set_layout(buttonEcoderNarrow, LV_LAYOUT_OFF);
  226. lv_obj_t * line4 = lv_line_create(scr, NULL);
  227. lv_ex_line(line4,line_points[3]);
  228. #endif
  229. #elif HAS_ROTARY_ENCODER
  230. buttonEcoder = lv_btn_create(scr, NULL); /*Add a button the current screen*/
  231. lv_obj_set_pos(buttonEcoder, PARA_UI_POS_X,PARA_UI_POS_Y*3);
  232. lv_obj_set_size(buttonEcoder, PARA_UI_SIZE_X,PARA_UI_SIZE_Y);
  233. lv_obj_set_event_cb_mks(buttonEcoder, event_handler,ID_ENCODER_SETTINGS,NULL,0);
  234. lv_btn_set_style(buttonEcoder, LV_BTN_STYLE_REL, &tft_style_label_rel);
  235. lv_btn_set_style(buttonEcoder, LV_BTN_STYLE_PR, &tft_style_label_pre);
  236. lv_btn_set_layout(buttonEcoder, LV_LAYOUT_OFF);
  237. labelEcoder = lv_label_create(buttonEcoder, NULL);
  238. if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonEcoder);
  239. buttonEcoderNarrow = lv_imgbtn_create(scr, NULL);
  240. lv_obj_set_pos(buttonEcoderNarrow,PARA_UI_POS_X+PARA_UI_SIZE_X,PARA_UI_POS_Y*3+PARA_UI_ARROW_V);
  241. lv_obj_set_event_cb_mks(buttonEcoderNarrow, event_handler,ID_ENCODER_SETTINGS_ARROW, NULL,0);
  242. lv_imgbtn_set_src(buttonEcoderNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
  243. lv_imgbtn_set_src(buttonEcoderNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
  244. lv_imgbtn_set_style(buttonEcoderNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
  245. lv_imgbtn_set_style(buttonEcoderNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
  246. lv_btn_set_layout(buttonEcoderNarrow, LV_LAYOUT_OFF);
  247. lv_obj_t * line3 = lv_line_create(scr, NULL);
  248. lv_ex_line(line3,line_points[2]);
  249. #endif
  250. buttonBack = lv_imgbtn_create(scr, NULL);
  251. lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_ADVANCE_RETURN, NULL, 0);
  252. lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin");
  253. lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin");
  254. lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
  255. lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
  256. #if HAS_ROTARY_ENCODER
  257. if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
  258. #endif
  259. lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
  260. lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
  261. label_Back = lv_label_create(buttonBack, NULL);
  262. if (gCfgItems.multiple_language) {
  263. lv_label_set_text(label_Back, common_menu.text_back);
  264. lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
  265. lv_label_set_text(labelPausePos, machine_menu.PausePosition);
  266. lv_obj_align(labelPausePos, buttonPausePos, LV_ALIGN_IN_LEFT_MID, 0, 0);
  267. lv_label_set_text(labelFilamentSettings, machine_menu.FilamentConf);
  268. lv_obj_align(labelFilamentSettings, buttonFilamentSettings, LV_ALIGN_IN_LEFT_MID, 0, 0);
  269. #if ENABLED(USE_WIFI_FUNCTION)
  270. lv_label_set_text(labelWifiSet, machine_menu.WifiSettings);
  271. lv_obj_align(labelWifiSet, buttonWifiSet, LV_ALIGN_IN_LEFT_MID,0, 0);
  272. #endif
  273. #if HAS_ROTARY_ENCODER
  274. lv_label_set_text(labelEcoder, machine_menu.EncoderSettings);
  275. lv_obj_align(labelEcoder, buttonEcoder, LV_ALIGN_IN_LEFT_MID,0, 0);
  276. #endif
  277. }
  278. }
  279. void lv_clear_advance_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