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

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