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.pde 73KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058
  1. #include "language.h"
  2. #include "temperature.h"
  3. #include "ultralcd.h"
  4. #ifdef ULTRA_LCD
  5. #include "Marlin.h"
  6. #include "language.h"
  7. #include "temperature.h"
  8. #include "EEPROMwrite.h"
  9. #if LANGUAGE_CHOICE == 6
  10. #include "LiquidCrystalRus.h"
  11. #else
  12. #include <LiquidCrystal.h>
  13. #endif
  14. //===========================================================================
  15. //=============================imported variables============================
  16. //===========================================================================
  17. extern volatile int feedmultiply;
  18. extern volatile bool feedmultiplychanged;
  19. extern volatile int extrudemultiply;
  20. extern long position[4];
  21. #ifdef SDSUPPORT
  22. #include "cardreader.h"
  23. extern CardReader card;
  24. #endif
  25. //===========================================================================
  26. //=============================public variables============================
  27. //===========================================================================
  28. volatile char buttons=0; //the last checked buttons in a bit array.
  29. long encoderpos=0;
  30. short lastenc=0;
  31. //===========================================================================
  32. //=============================private variables============================
  33. //===========================================================================
  34. static char messagetext[LCD_WIDTH]="";
  35. //return for string conversion routines
  36. static char conv[8];
  37. #if LANGUAGE_CHOICE == 6
  38. LiquidCrystalRus lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5,LCD_PINS_D6,LCD_PINS_D7); //RS,Enable,D4,D5,D6,D7
  39. #else
  40. LiquidCrystal lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5,LCD_PINS_D6,LCD_PINS_D7); //RS,Enable,D4,D5,D6,D7
  41. #endif
  42. static unsigned long previous_millis_lcd=0;
  43. //static long previous_millis_buttons=0;
  44. #ifdef NEWPANEL
  45. static long blocking=0;
  46. #else
  47. static long blocking[8]={0,0,0,0,0,0,0,0};
  48. #endif
  49. static MainMenu menu;
  50. void lcdProgMemprint(const char *str)
  51. {
  52. char ch=pgm_read_byte(str);
  53. while(ch)
  54. {
  55. lcd.print(ch);
  56. ch=pgm_read_byte(++str);
  57. }
  58. }
  59. #define lcdprintPGM(x) lcdProgMemprint(MYPGM(x))
  60. //===========================================================================
  61. //=============================functions ============================
  62. //===========================================================================
  63. int intround(const float &x){return int(0.5+x);}
  64. void lcd_status(const char* message)
  65. {
  66. strncpy(messagetext,message,LCD_WIDTH);
  67. messagetext[strlen(message)]=0;
  68. }
  69. void lcd_statuspgm(const char* message)
  70. {
  71. char ch=pgm_read_byte(message);
  72. char *target=messagetext;
  73. uint8_t cnt=0;
  74. while(ch &&cnt<LCD_WIDTH)
  75. {
  76. *target=ch;
  77. target++;
  78. cnt++;
  79. ch=pgm_read_byte(++message);
  80. }
  81. *target=0;
  82. }
  83. void lcd_alertstatuspgm(const char* message)
  84. {
  85. lcd_statuspgm(message);
  86. menu.showStatus();
  87. }
  88. FORCE_INLINE void clear()
  89. {
  90. lcd.clear();
  91. }
  92. void lcd_init()
  93. {
  94. //beep();
  95. #ifdef ULTIPANEL
  96. buttons_init();
  97. #endif
  98. byte Degree[8] =
  99. {
  100. B01100,
  101. B10010,
  102. B10010,
  103. B01100,
  104. B00000,
  105. B00000,
  106. B00000,
  107. B00000
  108. };
  109. byte Thermometer[8] =
  110. {
  111. B00100,
  112. B01010,
  113. B01010,
  114. B01010,
  115. B01010,
  116. B10001,
  117. B10001,
  118. B01110
  119. };
  120. byte uplevel[8]={
  121. B00100,
  122. B01110,
  123. B11111,
  124. B00100,
  125. B11100,
  126. B00000,
  127. B00000,
  128. B00000
  129. }; //thanks joris
  130. byte refresh[8]={
  131. B00000,
  132. B00110,
  133. B11001,
  134. B11000,
  135. B00011,
  136. B10011,
  137. B01100,
  138. B00000,
  139. }; //thanks joris
  140. byte folder [8]={
  141. B00000,
  142. B11100,
  143. B11111,
  144. B10001,
  145. B10001,
  146. B11111,
  147. B00000,
  148. B00000
  149. }; //thanks joris
  150. lcd.begin(LCD_WIDTH, LCD_HEIGHT);
  151. lcd.createChar(1,Degree);
  152. lcd.createChar(2,Thermometer);
  153. lcd.createChar(3,uplevel);
  154. lcd.createChar(4,refresh);
  155. lcd.createChar(5,folder);
  156. LCD_MESSAGEPGM(WELCOME_MSG);
  157. }
  158. void beep()
  159. {
  160. //return;
  161. #ifdef ULTIPANEL
  162. #if (BEEPER > -1)
  163. {
  164. pinMode(BEEPER,OUTPUT);
  165. for(int8_t i=0;i<20;i++){
  166. WRITE(BEEPER,HIGH);
  167. delay(5);
  168. WRITE(BEEPER,LOW);
  169. delay(5);
  170. }
  171. }
  172. #endif
  173. #endif
  174. }
  175. void beepshort()
  176. {
  177. //return;
  178. #ifdef ULTIPANEL
  179. #if (BEEPER > -1)
  180. {
  181. pinMode(BEEPER,OUTPUT);
  182. for(int8_t i=0;i<10;i++){
  183. WRITE(BEEPER,HIGH);
  184. delay(3);
  185. WRITE(BEEPER,LOW);
  186. delay(3);
  187. }
  188. }
  189. #endif
  190. #endif
  191. }
  192. void lcd_status()
  193. {
  194. #ifdef ULTIPANEL
  195. static uint8_t oldbuttons=0;
  196. //static long previous_millis_buttons=0;
  197. //static long previous_lcdinit=0;
  198. // buttons_check(); // Done in temperature interrupt
  199. //previous_millis_buttons=millis();
  200. long ms=millis();
  201. for(int8_t i=0; i<8; i++) {
  202. #ifndef NEWPANEL
  203. if((blocking[i]>ms))
  204. buttons &= ~(1<<i);
  205. #else
  206. if((blocking>ms))
  207. buttons &= ~(1<<i);
  208. #endif
  209. }
  210. if((buttons==oldbuttons) && ((millis() - previous_millis_lcd) < LCD_UPDATE_INTERVAL) )
  211. return;
  212. oldbuttons=buttons;
  213. #else
  214. if(((millis() - previous_millis_lcd) < LCD_UPDATE_INTERVAL) )
  215. return;
  216. #endif
  217. previous_millis_lcd=millis();
  218. menu.update();
  219. }
  220. #ifdef ULTIPANEL
  221. void buttons_init()
  222. {
  223. #ifdef NEWPANEL
  224. pinMode(BTN_EN1,INPUT);
  225. pinMode(BTN_EN2,INPUT);
  226. pinMode(BTN_ENC,INPUT);
  227. pinMode(SDCARDDETECT,INPUT);
  228. WRITE(BTN_EN1,HIGH);
  229. WRITE(BTN_EN2,HIGH);
  230. WRITE(BTN_ENC,HIGH);
  231. #if (SDCARDDETECT > -1)
  232. {
  233. WRITE(SDCARDDETECT,HIGH);
  234. }
  235. #endif
  236. #else
  237. pinMode(SHIFT_CLK,OUTPUT);
  238. pinMode(SHIFT_LD,OUTPUT);
  239. pinMode(SHIFT_EN,OUTPUT);
  240. pinMode(SHIFT_OUT,INPUT);
  241. WRITE(SHIFT_OUT,HIGH);
  242. WRITE(SHIFT_LD,HIGH);
  243. WRITE(SHIFT_EN,LOW);
  244. #endif
  245. }
  246. void buttons_check()
  247. {
  248. #ifdef NEWPANEL
  249. uint8_t newbutton=0;
  250. if(READ(BTN_EN1)==0) newbutton|=EN_A;
  251. if(READ(BTN_EN2)==0) newbutton|=EN_B;
  252. if((blocking<millis()) &&(READ(BTN_ENC)==0))
  253. newbutton|=EN_C;
  254. buttons=newbutton;
  255. #else //read it from the shift register
  256. uint8_t newbutton=0;
  257. WRITE(SHIFT_LD,LOW);
  258. WRITE(SHIFT_LD,HIGH);
  259. unsigned char tmp_buttons=0;
  260. for(int8_t i=0;i<8;i++)
  261. {
  262. newbutton = newbutton>>1;
  263. if(READ(SHIFT_OUT))
  264. newbutton|=(1<<7);
  265. WRITE(SHIFT_CLK,HIGH);
  266. WRITE(SHIFT_CLK,LOW);
  267. }
  268. buttons=~newbutton; //invert it, because a pressed switch produces a logical 0
  269. #endif
  270. //manage encoder rotation
  271. char enc=0;
  272. if(buttons&EN_A)
  273. enc|=(1<<0);
  274. if(buttons&EN_B)
  275. enc|=(1<<1);
  276. if(enc!=lastenc)
  277. {
  278. switch(enc)
  279. {
  280. case encrot0:
  281. if(lastenc==encrot3)
  282. encoderpos++;
  283. else if(lastenc==encrot1)
  284. encoderpos--;
  285. break;
  286. case encrot1:
  287. if(lastenc==encrot0)
  288. encoderpos++;
  289. else if(lastenc==encrot2)
  290. encoderpos--;
  291. break;
  292. case encrot2:
  293. if(lastenc==encrot1)
  294. encoderpos++;
  295. else if(lastenc==encrot3)
  296. encoderpos--;
  297. break;
  298. case encrot3:
  299. if(lastenc==encrot2)
  300. encoderpos++;
  301. else if(lastenc==encrot0)
  302. encoderpos--;
  303. break;
  304. default:
  305. ;
  306. }
  307. }
  308. lastenc=enc;
  309. }
  310. #endif
  311. MainMenu::MainMenu()
  312. {
  313. status=Main_Status;
  314. displayStartingRow=0;
  315. activeline=0;
  316. force_lcd_update=true;
  317. linechanging=false;
  318. tune=false;
  319. }
  320. void MainMenu::showStatus()
  321. {
  322. #if LCD_HEIGHT==4
  323. static int olddegHotEnd0=-1;
  324. static int oldtargetHotEnd0=-1;
  325. //force_lcd_update=true;
  326. if(force_lcd_update) //initial display of content
  327. {
  328. encoderpos=feedmultiply;
  329. clear();
  330. lcd.setCursor(0,0);lcdprintPGM("\002000/000\001 ");
  331. #if defined BED_USES_THERMISTOR || defined BED_USES_AD595
  332. lcd.setCursor(10,0);lcdprintPGM("B000/000\001 ");
  333. #elif EXTRUDERS > 1
  334. lcd.setCursor(10,0);lcdprintPGM("\002000/000\001 ");
  335. #endif
  336. }
  337. int tHotEnd0=intround(degHotend0());
  338. if((tHotEnd0!=olddegHotEnd0)||force_lcd_update)
  339. {
  340. lcd.setCursor(1,0);
  341. lcd.print(ftostr3(tHotEnd0));
  342. olddegHotEnd0=tHotEnd0;
  343. }
  344. int ttHotEnd0=intround(degTargetHotend0());
  345. if((ttHotEnd0!=oldtargetHotEnd0)||force_lcd_update)
  346. {
  347. lcd.setCursor(5,0);
  348. lcd.print(ftostr3(ttHotEnd0));
  349. oldtargetHotEnd0=ttHotEnd0;
  350. }
  351. #if defined BED_USES_THERMISTOR || defined BED_USES_AD595
  352. static int oldtBed=-1;
  353. static int oldtargetBed=-1;
  354. int tBed=intround(degBed());
  355. if((tBed!=oldtBed)||force_lcd_update)
  356. {
  357. lcd.setCursor(11,0);
  358. lcd.print(ftostr3(tBed));
  359. oldtBed=tBed;
  360. }
  361. int targetBed=intround(degTargetBed());
  362. if((targetBed!=oldtargetBed)||force_lcd_update)
  363. {
  364. lcd.setCursor(15,0);
  365. lcd.print(ftostr3(targetBed));
  366. oldtargetBed=targetBed;
  367. }
  368. #elif EXTRUDERS > 1
  369. static int olddegHotEnd1=-1;
  370. static int oldtargetHotEnd1=-1;
  371. int tHotEnd1=intround(degHotend1());
  372. if((tHotEnd1!=olddegHotEnd1)||force_lcd_update)
  373. {
  374. lcd.setCursor(11,0);
  375. lcd.print(ftostr3(tHotEnd1));
  376. olddegHotEnd1=tHotEnd1;
  377. }
  378. int ttHotEnd1=intround(degTargetHotend1());
  379. if((ttHotEnd1!=oldtargetHotEnd1)||force_lcd_update)
  380. {
  381. lcd.setCursor(15,0);
  382. lcd.print(ftostr3(ttHotEnd1));
  383. oldtargetHotEnd1=ttHotEnd1;
  384. }
  385. #endif
  386. //starttime=2;
  387. static uint16_t oldtime=0;
  388. if(starttime!=0)
  389. {
  390. lcd.setCursor(0,1);
  391. uint16_t time=millis()/60000-starttime/60000;
  392. if(starttime!=oldtime)
  393. {
  394. lcd.print(itostr2(time/60));lcdprintPGM("h ");lcd.print(itostr2(time%60));lcdprintPGM("m");
  395. oldtime=time;
  396. }
  397. }
  398. static int oldzpos=0;
  399. int currentz=current_position[2]*100;
  400. if((currentz!=oldzpos)||force_lcd_update)
  401. {
  402. lcd.setCursor(10,1);
  403. lcdprintPGM("Z:");lcd.print(ftostr52(current_position[2]));
  404. oldzpos=currentz;
  405. }
  406. static int oldfeedmultiply=0;
  407. int curfeedmultiply=feedmultiply;
  408. if(feedmultiplychanged == true) {
  409. feedmultiplychanged = false;
  410. encoderpos = curfeedmultiply;
  411. }
  412. if(encoderpos!=curfeedmultiply||force_lcd_update)
  413. {
  414. curfeedmultiply=encoderpos;
  415. if(curfeedmultiply<10)
  416. curfeedmultiply=10;
  417. if(curfeedmultiply>999)
  418. curfeedmultiply=999;
  419. feedmultiply=curfeedmultiply;
  420. encoderpos=curfeedmultiply;
  421. }
  422. if((curfeedmultiply!=oldfeedmultiply)||force_lcd_update)
  423. {
  424. oldfeedmultiply=curfeedmultiply;
  425. lcd.setCursor(0,2);
  426. lcd.print(itostr3(curfeedmultiply));lcdprintPGM("% ");
  427. }
  428. if(messagetext[0]!='\0')
  429. {
  430. lcd.setCursor(0,LCD_HEIGHT-1);
  431. lcd.print(messagetext);
  432. uint8_t n=strlen(messagetext);
  433. for(int8_t i=0;i<LCD_WIDTH-n;i++)
  434. lcd.print(" ");
  435. messagetext[0]='\0';
  436. }
  437. #ifdef SDSUPPORT
  438. static uint8_t oldpercent=101;
  439. uint8_t percent=card.percentDone();
  440. if(oldpercent!=percent ||force_lcd_update)
  441. {
  442. lcd.setCursor(10,2);
  443. lcd.print(itostr3((int)percent));
  444. lcdprintPGM("%SD");
  445. }
  446. #endif
  447. #else //smaller LCDS----------------------------------
  448. static int olddegHotEnd0=-1;
  449. static int oldtargetHotEnd0=-1;
  450. if(force_lcd_update) //initial display of content
  451. {
  452. encoderpos=feedmultiply;
  453. lcd.setCursor(0,0);lcdprintPGM("\002---/---\001 ");
  454. }
  455. int tHotEnd0=intround(degHotend0());
  456. int ttHotEnd0=intround(degTargetHotend0());
  457. if((abs(tHotEnd0-olddegHotEnd0)>1)||force_lcd_update)
  458. {
  459. lcd.setCursor(1,0);
  460. lcd.print(ftostr3(tHotEnd0));
  461. olddegHotEnd0=tHotEnd0;
  462. }
  463. if((ttHotEnd0!=oldtargetHotEnd0)||force_lcd_update)
  464. {
  465. lcd.setCursor(5,0);
  466. lcd.print(ftostr3(ttHotEnd0));
  467. oldtargetHotEnd0=ttHotEnd0;
  468. }
  469. if(messagetext[0]!='\0')
  470. {
  471. lcd.setCursor(0,LCD_HEIGHT-1);
  472. lcd.print(messagetext);
  473. uint8_t n=strlen(messagetext);
  474. for(int8_t i=0;i<LCD_WIDTH-n;i++)
  475. lcd.print(" ");
  476. messagetext[0]='\0';
  477. }
  478. #endif
  479. force_lcd_update=false;
  480. }
  481. enum {ItemP_exit, ItemP_autostart,ItemP_disstep,ItemP_home, ItemP_origin, ItemP_preheat_pla, ItemP_preheat_abs, ItemP_cooldown,/*ItemP_extrude,*/ItemP_move};
  482. //any action must not contain a ',' character anywhere, or this breaks:
  483. #define MENUITEM(repaint_action, click_action) \
  484. {\
  485. if(force_lcd_update) { lcd.setCursor(0,line); repaint_action; } \
  486. if((activeline==line) && CLICKED) {click_action} \
  487. }
  488. void MainMenu::showPrepare()
  489. {
  490. #ifdef ULTIPANEL
  491. uint8_t line=0;
  492. clearIfNecessary();
  493. for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
  494. {
  495. //Serial.println((int)(line-lineoffset));
  496. switch(i)
  497. {
  498. case ItemP_exit:
  499. MENUITEM( lcdprintPGM(MSG_MAIN) , BLOCK;status=Main_Menu;beepshort(); ) ;
  500. break;
  501. case ItemP_autostart:
  502. MENUITEM( lcdprintPGM(MSG_AUTOSTART) , BLOCK;
  503. #ifdef SDSUPPORT
  504. card.lastnr=0;card.setroot();card.checkautostart(true);
  505. #endif
  506. beepshort(); ) ;
  507. break;
  508. case ItemP_disstep:
  509. MENUITEM( lcdprintPGM(MSG_DISABLE_STEPPERS) , BLOCK;enquecommand("M84");beepshort(); ) ;
  510. break;
  511. case ItemP_home:
  512. MENUITEM( lcdprintPGM(MSG_AUTO_HOME) , BLOCK;enquecommand("G28");beepshort(); ) ;
  513. break;
  514. case ItemP_origin:
  515. MENUITEM( lcdprintPGM(MSG_SET_ORIGIN) , BLOCK;enquecommand("G92 X0 Y0 Z0");beepshort(); ) ;
  516. break;
  517. case ItemP_preheat_pla:
  518. MENUITEM( lcdprintPGM(MSG_PREHEAT_PLA) , BLOCK;setTargetHotend0(plaPreheatHotendTemp);setTargetBed(plaPreheatHPBTemp);
  519. #if FAN_PIN > -1
  520. FanSpeed = plaPreheatFanSpeed;
  521. analogWrite(FAN_PIN, FanSpeed);
  522. #endif
  523. beepshort(); );
  524. break;
  525. case ItemP_preheat_abs:
  526. MENUITEM( lcdprintPGM(MSG_PREHEAT_ABS) , BLOCK;setTargetHotend0(absPreheatHotendTemp);setTargetBed(absPreheatHPBTemp);
  527. #if FAN_PIN > -1
  528. FanSpeed = absPreheatFanSpeed;
  529. analogWrite(FAN_PIN, FanSpeed);
  530. #endif
  531. beepshort(); );
  532. break;
  533. case ItemP_cooldown:
  534. MENUITEM( lcdprintPGM(MSG_COOLDOWN) , BLOCK;setTargetHotend0(0);setTargetHotend1(0);setTargetHotend2(0);setTargetBed(0);beepshort(); ) ;
  535. break;
  536. // case ItemP_extrude:
  537. // MENUITEM( lcdprintPGM(" Extrude") , BLOCK;enquecommand("G92 E0");enquecommand("G1 F700 E50");beepshort(); ) ;
  538. // break;
  539. case ItemP_move:
  540. MENUITEM( lcdprintPGM(MSG_MOVE_AXIS) , BLOCK;status=Sub_PrepareMove;beepshort(); );
  541. break;
  542. default:
  543. break;
  544. }
  545. line++;
  546. }
  547. updateActiveLines(ItemP_move,encoderpos);
  548. #endif
  549. }
  550. enum {
  551. ItemAM_exit,
  552. ItemAM_X, ItemAM_Y, ItemAM_Z, ItemAM_E, ItemAM_ERetract
  553. };
  554. void MainMenu::showAxisMove()
  555. {
  556. uint8_t line=0;
  557. int oldencoderpos=0;
  558. clearIfNecessary();
  559. for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
  560. {
  561. switch(i)
  562. {
  563. case ItemAM_exit:
  564. MENUITEM( lcdprintPGM(MSG_PREPARE_ALT) , BLOCK;status=Main_Prepare;beepshort(); ) ;
  565. break;
  566. case ItemAM_X:
  567. {
  568. //oldencoderpos=0;
  569. if(force_lcd_update)
  570. {
  571. lcd.setCursor(0,line);lcdprintPGM(" X:");
  572. lcd.setCursor(11,line);lcd.print(ftostr52(current_position[X_AXIS]));
  573. }
  574. if((activeline!=line) )
  575. break;
  576. if(CLICKED)
  577. {
  578. linechanging=!linechanging;
  579. if(linechanging)
  580. {
  581. enquecommand("G91");
  582. }
  583. else
  584. {
  585. enquecommand("G90");
  586. encoderpos=activeline*lcdslow;
  587. beepshort();
  588. }
  589. BLOCK;
  590. }
  591. if(linechanging)
  592. {
  593. if (encoderpos >0)
  594. {
  595. enquecommand("G1 F700 X0.1");
  596. oldencoderpos=encoderpos;
  597. encoderpos=0;
  598. }
  599. else if (encoderpos < 0)
  600. {
  601. enquecommand("G1 F700 X-0.1");
  602. oldencoderpos=encoderpos;
  603. encoderpos=0;
  604. }
  605. lcd.setCursor(11,line);lcd.print(ftostr52(current_position[X_AXIS]));
  606. }
  607. }
  608. break;
  609. case ItemAM_Y:
  610. {
  611. if(force_lcd_update)
  612. {
  613. lcd.setCursor(0,line);lcdprintPGM(" Y:");
  614. lcd.setCursor(11,line);lcd.print(ftostr52(current_position[Y_AXIS]));
  615. }
  616. if((activeline!=line) )
  617. break;
  618. if(CLICKED)
  619. {
  620. linechanging=!linechanging;
  621. if(linechanging)
  622. {
  623. enquecommand("G91");
  624. }
  625. else
  626. {
  627. enquecommand("G90");
  628. encoderpos=activeline*lcdslow;
  629. beepshort();
  630. }
  631. BLOCK;
  632. }
  633. if(linechanging)
  634. {
  635. if (encoderpos >0)
  636. {
  637. enquecommand("G1 F700 Y0.1");
  638. oldencoderpos=encoderpos;
  639. encoderpos=0;
  640. }
  641. else if (encoderpos < 0)
  642. {
  643. enquecommand("G1 F700 Y-0.1");
  644. oldencoderpos=encoderpos;
  645. encoderpos=0;
  646. }
  647. lcd.setCursor(11,line);lcd.print(ftostr52(current_position[Y_AXIS]));
  648. }
  649. }
  650. break;
  651. case ItemAM_Z:
  652. {
  653. if(force_lcd_update)
  654. {
  655. lcd.setCursor(0,line);lcdprintPGM(" Z:");
  656. lcd.setCursor(11,line);lcd.print(ftostr52(current_position[Z_AXIS]));
  657. }
  658. if((activeline!=line) )
  659. break;
  660. if(CLICKED)
  661. {
  662. linechanging=!linechanging;
  663. if(linechanging)
  664. {
  665. enquecommand("G91");
  666. }
  667. else
  668. {
  669. enquecommand("G90");
  670. encoderpos=activeline*lcdslow;
  671. beepshort();
  672. }
  673. BLOCK;
  674. }
  675. if(linechanging)
  676. {
  677. if (encoderpos >0)
  678. {
  679. enquecommand("G1 F70 Z0.1");
  680. oldencoderpos=encoderpos;
  681. encoderpos=0;
  682. }
  683. else if (encoderpos < 0)
  684. {
  685. enquecommand("G1 F70 Z-0.1");
  686. oldencoderpos=encoderpos;
  687. encoderpos=0;
  688. }
  689. lcd.setCursor(11,line);lcd.print(ftostr52(current_position[Z_AXIS]));
  690. }
  691. }
  692. break;
  693. case ItemAM_E:
  694. // ErikDB: TODO: this length should be changed for volumetric.
  695. MENUITEM( lcdprintPGM(MSG_EXTRUDE) , BLOCK;enquecommand("G92 E0");enquecommand("G1 F70 E1");beepshort(); ) ;
  696. break;
  697. case ItemAM_ERetract:
  698. // ErikDB: TODO: this length should be changed for volumetric.
  699. MENUITEM( lcdprintPGM(MSG_RETRACT) , BLOCK;enquecommand("G92 E0");enquecommand("G1 F700 E-1");beepshort(); ) ;
  700. break;
  701. default:
  702. break;
  703. }
  704. line++;
  705. }
  706. updateActiveLines(ItemAM_ERetract,encoderpos);
  707. }
  708. enum {ItemT_exit,ItemT_speed,ItemT_flow,ItemT_nozzle,
  709. #if (HEATER_BED_PIN > -1)
  710. ItemT_bed,
  711. #endif
  712. ItemT_fan};
  713. void MainMenu::showTune()
  714. {
  715. uint8_t line=0;
  716. clearIfNecessary();
  717. for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
  718. {
  719. //Serial.println((int)(line-lineoffset));
  720. switch(i)
  721. {
  722. case ItemT_exit:
  723. MENUITEM( lcdprintPGM(MSG_MAIN) , BLOCK;status=Main_Menu;beepshort(); ) ;
  724. break;
  725. case ItemT_speed:
  726. {
  727. if(force_lcd_update)
  728. {
  729. lcd.setCursor(0,line);lcdprintPGM(MSG_SPEED);
  730. lcd.setCursor(13,line);lcd.print(ftostr3(feedmultiply));
  731. }
  732. if((activeline!=line) )
  733. break;
  734. if(CLICKED) //AnalogWrite(FAN_PIN, fanpwm);
  735. {
  736. linechanging=!linechanging;
  737. if(linechanging)
  738. {
  739. encoderpos=feedmultiply;
  740. }
  741. else
  742. {
  743. encoderpos=activeline*lcdslow;
  744. beepshort();
  745. }
  746. BLOCK;
  747. }
  748. if(linechanging)
  749. {
  750. if(encoderpos<1) encoderpos=1;
  751. if(encoderpos>400) encoderpos=400;
  752. feedmultiply = encoderpos;
  753. feedmultiplychanged=true;
  754. lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
  755. }
  756. }break;
  757. case ItemT_nozzle:
  758. {
  759. if(force_lcd_update)
  760. {
  761. lcd.setCursor(0,line);lcdprintPGM(MSG_NOZZLE);
  762. lcd.setCursor(13,line);lcd.print(ftostr3(intround(degTargetHotend0())));
  763. }
  764. if((activeline!=line) )
  765. break;
  766. if(CLICKED)
  767. {
  768. linechanging=!linechanging;
  769. if(linechanging)
  770. {
  771. encoderpos=intround(degTargetHotend0());
  772. }
  773. else
  774. {
  775. setTargetHotend0(encoderpos);
  776. encoderpos=activeline*lcdslow;
  777. beepshort();
  778. }
  779. BLOCK;
  780. }
  781. if(linechanging)
  782. {
  783. if(encoderpos<0) encoderpos=0;
  784. if(encoderpos>260) encoderpos=260;
  785. lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
  786. }
  787. }break;
  788. #if (HEATER_BED_PIN > -1)
  789. case ItemT_bed:
  790. {
  791. if(force_lcd_update)
  792. {
  793. lcd.setCursor(0,line);lcdprintPGM(MSG_BED);
  794. lcd.setCursor(13,line);lcd.print(ftostr3(intround(degTargetBed())));
  795. }
  796. if((activeline!=line) )
  797. break;
  798. if(CLICKED)
  799. {
  800. linechanging=!linechanging;
  801. if(linechanging)
  802. {
  803. encoderpos=intround(degTargetBed());
  804. }
  805. else
  806. {
  807. setTargetBed(encoderpos);
  808. encoderpos=activeline*lcdslow;
  809. beepshort();
  810. }
  811. BLOCK;
  812. }
  813. if(linechanging)
  814. {
  815. if(encoderpos<0) encoderpos=0;
  816. if(encoderpos>260) encoderpos=260;
  817. lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
  818. }
  819. }break;
  820. #endif
  821. case ItemT_fan:
  822. {
  823. if(force_lcd_update)
  824. {
  825. lcd.setCursor(0,line);lcdprintPGM(MSG_FAN_SPEED);
  826. lcd.setCursor(13,line);lcd.print(ftostr3(FanSpeed));
  827. }
  828. if((activeline!=line) )
  829. break;
  830. if(CLICKED) //nalogWrite(FAN_PIN, fanpwm);
  831. {
  832. linechanging=!linechanging;
  833. if(linechanging)
  834. {
  835. encoderpos=FanSpeed;
  836. }
  837. else
  838. {
  839. encoderpos=activeline*lcdslow;
  840. beepshort();
  841. }
  842. BLOCK;
  843. }
  844. if(linechanging)
  845. {
  846. if(encoderpos<0) encoderpos=0;
  847. if(encoderpos>255) encoderpos=255;
  848. FanSpeed=encoderpos;
  849. analogWrite(FAN_PIN, FanSpeed);
  850. lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
  851. }
  852. }break;
  853. case ItemT_flow://axis_steps_per_unit[i] = code_value();
  854. {
  855. if(force_lcd_update)
  856. {
  857. lcd.setCursor(0,line);lcdprintPGM(MSG_FLOW);
  858. lcd.setCursor(13,line);lcd.print(ftostr52(axis_steps_per_unit[E_AXIS]));
  859. }
  860. if((activeline!=line) )
  861. break;
  862. if(CLICKED)
  863. {
  864. linechanging=!linechanging;
  865. if(linechanging)
  866. {
  867. encoderpos=(long)(axis_steps_per_unit[E_AXIS]*100.0);
  868. }
  869. else
  870. {
  871. float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[E_AXIS]);
  872. position[E_AXIS]=lround(position[E_AXIS]*factor);
  873. //current_position[E_AXIS]*=factor;
  874. axis_steps_per_unit[E_AXIS]= encoderpos/100.0;
  875. encoderpos=activeline*lcdslow;
  876. }
  877. BLOCK;
  878. beepshort();
  879. }
  880. if(linechanging)
  881. {
  882. if(encoderpos<5) encoderpos=5;
  883. if(encoderpos>999999) encoderpos=999999;
  884. lcd.setCursor(13,line);lcd.print(ftostr52(encoderpos/100.0));
  885. }
  886. }break;
  887. default:
  888. break;
  889. }
  890. line++;
  891. }
  892. updateActiveLines(ItemT_fan,encoderpos);
  893. }
  894. //does not work
  895. // #define MENUCHANGEITEM(repaint_action, enter_action, accept_action, change_action) \
  896. // {\
  897. // if(force_lcd_update) { lcd.setCursor(0,line); repaint_action; } \
  898. // if(activeline==line) \
  899. // { \
  900. // if(CLICKED) \
  901. // { \
  902. // linechanging=!linechanging; \
  903. // if(linechanging) {enter_action;} \
  904. // else {accept_action;} \
  905. // } \
  906. // else \
  907. // if(linechanging) {change_action};}\
  908. // }
  909. //
  910. enum {
  911. ItemCT_exit,ItemCT_nozzle0,
  912. #ifdef AUTOTEMP
  913. ItemCT_autotempactive,
  914. ItemCT_autotempmin,ItemCT_autotempmax,ItemCT_autotempfact,
  915. #endif
  916. #if EXTRUDERS > 1
  917. ItemCT_nozzle1,
  918. #endif
  919. #if EXTRUDERS > 2
  920. ItemCT_nozzle2,
  921. #endif
  922. #if defined BED_USES_THERMISTOR || defined BED_USES_AD595
  923. ItemCT_bed,
  924. #endif
  925. ItemCT_fan,
  926. ItemCT_PID_P,ItemCT_PID_I,ItemCT_PID_D,ItemCT_PID_C,
  927. ItemCT_PLA_PreHeat_Setting,
  928. ItemCT_ABS_PreHeat_Setting,
  929. };
  930. void MainMenu::showControlTemp()
  931. {
  932. uint8_t line=0;
  933. clearIfNecessary();
  934. for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
  935. {
  936. switch(i)
  937. {
  938. case ItemCT_exit:
  939. MENUITEM( lcdprintPGM(MSG_CONTROL) , BLOCK;status=Main_Control;beepshort(); ) ;
  940. break;
  941. case ItemCT_nozzle0:
  942. {
  943. if(force_lcd_update)
  944. {
  945. lcd.setCursor(0,line);lcdprintPGM(MSG_NOZZLE);
  946. lcd.setCursor(13,line);lcd.print(ftostr3(intround(degTargetHotend0())));
  947. }
  948. if((activeline!=line) )
  949. break;
  950. if(CLICKED)
  951. {
  952. linechanging=!linechanging;
  953. if(linechanging)
  954. {
  955. encoderpos=intround(degTargetHotend0());
  956. }
  957. else
  958. {
  959. setTargetHotend0(encoderpos);
  960. encoderpos=activeline*lcdslow;
  961. beepshort();
  962. }
  963. BLOCK;
  964. }
  965. if(linechanging)
  966. {
  967. if(encoderpos<0) encoderpos=0;
  968. if(encoderpos>260) encoderpos=260;
  969. lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
  970. }
  971. }break;
  972. #if EXTRUDERS > 1
  973. case ItemCT_nozzle1:
  974. {
  975. if(force_lcd_update)
  976. {
  977. lcd.setCursor(0,line);lcdprintPGM(MSG_NOZZLE1);
  978. lcd.setCursor(13,line);lcd.print(ftostr3(intround(degTargetHotend1())));
  979. }
  980. if((activeline!=line) )
  981. break;
  982. if(CLICKED)
  983. {
  984. linechanging=!linechanging;
  985. if(linechanging)
  986. {
  987. encoderpos=intround(degTargetHotend1());
  988. }
  989. else
  990. {
  991. setTargetHotend1(encoderpos);
  992. encoderpos=activeline*lcdslow;
  993. beepshort();
  994. }
  995. BLOCK;
  996. }
  997. if(linechanging)
  998. {
  999. if(encoderpos<0) encoderpos=0;
  1000. if(encoderpos>260) encoderpos=260;
  1001. lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
  1002. }
  1003. }break;
  1004. #endif
  1005. #if EXTRUDERS > 2
  1006. case ItemCT_nozzle2:
  1007. {
  1008. if(force_lcd_update)
  1009. {
  1010. lcd.setCursor(0,line);lcdprintPGM(MSG_NOZZLE2);
  1011. lcd.setCursor(13,line);lcd.print(ftostr3(intround(degTargetHotend2())));
  1012. }
  1013. if((activeline!=line) )
  1014. break;
  1015. if(CLICKED)
  1016. {
  1017. linechanging=!linechanging;
  1018. if(linechanging)
  1019. {
  1020. encoderpos=intround(degTargetHotend2());
  1021. }
  1022. else
  1023. {
  1024. setTargetHotend1(encoderpos);
  1025. encoderpos=activeline*lcdslow;
  1026. beepshort();
  1027. }
  1028. BLOCK;
  1029. }
  1030. if(linechanging)
  1031. {
  1032. if(encoderpos<0) encoderpos=0;
  1033. if(encoderpos>260) encoderpos=260;
  1034. lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
  1035. }
  1036. }break;
  1037. #endif
  1038. #ifdef AUTOTEMP
  1039. case ItemCT_autotempmin:
  1040. {
  1041. if(force_lcd_update)
  1042. {
  1043. lcd.setCursor(0,line);lcdprintPGM(MSG_MIN);
  1044. lcd.setCursor(13,line);lcd.print(ftostr3(autotemp_min));
  1045. }
  1046. if((activeline!=line) )
  1047. break;
  1048. if(CLICKED)
  1049. {
  1050. linechanging=!linechanging;
  1051. if(linechanging)
  1052. {
  1053. encoderpos=intround(autotemp_min);
  1054. }
  1055. else
  1056. {
  1057. autotemp_min=encoderpos;
  1058. encoderpos=activeline*lcdslow;
  1059. beepshort();
  1060. }
  1061. BLOCK;
  1062. }
  1063. if(linechanging)
  1064. {
  1065. if(encoderpos<0) encoderpos=0;
  1066. if(encoderpos>260) encoderpos=260;
  1067. lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
  1068. }
  1069. }break;
  1070. case ItemCT_autotempmax:
  1071. {
  1072. if(force_lcd_update)
  1073. {
  1074. lcd.setCursor(0,line);lcdprintPGM(MSG_MAX);
  1075. lcd.setCursor(13,line);lcd.print(ftostr3(autotemp_max));
  1076. }
  1077. if((activeline!=line) )
  1078. break;
  1079. if(CLICKED)
  1080. {
  1081. linechanging=!linechanging;
  1082. if(linechanging)
  1083. {
  1084. encoderpos=intround(autotemp_max);
  1085. }
  1086. else
  1087. {
  1088. autotemp_max=encoderpos;
  1089. encoderpos=activeline*lcdslow;
  1090. beepshort();
  1091. }
  1092. BLOCK;
  1093. }
  1094. if(linechanging)
  1095. {
  1096. if(encoderpos<0) encoderpos=0;
  1097. if(encoderpos>260) encoderpos=260;
  1098. lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
  1099. }
  1100. }break;
  1101. case ItemCT_autotempfact:
  1102. {
  1103. if(force_lcd_update)
  1104. {
  1105. lcd.setCursor(0,line);lcdprintPGM(MSG_FACTOR);
  1106. lcd.setCursor(13,line);lcd.print(ftostr32(autotemp_factor));
  1107. }
  1108. if((activeline!=line) )
  1109. break;
  1110. if(CLICKED)
  1111. {
  1112. linechanging=!linechanging;
  1113. if(linechanging)
  1114. {
  1115. encoderpos=intround(autotemp_factor*100);
  1116. }
  1117. else
  1118. {
  1119. autotemp_max=encoderpos;
  1120. encoderpos=activeline*lcdslow;
  1121. beepshort();
  1122. }
  1123. BLOCK;
  1124. }
  1125. if(linechanging)
  1126. {
  1127. if(encoderpos<0) encoderpos=0;
  1128. if(encoderpos>99) encoderpos=99;
  1129. lcd.setCursor(13,line);lcd.print(ftostr32(encoderpos/100.));
  1130. }
  1131. }break;
  1132. case ItemCT_autotempactive:
  1133. {
  1134. if(force_lcd_update)
  1135. {
  1136. lcd.setCursor(0,line);lcdprintPGM(MSG_AUTOTEMP);
  1137. lcd.setCursor(13,line);
  1138. if(autotemp_enabled)
  1139. lcdprintPGM(MSG_ON);
  1140. else
  1141. lcdprintPGM(MSG_OFF);
  1142. }
  1143. if((activeline!=line) )
  1144. break;
  1145. if(CLICKED)
  1146. {
  1147. autotemp_enabled=!autotemp_enabled;
  1148. lcd.setCursor(13,line);
  1149. if(autotemp_enabled)
  1150. lcdprintPGM(MSG_ON);
  1151. else
  1152. lcdprintPGM(MSG_OFF);
  1153. BLOCK;
  1154. }
  1155. }break;
  1156. #endif //autotemp
  1157. #if defined BED_USES_THERMISTOR || defined BED_USES_AD595
  1158. case ItemCT_bed:
  1159. {
  1160. if(force_lcd_update)
  1161. {
  1162. lcd.setCursor(0,line);lcdprintPGM(MSG_BED);
  1163. lcd.setCursor(13,line);lcd.print(ftostr3(intround(degTargetBed())));
  1164. }
  1165. if((activeline!=line) )
  1166. break;
  1167. if(CLICKED)
  1168. {
  1169. linechanging=!linechanging;
  1170. if(linechanging)
  1171. {
  1172. encoderpos=intround(degTargetBed());
  1173. }
  1174. else
  1175. {
  1176. setTargetBed(encoderpos);
  1177. encoderpos=activeline*lcdslow;
  1178. beepshort();
  1179. }
  1180. BLOCK;
  1181. }
  1182. if(linechanging)
  1183. {
  1184. if(encoderpos<0) encoderpos=0;
  1185. if(encoderpos>260) encoderpos=260;
  1186. lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
  1187. }
  1188. }break;
  1189. #endif
  1190. case ItemCT_fan:
  1191. {
  1192. if(force_lcd_update)
  1193. {
  1194. lcd.setCursor(0,line);lcdprintPGM(MSG_FAN_SPEED);
  1195. lcd.setCursor(13,line);lcd.print(ftostr3(FanSpeed));
  1196. }
  1197. if((activeline!=line) )
  1198. break;
  1199. if(CLICKED) //nalogWrite(FAN_PIN, fanpwm);
  1200. {
  1201. linechanging=!linechanging;
  1202. if(linechanging)
  1203. {
  1204. encoderpos=FanSpeed;
  1205. }
  1206. else
  1207. {
  1208. encoderpos=activeline*lcdslow;
  1209. beepshort();
  1210. }
  1211. BLOCK;
  1212. }
  1213. if(linechanging)
  1214. {
  1215. if(encoderpos<0) encoderpos=0;
  1216. if(encoderpos>255) encoderpos=255;
  1217. FanSpeed=encoderpos;
  1218. analogWrite(FAN_PIN, FanSpeed);
  1219. lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
  1220. }
  1221. }break;
  1222. #ifdef PIDTEMP
  1223. case ItemCT_PID_P:
  1224. {
  1225. if(force_lcd_update)
  1226. {
  1227. lcd.setCursor(0,line);lcdprintPGM(" PID-P: ");
  1228. lcd.setCursor(13,line);lcd.print(itostr4(Kp));
  1229. }
  1230. if((activeline!=line) )
  1231. break;
  1232. if(CLICKED)
  1233. {
  1234. linechanging=!linechanging;
  1235. if(linechanging)
  1236. {
  1237. encoderpos=(long)Kp;
  1238. }
  1239. else
  1240. {
  1241. Kp= encoderpos;
  1242. encoderpos=activeline*lcdslow;
  1243. }
  1244. BLOCK;
  1245. beepshort();
  1246. }
  1247. if(linechanging)
  1248. {
  1249. if(encoderpos<1) encoderpos=1;
  1250. if(encoderpos>9990) encoderpos=9990;
  1251. lcd.setCursor(13,line);lcd.print(itostr4(encoderpos));
  1252. }
  1253. }break;
  1254. case ItemCT_PID_I:
  1255. {
  1256. if(force_lcd_update)
  1257. {
  1258. lcd.setCursor(0,line);lcdprintPGM(MSG_PID_I);
  1259. lcd.setCursor(13,line);lcd.print(ftostr51(Ki/PID_dT));
  1260. }
  1261. if((activeline!=line) )
  1262. break;
  1263. if(CLICKED)
  1264. {
  1265. linechanging=!linechanging;
  1266. if(linechanging)
  1267. {
  1268. encoderpos=(long)(Ki*10/PID_dT);
  1269. }
  1270. else
  1271. {
  1272. Ki= encoderpos/10.*PID_dT;
  1273. encoderpos=activeline*lcdslow;
  1274. }
  1275. BLOCK;
  1276. beepshort();
  1277. }
  1278. if(linechanging)
  1279. {
  1280. if(encoderpos<0) encoderpos=0;
  1281. if(encoderpos>9990) encoderpos=9990;
  1282. lcd.setCursor(13,line);lcd.print(ftostr51(encoderpos/10.));
  1283. }
  1284. }break;
  1285. case ItemCT_PID_D:
  1286. {
  1287. if(force_lcd_update)
  1288. {
  1289. lcd.setCursor(0,line);lcdprintPGM(MSG_PID_D);
  1290. lcd.setCursor(13,line);lcd.print(itostr4(Kd*PID_dT));
  1291. }
  1292. if((activeline!=line) )
  1293. break;
  1294. if(CLICKED)
  1295. {
  1296. linechanging=!linechanging;
  1297. if(linechanging)
  1298. {
  1299. encoderpos=(long)(Kd/5./PID_dT);
  1300. }
  1301. else
  1302. {
  1303. Kd= encoderpos;
  1304. encoderpos=activeline*lcdslow;
  1305. }
  1306. BLOCK;
  1307. beepshort();
  1308. }
  1309. if(linechanging)
  1310. {
  1311. if(encoderpos<0) encoderpos=0;
  1312. if(encoderpos>9990) encoderpos=9990;
  1313. lcd.setCursor(13,line);lcd.print(itostr4(encoderpos));
  1314. }
  1315. }break;
  1316. case ItemCT_PID_C:
  1317. #ifdef PID_ADD_EXTRUSION_RATE
  1318. {
  1319. if(force_lcd_update)
  1320. {
  1321. lcd.setCursor(0,line);lcdprintPGM(MSG_PID_C);
  1322. lcd.setCursor(13,line);lcd.print(itostr3(Kc));
  1323. }
  1324. if((activeline!=line) )
  1325. break;
  1326. if(CLICKED)
  1327. {
  1328. linechanging=!linechanging;
  1329. if(linechanging)
  1330. {
  1331. encoderpos=(long)Kc;
  1332. }
  1333. else
  1334. {
  1335. Kc= encoderpos;
  1336. encoderpos=activeline*lcdslow;
  1337. }
  1338. BLOCK;
  1339. beepshort();
  1340. }
  1341. if(linechanging)
  1342. {
  1343. if(encoderpos<0) encoderpos=0;
  1344. if(encoderpos>990) encoderpos=990;
  1345. lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
  1346. }
  1347. }
  1348. #endif
  1349. #endif
  1350. break;
  1351. case ItemCT_PLA_PreHeat_Setting:
  1352. MENUITEM( lcdprintPGM(MSG_PREHEAT_PLA_SETTINGS) , BLOCK;status=Sub_PreheatPLASettings;beepshort(); ) ;
  1353. break;
  1354. case ItemCT_ABS_PreHeat_Setting:
  1355. MENUITEM( lcdprintPGM(MSG_PREHEAT_ABS_SETTINGS) , BLOCK;status=Sub_PreheatABSSettings;beepshort(); ) ;
  1356. break;
  1357. default:
  1358. break;
  1359. }
  1360. line++;
  1361. }
  1362. updateActiveLines(ItemCT_ABS_PreHeat_Setting,encoderpos);
  1363. }
  1364. enum {
  1365. ItemCM_exit,
  1366. ItemCM_acc, ItemCM_xyjerk,
  1367. ItemCM_vmaxx, ItemCM_vmaxy, ItemCM_vmaxz, ItemCM_vmaxe,
  1368. ItemCM_vtravmin,ItemCM_vmin,
  1369. ItemCM_amaxx, ItemCM_amaxy, ItemCM_amaxz, ItemCM_amaxe,
  1370. ItemCM_aret, ItemCM_xsteps,ItemCM_ysteps, ItemCM_zsteps, ItemCM_esteps
  1371. };
  1372. void MainMenu::showControlMotion()
  1373. {
  1374. uint8_t line=0;
  1375. clearIfNecessary();
  1376. for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
  1377. {
  1378. switch(i)
  1379. {
  1380. case ItemCM_exit:
  1381. MENUITEM( lcdprintPGM(MSG_CONTROL) , BLOCK;status=Main_Control;beepshort(); ) ;
  1382. break;
  1383. case ItemCM_acc:
  1384. {
  1385. if(force_lcd_update)
  1386. {
  1387. lcd.setCursor(0,line);lcdprintPGM(MSG_ACC);
  1388. lcd.setCursor(13,line);lcd.print(itostr3(acceleration/100));lcdprintPGM("00");
  1389. }
  1390. if((activeline!=line) )
  1391. break;
  1392. if(CLICKED)
  1393. {
  1394. linechanging=!linechanging;
  1395. if(linechanging)
  1396. {
  1397. encoderpos=(long)acceleration/100;
  1398. }
  1399. else
  1400. {
  1401. acceleration= encoderpos*100;
  1402. encoderpos=activeline*lcdslow;
  1403. }
  1404. BLOCK;
  1405. beepshort();
  1406. }
  1407. if(linechanging)
  1408. {
  1409. if(encoderpos<5) encoderpos=5;
  1410. if(encoderpos>990) encoderpos=990;
  1411. lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));lcdprintPGM("00");
  1412. }
  1413. }break;
  1414. case ItemCM_xyjerk: //max_xy_jerk
  1415. {
  1416. if(force_lcd_update)
  1417. {
  1418. lcd.setCursor(0,line);lcdprintPGM(MSG_VXY_JERK);
  1419. lcd.setCursor(13,line);lcd.print(itostr3(max_xy_jerk));
  1420. }
  1421. if((activeline!=line) )
  1422. break;
  1423. if(CLICKED)
  1424. {
  1425. linechanging=!linechanging;
  1426. if(linechanging)
  1427. {
  1428. encoderpos=(long)max_xy_jerk;
  1429. }
  1430. else
  1431. {
  1432. max_xy_jerk= encoderpos;
  1433. encoderpos=activeline*lcdslow;
  1434. }
  1435. BLOCK;
  1436. beepshort();
  1437. }
  1438. if(linechanging)
  1439. {
  1440. if(encoderpos<1) encoderpos=1;
  1441. if(encoderpos>990) encoderpos=990;
  1442. lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
  1443. }
  1444. }break;
  1445. case ItemCM_vmaxx:
  1446. case ItemCM_vmaxy:
  1447. case ItemCM_vmaxz:
  1448. case ItemCM_vmaxe:
  1449. {
  1450. if(force_lcd_update)
  1451. {
  1452. lcd.setCursor(0,line);lcdprintPGM(MSG_VMAX);
  1453. if(i==ItemCM_vmaxx)lcdprintPGM(MSG_X);
  1454. if(i==ItemCM_vmaxy)lcdprintPGM(MSG_Y);
  1455. if(i==ItemCM_vmaxz)lcdprintPGM(MSG_Z);
  1456. if(i==ItemCM_vmaxe)lcdprintPGM(MSG_E);
  1457. lcd.setCursor(13,line);lcd.print(itostr3(max_feedrate[i-ItemCM_vmaxx]));
  1458. }
  1459. if((activeline!=line) )
  1460. break;
  1461. if(CLICKED)
  1462. {
  1463. linechanging=!linechanging;
  1464. if(linechanging)
  1465. {
  1466. encoderpos=(long)max_feedrate[i-ItemCM_vmaxx];
  1467. }
  1468. else
  1469. {
  1470. max_feedrate[i-ItemCM_vmaxx]= encoderpos;
  1471. encoderpos=activeline*lcdslow;
  1472. }
  1473. BLOCK;
  1474. beepshort();
  1475. }
  1476. if(linechanging)
  1477. {
  1478. if(encoderpos<1) encoderpos=1;
  1479. if(encoderpos>990) encoderpos=990;
  1480. lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
  1481. }
  1482. }break;
  1483. case ItemCM_vmin:
  1484. {
  1485. if(force_lcd_update)
  1486. {
  1487. lcd.setCursor(0,line);lcdprintPGM(MSG_VMIN);
  1488. lcd.setCursor(13,line);lcd.print(itostr3(minimumfeedrate));
  1489. }
  1490. if((activeline!=line) )
  1491. break;
  1492. if(CLICKED)
  1493. {
  1494. linechanging=!linechanging;
  1495. if(linechanging)
  1496. {
  1497. encoderpos=(long)(minimumfeedrate);
  1498. }
  1499. else
  1500. {
  1501. minimumfeedrate= encoderpos;
  1502. encoderpos=activeline*lcdslow;
  1503. }
  1504. BLOCK;
  1505. beepshort();
  1506. }
  1507. if(linechanging)
  1508. {
  1509. if(encoderpos<0) encoderpos=0;
  1510. if(encoderpos>990) encoderpos=990;
  1511. lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
  1512. }
  1513. }break;
  1514. case ItemCM_vtravmin:
  1515. {
  1516. if(force_lcd_update)
  1517. {
  1518. lcd.setCursor(0,line);lcdprintPGM(MSG_VTRAV_MIN);
  1519. lcd.setCursor(13,line);lcd.print(itostr3(mintravelfeedrate));
  1520. }
  1521. if((activeline!=line) )
  1522. break;
  1523. if(CLICKED)
  1524. {
  1525. linechanging=!linechanging;
  1526. if(linechanging)
  1527. {
  1528. encoderpos=(long)mintravelfeedrate;
  1529. }
  1530. else
  1531. {
  1532. mintravelfeedrate= encoderpos;
  1533. encoderpos=activeline*lcdslow;
  1534. }
  1535. BLOCK;
  1536. beepshort();
  1537. }
  1538. if(linechanging)
  1539. {
  1540. if(encoderpos<0) encoderpos=0;
  1541. if(encoderpos>990) encoderpos=990;
  1542. lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
  1543. }
  1544. }break;
  1545. case ItemCM_amaxx:
  1546. case ItemCM_amaxy:
  1547. case ItemCM_amaxz:
  1548. case ItemCM_amaxe:
  1549. {
  1550. if(force_lcd_update)
  1551. {
  1552. lcd.setCursor(0,line);lcdprintPGM(" Amax ");
  1553. if(i==ItemCM_amaxx)lcdprintPGM(MSG_X);
  1554. if(i==ItemCM_amaxy)lcdprintPGM(MSG_Y);
  1555. if(i==ItemCM_amaxz)lcdprintPGM(MSG_Z);
  1556. if(i==ItemCM_amaxe)lcdprintPGM(MSG_E);
  1557. lcd.setCursor(13,line);lcd.print(itostr3(max_acceleration_units_per_sq_second[i-ItemCM_amaxx]/100));lcdprintPGM("00");
  1558. }
  1559. if((activeline!=line) )
  1560. break;
  1561. if(CLICKED)
  1562. {
  1563. linechanging=!linechanging;
  1564. if(linechanging)
  1565. {
  1566. encoderpos=(long)max_acceleration_units_per_sq_second[i-ItemCM_amaxx]/100;
  1567. }
  1568. else
  1569. {
  1570. max_acceleration_units_per_sq_second[i-ItemCM_amaxx]= encoderpos*100;
  1571. encoderpos=activeline*lcdslow;
  1572. }
  1573. BLOCK;
  1574. beepshort();
  1575. }
  1576. if(linechanging)
  1577. {
  1578. if(encoderpos<1) encoderpos=1;
  1579. if(encoderpos>990) encoderpos=990;
  1580. lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));lcdprintPGM("00");
  1581. }
  1582. }break;
  1583. case ItemCM_aret://float retract_acceleration = 7000;
  1584. {
  1585. if(force_lcd_update)
  1586. {
  1587. lcd.setCursor(0,line);lcdprintPGM(MSG_A_RETRACT);
  1588. lcd.setCursor(13,line);lcd.print(ftostr3(retract_acceleration/100));lcdprintPGM("00");
  1589. }
  1590. if((activeline!=line) )
  1591. break;
  1592. if(CLICKED)
  1593. {
  1594. linechanging=!linechanging;
  1595. if(linechanging)
  1596. {
  1597. encoderpos=(long)retract_acceleration/100;
  1598. }
  1599. else
  1600. {
  1601. retract_acceleration= encoderpos*100;
  1602. encoderpos=activeline*lcdslow;
  1603. }
  1604. BLOCK;
  1605. beepshort();
  1606. }
  1607. if(linechanging)
  1608. {
  1609. if(encoderpos<10) encoderpos=10;
  1610. if(encoderpos>990) encoderpos=990;
  1611. lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));lcdprintPGM("00");
  1612. }
  1613. }break;
  1614. case ItemCM_xsteps://axis_steps_per_unit[i] = code_value();
  1615. {
  1616. if(force_lcd_update)
  1617. {
  1618. lcd.setCursor(0,line);lcdprintPGM(MSG_XSTEPS);
  1619. lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[X_AXIS]));
  1620. }
  1621. if((activeline!=line) )
  1622. break;
  1623. if(CLICKED)
  1624. {
  1625. linechanging=!linechanging;
  1626. if(linechanging)
  1627. {
  1628. encoderpos=(long)(axis_steps_per_unit[X_AXIS]*100.0);
  1629. }
  1630. else
  1631. {
  1632. float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[X_AXIS]);
  1633. position[X_AXIS]=lround(position[X_AXIS]*factor);
  1634. //current_position[X_AXIS]*=factor;
  1635. axis_steps_per_unit[X_AXIS]= encoderpos/100.0;
  1636. encoderpos=activeline*lcdslow;
  1637. }
  1638. BLOCK;
  1639. beepshort();
  1640. }
  1641. if(linechanging)
  1642. {
  1643. if(encoderpos<5) encoderpos=5;
  1644. if(encoderpos>999999) encoderpos=999999;
  1645. lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0));
  1646. }
  1647. }break;
  1648. case ItemCM_ysteps://axis_steps_per_unit[i] = code_value();
  1649. {
  1650. if(force_lcd_update)
  1651. {
  1652. lcd.setCursor(0,line);lcdprintPGM(MSG_YSTEPS);
  1653. lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[Y_AXIS]));
  1654. }
  1655. if((activeline!=line) )
  1656. break;
  1657. if(CLICKED)
  1658. {
  1659. linechanging=!linechanging;
  1660. if(linechanging)
  1661. {
  1662. encoderpos=(long)(axis_steps_per_unit[Y_AXIS]*100.0);
  1663. }
  1664. else
  1665. {
  1666. float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[Y_AXIS]);
  1667. position[Y_AXIS]=lround(position[Y_AXIS]*factor);
  1668. //current_position[Y_AXIS]*=factor;
  1669. axis_steps_per_unit[Y_AXIS]= encoderpos/100.0;
  1670. encoderpos=activeline*lcdslow;
  1671. }
  1672. BLOCK;
  1673. beepshort();
  1674. }
  1675. if(linechanging)
  1676. {
  1677. if(encoderpos<5) encoderpos=5;
  1678. if(encoderpos>999999) encoderpos=999999;
  1679. lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0));
  1680. }
  1681. }break;
  1682. case ItemCM_zsteps://axis_steps_per_unit[i] = code_value();
  1683. {
  1684. if(force_lcd_update)
  1685. {
  1686. lcd.setCursor(0,line);lcdprintPGM(MSG_ZSTEPS);
  1687. lcd.setCursor(11,line);lcd.print(ftostr51(axis_steps_per_unit[Z_AXIS]));
  1688. }
  1689. if((activeline!=line) )
  1690. break;
  1691. if(CLICKED)
  1692. {
  1693. linechanging=!linechanging;
  1694. if(linechanging)
  1695. {
  1696. encoderpos=(long)(axis_steps_per_unit[Z_AXIS]*100.0);
  1697. }
  1698. else
  1699. {
  1700. float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[Z_AXIS]);
  1701. position[Z_AXIS]=lround(position[Z_AXIS]*factor);
  1702. //current_position[Z_AXIS]*=factor;
  1703. axis_steps_per_unit[Z_AXIS]= encoderpos/100.0;
  1704. encoderpos=activeline*lcdslow;
  1705. }
  1706. BLOCK;
  1707. beepshort();
  1708. }
  1709. if(linechanging)
  1710. {
  1711. if(encoderpos<5) encoderpos=5;
  1712. if(encoderpos>999999) encoderpos=999999;
  1713. lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0));
  1714. }
  1715. }break;
  1716. case ItemCM_esteps://axis_steps_per_unit[i] = code_value();
  1717. {
  1718. if(force_lcd_update)
  1719. {
  1720. lcd.setCursor(0,line);lcdprintPGM(MSG_ESTEPS);
  1721. lcd.setCursor(11,line);lcd.print(ftostr51(axis_steps_per_unit[E_AXIS]));
  1722. }
  1723. if((activeline!=line) )
  1724. break;
  1725. if(CLICKED)
  1726. {
  1727. linechanging=!linechanging;
  1728. if(linechanging)
  1729. {
  1730. encoderpos=(long)(axis_steps_per_unit[E_AXIS]*100.0);
  1731. }
  1732. else
  1733. {
  1734. float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[E_AXIS]);
  1735. position[E_AXIS]=lround(position[E_AXIS]*factor);
  1736. //current_position[E_AXIS]*=factor;
  1737. axis_steps_per_unit[E_AXIS]= encoderpos/100.0;
  1738. encoderpos=activeline*lcdslow;
  1739. }
  1740. BLOCK;
  1741. beepshort();
  1742. }
  1743. if(linechanging)
  1744. {
  1745. if(encoderpos<5) encoderpos=5;
  1746. if(encoderpos>999999) encoderpos=999999;
  1747. lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0));
  1748. }
  1749. }break;
  1750. default:
  1751. break;
  1752. }
  1753. line++;
  1754. }
  1755. updateActiveLines(ItemCM_esteps,encoderpos);
  1756. }
  1757. enum {
  1758. ItemR_exit,
  1759. ItemR_autoretract,
  1760. ItemR_retract_length,ItemR_retract_feedrate,ItemR_retract_zlift,
  1761. ItemR_unretract_length,ItemR_unretract_feedrate,
  1762. };
  1763. void MainMenu::showControlRetract()
  1764. {
  1765. #ifdef FWRETRACT
  1766. uint8_t line=0;
  1767. clearIfNecessary();
  1768. for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
  1769. {
  1770. switch(i)
  1771. {
  1772. case ItemR_exit:
  1773. MENUITEM( lcdprintPGM(MSG_CONTROL) , BLOCK;status=Main_Control;beepshort(); ) ;
  1774. break;
  1775. //float retract_length=2, retract_feedrate=1200, retract_zlift=0.4;
  1776. //float retract_recover_length=0, retract_recover_feedrate=500;
  1777. case ItemR_autoretract:
  1778. {
  1779. if(force_lcd_update)
  1780. {
  1781. lcd.setCursor(0,line);lcdprintPGM(MSG_AUTORETRACT);
  1782. lcd.setCursor(13,line);
  1783. if(autoretract_enabled)
  1784. lcdprintPGM(MSG_ON);
  1785. else
  1786. lcdprintPGM(MSG_OFF);
  1787. }
  1788. if((activeline!=line) )
  1789. break;
  1790. if(CLICKED)
  1791. {
  1792. autoretract_enabled=!autoretract_enabled;
  1793. lcd.setCursor(13,line);
  1794. if(autoretract_enabled)
  1795. lcdprintPGM(MSG_ON);
  1796. else
  1797. lcdprintPGM(MSG_OFF);
  1798. BLOCK;
  1799. }
  1800. }break;
  1801. case ItemR_retract_length:
  1802. {
  1803. if(force_lcd_update)
  1804. {
  1805. lcd.setCursor(0,line);lcdprintPGM(MSG_CONTROL_RETRACT);
  1806. lcd.setCursor(13,line);lcd.print(ftostr52(retract_length));
  1807. }
  1808. if((activeline!=line) )
  1809. break;
  1810. if(CLICKED)
  1811. {
  1812. linechanging=!linechanging;
  1813. if(linechanging)
  1814. {
  1815. encoderpos=(long)(retract_length*100);
  1816. }
  1817. else
  1818. {
  1819. retract_length= encoderpos/100.;
  1820. encoderpos=activeline*lcdslow;
  1821. }
  1822. BLOCK;
  1823. beepshort();
  1824. }
  1825. if(linechanging)
  1826. {
  1827. if(encoderpos<1) encoderpos=1;
  1828. if(encoderpos>990) encoderpos=990;
  1829. lcd.setCursor(13,line);lcd.print(ftostr52(encoderpos/100.));
  1830. }
  1831. }break;
  1832. case ItemR_retract_feedrate:
  1833. {
  1834. if(force_lcd_update)
  1835. {
  1836. lcd.setCursor(0,line);lcdprintPGM(MSG_CONTROL_RETRACTF);
  1837. lcd.setCursor(13,line);lcd.print(itostr4(retract_feedrate));
  1838. }
  1839. if((activeline!=line) )
  1840. break;
  1841. if(CLICKED)
  1842. {
  1843. linechanging=!linechanging;
  1844. if(linechanging)
  1845. {
  1846. encoderpos=(long)(retract_feedrate/5);
  1847. }
  1848. else
  1849. {
  1850. retract_feedrate= encoderpos*5.;
  1851. encoderpos=activeline*lcdslow;
  1852. }
  1853. BLOCK;
  1854. beepshort();
  1855. }
  1856. if(linechanging)
  1857. {
  1858. if(encoderpos<1) encoderpos=1;
  1859. if(encoderpos>990) encoderpos=990;
  1860. lcd.setCursor(13,line);lcd.print(itostr4(encoderpos*5));
  1861. }
  1862. }break;
  1863. case ItemR_retract_zlift://float retract_acceleration = 7000;
  1864. {
  1865. if(force_lcd_update)
  1866. {
  1867. lcd.setCursor(0,line);lcdprintPGM(MSG_CONTROL_RETRACT_ZLIFT);
  1868. lcd.setCursor(13,line);lcd.print(ftostr52(retract_zlift));;
  1869. }
  1870. if((activeline!=line) )
  1871. break;
  1872. if(CLICKED)
  1873. {
  1874. linechanging=!linechanging;
  1875. if(linechanging)
  1876. {
  1877. encoderpos=(long)(retract_zlift*10);
  1878. }
  1879. else
  1880. {
  1881. retract_zlift= encoderpos/10.;
  1882. encoderpos=activeline*lcdslow;
  1883. }
  1884. BLOCK;
  1885. beepshort();
  1886. }
  1887. if(linechanging)
  1888. {
  1889. if(encoderpos<0) encoderpos=0;
  1890. if(encoderpos>990) encoderpos=990;
  1891. lcd.setCursor(13,line);lcd.print(ftostr52(encoderpos/10.));
  1892. }
  1893. }break;
  1894. case ItemR_unretract_length:
  1895. {
  1896. if(force_lcd_update)
  1897. {
  1898. lcd.setCursor(0,line);lcdprintPGM(MSG_CONTROL_RETRACT_RECOVER);
  1899. lcd.setCursor(13,line);lcd.print(ftostr52(retract_recover_length));;
  1900. }
  1901. if((activeline!=line) )
  1902. break;
  1903. if(CLICKED)
  1904. {
  1905. linechanging=!linechanging;
  1906. if(linechanging)
  1907. {
  1908. encoderpos=(long)(retract_recover_length*100);
  1909. }
  1910. else
  1911. {
  1912. retract_recover_length= encoderpos/100.;
  1913. encoderpos=activeline*lcdslow;
  1914. }
  1915. BLOCK;
  1916. beepshort();
  1917. }
  1918. if(linechanging)
  1919. {
  1920. if(encoderpos<0) encoderpos=0;
  1921. if(encoderpos>990) encoderpos=990;
  1922. lcd.setCursor(13,line);lcd.print(ftostr52(encoderpos/100.));
  1923. }
  1924. }break;
  1925. case ItemR_unretract_feedrate:
  1926. {
  1927. if(force_lcd_update)
  1928. {
  1929. lcd.setCursor(0,line);lcdprintPGM(MSG_CONTROL_RETRACT_RECOVERF);
  1930. lcd.setCursor(13,line);lcd.print(itostr4(retract_recover_feedrate));
  1931. }
  1932. if((activeline!=line) )
  1933. break;
  1934. if(CLICKED)
  1935. {
  1936. linechanging=!linechanging;
  1937. if(linechanging)
  1938. {
  1939. encoderpos=(long)retract_recover_feedrate/5;
  1940. }
  1941. else
  1942. {
  1943. retract_recover_feedrate= encoderpos*5.;
  1944. encoderpos=activeline*lcdslow;
  1945. }
  1946. BLOCK;
  1947. beepshort();
  1948. }
  1949. if(linechanging)
  1950. {
  1951. if(encoderpos<1) encoderpos=1;
  1952. if(encoderpos>990) encoderpos=990;
  1953. lcd.setCursor(13,line);lcd.print(itostr4(encoderpos*5));
  1954. }
  1955. }break;
  1956. default:
  1957. break;
  1958. }
  1959. line++;
  1960. }
  1961. updateActiveLines(ItemR_unretract_feedrate,encoderpos);
  1962. #endif
  1963. }
  1964. enum {
  1965. ItemC_exit,ItemC_temp,ItemC_move,
  1966. #ifdef FWRETRACT
  1967. ItemC_rectract,
  1968. #endif
  1969. ItemC_store, ItemC_load,ItemC_failsafe
  1970. };
  1971. void MainMenu::showControl()
  1972. {
  1973. uint8_t line=0;
  1974. clearIfNecessary();
  1975. for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
  1976. {
  1977. switch(i)
  1978. {
  1979. case ItemC_exit:
  1980. MENUITEM( lcdprintPGM(MSG_MAIN_WIDE) , BLOCK;status=Main_Menu;beepshort(); ) ;
  1981. break;
  1982. case ItemC_temp:
  1983. MENUITEM( lcdprintPGM(MSG_TEMPERATURE_WIDE) , BLOCK;status=Sub_TempControl;beepshort(); ) ;
  1984. break;
  1985. case ItemC_move:
  1986. MENUITEM( lcdprintPGM(MSG_MOTION_WIDE) , BLOCK;status=Sub_MotionControl;beepshort(); ) ;
  1987. break;
  1988. #ifdef FWRETRACT
  1989. case ItemC_rectract:
  1990. MENUITEM( lcdprintPGM(MSG_RECTRACT_WIDE) , BLOCK;status=Sub_RetractControl;beepshort(); ) ;
  1991. break;
  1992. #endif
  1993. case ItemC_store:
  1994. {
  1995. if(force_lcd_update)
  1996. {
  1997. lcd.setCursor(0,line);lcdprintPGM(MSG_STORE_EPROM);
  1998. }
  1999. if((activeline==line) && CLICKED)
  2000. {
  2001. //enquecommand("M84");
  2002. beepshort();
  2003. BLOCK;
  2004. EEPROM_StoreSettings();
  2005. }
  2006. }break;
  2007. case ItemC_load:
  2008. {
  2009. if(force_lcd_update)
  2010. {
  2011. lcd.setCursor(0,line);lcdprintPGM(MSG_LOAD_EPROM);
  2012. }
  2013. if((activeline==line) && CLICKED)
  2014. {
  2015. //enquecommand("M84");
  2016. beepshort();
  2017. BLOCK;
  2018. EEPROM_RetrieveSettings();
  2019. }
  2020. }break;
  2021. case ItemC_failsafe:
  2022. {
  2023. if(force_lcd_update)
  2024. {
  2025. lcd.setCursor(0,line);lcdprintPGM(MSG_RESTORE_FAILSAFE);
  2026. }
  2027. if((activeline==line) && CLICKED)
  2028. {
  2029. //enquecommand("M84");
  2030. beepshort();
  2031. BLOCK;
  2032. EEPROM_RetrieveSettings(true);
  2033. }
  2034. }break;
  2035. default:
  2036. break;
  2037. }
  2038. line++;
  2039. }
  2040. updateActiveLines(ItemC_failsafe,encoderpos);
  2041. }
  2042. void MainMenu::showSD()
  2043. {
  2044. #ifdef SDSUPPORT
  2045. uint8_t line=0;
  2046. clearIfNecessary();
  2047. static uint8_t nrfiles=0;
  2048. if(force_lcd_update)
  2049. {
  2050. if(card.cardOK)
  2051. {
  2052. nrfiles=card.getnrfilenames();
  2053. }
  2054. else
  2055. {
  2056. nrfiles=0;
  2057. lineoffset=0;
  2058. }
  2059. }
  2060. bool enforceupdate=false;
  2061. for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
  2062. {
  2063. switch(i)
  2064. {
  2065. case 0:
  2066. MENUITEM( lcdprintPGM(MSG_MAIN) , BLOCK;status=Main_Menu;beepshort(); ) ;
  2067. break;
  2068. // case 1:
  2069. // {
  2070. // if(force_lcd_update)
  2071. // {
  2072. // lcd.setCursor(0,line);
  2073. // #ifdef CARDINSERTED
  2074. // if(CARDINSERTED)
  2075. // #else
  2076. // if(true)
  2077. // #endif
  2078. // {
  2079. // lcdprintPGM(" \004Refresh");
  2080. // }
  2081. // else
  2082. // {
  2083. // lcdprintPGM(" \004Insert Card");
  2084. // }
  2085. //
  2086. // }
  2087. // if((activeline==line) && CLICKED)
  2088. // {
  2089. // BLOCK;
  2090. // beepshort();
  2091. // card.initsd();
  2092. // force_lcd_update=true;
  2093. // nrfiles=card.getnrfilenames();
  2094. // }
  2095. // }break;
  2096. case 1:
  2097. MENUITEM( lcd.print(" ");card.getWorkDirName();
  2098. if(card.filename[0]=='/') lcdprintPGM(MSG_REFRESH);
  2099. else {
  2100. lcd.print("\005");
  2101. lcd.print(card.filename);
  2102. lcd.print("/..");
  2103. } ,
  2104. BLOCK;
  2105. if(SDCARDDETECT == -1) card.initsd();
  2106. card.updir();
  2107. enforceupdate=true;
  2108. lineoffset=0;
  2109. beepshort(); ) ;
  2110. break;
  2111. default:
  2112. {
  2113. #define FIRSTITEM 2
  2114. if(i-FIRSTITEM<nrfiles)
  2115. {
  2116. if(force_lcd_update)
  2117. {
  2118. card.getfilename(i-FIRSTITEM);
  2119. //Serial.print("Filenr:");Serial.println(i-2);
  2120. lcd.setCursor(0,line);lcdprintPGM(" ");
  2121. if(card.filenameIsDir) lcd.print("\005");
  2122. if (card.longFilename[0])
  2123. {
  2124. card.longFilename[LCD_WIDTH-1] = '\0';
  2125. lcd.print(card.longFilename);
  2126. }
  2127. else
  2128. {
  2129. lcd.print(card.filename);
  2130. }
  2131. }
  2132. if((activeline==line) && CLICKED)
  2133. {
  2134. BLOCK
  2135. card.getfilename(i-FIRSTITEM);
  2136. if(card.filenameIsDir)
  2137. {
  2138. for(int8_t i=0;i<strlen(card.filename);i++)
  2139. card.filename[i]=tolower(card.filename[i]);
  2140. card.chdir(card.filename);
  2141. lineoffset=0;
  2142. enforceupdate=true;
  2143. }
  2144. else
  2145. {
  2146. char cmd[30];
  2147. for(int8_t i=0;i<strlen(card.filename);i++)
  2148. card.filename[i]=tolower(card.filename[i]);
  2149. sprintf(cmd,"M23 %s",card.filename);
  2150. //sprintf(cmd,"M115");
  2151. enquecommand(cmd);
  2152. enquecommand("M24");
  2153. beep();
  2154. status=Main_Status;
  2155. if (card.longFilename[0])
  2156. {
  2157. card.longFilename[LCD_WIDTH-1] = '\0';
  2158. lcd_status(card.longFilename);
  2159. }
  2160. else
  2161. {
  2162. lcd_status(card.filename);
  2163. }
  2164. }
  2165. }
  2166. }
  2167. }
  2168. break;
  2169. }
  2170. line++;
  2171. }
  2172. updateActiveLines(FIRSTITEM+nrfiles-1,encoderpos);
  2173. if(enforceupdate)
  2174. {
  2175. force_lcd_update=true;
  2176. enforceupdate=false;
  2177. }
  2178. #endif
  2179. }
  2180. enum {ItemM_watch, ItemM_prepare, ItemM_control, ItemM_file, ItemM_pause};
  2181. void MainMenu::showMainMenu()
  2182. {
  2183. #ifndef ULTIPANEL
  2184. force_lcd_update=false;
  2185. #endif
  2186. if(tune)
  2187. {
  2188. if(!(movesplanned() || IS_SD_PRINTING))
  2189. {
  2190. force_lcd_update=true;
  2191. tune=false;
  2192. }
  2193. }
  2194. else
  2195. {
  2196. if(movesplanned() || IS_SD_PRINTING)
  2197. {
  2198. force_lcd_update=true;
  2199. tune=true;
  2200. }
  2201. }
  2202. clearIfNecessary();
  2203. uint8_t line=0;
  2204. for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
  2205. {
  2206. switch(i)
  2207. {
  2208. case ItemM_watch:
  2209. MENUITEM( lcdprintPGM(MSG_WATCH) , BLOCK;status=Main_Status;beepshort(); ) ;
  2210. break;
  2211. case ItemM_prepare:
  2212. MENUITEM( if(!tune) lcdprintPGM(MSG_PREPARE);else lcdprintPGM(MSG_TUNE); , BLOCK;status=Main_Prepare;beepshort(); ) ;
  2213. break;
  2214. case ItemM_control:
  2215. MENUITEM( lcdprintPGM(MSG_CONTROL_ARROW) , BLOCK;status=Main_Control;beepshort(); ) ;
  2216. break;
  2217. #ifdef SDSUPPORT
  2218. case ItemM_file:
  2219. {
  2220. if(force_lcd_update)
  2221. {
  2222. lcd.setCursor(0,line);
  2223. #ifdef CARDINSERTED
  2224. if(CARDINSERTED)
  2225. #else
  2226. if(true)
  2227. #endif
  2228. {
  2229. if(card.sdprinting)
  2230. lcdprintPGM(MSG_STOP_PRINT);
  2231. else
  2232. lcdprintPGM(MSG_CARD_MENU);
  2233. }
  2234. else
  2235. {
  2236. lcdprintPGM(MSG_NO_CARD);
  2237. }
  2238. }
  2239. #ifdef CARDINSERTED
  2240. if(CARDINSERTED)
  2241. #endif
  2242. if((activeline==line)&&CLICKED)
  2243. {
  2244. card.printingHasFinished();
  2245. BLOCK;
  2246. status=Main_SD;
  2247. beepshort();
  2248. }
  2249. }break;
  2250. case ItemM_pause:
  2251. {
  2252. if(force_lcd_update)
  2253. {
  2254. lcd.setCursor(0,line);
  2255. #ifdef CARDINSERTED
  2256. if(CARDINSERTED)
  2257. #else
  2258. if(true)
  2259. #endif
  2260. {
  2261. if(card.sdprinting)
  2262. lcdprintPGM(MSG_PAUSE_PRINT);
  2263. else
  2264. lcdprintPGM(MSG_RESUME_PRINT);
  2265. }
  2266. else
  2267. {
  2268. //lcdprintPGM(MSG_NO_CARD);
  2269. }
  2270. }
  2271. #ifdef CARDINSERTED
  2272. if(CARDINSERTED)
  2273. #endif
  2274. if((activeline==line) && CLICKED)
  2275. {
  2276. if(card.sdprinting)
  2277. {
  2278. card.pauseSDPrint();
  2279. beepshort();
  2280. status = Main_Status;
  2281. }
  2282. else
  2283. {
  2284. card.startFileprint();
  2285. starttime=millis();
  2286. beepshort();
  2287. status = Main_Status;
  2288. }
  2289. }
  2290. }break;
  2291. #else
  2292. case ItemM_file:
  2293. break;
  2294. case ItemM_pause:
  2295. break;
  2296. #endif
  2297. default:
  2298. SERIAL_ERROR_START;
  2299. SERIAL_ERRORLNPGM(MSG_SERIAL_ERROR_MENU_STRUCTURE);
  2300. break;
  2301. }
  2302. line++;
  2303. }
  2304. uint8_t numberOfLines = 4;
  2305. #ifdef SDSUPPORT
  2306. numberOfLines = 4;
  2307. #else
  2308. numberOfLines = 3;
  2309. #endif
  2310. updateActiveLines(numberOfLines,encoderpos);
  2311. }
  2312. void MainMenu::update()
  2313. {
  2314. static MainStatus oldstatus=Main_Menu; //init automatically causes foce_lcd_update=true
  2315. static long timeoutToStatus=0;
  2316. static bool oldcardstatus=false;
  2317. #ifdef CARDINSERTED
  2318. if((CARDINSERTED != oldcardstatus))
  2319. {
  2320. force_lcd_update=true;
  2321. oldcardstatus=CARDINSERTED;
  2322. lcd_init(); // to maybe revive the lcd if static electricty killed it.
  2323. //Serial.println("echo: SD CHANGE");
  2324. if(CARDINSERTED)
  2325. {
  2326. card.initsd();
  2327. LCD_MESSAGEPGM(MSG_SD_INSERTED);
  2328. }
  2329. else
  2330. {
  2331. card.release();
  2332. LCD_MESSAGEPGM(MSG_SD_REMOVED);
  2333. }
  2334. }
  2335. #endif
  2336. if(status!=oldstatus)
  2337. {
  2338. force_lcd_update=true;
  2339. encoderpos=0;
  2340. lineoffset=0;
  2341. oldstatus=status;
  2342. }
  2343. if( (encoderpos!=lastencoderpos) || CLICKED)
  2344. timeoutToStatus=millis()+STATUSTIMEOUT;
  2345. switch(status)
  2346. {
  2347. case Main_Status:
  2348. {
  2349. showStatus();
  2350. if(CLICKED)
  2351. {
  2352. linechanging=false;
  2353. BLOCK
  2354. status=Main_Menu;
  2355. timeoutToStatus=millis()+STATUSTIMEOUT;
  2356. }
  2357. }break;
  2358. case Main_Menu:
  2359. {
  2360. showMainMenu();
  2361. linechanging=false;
  2362. }break;
  2363. case Main_Prepare:
  2364. {
  2365. if(tune)
  2366. {
  2367. showTune();
  2368. }
  2369. else
  2370. {
  2371. showPrepare();
  2372. }
  2373. }break;
  2374. case Sub_PrepareMove:
  2375. {
  2376. showAxisMove();
  2377. }break;
  2378. case Main_Control:
  2379. {
  2380. showControl();
  2381. }break;
  2382. case Sub_MotionControl:
  2383. {
  2384. showControlMotion();
  2385. }break;
  2386. case Sub_RetractControl:
  2387. {
  2388. showControlRetract();
  2389. }break;
  2390. case Sub_TempControl:
  2391. {
  2392. showControlTemp();
  2393. }break;
  2394. case Main_SD:
  2395. {
  2396. showSD();
  2397. }break;
  2398. case Sub_PreheatPLASettings:
  2399. {
  2400. showPLAsettings();
  2401. }break;
  2402. case Sub_PreheatABSSettings:
  2403. {
  2404. showABSsettings();
  2405. }break;
  2406. }
  2407. if(timeoutToStatus<millis())
  2408. status=Main_Status;
  2409. //force_lcd_update=false;
  2410. lastencoderpos=encoderpos;
  2411. }
  2412. enum {
  2413. ItemPLAPreHeat_Exit,
  2414. ItemPLAPreHeat_set_PLA_FanSpeed,
  2415. ItemPLAPreHeat_set_nozzle,
  2416. ItemPLAPreHeat_set_HPB,
  2417. ItemPLAPreHeat_Store_Eprom
  2418. };
  2419. void MainMenu::showPLAsettings()
  2420. {
  2421. #ifdef ULTIPANEL
  2422. uint8_t line=0;
  2423. clearIfNecessary();
  2424. for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
  2425. {
  2426. switch(i)
  2427. {
  2428. case ItemPLAPreHeat_Exit:
  2429. MENUITEM( lcdprintPGM(MSG_TEMPERATURE_RTN) , BLOCK;status=Sub_TempControl;beepshort(); ) ;
  2430. break;
  2431. case ItemPLAPreHeat_set_PLA_FanSpeed:
  2432. {
  2433. if(force_lcd_update)
  2434. {
  2435. lcd.setCursor(0,line);lcdprintPGM(MSG_FAN_SPEED);
  2436. lcd.setCursor(13,line);lcd.print(ftostr3(plaPreheatFanSpeed));
  2437. }
  2438. if((activeline!=line) )
  2439. break;
  2440. if(CLICKED)
  2441. {
  2442. linechanging=!linechanging;
  2443. if(linechanging)
  2444. {
  2445. encoderpos=plaPreheatFanSpeed;
  2446. }
  2447. else
  2448. {
  2449. encoderpos=activeline*lcdslow;
  2450. beepshort();
  2451. }
  2452. BLOCK;
  2453. }
  2454. if(linechanging)
  2455. {
  2456. if(encoderpos<0) encoderpos=0;
  2457. if(encoderpos>255) encoderpos=255;
  2458. plaPreheatFanSpeed=encoderpos;
  2459. lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
  2460. }
  2461. }break;
  2462. case ItemPLAPreHeat_set_nozzle:
  2463. {
  2464. if(force_lcd_update)
  2465. {
  2466. lcd.setCursor(0,line);lcdprintPGM(MSG_NOZZLE);
  2467. lcd.setCursor(13,line);lcd.print(ftostr3(plaPreheatHotendTemp));
  2468. }
  2469. if((activeline!=line) )
  2470. break;
  2471. if(CLICKED)
  2472. {
  2473. linechanging=!linechanging;
  2474. if(linechanging)
  2475. {
  2476. encoderpos=plaPreheatHotendTemp;
  2477. }
  2478. else
  2479. {
  2480. encoderpos=activeline*lcdslow;
  2481. beepshort();
  2482. }
  2483. BLOCK;
  2484. }
  2485. if(linechanging)
  2486. {
  2487. if(encoderpos<0) encoderpos=0;
  2488. if(encoderpos>260) encoderpos=260;
  2489. plaPreheatHotendTemp = encoderpos;
  2490. lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
  2491. }
  2492. }break;
  2493. case ItemPLAPreHeat_set_HPB:
  2494. {
  2495. if(force_lcd_update)
  2496. {
  2497. lcd.setCursor(0,line);lcdprintPGM(MSG_BED);
  2498. lcd.setCursor(13,line);lcd.print(ftostr3(plaPreheatHPBTemp));
  2499. }
  2500. if((activeline!=line) )
  2501. break;
  2502. if(CLICKED)
  2503. {
  2504. linechanging=!linechanging;
  2505. if(linechanging)
  2506. {
  2507. encoderpos=plaPreheatHPBTemp;
  2508. }
  2509. else
  2510. {
  2511. encoderpos=activeline*lcdslow;
  2512. beepshort();
  2513. }
  2514. BLOCK;
  2515. }
  2516. if(linechanging)
  2517. {
  2518. if(encoderpos<0) encoderpos=0;
  2519. if(encoderpos>250) encoderpos=150;
  2520. plaPreheatHPBTemp = encoderpos;
  2521. lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
  2522. }
  2523. }break;
  2524. case ItemPLAPreHeat_Store_Eprom:
  2525. {
  2526. if(force_lcd_update)
  2527. {
  2528. lcd.setCursor(0,line);lcdprintPGM(MSG_STORE_EPROM);
  2529. }
  2530. if((activeline==line) && CLICKED)
  2531. {
  2532. //enquecommand("M84");
  2533. beepshort();
  2534. BLOCK;
  2535. EEPROM_StoreSettings();
  2536. }
  2537. }break;
  2538. default:
  2539. break;
  2540. }
  2541. line++;
  2542. }
  2543. updateActiveLines(ItemPLAPreHeat_Store_Eprom,encoderpos);
  2544. #endif
  2545. }
  2546. enum {
  2547. ItemABSPreHeat_Exit,
  2548. ItemABSPreHeat_set_FanSpeed,
  2549. ItemABSPreHeat_set_nozzle,
  2550. ItemABSPreHeat_set_HPB,
  2551. ItemABSPreHeat_Store_Eprom
  2552. };
  2553. void MainMenu::showABSsettings()
  2554. {
  2555. #ifdef ULTIPANEL
  2556. uint8_t line=0;
  2557. clearIfNecessary();
  2558. for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
  2559. {
  2560. switch(i)
  2561. {
  2562. case ItemABSPreHeat_Exit:
  2563. MENUITEM( lcdprintPGM(MSG_TEMPERATURE_RTN) , BLOCK;status=Sub_TempControl;beepshort(); ) ;
  2564. break;
  2565. case ItemABSPreHeat_set_FanSpeed:
  2566. {
  2567. if(force_lcd_update)
  2568. {
  2569. lcd.setCursor(0,line);lcdprintPGM(MSG_FAN_SPEED);
  2570. lcd.setCursor(13,line);lcd.print(ftostr3(absPreheatFanSpeed));
  2571. }
  2572. if((activeline!=line) )
  2573. break;
  2574. if(CLICKED)
  2575. {
  2576. linechanging=!linechanging;
  2577. if(linechanging)
  2578. {
  2579. encoderpos=absPreheatFanSpeed;
  2580. }
  2581. else
  2582. {
  2583. encoderpos=activeline*lcdslow;
  2584. beepshort();
  2585. }
  2586. BLOCK;
  2587. }
  2588. if(linechanging)
  2589. {
  2590. if(encoderpos<0) encoderpos=0;
  2591. if(encoderpos>255) encoderpos=255;
  2592. absPreheatFanSpeed=encoderpos;
  2593. lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
  2594. }
  2595. }break;
  2596. case ItemABSPreHeat_set_nozzle:
  2597. {
  2598. if(force_lcd_update)
  2599. {
  2600. lcd.setCursor(0,line);lcdprintPGM(MSG_NOZZLE);
  2601. lcd.setCursor(13,line);lcd.print(ftostr3(absPreheatHotendTemp));
  2602. }
  2603. if((activeline!=line) )
  2604. break;
  2605. if(CLICKED)
  2606. {
  2607. linechanging=!linechanging;
  2608. if(linechanging)
  2609. {
  2610. encoderpos=absPreheatHotendTemp;
  2611. }
  2612. else
  2613. {
  2614. encoderpos=activeline*lcdslow;
  2615. beepshort();
  2616. }
  2617. BLOCK;
  2618. }
  2619. if(linechanging)
  2620. {
  2621. if(encoderpos<0) encoderpos=0;
  2622. if(encoderpos>260) encoderpos=260;
  2623. absPreheatHotendTemp = encoderpos;
  2624. lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
  2625. }
  2626. }break;
  2627. case ItemABSPreHeat_set_HPB:
  2628. {
  2629. if(force_lcd_update)
  2630. {
  2631. lcd.setCursor(0,line);lcdprintPGM(MSG_BED);
  2632. lcd.setCursor(13,line);lcd.print(ftostr3(absPreheatHPBTemp));
  2633. }
  2634. if((activeline!=line) )
  2635. break;
  2636. if(CLICKED)
  2637. {
  2638. linechanging=!linechanging;
  2639. if(linechanging)
  2640. {
  2641. encoderpos=absPreheatHPBTemp;
  2642. }
  2643. else
  2644. {
  2645. encoderpos=activeline*lcdslow;
  2646. beepshort();
  2647. }
  2648. BLOCK;
  2649. }
  2650. if(linechanging)
  2651. {
  2652. if(encoderpos<0) encoderpos=0;
  2653. if(encoderpos>250) encoderpos=150;
  2654. absPreheatHPBTemp = encoderpos;
  2655. lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
  2656. }
  2657. }break;
  2658. case ItemABSPreHeat_Store_Eprom:
  2659. {
  2660. if(force_lcd_update)
  2661. {
  2662. lcd.setCursor(0,line);lcdprintPGM(MSG_STORE_EPROM);
  2663. }
  2664. if((activeline==line) && CLICKED)
  2665. {
  2666. //enquecommand("M84");
  2667. beepshort();
  2668. BLOCK;
  2669. EEPROM_StoreSettings();
  2670. }
  2671. }break;
  2672. default:
  2673. break;
  2674. }
  2675. line++;
  2676. }
  2677. updateActiveLines(ItemABSPreHeat_Store_Eprom,encoderpos);
  2678. #endif
  2679. }
  2680. //**********************************************************************************************************
  2681. // convert float to string with +123.4 format
  2682. char *ftostr3(const float &x)
  2683. {
  2684. //sprintf(conv,"%5.1f",x);
  2685. int xx=x;
  2686. conv[0]=(xx/100)%10+'0';
  2687. conv[1]=(xx/10)%10+'0';
  2688. conv[2]=(xx)%10+'0';
  2689. conv[3]=0;
  2690. return conv;
  2691. }
  2692. char *itostr2(const uint8_t &x)
  2693. {
  2694. //sprintf(conv,"%5.1f",x);
  2695. int xx=x;
  2696. conv[0]=(xx/10)%10+'0';
  2697. conv[1]=(xx)%10+'0';
  2698. conv[2]=0;
  2699. return conv;
  2700. }
  2701. // convert float to string with +123.4 format
  2702. char *ftostr31(const float &x)
  2703. {
  2704. int xx=x*10;
  2705. conv[0]=(xx>=0)?'+':'-';
  2706. xx=abs(xx);
  2707. conv[1]=(xx/1000)%10+'0';
  2708. conv[2]=(xx/100)%10+'0';
  2709. conv[3]=(xx/10)%10+'0';
  2710. conv[4]='.';
  2711. conv[5]=(xx)%10+'0';
  2712. conv[6]=0;
  2713. return conv;
  2714. }
  2715. char *ftostr32(const float &x)
  2716. {
  2717. long xx=x*100;
  2718. conv[0]=(xx>=0)?'+':'-';
  2719. xx=abs(xx);
  2720. conv[1]=(xx/100)%10+'0';
  2721. conv[2]='.';
  2722. conv[3]=(xx/10)%10+'0';
  2723. conv[4]=(xx)%10+'0';
  2724. conv[6]=0;
  2725. return conv;
  2726. }
  2727. char *itostr31(const int &xx)
  2728. {
  2729. conv[0]=(xx>=0)?'+':'-';
  2730. conv[1]=(xx/1000)%10+'0';
  2731. conv[2]=(xx/100)%10+'0';
  2732. conv[3]=(xx/10)%10+'0';
  2733. conv[4]='.';
  2734. conv[5]=(xx)%10+'0';
  2735. conv[6]=0;
  2736. return conv;
  2737. }
  2738. char *itostr3(const int &xx)
  2739. {
  2740. conv[0]=(xx/100)%10+'0';
  2741. conv[1]=(xx/10)%10+'0';
  2742. conv[2]=(xx)%10+'0';
  2743. conv[3]=0;
  2744. return conv;
  2745. }
  2746. char *itostr4(const int &xx)
  2747. {
  2748. conv[0]=(xx/1000)%10+'0';
  2749. conv[1]=(xx/100)%10+'0';
  2750. conv[2]=(xx/10)%10+'0';
  2751. conv[3]=(xx)%10+'0';
  2752. conv[4]=0;
  2753. return conv;
  2754. }
  2755. // convert float to string with +1234.5 format
  2756. char *ftostr51(const float &x)
  2757. {
  2758. long xx=x*10;
  2759. conv[0]=(xx>=0)?'+':'-';
  2760. xx=abs(xx);
  2761. conv[1]=(xx/10000)%10+'0';
  2762. conv[2]=(xx/1000)%10+'0';
  2763. conv[3]=(xx/100)%10+'0';
  2764. conv[4]=(xx/10)%10+'0';
  2765. conv[5]='.';
  2766. conv[6]=(xx)%10+'0';
  2767. conv[7]=0;
  2768. return conv;
  2769. }
  2770. // convert float to string with +123.45 format
  2771. char *ftostr52(const float &x)
  2772. {
  2773. long xx=x*100;
  2774. conv[0]=(xx>=0)?'+':'-';
  2775. xx=abs(xx);
  2776. conv[1]=(xx/10000)%10+'0';
  2777. conv[2]=(xx/1000)%10+'0';
  2778. conv[3]=(xx/100)%10+'0';
  2779. conv[4]='.';
  2780. conv[5]=(xx/10)%10+'0';
  2781. conv[6]=(xx)%10+'0';
  2782. conv[7]=0;
  2783. return conv;
  2784. }
  2785. #endif //ULTRA_LCD