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

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