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_eeprom_settings.cpp 8.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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_EEPROM_RETURN 1
  30. #define ID_EEPROM_STORE 2
  31. #define ID_EEPROM_STORE_ARROW 3
  32. #define ID_EEPROM_READ 4
  33. #define ID_EEPROM_READ_ARROW 5
  34. #define ID_EEPROM_REVERT 6
  35. #define ID_EEPROM_REVERT_ARROW 7
  36. static void event_handler(lv_obj_t * obj, lv_event_t event) {
  37. switch (obj->mks_obj_id) {
  38. case ID_EEPROM_RETURN:
  39. if (event == LV_EVENT_CLICKED) {
  40. }
  41. else if (event == LV_EVENT_RELEASED) {
  42. lv_clear_eeprom_settings();
  43. draw_return_ui();
  44. }
  45. break;
  46. case ID_EEPROM_STORE:
  47. if (event == LV_EVENT_CLICKED) {
  48. }
  49. else if (event == LV_EVENT_RELEASED) {
  50. lv_clear_eeprom_settings();
  51. lv_draw_dialog(DIALOG_STORE_EEPROM_TIPS);
  52. }
  53. break;
  54. case ID_EEPROM_STORE_ARROW:
  55. if (event == LV_EVENT_CLICKED) {
  56. }
  57. else if (event == LV_EVENT_RELEASED) {
  58. lv_clear_eeprom_settings();
  59. lv_draw_dialog(DIALOG_STORE_EEPROM_TIPS);
  60. }
  61. break;
  62. #if 0
  63. case ID_EEPROM_READ:
  64. if (event == LV_EVENT_CLICKED) {
  65. }
  66. else if (event == LV_EVENT_RELEASED) {
  67. lv_clear_eeprom_settings();
  68. lv_draw_dialog(DIALOG_READ_EEPROM_TIPS);
  69. }
  70. break;
  71. case ID_EEPROM_READ_ARROW:
  72. if (event == LV_EVENT_CLICKED) {
  73. }
  74. else if (event == LV_EVENT_RELEASED) {
  75. lv_clear_eeprom_settings();
  76. lv_draw_dialog(DIALOG_READ_EEPROM_TIPS);
  77. }
  78. break;
  79. #endif
  80. case ID_EEPROM_REVERT:
  81. if (event == LV_EVENT_CLICKED) {
  82. }
  83. else if (event == LV_EVENT_RELEASED) {
  84. lv_clear_eeprom_settings();
  85. lv_draw_dialog(DIALOG_REVERT_EEPROM_TIPS);
  86. }
  87. break;
  88. case ID_EEPROM_REVERT_ARROW:
  89. if (event == LV_EVENT_CLICKED) {
  90. }
  91. else if (event == LV_EVENT_RELEASED) {
  92. lv_clear_eeprom_settings();
  93. lv_draw_dialog(DIALOG_REVERT_EEPROM_TIPS);
  94. }
  95. break;
  96. }
  97. }
  98. void lv_draw_eeprom_settings(void) {
  99. lv_obj_t *buttonBack, *label_Back;
  100. lv_obj_t *buttonStore,*labelStore,*buttonStoreNarrow;
  101. //lv_obj_t *buttonRead,*labelRead,*buttonReadNarrow;
  102. lv_obj_t *buttonRevert, *labelRevert, *buttonRevertNarrow;
  103. lv_obj_t * line1, * line2; //* line3;
  104. if (disp_state_stack._disp_state[disp_state_stack._disp_index] != EEPROM_SETTINGS_UI) {
  105. disp_state_stack._disp_index++;
  106. disp_state_stack._disp_state[disp_state_stack._disp_index] = EEPROM_SETTINGS_UI;
  107. }
  108. disp_state = EEPROM_SETTINGS_UI;
  109. scr = lv_obj_create(NULL, NULL);
  110. lv_obj_set_style(scr, &tft_style_scr);
  111. lv_scr_load(scr);
  112. lv_obj_clean(scr);
  113. lv_obj_t * title = lv_label_create(scr, NULL);
  114. lv_obj_set_style(title, &tft_style_label_rel);
  115. lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS);
  116. lv_label_set_text(title, creat_title_text());
  117. lv_refr_now(lv_refr_get_disp_refreshing());
  118. buttonRevert = lv_btn_create(scr, NULL); /*Add a button the current screen*/
  119. lv_obj_set_pos(buttonRevert, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/
  120. lv_obj_set_size(buttonRevert, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
  121. //lv_obj_set_event_cb(buttonMotor, event_handler);
  122. lv_obj_set_event_cb_mks(buttonRevert, event_handler, ID_EEPROM_REVERT, NULL, 0);
  123. lv_btn_set_style(buttonRevert, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
  124. lv_btn_set_style(buttonRevert, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
  125. lv_btn_set_layout(buttonRevert, LV_LAYOUT_OFF);
  126. labelRevert = lv_label_create(buttonRevert, NULL); /*Add a label to the button*/
  127. buttonRevertNarrow = lv_imgbtn_create(scr, NULL);
  128. lv_obj_set_pos(buttonRevertNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y + PARA_UI_ARROW_V);
  129. lv_obj_set_event_cb_mks(buttonRevertNarrow, event_handler, ID_EEPROM_REVERT_ARROW, NULL, 0);
  130. lv_imgbtn_set_src(buttonRevertNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
  131. lv_imgbtn_set_src(buttonRevertNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
  132. lv_imgbtn_set_style(buttonRevertNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
  133. lv_imgbtn_set_style(buttonRevertNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
  134. lv_btn_set_layout(buttonRevertNarrow, LV_LAYOUT_OFF);
  135. //line3 = lv_line_create(scr, NULL);
  136. //lv_ex_line(line3,line_points[2]);
  137. line1 = lv_line_create(scr, NULL);
  138. lv_ex_line(line1, line_points[0]);
  139. buttonStore = lv_btn_create(scr, NULL); /*Add a button the current screen*/
  140. lv_obj_set_pos(buttonStore, PARA_UI_POS_X, PARA_UI_POS_Y * 2); /*Set its position*/
  141. lv_obj_set_size(buttonStore, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
  142. //lv_obj_set_event_cb(buttonMotor, event_handler);
  143. lv_obj_set_event_cb_mks(buttonStore, event_handler, ID_EEPROM_STORE, NULL, 0);
  144. lv_btn_set_style(buttonStore, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
  145. lv_btn_set_style(buttonStore, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
  146. lv_btn_set_layout(buttonStore, LV_LAYOUT_OFF);
  147. labelStore = lv_label_create(buttonStore, NULL); /*Add a label to the button*/
  148. buttonStoreNarrow = lv_imgbtn_create(scr, NULL);
  149. lv_obj_set_pos(buttonStoreNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 2 + PARA_UI_ARROW_V);
  150. lv_obj_set_event_cb_mks(buttonStoreNarrow, event_handler, ID_EEPROM_STORE_ARROW, NULL, 0);
  151. lv_imgbtn_set_src(buttonStoreNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
  152. lv_imgbtn_set_src(buttonStoreNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
  153. lv_imgbtn_set_style(buttonStoreNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
  154. lv_imgbtn_set_style(buttonStoreNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
  155. lv_btn_set_layout(buttonStoreNarrow, LV_LAYOUT_OFF);
  156. line2 = lv_line_create(scr, NULL);
  157. lv_ex_line(line2, line_points[1]);
  158. buttonBack = lv_imgbtn_create(scr, NULL);
  159. lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_EEPROM_RETURN, NULL, 0);
  160. lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin");
  161. lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin");
  162. lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
  163. lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
  164. lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
  165. lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
  166. label_Back = lv_label_create(buttonBack, NULL);
  167. if (gCfgItems.multiple_language) {
  168. lv_label_set_text(label_Back, common_menu.text_back);
  169. lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
  170. lv_label_set_text(labelStore, eeprom_menu.store);
  171. lv_obj_align(labelStore, buttonStore, LV_ALIGN_IN_LEFT_MID,0, 0);
  172. //lv_label_set_text(labelRead, eeprom_menu.read);
  173. //lv_obj_align(labelRead, buttonRead, LV_ALIGN_IN_LEFT_MID,0, 0);
  174. lv_label_set_text(labelRevert, eeprom_menu.revert);
  175. lv_obj_align(labelRevert, buttonRevert, LV_ALIGN_IN_LEFT_MID, 0, 0);
  176. }
  177. #if HAS_ROTARY_ENCODER
  178. if (gCfgItems.encoder_enable) {
  179. lv_group_add_obj(g, buttonRevert);
  180. lv_group_add_obj(g, buttonStore);
  181. lv_group_add_obj(g, buttonBack);
  182. }
  183. #endif
  184. }
  185. void lv_clear_eeprom_settings() {
  186. #if HAS_ROTARY_ENCODER
  187. if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
  188. #endif
  189. lv_obj_del(scr);
  190. }
  191. #endif // HAS_TFT_LVGL_UI