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

ultralcd.pde 72KB

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