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_320x240.cpp 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  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 (draw_menu_navigation) {
  43. add_control(48, 206, PAGE_UP, imgPageUp, encoderTopLine > 0);
  44. add_control(240, 206, PAGE_DOWN, imgPageDown, encoderTopLine + LCD_HEIGHT < screen_items);
  45. add_control(144, 206, 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 - 46)
  60. tft.set_background(COLOR_BACKGROUND);
  61. #else
  62. #define BOOT_LOGO_W TFT_WIDTH // MarlinLogo320x240x16
  63. #define BOOT_LOGO_H TFT_HEIGHT
  64. #define SITE_URL_Y (TFT_HEIGHT - 52)
  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. tft.canvas(0, 60, TFT_WIDTH, 20);
  80. tft.set_background(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_KILL_SCREEN_TEXT, tft_string);
  84. tft.canvas(0, 120, TFT_WIDTH, 20);
  85. tft.set_background(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_KILL_SCREEN_TEXT, tft_string);
  89. tft.canvas(0, 160, TFT_WIDTH, 20);
  90. tft.set_background(COLOR_KILL_SCREEN_BG);
  91. tft_string.set(GET_TEXT(MSG_PLEASE_RESET));
  92. tft_string.trim();
  93. tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_KILL_SCREEN_TEXT, tft_string);
  94. tft.queue.sync();
  95. }
  96. void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater) {
  97. MarlinImage image = imgHotEnd;
  98. uint16_t Color;
  99. celsius_t currentTemperature, targetTemperature;
  100. if (Heater >= 0) { // HotEnd
  101. currentTemperature = thermalManager.degHotend(Heater);
  102. targetTemperature = thermalManager.degTargetHotend(Heater);
  103. }
  104. #if HAS_HEATED_BED
  105. else if (Heater == H_BED) {
  106. currentTemperature = thermalManager.degBed();
  107. targetTemperature = thermalManager.degTargetBed();
  108. }
  109. #endif
  110. #if HAS_TEMP_CHAMBER
  111. else if (Heater == H_CHAMBER) {
  112. currentTemperature = thermalManager.degChamber();
  113. #if HAS_HEATED_CHAMBER
  114. targetTemperature = thermalManager.degTargetChamber();
  115. #else
  116. targetTemperature = ABSOLUTE_ZERO;
  117. #endif
  118. }
  119. #endif
  120. #if HAS_TEMP_COOLER
  121. else if (Heater == H_COOLER) {
  122. currentTemperature = thermalManager.degCooler();
  123. targetTemperature = TERN(HAS_COOLER, thermalManager.degTargetCooler(), ABSOLUTE_ZERO);
  124. }
  125. #endif
  126. else return;
  127. TERN_(TOUCH_SCREEN, if (targetTemperature >= 0) touch.add_control(HEATER, x, y, 64, 100, Heater));
  128. tft.canvas(x, y, 64, 100);
  129. tft.set_background(COLOR_BACKGROUND);
  130. Color = currentTemperature < 0 ? COLOR_INACTIVE : COLOR_COLD;
  131. if (Heater >= 0) { // HotEnd
  132. if (currentTemperature >= 50) Color = COLOR_HOTEND;
  133. }
  134. #if HAS_HEATED_BED
  135. else if (Heater == H_BED) {
  136. if (currentTemperature >= 50) Color = COLOR_HEATED_BED;
  137. image = targetTemperature > 0 ? imgBedHeated : imgBed;
  138. }
  139. #endif
  140. #if HAS_TEMP_CHAMBER
  141. else if (Heater == H_CHAMBER) {
  142. if (currentTemperature >= 50) Color = COLOR_CHAMBER;
  143. image = targetTemperature > 0 ? imgChamberHeated : imgChamber;
  144. }
  145. #endif
  146. #if HAS_TEMP_COOLER
  147. else if (Heater == H_COOLER) {
  148. if (currentTemperature <= 26) Color = COLOR_COLD;
  149. if (currentTemperature > 26) Color = COLOR_RED;
  150. image = targetTemperature > 26 ? imgCoolerHot : imgCooler;
  151. }
  152. #endif
  153. tft.add_image(0, 18, image, Color);
  154. tft_string.set((uint8_t *)i16tostr3rj(currentTemperature));
  155. tft_string.add(LCD_STR_DEGREE);
  156. tft_string.trim();
  157. tft.add_text(tft_string.center(64) + 2, 72, Color, tft_string);
  158. if (targetTemperature >= 0) {
  159. tft_string.set((uint8_t *)i16tostr3rj(targetTemperature));
  160. tft_string.add(LCD_STR_DEGREE);
  161. tft_string.trim();
  162. tft.add_text(tft_string.center(64) + 2, 8, Color, tft_string);
  163. }
  164. }
  165. void draw_fan_status(uint16_t x, uint16_t y, const bool blink) {
  166. TERN_(TOUCH_SCREEN, touch.add_control(FAN, x, y, 64, 100));
  167. tft.canvas(x, y, 64, 100);
  168. tft.set_background(COLOR_BACKGROUND);
  169. uint8_t fanSpeed = thermalManager.fan_speed[0];
  170. MarlinImage image;
  171. if (fanSpeed >= 127)
  172. image = blink ? imgFanFast1 : imgFanFast0;
  173. else if (fanSpeed > 0)
  174. image = blink ? imgFanSlow1 : imgFanSlow0;
  175. else
  176. image = imgFanIdle;
  177. tft.add_image(0, 10, image, COLOR_FAN);
  178. tft_string.set((uint8_t *)ui8tostr4pctrj(thermalManager.fan_speed[0]));
  179. tft_string.trim();
  180. tft.add_text(tft_string.center(64) + 6, 72, COLOR_FAN, tft_string);
  181. }
  182. void MarlinUI::draw_status_screen() {
  183. const bool blink = get_blink();
  184. TERN_(TOUCH_SCREEN, touch.clear());
  185. // heaters and fan
  186. uint16_t i, x, y = TFT_STATUS_TOP_Y;
  187. for (i = 0 ; i < ITEMS_COUNT; i++) {
  188. x = (320 / ITEMS_COUNT - 64) / 2 + (320 * i / ITEMS_COUNT);
  189. switch (i) {
  190. #ifdef ITEM_E0
  191. case ITEM_E0: draw_heater_status(x, y, H_E0); break;
  192. #endif
  193. #ifdef ITEM_E1
  194. case ITEM_E1: draw_heater_status(x, y, H_E1); break;
  195. #endif
  196. #ifdef ITEM_E2
  197. case ITEM_E2: draw_heater_status(x, y, H_E2); break;
  198. #endif
  199. #ifdef ITEM_BED
  200. case ITEM_BED: draw_heater_status(x, y, H_BED); break;
  201. #endif
  202. #ifdef ITEM_CHAMBER
  203. case ITEM_CHAMBER: draw_heater_status(x, y, H_CHAMBER); break;
  204. #endif
  205. #ifdef ITEM_FAN
  206. case ITEM_FAN: draw_fan_status(x, y, blink); break;
  207. #endif
  208. }
  209. }
  210. // coordinates
  211. tft.canvas(4, 103, 312, 24);
  212. tft.set_background(COLOR_BACKGROUND);
  213. tft.add_rectangle(0, 0, 312, 24, COLOR_AXIS_HOMED);
  214. tft.add_text( 10, 3, COLOR_AXIS_HOMED , "X");
  215. tft.add_text(127, 3, COLOR_AXIS_HOMED , "Y");
  216. tft.add_text(219, 3, COLOR_AXIS_HOMED , "Z");
  217. bool not_homed = axis_should_home(X_AXIS);
  218. tft_string.set(blink && not_homed ? "?" : ftostr4sign(LOGICAL_X_POSITION(current_position.x)));
  219. tft.add_text( 68 - tft_string.width(), 3, not_homed ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string);
  220. not_homed = axis_should_home(Y_AXIS);
  221. tft_string.set(blink && not_homed ? "?" : ftostr4sign(LOGICAL_Y_POSITION(current_position.y)));
  222. tft.add_text(185 - tft_string.width(), 3, not_homed ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string);
  223. not_homed = axis_should_home(Z_AXIS);
  224. uint16_t offset = 25;
  225. if (blink && not_homed)
  226. tft_string.set("?");
  227. else {
  228. const float z = LOGICAL_Z_POSITION(current_position.z);
  229. tft_string.set(ftostr52sp((int16_t)z));
  230. tft_string.rtrim();
  231. offset += tft_string.width();
  232. tft_string.set(ftostr52sp(z));
  233. offset -= tft_string.width();
  234. }
  235. tft.add_text(301 - tft_string.width() - offset, 3, not_homed ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string);
  236. // feed rate
  237. tft.canvas(70, 136, 80, 32);
  238. tft.set_background(COLOR_BACKGROUND);
  239. uint16_t color = feedrate_percentage == 100 ? COLOR_RATE_100 : COLOR_RATE_ALTERED;
  240. tft.add_image(0, 0, imgFeedRate, color);
  241. tft_string.set(i16tostr3rj(feedrate_percentage));
  242. tft_string.add('%');
  243. tft.add_text(32, 6, color , tft_string);
  244. TERN_(TOUCH_SCREEN, touch.add_control(FEEDRATE, 70, 136, 80, 32));
  245. // flow rate
  246. tft.canvas(170, 136, 80, 32);
  247. tft.set_background(COLOR_BACKGROUND);
  248. color = planner.flow_percentage[0] == 100 ? COLOR_RATE_100 : COLOR_RATE_ALTERED;
  249. tft.add_image(0, 0, imgFlowRate, color);
  250. tft_string.set(i16tostr3rj(planner.flow_percentage[active_extruder]));
  251. tft_string.add('%');
  252. tft.add_text(32, 6, color , tft_string);
  253. TERN_(TOUCH_SCREEN, touch.add_control(FLOWRATE, 170, 136, 80, 32, active_extruder));
  254. // print duration
  255. char buffer[14];
  256. duration_t elapsed = print_job_timer.duration();
  257. elapsed.toDigital(buffer);
  258. tft.canvas(96, 176, 128, 20);
  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. // progress bar
  263. const uint8_t progress = ui.get_progress_percent();
  264. tft.canvas(4, 198, 312, 9);
  265. tft.set_background(COLOR_PROGRESS_BG);
  266. tft.add_rectangle(0, 0, 312, 9, COLOR_PROGRESS_FRAME);
  267. if (progress)
  268. tft.add_bar(1, 1, (310 * progress) / 100, 7, COLOR_PROGRESS_BAR);
  269. // status message
  270. tft.canvas(0, 216, 320, 20);
  271. tft.set_background(COLOR_BACKGROUND);
  272. tft_string.set(status_message);
  273. tft_string.trim();
  274. tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_STATUS_MESSAGE, tft_string);
  275. #if ENABLED(TOUCH_SCREEN)
  276. add_control(256, 130, menu_main, imgSettings);
  277. TERN_(SDSUPPORT, add_control(0, 130, menu_media, imgSD, !printingIsActive(), COLOR_CONTROL_ENABLED, card.isMounted() && printingIsActive() ? COLOR_BUSY : COLOR_CONTROL_DISABLED));
  278. #endif
  279. }
  280. // Low-level draw_edit_screen can be used to draw an edit screen from anyplace
  281. void MenuEditItemBase::draw_edit_screen(PGM_P const pstr, const char * const value/*=nullptr*/) {
  282. ui.encoder_direction_normal();
  283. TERN_(TOUCH_SCREEN, touch.clear());
  284. uint16_t line = 1;
  285. menu_line(line++);
  286. tft_string.set(pstr, itemIndex, itemString);
  287. tft_string.trim();
  288. tft.add_text(tft_string.center(TFT_WIDTH), MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
  289. TERN_(AUTO_BED_LEVELING_UBL, if (ui.external_control) line++); // ftostr52() will overwrite *value so *value has to be displayed first
  290. menu_line(line);
  291. tft_string.set(value);
  292. tft_string.trim();
  293. tft.add_text(tft_string.center(TFT_WIDTH), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
  294. #if ENABLED(AUTO_BED_LEVELING_UBL)
  295. if (ui.external_control) {
  296. menu_line(line - 1);
  297. tft_string.set(X_LBL);
  298. tft.add_text(52, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
  299. tft_string.set(ftostr52(LOGICAL_X_POSITION(current_position.x)));
  300. tft_string.trim();
  301. tft.add_text(144 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
  302. tft_string.set(Y_LBL);
  303. tft.add_text(176, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
  304. tft_string.set(ftostr52(LOGICAL_X_POSITION(current_position.y)));
  305. tft_string.trim();
  306. tft.add_text(268 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
  307. }
  308. #endif
  309. extern screenFunc_t _manual_move_func_ptr;
  310. if (ui.currentScreen != _manual_move_func_ptr && !ui.external_control) {
  311. #define SLIDER_LENGTH 224
  312. #define SLIDER_Y_POSITION 140
  313. tft.canvas((TFT_WIDTH - SLIDER_LENGTH) / 2, SLIDER_Y_POSITION, SLIDER_LENGTH, 16);
  314. tft.set_background(COLOR_BACKGROUND);
  315. int16_t position = (SLIDER_LENGTH - 2) * ui.encoderPosition / maxEditValue;
  316. tft.add_bar(0, 7, 1, 2, ui.encoderPosition == 0 ? COLOR_SLIDER_INACTIVE : COLOR_SLIDER);
  317. tft.add_bar(1, 6, position, 4, COLOR_SLIDER);
  318. tft.add_bar(position + 1, 6, SLIDER_LENGTH - 2 - position, 4, COLOR_SLIDER_INACTIVE);
  319. tft.add_bar(SLIDER_LENGTH - 1, 7, 1, 2, int32_t(ui.encoderPosition) == maxEditValue ? COLOR_SLIDER : COLOR_SLIDER_INACTIVE);
  320. #if ENABLED(TOUCH_SCREEN)
  321. tft.add_image((SLIDER_LENGTH - 8) * ui.encoderPosition / maxEditValue, 0, imgSlider, COLOR_SLIDER);
  322. touch.add_control(SLIDER, (TFT_WIDTH - SLIDER_LENGTH) / 2, SLIDER_Y_POSITION - 8, SLIDER_LENGTH, 32, maxEditValue);
  323. #endif
  324. }
  325. tft.draw_edit_screen_buttons();
  326. }
  327. void TFT::draw_edit_screen_buttons() {
  328. #if ENABLED(TOUCH_SCREEN)
  329. add_control(32, 176, DECREASE, imgDecrease);
  330. add_control(224, 176, INCREASE, imgIncrease);
  331. add_control(128, 176, CLICK, imgConfirm);
  332. #endif
  333. }
  334. // The Select Screen presents a prompt and two "buttons"
  335. 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*/) {
  336. uint16_t line = 1;
  337. if (!string) line++;
  338. menu_line(line++);
  339. tft_string.set(pref);
  340. tft_string.trim();
  341. tft.add_text(tft_string.center(TFT_WIDTH), MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
  342. if (string) {
  343. menu_line(line++);
  344. tft_string.set(string);
  345. tft_string.trim();
  346. tft.add_text(tft_string.center(TFT_WIDTH), MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
  347. }
  348. if (suff) {
  349. menu_line(line);
  350. tft_string.set(suff);
  351. tft_string.trim();
  352. tft.add_text(tft_string.center(TFT_WIDTH), MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
  353. }
  354. #if ENABLED(TOUCH_SCREEN)
  355. add_control(48, 176, CANCEL, imgCancel, true, yesno ? HALF(COLOR_CONTROL_CANCEL) : COLOR_CONTROL_CANCEL);
  356. add_control(208, 176, CONFIRM, imgConfirm, true, yesno ? COLOR_CONTROL_CONFIRM : HALF(COLOR_CONTROL_CONFIRM));
  357. #endif
  358. }
  359. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  360. void MarlinUI::draw_hotend_status(const uint8_t row, const uint8_t extruder) {
  361. #if ENABLED(TOUCH_SCREEN)
  362. touch.clear();
  363. draw_menu_navigation = false;
  364. touch.add_control(RESUME_CONTINUE , 0, 0, 320, 240);
  365. #endif
  366. menu_line(row);
  367. tft_string.set(GET_TEXT(MSG_FILAMENT_CHANGE_NOZZLE));
  368. tft_string.add('E');
  369. tft_string.add((char)('1' + extruder));
  370. tft_string.add(' ');
  371. tft_string.add(i16tostr3rj(thermalManager.degHotend(extruder)));
  372. tft_string.add(LCD_STR_DEGREE);
  373. tft_string.add(" / ");
  374. tft_string.add(i16tostr3rj(thermalManager.degTargetHotend(extruder)));
  375. tft_string.add(LCD_STR_DEGREE);
  376. tft_string.trim();
  377. tft.add_text(tft_string.center(TFT_WIDTH), MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
  378. }
  379. #endif // ADVANCED_PAUSE_FEATURE
  380. #if ENABLED(AUTO_BED_LEVELING_UBL)
  381. #define GRID_OFFSET_X 8
  382. #define GRID_OFFSET_Y 8
  383. #define GRID_WIDTH 144
  384. #define GRID_HEIGHT 144
  385. #define CONTROL_OFFSET 8
  386. void MarlinUI::ubl_plot(const uint8_t x_plot, const uint8_t y_plot) {
  387. tft.canvas(GRID_OFFSET_X, GRID_OFFSET_Y, GRID_WIDTH, GRID_HEIGHT);
  388. tft.set_background(COLOR_BACKGROUND);
  389. tft.add_rectangle(0, 0, GRID_WIDTH, GRID_HEIGHT, COLOR_WHITE);
  390. for (uint16_t x = 0; x < (GRID_MAX_POINTS_X); x++)
  391. for (uint16_t y = 0; y < (GRID_MAX_POINTS_Y); y++)
  392. if (position_is_reachable({ ubl.mesh_index_to_xpos(x), ubl.mesh_index_to_ypos(y) }))
  393. 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);
  394. 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);
  395. const xy_pos_t pos = { ubl.mesh_index_to_xpos(x_plot), ubl.mesh_index_to_ypos(y_plot) },
  396. lpos = pos.asLogical();
  397. tft.canvas(216, GRID_OFFSET_Y + (GRID_HEIGHT - 32) / 2 - 32, 96, 32);
  398. tft.set_background(COLOR_BACKGROUND);
  399. tft_string.set(X_LBL);
  400. tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
  401. tft_string.set(ftostr52(lpos.x));
  402. tft_string.trim();
  403. tft.add_text(96 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
  404. tft.canvas(216, GRID_OFFSET_Y + (GRID_HEIGHT - 32) / 2, 96, 32);
  405. tft.set_background(COLOR_BACKGROUND);
  406. tft_string.set(Y_LBL);
  407. tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
  408. tft_string.set(ftostr52(lpos.y));
  409. tft_string.trim();
  410. tft.add_text(96 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
  411. tft.canvas(216, GRID_OFFSET_Y + (GRID_HEIGHT - 32) / 2 + 32, 96, 32);
  412. tft.set_background(COLOR_BACKGROUND);
  413. tft_string.set(Z_LBL);
  414. tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
  415. tft_string.set(isnan(ubl.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(ubl.z_values[x_plot][y_plot]));
  416. tft_string.trim();
  417. tft.add_text(96 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
  418. constexpr uint8_t w = (TFT_WIDTH) / 10;
  419. tft.canvas(GRID_OFFSET_X + (GRID_WIDTH - w) / 2, GRID_OFFSET_Y + GRID_HEIGHT + CONTROL_OFFSET - 1, w, 32);
  420. tft.set_background(COLOR_BACKGROUND);
  421. tft_string.set(ui8tostr3rj(x_plot));
  422. tft_string.trim();
  423. tft.add_text(tft_string.center(w), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
  424. tft.canvas(GRID_OFFSET_X + GRID_WIDTH + CONTROL_OFFSET, GRID_OFFSET_Y + (GRID_HEIGHT - 27) / 2, w, 32);
  425. tft.set_background(COLOR_BACKGROUND);
  426. tft_string.set(ui8tostr3rj(y_plot));
  427. tft_string.trim();
  428. tft.add_text(tft_string.center(w), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
  429. #if ENABLED(TOUCH_SCREEN)
  430. touch.clear();
  431. draw_menu_navigation = false;
  432. 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);
  433. 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);
  434. add_control(GRID_OFFSET_X + CONTROL_OFFSET, GRID_OFFSET_Y + GRID_HEIGHT + CONTROL_OFFSET, UBL, -(ENCODER_STEPS_PER_MENU_ITEM), imgLeft);
  435. add_control(GRID_OFFSET_X + GRID_WIDTH - CONTROL_OFFSET - 32, GRID_OFFSET_Y + GRID_HEIGHT + CONTROL_OFFSET, UBL, ENCODER_STEPS_PER_MENU_ITEM, imgRight);
  436. add_control(224, GRID_OFFSET_Y + GRID_HEIGHT + CONTROL_OFFSET, CLICK, imgLeveling);
  437. add_control(144, 206, BACK, imgBack);
  438. #endif
  439. }
  440. #endif // AUTO_BED_LEVELING_UBL
  441. void MarlinUI::move_axis_screen() {
  442. }
  443. #endif // HAS_UI_320x240