My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

draw_number_key.cpp 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  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_TFT_LVGL_UI
  24. #include "draw_ui.h"
  25. #include <lv_conf.h>
  26. #include "../../../gcode/gcode.h"
  27. #include "../../../gcode/queue.h"
  28. #include "../../../module/planner.h"
  29. #include "../../../inc/MarlinConfig.h"
  30. #if ENABLED(POWER_LOSS_RECOVERY)
  31. #include "../../../feature/powerloss.h"
  32. #endif
  33. #if HAS_TRINAMIC_CONFIG
  34. #include "../../../module/stepper/indirection.h"
  35. #include "../../../feature/tmc_util.h"
  36. #endif
  37. #if HAS_BED_PROBE
  38. #include "../../../module/probe.h"
  39. #endif
  40. extern lv_group_t *g;
  41. static lv_obj_t *scr;
  42. static lv_obj_t *buttonValue = nullptr;
  43. static lv_obj_t *labelValue = nullptr;
  44. static char key_value[11] = { 0 };
  45. static uint8_t cnt = 0;
  46. static bool point_flag = true;
  47. enum {
  48. ID_NUM_KEY1 = 1,
  49. ID_NUM_KEY2,
  50. ID_NUM_KEY3,
  51. ID_NUM_KEY4,
  52. ID_NUM_KEY5,
  53. ID_NUM_KEY6,
  54. ID_NUM_KEY7,
  55. ID_NUM_KEY8,
  56. ID_NUM_KEY9,
  57. ID_NUM_KEY0,
  58. ID_NUM_BACK,
  59. ID_NUM_RESET,
  60. ID_NUM_CONFIRM,
  61. ID_NUM_POINT,
  62. ID_NUM_NEGATIVE
  63. };
  64. static void disp_key_value() {
  65. char *temp;
  66. TERN_(HAS_TRINAMIC_CONFIG, float milliamps);
  67. switch (value) {
  68. case PrintAcceleration:
  69. dtostrf(planner.settings.acceleration, 1, 1, public_buf_m);
  70. break;
  71. case RetractAcceleration:
  72. dtostrf(planner.settings.retract_acceleration, 1, 1, public_buf_m);
  73. break;
  74. case TravelAcceleration:
  75. dtostrf(planner.settings.travel_acceleration, 1, 1, public_buf_m);
  76. break;
  77. case XAcceleration:
  78. itoa(planner.settings.max_acceleration_mm_per_s2[X_AXIS], public_buf_m, 10);
  79. break;
  80. case YAcceleration:
  81. itoa(planner.settings.max_acceleration_mm_per_s2[Y_AXIS], public_buf_m, 10);
  82. break;
  83. case ZAcceleration:
  84. itoa(planner.settings.max_acceleration_mm_per_s2[Z_AXIS], public_buf_m, 10);
  85. break;
  86. case E0Acceleration:
  87. itoa(planner.settings.max_acceleration_mm_per_s2[E_AXIS], public_buf_m, 10);
  88. break;
  89. case E1Acceleration:
  90. itoa(planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(1)], public_buf_m, 10);
  91. break;
  92. case XMaxFeedRate:
  93. dtostrf(planner.settings.max_feedrate_mm_s[X_AXIS], 1, 1, public_buf_m);
  94. break;
  95. case YMaxFeedRate:
  96. dtostrf(planner.settings.max_feedrate_mm_s[Y_AXIS], 1, 1, public_buf_m);
  97. break;
  98. case ZMaxFeedRate:
  99. dtostrf(planner.settings.max_feedrate_mm_s[Z_AXIS], 1, 1, public_buf_m);
  100. break;
  101. case E0MaxFeedRate:
  102. dtostrf(planner.settings.max_feedrate_mm_s[E_AXIS], 1, 1, public_buf_m);
  103. break;
  104. case E1MaxFeedRate:
  105. dtostrf(planner.settings.max_feedrate_mm_s[E_AXIS_N(1)], 1, 1, public_buf_m);
  106. break;
  107. case XJerk:
  108. #if HAS_CLASSIC_JERK
  109. dtostrf(planner.max_jerk[X_AXIS], 1, 1, public_buf_m);
  110. #endif
  111. break;
  112. case YJerk:
  113. #if HAS_CLASSIC_JERK
  114. dtostrf(planner.max_jerk[Y_AXIS], 1, 1, public_buf_m);
  115. #endif
  116. break;
  117. case ZJerk:
  118. #if HAS_CLASSIC_JERK
  119. dtostrf(planner.max_jerk[Z_AXIS], 1, 1, public_buf_m);
  120. #endif
  121. break;
  122. case EJerk:
  123. #if HAS_CLASSIC_JERK
  124. dtostrf(planner.max_jerk[E_AXIS], 1, 1, public_buf_m);
  125. #endif
  126. break;
  127. case Xstep:
  128. dtostrf(planner.settings.axis_steps_per_mm[X_AXIS], 1, 1, public_buf_m);
  129. break;
  130. case Ystep:
  131. dtostrf(planner.settings.axis_steps_per_mm[Y_AXIS], 1, 1, public_buf_m);
  132. break;
  133. case Zstep:
  134. dtostrf(planner.settings.axis_steps_per_mm[Z_AXIS], 1, 1, public_buf_m);
  135. break;
  136. case E0step:
  137. dtostrf(planner.settings.axis_steps_per_mm[E_AXIS], 1, 1, public_buf_m);
  138. break;
  139. case E1step:
  140. dtostrf(planner.settings.axis_steps_per_mm[E_AXIS_N(1)], 1, 1, public_buf_m);
  141. break;
  142. case Xcurrent:
  143. #if AXIS_IS_TMC(X)
  144. milliamps = stepperX.getMilliamps();
  145. dtostrf(milliamps, 1, 1, public_buf_m);
  146. #endif
  147. break;
  148. case Ycurrent:
  149. #if AXIS_IS_TMC(Y)
  150. milliamps = stepperY.getMilliamps();
  151. dtostrf(milliamps, 1, 1, public_buf_m);
  152. #endif
  153. break;
  154. case Zcurrent:
  155. #if AXIS_IS_TMC(Z)
  156. milliamps = stepperZ.getMilliamps();
  157. dtostrf(milliamps, 1, 1, public_buf_m);
  158. #endif
  159. break;
  160. case E0current:
  161. #if AXIS_IS_TMC(E0)
  162. milliamps = stepperE0.getMilliamps();
  163. dtostrf(milliamps, 1, 1, public_buf_m);
  164. #endif
  165. break;
  166. case E1current:
  167. #if AXIS_IS_TMC(E1)
  168. milliamps = stepperE1.getMilliamps();
  169. dtostrf(milliamps, 1, 1, public_buf_m);
  170. #endif
  171. break;
  172. case pause_pos_x:
  173. dtostrf(gCfgItems.pausePosX, 1, 1, public_buf_m);
  174. break;
  175. case pause_pos_y:
  176. dtostrf(gCfgItems.pausePosY, 1, 1, public_buf_m);
  177. break;
  178. case pause_pos_z:
  179. dtostrf(gCfgItems.pausePosZ, 1, 1, public_buf_m);
  180. break;
  181. case level_pos_x1:
  182. itoa(gCfgItems.trammingPos[0].x, public_buf_m, 10);
  183. break;
  184. case level_pos_y1:
  185. itoa(gCfgItems.trammingPos[0].y, public_buf_m, 10);
  186. break;
  187. case level_pos_x2:
  188. itoa(gCfgItems.trammingPos[1].x, public_buf_m, 10);
  189. break;
  190. case level_pos_y2:
  191. itoa(gCfgItems.trammingPos[1].y, public_buf_m, 10);
  192. break;
  193. case level_pos_x3:
  194. itoa(gCfgItems.trammingPos[2].x, public_buf_m, 10);
  195. break;
  196. case level_pos_y3:
  197. itoa(gCfgItems.trammingPos[2].y, public_buf_m, 10);
  198. break;
  199. case level_pos_x4:
  200. itoa(gCfgItems.trammingPos[3].x, public_buf_m, 10);
  201. break;
  202. case level_pos_y4:
  203. itoa(gCfgItems.trammingPos[3].y, public_buf_m, 10);
  204. break;
  205. case level_pos_x5:
  206. itoa(gCfgItems.trammingPos[4].x, public_buf_m, 10);
  207. break;
  208. case level_pos_y5:
  209. itoa(gCfgItems.trammingPos[4].y, public_buf_m, 10);
  210. break;
  211. #if HAS_BED_PROBE
  212. case x_offset:
  213. #if HAS_PROBE_XY_OFFSET
  214. dtostrf(probe.offset.x, 1, 3, public_buf_m);
  215. #endif
  216. break;
  217. case y_offset:
  218. #if HAS_PROBE_XY_OFFSET
  219. dtostrf(probe.offset.y, 1, 3, public_buf_m);
  220. #endif
  221. break;
  222. case z_offset:
  223. dtostrf(probe.offset.z, 1, 3, public_buf_m);
  224. break;
  225. #endif
  226. case load_length:
  227. itoa(gCfgItems.filamentchange_load_length, public_buf_m, 10);
  228. break;
  229. case load_speed:
  230. itoa(gCfgItems.filamentchange_load_speed, public_buf_m, 10);
  231. break;
  232. case unload_length:
  233. itoa(gCfgItems.filamentchange_unload_length, public_buf_m, 10);
  234. break;
  235. case unload_speed:
  236. itoa(gCfgItems.filamentchange_unload_speed, public_buf_m, 10);
  237. break;
  238. case filament_temp:
  239. itoa(gCfgItems.filament_limit_temp, public_buf_m, 10);
  240. break;
  241. case x_sensitivity:
  242. #if X_SENSORLESS
  243. itoa(TERN(X_SENSORLESS, stepperX.homing_threshold(), 0), public_buf_m, 10);
  244. #endif
  245. break;
  246. case y_sensitivity:
  247. #if Y_SENSORLESS
  248. itoa(TERN(Y_SENSORLESS, stepperY.homing_threshold(), 0), public_buf_m, 10);
  249. #endif
  250. break;
  251. case z_sensitivity:
  252. #if Z_SENSORLESS
  253. itoa(TERN(Z_SENSORLESS, stepperZ.homing_threshold(), 0), public_buf_m, 10);
  254. #endif
  255. break;
  256. case z2_sensitivity:
  257. #if Z2_SENSORLESS
  258. itoa(TERN(Z2_SENSORLESS, stepperZ2.homing_threshold(), 0), public_buf_m, 10);
  259. #endif
  260. break;
  261. }
  262. strcpy(key_value, public_buf_m);
  263. cnt = strlen(key_value);
  264. temp = strchr(key_value, '.');
  265. point_flag = !temp;
  266. lv_label_set_text(labelValue, key_value);
  267. lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
  268. }
  269. static void set_value_confirm() {
  270. switch (value) {
  271. case PrintAcceleration: planner.settings.acceleration = atof(key_value); break;
  272. case RetractAcceleration: planner.settings.retract_acceleration = atof(key_value); break;
  273. case TravelAcceleration: planner.settings.travel_acceleration = atof(key_value); break;
  274. case XAcceleration: planner.settings.max_acceleration_mm_per_s2[X_AXIS] = atof(key_value); break;
  275. case YAcceleration: planner.settings.max_acceleration_mm_per_s2[Y_AXIS] = atof(key_value); break;
  276. case ZAcceleration: planner.settings.max_acceleration_mm_per_s2[Z_AXIS] = atof(key_value); break;
  277. case E0Acceleration: planner.settings.max_acceleration_mm_per_s2[E_AXIS] = atof(key_value); break;
  278. case E1Acceleration: planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(1)] = atof(key_value); break;
  279. case XMaxFeedRate: planner.settings.max_feedrate_mm_s[X_AXIS] = atof(key_value); break;
  280. case YMaxFeedRate: planner.settings.max_feedrate_mm_s[Y_AXIS] = atof(key_value); break;
  281. case ZMaxFeedRate: planner.settings.max_feedrate_mm_s[Z_AXIS] = atof(key_value); break;
  282. case E0MaxFeedRate: planner.settings.max_feedrate_mm_s[E_AXIS] = atof(key_value); break;
  283. case E1MaxFeedRate: planner.settings.max_feedrate_mm_s[E_AXIS_N(1)] = atof(key_value); break;
  284. case XJerk: TERN_(HAS_CLASSIC_JERK, planner.max_jerk[X_AXIS] = atof(key_value)); break;
  285. case YJerk: TERN_(HAS_CLASSIC_JERK, planner.max_jerk[Y_AXIS] = atof(key_value)); break;
  286. case ZJerk: TERN_(HAS_CLASSIC_JERK, planner.max_jerk[Z_AXIS] = atof(key_value)); break;
  287. case EJerk: TERN_(HAS_CLASSIC_JERK, planner.max_jerk[E_AXIS] = atof(key_value)); break;
  288. case Xstep: planner.settings.axis_steps_per_mm[X_AXIS] = atof(key_value); planner.refresh_positioning(); break;
  289. case Ystep: planner.settings.axis_steps_per_mm[Y_AXIS] = atof(key_value); planner.refresh_positioning(); break;
  290. case Zstep: planner.settings.axis_steps_per_mm[Z_AXIS] = atof(key_value); planner.refresh_positioning(); break;
  291. case E0step: planner.settings.axis_steps_per_mm[E_AXIS] = atof(key_value); planner.refresh_positioning(); break;
  292. case E1step: planner.settings.axis_steps_per_mm[E_AXIS_N(1)] = atof(key_value); planner.refresh_positioning(); break;
  293. case Xcurrent:
  294. #if AXIS_IS_TMC(X)
  295. stepperX.rms_current(atoi(key_value));
  296. #endif
  297. break;
  298. case Ycurrent:
  299. #if AXIS_IS_TMC(Y)
  300. stepperY.rms_current(atoi(key_value));
  301. #endif
  302. break;
  303. case Zcurrent:
  304. #if AXIS_IS_TMC(Z)
  305. stepperZ.rms_current(atoi(key_value));
  306. #endif
  307. break;
  308. case E0current:
  309. #if AXIS_IS_TMC(E0)
  310. stepperE0.rms_current(atoi(key_value));
  311. #endif
  312. break;
  313. case E1current:
  314. #if AXIS_IS_TMC(E1)
  315. stepperE1.rms_current(atoi(key_value));
  316. #endif
  317. break;
  318. case pause_pos_x: gCfgItems.pausePosX = atof(key_value); update_spi_flash(); break;
  319. case pause_pos_y: gCfgItems.pausePosY = atof(key_value); update_spi_flash(); break;
  320. case pause_pos_z: gCfgItems.pausePosZ = atof(key_value); update_spi_flash(); break;
  321. case level_pos_x1: gCfgItems.trammingPos[0].x = atoi(key_value); update_spi_flash(); break;
  322. case level_pos_y1: gCfgItems.trammingPos[0].y = atoi(key_value); update_spi_flash(); break;
  323. case level_pos_x2: gCfgItems.trammingPos[1].x = atoi(key_value); update_spi_flash(); break;
  324. case level_pos_y2: gCfgItems.trammingPos[1].y = atoi(key_value); update_spi_flash(); break;
  325. case level_pos_x3: gCfgItems.trammingPos[2].x = atoi(key_value); update_spi_flash(); break;
  326. case level_pos_y3: gCfgItems.trammingPos[2].y = atoi(key_value); update_spi_flash(); break;
  327. case level_pos_x4: gCfgItems.trammingPos[3].x = atoi(key_value); update_spi_flash(); break;
  328. case level_pos_y4: gCfgItems.trammingPos[3].y = atoi(key_value); update_spi_flash(); break;
  329. case level_pos_x5: gCfgItems.trammingPos[4].x = atoi(key_value); update_spi_flash(); break;
  330. case level_pos_y5: gCfgItems.trammingPos[4].y = atoi(key_value); update_spi_flash(); break;
  331. #if HAS_BED_PROBE
  332. case x_offset: {
  333. #if HAS_PROBE_XY_OFFSET
  334. const float x = atof(key_value);
  335. if (WITHIN(x, -(X_BED_SIZE), X_BED_SIZE))
  336. probe.offset.x = x;
  337. #endif
  338. } break;
  339. case y_offset: {
  340. #if HAS_PROBE_XY_OFFSET
  341. const float y = atof(key_value);
  342. if (WITHIN(y, -(Y_BED_SIZE), Y_BED_SIZE))
  343. probe.offset.y = y;
  344. #endif
  345. } break;
  346. case z_offset: {
  347. const float z = atof(key_value);
  348. if (WITHIN(z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX))
  349. probe.offset.z = z;
  350. } break;
  351. #endif
  352. case load_length:
  353. gCfgItems.filamentchange_load_length = atoi(key_value);
  354. uiCfg.filament_loading_time = (uint32_t)((gCfgItems.filamentchange_load_length*60.0/gCfgItems.filamentchange_load_speed)+0.5);
  355. update_spi_flash();
  356. break;
  357. case load_speed:
  358. gCfgItems.filamentchange_load_speed = atoi(key_value);
  359. uiCfg.filament_loading_time = (uint32_t)((gCfgItems.filamentchange_load_length*60.0/gCfgItems.filamentchange_load_speed)+0.5);
  360. update_spi_flash();
  361. break;
  362. case unload_length:
  363. gCfgItems.filamentchange_unload_length = atoi(key_value);
  364. uiCfg.filament_unloading_time = (uint32_t)((gCfgItems.filamentchange_unload_length*60.0/gCfgItems.filamentchange_unload_speed)+0.5);
  365. update_spi_flash();
  366. break;
  367. case unload_speed:
  368. gCfgItems.filamentchange_unload_speed = atoi(key_value);
  369. uiCfg.filament_unloading_time = (uint32_t)((gCfgItems.filamentchange_unload_length*60.0/gCfgItems.filamentchange_unload_speed)+0.5);
  370. update_spi_flash();
  371. break;
  372. case filament_temp:
  373. gCfgItems.filament_limit_temp = atoi(key_value);
  374. update_spi_flash();
  375. break;
  376. case x_sensitivity: TERN_(X_SENSORLESS, stepperX.homing_threshold(atoi(key_value))); break;
  377. case y_sensitivity: TERN_(Y_SENSORLESS, stepperY.homing_threshold(atoi(key_value))); break;
  378. case z_sensitivity: TERN_(Z_SENSORLESS, stepperZ.homing_threshold(atoi(key_value))); break;
  379. case z2_sensitivity: TERN_(Z2_SENSORLESS, stepperZ2.homing_threshold(atoi(key_value))); break;
  380. }
  381. gcode.process_subcommands_now(F("M500"));
  382. }
  383. static void event_handler(lv_obj_t *obj, lv_event_t event) {
  384. if (event != LV_EVENT_RELEASED) return;
  385. switch (obj->mks_obj_id) {
  386. case ID_NUM_KEY1 ... ID_NUM_KEY0:
  387. if (cnt <= 10) {
  388. key_value[cnt] = (obj->mks_obj_id == ID_NUM_KEY0) ? (char)'0' : char('1' + obj->mks_obj_id - ID_NUM_KEY1);
  389. lv_label_set_text(labelValue, key_value);
  390. lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
  391. cnt++;
  392. }
  393. break;
  394. case ID_NUM_BACK:
  395. if (cnt > 0) cnt--;
  396. if (key_value[cnt] == (char)'.') point_flag = true;
  397. key_value[cnt] = (char)'\0';
  398. lv_label_set_text(labelValue, key_value);
  399. lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
  400. break;
  401. case ID_NUM_RESET:
  402. ZERO(key_value);
  403. cnt = 0;
  404. key_value[cnt] = (char)'0';
  405. point_flag = true;
  406. lv_label_set_text(labelValue, key_value);
  407. lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
  408. break;
  409. case ID_NUM_POINT:
  410. if (cnt != 0 && point_flag) {
  411. point_flag = false;
  412. key_value[cnt] = (char)'.';
  413. lv_label_set_text(labelValue, key_value);
  414. lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
  415. cnt++;
  416. }
  417. break;
  418. case ID_NUM_NEGATIVE:
  419. if (cnt == 0) {
  420. key_value[cnt] = (char)'-';
  421. lv_label_set_text(labelValue, key_value);
  422. lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
  423. cnt++;
  424. }
  425. break;
  426. case ID_NUM_CONFIRM:
  427. last_disp_state = NUMBER_KEY_UI;
  428. if (strlen(key_value) != 0) set_value_confirm();
  429. goto_previous_ui();
  430. break;
  431. }
  432. }
  433. void lv_draw_number_key() {
  434. scr = lv_screen_create(NUMBER_KEY_UI, "");
  435. buttonValue = lv_btn_create(scr, 92, 40, 296, 40, event_handler, ID_NUM_KEY1, &style_num_text);
  436. labelValue = lv_label_create_empty(buttonValue);
  437. #define DRAW_NUMBER_KEY(N,X,Y) \
  438. lv_obj_t *NumberKey_##N = lv_btn_create(scr, X, Y, 68, 40, event_handler, ID_NUM_KEY##N, &style_num_key_pre); \
  439. lv_obj_t *labelKey_##N = lv_label_create_empty(NumberKey_##N); \
  440. lv_label_set_text(labelKey_##N, machine_menu.key_##N); \
  441. lv_obj_align(labelKey_##N, NumberKey_##N, LV_ALIGN_CENTER, 0, 0)
  442. DRAW_NUMBER_KEY(1, 92, 90);
  443. DRAW_NUMBER_KEY(2, 168, 90);
  444. DRAW_NUMBER_KEY(3, 244, 90);
  445. DRAW_NUMBER_KEY(4, 92, 140);
  446. DRAW_NUMBER_KEY(5, 168, 140);
  447. DRAW_NUMBER_KEY(6, 244, 140);
  448. DRAW_NUMBER_KEY(7, 92, 190);
  449. DRAW_NUMBER_KEY(8, 168, 190);
  450. DRAW_NUMBER_KEY(9, 244, 190);
  451. DRAW_NUMBER_KEY(0, 92, 240);
  452. lv_obj_t *KeyBack = lv_btn_create(scr, 320, 90, 68, 40, event_handler, ID_NUM_BACK, &style_num_key_pre);
  453. lv_obj_t *labelKeyBack = lv_label_create_empty(KeyBack);
  454. lv_label_set_text(labelKeyBack, machine_menu.key_back);
  455. lv_obj_align(labelKeyBack, KeyBack, LV_ALIGN_CENTER, 0, 0);
  456. lv_obj_t *KeyReset = lv_btn_create(scr, 320, 140, 68, 40, event_handler, ID_NUM_RESET, &style_num_key_pre);
  457. lv_obj_t *labelKeyReset = lv_label_create_empty(KeyReset);
  458. lv_label_set_text(labelKeyReset, machine_menu.key_reset);
  459. lv_obj_align(labelKeyReset, KeyReset, LV_ALIGN_CENTER, 0, 0);
  460. lv_obj_t *KeyConfirm = lv_btn_create(scr, 320, 190, 68, 90, event_handler, ID_NUM_CONFIRM, &style_num_key_pre);
  461. lv_obj_t *labelKeyConfirm = lv_label_create_empty(KeyConfirm);
  462. lv_label_set_text(labelKeyConfirm, machine_menu.key_confirm);
  463. lv_obj_align(labelKeyConfirm, KeyConfirm, LV_ALIGN_CENTER, 0, 0);
  464. lv_obj_t *KeyPoint = lv_btn_create(scr, 244, 240, 68, 40, event_handler, ID_NUM_POINT, &style_num_key_pre);
  465. lv_obj_t *labelKeyPoint = lv_label_create_empty(KeyPoint);
  466. lv_label_set_text(labelKeyPoint, machine_menu.key_point);
  467. lv_obj_align(labelKeyPoint, KeyPoint, LV_ALIGN_CENTER, 0, 0);
  468. lv_obj_t *Minus = lv_btn_create(scr, 168, 240, 68, 40, event_handler, ID_NUM_NEGATIVE, &style_num_key_pre);
  469. lv_obj_t *labelMinus = lv_label_create_empty(Minus);
  470. lv_label_set_text(labelMinus, machine_menu.negative);
  471. lv_obj_align(labelMinus, Minus, LV_ALIGN_CENTER, 0, 0);
  472. #if HAS_ROTARY_ENCODER
  473. if (gCfgItems.encoder_enable) {
  474. lv_group_add_obj(g, NumberKey_1);
  475. lv_group_add_obj(g, NumberKey_2);
  476. lv_group_add_obj(g, NumberKey_3);
  477. lv_group_add_obj(g, KeyBack);
  478. lv_group_add_obj(g, NumberKey_4);
  479. lv_group_add_obj(g, NumberKey_5);
  480. lv_group_add_obj(g, NumberKey_6);
  481. lv_group_add_obj(g, KeyReset);
  482. lv_group_add_obj(g, NumberKey_7);
  483. lv_group_add_obj(g, NumberKey_8);
  484. lv_group_add_obj(g, NumberKey_9);
  485. lv_group_add_obj(g, NumberKey_0);
  486. lv_group_add_obj(g, Minus);
  487. lv_group_add_obj(g, KeyPoint);
  488. lv_group_add_obj(g, KeyConfirm);
  489. }
  490. #endif
  491. disp_key_value();
  492. }
  493. void lv_clear_number_key() {
  494. #if HAS_ROTARY_ENCODER
  495. if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
  496. #endif
  497. lv_obj_del(scr);
  498. }
  499. #endif // HAS_TFT_LVGL_UI