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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007
  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. lcd.print(card.filename);
  2088. }
  2089. if((activeline==line) && CLICKED)
  2090. {
  2091. BLOCK
  2092. card.getfilename(i-FIRSTITEM);
  2093. if(card.filenameIsDir)
  2094. {
  2095. for(int8_t i=0;i<strlen(card.filename);i++)
  2096. card.filename[i]=tolower(card.filename[i]);
  2097. card.chdir(card.filename);
  2098. lineoffset=0;
  2099. enforceupdate=true;
  2100. }
  2101. else
  2102. {
  2103. char cmd[30];
  2104. for(int8_t i=0;i<strlen(card.filename);i++)
  2105. card.filename[i]=tolower(card.filename[i]);
  2106. sprintf(cmd,"M23 %s",card.filename);
  2107. //sprintf(cmd,"M115");
  2108. enquecommand(cmd);
  2109. enquecommand("M24");
  2110. beep();
  2111. status=Main_Status;
  2112. lcd_status(card.filename);
  2113. }
  2114. }
  2115. }
  2116. }
  2117. break;
  2118. }
  2119. line++;
  2120. }
  2121. updateActiveLines(FIRSTITEM+nrfiles-1,encoderpos);
  2122. if(enforceupdate)
  2123. {
  2124. force_lcd_update=true;
  2125. enforceupdate=false;
  2126. }
  2127. #endif
  2128. }
  2129. enum {ItemM_watch, ItemM_prepare, ItemM_control, ItemM_file, ItemM_pause};
  2130. void MainMenu::showMainMenu()
  2131. {
  2132. #ifndef ULTIPANEL
  2133. force_lcd_update=false;
  2134. #endif
  2135. if(tune)
  2136. {
  2137. if(!(movesplanned() || IS_SD_PRINTING))
  2138. {
  2139. force_lcd_update=true;
  2140. tune=false;
  2141. }
  2142. }
  2143. else
  2144. {
  2145. if(movesplanned() || IS_SD_PRINTING)
  2146. {
  2147. force_lcd_update=true;
  2148. tune=true;
  2149. }
  2150. }
  2151. clearIfNecessary();
  2152. uint8_t line=0;
  2153. for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
  2154. {
  2155. switch(i)
  2156. {
  2157. case ItemM_watch:
  2158. MENUITEM( lcdprintPGM(MSG_WATCH) , BLOCK;status=Main_Status;beepshort(); ) ;
  2159. break;
  2160. case ItemM_prepare:
  2161. MENUITEM( if(!tune) lcdprintPGM(MSG_PREPARE);else lcdprintPGM(MSG_TUNE); , BLOCK;status=Main_Prepare;beepshort(); ) ;
  2162. break;
  2163. case ItemM_control:
  2164. MENUITEM( lcdprintPGM(MSG_CONTROL_ARROW) , BLOCK;status=Main_Control;beepshort(); ) ;
  2165. break;
  2166. #ifdef SDSUPPORT
  2167. case ItemM_file:
  2168. {
  2169. if(force_lcd_update)
  2170. {
  2171. lcd.setCursor(0,line);
  2172. #ifdef CARDINSERTED
  2173. if(CARDINSERTED)
  2174. #else
  2175. if(true)
  2176. #endif
  2177. {
  2178. if(card.sdprinting)
  2179. lcdprintPGM(MSG_STOP_PRINT);
  2180. else
  2181. lcdprintPGM(MSG_CARD_MENU);
  2182. }
  2183. else
  2184. {
  2185. lcdprintPGM(MSG_NO_CARD);
  2186. }
  2187. }
  2188. #ifdef CARDINSERTED
  2189. if(CARDINSERTED)
  2190. #endif
  2191. if((activeline==line)&&CLICKED)
  2192. {
  2193. card.printingHasFinished();
  2194. BLOCK;
  2195. status=Main_SD;
  2196. beepshort();
  2197. }
  2198. }break;
  2199. case ItemM_pause:
  2200. {
  2201. if(force_lcd_update)
  2202. {
  2203. lcd.setCursor(0,line);
  2204. #ifdef CARDINSERTED
  2205. if(CARDINSERTED)
  2206. #else
  2207. if(true)
  2208. #endif
  2209. {
  2210. if(card.sdprinting)
  2211. lcdprintPGM(MSG_PAUSE_PRINT);
  2212. else
  2213. lcdprintPGM(MSG_RESUME_PRINT);
  2214. }
  2215. else
  2216. {
  2217. //lcdprintPGM(MSG_NO_CARD);
  2218. }
  2219. }
  2220. #ifdef CARDINSERTED
  2221. if(CARDINSERTED)
  2222. #endif
  2223. if((activeline==line) && CLICKED)
  2224. {
  2225. if(card.sdprinting)
  2226. {
  2227. card.pauseSDPrint();
  2228. beepshort();
  2229. status = Main_Status;
  2230. }
  2231. else
  2232. {
  2233. card.startFileprint();
  2234. starttime=millis();
  2235. beepshort();
  2236. status = Main_Status;
  2237. }
  2238. }
  2239. }break;
  2240. #else
  2241. case ItemM_file:
  2242. break;
  2243. case ItemM_pause:
  2244. break;
  2245. #endif
  2246. default:
  2247. SERIAL_ERROR_START;
  2248. SERIAL_ERRORLNPGM(MSG_SERIAL_ERROR_MENU_STRUCTURE);
  2249. break;
  2250. }
  2251. line++;
  2252. }
  2253. uint8_t numberOfLines = 4;
  2254. #ifdef SDSUPPORT
  2255. numberOfLines = 4;
  2256. #else
  2257. numberOfLines = 3;
  2258. #endif
  2259. updateActiveLines(numberOfLines,encoderpos);
  2260. }
  2261. void MainMenu::update()
  2262. {
  2263. static MainStatus oldstatus=Main_Menu; //init automatically causes foce_lcd_update=true
  2264. static long timeoutToStatus=0;
  2265. static bool oldcardstatus=false;
  2266. #ifdef CARDINSERTED
  2267. if((CARDINSERTED != oldcardstatus))
  2268. {
  2269. force_lcd_update=true;
  2270. oldcardstatus=CARDINSERTED;
  2271. lcd_init(); // to maybe revive the lcd if static electricty killed it.
  2272. //Serial.println("echo: SD CHANGE");
  2273. if(CARDINSERTED)
  2274. {
  2275. card.initsd();
  2276. LCD_MESSAGEPGM(MSG_SD_INSERTED);
  2277. }
  2278. else
  2279. {
  2280. card.release();
  2281. LCD_MESSAGEPGM(MSG_SD_REMOVED);
  2282. }
  2283. }
  2284. #endif
  2285. if(status!=oldstatus)
  2286. {
  2287. force_lcd_update=true;
  2288. encoderpos=0;
  2289. lineoffset=0;
  2290. oldstatus=status;
  2291. }
  2292. if( (encoderpos!=lastencoderpos) || CLICKED)
  2293. timeoutToStatus=millis()+STATUSTIMEOUT;
  2294. switch(status)
  2295. {
  2296. case Main_Status:
  2297. {
  2298. showStatus();
  2299. if(CLICKED)
  2300. {
  2301. linechanging=false;
  2302. BLOCK
  2303. status=Main_Menu;
  2304. timeoutToStatus=millis()+STATUSTIMEOUT;
  2305. }
  2306. }break;
  2307. case Main_Menu:
  2308. {
  2309. showMainMenu();
  2310. linechanging=false;
  2311. }break;
  2312. case Main_Prepare:
  2313. {
  2314. if(tune)
  2315. {
  2316. showTune();
  2317. }
  2318. else
  2319. {
  2320. showPrepare();
  2321. }
  2322. }break;
  2323. case Sub_PrepareMove:
  2324. {
  2325. showAxisMove();
  2326. }break;
  2327. case Main_Control:
  2328. {
  2329. showControl();
  2330. }break;
  2331. case Sub_MotionControl:
  2332. {
  2333. showControlMotion();
  2334. }break;
  2335. case Sub_RetractControl:
  2336. {
  2337. showControlRetract();
  2338. }break;
  2339. case Sub_TempControl:
  2340. {
  2341. showControlTemp();
  2342. }break;
  2343. case Main_SD:
  2344. {
  2345. showSD();
  2346. }break;
  2347. case Sub_PreheatPLASettings:
  2348. {
  2349. showPLAsettings();
  2350. }break;
  2351. case Sub_PreheatABSSettings:
  2352. {
  2353. showABSsettings();
  2354. }break;
  2355. }
  2356. if(timeoutToStatus<millis())
  2357. status=Main_Status;
  2358. //force_lcd_update=false;
  2359. lastencoderpos=encoderpos;
  2360. }
  2361. enum {
  2362. ItemPLAPreHeat_Exit,
  2363. ItemPLAPreHeat_set_PLA_FanSpeed,
  2364. ItemPLAPreHeat_set_nozzle,
  2365. ItemPLAPreHeat_set_HPB,
  2366. ItemPLAPreHeat_Store_Eprom
  2367. };
  2368. void MainMenu::showPLAsettings()
  2369. {
  2370. #ifdef ULTIPANEL
  2371. uint8_t line=0;
  2372. clearIfNecessary();
  2373. for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
  2374. {
  2375. switch(i)
  2376. {
  2377. case ItemPLAPreHeat_Exit:
  2378. MENUITEM( lcdprintPGM(MSG_TEMPERATURE_RTN) , BLOCK;status=Sub_TempControl;beepshort(); ) ;
  2379. break;
  2380. case ItemPLAPreHeat_set_PLA_FanSpeed:
  2381. {
  2382. if(force_lcd_update)
  2383. {
  2384. lcd.setCursor(0,line);lcdprintPGM(MSG_FAN_SPEED);
  2385. lcd.setCursor(13,line);lcd.print(ftostr3(plaPreheatFanSpeed));
  2386. }
  2387. if((activeline!=line) )
  2388. break;
  2389. if(CLICKED)
  2390. {
  2391. linechanging=!linechanging;
  2392. if(linechanging)
  2393. {
  2394. encoderpos=plaPreheatFanSpeed;
  2395. }
  2396. else
  2397. {
  2398. encoderpos=activeline*lcdslow;
  2399. beepshort();
  2400. }
  2401. BLOCK;
  2402. }
  2403. if(linechanging)
  2404. {
  2405. if(encoderpos<0) encoderpos=0;
  2406. if(encoderpos>255) encoderpos=255;
  2407. plaPreheatFanSpeed=encoderpos;
  2408. lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
  2409. }
  2410. }break;
  2411. case ItemPLAPreHeat_set_nozzle:
  2412. {
  2413. if(force_lcd_update)
  2414. {
  2415. lcd.setCursor(0,line);lcdprintPGM(MSG_NOZZLE);
  2416. lcd.setCursor(13,line);lcd.print(ftostr3(plaPreheatHotendTemp));
  2417. }
  2418. if((activeline!=line) )
  2419. break;
  2420. if(CLICKED)
  2421. {
  2422. linechanging=!linechanging;
  2423. if(linechanging)
  2424. {
  2425. encoderpos=plaPreheatHotendTemp;
  2426. }
  2427. else
  2428. {
  2429. encoderpos=activeline*lcdslow;
  2430. beepshort();
  2431. }
  2432. BLOCK;
  2433. }
  2434. if(linechanging)
  2435. {
  2436. if(encoderpos<0) encoderpos=0;
  2437. if(encoderpos>260) encoderpos=260;
  2438. plaPreheatHotendTemp = encoderpos;
  2439. lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
  2440. }
  2441. }break;
  2442. case ItemPLAPreHeat_set_HPB:
  2443. {
  2444. if(force_lcd_update)
  2445. {
  2446. lcd.setCursor(0,line);lcdprintPGM(MSG_BED);
  2447. lcd.setCursor(13,line);lcd.print(ftostr3(plaPreheatHPBTemp));
  2448. }
  2449. if((activeline!=line) )
  2450. break;
  2451. if(CLICKED)
  2452. {
  2453. linechanging=!linechanging;
  2454. if(linechanging)
  2455. {
  2456. encoderpos=plaPreheatHPBTemp;
  2457. }
  2458. else
  2459. {
  2460. encoderpos=activeline*lcdslow;
  2461. beepshort();
  2462. }
  2463. BLOCK;
  2464. }
  2465. if(linechanging)
  2466. {
  2467. if(encoderpos<0) encoderpos=0;
  2468. if(encoderpos>250) encoderpos=150;
  2469. plaPreheatHPBTemp = encoderpos;
  2470. lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
  2471. }
  2472. }break;
  2473. case ItemPLAPreHeat_Store_Eprom:
  2474. {
  2475. if(force_lcd_update)
  2476. {
  2477. lcd.setCursor(0,line);lcdprintPGM(MSG_STORE_EPROM);
  2478. }
  2479. if((activeline==line) && CLICKED)
  2480. {
  2481. //enquecommand("M84");
  2482. beepshort();
  2483. BLOCK;
  2484. EEPROM_StoreSettings();
  2485. }
  2486. }break;
  2487. default:
  2488. break;
  2489. }
  2490. line++;
  2491. }
  2492. updateActiveLines(ItemPLAPreHeat_Store_Eprom,encoderpos);
  2493. #endif
  2494. }
  2495. enum {
  2496. ItemABSPreHeat_Exit,
  2497. ItemABSPreHeat_set_FanSpeed,
  2498. ItemABSPreHeat_set_nozzle,
  2499. ItemABSPreHeat_set_HPB,
  2500. ItemABSPreHeat_Store_Eprom
  2501. };
  2502. void MainMenu::showABSsettings()
  2503. {
  2504. #ifdef ULTIPANEL
  2505. uint8_t line=0;
  2506. clearIfNecessary();
  2507. for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
  2508. {
  2509. switch(i)
  2510. {
  2511. case ItemABSPreHeat_Exit:
  2512. MENUITEM( lcdprintPGM(MSG_TEMPERATURE_RTN) , BLOCK;status=Sub_TempControl;beepshort(); ) ;
  2513. break;
  2514. case ItemABSPreHeat_set_FanSpeed:
  2515. {
  2516. if(force_lcd_update)
  2517. {
  2518. lcd.setCursor(0,line);lcdprintPGM(MSG_FAN_SPEED);
  2519. lcd.setCursor(13,line);lcd.print(ftostr3(absPreheatFanSpeed));
  2520. }
  2521. if((activeline!=line) )
  2522. break;
  2523. if(CLICKED)
  2524. {
  2525. linechanging=!linechanging;
  2526. if(linechanging)
  2527. {
  2528. encoderpos=absPreheatFanSpeed;
  2529. }
  2530. else
  2531. {
  2532. encoderpos=activeline*lcdslow;
  2533. beepshort();
  2534. }
  2535. BLOCK;
  2536. }
  2537. if(linechanging)
  2538. {
  2539. if(encoderpos<0) encoderpos=0;
  2540. if(encoderpos>255) encoderpos=255;
  2541. absPreheatFanSpeed=encoderpos;
  2542. lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
  2543. }
  2544. }break;
  2545. case ItemABSPreHeat_set_nozzle:
  2546. {
  2547. if(force_lcd_update)
  2548. {
  2549. lcd.setCursor(0,line);lcdprintPGM(MSG_NOZZLE);
  2550. lcd.setCursor(13,line);lcd.print(ftostr3(absPreheatHotendTemp));
  2551. }
  2552. if((activeline!=line) )
  2553. break;
  2554. if(CLICKED)
  2555. {
  2556. linechanging=!linechanging;
  2557. if(linechanging)
  2558. {
  2559. encoderpos=absPreheatHotendTemp;
  2560. }
  2561. else
  2562. {
  2563. encoderpos=activeline*lcdslow;
  2564. beepshort();
  2565. }
  2566. BLOCK;
  2567. }
  2568. if(linechanging)
  2569. {
  2570. if(encoderpos<0) encoderpos=0;
  2571. if(encoderpos>260) encoderpos=260;
  2572. absPreheatHotendTemp = encoderpos;
  2573. lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
  2574. }
  2575. }break;
  2576. case ItemABSPreHeat_set_HPB:
  2577. {
  2578. if(force_lcd_update)
  2579. {
  2580. lcd.setCursor(0,line);lcdprintPGM(MSG_BED);
  2581. lcd.setCursor(13,line);lcd.print(ftostr3(absPreheatHPBTemp));
  2582. }
  2583. if((activeline!=line) )
  2584. break;
  2585. if(CLICKED)
  2586. {
  2587. linechanging=!linechanging;
  2588. if(linechanging)
  2589. {
  2590. encoderpos=absPreheatHPBTemp;
  2591. }
  2592. else
  2593. {
  2594. encoderpos=activeline*lcdslow;
  2595. beepshort();
  2596. }
  2597. BLOCK;
  2598. }
  2599. if(linechanging)
  2600. {
  2601. if(encoderpos<0) encoderpos=0;
  2602. if(encoderpos>250) encoderpos=150;
  2603. absPreheatHPBTemp = encoderpos;
  2604. lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
  2605. }
  2606. }break;
  2607. case ItemABSPreHeat_Store_Eprom:
  2608. {
  2609. if(force_lcd_update)
  2610. {
  2611. lcd.setCursor(0,line);lcdprintPGM(MSG_STORE_EPROM);
  2612. }
  2613. if((activeline==line) && CLICKED)
  2614. {
  2615. //enquecommand("M84");
  2616. beepshort();
  2617. BLOCK;
  2618. EEPROM_StoreSettings();
  2619. }
  2620. }break;
  2621. default:
  2622. break;
  2623. }
  2624. line++;
  2625. }
  2626. updateActiveLines(ItemABSPreHeat_Store_Eprom,encoderpos);
  2627. #endif
  2628. }
  2629. //**********************************************************************************************************
  2630. // convert float to string with +123.4 format
  2631. char *ftostr3(const float &x)
  2632. {
  2633. //sprintf(conv,"%5.1f",x);
  2634. int xx=x;
  2635. conv[0]=(xx/100)%10+'0';
  2636. conv[1]=(xx/10)%10+'0';
  2637. conv[2]=(xx)%10+'0';
  2638. conv[3]=0;
  2639. return conv;
  2640. }
  2641. char *itostr2(const uint8_t &x)
  2642. {
  2643. //sprintf(conv,"%5.1f",x);
  2644. int xx=x;
  2645. conv[0]=(xx/10)%10+'0';
  2646. conv[1]=(xx)%10+'0';
  2647. conv[2]=0;
  2648. return conv;
  2649. }
  2650. // convert float to string with +123.4 format
  2651. char *ftostr31(const float &x)
  2652. {
  2653. int xx=x*10;
  2654. conv[0]=(xx>=0)?'+':'-';
  2655. xx=abs(xx);
  2656. conv[1]=(xx/1000)%10+'0';
  2657. conv[2]=(xx/100)%10+'0';
  2658. conv[3]=(xx/10)%10+'0';
  2659. conv[4]='.';
  2660. conv[5]=(xx)%10+'0';
  2661. conv[6]=0;
  2662. return conv;
  2663. }
  2664. char *ftostr32(const float &x)
  2665. {
  2666. long xx=x*100;
  2667. conv[0]=(xx>=0)?'+':'-';
  2668. xx=abs(xx);
  2669. conv[1]=(xx/100)%10+'0';
  2670. conv[2]='.';
  2671. conv[3]=(xx/10)%10+'0';
  2672. conv[4]=(xx)%10+'0';
  2673. conv[6]=0;
  2674. return conv;
  2675. }
  2676. char *itostr31(const int &xx)
  2677. {
  2678. conv[0]=(xx>=0)?'+':'-';
  2679. conv[1]=(xx/1000)%10+'0';
  2680. conv[2]=(xx/100)%10+'0';
  2681. conv[3]=(xx/10)%10+'0';
  2682. conv[4]='.';
  2683. conv[5]=(xx)%10+'0';
  2684. conv[6]=0;
  2685. return conv;
  2686. }
  2687. char *itostr3(const int &xx)
  2688. {
  2689. conv[0]=(xx/100)%10+'0';
  2690. conv[1]=(xx/10)%10+'0';
  2691. conv[2]=(xx)%10+'0';
  2692. conv[3]=0;
  2693. return conv;
  2694. }
  2695. char *itostr4(const int &xx)
  2696. {
  2697. conv[0]=(xx/1000)%10+'0';
  2698. conv[1]=(xx/100)%10+'0';
  2699. conv[2]=(xx/10)%10+'0';
  2700. conv[3]=(xx)%10+'0';
  2701. conv[4]=0;
  2702. return conv;
  2703. }
  2704. // convert float to string with +1234.5 format
  2705. char *ftostr51(const float &x)
  2706. {
  2707. long xx=x*10;
  2708. conv[0]=(xx>=0)?'+':'-';
  2709. xx=abs(xx);
  2710. conv[1]=(xx/10000)%10+'0';
  2711. conv[2]=(xx/1000)%10+'0';
  2712. conv[3]=(xx/100)%10+'0';
  2713. conv[4]=(xx/10)%10+'0';
  2714. conv[5]='.';
  2715. conv[6]=(xx)%10+'0';
  2716. conv[7]=0;
  2717. return conv;
  2718. }
  2719. // convert float to string with +123.45 format
  2720. char *ftostr52(const float &x)
  2721. {
  2722. long xx=x*100;
  2723. conv[0]=(xx>=0)?'+':'-';
  2724. xx=abs(xx);
  2725. conv[1]=(xx/10000)%10+'0';
  2726. conv[2]=(xx/1000)%10+'0';
  2727. conv[3]=(xx/100)%10+'0';
  2728. conv[4]='.';
  2729. conv[5]=(xx/10)%10+'0';
  2730. conv[6]=(xx)%10+'0';
  2731. conv[7]=0;
  2732. return conv;
  2733. }
  2734. #endif //ULTRA_LCD