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_set.cpp 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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_ready_print.h"
  25. #include "draw_set.h"
  26. #include "draw_ui.h"
  27. #include <lv_conf.h>
  28. #include "pic_manager.h"
  29. #include "../../../gcode/queue.h"
  30. #include "../../../inc/MarlinConfig.h"
  31. #if HAS_SUICIDE
  32. #include "../../../MarlinCore.h"
  33. #endif
  34. static lv_obj_t *scr;
  35. extern lv_group_t* g;
  36. enum {
  37. ID_S_WIFI = 1,
  38. ID_S_FAN,
  39. ID_S_ABOUT,
  40. ID_S_CONTINUE,
  41. ID_S_MOTOR_OFF,
  42. ID_S_LANGUAGE,
  43. ID_S_MACHINE_PARA,
  44. ID_S_EEPROM_SET,
  45. ID_S_RETURN
  46. };
  47. static void event_handler(lv_obj_t *obj, lv_event_t event) {
  48. if (event != LV_EVENT_RELEASED) return;
  49. if (obj->mks_obj_id == ID_S_CONTINUE) return;
  50. if (obj->mks_obj_id == ID_S_MOTOR_OFF) {
  51. TERN(HAS_SUICIDE, suicide(), queue.enqueue_now(F("M84")));
  52. return;
  53. }
  54. lv_clear_set();
  55. switch (obj->mks_obj_id) {
  56. case ID_S_FAN:
  57. lv_draw_fan();
  58. break;
  59. case ID_S_ABOUT:
  60. lv_draw_about();
  61. break;
  62. case ID_S_LANGUAGE:
  63. lv_draw_language();
  64. break;
  65. case ID_S_MACHINE_PARA:
  66. lv_draw_machine_para();
  67. break;
  68. case ID_S_EEPROM_SET:
  69. lv_draw_eeprom_settings();
  70. break;
  71. case ID_S_RETURN:
  72. lv_draw_ready_print();
  73. break;
  74. #if ENABLED(MKS_WIFI_MODULE)
  75. case ID_S_WIFI:
  76. if (gCfgItems.wifi_mode_sel == STA_MODEL) {
  77. if (wifi_link_state == WIFI_CONNECTED) {
  78. last_disp_state = SET_UI;
  79. lv_draw_wifi();
  80. }
  81. else {
  82. if (uiCfg.command_send) {
  83. uint8_t cmd_wifi_list[] = { 0xA5, 0x07, 0x00, 0x00, 0xFC };
  84. raw_send_to_wifi(cmd_wifi_list, COUNT(cmd_wifi_list));
  85. last_disp_state = SET_UI;
  86. lv_draw_wifi_list();
  87. }
  88. else {
  89. last_disp_state = SET_UI;
  90. lv_draw_dialog(DIALOG_WIFI_ENABLE_TIPS);
  91. }
  92. }
  93. }
  94. else {
  95. last_disp_state = SET_UI;
  96. lv_draw_wifi();
  97. }
  98. break;
  99. #endif
  100. }
  101. }
  102. void lv_draw_set() {
  103. scr = lv_screen_create(SET_UI);
  104. lv_big_button_create(scr, "F:/bmp_eeprom_settings.bin", set_menu.eepromSet, INTERVAL_V, titleHeight, event_handler, ID_S_EEPROM_SET);
  105. lv_big_button_create(scr, "F:/bmp_fan.bin", set_menu.fan, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_S_FAN);
  106. lv_big_button_create(scr, "F:/bmp_about.bin", set_menu.about, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_S_ABOUT);
  107. lv_big_button_create(scr, ENABLED(HAS_SUICIDE) ? "F:/bmp_manual_off.bin" : "F:/bmp_function1.bin", set_menu.TERN(HAS_SUICIDE, shutdown, motoroff), BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_S_MOTOR_OFF);
  108. lv_big_button_create(scr, "F:/bmp_machine_para.bin", set_menu.machine_para, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_S_MACHINE_PARA);
  109. #if HAS_LANG_SELECT_SCREEN
  110. lv_big_button_create(scr, "F:/bmp_language.bin", set_menu.language, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_S_LANGUAGE);
  111. #endif
  112. #if ENABLED(MKS_WIFI_MODULE)
  113. lv_big_button_create(scr, "F:/bmp_wifi.bin", set_menu.wifi, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_S_WIFI);
  114. #endif
  115. lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_S_RETURN);
  116. }
  117. void lv_clear_set() {
  118. #if HAS_ROTARY_ENCODER
  119. if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
  120. #endif
  121. lv_obj_del(scr);
  122. }
  123. #endif // HAS_TFT_LVGL_UI