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.

ultralcd.cpp 31KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073
  1. #include "temperature.h"
  2. #include "ultralcd.h"
  3. #ifdef ULTRA_LCD
  4. #include "Marlin.h"
  5. #include "language.h"
  6. #include "cardreader.h"
  7. #include "temperature.h"
  8. #include "stepper.h"
  9. #include "ConfigurationStore.h"
  10. /* Configuration settings */
  11. int plaPreheatHotendTemp;
  12. int plaPreheatHPBTemp;
  13. int plaPreheatFanSpeed;
  14. int absPreheatHotendTemp;
  15. int absPreheatHPBTemp;
  16. int absPreheatFanSpeed;
  17. /* !Configuration settings */
  18. //Function pointer to menu functions.
  19. typedef void (*menuFunc_t)();
  20. uint8_t lcd_status_message_level;
  21. char lcd_status_message[LCD_WIDTH+1] = WELCOME_MSG;
  22. #ifdef DOGLCD
  23. #include "dogm_lcd_implementation.h"
  24. #else
  25. #include "ultralcd_implementation_hitachi_HD44780.h"
  26. #endif
  27. /** forward declerations **/
  28. /* Different menus */
  29. static void lcd_status_screen();
  30. #ifdef ULTIPANEL
  31. static void lcd_main_menu();
  32. static void lcd_tune_menu();
  33. static void lcd_prepare_menu();
  34. static void lcd_move_menu();
  35. static void lcd_control_menu();
  36. static void lcd_control_temperature_menu();
  37. static void lcd_control_temperature_preheat_pla_settings_menu();
  38. static void lcd_control_temperature_preheat_abs_settings_menu();
  39. static void lcd_control_motion_menu();
  40. static void lcd_control_retract_menu();
  41. static void lcd_sdcard_menu();
  42. static void lcd_quick_feedback();//Cause an LCD refresh, and give the user visual or audiable feedback that something has happend
  43. /* Different types of actions that can be used in menuitems. */
  44. static void menu_action_back(menuFunc_t data);
  45. static void menu_action_submenu(menuFunc_t data);
  46. static void menu_action_gcode(const char* pgcode);
  47. static void menu_action_function(menuFunc_t data);
  48. static void menu_action_sdfile(const char* filename, char* longFilename);
  49. static void menu_action_sddirectory(const char* filename, char* longFilename);
  50. static void menu_action_setting_edit_bool(const char* pstr, bool* ptr);
  51. static void menu_action_setting_edit_int3(const char* pstr, int* ptr, int minValue, int maxValue);
  52. static void menu_action_setting_edit_float3(const char* pstr, float* ptr, float minValue, float maxValue);
  53. static void menu_action_setting_edit_float32(const char* pstr, float* ptr, float minValue, float maxValue);
  54. static void menu_action_setting_edit_float5(const char* pstr, float* ptr, float minValue, float maxValue);
  55. static void menu_action_setting_edit_float51(const char* pstr, float* ptr, float minValue, float maxValue);
  56. static void menu_action_setting_edit_float52(const char* pstr, float* ptr, float minValue, float maxValue);
  57. static void menu_action_setting_edit_long5(const char* pstr, unsigned long* ptr, unsigned long minValue, unsigned long maxValue);
  58. #define ENCODER_STEPS_PER_MENU_ITEM 5
  59. /* Helper macros for menus */
  60. #define START_MENU() do { \
  61. if (encoderPosition > 0x8000) encoderPosition = 0; \
  62. if (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM < currentMenuViewOffset) currentMenuViewOffset = encoderPosition / ENCODER_STEPS_PER_MENU_ITEM;\
  63. uint8_t _lineNr = currentMenuViewOffset, _menuItemNr; \
  64. for(uint8_t _drawLineNr = 0; _drawLineNr < LCD_HEIGHT; _drawLineNr++, _lineNr++) { \
  65. _menuItemNr = 0;
  66. #define MENU_ITEM(type, label, args...) do { \
  67. if (_menuItemNr == _lineNr) { \
  68. if (lcdDrawUpdate) { \
  69. const char* _label_pstr = PSTR(label); \
  70. if ((encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) == _menuItemNr) { \
  71. lcd_implementation_drawmenu_ ## type ## _selected (_drawLineNr, _label_pstr , ## args ); \
  72. }else{\
  73. lcd_implementation_drawmenu_ ## type (_drawLineNr, _label_pstr , ## args ); \
  74. }\
  75. }\
  76. if (LCD_CLICKED && (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) == _menuItemNr) {\
  77. lcd_quick_feedback(); \
  78. menu_action_ ## type ( args ); \
  79. return;\
  80. }\
  81. }\
  82. _menuItemNr++;\
  83. } while(0)
  84. #define MENU_ITEM_DUMMY() do { _menuItemNr++; } while(0)
  85. #define MENU_ITEM_EDIT(type, label, args...) MENU_ITEM(setting_edit_ ## type, label, PSTR(label) , ## args )
  86. #define END_MENU() \
  87. if (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM >= _menuItemNr) encoderPosition = _menuItemNr * ENCODER_STEPS_PER_MENU_ITEM - 1; \
  88. if ((uint8_t)(encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) >= currentMenuViewOffset + LCD_HEIGHT) { currentMenuViewOffset = (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) - LCD_HEIGHT + 1; lcdDrawUpdate = 1; _lineNr = currentMenuViewOffset - 1; _drawLineNr = -1; } \
  89. } } while(0)
  90. /** Used variables to keep track of the menu */
  91. volatile uint8_t buttons;//Contains the bits of the currently pressed buttons.
  92. uint8_t currentMenuViewOffset; /* scroll offset in the current menu */
  93. uint32_t blocking_enc;
  94. uint8_t lastEncoderBits;
  95. int8_t encoderDiff; /* encoderDiff is updated from interrupt context and added to encoderPosition every LCD update */
  96. uint32_t encoderPosition;
  97. #if (SDCARDDETECT > -1)
  98. bool lcd_oldcardstatus;
  99. #endif
  100. #endif//ULTIPANEL
  101. menuFunc_t currentMenu = lcd_status_screen; /* function pointer to the currently active menu */
  102. uint32_t lcd_next_update_millis;
  103. uint8_t lcd_status_update_delay;
  104. uint8_t lcdDrawUpdate = 2; /* Set to none-zero when the LCD needs to draw, decreased after every draw. Set to 2 in LCD routines so the LCD gets atleast 1 full redraw (first redraw is partial) */
  105. //prevMenu and prevEncoderPosition are used to store the previous menu location when editing settings.
  106. menuFunc_t prevMenu = NULL;
  107. uint16_t prevEncoderPosition;
  108. //Variables used when editing values.
  109. const char* editLabel;
  110. void* editValue;
  111. int32_t minEditValue, maxEditValue;
  112. /* Main status screen. It's up to the implementation specific part to show what is needed. As this is very display dependend */
  113. static void lcd_status_screen()
  114. {
  115. if (lcd_status_update_delay)
  116. lcd_status_update_delay--;
  117. else
  118. lcdDrawUpdate = 1;
  119. if (lcdDrawUpdate)
  120. {
  121. lcd_implementation_status_screen();
  122. lcd_status_update_delay = 10; /* redraw the main screen every second. This is easier then trying keep track of all things that change on the screen */
  123. }
  124. #ifdef ULTIPANEL
  125. if (LCD_CLICKED)
  126. {
  127. currentMenu = lcd_main_menu;
  128. lcd_quick_feedback();
  129. }
  130. feedmultiply += int(encoderPosition);
  131. encoderPosition = 0;
  132. if (feedmultiply < 10)
  133. feedmultiply = 10;
  134. if (feedmultiply > 999)
  135. feedmultiply = 999;
  136. #endif//ULTIPANEL
  137. }
  138. #ifdef ULTIPANEL
  139. static void lcd_return_to_status()
  140. {
  141. encoderPosition = 0;
  142. currentMenu = lcd_status_screen;
  143. }
  144. static void lcd_sdcard_pause()
  145. {
  146. card.pauseSDPrint();
  147. }
  148. static void lcd_sdcard_resume()
  149. {
  150. card.startFileprint();
  151. }
  152. static void lcd_sdcard_stop()
  153. {
  154. card.sdprinting = false;
  155. card.closefile();
  156. quickStop();
  157. if(SD_FINISHED_STEPPERRELEASE)
  158. {
  159. enquecommand_P(PSTR(SD_FINISHED_RELEASECOMMAND));
  160. }
  161. autotempShutdown();
  162. }
  163. /* Menu implementation */
  164. static void lcd_main_menu()
  165. {
  166. START_MENU();
  167. MENU_ITEM(back, MSG_WATCH, lcd_status_screen);
  168. if (movesplanned() || IS_SD_PRINTING)
  169. {
  170. MENU_ITEM(submenu, MSG_TUNE, lcd_tune_menu);
  171. }else{
  172. MENU_ITEM(submenu, MSG_PREPARE, lcd_prepare_menu);
  173. }
  174. MENU_ITEM(submenu, MSG_CONTROL, lcd_control_menu);
  175. #ifdef SDSUPPORT
  176. if (card.cardOK)
  177. {
  178. if (card.isFileOpen())
  179. {
  180. if (card.sdprinting)
  181. MENU_ITEM(function, MSG_PAUSE_PRINT, lcd_sdcard_pause);
  182. else
  183. MENU_ITEM(function, MSG_RESUME_PRINT, lcd_sdcard_resume);
  184. MENU_ITEM(function, MSG_STOP_PRINT, lcd_sdcard_stop);
  185. }else{
  186. MENU_ITEM(submenu, MSG_CARD_MENU, lcd_sdcard_menu);
  187. #if SDCARDDETECT < 1
  188. MENU_ITEM(gcode, MSG_CNG_SDCARD, PSTR("M21")); // SD-card changed by user
  189. #endif
  190. }
  191. }else{
  192. MENU_ITEM(submenu, MSG_NO_CARD, lcd_sdcard_menu);
  193. #if SDCARDDETECT < 1
  194. MENU_ITEM(gcode, MSG_INIT_SDCARD, PSTR("M21")); // Manually initialize the SD-card via user interface
  195. #endif
  196. }
  197. #endif
  198. END_MENU();
  199. }
  200. #ifdef SDSUPPORT
  201. static void lcd_autostart_sd()
  202. {
  203. card.lastnr=0;
  204. card.setroot();
  205. card.checkautostart(true);
  206. }
  207. #endif
  208. void lcd_preheat_pla()
  209. {
  210. setTargetHotend0(plaPreheatHotendTemp);
  211. setTargetHotend1(plaPreheatHotendTemp);
  212. setTargetHotend2(plaPreheatHotendTemp);
  213. setTargetBed(plaPreheatHPBTemp);
  214. fanSpeed = plaPreheatFanSpeed;
  215. lcd_return_to_status();
  216. }
  217. void lcd_preheat_abs()
  218. {
  219. setTargetHotend0(absPreheatHotendTemp);
  220. setTargetHotend1(absPreheatHotendTemp);
  221. setTargetHotend2(absPreheatHotendTemp);
  222. setTargetBed(absPreheatHPBTemp);
  223. fanSpeed = absPreheatFanSpeed;
  224. lcd_return_to_status();
  225. }
  226. static void lcd_tune_menu()
  227. {
  228. START_MENU();
  229. MENU_ITEM(back, MSG_MAIN, lcd_main_menu);
  230. MENU_ITEM_EDIT(int3, MSG_SPEED, &feedmultiply, 10, 999);
  231. MENU_ITEM_EDIT(int3, MSG_NOZZLE, &target_temperature[0], 0, HEATER_0_MAXTEMP - 15);
  232. #if TEMP_SENSOR_1 != 0
  233. MENU_ITEM_EDIT(int3, MSG_NOZZLE1, &target_temperature[1], 0, HEATER_1_MAXTEMP - 15);
  234. #endif
  235. #if TEMP_SENSOR_2 != 0
  236. MENU_ITEM_EDIT(int3, MSG_NOZZLE2, &target_temperature[2], 0, HEATER_2_MAXTEMP - 15);
  237. #endif
  238. #if TEMP_SENSOR_BED != 0
  239. MENU_ITEM_EDIT(int3, MSG_BED, &target_temperature_bed, 0, BED_MAXTEMP - 15);
  240. #endif
  241. MENU_ITEM_EDIT(int3, MSG_FAN_SPEED, &fanSpeed, 0, 255);
  242. MENU_ITEM_EDIT(int3, MSG_FLOW, &extrudemultiply, 10, 999);
  243. #ifdef FILAMENTCHANGEENABLE
  244. MENU_ITEM(gcode, MSG_FILAMENTCHANGE, PSTR("M600"));
  245. #endif
  246. END_MENU();
  247. }
  248. static void lcd_prepare_menu()
  249. {
  250. START_MENU();
  251. MENU_ITEM(back, MSG_MAIN, lcd_main_menu);
  252. #ifdef SDSUPPORT
  253. //MENU_ITEM(function, MSG_AUTOSTART, lcd_autostart_sd);
  254. #endif
  255. MENU_ITEM(gcode, MSG_DISABLE_STEPPERS, PSTR("M84"));
  256. MENU_ITEM(gcode, MSG_AUTO_HOME, PSTR("G28"));
  257. //MENU_ITEM(gcode, MSG_SET_ORIGIN, PSTR("G92 X0 Y0 Z0"));
  258. MENU_ITEM(function, MSG_PREHEAT_PLA, lcd_preheat_pla);
  259. MENU_ITEM(function, MSG_PREHEAT_ABS, lcd_preheat_abs);
  260. MENU_ITEM(gcode, MSG_COOLDOWN, PSTR("M104 S0\nM140 S0"));
  261. MENU_ITEM(submenu, MSG_MOVE_AXIS, lcd_move_menu);
  262. END_MENU();
  263. }
  264. float move_menu_scale;
  265. static void lcd_move_menu_axis();
  266. static void lcd_move_x()
  267. {
  268. if (encoderPosition != 0)
  269. {
  270. current_position[X_AXIS] += float((int)encoderPosition) * move_menu_scale;
  271. if (current_position[X_AXIS] < X_MIN_POS)
  272. current_position[X_AXIS] = X_MIN_POS;
  273. if (current_position[X_AXIS] > X_MAX_POS)
  274. current_position[X_AXIS] = X_MAX_POS;
  275. encoderPosition = 0;
  276. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 600, active_extruder);
  277. lcdDrawUpdate = 1;
  278. }
  279. if (lcdDrawUpdate)
  280. {
  281. lcd_implementation_drawedit(PSTR("X"), ftostr31(current_position[X_AXIS]));
  282. }
  283. if (LCD_CLICKED)
  284. {
  285. lcd_quick_feedback();
  286. currentMenu = lcd_move_menu_axis;
  287. encoderPosition = 0;
  288. }
  289. }
  290. static void lcd_move_y()
  291. {
  292. if (encoderPosition != 0)
  293. {
  294. current_position[Y_AXIS] += float((int)encoderPosition) * move_menu_scale;
  295. if (current_position[Y_AXIS] < Y_MIN_POS)
  296. current_position[Y_AXIS] = Y_MIN_POS;
  297. if (current_position[Y_AXIS] > Y_MAX_POS)
  298. current_position[Y_AXIS] = Y_MAX_POS;
  299. encoderPosition = 0;
  300. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 600, active_extruder);
  301. lcdDrawUpdate = 1;
  302. }
  303. if (lcdDrawUpdate)
  304. {
  305. lcd_implementation_drawedit(PSTR("Y"), ftostr31(current_position[Y_AXIS]));
  306. }
  307. if (LCD_CLICKED)
  308. {
  309. lcd_quick_feedback();
  310. currentMenu = lcd_move_menu_axis;
  311. encoderPosition = 0;
  312. }
  313. }
  314. static void lcd_move_z()
  315. {
  316. if (encoderPosition != 0)
  317. {
  318. current_position[Z_AXIS] += float((int)encoderPosition) * move_menu_scale;
  319. if (current_position[Z_AXIS] < Z_MIN_POS)
  320. current_position[Z_AXIS] = Z_MIN_POS;
  321. if (current_position[Z_AXIS] > Z_MAX_POS)
  322. current_position[Z_AXIS] = Z_MAX_POS;
  323. encoderPosition = 0;
  324. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 60, active_extruder);
  325. lcdDrawUpdate = 1;
  326. }
  327. if (lcdDrawUpdate)
  328. {
  329. lcd_implementation_drawedit(PSTR("Z"), ftostr31(current_position[Z_AXIS]));
  330. }
  331. if (LCD_CLICKED)
  332. {
  333. lcd_quick_feedback();
  334. currentMenu = lcd_move_menu_axis;
  335. encoderPosition = 0;
  336. }
  337. }
  338. static void lcd_move_e()
  339. {
  340. if (encoderPosition != 0)
  341. {
  342. current_position[E_AXIS] += float((int)encoderPosition) * move_menu_scale;
  343. encoderPosition = 0;
  344. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 20, active_extruder);
  345. lcdDrawUpdate = 1;
  346. }
  347. if (lcdDrawUpdate)
  348. {
  349. lcd_implementation_drawedit(PSTR("Extruder"), ftostr31(current_position[E_AXIS]));
  350. }
  351. if (LCD_CLICKED)
  352. {
  353. lcd_quick_feedback();
  354. currentMenu = lcd_move_menu_axis;
  355. encoderPosition = 0;
  356. }
  357. }
  358. static void lcd_move_menu_axis()
  359. {
  360. START_MENU();
  361. MENU_ITEM(back, MSG_MOVE_AXIS, lcd_move_menu);
  362. MENU_ITEM(submenu, "Move X", lcd_move_x);
  363. MENU_ITEM(submenu, "Move Y", lcd_move_y);
  364. if (move_menu_scale < 10.0)
  365. {
  366. MENU_ITEM(submenu, "Move Z", lcd_move_z);
  367. MENU_ITEM(submenu, "Extruder", lcd_move_e);
  368. }
  369. END_MENU();
  370. }
  371. static void lcd_move_menu_10mm()
  372. {
  373. move_menu_scale = 10.0;
  374. lcd_move_menu_axis();
  375. }
  376. static void lcd_move_menu_1mm()
  377. {
  378. move_menu_scale = 1.0;
  379. lcd_move_menu_axis();
  380. }
  381. static void lcd_move_menu_01mm()
  382. {
  383. move_menu_scale = 0.1;
  384. lcd_move_menu_axis();
  385. }
  386. static void lcd_move_menu()
  387. {
  388. START_MENU();
  389. MENU_ITEM(back, MSG_PREPARE, lcd_prepare_menu);
  390. MENU_ITEM(submenu, "Move 10mm", lcd_move_menu_10mm);
  391. MENU_ITEM(submenu, "Move 1mm", lcd_move_menu_1mm);
  392. MENU_ITEM(submenu, "Move 0.1mm", lcd_move_menu_01mm);
  393. //TODO:X,Y,Z,E
  394. END_MENU();
  395. }
  396. static void lcd_control_menu()
  397. {
  398. START_MENU();
  399. MENU_ITEM(back, MSG_MAIN, lcd_main_menu);
  400. MENU_ITEM(submenu, MSG_TEMPERATURE, lcd_control_temperature_menu);
  401. MENU_ITEM(submenu, MSG_MOTION, lcd_control_motion_menu);
  402. #ifdef FWRETRACT
  403. MENU_ITEM(submenu, MSG_RETRACT, lcd_control_retract_menu);
  404. #endif
  405. #ifdef EEPROM_SETTINGS
  406. MENU_ITEM(function, MSG_STORE_EPROM, Config_StoreSettings);
  407. MENU_ITEM(function, MSG_LOAD_EPROM, Config_RetrieveSettings);
  408. #endif
  409. MENU_ITEM(function, MSG_RESTORE_FAILSAFE, Config_ResetDefault);
  410. END_MENU();
  411. }
  412. static void lcd_control_temperature_menu()
  413. {
  414. START_MENU();
  415. MENU_ITEM(back, MSG_CONTROL, lcd_control_menu);
  416. MENU_ITEM_EDIT(int3, MSG_NOZZLE, &target_temperature[0], 0, HEATER_0_MAXTEMP - 15);
  417. #if TEMP_SENSOR_1 != 0
  418. MENU_ITEM_EDIT(int3, MSG_NOZZLE1, &target_temperature[1], 0, HEATER_1_MAXTEMP - 15);
  419. #endif
  420. #if TEMP_SENSOR_2 != 0
  421. MENU_ITEM_EDIT(int3, MSG_NOZZLE2, &target_temperature[2], 0, HEATER_2_MAXTEMP - 15);
  422. #endif
  423. #if TEMP_SENSOR_BED != 0
  424. MENU_ITEM_EDIT(int3, MSG_BED, &target_temperature_bed, 0, BED_MAXTEMP - 15);
  425. #endif
  426. MENU_ITEM_EDIT(int3, MSG_FAN_SPEED, &fanSpeed, 0, 255);
  427. #ifdef AUTOTEMP
  428. MENU_ITEM_EDIT(bool, MSG_AUTOTEMP, &autotemp_enabled);
  429. MENU_ITEM_EDIT(float3, MSG_MIN, &autotemp_min, 0, HEATER_0_MAXTEMP - 15);
  430. MENU_ITEM_EDIT(float3, MSG_MAX, &autotemp_max, 0, HEATER_0_MAXTEMP - 15);
  431. MENU_ITEM_EDIT(float32, MSG_FACTOR, &autotemp_factor, 0.0, 1.0);
  432. #endif
  433. #ifdef PIDTEMP
  434. MENU_ITEM_EDIT(float52, MSG_PID_P, &Kp, 1, 9990);
  435. //TODO, I and D should have a PID_dT multiplier (Ki = PID_I * PID_dT, Kd = PID_D / PID_dT)
  436. MENU_ITEM_EDIT(float52, MSG_PID_I, &Ki, 1, 9990);
  437. MENU_ITEM_EDIT(float52, MSG_PID_D, &Kd, 1, 9990);
  438. # ifdef PID_ADD_EXTRUSION_RATE
  439. MENU_ITEM_EDIT(float3, MSG_PID_C, &Kc, 1, 9990);
  440. # endif//PID_ADD_EXTRUSION_RATE
  441. #endif//PIDTEMP
  442. MENU_ITEM(submenu, MSG_PREHEAT_PLA_SETTINGS, lcd_control_temperature_preheat_pla_settings_menu);
  443. MENU_ITEM(submenu, MSG_PREHEAT_ABS_SETTINGS, lcd_control_temperature_preheat_abs_settings_menu);
  444. END_MENU();
  445. }
  446. static void lcd_control_temperature_preheat_pla_settings_menu()
  447. {
  448. START_MENU();
  449. MENU_ITEM(back, MSG_TEMPERATURE, lcd_control_temperature_menu);
  450. MENU_ITEM_EDIT(int3, MSG_FAN_SPEED, &plaPreheatFanSpeed, 0, 255);
  451. MENU_ITEM_EDIT(int3, MSG_NOZZLE, &plaPreheatHotendTemp, 0, HEATER_0_MAXTEMP - 15);
  452. #if TEMP_SENSOR_BED != 0
  453. MENU_ITEM_EDIT(int3, MSG_BED, &plaPreheatHPBTemp, 0, BED_MAXTEMP - 15);
  454. #endif
  455. #ifdef EEPROM_SETTINGS
  456. MENU_ITEM(function, MSG_STORE_EPROM, Config_StoreSettings);
  457. #endif
  458. END_MENU();
  459. }
  460. static void lcd_control_temperature_preheat_abs_settings_menu()
  461. {
  462. START_MENU();
  463. MENU_ITEM(back, MSG_TEMPERATURE, lcd_control_temperature_menu);
  464. MENU_ITEM_EDIT(int3, MSG_FAN_SPEED, &absPreheatFanSpeed, 0, 255);
  465. MENU_ITEM_EDIT(int3, MSG_NOZZLE, &absPreheatHotendTemp, 0, HEATER_0_MAXTEMP - 15);
  466. #if TEMP_SENSOR_BED != 0
  467. MENU_ITEM_EDIT(int3, MSG_BED, &absPreheatHPBTemp, 0, BED_MAXTEMP - 15);
  468. #endif
  469. #ifdef EEPROM_SETTINGS
  470. MENU_ITEM(function, MSG_STORE_EPROM, Config_StoreSettings);
  471. #endif
  472. END_MENU();
  473. }
  474. static void lcd_control_motion_menu()
  475. {
  476. START_MENU();
  477. MENU_ITEM(back, MSG_CONTROL, lcd_control_menu);
  478. MENU_ITEM_EDIT(float5, MSG_ACC, &acceleration, 500, 99000);
  479. MENU_ITEM_EDIT(float3, MSG_VXY_JERK, &max_xy_jerk, 1, 990);
  480. MENU_ITEM_EDIT(float3, MSG_VMAX MSG_X, &max_feedrate[X_AXIS], 1, 999);
  481. MENU_ITEM_EDIT(float3, MSG_VMAX MSG_Y, &max_feedrate[Y_AXIS], 1, 999);
  482. MENU_ITEM_EDIT(float3, MSG_VMAX MSG_Z, &max_feedrate[Z_AXIS], 1, 999);
  483. MENU_ITEM_EDIT(float3, MSG_VMAX MSG_E, &max_feedrate[E_AXIS], 1, 999);
  484. MENU_ITEM_EDIT(float3, MSG_VMIN, &minimumfeedrate, 0, 999);
  485. MENU_ITEM_EDIT(float3, MSG_VTRAV_MIN, &mintravelfeedrate, 0, 999);
  486. MENU_ITEM_EDIT(long5, MSG_AMAX MSG_X, &max_acceleration_units_per_sq_second[X_AXIS], 100, 99000);
  487. MENU_ITEM_EDIT(long5, MSG_AMAX MSG_Y, &max_acceleration_units_per_sq_second[Y_AXIS], 100, 99000);
  488. MENU_ITEM_EDIT(long5, MSG_AMAX MSG_Z, &max_acceleration_units_per_sq_second[Z_AXIS], 100, 99000);
  489. MENU_ITEM_EDIT(long5, MSG_AMAX MSG_E, &max_acceleration_units_per_sq_second[E_AXIS], 100, 99000);
  490. MENU_ITEM_EDIT(float5, MSG_A_RETRACT, &retract_acceleration, 100, 99000);
  491. MENU_ITEM_EDIT(float52, MSG_XSTEPS, &axis_steps_per_unit[X_AXIS], 5, 9999);
  492. MENU_ITEM_EDIT(float52, MSG_YSTEPS, &axis_steps_per_unit[Y_AXIS], 5, 9999);
  493. MENU_ITEM_EDIT(float51, MSG_ZSTEPS, &axis_steps_per_unit[Z_AXIS], 5, 9999);
  494. MENU_ITEM_EDIT(float51, MSG_ESTEPS, &axis_steps_per_unit[E_AXIS], 5, 9999);
  495. #ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
  496. MENU_ITEM_EDIT(bool, "Endstop abort", &abort_on_endstop_hit);
  497. #endif
  498. END_MENU();
  499. }
  500. #ifdef FWRETRACT
  501. static void lcd_control_retract_menu()
  502. {
  503. START_MENU();
  504. MENU_ITEM(back, MSG_CONTROL, lcd_control_menu);
  505. MENU_ITEM_EDIT(bool, MSG_AUTORETRACT, &autoretract_enabled);
  506. MENU_ITEM_EDIT(float52, MSG_CONTROL_RETRACT, &retract_length, 0, 100);
  507. MENU_ITEM_EDIT(float3, MSG_CONTROL_RETRACTF, &retract_feedrate, 1, 999);
  508. MENU_ITEM_EDIT(float52, MSG_CONTROL_RETRACT_ZLIFT, &retract_zlift, 0, 999);
  509. MENU_ITEM_EDIT(float52, MSG_CONTROL_RETRACT_RECOVER, &retract_recover_length, 0, 100);
  510. MENU_ITEM_EDIT(float3, MSG_CONTROL_RETRACT_RECOVERF, &retract_recover_feedrate, 1, 999);
  511. END_MENU();
  512. }
  513. #endif
  514. #if SDCARDDETECT == -1
  515. static void lcd_sd_refresh()
  516. {
  517. card.initsd();
  518. currentMenuViewOffset = 0;
  519. }
  520. #endif
  521. static void lcd_sd_updir()
  522. {
  523. card.updir();
  524. currentMenuViewOffset = 0;
  525. }
  526. void lcd_sdcard_menu()
  527. {
  528. uint16_t fileCnt = card.getnrfilenames();
  529. START_MENU();
  530. MENU_ITEM(back, MSG_MAIN, lcd_main_menu);
  531. card.getWorkDirName();
  532. if(card.filename[0]=='/')
  533. {
  534. #if SDCARDDETECT == -1
  535. MENU_ITEM(function, LCD_STR_REFRESH MSG_REFRESH, lcd_sd_refresh);
  536. #endif
  537. }else{
  538. MENU_ITEM(function, LCD_STR_FOLDER "..", lcd_sd_updir);
  539. }
  540. for(uint16_t i=0;i<fileCnt;i++)
  541. {
  542. if (_menuItemNr == _lineNr)
  543. {
  544. card.getfilename(i);
  545. if (card.filenameIsDir)
  546. {
  547. MENU_ITEM(sddirectory, MSG_CARD_MENU, card.filename, card.longFilename);
  548. }else{
  549. MENU_ITEM(sdfile, MSG_CARD_MENU, card.filename, card.longFilename);
  550. }
  551. }else{
  552. MENU_ITEM_DUMMY();
  553. }
  554. }
  555. END_MENU();
  556. }
  557. #define menu_edit_type(_type, _name, _strFunc, scale) \
  558. void menu_edit_ ## _name () \
  559. { \
  560. if ((int32_t)encoderPosition < minEditValue) \
  561. encoderPosition = minEditValue; \
  562. if ((int32_t)encoderPosition > maxEditValue) \
  563. encoderPosition = maxEditValue; \
  564. if (lcdDrawUpdate) \
  565. lcd_implementation_drawedit(editLabel, _strFunc(((_type)encoderPosition) / scale)); \
  566. if (LCD_CLICKED) \
  567. { \
  568. *((_type*)editValue) = ((_type)encoderPosition) / scale; \
  569. lcd_quick_feedback(); \
  570. currentMenu = prevMenu; \
  571. encoderPosition = prevEncoderPosition; \
  572. } \
  573. } \
  574. static void menu_action_setting_edit_ ## _name (const char* pstr, _type* ptr, _type minValue, _type maxValue) \
  575. { \
  576. prevMenu = currentMenu; \
  577. prevEncoderPosition = encoderPosition; \
  578. \
  579. lcdDrawUpdate = 2; \
  580. currentMenu = menu_edit_ ## _name; \
  581. \
  582. editLabel = pstr; \
  583. editValue = ptr; \
  584. minEditValue = minValue * scale; \
  585. maxEditValue = maxValue * scale; \
  586. encoderPosition = (*ptr) * scale; \
  587. }
  588. menu_edit_type(int, int3, itostr3, 1)
  589. menu_edit_type(float, float3, ftostr3, 1)
  590. menu_edit_type(float, float32, ftostr32, 100)
  591. menu_edit_type(float, float5, ftostr5, 0.01)
  592. menu_edit_type(float, float51, ftostr51, 10)
  593. menu_edit_type(float, float52, ftostr52, 100)
  594. menu_edit_type(unsigned long, long5, ftostr5, 0.01)
  595. /** End of menus **/
  596. static void lcd_quick_feedback()
  597. {
  598. lcdDrawUpdate = 2;
  599. blocking_enc = millis() + 500;
  600. lcd_implementation_quick_feedback();
  601. }
  602. /** Menu action functions **/
  603. static void menu_action_back(menuFunc_t data)
  604. {
  605. currentMenu = data;
  606. encoderPosition = 0;
  607. }
  608. static void menu_action_submenu(menuFunc_t data)
  609. {
  610. currentMenu = data;
  611. encoderPosition = 0;
  612. }
  613. static void menu_action_gcode(const char* pgcode)
  614. {
  615. enquecommand_P(pgcode);
  616. }
  617. static void menu_action_function(menuFunc_t data)
  618. {
  619. (*data)();
  620. }
  621. static void menu_action_sdfile(const char* filename, char* longFilename)
  622. {
  623. char cmd[30];
  624. char* c;
  625. sprintf_P(cmd, PSTR("M23 %s"), filename);
  626. for(c = &cmd[4]; *c; c++)
  627. *c = tolower(*c);
  628. enquecommand(cmd);
  629. enquecommand_P(PSTR("M24"));
  630. lcd_return_to_status();
  631. }
  632. static void menu_action_sddirectory(const char* filename, char* longFilename)
  633. {
  634. card.chdir(filename);
  635. encoderPosition = 0;
  636. }
  637. static void menu_action_setting_edit_bool(const char* pstr, bool* ptr)
  638. {
  639. *ptr = !(*ptr);
  640. }
  641. #endif//ULTIPANEL
  642. /** LCD API **/
  643. void lcd_init()
  644. {
  645. lcd_implementation_init();
  646. #ifdef NEWPANEL
  647. pinMode(BTN_EN1,INPUT);
  648. pinMode(BTN_EN2,INPUT);
  649. pinMode(BTN_ENC,INPUT);
  650. pinMode(SDCARDDETECT,INPUT);
  651. WRITE(BTN_EN1,HIGH);
  652. WRITE(BTN_EN2,HIGH);
  653. WRITE(BTN_ENC,HIGH);
  654. #else
  655. pinMode(SHIFT_CLK,OUTPUT);
  656. pinMode(SHIFT_LD,OUTPUT);
  657. pinMode(SHIFT_EN,OUTPUT);
  658. pinMode(SHIFT_OUT,INPUT);
  659. WRITE(SHIFT_OUT,HIGH);
  660. WRITE(SHIFT_LD,HIGH);
  661. WRITE(SHIFT_EN,LOW);
  662. #endif//!NEWPANEL
  663. #if (SDCARDDETECT > -1)
  664. WRITE(SDCARDDETECT, HIGH);
  665. lcd_oldcardstatus = IS_SD_INSERTED;
  666. #endif//(SDCARDDETECT > -1)
  667. lcd_buttons_update();
  668. encoderDiff = 0;
  669. }
  670. void lcd_update()
  671. {
  672. static unsigned long timeoutToStatus = 0;
  673. lcd_buttons_update();
  674. #if (SDCARDDETECT > -1)
  675. if((IS_SD_INSERTED != lcd_oldcardstatus))
  676. {
  677. lcdDrawUpdate = 2;
  678. lcd_oldcardstatus = IS_SD_INSERTED;
  679. lcd_implementation_init(); // to maybe revive the lcd if static electricty killed it.
  680. if(lcd_oldcardstatus)
  681. {
  682. card.initsd();
  683. LCD_MESSAGEPGM(MSG_SD_INSERTED);
  684. }
  685. else
  686. {
  687. card.release();
  688. LCD_MESSAGEPGM(MSG_SD_REMOVED);
  689. }
  690. }
  691. #endif//CARDINSERTED
  692. if (lcd_next_update_millis < millis())
  693. {
  694. #ifdef ULTIPANEL
  695. if (encoderDiff)
  696. {
  697. lcdDrawUpdate = 1;
  698. encoderPosition += encoderDiff;
  699. encoderDiff = 0;
  700. timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS;
  701. }
  702. if (LCD_CLICKED)
  703. timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS;
  704. #endif//ULTIPANEL
  705. #ifdef DOGLCD // Changes due to different driver architecture of the DOGM display
  706. blink++; // Variable for fan animation and alive dot
  707. u8g.firstPage();
  708. do {
  709. u8g.setFont(u8g_font_6x10_marlin);
  710. u8g.setPrintPos(125,0);
  711. if (blink % 2) u8g.setColorIndex(1); else u8g.setColorIndex(0); // Set color for the alive dot
  712. u8g.drawPixel(127,63); // draw alive dot
  713. u8g.setColorIndex(1); // black on white
  714. (*currentMenu)();
  715. if (!lcdDrawUpdate) break; // Terminate display update, when nothing new to draw. This must be done before the last dogm.next()
  716. } while( u8g.nextPage() );
  717. #else
  718. (*currentMenu)();
  719. #endif
  720. #ifdef ULTIPANEL
  721. if(timeoutToStatus < millis() && currentMenu != lcd_status_screen)
  722. {
  723. lcd_return_to_status();
  724. lcdDrawUpdate = 2;
  725. }
  726. #endif//ULTIPANEL
  727. if (lcdDrawUpdate == 2)
  728. lcd_implementation_clear();
  729. if (lcdDrawUpdate)
  730. lcdDrawUpdate--;
  731. lcd_next_update_millis = millis() + 100;
  732. }
  733. }
  734. void lcd_setstatus(const char* message)
  735. {
  736. if (lcd_status_message_level > 0)
  737. return;
  738. strncpy(lcd_status_message, message, LCD_WIDTH);
  739. lcdDrawUpdate = 2;
  740. }
  741. void lcd_setstatuspgm(const char* message)
  742. {
  743. if (lcd_status_message_level > 0)
  744. return;
  745. strncpy_P(lcd_status_message, message, LCD_WIDTH);
  746. lcdDrawUpdate = 2;
  747. }
  748. void lcd_setalertstatuspgm(const char* message)
  749. {
  750. lcd_setstatuspgm(message);
  751. lcd_status_message_level = 1;
  752. #ifdef ULTIPANEL
  753. lcd_return_to_status();
  754. #endif//ULTIPANEL
  755. }
  756. void lcd_reset_alert_level()
  757. {
  758. lcd_status_message_level = 0;
  759. }
  760. #ifdef ULTIPANEL
  761. /* Warning: This function is called from interrupt context */
  762. void lcd_buttons_update()
  763. {
  764. #ifdef NEWPANEL
  765. uint8_t newbutton=0;
  766. if(READ(BTN_EN1)==0) newbutton|=EN_A;
  767. if(READ(BTN_EN2)==0) newbutton|=EN_B;
  768. if((blocking_enc<millis()) && (READ(BTN_ENC)==0))
  769. newbutton |= EN_C;
  770. buttons = newbutton;
  771. #else //read it from the shift register
  772. uint8_t newbutton=0;
  773. WRITE(SHIFT_LD,LOW);
  774. WRITE(SHIFT_LD,HIGH);
  775. unsigned char tmp_buttons=0;
  776. for(int8_t i=0;i<8;i++)
  777. {
  778. newbutton = newbutton>>1;
  779. if(READ(SHIFT_OUT))
  780. newbutton|=(1<<7);
  781. WRITE(SHIFT_CLK,HIGH);
  782. WRITE(SHIFT_CLK,LOW);
  783. }
  784. buttons=~newbutton; //invert it, because a pressed switch produces a logical 0
  785. #endif//!NEWPANEL
  786. //manage encoder rotation
  787. uint8_t enc=0;
  788. if(buttons&EN_A)
  789. enc|=(1<<0);
  790. if(buttons&EN_B)
  791. enc|=(1<<1);
  792. if(enc != lastEncoderBits)
  793. {
  794. switch(enc)
  795. {
  796. case encrot0:
  797. if(lastEncoderBits==encrot3)
  798. encoderDiff++;
  799. else if(lastEncoderBits==encrot1)
  800. encoderDiff--;
  801. break;
  802. case encrot1:
  803. if(lastEncoderBits==encrot0)
  804. encoderDiff++;
  805. else if(lastEncoderBits==encrot2)
  806. encoderDiff--;
  807. break;
  808. case encrot2:
  809. if(lastEncoderBits==encrot1)
  810. encoderDiff++;
  811. else if(lastEncoderBits==encrot3)
  812. encoderDiff--;
  813. break;
  814. case encrot3:
  815. if(lastEncoderBits==encrot2)
  816. encoderDiff++;
  817. else if(lastEncoderBits==encrot0)
  818. encoderDiff--;
  819. break;
  820. }
  821. }
  822. lastEncoderBits = enc;
  823. }
  824. #endif//ULTIPANEL
  825. /********************************/
  826. /** Float conversion utilities **/
  827. /********************************/
  828. // convert float to string with +123.4 format
  829. char conv[8];
  830. char *ftostr3(const float &x)
  831. {
  832. return itostr3((int)x);
  833. }
  834. char *itostr2(const uint8_t &x)
  835. {
  836. //sprintf(conv,"%5.1f",x);
  837. int xx=x;
  838. conv[0]=(xx/10)%10+'0';
  839. conv[1]=(xx)%10+'0';
  840. conv[2]=0;
  841. return conv;
  842. }
  843. // convert float to string with +123.4 format
  844. char *ftostr31(const float &x)
  845. {
  846. int xx=x*10;
  847. conv[0]=(xx>=0)?'+':'-';
  848. xx=abs(xx);
  849. conv[1]=(xx/1000)%10+'0';
  850. conv[2]=(xx/100)%10+'0';
  851. conv[3]=(xx/10)%10+'0';
  852. conv[4]='.';
  853. conv[5]=(xx)%10+'0';
  854. conv[6]=0;
  855. return conv;
  856. }
  857. // convert float to string with 123.4 format
  858. char *ftostr31ns(const float &x)
  859. {
  860. int xx=x*10;
  861. //conv[0]=(xx>=0)?'+':'-';
  862. xx=abs(xx);
  863. conv[0]=(xx/1000)%10+'0';
  864. conv[1]=(xx/100)%10+'0';
  865. conv[2]=(xx/10)%10+'0';
  866. conv[3]='.';
  867. conv[4]=(xx)%10+'0';
  868. conv[5]=0;
  869. return conv;
  870. }
  871. char *ftostr32(const float &x)
  872. {
  873. long xx=x*100;
  874. if (xx >= 0)
  875. conv[0]=(xx/10000)%10+'0';
  876. else
  877. conv[0]='-';
  878. xx=abs(xx);
  879. conv[1]=(xx/1000)%10+'0';
  880. conv[2]=(xx/100)%10+'0';
  881. conv[3]='.';
  882. conv[4]=(xx/10)%10+'0';
  883. conv[5]=(xx)%10+'0';
  884. conv[6]=0;
  885. return conv;
  886. }
  887. char *itostr31(const int &xx)
  888. {
  889. conv[0]=(xx>=0)?'+':'-';
  890. conv[1]=(xx/1000)%10+'0';
  891. conv[2]=(xx/100)%10+'0';
  892. conv[3]=(xx/10)%10+'0';
  893. conv[4]='.';
  894. conv[5]=(xx)%10+'0';
  895. conv[6]=0;
  896. return conv;
  897. }
  898. char *itostr3(const int &xx)
  899. {
  900. if (xx >= 100)
  901. conv[0]=(xx/100)%10+'0';
  902. else
  903. conv[0]=' ';
  904. if (xx >= 10)
  905. conv[1]=(xx/10)%10+'0';
  906. else
  907. conv[1]=' ';
  908. conv[2]=(xx)%10+'0';
  909. conv[3]=0;
  910. return conv;
  911. }
  912. char *itostr3left(const int &xx)
  913. {
  914. if (xx >= 100)
  915. {
  916. conv[0]=(xx/100)%10+'0';
  917. conv[1]=(xx/10)%10+'0';
  918. conv[2]=(xx)%10+'0';
  919. conv[3]=0;
  920. }
  921. else if (xx >= 10)
  922. {
  923. conv[0]=(xx/10)%10+'0';
  924. conv[1]=(xx)%10+'0';
  925. conv[2]=0;
  926. }
  927. else
  928. {
  929. conv[0]=(xx)%10+'0';
  930. conv[1]=0;
  931. }
  932. return conv;
  933. }
  934. char *itostr4(const int &xx)
  935. {
  936. if (xx >= 1000)
  937. conv[0]=(xx/1000)%10+'0';
  938. else
  939. conv[0]=' ';
  940. if (xx >= 100)
  941. conv[1]=(xx/100)%10+'0';
  942. else
  943. conv[1]=' ';
  944. if (xx >= 10)
  945. conv[2]=(xx/10)%10+'0';
  946. else
  947. conv[2]=' ';
  948. conv[3]=(xx)%10+'0';
  949. conv[4]=0;
  950. return conv;
  951. }
  952. // convert float to string with 12345 format
  953. char *ftostr5(const float &x)
  954. {
  955. long xx=abs(x);
  956. if (xx >= 10000)
  957. conv[0]=(xx/10000)%10+'0';
  958. else
  959. conv[0]=' ';
  960. if (xx >= 1000)
  961. conv[1]=(xx/1000)%10+'0';
  962. else
  963. conv[1]=' ';
  964. if (xx >= 100)
  965. conv[2]=(xx/100)%10+'0';
  966. else
  967. conv[2]=' ';
  968. if (xx >= 10)
  969. conv[3]=(xx/10)%10+'0';
  970. else
  971. conv[3]=' ';
  972. conv[4]=(xx)%10+'0';
  973. conv[5]=0;
  974. return conv;
  975. }
  976. // convert float to string with +1234.5 format
  977. char *ftostr51(const float &x)
  978. {
  979. long xx=x*10;
  980. conv[0]=(xx>=0)?'+':'-';
  981. xx=abs(xx);
  982. conv[1]=(xx/10000)%10+'0';
  983. conv[2]=(xx/1000)%10+'0';
  984. conv[3]=(xx/100)%10+'0';
  985. conv[4]=(xx/10)%10+'0';
  986. conv[5]='.';
  987. conv[6]=(xx)%10+'0';
  988. conv[7]=0;
  989. return conv;
  990. }
  991. // convert float to string with +123.45 format
  992. char *ftostr52(const float &x)
  993. {
  994. long xx=x*100;
  995. conv[0]=(xx>=0)?'+':'-';
  996. xx=abs(xx);
  997. conv[1]=(xx/10000)%10+'0';
  998. conv[2]=(xx/1000)%10+'0';
  999. conv[3]=(xx/100)%10+'0';
  1000. conv[4]='.';
  1001. conv[5]=(xx/10)%10+'0';
  1002. conv[6]=(xx)%10+'0';
  1003. conv[7]=0;
  1004. return conv;
  1005. }
  1006. #endif //ULTRA_LCD