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_tmc_current_settings.cpp 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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 BOTH(HAS_TFT_LVGL_UI, HAS_TRINAMIC_CONFIG)
  24. #include "draw_ui.h"
  25. #include <lv_conf.h>
  26. #include "../../../module/stepper/indirection.h"
  27. #include "../../../feature/tmc_util.h"
  28. #include "../../../inc/MarlinConfig.h"
  29. extern lv_group_t *g;
  30. static lv_obj_t *scr;
  31. enum {
  32. ID_TMC_CURRENT_RETURN = 1,
  33. ID_TMC_CURRENT_X,
  34. ID_TMC_CURRENT_Y,
  35. ID_TMC_CURRENT_Z,
  36. ID_TMC_CURRENT_E0,
  37. ID_TMC_CURRENT_E1,
  38. ID_TMC_CURRENT_DOWN,
  39. ID_TMC_CURRENT_UP
  40. };
  41. static void event_handler(lv_obj_t *obj, lv_event_t event) {
  42. if (event != LV_EVENT_RELEASED) return;
  43. lv_clear_tmc_current_settings();
  44. switch (obj->mks_obj_id) {
  45. case ID_TMC_CURRENT_RETURN:
  46. uiCfg.para_ui_page = false;
  47. draw_return_ui();
  48. return;
  49. #if AXIS_IS_TMC(X)
  50. case ID_TMC_CURRENT_X: value = Xcurrent; break;
  51. #endif
  52. #if AXIS_IS_TMC(Y)
  53. case ID_TMC_CURRENT_Y: value = Ycurrent; break;
  54. #endif
  55. #if AXIS_IS_TMC(Z)
  56. case ID_TMC_CURRENT_Z: value = Zcurrent; break;
  57. #endif
  58. #if AXIS_IS_TMC(E0)
  59. case ID_TMC_CURRENT_E0: value = E0current; break;
  60. #endif
  61. #if AXIS_IS_TMC(E1)
  62. case ID_TMC_CURRENT_E1: value = E1current; break;
  63. #endif
  64. case ID_TMC_CURRENT_UP:
  65. uiCfg.para_ui_page = false;
  66. lv_draw_tmc_current_settings();
  67. return;
  68. case ID_TMC_CURRENT_DOWN:
  69. uiCfg.para_ui_page = true;
  70. lv_draw_tmc_current_settings();
  71. return;
  72. }
  73. lv_draw_number_key();
  74. }
  75. void lv_draw_tmc_current_settings() {
  76. scr = lv_screen_create(TMC_CURRENT_UI, machine_menu.TmcCurrentConfTitle);
  77. float milliamps;
  78. if (!uiCfg.para_ui_page) {
  79. #if AXIS_IS_TMC(X)
  80. milliamps = stepperX.getMilliamps();
  81. #else
  82. milliamps = -1;
  83. #endif
  84. dtostrf(milliamps, 1, 1, public_buf_l);
  85. lv_screen_menu_item_1_edit(scr, machine_menu.X_Current, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_TMC_CURRENT_X, 0, public_buf_l);
  86. #if AXIS_IS_TMC(Y)
  87. milliamps = stepperY.getMilliamps();
  88. #else
  89. milliamps = -1;
  90. #endif
  91. dtostrf(milliamps, 1, 1, public_buf_l);
  92. lv_screen_menu_item_1_edit(scr, machine_menu.Y_Current, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_TMC_CURRENT_Y, 1, public_buf_l);
  93. #if AXIS_IS_TMC(Z)
  94. milliamps = stepperZ.getMilliamps();
  95. #else
  96. milliamps = -1;
  97. #endif
  98. dtostrf(milliamps, 1, 1, public_buf_l);
  99. lv_screen_menu_item_1_edit(scr, machine_menu.Z_Current, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_TMC_CURRENT_Z, 2, public_buf_l);
  100. #if AXIS_IS_TMC(E0)
  101. milliamps = stepperE0.getMilliamps();
  102. #else
  103. milliamps = -1;
  104. #endif
  105. dtostrf(milliamps, 1, 1, public_buf_l);
  106. lv_screen_menu_item_1_edit(scr, machine_menu.E0_Current, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_TMC_CURRENT_E0, 3, public_buf_l);
  107. lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.next, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_TMC_CURRENT_DOWN, true);
  108. }
  109. else {
  110. #if AXIS_IS_TMC(E1)
  111. milliamps = stepperE1.getMilliamps();
  112. #else
  113. milliamps = -1;
  114. #endif
  115. dtostrf(milliamps, 1, 1, public_buf_l);
  116. lv_screen_menu_item_1_edit(scr, machine_menu.E1_Current, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_TMC_CURRENT_E1, 0, public_buf_l);
  117. lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.previous, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_TMC_CURRENT_UP, true);
  118. }
  119. lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACK_POS_X, PARA_UI_BACK_POS_Y, event_handler, ID_TMC_CURRENT_RETURN, true);
  120. }
  121. void lv_clear_tmc_current_settings() {
  122. #if HAS_ROTARY_ENCODER
  123. if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
  124. #endif
  125. lv_obj_del(scr);
  126. }
  127. #endif // HAS_TFT_LVGL_UI && HAS_TRINAMIC_CONFIG