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.

ui_320x240.cpp 32KB

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