My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ultralcd.pde 73KB

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