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.

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