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.

ui_1024x600.cpp 32KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927
  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_UI_1024x600
  24. #include "ui_common.h"
  25. #include "../marlinui.h"
  26. #include "../menu/menu.h"
  27. #include "../../libs/numtostr.h"
  28. #include "../../sd/cardreader.h"
  29. #include "../../module/temperature.h"
  30. #include "../../module/printcounter.h"
  31. #include "../../module/planner.h"
  32. #include "../../module/motion.h"
  33. #if DISABLED(LCD_PROGRESS_BAR) && BOTH(FILAMENT_LCD_DISPLAY, SDSUPPORT)
  34. #include "../../feature/filwidth.h"
  35. #include "../../gcode/parser.h"
  36. #endif
  37. #if ENABLED(AUTO_BED_LEVELING_UBL)
  38. #include "../../feature/bedlevel/bedlevel.h"
  39. #endif
  40. void MarlinUI::tft_idle() {
  41. #if ENABLED(TOUCH_SCREEN)
  42. if (draw_menu_navigation) {
  43. add_control(104, TFT_HEIGHT - 34, PAGE_UP, imgPageUp, encoderTopLine > 0);
  44. add_control(344, TFT_HEIGHT - 34, PAGE_DOWN, imgPageDown, encoderTopLine + LCD_HEIGHT < screen_items);
  45. add_control(224, TFT_HEIGHT - 34, BACK, imgBack);
  46. draw_menu_navigation = false;
  47. }
  48. #endif
  49. tft.queue.async();
  50. TERN_(TOUCH_SCREEN, touch.idle());
  51. }
  52. #if ENABLED(SHOW_BOOTSCREEN)
  53. void MarlinUI::show_bootscreen() {
  54. tft.queue.reset();
  55. tft.canvas(0, 0, TFT_WIDTH, TFT_HEIGHT);
  56. #if ENABLED(BOOT_MARLIN_LOGO_SMALL)
  57. #define BOOT_LOGO_W 195 // MarlinLogo195x59x16
  58. #define BOOT_LOGO_H 59
  59. #define SITE_URL_Y (TFT_HEIGHT - 70)
  60. tft.set_background(COLOR_BACKGROUND);
  61. #else
  62. #define BOOT_LOGO_W TFT_WIDTH // MarlinLogo480x320x16
  63. #define BOOT_LOGO_H TFT_HEIGHT
  64. #define SITE_URL_Y (TFT_HEIGHT - 90)
  65. #endif
  66. tft.add_image((TFT_WIDTH - BOOT_LOGO_W) / 2, (TFT_HEIGHT - BOOT_LOGO_H) / 2, imgBootScreen);
  67. #ifdef WEBSITE_URL
  68. tft_string.set(WEBSITE_URL);
  69. tft.add_text(tft_string.center(TFT_WIDTH), SITE_URL_Y, COLOR_WEBSITE_URL, tft_string);
  70. #endif
  71. tft.queue.sync();
  72. safe_delay(BOOTSCREEN_TIMEOUT);
  73. clear_lcd();
  74. }
  75. #endif
  76. void MarlinUI::draw_kill_screen() {
  77. tft.queue.reset();
  78. tft.fill(0, 0, TFT_WIDTH, TFT_HEIGHT, COLOR_KILL_SCREEN_BG);
  79. uint16_t line = 2;
  80. menu_line(line++, COLOR_KILL_SCREEN_BG);
  81. tft_string.set(status_message);
  82. tft_string.trim();
  83. tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_MENU_TEXT, tft_string);
  84. line++;
  85. menu_line(line++, COLOR_KILL_SCREEN_BG);
  86. tft_string.set(GET_TEXT(MSG_HALTED));
  87. tft_string.trim();
  88. tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_MENU_TEXT, tft_string);
  89. menu_line(line++, COLOR_KILL_SCREEN_BG);
  90. tft_string.set(GET_TEXT(MSG_PLEASE_RESET));
  91. tft_string.trim();
  92. tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_MENU_TEXT, tft_string);
  93. tft.queue.sync();
  94. }
  95. void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater) {
  96. MarlinImage image = imgHotEnd;
  97. uint16_t Color;
  98. celsius_t currentTemperature, targetTemperature;
  99. if (Heater >= 0) { // HotEnd
  100. currentTemperature = thermalManager.degHotend(Heater);
  101. targetTemperature = thermalManager.degTargetHotend(Heater);
  102. }
  103. #if HAS_HEATED_BED
  104. else if (Heater == H_BED) {
  105. currentTemperature = thermalManager.degBed();
  106. targetTemperature = thermalManager.degTargetBed();
  107. }
  108. #endif
  109. #if HAS_TEMP_CHAMBER
  110. else if (Heater == H_CHAMBER) {
  111. currentTemperature = thermalManager.degChamber();
  112. #if HAS_HEATED_CHAMBER
  113. targetTemperature = thermalManager.degTargetChamber();
  114. #else
  115. targetTemperature = ABSOLUTE_ZERO;
  116. #endif
  117. }
  118. #endif
  119. #if HAS_TEMP_COOLER
  120. else if (Heater == H_COOLER) {
  121. currentTemperature = thermalManager.degCooler();
  122. targetTemperature = TERN(HAS_COOLER, thermalManager.degTargetCooler(), ABSOLUTE_ZERO);
  123. }
  124. #endif
  125. else return;
  126. TERN_(TOUCH_SCREEN, if (targetTemperature >= 0) touch.add_control(HEATER, x, y, 80, 120, Heater));
  127. tft.canvas(x, y, 80, 120);
  128. tft.set_background(COLOR_BACKGROUND);
  129. Color = currentTemperature < 0 ? COLOR_INACTIVE : COLOR_COLD;
  130. if (Heater >= 0) { // HotEnd
  131. if (currentTemperature >= 50) Color = COLOR_HOTEND;
  132. }
  133. #if HAS_HEATED_BED
  134. else if (Heater == H_BED) {
  135. if (currentTemperature >= 50) Color = COLOR_HEATED_BED;
  136. image = targetTemperature > 0 ? imgBedHeated : imgBed;
  137. }
  138. #endif
  139. #if HAS_TEMP_CHAMBER
  140. else if (Heater == H_CHAMBER) {
  141. if (currentTemperature >= 50) Color = COLOR_CHAMBER;
  142. image = targetTemperature > 0 ? imgChamberHeated : imgChamber;
  143. }
  144. #endif
  145. tft.add_image(8, 28, image, Color);
  146. tft_string.set((uint8_t *)i16tostr3rj(currentTemperature));
  147. tft_string.add(LCD_STR_DEGREE);
  148. tft_string.trim();
  149. tft.add_text(tft_string.center(80) + 2, 82, Color, tft_string);
  150. if (targetTemperature >= 0) {
  151. tft_string.set((uint8_t *)i16tostr3rj(targetTemperature));
  152. tft_string.add(LCD_STR_DEGREE);
  153. tft_string.trim();
  154. tft.add_text(tft_string.center(80) + 2, 8, Color, tft_string);
  155. }
  156. }
  157. void draw_fan_status(uint16_t x, uint16_t y, const bool blink) {
  158. TERN_(TOUCH_SCREEN, touch.add_control(FAN, x, y, 80, 120));
  159. tft.canvas(x, y, 80, 120);
  160. tft.set_background(COLOR_BACKGROUND);
  161. uint8_t fanSpeed = thermalManager.fan_speed[0];
  162. MarlinImage image;
  163. if (fanSpeed >= 127)
  164. image = blink ? imgFanFast1 : imgFanFast0;
  165. else if (fanSpeed > 0)
  166. image = blink ? imgFanSlow1 : imgFanSlow0;
  167. else
  168. image = imgFanIdle;
  169. tft.add_image(8, 20, image, COLOR_FAN);
  170. tft_string.set((uint8_t *)ui8tostr4pctrj(thermalManager.fan_speed[0]));
  171. tft_string.trim();
  172. tft.add_text(tft_string.center(80) + 6, 82, COLOR_FAN, tft_string);
  173. }
  174. void MarlinUI::draw_status_screen() {
  175. const bool blink = get_blink();
  176. TERN_(TOUCH_SCREEN, touch.clear());
  177. // heaters and fan
  178. uint16_t i, x, y = TFT_STATUS_TOP_Y;
  179. for (i = 0 ; i < ITEMS_COUNT; i++) {
  180. x = (TFT_WIDTH / ITEMS_COUNT - 80) / 2 + (TFT_WIDTH * i / ITEMS_COUNT);
  181. switch (i) {
  182. #ifdef ITEM_E0
  183. case ITEM_E0: draw_heater_status(x, y, H_E0); break;
  184. #endif
  185. #ifdef ITEM_E1
  186. case ITEM_E1: draw_heater_status(x, y, H_E1); break;
  187. #endif
  188. #ifdef ITEM_E2
  189. case ITEM_E2: draw_heater_status(x, y, H_E2); break;
  190. #endif
  191. #ifdef ITEM_BED
  192. case ITEM_BED: draw_heater_status(x, y, H_BED); break;
  193. #endif
  194. #ifdef ITEM_CHAMBER
  195. case ITEM_CHAMBER: draw_heater_status(x, y, H_CHAMBER); break;
  196. #endif
  197. #ifdef ITEM_FAN
  198. case ITEM_FAN: draw_fan_status(x, y, blink); break;
  199. #endif
  200. }
  201. }
  202. y += 200;
  203. // coordinates
  204. tft.canvas(4, y, TFT_WIDTH - 8, FONT_LINE_HEIGHT);
  205. tft.set_background(COLOR_BACKGROUND);
  206. tft.add_rectangle(0, 0, TFT_WIDTH - 8, FONT_LINE_HEIGHT, COLOR_AXIS_HOMED);
  207. tft.add_text(200, 3, COLOR_AXIS_HOMED , "X");
  208. tft.add_text(500, 3, COLOR_AXIS_HOMED , "Y");
  209. tft.add_text(800, 3, COLOR_AXIS_HOMED , "Z");
  210. bool not_homed = axis_should_home(X_AXIS);
  211. tft_string.set(blink && not_homed ? "?" : ftostr4sign(LOGICAL_X_POSITION(current_position.x)));
  212. tft.add_text(300 - tft_string.width(), 3, not_homed ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string);
  213. not_homed = axis_should_home(Y_AXIS);
  214. tft_string.set(blink && not_homed ? "?" : ftostr4sign(LOGICAL_Y_POSITION(current_position.y)));
  215. tft.add_text(600 - tft_string.width(), 3, not_homed ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string);
  216. uint16_t offset = 32;
  217. not_homed = axis_should_home(Z_AXIS);
  218. if (blink && not_homed)
  219. tft_string.set("?");
  220. else {
  221. const float z = LOGICAL_Z_POSITION(current_position.z);
  222. tft_string.set(ftostr52sp((int16_t)z));
  223. tft_string.rtrim();
  224. offset += tft_string.width();
  225. tft_string.set(ftostr52sp(z));
  226. offset -= tft_string.width();
  227. }
  228. tft.add_text(900 - tft_string.width() - offset, 3, not_homed ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string);
  229. TERN_(TOUCH_SCREEN, touch.add_control(MOVE_AXIS, 4, y, TFT_WIDTH - 8, FONT_LINE_HEIGHT));
  230. y += 100;
  231. // feed rate
  232. tft.canvas(274, y, 100, 32);
  233. tft.set_background(COLOR_BACKGROUND);
  234. uint16_t color = feedrate_percentage == 100 ? COLOR_RATE_100 : COLOR_RATE_ALTERED;
  235. tft.add_image(0, 0, imgFeedRate, color);
  236. tft_string.set(i16tostr3rj(feedrate_percentage));
  237. tft_string.add('%');
  238. tft.add_text(36, 1, color , tft_string);
  239. TERN_(TOUCH_SCREEN, touch.add_control(FEEDRATE, 96, 176, 100, 32));
  240. // flow rate
  241. tft.canvas(650, y, 100, 32);
  242. tft.set_background(COLOR_BACKGROUND);
  243. color = planner.flow_percentage[0] == 100 ? COLOR_RATE_100 : COLOR_RATE_ALTERED;
  244. tft.add_image(0, 0, imgFlowRate, color);
  245. tft_string.set(i16tostr3rj(planner.flow_percentage[active_extruder]));
  246. tft_string.add('%');
  247. tft.add_text(36, 1, color , tft_string);
  248. TERN_(TOUCH_SCREEN, touch.add_control(FLOWRATE, 284, 176, 100, 32, active_extruder));
  249. #if ENABLED(TOUCH_SCREEN)
  250. add_control(404, y, menu_main, imgSettings);
  251. TERN_(SDSUPPORT, add_control(12, y, menu_media, imgSD, !printingIsActive(), COLOR_CONTROL_ENABLED, card.isMounted() && printingIsActive() ? COLOR_BUSY : COLOR_CONTROL_DISABLED));
  252. #endif
  253. y += 100;
  254. // print duration
  255. char buffer[14];
  256. duration_t elapsed = print_job_timer.duration();
  257. elapsed.toDigital(buffer);
  258. tft.canvas((TFT_WIDTH - 128) / 2, y, 128, 29);
  259. tft.set_background(COLOR_BACKGROUND);
  260. tft_string.set(buffer);
  261. tft.add_text(tft_string.center(128), 0, COLOR_PRINT_TIME, tft_string);
  262. y += 50;
  263. // progress bar
  264. const uint8_t progress = ui.get_progress_percent();
  265. tft.canvas(4, y, TFT_WIDTH - 8, 9);
  266. tft.set_background(COLOR_PROGRESS_BG);
  267. tft.add_rectangle(0, 0, TFT_WIDTH - 8, 9, COLOR_PROGRESS_FRAME);
  268. if (progress)
  269. tft.add_bar(1, 1, ((TFT_WIDTH - 10) * progress) / 100, 7, COLOR_PROGRESS_BAR);
  270. y += 50;
  271. // status message
  272. tft.canvas(0, y, TFT_WIDTH, FONT_LINE_HEIGHT - 5);
  273. tft.set_background(COLOR_BACKGROUND);
  274. tft_string.set(status_message);
  275. tft_string.trim();
  276. tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_STATUS_MESSAGE, tft_string);
  277. }
  278. // Low-level draw_edit_screen can be used to draw an edit screen from anyplace
  279. void MenuEditItemBase::draw_edit_screen(PGM_P const pstr, const char * const value/*=nullptr*/) {
  280. ui.encoder_direction_normal();
  281. TERN_(TOUCH_SCREEN, touch.clear());
  282. uint16_t line = 1;
  283. menu_line(line++);
  284. tft_string.set(pstr, itemIndex, itemString);
  285. tft_string.trim();
  286. tft.add_text(tft_string.center(TFT_WIDTH), MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
  287. TERN_(AUTO_BED_LEVELING_UBL, if (ui.external_control) line++); // ftostr52() will overwrite *value so *value has to be displayed first
  288. menu_line(line);
  289. tft_string.set(value);
  290. tft_string.trim();
  291. tft.add_text(tft_string.center(TFT_WIDTH), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
  292. #if ENABLED(AUTO_BED_LEVELING_UBL)
  293. if (ui.external_control) {
  294. menu_line(line - 1);
  295. tft_string.set(X_LBL);
  296. tft.add_text((TFT_WIDTH / 2 - 120), MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
  297. tft_string.set(ftostr52(LOGICAL_X_POSITION(current_position.x)));
  298. tft_string.trim();
  299. tft.add_text((TFT_WIDTH / 2 - 16) - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
  300. tft_string.set(Y_LBL);
  301. tft.add_text((TFT_WIDTH / 2 + 16), MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
  302. tft_string.set(ftostr52(LOGICAL_X_POSITION(current_position.y)));
  303. tft_string.trim();
  304. tft.add_text((TFT_WIDTH / 2 + 120) - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
  305. }
  306. #endif
  307. extern screenFunc_t _manual_move_func_ptr;
  308. if (ui.currentScreen != _manual_move_func_ptr && !ui.external_control) {
  309. #define SLIDER_LENGTH 336
  310. #define SLIDER_Y_POSITION 186
  311. tft.canvas((TFT_WIDTH - SLIDER_LENGTH) / 2, SLIDER_Y_POSITION, SLIDER_LENGTH, 16);
  312. tft.set_background(COLOR_BACKGROUND);
  313. int16_t position = (SLIDER_LENGTH - 2) * ui.encoderPosition / maxEditValue;
  314. tft.add_bar(0, 7, 1, 2, ui.encoderPosition == 0 ? COLOR_SLIDER_INACTIVE : COLOR_SLIDER);
  315. tft.add_bar(1, 6, position, 4, COLOR_SLIDER);
  316. tft.add_bar(position + 1, 6, SLIDER_LENGTH - 2 - position, 4, COLOR_SLIDER_INACTIVE);
  317. tft.add_bar(SLIDER_LENGTH - 1, 7, 1, 2, int32_t(ui.encoderPosition) == maxEditValue ? COLOR_SLIDER : COLOR_SLIDER_INACTIVE);
  318. #if ENABLED(TOUCH_SCREEN)
  319. tft.add_image((SLIDER_LENGTH - 8) * ui.encoderPosition / maxEditValue, 0, imgSlider, COLOR_SLIDER);
  320. touch.add_control(SLIDER, (TFT_WIDTH - SLIDER_LENGTH) / 2, SLIDER_Y_POSITION - 8, SLIDER_LENGTH, 32, maxEditValue);
  321. #endif
  322. }
  323. tft.draw_edit_screen_buttons();
  324. }
  325. void TFT::draw_edit_screen_buttons() {
  326. #if ENABLED(TOUCH_SCREEN)
  327. add_control(64, TFT_HEIGHT - 64, DECREASE, imgDecrease);
  328. add_control(352, TFT_HEIGHT - 64, INCREASE, imgIncrease);
  329. add_control(208, TFT_HEIGHT - 64, CLICK, imgConfirm);
  330. #endif
  331. }
  332. // The Select Screen presents a prompt and two "buttons"
  333. void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const bool yesno, PGM_P const pref, const char * const string/*=nullptr*/, PGM_P const suff/*=nullptr*/) {
  334. uint16_t line = 1;
  335. if (!string) line++;
  336. menu_line(line++);
  337. tft_string.set(pref);
  338. tft_string.trim();
  339. tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_MENU_TEXT, tft_string);
  340. if (string) {
  341. menu_line(line++);
  342. tft_string.set(string);
  343. tft_string.trim();
  344. tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_MENU_TEXT, tft_string);
  345. }
  346. if (suff) {
  347. menu_line(line);
  348. tft_string.set(suff);
  349. tft_string.trim();
  350. tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_MENU_TEXT, tft_string);
  351. }
  352. #if ENABLED(TOUCH_SCREEN)
  353. add_control(88, TFT_HEIGHT - 64, CANCEL, imgCancel, true, yesno ? HALF(COLOR_CONTROL_CANCEL) : COLOR_CONTROL_CANCEL);
  354. add_control(328, TFT_HEIGHT - 64, CONFIRM, imgConfirm, true, yesno ? COLOR_CONTROL_CONFIRM : HALF(COLOR_CONTROL_CONFIRM));
  355. #else
  356. menu_line(++line);
  357. if (no) {
  358. tft_string.set(no);
  359. tft_string.trim();
  360. tft.add_text(tft_string.center(TFT_WIDTH / 2), 0, !yesno ? COLOR_RED : COLOR_MENU_TEXT, tft_string);
  361. }
  362. if (yes) {
  363. tft_string.set(yes);
  364. tft_string.trim();
  365. tft.add_text(TFT_WIDTH / 2 + tft_string.center(TFT_WIDTH / 2), 0, yesno ? COLOR_RED : COLOR_MENU_TEXT, tft_string);
  366. }
  367. #endif
  368. }
  369. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  370. void MarlinUI::draw_hotend_status(const uint8_t row, const uint8_t extruder) {
  371. #if ENABLED(TOUCH_SCREEN)
  372. touch.clear();
  373. draw_menu_navigation = false;
  374. touch.add_control(RESUME_CONTINUE , 0, 0, TFT_WIDTH, TFT_HEIGHT);
  375. #endif
  376. menu_line(row);
  377. tft_string.set(GET_TEXT(MSG_FILAMENT_CHANGE_NOZZLE));
  378. tft_string.add('E');
  379. tft_string.add((char)('1' + extruder));
  380. tft_string.add(' ');
  381. tft_string.add(i16tostr3rj(thermalManager.degHotend(extruder)));
  382. tft_string.add(LCD_STR_DEGREE);
  383. tft_string.add(" / ");
  384. tft_string.add(i16tostr3rj(thermalManager.degTargetHotend(extruder)));
  385. tft_string.add(LCD_STR_DEGREE);
  386. tft_string.trim();
  387. tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_MENU_TEXT, tft_string);
  388. }
  389. #endif // ADVANCED_PAUSE_FEATURE
  390. #if ENABLED(AUTO_BED_LEVELING_UBL)
  391. #define GRID_OFFSET_X 8
  392. #define GRID_OFFSET_Y 8
  393. #define GRID_WIDTH 192
  394. #define GRID_HEIGHT 192
  395. #define CONTROL_OFFSET 16
  396. void MarlinUI::ubl_plot(const uint8_t x_plot, const uint8_t y_plot) {
  397. tft.canvas(GRID_OFFSET_X, GRID_OFFSET_Y, GRID_WIDTH, GRID_HEIGHT);
  398. tft.set_background(COLOR_BACKGROUND);
  399. tft.add_rectangle(0, 0, GRID_WIDTH, GRID_HEIGHT, COLOR_WHITE);
  400. for (uint16_t x = 0; x < GRID_MAX_POINTS_X ; x++)
  401. for (uint16_t y = 0; y < GRID_MAX_POINTS_Y ; y++)
  402. if (position_is_reachable({ ubl.mesh_index_to_xpos(x), ubl.mesh_index_to_ypos(y) }))
  403. tft.add_bar(1 + (x * 2 + 1) * (GRID_WIDTH - 4) / GRID_MAX_POINTS_X / 2, GRID_HEIGHT - 3 - ((y * 2 + 1) * (GRID_HEIGHT - 4) / GRID_MAX_POINTS_Y / 2), 2, 2, COLOR_UBL);
  404. tft.add_rectangle((x_plot * 2 + 1) * (GRID_WIDTH - 4) / GRID_MAX_POINTS_X / 2 - 1, GRID_HEIGHT - 5 - ((y_plot * 2 + 1) * (GRID_HEIGHT - 4) / GRID_MAX_POINTS_Y / 2), 6, 6, COLOR_UBL);
  405. const xy_pos_t pos = { ubl.mesh_index_to_xpos(x_plot), ubl.mesh_index_to_ypos(y_plot) },
  406. lpos = pos.asLogical();
  407. tft.canvas(320, GRID_OFFSET_Y + (GRID_HEIGHT - MENU_ITEM_HEIGHT) / 2 - MENU_ITEM_HEIGHT, 120, MENU_ITEM_HEIGHT);
  408. tft.set_background(COLOR_BACKGROUND);
  409. tft_string.set(X_LBL);
  410. tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
  411. tft_string.set(ftostr52(lpos.x));
  412. tft_string.trim();
  413. tft.add_text(120 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
  414. tft.canvas(320, GRID_OFFSET_Y + (GRID_HEIGHT - MENU_ITEM_HEIGHT) / 2, 120, MENU_ITEM_HEIGHT);
  415. tft.set_background(COLOR_BACKGROUND);
  416. tft_string.set(Y_LBL);
  417. tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
  418. tft_string.set(ftostr52(lpos.y));
  419. tft_string.trim();
  420. tft.add_text(120 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
  421. tft.canvas(320, GRID_OFFSET_Y + (GRID_HEIGHT - MENU_ITEM_HEIGHT) / 2 + MENU_ITEM_HEIGHT, 120, MENU_ITEM_HEIGHT);
  422. tft.set_background(COLOR_BACKGROUND);
  423. tft_string.set(Z_LBL);
  424. tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
  425. tft_string.set(isnan(ubl.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(ubl.z_values[x_plot][y_plot]));
  426. tft_string.trim();
  427. tft.add_text(120 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
  428. constexpr uint8_t w = (TFT_WIDTH) / 10;
  429. tft.canvas(GRID_OFFSET_X + (GRID_WIDTH - w) / 2, GRID_OFFSET_Y + GRID_HEIGHT + CONTROL_OFFSET - 5, w, MENU_ITEM_HEIGHT);
  430. tft.set_background(COLOR_BACKGROUND);
  431. tft_string.set(ui8tostr3rj(x_plot));
  432. tft_string.trim();
  433. tft.add_text(tft_string.center(w), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
  434. tft.canvas(GRID_OFFSET_X + GRID_WIDTH + CONTROL_OFFSET + 16 - 24, GRID_OFFSET_Y + (GRID_HEIGHT - MENU_ITEM_HEIGHT) / 2, w, MENU_ITEM_HEIGHT);
  435. tft.set_background(COLOR_BACKGROUND);
  436. tft_string.set(ui8tostr3rj(y_plot));
  437. tft_string.trim();
  438. tft.add_text(tft_string.center(w), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
  439. #if ENABLED(TOUCH_SCREEN)
  440. touch.clear();
  441. draw_menu_navigation = false;
  442. add_control(GRID_OFFSET_X + GRID_WIDTH + CONTROL_OFFSET, GRID_OFFSET_Y + CONTROL_OFFSET, UBL, ENCODER_STEPS_PER_MENU_ITEM * GRID_MAX_POINTS_X, imgUp);
  443. add_control(GRID_OFFSET_X + GRID_WIDTH + CONTROL_OFFSET, GRID_OFFSET_Y + GRID_HEIGHT - CONTROL_OFFSET - 32, UBL, - ENCODER_STEPS_PER_MENU_ITEM * GRID_MAX_POINTS_X, imgDown);
  444. add_control(GRID_OFFSET_X + CONTROL_OFFSET, GRID_OFFSET_Y + GRID_HEIGHT + CONTROL_OFFSET, UBL, - ENCODER_STEPS_PER_MENU_ITEM, imgLeft);
  445. add_control(GRID_OFFSET_X + GRID_WIDTH - CONTROL_OFFSET - 32, GRID_OFFSET_Y + GRID_HEIGHT + CONTROL_OFFSET, UBL, ENCODER_STEPS_PER_MENU_ITEM, imgRight);
  446. add_control(320, GRID_OFFSET_Y + GRID_HEIGHT + CONTROL_OFFSET, CLICK, imgLeveling);
  447. add_control(224, TFT_HEIGHT - 34, BACK, imgBack);
  448. #endif
  449. }
  450. #endif // AUTO_BED_LEVELING_UBL
  451. #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
  452. #include "../../feature/babystep.h"
  453. #endif
  454. #if HAS_BED_PROBE
  455. #include "../../module/probe.h"
  456. #endif
  457. #define Z_SELECTION_Z 1
  458. #define Z_SELECTION_Z_PROBE -1
  459. struct MotionAxisState {
  460. xy_int_t xValuePos, yValuePos, zValuePos, eValuePos, stepValuePos, zTypePos, eNamePos;
  461. float currentStepSize = 10.0;
  462. int z_selection = Z_SELECTION_Z;
  463. uint8_t e_selection = 0;
  464. bool homming = false;
  465. bool blocked = false;
  466. char message[32];
  467. };
  468. MotionAxisState motionAxisState;
  469. #define E_BTN_COLOR COLOR_YELLOW
  470. #define X_BTN_COLOR COLOR_CORAL_RED
  471. #define Y_BTN_COLOR COLOR_VIVID_GREEN
  472. #define Z_BTN_COLOR COLOR_LIGHT_BLUE
  473. #define BTN_WIDTH 64
  474. #define BTN_HEIGHT 52
  475. #define X_MARGIN 20
  476. #define Y_MARGIN 15
  477. static void quick_feedback() {
  478. #if HAS_CHIRP
  479. ui.chirp(); // Buzz and wait. Is the delay needed for buttons to settle?
  480. #if BOTH(HAS_LCD_MENU, USE_BEEPER)
  481. for (int8_t i = 5; i--;) { buzzer.tick(); delay(2); }
  482. #elif HAS_LCD_MENU
  483. delay(10);
  484. #endif
  485. #endif
  486. }
  487. #define CUR_STEP_VALUE_WIDTH 104
  488. static void drawCurStepValue() {
  489. tft_string.set((uint8_t *)ftostr52sp(motionAxisState.currentStepSize));
  490. tft_string.add("mm");
  491. tft.canvas(motionAxisState.stepValuePos.x, motionAxisState.stepValuePos.y, CUR_STEP_VALUE_WIDTH, BTN_HEIGHT);
  492. tft.set_background(COLOR_BACKGROUND);
  493. tft.add_text(tft_string.center(CUR_STEP_VALUE_WIDTH), 0, COLOR_AXIS_HOMED, tft_string);
  494. }
  495. static void drawCurZSelection() {
  496. tft_string.set("Z");
  497. tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y, tft_string.width(), 34);
  498. tft.set_background(COLOR_BACKGROUND);
  499. tft.add_text(0, 0, Z_BTN_COLOR, tft_string);
  500. tft.queue.sync();
  501. tft_string.set("Offset");
  502. tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y + 34, tft_string.width(), 34);
  503. tft.set_background(COLOR_BACKGROUND);
  504. if (motionAxisState.z_selection == Z_SELECTION_Z_PROBE) {
  505. tft.add_text(0, 0, Z_BTN_COLOR, tft_string);
  506. }
  507. }
  508. static void drawCurESelection() {
  509. tft.canvas(motionAxisState.eNamePos.x, motionAxisState.eNamePos.y, BTN_WIDTH, BTN_HEIGHT);
  510. tft.set_background(COLOR_BACKGROUND);
  511. tft_string.set("E");
  512. tft.add_text(0, 0, E_BTN_COLOR , tft_string);
  513. tft.add_text(tft_string.width(), 0, E_BTN_COLOR, ui8tostr3rj(motionAxisState.e_selection));
  514. }
  515. static void drawMessage(const char *msg) {
  516. tft.canvas(X_MARGIN, TFT_HEIGHT - Y_MARGIN - 34, TFT_HEIGHT / 2, 34);
  517. tft.set_background(COLOR_BACKGROUND);
  518. tft.add_text(0, 0, COLOR_YELLOW, msg);
  519. }
  520. static void drawAxisValue(AxisEnum axis) {
  521. const float value =
  522. #if HAS_BED_PROBE
  523. axis == Z_AXIS && motionAxisState.z_selection == Z_SELECTION_Z_PROBE ?
  524. probe.offset.z :
  525. #endif
  526. NATIVE_TO_LOGICAL(
  527. ui.manual_move.processing ? destination[axis] : current_position[axis] + TERN0(IS_KINEMATIC, ui.manual_move.offset),
  528. axis
  529. );
  530. xy_int_t pos;
  531. uint16_t color;
  532. switch (axis) {
  533. case X_AXIS: pos = motionAxisState.xValuePos; color = X_BTN_COLOR; break;
  534. case Y_AXIS: pos = motionAxisState.yValuePos; color = Y_BTN_COLOR; break;
  535. case Z_AXIS: pos = motionAxisState.zValuePos; color = Z_BTN_COLOR; break;
  536. case E_AXIS: pos = motionAxisState.eValuePos; color = E_BTN_COLOR; break;
  537. default: return;
  538. }
  539. tft.canvas(pos.x, pos.y, BTN_WIDTH + X_MARGIN, BTN_HEIGHT);
  540. tft.set_background(COLOR_BACKGROUND);
  541. tft_string.set(ftostr52sp(value));
  542. tft.add_text(0, 0, color, tft_string);
  543. }
  544. static void moveAxis(AxisEnum axis, const int8_t direction) {
  545. quick_feedback();
  546. if (axis == E_AXIS && thermalManager.temp_hotend[motionAxisState.e_selection].celsius < EXTRUDE_MINTEMP) {
  547. drawMessage("Too cold");
  548. return;
  549. }
  550. const float diff = motionAxisState.currentStepSize * direction;
  551. if (axis == Z_AXIS && motionAxisState.z_selection == Z_SELECTION_Z_PROBE) {
  552. #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
  553. const int16_t babystep_increment = direction * BABYSTEP_SIZE_Z;
  554. const bool do_probe = DISABLED(BABYSTEP_HOTEND_Z_OFFSET) || active_extruder == 0;
  555. const float bsDiff = planner.steps_to_mm[Z_AXIS] * babystep_increment,
  556. new_probe_offset = probe.offset.z + bsDiff,
  557. new_offs = TERN(BABYSTEP_HOTEND_Z_OFFSET
  558. , do_probe ? new_probe_offset : hotend_offset[active_extruder].z - bsDiff
  559. , new_probe_offset
  560. );
  561. if (WITHIN(new_offs, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) {
  562. babystep.add_steps(Z_AXIS, babystep_increment);
  563. if (do_probe)
  564. probe.offset.z = new_offs;
  565. else
  566. TERN(BABYSTEP_HOTEND_Z_OFFSET, hotend_offset[active_extruder].z = new_offs, NOOP);
  567. drawMessage(""); // clear the error
  568. drawAxisValue(axis);
  569. }
  570. else {
  571. drawMessage(GET_TEXT(MSG_LCD_SOFT_ENDSTOPS));
  572. }
  573. #elif HAS_BED_PROBE
  574. // only change probe.offset.z
  575. probe.offset.z += diff;
  576. if (direction < 0 && current_position[axis] < Z_PROBE_OFFSET_RANGE_MIN) {
  577. current_position[axis] = Z_PROBE_OFFSET_RANGE_MIN;
  578. drawMessage(GET_TEXT(MSG_LCD_SOFT_ENDSTOPS));
  579. }
  580. else if (direction > 0 && current_position[axis] > Z_PROBE_OFFSET_RANGE_MAX) {
  581. current_position[axis] = Z_PROBE_OFFSET_RANGE_MAX;
  582. drawMessage(GET_TEXT(MSG_LCD_SOFT_ENDSTOPS));
  583. }
  584. else {
  585. drawMessage(""); // clear the error
  586. }
  587. drawAxisValue(axis);
  588. #endif
  589. return;
  590. }
  591. if (!ui.manual_move.processing) {
  592. // Get motion limit from software endstops, if any
  593. float min, max;
  594. soft_endstop.get_manual_axis_limits(axis, min, max);
  595. // Delta limits XY based on the current offset from center
  596. // This assumes the center is 0,0
  597. #if ENABLED(DELTA)
  598. if (axis != Z_AXIS && axis != E_AXIS) {
  599. max = SQRT(sq((float)(DELTA_PRINTABLE_RADIUS)) - sq(current_position[Y_AXIS - axis])); // (Y_AXIS - axis) == the other axis
  600. min = -max;
  601. }
  602. #endif
  603. // Get the new position
  604. #if IS_KINEMATIC
  605. ui.manual_move.offset += diff;
  606. if (direction < 0)
  607. NOLESS(ui.manual_move.offset, min - current_position[axis]);
  608. else
  609. NOMORE(ui.manual_move.offset, max - current_position[axis]);
  610. #else
  611. current_position[axis] += diff;
  612. const char *msg = NUL_STR; // clear the error
  613. if (direction < 0 && current_position[axis] < min) {
  614. current_position[axis] = min;
  615. msg = GET_TEXT(MSG_LCD_SOFT_ENDSTOPS);
  616. }
  617. else if (direction > 0 && current_position[axis] > max) {
  618. current_position[axis] = max;
  619. msg = GET_TEXT(MSG_LCD_SOFT_ENDSTOPS);
  620. }
  621. drawMessage(msg);
  622. #endif
  623. ui.manual_move.soon(axis
  624. #if MULTI_MANUAL
  625. , motionAxisState.e_selection
  626. #endif
  627. );
  628. }
  629. drawAxisValue(axis);
  630. }
  631. static void e_plus() { moveAxis(E_AXIS, 1); }
  632. static void e_minus() { moveAxis(E_AXIS, -1); }
  633. static void x_minus() { moveAxis(X_AXIS, -1); }
  634. static void x_plus() { moveAxis(X_AXIS, 1); }
  635. static void y_plus() { moveAxis(Y_AXIS, 1); }
  636. static void y_minus() { moveAxis(Y_AXIS, -1); }
  637. static void z_plus() { moveAxis(Z_AXIS, 1); }
  638. static void z_minus() { moveAxis(Z_AXIS, -1); }
  639. #if ENABLED(TOUCH_SCREEN)
  640. static void e_select() {
  641. motionAxisState.e_selection++;
  642. if (motionAxisState.e_selection >= EXTRUDERS) {
  643. motionAxisState.e_selection = 0;
  644. }
  645. quick_feedback();
  646. drawCurESelection();
  647. drawAxisValue(E_AXIS);
  648. }
  649. static void do_home() {
  650. quick_feedback();
  651. drawMessage(GET_TEXT(MSG_LEVEL_BED_HOMING));
  652. queue.inject_P(G28_STR);
  653. // Disable touch until home is done
  654. TERN_(HAS_TFT_XPT2046, touch.disable());
  655. drawAxisValue(E_AXIS);
  656. drawAxisValue(X_AXIS);
  657. drawAxisValue(Y_AXIS);
  658. drawAxisValue(Z_AXIS);
  659. }
  660. static void step_size() {
  661. motionAxisState.currentStepSize = motionAxisState.currentStepSize / 10.0;
  662. if (motionAxisState.currentStepSize < 0.0015) motionAxisState.currentStepSize = 10.0;
  663. quick_feedback();
  664. drawCurStepValue();
  665. }
  666. #endif
  667. #if HAS_BED_PROBE
  668. static void z_select() {
  669. motionAxisState.z_selection *= -1;
  670. quick_feedback();
  671. drawCurZSelection();
  672. drawAxisValue(Z_AXIS);
  673. }
  674. #endif
  675. static void disable_steppers() {
  676. quick_feedback();
  677. queue.inject_P(PSTR("M84"));
  678. }
  679. static void drawBtn(int x, int y, const char *label, intptr_t data, MarlinImage img, uint16_t bgColor, bool enabled = true) {
  680. uint16_t width = Images[imgBtn52Rounded].width;
  681. uint16_t height = Images[imgBtn52Rounded].height;
  682. if (!enabled) bgColor = COLOR_CONTROL_DISABLED;
  683. tft.canvas(x, y, width, height);
  684. tft.set_background(COLOR_BACKGROUND);
  685. tft.add_image(0, 0, imgBtn52Rounded, bgColor, COLOR_BACKGROUND, COLOR_DARKGREY);
  686. // TODO: Make an add_text() taking a font arg
  687. if (label) {
  688. tft_string.set(label);
  689. tft_string.trim();
  690. tft.add_text(tft_string.center(width), height / 2 - tft_string.font_height() / 2, bgColor, tft_string);
  691. }
  692. else {
  693. tft.add_image(0, 0, img, bgColor, COLOR_BACKGROUND, COLOR_DARKGREY);
  694. }
  695. TERN_(HAS_TFT_XPT2046, if (enabled) touch.add_control(BUTTON, x, y, width, height, data));
  696. }
  697. void MarlinUI::move_axis_screen() {
  698. // Reset
  699. defer_status_screen(true);
  700. motionAxisState.blocked = false;
  701. TERN_(HAS_TFT_XPT2046, touch.enable());
  702. ui.clear_lcd();
  703. TERN_(TOUCH_SCREEN, touch.clear());
  704. const bool busy = printingIsActive();
  705. // Babysteps during printing? Select babystep for Z probe offset
  706. if (busy && ENABLED(BABYSTEP_ZPROBE_OFFSET))
  707. motionAxisState.z_selection = Z_SELECTION_Z_PROBE;
  708. // ROW 1 -> E- Y- CurY Z+
  709. int x = X_MARGIN, y = Y_MARGIN, spacing = 0;
  710. drawBtn(x, y, "E+", (intptr_t)e_plus, imgUp, E_BTN_COLOR, !busy);
  711. spacing = (TFT_WIDTH - X_MARGIN * 2 - 3 * BTN_WIDTH) / 2;
  712. x += BTN_WIDTH + spacing;
  713. drawBtn(x, y, "Y+", (intptr_t)y_plus, imgUp, Y_BTN_COLOR, !busy);
  714. // Cur Y
  715. x += BTN_WIDTH;
  716. motionAxisState.yValuePos.x = x + 2;
  717. motionAxisState.yValuePos.y = y;
  718. drawAxisValue(Y_AXIS);
  719. x += spacing;
  720. drawBtn(x, y, "Z+", (intptr_t)z_plus, imgUp, Z_BTN_COLOR, !busy || ENABLED(BABYSTEP_ZPROBE_OFFSET)); //only enabled when not busy or have baby step
  721. // ROW 2 -> "Ex" X- HOME X+ "Z"
  722. y += BTN_HEIGHT + (TFT_HEIGHT - Y_MARGIN * 2 - 4 * BTN_HEIGHT) / 3;
  723. x = X_MARGIN;
  724. spacing = (TFT_WIDTH - X_MARGIN * 2 - 5 * BTN_WIDTH) / 4;
  725. motionAxisState.eNamePos.x = x;
  726. motionAxisState.eNamePos.y = y;
  727. drawCurESelection();
  728. TERN_(HAS_TFT_XPT2046, if (!busy) touch.add_control(BUTTON, x, y, BTN_WIDTH, BTN_HEIGHT, (intptr_t)e_select));
  729. x += BTN_WIDTH + spacing;
  730. drawBtn(x, y, "X-", (intptr_t)x_minus, imgLeft, X_BTN_COLOR, !busy);
  731. x += BTN_WIDTH + spacing; //imgHome is 64x64
  732. TERN_(HAS_TFT_XPT2046, add_control(TFT_WIDTH / 2 - Images[imgHome].width / 2, y - (Images[imgHome].width - BTN_HEIGHT) / 2, BUTTON, (intptr_t)do_home, imgHome, !busy));
  733. x += BTN_WIDTH + spacing;
  734. uint16_t xplus_x = x;
  735. drawBtn(x, y, "X+", (intptr_t)x_plus, imgRight, X_BTN_COLOR, !busy);
  736. x += BTN_WIDTH + spacing;
  737. motionAxisState.zTypePos.x = x;
  738. motionAxisState.zTypePos.y = y;
  739. drawCurZSelection();
  740. #if BOTH(HAS_BED_PROBE, TOUCH_SCREEN)
  741. if (!busy) touch.add_control(BUTTON, x, y, BTN_WIDTH, 34 * 2, (intptr_t)z_select);
  742. #endif
  743. // ROW 3 -> E- CurX Y- Z-
  744. y += BTN_HEIGHT + (TFT_HEIGHT - Y_MARGIN * 2 - 4 * BTN_HEIGHT) / 3;
  745. x = X_MARGIN;
  746. spacing = (TFT_WIDTH - X_MARGIN * 2 - 3 * BTN_WIDTH) / 2;
  747. drawBtn(x, y, "E-", (intptr_t)e_minus, imgDown, E_BTN_COLOR, !busy);
  748. // Cur E
  749. motionAxisState.eValuePos.x = x;
  750. motionAxisState.eValuePos.y = y + BTN_HEIGHT + 2;
  751. drawAxisValue(E_AXIS);
  752. // Cur X
  753. motionAxisState.xValuePos.x = BTN_WIDTH + (TFT_WIDTH - X_MARGIN * 2 - 5 * BTN_WIDTH) / 4; //X- pos
  754. motionAxisState.xValuePos.y = y - 10;
  755. drawAxisValue(X_AXIS);
  756. x += BTN_WIDTH + spacing;
  757. drawBtn(x, y, "Y-", (intptr_t)y_minus, imgDown, Y_BTN_COLOR, !busy);
  758. x += BTN_WIDTH + spacing;
  759. drawBtn(x, y, "Z-", (intptr_t)z_minus, imgDown, Z_BTN_COLOR, !busy || ENABLED(BABYSTEP_ZPROBE_OFFSET)); //only enabled when not busy or have baby step
  760. // Cur Z
  761. motionAxisState.zValuePos.x = x;
  762. motionAxisState.zValuePos.y = y + BTN_HEIGHT + 2;
  763. drawAxisValue(Z_AXIS);
  764. // ROW 4 -> step_size disable steppers back
  765. y = TFT_HEIGHT - Y_MARGIN - 32; //
  766. x = TFT_WIDTH / 2 - CUR_STEP_VALUE_WIDTH / 2;
  767. motionAxisState.stepValuePos.x = x;
  768. motionAxisState.stepValuePos.y = y;
  769. if (!busy) {
  770. drawCurStepValue();
  771. TERN_(HAS_TFT_XPT2046, touch.add_control(BUTTON, motionAxisState.stepValuePos.x, motionAxisState.stepValuePos.y, CUR_STEP_VALUE_WIDTH, BTN_HEIGHT, (intptr_t)step_size));
  772. }
  773. // aligned with x+
  774. drawBtn(xplus_x, TFT_HEIGHT - Y_MARGIN - BTN_HEIGHT, "off", (intptr_t)disable_steppers, imgCancel, COLOR_WHITE, !busy);
  775. TERN_(HAS_TFT_XPT2046, add_control(TFT_WIDTH - X_MARGIN - BTN_WIDTH, y, BACK, imgBack));
  776. }
  777. #undef BTN_WIDTH
  778. #undef BTN_HEIGHT
  779. #endif // HAS_UI_480x320