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

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