123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039 |
- #include "language.h"
- #include "temperature.h"
- #include "ultralcd.h"
- #ifdef ULTRA_LCD
- #include "Marlin.h"
- #include "language.h"
- #include "temperature.h"
- #include "ConfigurationStore.h"
-
- //===========================================================================
- //=============================imported variables============================
- //===========================================================================
-
- extern long position[4];
- #ifdef SDSUPPORT
- #include "cardreader.h"
- #endif
-
- //===========================================================================
- //=============================public variables============================
- //===========================================================================
- volatile uint8_t buttons=0; //the last checked buttons in a bit array.
- long encoderpos=0;
- short lastenc=0;
-
- //TODO: This should be in a preferences file.
- int plaPreheatHotendTemp;
- int plaPreheatHPBTemp;
- int plaPreheatFanSpeed;
-
- int absPreheatHotendTemp;
- int absPreheatHPBTemp;
- int absPreheatFanSpeed;
-
- //===========================================================================
- //=============================private variables============================
- //===========================================================================
- static char messagetext[LCD_WIDTH]="";
-
- //return for string conversion routines
- static char conv[8];
-
- LCD_CLASS lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5,LCD_PINS_D6,LCD_PINS_D7); //RS,Enable,D4,D5,D6,D7
-
- static unsigned long previous_millis_lcd=0;
- //static long previous_millis_buttons=0;
-
-
- #ifdef NEWPANEL
- static unsigned long blocking=0;
- #else
- static unsigned long blocking[8]={0,0,0,0,0,0,0,0};
- #endif
-
- static MainMenu menu;
-
-
- void lcdProgMemprint(const char *str)
- {
- char ch=pgm_read_byte(str);
- while(ch)
- {
- lcd.print(ch);
- ch=pgm_read_byte(++str);
- }
- }
- #define LCD_PRINT_PGM(x) lcdProgMemprint(PSTR(x))
-
-
- //===========================================================================
- //=============================functions ============================
- //===========================================================================
-
- int intround(const float &x){return int(0.5+x);}
-
- void lcd_setstatus(const char* message)
- {
- strncpy(messagetext,message,LCD_WIDTH);
- messagetext[strlen(message)]=0;
- }
-
- void lcd_setstatuspgm(const char* message)
- {
- char ch=pgm_read_byte(message);
- char *target=messagetext;
- uint8_t cnt=0;
- while(ch &&cnt<LCD_WIDTH)
- {
- *target=ch;
- target++;
- cnt++;
- ch=pgm_read_byte(++message);
- }
- *target=0;
- }
-
- void lcd_setalertstatuspgm(const char* message)
- {
- lcd_setstatuspgm(message);
- menu.showStatus();
- }
-
- FORCE_INLINE void clear()
- {
- lcd.clear();
- }
-
-
- void lcd_init()
- {
- //beep();
- #ifdef ULTIPANEL
- lcd_buttons_init();
- #endif
-
- byte Degree[8] =
- {
- B01100,
- B10010,
- B10010,
- B01100,
- B00000,
- B00000,
- B00000,
- B00000
- };
- byte Thermometer[8] =
- {
- B00100,
- B01010,
- B01010,
- B01010,
- B01010,
- B10001,
- B10001,
- B01110
- };
- byte uplevel[8]={
- B00100,
- B01110,
- B11111,
- B00100,
- B11100,
- B00000,
- B00000,
- B00000
- }; //thanks joris
- byte refresh[8]={
- B00000,
- B00110,
- B11001,
- B11000,
- B00011,
- B10011,
- B01100,
- B00000,
- }; //thanks joris
- byte folder [8]={
- B00000,
- B11100,
- B11111,
- B10001,
- B10001,
- B11111,
- B00000,
- B00000
- }; //thanks joris
- lcd.begin(LCD_WIDTH, LCD_HEIGHT);
- lcd.createChar(1,Degree);
- lcd.createChar(2,Thermometer);
- lcd.createChar(3,uplevel);
- lcd.createChar(4,refresh);
- lcd.createChar(5,folder);
- LCD_MESSAGEPGM(WELCOME_MSG);
- }
-
-
- void beep()
- {
- //return;
- #ifdef ULTIPANEL
- #if (BEEPER > -1)
- {
- pinMode(BEEPER,OUTPUT);
- for(int8_t i=0;i<20;i++){
- WRITE(BEEPER,HIGH);
- delay(5);
- WRITE(BEEPER,LOW);
- delay(5);
- }
- }
- #endif
- #endif
- }
-
- void beepshort()
- {
- //return;
- #ifdef ULTIPANEL
- #if (BEEPER > -1)
- {
- pinMode(BEEPER,OUTPUT);
- for(int8_t i=0;i<10;i++){
- WRITE(BEEPER,HIGH);
- delay(3);
- WRITE(BEEPER,LOW);
- delay(3);
- }
- }
- #endif
- #endif
- }
-
- void lcd_update()
- {
- #ifdef ULTIPANEL
- static uint8_t oldbuttons=0;
- //static long previous_millis_buttons=0;
- //static long previous_lcdinit=0;
- // buttons_check(); // Done in temperature interrupt
- //previous_millis_buttons=millis();
- unsigned long ms=millis();
- for(int8_t i=0; i<8; i++) {
- #ifndef NEWPANEL
- if((blocking[i]>ms))
- buttons &= ~(1<<i);
- #else
- if((blocking>ms))
- buttons &= ~(1<<i);
- #endif
- }
- if((buttons==oldbuttons) && ((millis() - previous_millis_lcd) < LCD_UPDATE_INTERVAL) )
- return;
- oldbuttons=buttons;
- #else
-
- if(((millis() - previous_millis_lcd) < LCD_UPDATE_INTERVAL) )
- return;
- #endif
-
- previous_millis_lcd=millis();
- menu.update();
- }
- #ifdef ULTIPANEL
-
-
- void lcd_buttons_init()
- {
- #ifdef NEWPANEL
- pinMode(BTN_EN1,INPUT);
- pinMode(BTN_EN2,INPUT);
- pinMode(BTN_ENC,INPUT);
- pinMode(SDCARDDETECT,INPUT);
- WRITE(BTN_EN1,HIGH);
- WRITE(BTN_EN2,HIGH);
- WRITE(BTN_ENC,HIGH);
- #if (SDCARDDETECT > -1)
- {
- WRITE(SDCARDDETECT,HIGH);
- }
- #endif
- #else
- pinMode(SHIFT_CLK,OUTPUT);
- pinMode(SHIFT_LD,OUTPUT);
- pinMode(SHIFT_EN,OUTPUT);
- pinMode(SHIFT_OUT,INPUT);
- WRITE(SHIFT_OUT,HIGH);
- WRITE(SHIFT_LD,HIGH);
- WRITE(SHIFT_EN,LOW);
- #endif
- }
-
- /* Warning, this is called from interrupt context! */
- void lcd_buttons_update()
- {
-
- #ifdef NEWPANEL
- uint8_t newbutton=0;
- if(READ(BTN_EN1)==0) newbutton|=EN_A;
- if(READ(BTN_EN2)==0) newbutton|=EN_B;
- if((blocking<millis()) &&(READ(BTN_ENC)==0))
- newbutton|=EN_C;
- buttons=newbutton;
- #else //read it from the shift register
- uint8_t newbutton=0;
- WRITE(SHIFT_LD,LOW);
- WRITE(SHIFT_LD,HIGH);
- unsigned char tmp_buttons=0;
- for(int8_t i=0;i<8;i++)
- {
- newbutton = newbutton>>1;
- if(READ(SHIFT_OUT))
- newbutton|=(1<<7);
- WRITE(SHIFT_CLK,HIGH);
- WRITE(SHIFT_CLK,LOW);
- }
- buttons=~newbutton; //invert it, because a pressed switch produces a logical 0
- #endif
-
- //manage encoder rotation
- char enc=0;
- if(buttons&EN_A)
- enc|=(1<<0);
- if(buttons&EN_B)
- enc|=(1<<1);
- if(enc!=lastenc)
- {
- switch(enc)
- {
- case encrot0:
- if(lastenc==encrot3)
- encoderpos++;
- else if(lastenc==encrot1)
- encoderpos--;
- break;
- case encrot1:
- if(lastenc==encrot0)
- encoderpos++;
- else if(lastenc==encrot2)
- encoderpos--;
- break;
- case encrot2:
- if(lastenc==encrot1)
- encoderpos++;
- else if(lastenc==encrot3)
- encoderpos--;
- break;
- case encrot3:
- if(lastenc==encrot2)
- encoderpos++;
- else if(lastenc==encrot0)
- encoderpos--;
- break;
- default:
- ;
- }
- }
- lastenc=enc;
- }
-
- #endif
-
- MainMenu::MainMenu()
- {
- status=Main_Status;
- displayStartingRow=0;
- activeline=0;
- force_lcd_update=true;
- linechanging=false;
- tune=false;
- }
-
- void MainMenu::showStatus()
- {
- #if LCD_HEIGHT==4
- static int olddegHotEnd0=-1;
- static int oldtargetHotEnd0=-1;
- //force_lcd_update=true;
- if(force_lcd_update) //initial display of content
- {
- encoderpos=feedmultiply;
- clear();
- lcd.setCursor(0,0);LCD_PRINT_PGM("\002000/000\001 ");
- #if defined BED_USES_THERMISTOR || defined BED_USES_AD595
- lcd.setCursor(10,0);LCD_PRINT_PGM("B000/000\001 ");
- #elif EXTRUDERS > 1
- lcd.setCursor(10,0);LCD_PRINT_PGM("\002000/000\001 ");
- #endif
- }
-
- int tHotEnd0=intround(degHotend0());
- if((tHotEnd0!=olddegHotEnd0)||force_lcd_update)
- {
- lcd.setCursor(1,0);
- lcd.print(ftostr3(tHotEnd0));
- olddegHotEnd0=tHotEnd0;
- }
- int ttHotEnd0=intround(degTargetHotend0());
- if((ttHotEnd0!=oldtargetHotEnd0)||force_lcd_update)
- {
- lcd.setCursor(5,0);
- lcd.print(ftostr3(ttHotEnd0));
- oldtargetHotEnd0=ttHotEnd0;
- }
- #if defined BED_USES_THERMISTOR || defined BED_USES_AD595
- static int oldtBed=-1;
- static int oldtargetBed=-1;
- int tBed=intround(degBed());
- if((tBed!=oldtBed)||force_lcd_update)
- {
- lcd.setCursor(11,0);
- lcd.print(ftostr3(tBed));
- oldtBed=tBed;
- }
- int targetBed=intround(degTargetBed());
- if((targetBed!=oldtargetBed)||force_lcd_update)
- {
- lcd.setCursor(15,0);
- lcd.print(ftostr3(targetBed));
- oldtargetBed=targetBed;
- }
- #elif EXTRUDERS > 1
- static int olddegHotEnd1=-1;
- static int oldtargetHotEnd1=-1;
- int tHotEnd1=intround(degHotend1());
- if((tHotEnd1!=olddegHotEnd1)||force_lcd_update)
- {
- lcd.setCursor(11,0);
- lcd.print(ftostr3(tHotEnd1));
- olddegHotEnd1=tHotEnd1;
- }
- int ttHotEnd1=intround(degTargetHotend1());
- if((ttHotEnd1!=oldtargetHotEnd1)||force_lcd_update)
- {
- lcd.setCursor(15,0);
- lcd.print(ftostr3(ttHotEnd1));
- oldtargetHotEnd1=ttHotEnd1;
- }
- #endif
- //starttime=2;
- static uint16_t oldtime=0;
- if(starttime!=0)
- {
- lcd.setCursor(0,1);
- uint16_t time=millis()/60000-starttime/60000;
-
- if(starttime!=oldtime)
- {
- lcd.print(itostr2(time/60));LCD_PRINT_PGM("h ");lcd.print(itostr2(time%60));LCD_PRINT_PGM("m");
- oldtime=time;
- }
- }
- static int oldzpos=0;
- int currentz=current_position[2]*100;
- if((currentz!=oldzpos)||force_lcd_update)
- {
- lcd.setCursor(10,1);
- LCD_PRINT_PGM("Z:");lcd.print(ftostr52(current_position[2]));
- oldzpos=currentz;
- }
-
- static int oldfeedmultiply=0;
- int curfeedmultiply=feedmultiply;
-
- if(feedmultiplychanged == true) {
- feedmultiplychanged = false;
- encoderpos = curfeedmultiply;
- }
-
- if(encoderpos!=curfeedmultiply||force_lcd_update)
- {
- curfeedmultiply=encoderpos;
- if(curfeedmultiply<10)
- curfeedmultiply=10;
- if(curfeedmultiply>999)
- curfeedmultiply=999;
- feedmultiply=curfeedmultiply;
- encoderpos=curfeedmultiply;
- }
-
- if((curfeedmultiply!=oldfeedmultiply)||force_lcd_update)
- {
- oldfeedmultiply=curfeedmultiply;
- lcd.setCursor(0,2);
- lcd.print(itostr3(curfeedmultiply));LCD_PRINT_PGM("% ");
- }
-
- if(messagetext[0]!='\0')
- {
- lcd.setCursor(0,LCD_HEIGHT-1);
- lcd.print(messagetext);
- uint8_t n=strlen(messagetext);
- for(int8_t i=0;i<LCD_WIDTH-n;i++)
- lcd.print(" ");
- messagetext[0]='\0';
- }
- #ifdef SDSUPPORT
- static uint8_t oldpercent=101;
- uint8_t percent=card.percentDone();
- if(oldpercent!=percent ||force_lcd_update)
- {
- lcd.setCursor(10,2);
- lcd.print(itostr3((int)percent));
- LCD_PRINT_PGM("%SD");
- }
- #endif
- #else //smaller LCDS----------------------------------
- static int olddegHotEnd0=-1;
- static int oldtargetHotEnd0=-1;
- if(force_lcd_update) //initial display of content
- {
- encoderpos=feedmultiply;
- lcd.setCursor(0,0);LCD_PRINT_PGM("\002---/---\001 ");
- }
-
- int tHotEnd0=intround(degHotend0());
- int ttHotEnd0=intround(degTargetHotend0());
-
-
- if((abs(tHotEnd0-olddegHotEnd0)>1)||force_lcd_update)
- {
- lcd.setCursor(1,0);
- lcd.print(ftostr3(tHotEnd0));
- olddegHotEnd0=tHotEnd0;
- }
- if((ttHotEnd0!=oldtargetHotEnd0)||force_lcd_update)
- {
- lcd.setCursor(5,0);
- lcd.print(ftostr3(ttHotEnd0));
- oldtargetHotEnd0=ttHotEnd0;
- }
-
- if(messagetext[0]!='\0')
- {
- lcd.setCursor(0,LCD_HEIGHT-1);
- lcd.print(messagetext);
- uint8_t n=strlen(messagetext);
- for(int8_t i=0;i<LCD_WIDTH-n;i++)
- lcd.print(" ");
- messagetext[0]='\0';
- }
-
- #endif
- force_lcd_update=false;
- }
-
- enum {ItemP_exit, ItemP_autostart,ItemP_disstep,ItemP_home, ItemP_origin, ItemP_preheat_pla, ItemP_preheat_abs, ItemP_cooldown,/*ItemP_extrude,*/ItemP_move};
-
- //any action must not contain a ',' character anywhere, or this breaks:
- #define MENUITEM(repaint_action, click_action) \
- {\
- if(force_lcd_update) { lcd.setCursor(0,line); repaint_action; } \
- if((activeline==line) && LCD_CLICKED) {click_action} \
- }
-
- void MainMenu::showPrepare()
- {
- #ifdef ULTIPANEL
- uint8_t line=0;
- clearIfNecessary();
- for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
- {
- //Serial.println((int)(line-lineoffset));
- switch(i)
- {
- case ItemP_exit:
- MENUITEM( LCD_PRINT_PGM(MSG_MAIN) , LCD_BLOCK;status=Main_Menu;beepshort(); ) ;
- break;
- case ItemP_autostart:
- MENUITEM( LCD_PRINT_PGM(MSG_AUTOSTART) , LCD_BLOCK;
- #ifdef SDSUPPORT
- card.lastnr=0;card.setroot();card.checkautostart(true);
- #endif
- beepshort(); ) ;
- break;
- case ItemP_disstep:
- MENUITEM( LCD_PRINT_PGM(MSG_DISABLE_STEPPERS) , LCD_BLOCK;enquecommand("M84");beepshort(); ) ;
- break;
- case ItemP_home:
- MENUITEM( LCD_PRINT_PGM(MSG_AUTO_HOME) , LCD_BLOCK;enquecommand("G28");beepshort(); ) ;
- break;
- case ItemP_origin:
- MENUITEM( LCD_PRINT_PGM(MSG_SET_ORIGIN) , LCD_BLOCK;enquecommand("G92 X0 Y0 Z0");beepshort(); ) ;
- break;
- case ItemP_preheat_pla:
- MENUITEM( LCD_PRINT_PGM(MSG_PREHEAT_PLA) , LCD_BLOCK;setTargetHotend0(plaPreheatHotendTemp);setTargetBed(plaPreheatHPBTemp);
- #if FAN_PIN > -1
- fanSpeed = plaPreheatFanSpeed;
- analogWrite(FAN_PIN, fanSpeed);
- #endif
- beepshort(); );
- break;
- case ItemP_preheat_abs:
- MENUITEM( LCD_PRINT_PGM(MSG_PREHEAT_ABS) , LCD_BLOCK;setTargetHotend0(absPreheatHotendTemp);setTargetBed(absPreheatHPBTemp);
- #if FAN_PIN > -1
- fanSpeed = absPreheatFanSpeed;
- analogWrite(FAN_PIN, fanSpeed);
- #endif
- beepshort(); );
- break;
- case ItemP_cooldown:
- MENUITEM( LCD_PRINT_PGM(MSG_COOLDOWN) , LCD_BLOCK;setTargetHotend0(0);setTargetHotend1(0);setTargetHotend2(0);setTargetBed(0);beepshort(); ) ;
- break;
- // case ItemP_extrude:
- // MENUITEM( LCD_PRINT_PGM(" Extrude") , LCD_BLOCK;enquecommand("G92 E0");enquecommand("G1 F700 E50");beepshort(); ) ;
- // break;
- case ItemP_move:
- MENUITEM( LCD_PRINT_PGM(MSG_MOVE_AXIS) , LCD_BLOCK;status=Sub_PrepareMove;beepshort(); );
- break;
- default:
- break;
- }
- line++;
- }
- updateActiveLines(ItemP_move,encoderpos);
- #endif
- }
-
- enum {
- ItemAM_exit,
- ItemAM_X, ItemAM_Y, ItemAM_Z, ItemAM_E, ItemAM_ERetract
- };
-
- void MainMenu::showAxisMove()
- {
- uint8_t line=0;
- int oldencoderpos=0;
- clearIfNecessary();
- for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
- {
- switch(i)
- {
- case ItemAM_exit:
- MENUITEM( LCD_PRINT_PGM(MSG_PREPARE_ALT) , LCD_BLOCK;status=Main_Prepare;beepshort(); ) ;
- break;
- case ItemAM_X:
- {
- //oldencoderpos=0;
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(" X:");
- lcd.setCursor(11,line);lcd.print(ftostr52(current_position[X_AXIS]));
- }
-
- if((activeline!=line) )
- break;
-
- if(LCD_CLICKED)
- {
- linechanging=!linechanging;
- if(linechanging)
- {
- enquecommand("G91");
- }
- else
- {
- enquecommand("G90");
- encoderpos=activeline*lcdslow;
- beepshort();
- }
- LCD_BLOCK;
- }
- if(linechanging)
- {
- if (encoderpos >0)
- {
- enquecommand("G1 F700 X0.1");
- oldencoderpos=encoderpos;
- encoderpos=0;
- }
-
- else if (encoderpos < 0)
- {
- enquecommand("G1 F700 X-0.1");
- oldencoderpos=encoderpos;
- encoderpos=0;
- }
- lcd.setCursor(11,line);lcd.print(ftostr52(current_position[X_AXIS]));
- }
- }
- break;
- case ItemAM_Y:
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(" Y:");
- lcd.setCursor(11,line);lcd.print(ftostr52(current_position[Y_AXIS]));
- }
-
- if((activeline!=line) )
- break;
-
- if(LCD_CLICKED)
- {
- linechanging=!linechanging;
- if(linechanging)
- {
- enquecommand("G91");
- }
- else
- {
- enquecommand("G90");
- encoderpos=activeline*lcdslow;
- beepshort();
- }
- LCD_BLOCK;
- }
- if(linechanging)
- {
- if (encoderpos >0)
- {
- enquecommand("G1 F700 Y0.1");
- oldencoderpos=encoderpos;
- encoderpos=0;
- }
-
- else if (encoderpos < 0)
- {
- enquecommand("G1 F700 Y-0.1");
- oldencoderpos=encoderpos;
- encoderpos=0;
- }
- lcd.setCursor(11,line);lcd.print(ftostr52(current_position[Y_AXIS]));
- }
- }
- break;
- case ItemAM_Z:
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(" Z:");
- lcd.setCursor(11,line);lcd.print(ftostr52(current_position[Z_AXIS]));
- }
-
- if((activeline!=line) )
- break;
-
- if(LCD_CLICKED)
- {
- linechanging=!linechanging;
- if(linechanging)
- {
- enquecommand("G91");
- }
- else
- {
- enquecommand("G90");
- encoderpos=activeline*lcdslow;
- beepshort();
- }
- LCD_BLOCK;
- }
- if(linechanging)
- {
- if (encoderpos >0)
- {
- enquecommand("G1 F70 Z0.1");
- oldencoderpos=encoderpos;
- encoderpos=0;
- }
-
- else if (encoderpos < 0)
- {
- enquecommand("G1 F70 Z-0.1");
- oldencoderpos=encoderpos;
- encoderpos=0;
- }
- lcd.setCursor(11,line);lcd.print(ftostr52(current_position[Z_AXIS]));
- }
- }
- break;
- case ItemAM_E:
- // ErikDB: TODO: this length should be changed for volumetric.
- MENUITEM( LCD_PRINT_PGM(MSG_EXTRUDE) , LCD_BLOCK;enquecommand("G92 E0");enquecommand("G1 F70 E1");beepshort(); ) ;
- break;
- case ItemAM_ERetract:
- // ErikDB: TODO: this length should be changed for volumetric.
- MENUITEM( LCD_PRINT_PGM(MSG_RETRACT) , LCD_BLOCK;enquecommand("G92 E0");enquecommand("G1 F700 E-1");beepshort(); ) ;
- break;
- default:
- break;
- }
- line++;
- }
- updateActiveLines(ItemAM_ERetract,encoderpos);
- }
-
- enum {ItemT_exit,ItemT_speed,ItemT_flow,ItemT_nozzle,
- #if (HEATER_BED_PIN > -1)
- ItemT_bed,
- #endif
- ItemT_fan};
-
- void MainMenu::showTune()
- {
- uint8_t line=0;
- clearIfNecessary();
- for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
- {
- //Serial.println((int)(line-lineoffset));
- switch(i)
- {
- case ItemT_exit:
- MENUITEM( LCD_PRINT_PGM(MSG_MAIN) , LCD_BLOCK;status=Main_Menu;beepshort(); ) ;
- break;
- case ItemT_speed:
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_SPEED);
- lcd.setCursor(13,line);lcd.print(ftostr3(feedmultiply));
- }
-
- if((activeline!=line) )
- break;
-
- if(LCD_CLICKED) //AnalogWrite(FAN_PIN, fanpwm);
- {
- linechanging=!linechanging;
- if(linechanging)
- {
- encoderpos=feedmultiply;
- }
- else
- {
- encoderpos=activeline*lcdslow;
- beepshort();
- }
- LCD_BLOCK;
- }
- if(linechanging)
- {
- if(encoderpos<1) encoderpos=1;
- if(encoderpos>400) encoderpos=400;
- feedmultiply = encoderpos;
- feedmultiplychanged=true;
- lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
- }
-
- }break;
- case ItemT_nozzle:
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_NOZZLE);
- lcd.setCursor(13,line);lcd.print(ftostr3(intround(degTargetHotend0())));
- }
-
- if((activeline!=line) )
- break;
-
- if(LCD_CLICKED)
- {
- linechanging=!linechanging;
- if(linechanging)
- {
- encoderpos=intround(degTargetHotend0());
- }
- else
- {
- setTargetHotend0(encoderpos);
- encoderpos=activeline*lcdslow;
- beepshort();
- }
- LCD_BLOCK;
- }
- if(linechanging)
- {
- if(encoderpos<0) encoderpos=0;
- if(encoderpos>260) encoderpos=260;
- lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
- }
- }break;
- #if (HEATER_BED_PIN > -1)
- case ItemT_bed:
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_BED);
- lcd.setCursor(13,line);lcd.print(ftostr3(intround(degTargetBed())));
- }
-
- if((activeline!=line) )
- break;
-
- if(LCD_CLICKED)
- {
- linechanging=!linechanging;
- if(linechanging)
- {
- encoderpos=intround(degTargetBed());
- }
- else
- {
- setTargetBed(encoderpos);
- encoderpos=activeline*lcdslow;
- beepshort();
- }
- LCD_BLOCK;
- }
- if(linechanging)
- {
- if(encoderpos<0) encoderpos=0;
- if(encoderpos>260) encoderpos=260;
- lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
- }
- }break;
- #endif
-
-
- case ItemT_fan:
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_FAN_SPEED);
- lcd.setCursor(13,line);lcd.print(ftostr3(fanSpeed));
- }
-
- if((activeline!=line) )
- break;
-
- if(LCD_CLICKED) //nalogWrite(FAN_PIN, fanpwm);
- {
- linechanging=!linechanging;
- if(linechanging)
- {
- encoderpos=fanSpeed;
- }
- else
- {
- encoderpos=activeline*lcdslow;
- beepshort();
- }
- LCD_BLOCK;
- }
- if(linechanging)
- {
- if(encoderpos<0) encoderpos=0;
- if(encoderpos>255) encoderpos=255;
- fanSpeed=encoderpos;
- analogWrite(FAN_PIN, fanSpeed);
- lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
- }
-
- }break;
- case ItemT_flow://axis_steps_per_unit[i] = code_value();
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_FLOW);
- lcd.setCursor(13,line);lcd.print(ftostr52(axis_steps_per_unit[E_AXIS]));
- }
-
- if((activeline!=line) )
- break;
-
- if(LCD_CLICKED)
- {
- linechanging=!linechanging;
- if(linechanging)
- {
- encoderpos=(long)(axis_steps_per_unit[E_AXIS]*100.0);
- }
- else
- {
- float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[E_AXIS]);
- position[E_AXIS]=lround(position[E_AXIS]*factor);
- //current_position[E_AXIS]*=factor;
- axis_steps_per_unit[E_AXIS]= encoderpos/100.0;
- encoderpos=activeline*lcdslow;
-
- }
- LCD_BLOCK;
- beepshort();
- }
- if(linechanging)
- {
- if(encoderpos<5) encoderpos=5;
- if(encoderpos>999999) encoderpos=999999;
- lcd.setCursor(13,line);lcd.print(ftostr52(encoderpos/100.0));
- }
-
- }break;
- default:
- break;
- }
- line++;
- }
- updateActiveLines(ItemT_fan,encoderpos);
- }
-
- /*does not work
- #define MENUCHANGEITEM(repaint_action, enter_action, accept_action, change_action) \
- {\
- if(force_lcd_update) { lcd.setCursor(0,line); repaint_action; } \
- if(activeline==line) \
- { \
- if(LCD_CLICKED) \
- { \
- linechanging=!linechanging; \
- if(linechanging) {enter_action;} \
- else {accept_action;} \
- } \
- else \
- if(linechanging) {change_action};}\
- }
- */
-
- enum {
- ItemCT_exit,ItemCT_nozzle0,
- #ifdef AUTOTEMP
- ItemCT_autotempactive,
- ItemCT_autotempmin,ItemCT_autotempmax,ItemCT_autotempfact,
- #endif
- #if EXTRUDERS > 1
- ItemCT_nozzle1,
- #endif
- #if EXTRUDERS > 2
- ItemCT_nozzle2,
- #endif
- #if defined BED_USES_THERMISTOR || defined BED_USES_AD595
- ItemCT_bed,
- #endif
- ItemCT_fan,
- ItemCT_PID_P,ItemCT_PID_I,ItemCT_PID_D,ItemCT_PID_C,
- ItemCT_PLA_PreHeat_Setting,
- ItemCT_ABS_PreHeat_Setting,
- };
-
- void MainMenu::showControlTemp()
- {
- uint8_t line=0;
- clearIfNecessary();
- for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
- {
- switch(i)
- {
- case ItemCT_exit:
- MENUITEM( LCD_PRINT_PGM(MSG_CONTROL) , LCD_BLOCK;status=Main_Control;beepshort(); ) ;
- break;
- case ItemCT_nozzle0:
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_NOZZLE);
- lcd.setCursor(13,line);lcd.print(ftostr3(intround(degTargetHotend0())));
- }
-
- if((activeline!=line) )
- break;
-
- if(LCD_CLICKED)
- {
- linechanging=!linechanging;
- if(linechanging)
- {
- encoderpos=intround(degTargetHotend0());
- }
- else
- {
- setTargetHotend0(encoderpos);
- encoderpos=activeline*lcdslow;
- beepshort();
- }
- LCD_BLOCK;
- }
- if(linechanging)
- {
- if(encoderpos<0) encoderpos=0;
- if(encoderpos>260) encoderpos=260;
- lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
- }
-
- }break;
- #if EXTRUDERS > 1
- case ItemCT_nozzle1:
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_NOZZLE1);
- lcd.setCursor(13,line);lcd.print(ftostr3(intround(degTargetHotend1())));
- }
-
- if((activeline!=line) )
- break;
-
- if(LCD_CLICKED)
- {
- linechanging=!linechanging;
- if(linechanging)
- {
- encoderpos=intround(degTargetHotend1());
- }
- else
- {
- setTargetHotend1(encoderpos);
- encoderpos=activeline*lcdslow;
- beepshort();
- }
- LCD_BLOCK;
- }
- if(linechanging)
- {
- if(encoderpos<0) encoderpos=0;
- if(encoderpos>260) encoderpos=260;
- lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
- }
-
- }break;
- #endif
- #if EXTRUDERS > 2
- case ItemCT_nozzle2:
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_NOZZLE2);
- lcd.setCursor(13,line);lcd.print(ftostr3(intround(degTargetHotend2())));
- }
-
- if((activeline!=line) )
- break;
-
- if(LCD_CLICKED)
- {
- linechanging=!linechanging;
- if(linechanging)
- {
- encoderpos=intround(degTargetHotend2());
- }
- else
- {
- setTargetHotend2(encoderpos);
- encoderpos=activeline*lcdslow;
- beepshort();
- }
- LCD_BLOCK;
- }
- if(linechanging)
- {
- if(encoderpos<0) encoderpos=0;
- if(encoderpos>260) encoderpos=260;
- lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
- }
-
- }break;
- #endif
- #ifdef AUTOTEMP
- case ItemCT_autotempmin:
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_MIN);
- lcd.setCursor(13,line);lcd.print(ftostr3(autotemp_min));
- }
-
- if((activeline!=line) )
- break;
-
- if(LCD_CLICKED)
- {
- linechanging=!linechanging;
- if(linechanging)
- {
- encoderpos=intround(autotemp_min);
- }
- else
- {
- autotemp_min=encoderpos;
- encoderpos=activeline*lcdslow;
- beepshort();
- }
- LCD_BLOCK;
- }
- if(linechanging)
- {
- if(encoderpos<0) encoderpos=0;
- if(encoderpos>260) encoderpos=260;
- lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
- }
-
- }break;
- case ItemCT_autotempmax:
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_MAX);
- lcd.setCursor(13,line);lcd.print(ftostr3(autotemp_max));
- }
-
- if((activeline!=line) )
- break;
-
- if(LCD_CLICKED)
- {
- linechanging=!linechanging;
- if(linechanging)
- {
- encoderpos=intround(autotemp_max);
- }
- else
- {
- autotemp_max=encoderpos;
- encoderpos=activeline*lcdslow;
- beepshort();
- }
- LCD_BLOCK;
- }
- if(linechanging)
- {
- if(encoderpos<0) encoderpos=0;
- if(encoderpos>260) encoderpos=260;
- lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
- }
-
- }break;
- case ItemCT_autotempfact:
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_FACTOR);
- lcd.setCursor(13,line);lcd.print(ftostr32(autotemp_factor));
- }
-
- if((activeline!=line) )
- break;
-
- if(LCD_CLICKED)
- {
- linechanging=!linechanging;
- if(linechanging)
- {
- encoderpos=intround(autotemp_factor*100);
- }
- else
- {
- autotemp_max=encoderpos;
- encoderpos=activeline*lcdslow;
- beepshort();
- }
- LCD_BLOCK;
- }
- if(linechanging)
- {
- if(encoderpos<0) encoderpos=0;
- if(encoderpos>99) encoderpos=99;
- lcd.setCursor(13,line);lcd.print(ftostr32(encoderpos/100.));
- }
-
- }break;
- case ItemCT_autotempactive:
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_AUTOTEMP);
- lcd.setCursor(13,line);
- if(autotemp_enabled)
- LCD_PRINT_PGM(MSG_ON);
- else
- LCD_PRINT_PGM(MSG_OFF);
- }
-
- if((activeline!=line) )
- break;
-
- if(LCD_CLICKED)
- {
- autotemp_enabled=!autotemp_enabled;
- lcd.setCursor(13,line);
- if(autotemp_enabled)
- LCD_PRINT_PGM(MSG_ON);
- else
- LCD_PRINT_PGM(MSG_OFF);
- LCD_BLOCK;
- }
-
- }break;
- #endif //autotemp
- #if defined BED_USES_THERMISTOR || defined BED_USES_AD595
- case ItemCT_bed:
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_BED);
- lcd.setCursor(13,line);lcd.print(ftostr3(intround(degTargetBed())));
- }
-
- if((activeline!=line) )
- break;
-
- if(LCD_CLICKED)
- {
- linechanging=!linechanging;
- if(linechanging)
- {
- encoderpos=intround(degTargetBed());
- }
- else
- {
- setTargetBed(encoderpos);
- encoderpos=activeline*lcdslow;
- beepshort();
- }
- LCD_BLOCK;
- }
- if(linechanging)
- {
- if(encoderpos<0) encoderpos=0;
- if(encoderpos>260) encoderpos=260;
- lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
- }
- }break;
- #endif
- case ItemCT_fan:
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_FAN_SPEED);
- lcd.setCursor(13,line);lcd.print(ftostr3(fanSpeed));
- }
-
- if((activeline!=line) )
- break;
-
- if(LCD_CLICKED) //nalogWrite(FAN_PIN, fanpwm);
- {
- linechanging=!linechanging;
- if(linechanging)
- {
- encoderpos=fanSpeed;
- }
- else
- {
- encoderpos=activeline*lcdslow;
- beepshort();
- }
- LCD_BLOCK;
- }
- if(linechanging)
- {
- if(encoderpos<0) encoderpos=0;
- if(encoderpos>255) encoderpos=255;
- fanSpeed=encoderpos;
- analogWrite(FAN_PIN, fanSpeed);
- lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
- }
-
- }break;
- #ifdef PIDTEMP
- case ItemCT_PID_P:
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(" PID-P: ");
- lcd.setCursor(13,line);lcd.print(itostr4(Kp));
- }
-
- if((activeline!=line) )
- break;
-
- if(LCD_CLICKED)
- {
- linechanging=!linechanging;
- if(linechanging)
- {
- encoderpos=(long)Kp;
- }
- else
- {
- Kp= encoderpos;
- encoderpos=activeline*lcdslow;
-
- }
- LCD_BLOCK;
- beepshort();
- }
- if(linechanging)
- {
- if(encoderpos<1) encoderpos=1;
- if(encoderpos>9990) encoderpos=9990;
- lcd.setCursor(13,line);lcd.print(itostr4(encoderpos));
- }
-
- }break;
- case ItemCT_PID_I:
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_PID_I);
- lcd.setCursor(13,line);lcd.print(ftostr51(Ki/PID_dT));
- }
-
- if((activeline!=line) )
- break;
-
- if(LCD_CLICKED)
- {
- linechanging=!linechanging;
- if(linechanging)
- {
- encoderpos=(long)(Ki*10/PID_dT);
- }
- else
- {
- Ki= encoderpos/10.*PID_dT;
- encoderpos=activeline*lcdslow;
-
- }
- LCD_BLOCK;
- beepshort();
- }
- if(linechanging)
- {
- if(encoderpos<0) encoderpos=0;
- if(encoderpos>9990) encoderpos=9990;
- lcd.setCursor(13,line);lcd.print(ftostr51(encoderpos/10.));
- }
-
- }break;
- case ItemCT_PID_D:
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_PID_D);
- lcd.setCursor(13,line);lcd.print(itostr4(Kd*PID_dT));
- }
-
- if((activeline!=line) )
- break;
-
-
- if(LCD_CLICKED)
- {
- linechanging=!linechanging;
- if(linechanging)
- {
- encoderpos=(long)(Kd/5./PID_dT);
- }
- else
- {
- Kd= encoderpos;
- encoderpos=activeline*lcdslow;
-
- }
- LCD_BLOCK;
- beepshort();
- }
- if(linechanging)
- {
- if(encoderpos<0) encoderpos=0;
- if(encoderpos>9990) encoderpos=9990;
- lcd.setCursor(13,line);lcd.print(itostr4(encoderpos));
- }
-
- }break;
- case ItemCT_PID_C:
- #ifdef PID_ADD_EXTRUSION_RATE
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_PID_C);
- lcd.setCursor(13,line);lcd.print(itostr3(Kc));
- }
-
- if((activeline!=line) )
- break;
-
- if(LCD_CLICKED)
- {
- linechanging=!linechanging;
- if(linechanging)
- {
- encoderpos=(long)Kc;
- }
- else
- {
- Kc= encoderpos;
- encoderpos=activeline*lcdslow;
-
- }
- LCD_BLOCK;
- beepshort();
- }
- if(linechanging)
- {
- if(encoderpos<0) encoderpos=0;
- if(encoderpos>990) encoderpos=990;
- lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
- }
-
- }
- #endif
- #endif
- break;
- case ItemCT_PLA_PreHeat_Setting:
- MENUITEM( LCD_PRINT_PGM(MSG_PREHEAT_PLA_SETTINGS) , LCD_BLOCK;status=Sub_PreheatPLASettings;beepshort(); ) ;
- break;
- case ItemCT_ABS_PreHeat_Setting:
- MENUITEM( LCD_PRINT_PGM(MSG_PREHEAT_ABS_SETTINGS) , LCD_BLOCK;status=Sub_PreheatABSSettings;beepshort(); ) ;
- break;
- default:
- break;
- }
- line++;
- }
-
- updateActiveLines(ItemCT_ABS_PreHeat_Setting,encoderpos);
- }
-
-
- enum {
- ItemCM_exit,
- ItemCM_acc, ItemCM_xyjerk,
- ItemCM_vmaxx, ItemCM_vmaxy, ItemCM_vmaxz, ItemCM_vmaxe,
- ItemCM_vtravmin,ItemCM_vmin,
- ItemCM_amaxx, ItemCM_amaxy, ItemCM_amaxz, ItemCM_amaxe,
- ItemCM_aret, ItemCM_xsteps,ItemCM_ysteps, ItemCM_zsteps, ItemCM_esteps
- };
-
-
-
- void MainMenu::showControlMotion()
- {
- uint8_t line=0;
- clearIfNecessary();
- for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
- {
- switch(i)
- {
- case ItemCM_exit:
- MENUITEM( LCD_PRINT_PGM(MSG_CONTROL) , LCD_BLOCK;status=Main_Control;beepshort(); ) ;
- break;
- case ItemCM_acc:
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_ACC);
- lcd.setCursor(13,line);lcd.print(itostr3(acceleration/100));LCD_PRINT_PGM("00");
- }
-
- if((activeline!=line) )
- break;
-
- if(LCD_CLICKED)
- {
- linechanging=!linechanging;
- if(linechanging)
- {
- encoderpos=(long)acceleration/100;
- }
- else
- {
- acceleration= encoderpos*100;
- encoderpos=activeline*lcdslow;
- }
- LCD_BLOCK;
- beepshort();
- }
- if(linechanging)
- {
- if(encoderpos<5) encoderpos=5;
- if(encoderpos>990) encoderpos=990;
- lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));LCD_PRINT_PGM("00");
- }
-
- }break;
- case ItemCM_xyjerk: //max_xy_jerk
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_VXY_JERK);
- lcd.setCursor(13,line);lcd.print(itostr3(max_xy_jerk));
- }
-
- if((activeline!=line) )
- break;
-
- if(LCD_CLICKED)
- {
- linechanging=!linechanging;
- if(linechanging)
- {
- encoderpos=(long)max_xy_jerk;
- }
- else
- {
- max_xy_jerk= encoderpos;
- encoderpos=activeline*lcdslow;
-
- }
- LCD_BLOCK;
- beepshort();
- }
- if(linechanging)
- {
- if(encoderpos<1) encoderpos=1;
- if(encoderpos>990) encoderpos=990;
- lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
- }
-
- }break;
-
- case ItemCM_vmaxx:
- case ItemCM_vmaxy:
- case ItemCM_vmaxz:
- case ItemCM_vmaxe:
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_VMAX);
- if(i==ItemCM_vmaxx)LCD_PRINT_PGM(MSG_X);
- if(i==ItemCM_vmaxy)LCD_PRINT_PGM(MSG_Y);
- if(i==ItemCM_vmaxz)LCD_PRINT_PGM(MSG_Z);
- if(i==ItemCM_vmaxe)LCD_PRINT_PGM(MSG_E);
- lcd.setCursor(13,line);lcd.print(itostr3(max_feedrate[i-ItemCM_vmaxx]));
- }
-
- if((activeline!=line) )
- break;
-
- if(LCD_CLICKED)
- {
- linechanging=!linechanging;
- if(linechanging)
- {
- encoderpos=(long)max_feedrate[i-ItemCM_vmaxx];
- }
- else
- {
- max_feedrate[i-ItemCM_vmaxx]= encoderpos;
- encoderpos=activeline*lcdslow;
-
- }
- LCD_BLOCK;
- beepshort();
- }
- if(linechanging)
- {
- if(encoderpos<1) encoderpos=1;
- if(encoderpos>990) encoderpos=990;
- lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
- }
-
- }break;
-
- case ItemCM_vmin:
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_VMIN);
- lcd.setCursor(13,line);lcd.print(itostr3(minimumfeedrate));
- }
-
- if((activeline!=line) )
- break;
-
- if(LCD_CLICKED)
- {
- linechanging=!linechanging;
- if(linechanging)
- {
- encoderpos=(long)(minimumfeedrate);
- }
- else
- {
- minimumfeedrate= encoderpos;
- encoderpos=activeline*lcdslow;
-
- }
- LCD_BLOCK;
- beepshort();
- }
- if(linechanging)
- {
- if(encoderpos<0) encoderpos=0;
- if(encoderpos>990) encoderpos=990;
- lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
- }
-
- }break;
- case ItemCM_vtravmin:
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_VTRAV_MIN);
- lcd.setCursor(13,line);lcd.print(itostr3(mintravelfeedrate));
- }
-
- if((activeline!=line) )
- break;
-
- if(LCD_CLICKED)
- {
- linechanging=!linechanging;
- if(linechanging)
- {
- encoderpos=(long)mintravelfeedrate;
- }
- else
- {
- mintravelfeedrate= encoderpos;
- encoderpos=activeline*lcdslow;
-
- }
- LCD_BLOCK;
- beepshort();
- }
- if(linechanging)
- {
- if(encoderpos<0) encoderpos=0;
- if(encoderpos>990) encoderpos=990;
- lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
- }
-
- }break;
-
- case ItemCM_amaxx:
- case ItemCM_amaxy:
- case ItemCM_amaxz:
- case ItemCM_amaxe:
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(" Amax ");
- if(i==ItemCM_amaxx)LCD_PRINT_PGM(MSG_X);
- if(i==ItemCM_amaxy)LCD_PRINT_PGM(MSG_Y);
- if(i==ItemCM_amaxz)LCD_PRINT_PGM(MSG_Z);
- if(i==ItemCM_amaxe)LCD_PRINT_PGM(MSG_E);
- lcd.setCursor(13,line);lcd.print(itostr3(max_acceleration_units_per_sq_second[i-ItemCM_amaxx]/100));LCD_PRINT_PGM("00");
- }
-
- if((activeline!=line) )
- break;
-
- if(LCD_CLICKED)
- {
- linechanging=!linechanging;
- if(linechanging)
- {
- encoderpos=(long)max_acceleration_units_per_sq_second[i-ItemCM_amaxx]/100;
- }
- else
- {
- max_acceleration_units_per_sq_second[i-ItemCM_amaxx]= encoderpos*100;
- encoderpos=activeline*lcdslow;
- }
- LCD_BLOCK;
- beepshort();
- }
- if(linechanging)
- {
- if(encoderpos<1) encoderpos=1;
- if(encoderpos>990) encoderpos=990;
- lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));LCD_PRINT_PGM("00");
- }
-
- }break;
-
-
- case ItemCM_aret://float retract_acceleration = 7000;
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_A_RETRACT);
- lcd.setCursor(13,line);lcd.print(ftostr3(retract_acceleration/100));LCD_PRINT_PGM("00");
- }
-
- if((activeline!=line) )
- break;
-
- if(LCD_CLICKED)
- {
- linechanging=!linechanging;
- if(linechanging)
- {
- encoderpos=(long)retract_acceleration/100;
- }
- else
- {
- retract_acceleration= encoderpos*100;
- encoderpos=activeline*lcdslow;
-
- }
- LCD_BLOCK;
- beepshort();
- }
- if(linechanging)
- {
- if(encoderpos<10) encoderpos=10;
- if(encoderpos>990) encoderpos=990;
- lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));LCD_PRINT_PGM("00");
- }
-
- }break;
- case ItemCM_xsteps://axis_steps_per_unit[i] = code_value();
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_XSTEPS);
- lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[X_AXIS]));
- }
-
- if((activeline!=line) )
- break;
-
- if(LCD_CLICKED)
- {
- linechanging=!linechanging;
- if(linechanging)
- {
- encoderpos=(long)(axis_steps_per_unit[X_AXIS]*100.0);
- }
- else
- {
- float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[X_AXIS]);
- position[X_AXIS]=lround(position[X_AXIS]*factor);
- //current_position[X_AXIS]*=factor;
- axis_steps_per_unit[X_AXIS]= encoderpos/100.0;
- encoderpos=activeline*lcdslow;
- }
- LCD_BLOCK;
- beepshort();
- }
- if(linechanging)
- {
- if(encoderpos<5) encoderpos=5;
- if(encoderpos>999999) encoderpos=999999;
- lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0));
- }
-
- }break;
- case ItemCM_ysteps://axis_steps_per_unit[i] = code_value();
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_YSTEPS);
- lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[Y_AXIS]));
- }
-
- if((activeline!=line) )
- break;
-
- if(LCD_CLICKED)
- {
- linechanging=!linechanging;
- if(linechanging)
- {
- encoderpos=(long)(axis_steps_per_unit[Y_AXIS]*100.0);
- }
- else
- {
- float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[Y_AXIS]);
- position[Y_AXIS]=lround(position[Y_AXIS]*factor);
- //current_position[Y_AXIS]*=factor;
- axis_steps_per_unit[Y_AXIS]= encoderpos/100.0;
- encoderpos=activeline*lcdslow;
-
- }
- LCD_BLOCK;
- beepshort();
- }
- if(linechanging)
- {
- if(encoderpos<5) encoderpos=5;
- if(encoderpos>999999) encoderpos=999999;
- lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0));
- }
-
- }break;
- case ItemCM_zsteps://axis_steps_per_unit[i] = code_value();
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_ZSTEPS);
- lcd.setCursor(11,line);lcd.print(ftostr51(axis_steps_per_unit[Z_AXIS]));
- }
-
- if((activeline!=line) )
- break;
-
- if(LCD_CLICKED)
- {
- linechanging=!linechanging;
- if(linechanging)
- {
- encoderpos=(long)(axis_steps_per_unit[Z_AXIS]*100.0);
- }
- else
- {
- float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[Z_AXIS]);
- position[Z_AXIS]=lround(position[Z_AXIS]*factor);
- //current_position[Z_AXIS]*=factor;
- axis_steps_per_unit[Z_AXIS]= encoderpos/100.0;
- encoderpos=activeline*lcdslow;
-
- }
- LCD_BLOCK;
- beepshort();
- }
- if(linechanging)
- {
- if(encoderpos<5) encoderpos=5;
- if(encoderpos>999999) encoderpos=999999;
- lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0));
- }
-
- }break;
-
- case ItemCM_esteps://axis_steps_per_unit[i] = code_value();
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_ESTEPS);
- lcd.setCursor(11,line);lcd.print(ftostr51(axis_steps_per_unit[E_AXIS]));
- }
-
- if((activeline!=line) )
- break;
-
- if(LCD_CLICKED)
- {
- linechanging=!linechanging;
- if(linechanging)
- {
- encoderpos=(long)(axis_steps_per_unit[E_AXIS]*100.0);
- }
- else
- {
- float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[E_AXIS]);
- position[E_AXIS]=lround(position[E_AXIS]*factor);
- //current_position[E_AXIS]*=factor;
- axis_steps_per_unit[E_AXIS]= encoderpos/100.0;
- encoderpos=activeline*lcdslow;
-
- }
- LCD_BLOCK;
- beepshort();
- }
- if(linechanging)
- {
- if(encoderpos<5) encoderpos=5;
- if(encoderpos>999999) encoderpos=999999;
- lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0));
- }
-
- }break;
- default:
- break;
- }
- line++;
- }
- updateActiveLines(ItemCM_esteps,encoderpos);
- }
-
-
- enum {
- ItemR_exit,
- ItemR_autoretract,
- ItemR_retract_length,ItemR_retract_feedrate,ItemR_retract_zlift,
- ItemR_unretract_length,ItemR_unretract_feedrate,
-
- };
-
-
-
- void MainMenu::showControlRetract()
- {
- #ifdef FWRETRACT
- uint8_t line=0;
- clearIfNecessary();
- for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
- {
- switch(i)
- {
- case ItemR_exit:
- MENUITEM( LCD_PRINT_PGM(MSG_CONTROL) , LCD_BLOCK;status=Main_Control;beepshort(); ) ;
- break;
-
- //float retract_length=2, retract_feedrate=1200, retract_zlift=0.4;
- //float retract_recover_length=0, retract_recover_feedrate=500;
- case ItemR_autoretract:
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_AUTORETRACT);
- lcd.setCursor(13,line);
- if(autoretract_enabled)
- LCD_PRINT_PGM(MSG_ON);
- else
- LCD_PRINT_PGM(MSG_OFF);
- }
-
- if((activeline!=line) )
- break;
-
- if(LCD_CLICKED)
- {
- autoretract_enabled=!autoretract_enabled;
- lcd.setCursor(13,line);
- if(autoretract_enabled)
- LCD_PRINT_PGM(MSG_ON);
- else
- LCD_PRINT_PGM(MSG_OFF);
- LCD_BLOCK;
- }
-
- }break;
-
- case ItemR_retract_length:
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_CONTROL_RETRACT);
- lcd.setCursor(13,line);lcd.print(ftostr52(retract_length));
- }
-
- if((activeline!=line) )
- break;
-
- if(LCD_CLICKED)
- {
- linechanging=!linechanging;
- if(linechanging)
- {
- encoderpos=(long)(retract_length*100);
- }
- else
- {
- retract_length= encoderpos/100.;
- encoderpos=activeline*lcdslow;
-
- }
- LCD_BLOCK;
- beepshort();
- }
- if(linechanging)
- {
- if(encoderpos<1) encoderpos=1;
- if(encoderpos>990) encoderpos=990;
- lcd.setCursor(13,line);lcd.print(ftostr52(encoderpos/100.));
- }
-
- }break;
- case ItemR_retract_feedrate:
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_CONTROL_RETRACTF);
- lcd.setCursor(13,line);lcd.print(itostr4(retract_feedrate));
- }
-
- if((activeline!=line) )
- break;
-
- if(LCD_CLICKED)
- {
- linechanging=!linechanging;
- if(linechanging)
- {
- encoderpos=(long)(retract_feedrate/5);
- }
- else
- {
- retract_feedrate= encoderpos*5.;
- encoderpos=activeline*lcdslow;
-
- }
- LCD_BLOCK;
- beepshort();
- }
- if(linechanging)
- {
- if(encoderpos<1) encoderpos=1;
- if(encoderpos>990) encoderpos=990;
- lcd.setCursor(13,line);lcd.print(itostr4(encoderpos*5));
- }
-
- }break;
- case ItemR_retract_zlift://float retract_acceleration = 7000;
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_CONTROL_RETRACT_ZLIFT);
- lcd.setCursor(13,line);lcd.print(ftostr52(retract_zlift));;
- }
-
- if((activeline!=line) )
- break;
-
- if(LCD_CLICKED)
- {
- linechanging=!linechanging;
- if(linechanging)
- {
- encoderpos=(long)(retract_zlift*10);
- }
- else
- {
- retract_zlift= encoderpos/10.;
- encoderpos=activeline*lcdslow;
-
- }
- LCD_BLOCK;
- beepshort();
- }
- if(linechanging)
- {
- if(encoderpos<0) encoderpos=0;
- if(encoderpos>990) encoderpos=990;
- lcd.setCursor(13,line);lcd.print(ftostr52(encoderpos/10.));
- }
-
- }break;
- case ItemR_unretract_length:
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_CONTROL_RETRACT_RECOVER);
- lcd.setCursor(13,line);lcd.print(ftostr52(retract_recover_length));;
- }
-
- if((activeline!=line) )
- break;
-
- if(LCD_CLICKED)
- {
- linechanging=!linechanging;
- if(linechanging)
- {
- encoderpos=(long)(retract_recover_length*100);
- }
- else
- {
- retract_recover_length= encoderpos/100.;
- encoderpos=activeline*lcdslow;
-
- }
- LCD_BLOCK;
- beepshort();
- }
- if(linechanging)
- {
- if(encoderpos<0) encoderpos=0;
- if(encoderpos>990) encoderpos=990;
- lcd.setCursor(13,line);lcd.print(ftostr52(encoderpos/100.));
- }
-
- }break;
-
- case ItemR_unretract_feedrate:
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_CONTROL_RETRACT_RECOVERF);
- lcd.setCursor(13,line);lcd.print(itostr4(retract_recover_feedrate));
- }
-
- if((activeline!=line) )
- break;
-
- if(LCD_CLICKED)
- {
- linechanging=!linechanging;
- if(linechanging)
- {
- encoderpos=(long)retract_recover_feedrate/5;
- }
- else
- {
- retract_recover_feedrate= encoderpos*5.;
- encoderpos=activeline*lcdslow;
-
- }
- LCD_BLOCK;
- beepshort();
- }
- if(linechanging)
- {
- if(encoderpos<1) encoderpos=1;
- if(encoderpos>990) encoderpos=990;
- lcd.setCursor(13,line);lcd.print(itostr4(encoderpos*5));
- }
-
- }break;
-
- default:
- break;
- }
- line++;
- }
- updateActiveLines(ItemR_unretract_feedrate,encoderpos);
- #endif
- }
-
-
-
- enum {
- ItemC_exit,ItemC_temp,ItemC_move,
- #ifdef FWRETRACT
- ItemC_rectract,
- #endif
- ItemC_store, ItemC_load,ItemC_failsafe
- };
-
- void MainMenu::showControl()
- {
- uint8_t line=0;
- clearIfNecessary();
- for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
- {
- switch(i)
- {
- case ItemC_exit:
- MENUITEM( LCD_PRINT_PGM(MSG_MAIN_WIDE) , LCD_BLOCK;status=Main_Menu;beepshort(); ) ;
- break;
- case ItemC_temp:
- MENUITEM( LCD_PRINT_PGM(MSG_TEMPERATURE_WIDE) , LCD_BLOCK;status=Sub_TempControl;beepshort(); ) ;
- break;
- case ItemC_move:
- MENUITEM( LCD_PRINT_PGM(MSG_MOTION_WIDE) , LCD_BLOCK;status=Sub_MotionControl;beepshort(); ) ;
- break;
- #ifdef FWRETRACT
- case ItemC_rectract:
- MENUITEM( LCD_PRINT_PGM(MSG_RECTRACT_WIDE) , LCD_BLOCK;status=Sub_RetractControl;beepshort(); ) ;
- break;
- #endif
- case ItemC_store:
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_STORE_EPROM);
- }
- if((activeline==line) && LCD_CLICKED)
- {
- //enquecommand("M84");
- beepshort();
- LCD_BLOCK;
- Config_StoreSettings();
- }
- }break;
- case ItemC_load:
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_LOAD_EPROM);
- }
- if((activeline==line) && LCD_CLICKED)
- {
- //enquecommand("M84");
- beepshort();
- LCD_BLOCK;
- Config_RetrieveSettings();
- }
- }break;
- case ItemC_failsafe:
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_RESTORE_FAILSAFE);
- }
- if((activeline==line) && LCD_CLICKED)
- {
- //enquecommand("M84");
- beepshort();
- LCD_BLOCK;
- Config_ResetDefault();
- }
- }break;
- default:
- break;
- }
- line++;
- }
- updateActiveLines(ItemC_failsafe,encoderpos);
- }
-
-
-
-
-
- void MainMenu::showSD()
- {
- #ifdef SDSUPPORT
- uint8_t line=0;
-
- clearIfNecessary();
- static uint8_t nrfiles=0;
- if(force_lcd_update)
- {
- if(card.cardOK)
- {
- nrfiles=card.getnrfilenames();
- }
- else
- {
- nrfiles=0;
- lineoffset=0;
- }
- }
- bool enforceupdate=false;
- for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
- {
- switch(i)
- {
- case 0:
- MENUITEM( LCD_PRINT_PGM(MSG_MAIN) , LCD_BLOCK;status=Main_Menu;beepshort(); ) ;
- break;
- // case 1:
- // {
- // if(force_lcd_update)
- // {
- // lcd.setCursor(0,line);
- // if(CARDINSERTED)
- // {
- // LCD_PRINT_PGM(" \004Refresh");
- // }
- // else
- // {
- // LCD_PRINT_PGM(" \004Insert Card");
- // }
- //
- // }
- // if((activeline==line) && LCD_CLICKED)
- // {
- // LCD_BLOCK;
- // beepshort();
- // card.initsd();
- // force_lcd_update=true;
- // nrfiles=card.getnrfilenames();
- // }
- // }break;
- case 1:
- MENUITEM( lcd.print(" ");card.getWorkDirName();
- if(card.filename[0]=='/') LCD_PRINT_PGM(MSG_REFRESH);
- else {
- lcd.print("\005");
- lcd.print(card.filename);
- lcd.print("/..");
- } ,
- LCD_BLOCK;
- if(SDCARDDETECT == -1) card.initsd();
- card.updir();
- enforceupdate=true;
- lineoffset=0;
- beepshort(); ) ;
-
- break;
- default:
- {
- #define FIRSTITEM 2
- if(i-FIRSTITEM<nrfiles)
- {
- if(force_lcd_update)
- {
- card.getfilename(i-FIRSTITEM);
- //Serial.print("Filenr:");Serial.println(i-2);
- lcd.setCursor(0,line);LCD_PRINT_PGM(" ");
- if(card.filenameIsDir)
- {
- lcd.print("\005");
- card.longFilename[LCD_WIDTH-2] = '\0';
- }
- if (card.longFilename[0])
- {
- card.longFilename[LCD_WIDTH-1] = '\0';
- lcd.print(card.longFilename);
- }
- else
- {
- lcd.print(card.filename);
- }
- }
- if((activeline==line) && LCD_CLICKED)
- {
- LCD_BLOCK
- card.getfilename(i-FIRSTITEM);
- if(card.filenameIsDir)
- {
- for(uint8_t i=0;i<strlen(card.filename);i++)
- card.filename[i]=tolower(card.filename[i]);
- card.chdir(card.filename);
- lineoffset=0;
- enforceupdate=true;
- }
- else
- {
- char cmd[30];
- for(uint8_t i=0;i<strlen(card.filename);i++)
- card.filename[i]=tolower(card.filename[i]);
- sprintf(cmd,"M23 %s",card.filename);
- //sprintf(cmd,"M115");
- enquecommand(cmd);
- enquecommand("M24");
- beep();
- status=Main_Status;
- if (card.longFilename[0])
- {
- card.longFilename[LCD_WIDTH-1] = '\0';
- lcd_setstatus(card.longFilename);
- }
- else
- {
- lcd_setstatus(card.filename);
- }
- }
- }
- }
-
- }
- break;
- }
- line++;
- }
- updateActiveLines(FIRSTITEM+nrfiles-1,encoderpos);
- if(enforceupdate)
- {
- force_lcd_update=true;
- enforceupdate=false;
- }
- #endif
- }
-
-
- enum {ItemM_watch, ItemM_prepare, ItemM_control, ItemM_file, ItemM_pause};
- void MainMenu::showMainMenu()
- {
-
- #ifndef ULTIPANEL
- force_lcd_update=false;
- #endif
- if(tune)
- {
- if(!(movesplanned() || IS_SD_PRINTING))
- {
- force_lcd_update=true;
- tune=false;
- }
- }
- else
- {
- if(movesplanned() || IS_SD_PRINTING)
- {
- force_lcd_update=true;
- tune=true;
- }
- }
- clearIfNecessary();
- uint8_t line=0;
- for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
- {
- switch(i)
- {
- case ItemM_watch:
- MENUITEM( LCD_PRINT_PGM(MSG_WATCH) , LCD_BLOCK;status=Main_Status;beepshort(); ) ;
- break;
- case ItemM_prepare:
- MENUITEM( if(!tune) LCD_PRINT_PGM(MSG_PREPARE);else LCD_PRINT_PGM(MSG_TUNE); , LCD_BLOCK;status=Main_Prepare;beepshort(); ) ;
- break;
-
- case ItemM_control:
- MENUITEM( LCD_PRINT_PGM(MSG_CONTROL_ARROW) , LCD_BLOCK;status=Main_Control;beepshort(); ) ;
- break;
- #ifdef SDSUPPORT
- case ItemM_file:
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);
- if(IS_SD_INSERTED)
- {
- if(card.sdprinting)
- LCD_PRINT_PGM(MSG_STOP_PRINT);
- else
- LCD_PRINT_PGM(MSG_CARD_MENU);
- }
- else
- {
- LCD_PRINT_PGM(MSG_NO_CARD);
- }
- }
- if(IS_SD_INSERTED&&(activeline==line) && LCD_CLICKED)
- {
- card.printingHasFinished();
- LCD_BLOCK;
- status=Main_SD;
- beepshort();
- }
- }break;
- case ItemM_pause:
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);
- if(IS_SD_INSERTED)
- {
- if(card.sdprinting)
- LCD_PRINT_PGM(MSG_PAUSE_PRINT);
- else
- LCD_PRINT_PGM(MSG_RESUME_PRINT);
- }
- else
- {
- //LCD_PRINT_PGM(MSG_NO_CARD);
- }
- }
- if(IS_SD_INSERTED && (activeline==line) && LCD_CLICKED)
- {
- if(card.sdprinting)
- {
- card.pauseSDPrint();
- beepshort();
- status = Main_Status;
- }
- else
- {
- card.startFileprint();
- starttime=millis();
- beepshort();
- status = Main_Status;
- }
- }
- }break;
- #else
- case ItemM_file:
- break;
- case ItemM_pause:
- break;
- #endif
- default:
- SERIAL_ERROR_START;
- SERIAL_ERRORLNPGM(MSG_SERIAL_ERROR_MENU_STRUCTURE);
- break;
- }
- line++;
- }
-
- uint8_t numberOfLines = 4;
- #ifdef SDSUPPORT
- numberOfLines = 4;
- #else
- numberOfLines = 3;
- #endif
- updateActiveLines(numberOfLines,encoderpos);
- }
-
- void MainMenu::update()
- {
- static MainStatus oldstatus=Main_Menu; //init automatically causes foce_lcd_update=true
- static unsigned long timeoutToStatus=0;
- #if (SDCARDDETECT > -1)
- //This code is only relivant if you have an SDcard detect pin.
- static bool oldcardstatus=false;
- if((IS_SD_INSERTED != oldcardstatus))
- {
- force_lcd_update=true;
- oldcardstatus=IS_SD_INSERTED;
- lcd_init(); // to maybe revive the lcd if static electricty killed it.
- //Serial.println("echo: SD CHANGE");
- if(IS_SD_INSERTED)
- {
- card.initsd();
- LCD_MESSAGEPGM(MSG_SD_INSERTED);
- }
- else
- {
- card.release();
- LCD_MESSAGEPGM(MSG_SD_REMOVED);
- }
- }
- #endif
-
- if(status!=oldstatus)
- {
- force_lcd_update=true;
- encoderpos=0;
- lineoffset=0;
-
- oldstatus=status;
- }
- if( (encoderpos!=lastencoderpos) || LCD_CLICKED)
- timeoutToStatus=millis()+LCD_TIMEOUT_TO_STATUS;
-
- switch(status)
- {
- case Main_Status:
- {
- showStatus();
- if(LCD_CLICKED)
- {
- linechanging=false;
- LCD_BLOCK
- status=Main_Menu;
- timeoutToStatus=millis()+LCD_TIMEOUT_TO_STATUS;
- }
- }break;
- case Main_Menu:
- {
- showMainMenu();
- linechanging=false;
- }break;
- case Main_Prepare:
- {
- if(tune)
- {
- showTune();
- }
- else
- {
- showPrepare();
- }
- }break;
- case Sub_PrepareMove:
- {
- showAxisMove();
- }break;
- case Main_Control:
- {
- showControl();
- }break;
- case Sub_MotionControl:
- {
- showControlMotion();
- }break;
- case Sub_RetractControl:
- {
- showControlRetract();
- }break;
- case Sub_TempControl:
- {
- showControlTemp();
- }break;
- case Main_SD:
- {
- showSD();
- }break;
- case Sub_PreheatPLASettings:
- {
- showPLAsettings();
- }break;
- case Sub_PreheatABSSettings:
- {
- showABSsettings();
- }break;
- }
-
- if(timeoutToStatus<millis())
- status=Main_Status;
- //force_lcd_update=false;
- lastencoderpos=encoderpos;
- }
-
- enum {
- ItemPLAPreHeat_Exit,
- ItemPLAPreHeat_set_PLA_FanSpeed,
- ItemPLAPreHeat_set_nozzle,
- ItemPLAPreHeat_set_HPB,
- ItemPLAPreHeat_Store_Eprom
- };
-
- void MainMenu::showPLAsettings()
- {
- #ifdef ULTIPANEL
- uint8_t line=0;
- clearIfNecessary();
- for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
- {
- switch(i)
- {
-
- case ItemPLAPreHeat_Exit:
- MENUITEM( LCD_PRINT_PGM(MSG_TEMPERATURE_RTN) , LCD_BLOCK;status=Sub_TempControl;beepshort(); ) ;
- break;
-
- case ItemPLAPreHeat_set_PLA_FanSpeed:
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_FAN_SPEED);
- lcd.setCursor(13,line);lcd.print(ftostr3(plaPreheatFanSpeed));
- }
-
- if((activeline!=line) )
- break;
-
- if(LCD_CLICKED)
- {
- linechanging=!linechanging;
- if(linechanging)
- {
- encoderpos=plaPreheatFanSpeed;
- }
- else
- {
- encoderpos=activeline*lcdslow;
- beepshort();
- }
- LCD_BLOCK;
- }
- if(linechanging)
- {
- if(encoderpos<0) encoderpos=0;
- if(encoderpos>255) encoderpos=255;
- plaPreheatFanSpeed=encoderpos;
- lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
- }
- }break;
-
- case ItemPLAPreHeat_set_nozzle:
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_NOZZLE);
- lcd.setCursor(13,line);lcd.print(ftostr3(plaPreheatHotendTemp));
- }
-
- if((activeline!=line) )
- break;
-
- if(LCD_CLICKED)
- {
- linechanging=!linechanging;
- if(linechanging)
- {
- encoderpos=plaPreheatHotendTemp;
- }
- else
- {
- encoderpos=activeline*lcdslow;
- beepshort();
- }
- LCD_BLOCK;
- }
- if(linechanging)
- {
- if(encoderpos<0) encoderpos=0;
- if(encoderpos>260) encoderpos=260;
- plaPreheatHotendTemp = encoderpos;
- lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
- }
- }break;
-
- case ItemPLAPreHeat_set_HPB:
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_BED);
- lcd.setCursor(13,line);lcd.print(ftostr3(plaPreheatHPBTemp));
- }
-
- if((activeline!=line) )
- break;
-
- if(LCD_CLICKED)
- {
- linechanging=!linechanging;
- if(linechanging)
- {
- encoderpos=plaPreheatHPBTemp;
- }
- else
- {
- encoderpos=activeline*lcdslow;
- beepshort();
- }
- LCD_BLOCK;
- }
- if(linechanging)
- {
- if(encoderpos<0) encoderpos=0;
- if(encoderpos>250) encoderpos=150;
- plaPreheatHPBTemp = encoderpos;
- lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
- }
- }break;
- case ItemPLAPreHeat_Store_Eprom:
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_STORE_EPROM);
- }
- if((activeline==line) && LCD_CLICKED)
- {
- //enquecommand("M84");
- beepshort();
- LCD_BLOCK;
- Config_StoreSettings();
- }
- }break;
- default:
- break;
- }
- line++;
- }
- updateActiveLines(ItemPLAPreHeat_Store_Eprom,encoderpos);
- #endif
- }
-
- enum {
- ItemABSPreHeat_Exit,
- ItemABSPreHeat_set_FanSpeed,
- ItemABSPreHeat_set_nozzle,
- ItemABSPreHeat_set_HPB,
- ItemABSPreHeat_Store_Eprom
- };
-
- void MainMenu::showABSsettings()
- {
- #ifdef ULTIPANEL
- uint8_t line=0;
- clearIfNecessary();
- for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
- {
- switch(i)
- {
-
- case ItemABSPreHeat_Exit:
- MENUITEM( LCD_PRINT_PGM(MSG_TEMPERATURE_RTN) , LCD_BLOCK;status=Sub_TempControl;beepshort(); ) ;
- break;
-
- case ItemABSPreHeat_set_FanSpeed:
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_FAN_SPEED);
- lcd.setCursor(13,line);lcd.print(ftostr3(absPreheatFanSpeed));
- }
-
- if((activeline!=line) )
- break;
-
- if(LCD_CLICKED)
- {
- linechanging=!linechanging;
- if(linechanging)
- {
- encoderpos=absPreheatFanSpeed;
- }
- else
- {
- encoderpos=activeline*lcdslow;
- beepshort();
- }
- LCD_BLOCK;
- }
- if(linechanging)
- {
- if(encoderpos<0) encoderpos=0;
- if(encoderpos>255) encoderpos=255;
- absPreheatFanSpeed=encoderpos;
- lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
- }
- }break;
-
- case ItemABSPreHeat_set_nozzle:
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_NOZZLE);
- lcd.setCursor(13,line);lcd.print(ftostr3(absPreheatHotendTemp));
- }
-
- if((activeline!=line) )
- break;
-
- if(LCD_CLICKED)
- {
- linechanging=!linechanging;
- if(linechanging)
- {
- encoderpos=absPreheatHotendTemp;
- }
- else
- {
- encoderpos=activeline*lcdslow;
- beepshort();
- }
- LCD_BLOCK;
- }
- if(linechanging)
- {
- if(encoderpos<0) encoderpos=0;
- if(encoderpos>260) encoderpos=260;
- absPreheatHotendTemp = encoderpos;
- lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
- }
- }break;
-
- case ItemABSPreHeat_set_HPB:
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_BED);
- lcd.setCursor(13,line);lcd.print(ftostr3(absPreheatHPBTemp));
- }
-
- if((activeline!=line) )
- break;
-
- if(LCD_CLICKED)
- {
- linechanging=!linechanging;
- if(linechanging)
- {
- encoderpos=absPreheatHPBTemp;
- }
- else
- {
- encoderpos=activeline*lcdslow;
- beepshort();
- }
- LCD_BLOCK;
- }
- if(linechanging)
- {
- if(encoderpos<0) encoderpos=0;
- if(encoderpos>250) encoderpos=150;
- absPreheatHPBTemp = encoderpos;
- lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
- }
- }break;
- case ItemABSPreHeat_Store_Eprom:
- {
- if(force_lcd_update)
- {
- lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_STORE_EPROM);
- }
- if((activeline==line) && LCD_CLICKED)
- {
- //enquecommand("M84");
- beepshort();
- LCD_BLOCK;
- Config_StoreSettings();
- }
- }break;
- default:
- break;
- }
- line++;
- }
- updateActiveLines(ItemABSPreHeat_Store_Eprom,encoderpos);
- #endif
- }
-
- //**********************************************************************************************************
- // convert float to string with +123.4 format
- char *ftostr3(const float &x)
- {
- //sprintf(conv,"%5.1f",x);
- int xx=x;
- conv[0]=(xx/100)%10+'0';
- conv[1]=(xx/10)%10+'0';
- conv[2]=(xx)%10+'0';
- conv[3]=0;
- return conv;
- }
-
- char *itostr2(const uint8_t &x)
- {
- //sprintf(conv,"%5.1f",x);
- int xx=x;
- conv[0]=(xx/10)%10+'0';
- conv[1]=(xx)%10+'0';
- conv[2]=0;
- return conv;
- }
-
- // convert float to string with +123.4 format
- char *ftostr31(const float &x)
- {
- int xx=x*10;
- conv[0]=(xx>=0)?'+':'-';
- xx=abs(xx);
- conv[1]=(xx/1000)%10+'0';
- conv[2]=(xx/100)%10+'0';
- conv[3]=(xx/10)%10+'0';
- conv[4]='.';
- conv[5]=(xx)%10+'0';
- conv[6]=0;
- return conv;
- }
-
- char *ftostr32(const float &x)
- {
- long xx=x*100;
- conv[0]=(xx>=0)?'+':'-';
- xx=abs(xx);
- conv[1]=(xx/100)%10+'0';
- conv[2]='.';
- conv[3]=(xx/10)%10+'0';
- conv[4]=(xx)%10+'0';
- conv[6]=0;
- return conv;
- }
-
- char *itostr31(const int &xx)
- {
- conv[0]=(xx>=0)?'+':'-';
- conv[1]=(xx/1000)%10+'0';
- conv[2]=(xx/100)%10+'0';
- conv[3]=(xx/10)%10+'0';
- conv[4]='.';
- conv[5]=(xx)%10+'0';
- conv[6]=0;
- return conv;
- }
-
- char *itostr3(const int &xx)
- {
- conv[0]=(xx/100)%10+'0';
- conv[1]=(xx/10)%10+'0';
- conv[2]=(xx)%10+'0';
- conv[3]=0;
- return conv;
- }
-
- char *itostr4(const int &xx)
- {
- conv[0]=(xx/1000)%10+'0';
- conv[1]=(xx/100)%10+'0';
- conv[2]=(xx/10)%10+'0';
- conv[3]=(xx)%10+'0';
- conv[4]=0;
- return conv;
- }
-
- // convert float to string with +1234.5 format
- char *ftostr51(const float &x)
- {
- long xx=x*10;
- conv[0]=(xx>=0)?'+':'-';
- xx=abs(xx);
- conv[1]=(xx/10000)%10+'0';
- conv[2]=(xx/1000)%10+'0';
- conv[3]=(xx/100)%10+'0';
- conv[4]=(xx/10)%10+'0';
- conv[5]='.';
- conv[6]=(xx)%10+'0';
- conv[7]=0;
- return conv;
- }
-
- // convert float to string with +123.45 format
- char *ftostr52(const float &x)
- {
- long xx=x*100;
- conv[0]=(xx>=0)?'+':'-';
- xx=abs(xx);
- conv[1]=(xx/10000)%10+'0';
- conv[2]=(xx/1000)%10+'0';
- conv[3]=(xx/100)%10+'0';
- conv[4]='.';
- conv[5]=(xx/10)%10+'0';
- conv[6]=(xx)%10+'0';
- conv[7]=0;
- return conv;
- }
-
- #endif //ULTRA_LCD
-
|