My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

ui_1024x600.cpp 33KB

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